ReadFramework
WriterRetrieval.h
Go to the documentation of this file.
1 /*******************************************************************************************************
2  ReadFramework is the basis for modules developed at CVL/TU Wien for the EU project READ.
3 
4  Copyright (C) 2016 Markus Diem <diem@caa.tuwien.ac.at>
5  Copyright (C) 2016 Stefan Fiel <fiel@caa.tuwien.ac.at>
6  Copyright (C) 2016 Florian Kleber <kleber@caa.tuwien.ac.at>
7 
8  This file is part of ReadFramework.
9 
10  ReadFramework is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  ReadFramework is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23  The READ project has received funding from the European Union’s Horizon 2020
24  research and innovation programme under grant agreement No 674943
25 
26  related links:
27  [1] http://www.caa.tuwien.ac.at/cvl/
28  [2] https://transkribus.eu/Transkribus/
29  [3] https://github.com/TUWien/
30  [4] http://nomacs.org
31  *******************************************************************************************************/
32 
33 #pragma once
34 
35 
36 #include "BaseModule.h"
37 #include "WriterDatabase.h"
38 
39 
40 #pragma warning(push, 0) // no warnings from includes
41 // Qt Includes
42 #include <QVector>
43 #include <opencv2/imgproc.hpp>
44 #include <QSettings>
45 #pragma warning(pop)
46 
47 #ifndef DllCoreExport
48 #ifdef DLL_CORE_EXPORT
49 #define DllCoreExport Q_DECL_EXPORT
50 #else
51 #define DllCoreExport Q_DECL_IMPORT
52 #endif
53 #endif
54 
55 #pragma warning(disable: 4251) // dll interface
56 
57 // Qt defines
58 
59 
60 namespace rdf {
62  public:
64 
65  QString vocabularyPath() const;
66  void setVocabularyPath(QString path);
67 
68  QString featureDirectory() const;
69  void setFeatureDirectory(QString dir);
70 
71  QString evalPath() const;
72  void setEvalPath(QString path);
73 
74  QString toString() const override;
75 
76  protected:
77  void load(const QSettings& settings) override;
78  void save(QSettings& settings) const override;
79 
80  private:
81  QString mVocPath = "";
82  QString mFeatureDir = "sift";
83  QString mEvalPath = "";
84  };
85 
86 
88  public:
89  WriterRetrieval(cv::Mat img);
90 
91  bool compute() override;
92  QSharedPointer<WriterRetrievalConfig> config() const;
93  cv::Mat getFeature();
94 
95  void setXmlPath(std::string xmlPath);
96 
97  cv::Mat draw(const cv::Mat& img) const;
98  QString toString() const override;
99 
100  private:
101 
102  bool checkInput() const override;
103  cv::Mat mImg;
104  cv::Mat mFeature;
105 
106  cv::Mat mDesc = cv::Mat();
107  QVector<cv::KeyPoint> mKeyPoints;
108 
109  QString mXmlPath = "";
110 
111  WriterVocabulary mVoc;
112  };
113 
115 
116  public:
117  WriterImage();
118 
119  void setImage(cv::Mat img);
120  void setMask(cv::Mat mask);
121  void calculateFeatures();
122  void saveFeatures(QString filePath);
123  void loadFeatures(QString filePath);
124 
125 
126  void setKeyPoints(QVector<cv::KeyPoint> kp);
127  QVector<cv::KeyPoint> keyPoints() const;
128  void setDescriptors(cv::Mat desc);
129  cv::Mat descriptors() const;
130 
131  void filterKeyPoints(int minSize, int maxSize);
132  void filterKeyPointsPoly(QVector<QPolygonF> polys);
133 
134  private:
135  QString debugName();
136 
137  cv::Mat mImg;
138  cv::Mat mMask = cv::Mat();
139  cv::Mat mDescriptors;
140  QVector<cv::KeyPoint> mKeyPoints;
141 
142  };
143 
144 
145 }
Definition: BaseModule.h:63
#define DllCoreExport
Definition: BaseImageElement.h:43
Definition: WriterRetrieval.h:87
config
Definition: DependencyCollector.py:271
Definition: WriterRetrieval.h:114
Definition: WriterDatabase.h:108
DllCoreExport bool save(const QImage &img, const QString &savePath, int compression=-1)
Saves the specified QImage img.
Definition: Image.cpp:180
Definition: WriterRetrieval.h:61
DllCoreExport QImage load(const QString &path, bool *ok=0)
Definition: Image.cpp:152
This is the base class for all modules. It provides all functions which are implemented by the module...
Definition: BaseModule.h:126
Definition: Algorithms.cpp:45