35 #pragma warning(push, 0) // no warnings from includes 39 #include <QSharedPointer> 41 #include <opencv2/core.hpp> 45 #ifdef DLL_CORE_EXPORT 46 #define DllCoreExport Q_DECL_EXPORT 48 #define DllCoreExport Q_DECL_IMPORT 52 #pragma warning(disable: 4251) // dll interface warning 71 Line(
const QLineF& line = QLineF(),
float thickness = 1);
73 Line(
const cv::Point p1,
const cv::Point p2,
float thickness = 1);
75 Line(
double p1x,
double p1y,
double p2x,
double p2y,
float thickness = 1);
78 void sortEndpoints(
bool horizontal =
true);
79 void setLine(
const QLineF& line,
float thickness = 1);
80 void setThickness(
float thickness);
81 float thickness()
const;
82 double squaredLength()
const;
83 double length()
const;
84 double weightedLength(
const Vector2D& orVec)
const;
86 double minDistance(
const Line &l)
const;
88 void translate(cv::Point offset);
91 double distance(
const Vector2D& p)
const;
92 double horizontalOverlap(
const Line& l)
const;
93 double horizontalDistance(
const Line& l,
double threshold = 20)
const;
94 double verticalOverlap(
const Line& l)
const;
95 double verticalDistance(
const Line& l,
double threshold = 20)
const;
100 double diffAngle(
const Line& l)
const;
101 bool within(
const Vector2D& p)
const;
108 QLineF qLine()
const;
109 QPolygonF toPoly()
const;
111 bool isHorizontal(
double mAngleTresh = 0.5)
const;
112 bool isVertical(
double mAngleTresh = 0.5)
const;
113 bool isColinear(
const Line& line,
double threshold = 20)
const;
114 bool isClose(
const Line& line,
double threshold = 20)
const;
115 bool intersects(
const Line& line, QLineF::IntersectType t = QLineF::BoundedIntersection)
const;
117 Vector2D intersection(
const Line& line, QLineF::IntersectType t = QLineF::BoundedIntersection)
const;
118 Vector2D intersectionUnrestricted(
const Line& line)
const;
121 void draw(QPainter& p)
const;
122 Line extendBorder(
const Rect& box)
const;
124 static bool lessX1(
const Line& l1,
const Line& l2);
125 static bool lessY1(
const Line& l1,
const Line& l2);
129 float mThickness = 1;
131 cv::Mat toMat(
const Line& l)
const;
152 return l.
mX == r.
mX && l.
mY == r.
mY;
236 inline double x()
const {
241 inline double y()
const {
247 QPoint toQPoint()
const;
248 QPointF toQPointF()
const;
249 QSize toQSize()
const;
250 QSizeF toQSizeF()
const;
252 cv::Point toCvPoint()
const;
253 cv::Point2d toCvPoint2d()
const;
254 cv::Point2f toCvPoint2f()
const;
255 cv::Size toCvSize()
const;
256 cv::Mat toMatRow()
const;
257 cv::Mat toMatCol()
const;
259 QString toString()
const;
261 void draw(QPainter& p)
const;
263 double angle()
const;
264 double sqLength()
const;
265 double length()
const;
266 void rotate(
double angle);
267 double theta(
const Vector2D& o)
const;
269 bool isNeighbor(
const Vector2D& other,
double radius)
const;
284 void setLine(
double x1,
double y1,
double x2,
double y2,
double width);
285 void setLine(
Line l);
287 void setCenter(
double x,
double y);
288 double theta()
const;
289 void setTheta(
double t);
291 void setOrientation(
double dx,
double dy);
293 void setPrec(
double p);
296 double length()
const;
297 void setLength(
double l);
302 bool doubleEqual(
double a,
double b);
303 double interLow(
double x,
double x1,
double y1,
double x2,
double y2);
304 double interHigh(
double x,
double x1,
double y1,
double x2,
double y2);
327 void setVec(
const cv::Vec6f& vec);
333 Vector2D pointAt(
int idx = 0)
const;
335 void draw(QPainter& p)
const;
348 Rect(
const QRect& rect);
349 Rect(
const QRectF& rect);
350 Rect(
const cv::Rect& rect);
352 Rect(
double x,
double y,
double width,
double height);
353 Rect(
const cv::Mat& img);
361 double width()
const;
362 double height()
const;
367 double bottom()
const;
369 double right()
const;
379 void scale(
double factor);
380 void expand(
double v);
381 void setTopLeft(
const Vector2D& topLeft);
382 void setSize(
const Vector2D& newSize);
385 QRect toQRect()
const;
386 QRectF toQRectF()
const;
387 cv::Rect toCvRect()
const;
390 bool contains(
const Rect& o)
const;
391 bool contains(
const Vector2D& pt)
const;
392 bool isProximate(
const Rect& o,
double eps = 10.0)
const;
396 Rect intersected(
const Rect& o)
const;
397 bool intersects(
const Rect& o)
const;
399 void draw(QPainter& p)
const;
401 static Rect fromPoints(
const QVector<Vector2D>& pts);
403 virtual QString toString()
const;
417 Ellipse(
const cv::RotatedRect& rect);
421 static Ellipse fromData(
const std::vector<cv::Point>& pts);
422 static Ellipse fromData(
const QVector<Vector2D>& pts);
426 bool isValid()
const;
428 QString toString()
const;
430 void setCenter(
const Vector2D& center);
438 void scale(
double factor);
440 double majorAxis()
const;
441 double minorAxis()
const;
442 double radius()
const;
444 Rect bbox(
bool squared =
false)
const;
446 cv::Mat toCov()
const;
448 void setAngle(
double angle);
449 double angle()
const;
453 void draw(QPainter& p,
double alpha = 0.0)
const;
454 void pdf(cv::Mat& img,
const Rect& box =
Rect())
const;
455 cv::Mat toBinaryMask(
const Rect& box =
Rect())
const;
457 Vector2D getPoint(
double angle)
const;
471 BaseLine(
const QPolygonF& baseLine = QPolygonF());
475 bool isEmpty()
const;
477 void setPolygon(
const QPolygonF& baseLine);
478 QPolygonF polygon()
const;
479 QPolygon toPolygon()
const;
481 void translate(
const QPointF& offset);
483 void read(
const QString& pointList);
484 QString write()
const;
486 QPointF startPoint()
const;
487 QPointF endPoint()
const;
496 Polygon(
const QPolygonF& polygon = QPolygonF());
505 bool isEmpty()
const;
507 void read(
const QString& pointList);
508 QString write()
const;
510 void translate(
const QPointF& offset);
513 QPolygonF polygon()
const;
514 QPolygonF closedPolygon()
const;
515 QVector<Vector2D> toPoints()
const;
517 static Polygon fromCvPoints(
const std::vector<cv::Point2d>& pts);
518 static Polygon fromCvPoints(
const std::vector<cv::Point2f>& pts);
519 static Polygon fromCvPoints(
const std::vector<cv::Point>& pts);
521 void setPolygon(
const QPolygonF& polygon);
523 void scale(
double factor);
524 void draw(QPainter& p)
const;
525 bool contains(
const Vector2D& pt)
const;
538 void setReferenceLine(
Line referenceLine);
539 Line referenceLine()
const;
541 bool isEmpty()
const;
543 void addCandidate(
int lIdx,
double o,
double d);
544 void addCandidate(
Line c,
int lIdx);
550 rdf::Line mergeLines(
const QVector<rdf::Line> &l);
551 QVector<int> sortByOverlap();
552 QVector<int> sortByDistance();
559 QVector<int> candidatesIdx()
const;
560 QVector<double> overlaps()
const;
561 QVector<double> distances()
const;
579 void setId(
const QString&
id);
582 void setCustom(
const QString& c);
583 QString custom()
const;
590 void setRowSpan(
int r);
592 void setColSpan(
int c);
595 void setLeftBorderVisible(
bool b);
596 bool leftBorderVisible()
const;
598 void setRightBorderVisible(
bool b);
599 bool rightBorderVisible()
const;
601 void setTopBorderVisible(
bool b);
602 bool topBorderVisible()
const;
604 void setBottomBorderVisible(
bool b);
605 bool bottomBorderVisible()
const;
607 void setLeftIdx(
int i);
608 QVector<int> leftIdx()
const;
610 void setRightIdx(
int i);
611 QVector<int> rightIdx()
const;
613 void setTopIdx(
int i);
614 QVector<int> topIdx()
const;
616 void setBottomIdx(
int i);
617 QVector<int> bottomIdx()
const;
619 void setHeader(
bool b);
622 void clearCandidates();
626 void setRefLineLeft(
Line l);
627 void addLineCandidateLeft(
Line c,
int lIdx);
629 void clearLineCandidatesLeft();
633 void setRefLineRight(
Line l);
634 void addLineCandidateRight(
Line c,
int lIdx);
636 void clearLineCandidatesRight();
640 void setRefLineTop(
Line l);
641 void addLineCandidateTop(
Line c,
int lIdx);
643 void clearLineCandidatesTop();
647 void setRefLineBottom(
Line l);
648 void addLineCandidateBottom(
Line c,
int lIdx);
650 void clearLineCandidatesBottom();
652 void setPolygon(
const Polygon& polygon);
655 void setNewPolygon(
const Polygon& polygon);
658 void setCornerPts(QVector<int> cPts);
659 QVector<int> cornerPty()
const;
661 double width()
const;
662 double height()
const;
673 static bool compareCells(
const QSharedPointer<rdf::TableCellRaw> l1,
const QSharedPointer<rdf::TableCellRaw> l2);
688 bool mLeftBorderVisible =
false;
690 bool mRightBorderVisible =
false;
692 bool mTopBorderVisible =
false;
694 bool mBottomBorderVisible =
false;
697 bool mHeader =
false;
QVector< double > mDistances
Definition: Shapes.h:570
Vector2D mCenter
Definition: Shapes.h:463
void operator+=(const Vector2D &vec)
Definition: Shapes.h:190
double x() const
Definition: Shapes.h:236
Vector2D mCenter
Definition: Shapes.h:308
Polygon mNewPoly
Definition: Shapes.h:702
QVector< int > mRefCornerPts
Definition: Shapes.h:703
Vector2D mLineOrient
Definition: Shapes.h:310
void operator*=(const double &scalar)
Definition: Shapes.h:203
LineCandidates mLeftLine
Definition: Shapes.h:705
Vector2D center() const
Definition: Shapes.h:431
DllCoreExport friend bool operator==(const Vector2D &l, const Vector2D &r)
Definition: Shapes.h:151
void operator+=(const double &scalar)
Definition: Shapes.h:215
Line mReferenceLine
Definition: Shapes.h:566
QVector< double > mOverlaps
Definition: Shapes.h:569
void operator-=(const Vector2D &vec)
Definition: Shapes.h:196
QDataStream & operator<<(QDataStream &s, const BaseElement &e)
Definition: BaseImageElement.cpp:81
QVector< int > mLeftIdx
Definition: Shapes.h:689
double mX
Definition: Shapes.h:274
QLineF mLine
Definition: Shapes.h:128
DllCoreExport friend Vector2D operator*(const Vector2D &l, double s)
Definition: Shapes.h:177
double mY
Definition: Shapes.h:275
QPolygonF mBaseLine
Definition: Shapes.h:490
QVector< int > mRightIdx
Definition: Shapes.h:691
QVector< int > mTopIdx
Definition: Shapes.h:693
QVector< int > mBottomIdx
Definition: Shapes.h:695
LineCandidates mBottomLine
Definition: Shapes.h:708
DllCoreExport friend Vector2D operator-(const Vector2D &l, const Vector2D &r)
Definition: Shapes.h:163
bool merge(const QSharedPointer< TextLineSet > &tl1, const QSharedPointer< TextLineSet > &tl2)
Definition: PixelSet.cpp:1728
Vector2D mTopLeft
Definition: Shapes.h:408
QString mId
Definition: Shapes.h:685
bool operator<(const PixelEdge &pe1, const PixelEdge &pe2)
Definition: Pixel.cpp:537
QPolygonF mPoly
Definition: Shapes.h:528
QVector< Vector2D > mPts
Definition: Shapes.h:341
bool operator==(const BaseElement &l, const QString &id)
Definition: BaseImageElement.cpp:57
void operator<<(const QPointF &pt)
Definition: Shapes.h:498
DllCoreExport friend Vector2D operator+(const Vector2D &l, const Vector2D &r)
Definition: Shapes.h:159
QPointF toQPointF() const
Definition: Shapes.cpp:967
DllCoreExport friend Vector2D operator/(const Vector2D &l, double s)
Definition: Shapes.h:185
void operator<<(const Vector2D &pt)
Definition: Shapes.h:501
LineCandidates mRightLine
Definition: Shapes.h:706
void operator/=(const double &scalar)
Definition: Shapes.h:209
Line mLine
Definition: Shapes.h:307
A basic line class including stroke width (thickness).
Definition: Shapes.h:68
double mYs
Definition: Shapes.h:316
#define DllCoreExport
Definition: Shapes.h:48
Vector2D mSize
Definition: Shapes.h:409
void operator-=(const double &scalar)
Definition: Shapes.h:221
QVector< int > mLCandidatesIdx
Definition: Shapes.h:568
Vector2D mAxis
Definition: Shapes.h:464
Definition: Algorithms.cpp:45
DllCoreExport friend double operator*(const Vector2D &l, const Vector2D &r)
Computes the scalar product between l and r.
Definition: Shapes.h:173
double y() const
Definition: Shapes.h:241
DllCoreExport friend bool operator!=(const Vector2D &l, const Vector2D &r)
Definition: Shapes.h:155
DllCoreExport friend Vector2D operator*(double s, const Vector2D &l)
Definition: Shapes.h:181
QString mCostum
Definition: Shapes.h:686
bool operator!=(const BaseElement &l, const BaseElement &r)
Returns true if l and r do not have the same id.
Definition: BaseImageElement.cpp:77
LineCandidates mTopLine
Definition: Shapes.h:707
Polygon mRefPoly
Definition: Shapes.h:701