@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD = 0,
191
191
HOUGH_GRADIENT = 3
192
192
};
193
193
194
+ // ! Variants of Line Segment Detector
195
+ enum { LSD_REFINE_NONE = 0 ,
196
+ LSD_REFINE_STD = 1 ,
197
+ LSD_REFINE_ADV = 2
198
+ };
199
+
194
200
// ! Histogram comparison methods
195
201
enum { HISTCMP_CORREL = 0 ,
196
202
HISTCMP_CHISQR = 1 ,
@@ -829,7 +835,62 @@ class CV_EXPORTS_W Subdiv2D
829
835
Point2f bottomRight;
830
836
};
831
837
838
+ class LineSegmentDetector : public Algorithm
839
+ {
840
+ public:
841
+ /* *
842
+ * Detect lines in the input image with the specified ROI.
843
+ *
844
+ * @param _image A grayscale(CV_8UC1) input image.
845
+ * If only a roi needs to be selected, use
846
+ * lsd_ptr->detect(image(roi), ..., lines);
847
+ * lines += Scalar(roi.x, roi.y, roi.x, roi.y);
848
+ * @param _lines Return: A vector of Vec4i elements specifying the beginning and ending point of a line.
849
+ * Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end.
850
+ * Returned lines are strictly oriented depending on the gradient.
851
+ * @param _roi Return: ROI of the image, where lines are to be found. If specified, the returning
852
+ * lines coordinates are image wise.
853
+ * @param width Return: Vector of widths of the regions, where the lines are found. E.g. Width of line.
854
+ * @param prec Return: Vector of precisions with which the lines are found.
855
+ * @param nfa Return: Vector containing number of false alarms in the line region, with precision of 10%.
856
+ * The bigger the value, logarithmically better the detection.
857
+ * * -1 corresponds to 10 mean false alarms
858
+ * * 0 corresponds to 1 mean false alarm
859
+ * * 1 corresponds to 0.1 mean false alarms
860
+ * This vector will be calculated _only_ when the objects type is REFINE_ADV
861
+ */
862
+ virtual void detect (const InputArray _image, OutputArray _lines,
863
+ OutputArray width = noArray(), OutputArray prec = noArray(),
864
+ OutputArray nfa = noArray()) = 0;
865
+
866
+ /* *
867
+ * Draw lines on the given canvas.
868
+ *
869
+ * @param image The image, where lines will be drawn.
870
+ * Should have the size of the image, where the lines were found
871
+ * @param lines The lines that need to be drawn
872
+ */
873
+ virtual void drawSegments (InputOutputArray image, const InputArray lines) = 0;
874
+
875
+ /* *
876
+ * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2.
877
+ *
878
+ * @param image The image, where lines will be drawn.
879
+ * Should have the size of the image, where the lines were found
880
+ * @param lines1 The first lines that need to be drawn. Color - Blue.
881
+ * @param lines2 The second lines that need to be drawn. Color - Red.
882
+ * @return The number of mismatching pixels between lines1 and lines2.
883
+ */
884
+ virtual int compareSegments (const Size & size, const InputArray lines1, const InputArray lines2, Mat* image = 0 ) = 0;
885
+
886
+ virtual ~LineSegmentDetector () {};
887
+ };
832
888
889
+ // ! Returns a pointer to a LineSegmentDetector class.
890
+ CV_EXPORTS Ptr <LineSegmentDetector> createLineSegmentDetectorPtr (
891
+ int _refine = LSD_REFINE_STD, double _scale = 0.8 ,
892
+ double _sigma_scale = 0.6 , double _quant = 2.0 , double _ang_th = 22.5 ,
893
+ double _log_eps = 0 , double _density_th = 0.7 , int _n_bins = 1024 );
833
894
834
895
// ! returns type (one of KERNEL_*) of 1D or 2D kernel specified by its coefficients.
835
896
CV_EXPORTS int getKernelType (InputArray kernel, Point anchor);
0 commit comments