Read@CVL
SkewPlugin.h
Go to the documentation of this file.
1 /*******************************************************************************************************
2 ReadModules are plugins for nomacs 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 ReadModules.
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 #include "DkPluginInterface.h"
36 #include "DkBatchInfo.h"
37 
38 // RDF includes
39 #include "SkewEstimation.h"
40 
41 class QSettings;
42 
43 
44 // opencv defines
45 namespace cv {
46  class Mat;
47 }
48 
49 namespace rdm {
50 
51 
52 class SkewInfo : public nmc::DkBatchInfo {
53 
54 public:
55  SkewInfo(const QString& id = QString(), const QString& filePath = QString());
56 
57  void setProperty(const QString& p);
58  QString property() const;
59 
60  void setSkew(const double skew);
61  double skew() const;
62 
63  void setSkewGt(const double skew);
64  double skewGt() const;
65 
66 private:
67  QString mProp;
68  double mSkew;
69  double mSkewGt;
70 
71 };
72 
73 class SkewEstPlugin : public QObject, nmc::DkBatchPluginInterface {
74  Q_OBJECT
75  Q_INTERFACES(nmc::DkBatchPluginInterface)
76  Q_PLUGIN_METADATA(IID "com.nomacs.ImageLounge.SkewPlugin/5.1" FILE "SkewPlugin.json")
77 
78 public:
79  SkewEstPlugin(QObject* parent = 0);
80  ~SkewEstPlugin();
81 
82  QString id() const override;
83  QImage image() const override;
84 
85  QList<QAction*> createActions(QWidget* parent) override;
86  QList<QAction*> pluginActions() const override;
87  QSharedPointer<nmc::DkImageContainer> runPlugin(
88  const QString &runID,
89  QSharedPointer<nmc::DkImageContainer> imgC,
90  const nmc::DkSaveInfo& saveInfo,
91  QSharedPointer<nmc::DkBatchInfo>& info) const override;
92 
93  void preLoadPlugin() const override;
94  void postLoadPlugin(const QVector<QSharedPointer<nmc::DkBatchInfo> >& batchInfo) const override;
95 
96  void setFilePath(QString fp);
97  QString filePath() const;
98 
99  enum RunID {
104  // add actions here
105 
106  id_end
107  };
108 
109 protected:
110  QList<QAction*> mActions;
111  QStringList mRunIDs;
112  QStringList mMenuNames;
113  QStringList mMenuStatusTips;
114 
115  QString mFilePath;
117 
118  double mMinAngle = -CV_PI/2.0;
119  double mMaxAngle = CV_PI/2.0;
120 
121 private:
122  void init();
123  void loadSettings(QSettings& settings);
124  void saveSettings(QSettings& settings) const;
125 
126  void skewNative(QSharedPointer<nmc::DkImageContainer>& imgC, QSharedPointer<SkewInfo>& skewInfo) const;
127  void skewDoc(QSharedPointer<nmc::DkImageContainer>& imgC, QSharedPointer<SkewInfo>& skewInfo) const;
128  void skewTextLine(QSharedPointer<nmc::DkImageContainer>& imgC, QSharedPointer<SkewInfo>& skewInfo, const QString& runId) const;
129  void parseGT(const QString& fileName, double skewAngle, QSharedPointer<SkewInfo>& skewInfo) const;
130 };
131 };
Definition: SkewPlugin.h:100
QStringList mMenuNames
Definition: SkewPlugin.h:112
QList< QAction * > mActions
Definition: SkewPlugin.h:110
Definition: Drawer.h:53
Definition: SkewEstimation.h:63
QStringList mRunIDs
Definition: SkewPlugin.h:111
QStringList mMenuStatusTips
Definition: SkewPlugin.h:113
Definition: SkewPlugin.h:52
RunID
Definition: SkewPlugin.h:99
rdf::BaseSkewEstimationConfig mBseConfig
Definition: SkewPlugin.h:116
Definition: SkewPlugin.h:103
Definition: SkewPlugin.h:102
Definition: SkewPlugin.h:101
Definition: BatchTest.cpp:45
Definition: SkewPlugin.h:73
QString mFilePath
Definition: SkewPlugin.h:115