@@ -29,10 +29,11 @@ class FastLineDetectorImpl : public FastLineDetector
29
29
* _ hysteresis procedure in Canny()
30
30
* @param _canny_th2 50 - Second threshold for
31
31
* _ hysteresis procedure in Canny()
32
- * @param _canny_aperture_size 3 - Aperturesize for the sobel
33
- * _ operator in Canny()
32
+ * @param _canny_aperture_size 3 - Aperturesize for the sobel operator in Canny().
33
+ * If zero, Canny() is not applied and the input
34
+ * image is taken as an edge image.
34
35
* @param _do_merge false - If true, incremental merging of segments
35
- will be perfomred
36
+ * will be performed
36
37
*/
37
38
FastLineDetectorImpl (int _length_threshold = 10 , float _distance_threshold = 1 .414213562f ,
38
39
double _canny_th1 = 50.0 , double _canny_th2 = 50.0 , int _canny_aperture_size = 3 ,
@@ -80,7 +81,7 @@ class FastLineDetectorImpl : public FastLineDetector
80
81
81
82
double distPointLine (const Mat& p, Mat& l);
82
83
83
- void extractSegments (const std::vector<Point2i>& points, std::vector<SEGMENT>& segments );
84
+ void extractSegments (const std::vector<Point2i>& points, std::vector<SEGMENT>& segments);
84
85
85
86
void lineDetection (const Mat& src, std::vector<SEGMENT>& segments_all);
86
87
@@ -113,7 +114,7 @@ FastLineDetectorImpl::FastLineDetectorImpl(int _length_threshold, float _distanc
113
114
canny_th1 (_canny_th1), canny_th2(_canny_th2), canny_aperture_size(_canny_aperture_size), do_merge(_do_merge)
114
115
{
115
116
CV_Assert (_length_threshold > 0 && _distance_threshold > 0 &&
116
- _canny_th1 > 0 && _canny_th2 > 0 && _canny_aperture_size > 0 );
117
+ _canny_th1 > 0 && _canny_th2 > 0 && _canny_aperture_size >= 0 );
117
118
}
118
119
119
120
void FastLineDetectorImpl::detect (InputArray _image, OutputArray _lines)
@@ -344,7 +345,7 @@ template<class T>
344
345
pt = T (pt_tmp);
345
346
}
346
347
347
- void FastLineDetectorImpl::extractSegments (const std::vector<Point2i>& points, std::vector<SEGMENT>& segments )
348
+ void FastLineDetectorImpl::extractSegments (const std::vector<Point2i>& points, std::vector<SEGMENT>& segments)
348
349
{
349
350
bool is_line;
350
351
@@ -544,8 +545,14 @@ void FastLineDetectorImpl::lineDetection(const Mat& src, std::vector<SEGMENT>& s
544
545
std::vector<Point2i> points;
545
546
std::vector<SEGMENT> segments, segments_tmp;
546
547
Mat canny;
547
- Canny (src, canny, canny_th1, canny_th2, canny_aperture_size);
548
-
548
+ if (canny_aperture_size == 0 )
549
+ {
550
+ canny = src;
551
+ }
552
+ else
553
+ {
554
+ Canny (src, canny, canny_th1, canny_th2, canny_aperture_size);
555
+ }
549
556
canny.colRange (0 ,6 ).rowRange (0 ,6 ) = 0 ;
550
557
canny.colRange (src.cols -5 ,src.cols ).rowRange (src.rows -5 ,src.rows ) = 0 ;
551
558
0 commit comments