From f0b050fa887762e333081b8741e633b4efad2cc0 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 19 Sep 2013 18:41:08 +0400 Subject: [PATCH 1/5] exposed LineSegemntDetector to python --- modules/imgproc/include/opencv2/imgproc.hpp | 10 +++++----- modules/python/src2/cv2.cpp | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 3b257194d..62d5a8367 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -900,7 +900,7 @@ protected: Point2f bottomRight; }; -class LineSegmentDetector : public Algorithm +class CV_EXPORTS_W LineSegmentDetector : public Algorithm { public: /** @@ -922,7 +922,7 @@ public: * * 1 corresponds to 0.1 mean false alarms * This vector will be calculated _only_ when the objects type is REFINE_ADV */ - virtual void detect(InputArray _image, OutputArray _lines, + CV_WRAP virtual void detect(InputArray _image, OutputArray _lines, OutputArray width = noArray(), OutputArray prec = noArray(), OutputArray nfa = noArray()) = 0; @@ -933,7 +933,7 @@ public: * Should have the size of the image, where the lines were found * @param lines The lines that need to be drawn */ - virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0; + CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0; /** * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2. @@ -945,13 +945,13 @@ public: * Should have the size of the image, where the lines were found * @return The number of mismatching pixels between lines1 and lines2. */ - virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0; + CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0; virtual ~LineSegmentDetector() {}; }; //! Returns a pointer to a LineSegmentDetector class. -CV_EXPORTS Ptr createLineSegmentDetectorPtr( +CV_EXPORTS_W Ptr createLineSegmentDetectorPtr( int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024); diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index b2bd368a1..f404c0625 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -137,7 +137,8 @@ typedef Ptr Ptr_StereoSGBM; typedef Ptr Ptr_ChannelFeatureBuilder; typedef Ptr Ptr_CLAHE; - +typedef Ptr Ptr_LineSegmentDetector; + typedef SimpleBlobDetector::Params SimpleBlobDetector_Params; typedef cvflann::flann_distance_t cvflann_flann_distance_t; From 0a8d62e5fd1696ad2507e5eecb9b8a8b168f167d Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 19 Sep 2013 18:44:11 +0400 Subject: [PATCH 2/5] createLineSegmentDetectorPtr -> createLineSegmentDetector --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- modules/imgproc/src/lsd.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 62d5a8367..cfc688d0f 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -951,7 +951,7 @@ public: }; //! Returns a pointer to a LineSegmentDetector class. -CV_EXPORTS_W Ptr createLineSegmentDetectorPtr( +CV_EXPORTS_W Ptr createLineSegmentDetector( int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024); diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp index bb3895448..69362e470 100644 --- a/modules/imgproc/src/lsd.cpp +++ b/modules/imgproc/src/lsd.cpp @@ -388,7 +388,7 @@ private: ///////////////////////////////////////////////////////////////////////////////////////// -CV_EXPORTS Ptr createLineSegmentDetectorPtr( +CV_EXPORTS Ptr createLineSegmentDetector( int _refine, double _scale, double _sigma_scale, double _quant, double _ang_th, double _log_eps, double _density_th, int _n_bins) { From 20fe614c2f97cb75d7103a7290aeeed33e176656 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 19 Sep 2013 19:06:48 +0400 Subject: [PATCH 3/5] createLineSegmentDetectorPtr -> createLineSegmentDetector in tests and samples --- modules/imgproc/test/test_lsd.cpp | 24 ++++++++++++------------ samples/cpp/lsd_lines.cpp | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/imgproc/test/test_lsd.cpp b/modules/imgproc/test/test_lsd.cpp index 7d8b7f243..82f5b0bce 100644 --- a/modules/imgproc/test/test_lsd.cpp +++ b/modules/imgproc/test/test_lsd.cpp @@ -110,7 +110,7 @@ TEST_F(Imgproc_LSD_ADV, whiteNoise) for (int i = 0; i < EPOCHS; ++i) { GenerateWhiteNoise(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV); + Ptr detector = createLineSegmentDetector(LSD_REFINE_ADV); detector->detect(test_image, lines); if(40u >= lines.size()) ++passedtests; @@ -123,7 +123,7 @@ TEST_F(Imgproc_LSD_ADV, constColor) for (int i = 0; i < EPOCHS; ++i) { GenerateConstColor(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV); + Ptr detector = createLineSegmentDetector(LSD_REFINE_ADV); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; @@ -137,7 +137,7 @@ TEST_F(Imgproc_LSD_ADV, lines) { const unsigned int numOfLines = 1; GenerateLines(test_image, numOfLines); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV); + Ptr detector = createLineSegmentDetector(LSD_REFINE_ADV); detector->detect(test_image, lines); if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect @@ -150,7 +150,7 @@ TEST_F(Imgproc_LSD_ADV, rotatedRect) for (int i = 0; i < EPOCHS; ++i) { GenerateRotatedRect(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_ADV); + Ptr detector = createLineSegmentDetector(LSD_REFINE_ADV); detector->detect(test_image, lines); if(2u <= lines.size()) ++passedtests; @@ -163,7 +163,7 @@ TEST_F(Imgproc_LSD_STD, whiteNoise) for (int i = 0; i < EPOCHS; ++i) { GenerateWhiteNoise(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(50u >= lines.size()) ++passedtests; @@ -176,7 +176,7 @@ TEST_F(Imgproc_LSD_STD, constColor) for (int i = 0; i < EPOCHS; ++i) { GenerateConstColor(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; @@ -190,7 +190,7 @@ TEST_F(Imgproc_LSD_STD, lines) { const unsigned int numOfLines = 1; GenerateLines(test_image, numOfLines); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect @@ -203,7 +203,7 @@ TEST_F(Imgproc_LSD_STD, rotatedRect) for (int i = 0; i < EPOCHS; ++i) { GenerateRotatedRect(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(4u <= lines.size()) ++passedtests; @@ -216,7 +216,7 @@ TEST_F(Imgproc_LSD_NONE, whiteNoise) for (int i = 0; i < EPOCHS; ++i) { GenerateWhiteNoise(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(50u >= lines.size()) ++passedtests; @@ -229,7 +229,7 @@ TEST_F(Imgproc_LSD_NONE, constColor) for (int i = 0; i < EPOCHS; ++i) { GenerateConstColor(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE); + Ptr detector = createLineSegmentDetector(LSD_REFINE_NONE); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; @@ -243,7 +243,7 @@ TEST_F(Imgproc_LSD_NONE, lines) { const unsigned int numOfLines = 1; GenerateLines(test_image, numOfLines); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE); + Ptr detector = createLineSegmentDetector(LSD_REFINE_NONE); detector->detect(test_image, lines); if(numOfLines * 2 == lines.size()) ++passedtests; // * 2 because of Gibbs effect @@ -256,7 +256,7 @@ TEST_F(Imgproc_LSD_NONE, rotatedRect) for (int i = 0; i < EPOCHS; ++i) { GenerateRotatedRect(test_image); - Ptr detector = createLineSegmentDetectorPtr(LSD_REFINE_NONE); + Ptr detector = createLineSegmentDetector(LSD_REFINE_NONE); detector->detect(test_image, lines); if(8u <= lines.size()) ++passedtests; diff --git a/samples/cpp/lsd_lines.cpp b/samples/cpp/lsd_lines.cpp index 62692f70b..92452a99c 100644 --- a/samples/cpp/lsd_lines.cpp +++ b/samples/cpp/lsd_lines.cpp @@ -30,9 +30,9 @@ int main(int argc, char** argv) // Create and LSD detector with standard or no refinement. #if 1 - Ptr ls = createLineSegmentDetectorPtr(LSD_REFINE_STD); + Ptr ls = createLineSegmentDetector(LSD_REFINE_STD); #else - Ptr ls = createLineSegmentDetectorPtr(LSD_REFINE_NONE); + Ptr ls = createLineSegmentDetector(LSD_REFINE_NONE); #endif double start = double(getTickCount()); From 851a8a1cd0e5a1717ed2863641c27451c170faee Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 30 Sep 2013 14:31:39 +0400 Subject: [PATCH 4/5] fixed whitespace error --- modules/python/src2/cv2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index f404c0625..fa5f50211 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -138,7 +138,7 @@ typedef Ptr Ptr_StereoSGBM; typedef Ptr Ptr_ChannelFeatureBuilder; typedef Ptr Ptr_CLAHE; typedef Ptr Ptr_LineSegmentDetector; - + typedef SimpleBlobDetector::Params SimpleBlobDetector_Params; typedef cvflann::flann_distance_t cvflann_flann_distance_t; From bc1f9d6268c24ce5de961f7ba58c5cf5997990d4 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 30 Sep 2013 15:07:32 +0400 Subject: [PATCH 5/5] fixed description of createLineSegmentDetector --- modules/imgproc/doc/feature_detection.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/doc/feature_detection.rst b/modules/imgproc/doc/feature_detection.rst index a6d5817dd..87e14d98f 100644 --- a/modules/imgproc/doc/feature_detection.rst +++ b/modules/imgproc/doc/feature_detection.rst @@ -509,11 +509,11 @@ Line segment detector class, following the algorithm described at [Rafael12]_. .. ocv:class:: LineSegmentDetector : public Algorithm -createLineSegmentDetectorPtr ----------------------------- +createLineSegmentDetector +------------------------- Creates a smart pointer to a LineSegmentDetector object and initializes it. -.. ocv:function:: Ptr createLineSegmentDetectorPtr(int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024) +.. ocv:function:: Ptr createLineSegmentDetector(int _refine = LSD_REFINE_STD, double _scale = 0.8, double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5, double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024) :param _refine: The way found lines will be refined: