38 #pragma warning(push, 0) // no warnings from includes 41 #include <opencv2/core.hpp> 58 double distThreshold()
const;
59 void setDistThreshold(
double d);
61 double errorThr()
const;
62 void setErrorThr(
double e);
64 double variationThrLower()
const;
65 void setVariationThrLower(
double v);
67 double variationThrUpper()
const;
68 void setVariationThrUpper(
double v);
70 double coLinearityThr()
const;
71 void setCoLinearityThr(
double c);
76 bool saveChilds()
const;
77 void setSaveChilds(
bool c);
79 QString templDatabase()
const;
80 void setTemplDatabase(QString s);
82 QString evalPath()
const;
83 void setevalPath(QString s);
85 QString toString()
const override;
88 void load(
const QSettings& settings)
override;
89 void save(QSettings& settings)
const override;
92 QString mTemplDatabase = QString(
"C:\\Users\\flo\\projects\\READ\\formTest\\form - gt\\Table_Template_M_Freyung_014_01\\page\\M_Freyung_014 - 01_0112.xml");
93 QString mEvalPath = QString(
"C:\\Users\\flo\\projects\\READ\\formTest\\form - gt\\Table_Template_M_Freyung_014_01\\page\\");
97 double mDistThreshold = 200.0;
98 double mColinearityThreshold = 20;
99 double mErrorThr = 15.0;
100 double mVariationThrLower = 0.2;
101 double mVariationThrUpper = 0.3;
103 bool mSaveChilds =
false;
128 void setReferenceLine(
Line l);
129 Line referenceLine()
const;
131 int getRowIdx()
const;
132 int getColIdx()
const;
133 void setLineCell(
int rowIdx,
int colIdx);
137 void setSpan(
int rowSpan,
int colSpan);
139 void setMatchedLine(
Line l);
140 void setMatchedLine(
Line l,
double overlap,
double distance);
141 Line matchedLine()
const;
142 double overlap()
const;
143 double distance()
const;
145 void addBrokenLine(
Line l,
int lineIdx);
146 bool brokenLinesPresent()
const;
147 QVector<Line> brokenLines()
const;
148 QVector<int> brokenLinesIdx()
const;
150 void setMatchedLineIdx(
int idx);
151 int matchedLineIdx()
const;
153 void setCellIdx(
int idx);
156 void setNeighbourCellIdx(QVector<int> n);
157 QVector<int> neighbourCellIDx();
161 QVector<int> adjacencyNodes()
const;
164 void addAdjacencyNode(
int idx);
165 bool testAdjacency(QSharedPointer<AssociationGraphNode> neighbour,
double distThreshold = 20,
double variationThrLower = 0.2,
double variationThrUpper = 0.2);
166 void clearAdjacencyList();
171 static bool compareNodes(
const QSharedPointer<rdf::AssociationGraphNode> n1,
const QSharedPointer<rdf::AssociationGraphNode> n2);
191 double mOverlap = -1;
192 double mDistance = -1;
204 void setSize(cv::Size s);
205 bool setTemplate(QString templateName);
206 void setTable(QSharedPointer<rdf::TableRegion> table);
207 cv::Mat computeTableImage(QSharedPointer<rdf::TableRegion> table,
bool mergeCells =
false);
208 void computeEvalCells();
209 void computeEvalTableRegion();
211 double tableJaccard();
214 QVector<double> cellJaccards();
215 double meanCellJaccard();
216 QVector<double> cellMatches();
217 double meanCellMatch();
219 double missedCells(
double threshold = 0.2);
220 double underSegmented(
double threshold = 0.2);
221 QVector<double> underSegmentedC();
232 double mCellsTemplate = -1;
233 double mCellsMatched = -1;
251 FormFeatures(
const cv::Mat& img,
const cv::Mat& mask = cv::Mat());
253 void setInputImg(
const cv::Mat& img);
254 void setMask(
const cv::Mat& mask);
255 bool isEmpty()
const override;
256 bool compute()
override;
257 bool computeBinaryInput();
266 bool readTemplate(QSharedPointer<rdf::FormFeatures> templateForm);
267 bool estimateRoughAlignment(
bool useBinaryImg =
false);
268 cv::Mat drawAlignment(cv::Mat img = cv::Mat());
269 cv::Mat drawMatchedForm(cv::Mat img = cv::Mat(),
float t = 10.0);
270 cv::Mat drawLinesNotUsedForm(cv::Mat img = cv::Mat(),
float t = 10.0);
271 cv::Mat drawLines(cv::Mat img = cv::Mat(),
float t = 10.0);
272 cv::Mat drawMaxClique(cv::Mat img = cv::Mat(),
float t = 10.0,
int idx = 0);
274 QSharedPointer<rdf::TableRegion> tableRegion();
275 QSharedPointer<rdf::TableRegion> tableRegionTemplate();
276 QVector<QSharedPointer<rdf::TableCellRaw>> createRawTableFromTemplate();
277 void createAssociationGraphNodes(QVector<QSharedPointer<rdf::TableCellRaw>> cellsR);
278 void createReducedAssociationGraphNodes(QVector<QSharedPointer<rdf::TableCellRaw>> cellsR);
279 QVector<QSharedPointer<rdf::AssociationGraphNode>> mergeColinearNodes(QVector<QSharedPointer<rdf::AssociationGraphNode>> &tmpNodes);
280 void createAssociationGraph();
281 bool** adjacencyMatrix(
const QVector<QSharedPointer<rdf::AssociationGraphNode>> &associationGraphNodes);
282 void findMaxCliques();
283 void createTableFromMaxClique(
const QVector<QSharedPointer<rdf::TableCell>> &cells);
284 void createTableFromMaxCliqueReduced(
const QVector<QSharedPointer<rdf::TableCell>> &cells);
287 QVector<QSet<int>> getMaxCliqueHor()
const;
288 QVector<QSet<int>> getMaxCliqueVer()
const;
291 bool matchTemplate();
296 double findMinWidth(QVector<QSharedPointer<rdf::TableCellRaw>> cellsR,
int cellIdx,
int neighbour);
298 void createCellfromLineCandidates(QVector<QSharedPointer<rdf::TableCellRaw>> cellsR);
300 bool isEmptyLines()
const;
301 bool isEmptyTable()
const;
303 bool setTemplateName(QString s);
304 QString templateName()
const;
306 cv::Size sizeImg()
const;
307 void setSize(cv::Size s);
308 QVector<rdf::Line> horLines()
const;
309 void setHorLines(
const QVector<rdf::Line>& h);
310 QVector<rdf::Line> verLines()
const;
311 void setVerLines(
const QVector<rdf::Line>& v);
313 QVector<rdf::Line> usedHorLines()
const;
314 QVector<rdf::Line> notUsedHorLines()
const;
315 QVector<rdf::Line> filterHorLines(
double minOverlap = 0.1,
double distThreshold=20)
const;
316 QVector<rdf::Line> useVerLines()
const;
317 QVector<rdf::Line> notUseVerLines()
const;
318 QVector<rdf::Line> filterVerLines(
double minOverlap = 0.1,
double distThreshold=20)
const;
320 double lineDistance(
rdf::Line templateLine,
rdf::Line formLine,
double minOverlap = 0.1,
bool horizontal =
true);
322 cv::Point offset()
const;
323 double error()
const;
325 QSharedPointer<FormFeaturesConfig>
config()
const;
326 void setConfig(QSharedPointer<FormFeaturesConfig> c);
328 cv::Mat binaryImage()
const;
329 void setEstimateSkew(
bool s);
333 QString toString()
const override;
335 void setFormName(QString s);
336 QString formName()
const;
339 void setCells(QVector<QSharedPointer<rdf::TableCell>> c);
340 QVector<QSharedPointer<rdf::TableCell>> cells()
const;
341 void setRegion(QSharedPointer<rdf::TableRegion> r);
342 QSharedPointer<rdf::TableRegion> region()
const;
343 void setSeparators(QSharedPointer<rdf::Region> r);
358 bool mEstimateSkew =
false;
359 bool mPreFilter =
true;
360 int preFilterArea = 10;
361 double mPageAngle = 0.0;
362 double mMinError = std::numeric_limits<double>::max();
364 QVector<rdf::Line> mHorLines;
365 QVector<int> mUsedHorLineIdx;
366 QVector<rdf::Line> mVerLines;
367 QVector<int> mUsedVerLineIdx;
369 QVector<QSharedPointer<rdf::AssociationGraphNode>> mANodesHorizontal;
370 QVector<QSharedPointer<rdf::AssociationGraphNode>> mANodesVertical;
375 QVector<QSet<int>> mMaxCliquesHor;
376 QVector<QSet<int>> mMaxCliquesVer;
379 QSharedPointer<rdf::FormFeatures> mTemplateForm;
383 cv::Point mOffset = cv::Point(0,0);
388 bool checkInput()
const override;
390 QString mTemplateName;
392 QVector<QSharedPointer<rdf::TableCell>> mCells;
393 QSharedPointer<rdf::TableRegion> mRegion;
396 QVector<QSharedPointer<rdf::TableCellRaw>> mCellsR;
Line mReferenceLine
Definition: FormAnalysis.h:176
Definition: BaseModule.h:63
QVector< int > mBrokenLinesIdx
Definition: FormAnalysis.h:189
#define DllCoreExport
Definition: BaseImageElement.h:43
LinePosition mLinePos
Definition: FormAnalysis.h:177
QVector< int > mAdjacencyNodesIdx
Definition: FormAnalysis.h:194
Line mMatchedLine
Definition: FormAnalysis.h:184
LinePosition
Definition: FormAnalysis.h:115
QSet< int > mAn
Definition: FormAnalysis.h:195
bool operator<(const PixelEdge &pe1, const PixelEdge &pe2)
Definition: Pixel.cpp:537
config
Definition: DependencyCollector.py:271
A basic line class including stroke width (thickness).
Definition: Shapes.h:68
DllCoreExport bool save(const QImage &img, const QString &savePath, int compression=-1)
Saves the specified QImage img.
Definition: Image.cpp:180
int mMatchedLineIdx
Definition: FormAnalysis.h:185
DllCoreExport QImage load(const QString &path, bool *ok=0)
Definition: Image.cpp:152
Definition: FormAnalysis.h:117
QVector< int > mMergedNeighbourCells
Definition: FormAnalysis.h:175
QVector< Line > mBrokenLines
Definition: FormAnalysis.h:188
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
Definition: FormAnalysis.h:111
Definition: FormAnalysis.h:118