40 #pragma warning(push, 0) // no warnings from includes 42 #include <QSharedPointer> 48 #ifdef DLL_CORE_EXPORT 49 #define DllCoreExport Q_DECL_EXPORT 51 #define DllCoreExport Q_DECL_IMPORT 76 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const = 0;
78 void setStopLines(
const QVector<Line>& stopLines);
84 QVector<QSharedPointer<PixelEdge> > filter(QVector<QSharedPointer<PixelEdge> >& edges)
const;
95 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const override;
110 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const override;
124 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const override;
126 void setRadius(
double radius);
127 void setLineSpacingMultiplier(
double multiplier);
130 double mRadius = 0.0;
131 double mMultiplier = 2.0;
143 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const override;
145 void setLineSpacingMultiplier(
double multiplier);
148 double mMultiplier = 1.0;
161 virtual QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& pixels)
const override;
164 double mEpsMultiplier = 1.2;
176 PixelSet(
const QVector<QSharedPointer<Pixel> >&
set);
195 void operator+=(
const PixelSet&
set);
197 QSharedPointer<Pixel> operator[](
int idx)
const;
198 void operator<<(const QSharedPointer<Pixel>& pixel);
201 bool isEmpty()
const;
202 bool contains(
const QSharedPointer<Pixel>& pixel)
const;
205 virtual void add(
const QSharedPointer<Pixel>& pixel);
206 virtual void remove(
const QSharedPointer<Pixel>& pixel);
207 virtual void append(
const QVector<QSharedPointer<Pixel> >&
set);
208 virtual void scale(
double factor);
209 virtual void filterDuplicates(
int eps = 5);
211 QVector<QSharedPointer<Pixel> >
pixels()
const {
216 QVector<Vector2D> pointSet(
double offsetAngle = 0.0)
const;
217 QVector<Vector2D> centers()
const;
219 Rect boundingBox()
const;
220 Line fitLine(
double offsetAngle = 0.0)
const;
225 double orientation(
double statMoment = 0.5)
const;
226 double lineSpacing(
double statMoment = 0.5)
const;
229 QSharedPointer<Pixel>
find(
const QString&
id)
const;
231 QSharedPointer<TextLine> toTextLine()
const;
235 const DrawFlags& options = DrawFlags() | draw_pixels | draw_poly,
238 static QVector<QSharedPointer<PixelEdge> > connect(
const QVector<QSharedPointer<Pixel> >& superPixels,
const ConnectionMode& mode = connect_Delaunay);
239 static QVector<PixelSet> fromEdges(
const QVector<QSharedPointer<PixelEdge> >& edges);
241 QVector<PixelSet> splitScales()
const;
243 virtual QString toString()
const override;
246 QVector<QSharedPointer<Pixel> >
mSet;
248 Polygon polygon(
const QVector<Vector2D>& pts)
const;
255 TextLineSet(
const QVector<QSharedPointer<Pixel> >&
set);
258 void add(
const QSharedPointer<Pixel>& pixel)
override;
259 void remove(
const QSharedPointer<Pixel>& pixel)
override;
260 void append(
const QVector<QSharedPointer<Pixel> >&
set)
override;
261 void scale(
double factor)
override;
268 double error()
const;
269 double computeError(
const QVector<Vector2D>& pts)
const;
270 double density()
const;
274 double mLineErr = DBL_MAX;
279 namespace TextLineHelper {
281 QVector<QSharedPointer<TextLineSet> >
filterLowDensity(
const QVector<QSharedPointer<TextLineSet> >& textLines);
282 QVector<QSharedPointer<TextLineSet> >
filterHeight(
const QVector<QSharedPointer<TextLineSet> >& textLines,
double minHeight = 5,
double maxHeight = 5000);
283 QVector<QSharedPointer<TextLineSet> >
filterAngle(
const QVector<QSharedPointer<TextLineSet> >& textLines,
double maxAngle = 4 *
DK_DEG2RAD);
287 QSharedPointer<TextLineSet>
find(
const QString&
id,
const QVector<QSharedPointer<TextLineSet> >& tl);
288 bool merge(
const QSharedPointer<TextLineSet> & tl1,
const QSharedPointer<TextLineSet> & tl2);
308 draw_text_lines = 0x2,
319 void scale(
double factor)
override;
323 void setTextLines(
const QVector<QSharedPointer<TextLineSet> >& textLines);
324 QVector<QSharedPointer<TextLineSet> > textLines()
const;
325 bool remove(
const QSharedPointer<TextLineSet>& tl);
326 void cleanTextLines();
328 QSharedPointer<Region> toTextRegion()
const;
330 void draw(QPainter& p,
const DrawFlags& df = DrawFlags() | draw_poly | draw_text_lines);
331 virtual QString toString()
const override;
336 QVector<QSharedPointer<TextLineSet> > mTextLines;
349 TextBlockSet(
const QVector<Polygon>& regions = QVector<Polygon>());
350 TextBlockSet(
const QVector<QSharedPointer<Region>>& regions);
354 bool isEmpty()
const;
356 void scale(
double factor)
override;
359 QVector<QSharedPointer<TextBlock> > textBlocks()
const;
361 QSharedPointer<Region> toTextRegion()
const;
363 void removeWeakTextLines()
const;
367 QVector<QSharedPointer<TextBlock> > mTextBlocks;
392 bool isEmpty()
const;
398 QVector<QSharedPointer<PixelEdge> > edges(
const QString& pixelID)
const;
399 QVector<QSharedPointer<PixelEdge> > edges(
const QVector<int>& edgeIDs)
const;
400 QVector<QSharedPointer<PixelEdge> > edges()
const;
402 int pixelIndex(
const QString & pixelID)
const;
403 QVector<int> edgeIndexes(
const QString & pixelID)
const;
407 QVector<QSharedPointer<PixelEdge> >
mEdges;
424 void setMaxDistance(
double dist);
425 void setEpsilonMultiplier(
double eps);
427 void setFast(
bool f);
429 QVector<PixelSet> sets()
const;
430 QVector<QSharedPointer<PixelEdge> > edges()
const;
449 unsigned int mCLabel = cluster0;
453 double mMaxDistance = 0;
454 double mEpsMultiplier = 2.0;
458 void expandCluster(
int pixelIndex,
unsigned int clusterIndex,
const QVector<int>& neighbors,
double eps,
int minPts)
const;
459 QVector<int> regionQuery(
int pixelIdx,
double eps)
const;
461 cv::Mat calcDists(
const PixelSet& pixels)
const;
cv::Mat mDists
Definition: PixelSet.h:445
Label
Definition: PixelSet.h:436
Abstract class PixelConnector. This is the base class for all pixel connecting classes which implemen...
Definition: PixelSet.h:71
Connects Pixels using the DBScan.
Definition: PixelSet.h:156
PixelSet mPixels
Definition: PixelSet.h:433
Definition: PixelSet.h:387
QVector< QSharedPointer< TextLineSet > > filterHeight(const QVector< QSharedPointer< TextLineSet > > &textLines, double minHeight=5, double maxHeight=5000)
Represents a text block. A single text block has a boundary region and (possibly) a set of super pixe...
Definition: PixelSet.h:300
ConnectionMode
Definition: PixelSet.h:178
Definition: PixelSet.h:384
#define DllCoreExport
Definition: BaseImageElement.h:43
Fully connected graph. Super pixels are connected with all other super pixels within a region...
Definition: PixelSet.h:119
DllCoreExport typedef double(* PixelDistanceFunction)(const Pixel *px1, const Pixel *px2)
Definition: Algorithms.h:163
PixelSet stores and manipulates pixel collections.
Definition: PixelSet.h:172
Flags turns enums into typesave flags It is strongly related (copied) from Useage: enum mDrawFlags { ...
Definition: Utils.h:166
cv::Mat mLabels
Definition: PixelSet.h:446
QDataStream & operator<<(QDataStream &s, const BaseElement &e)
Definition: BaseImageElement.cpp:81
DllCoreExport double euclidean(const Pixel *px1, const Pixel *px2)
Euclidean distance between the pixel's centers.
Definition: Algorithms.cpp:309
void mergeStableTextLines(QVector< QSharedPointer< TextLineSet > > &textLines)
QVector< QSharedPointer< Pixel > > pixels() const
Definition: PixelSet.h:211
DBScan clustering for pixels.
Definition: PixelSet.h:417
QVector< Line > mStopLines
Definition: PixelSet.h:82
unsigned int * mLabelPtr
Definition: PixelSet.h:447
Definition: PixelSet.h:188
DllCoreExport typedef double(* EdgeWeightFunction)(const PixelEdge *edge)
Definition: Algorithms.h:168
QVector< QSharedPointer< Pixel > > mSet
Definition: PixelSet.h:246
mDrawFlags
Definition: PixelSet.h:185
Definition: PixelSet.h:385
QMap< QString, QVector< int > > mPixelEdges
Definition: PixelSet.h:410
Represents a pixel graph. This class comes in handy if you want to map pixel edges with pixels...
Definition: PixelSet.h:377
Definition: PixelSet.h:251
bool merge(const QSharedPointer< TextLineSet > &tl1, const QSharedPointer< TextLineSet > &tl2)
Definition: PixelSet.cpp:1728
QVector< QSharedPointer< PixelEdge > > mEdges
Definition: PixelSet.h:407
QMap< QString, int > mPixelLookup
Definition: PixelSet.h:409
Definition: PixelSet.h:180
Definition: BaseImageElement.h:53
PixelDistance::PixelDistanceFunction mDistanceFnc
Definition: PixelSet.h:81
SortMode
Definition: PixelSet.h:383
A basic line class including stroke width (thickness).
Definition: Shapes.h:68
Definition: PixelSet.h:439
Flags< mDrawFlags > DrawFlags
Definition: PixelSet.h:314
Connects pixels using the Delaunay triangulation.
Definition: PixelSet.h:91
Stores all text blocks. This class is used to group super pixels with respect to layout constrains (e...
Definition: PixelSet.h:346
QVector< QSharedPointer< TextLineSet > > filterAngle(const QVector< QSharedPointer< TextLineSet > > &textLines, double maxAngle=4 *DK_DEG2RAD)
QVector< QSharedPointer< TextLineSet > > filterLowDensity(const QVector< QSharedPointer< TextLineSet > > &textLines)
Definition: Algorithms.cpp:45
Definition: PixelSet.h:438
#define DK_DEG2RAD
Definition: Utils.h:55
PixelSet mSet
Definition: PixelSet.h:406
Flags< mDrawFlags > DrawFlags
Definition: PixelSet.h:193
Connects tab stops.
Definition: PixelSet.h:138
Definition: PixelSet.h:179
Connects pixels using the Voronoi diagram. NOTE: this is highly experimental for it creates new pixel...
Definition: PixelSet.h:106
Definition: PixelSet.h:386
mDrawFlags
Definition: PixelSet.h:305
QSharedPointer< TextLineSet > find(const QString &id, const QVector< QSharedPointer< TextLineSet > > &tl)
Line mLine
Definition: PixelSet.h:273