Read@CVL
TabStopAnalysis.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 #include "BaseModule.h"
36 #include "Pixel.h"
37 #include "PixelSet.h"
38 
39 #pragma warning(push, 0) // no warnings from includes
40 // Qt Includes
41 #pragma warning(pop)
42 
43 #ifndef DllCoreExport
44 #ifdef DLL_CORE_EXPORT
45 #define DllCoreExport Q_DECL_EXPORT
46 #else
47 #define DllCoreExport Q_DECL_IMPORT
48 #endif
49 #endif
50 
51 // Qt defines
52 
53 namespace rdf {
54 
55 // read defines
56 
58 
59 public:
60  TabStopConfig();
61 
62  virtual QString toString() const override;
63 
64 protected:
65 
66  //void load(const QSettings& settings) override;
67  //void save(QSettings& settings) const override;
68 };
69 
71 
72 public:
73  TabStopCluster(const QSharedPointer<PixelSet>& ps);
74 
75  void setLine(const Line& line);
76  Line line() const;
77  QSharedPointer<PixelSet> set() const;
78 
79  void setAngle(double angle);
80  double angle() const;
81 
82  void draw(QPainter& p) const;
83 
84 private:
85  QSharedPointer<PixelSet> mSet;
86  Line mLine;
87  double mMedAngle;
88 };
89 
91 
92 public:
93  TabStopAnalysis(const PixelSet& set = PixelSet());
94 
95  bool isEmpty() const override;
96  bool compute() override;
97  QSharedPointer<TabStopConfig> config() const;
98 
99  cv::Mat draw(const cv::Mat& img) const;
100  QString toString() const override;
101 
102  // getter
103  QVector<QSharedPointer<TabStopCluster> > tabStopClusters() const;
104  QVector<Line> tabStopLines(double offset = 0.0) const;
105 
106 private:
107  PixelSet mSet;
108  QSharedPointer<PixelGraph> mGraph;
109 
110  QVector<QSharedPointer<TabStopCluster> > mTabStops;
111 
112  bool checkInput() const override;
113 
114  // find tabs
115  QVector<QSharedPointer<Pixel> > findTabStopCandidates(const QSharedPointer<PixelGraph>& graph) const;
116  QVector<QSharedPointer<TabStopCluster> > findTabs(const QVector<QSharedPointer<Pixel> >& pixel) const;
117  double medianOrientation(const PixelSet& set) const;
118  void updateTabStopCandidates(const PixelSet& set, double orientation, const PixelTabStop::Type& newType = PixelTabStop::type_none) const;
119 };
120 
121 }
Definition: BaseModule.h:63
Type
Definition: Pixel.h:160
Definition: TabStopAnalysis.h:57
#define DllCoreExport
Definition: BaseImageElement.h:43
PixelSet stores and manipulates pixel collections.
Definition: PixelSet.h:172
Definition: TabStopAnalysis.h:70
Definition: TabStopAnalysis.h:90
config
Definition: DependencyCollector.py:271
Definition: Pixel.h:161
A basic line class including stroke width (thickness).
Definition: Shapes.h:68
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