From: LaurentBerger Date: Mon, 1 Feb 2021 21:22:10 +0000 (+0100) Subject: Merge pull request #19423 from LaurentBerger:houg_acc X-Git-Tag: accepted/tizen/unified/20220125.121719~1^2~229 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94e1126678e78f70e4d35dea27be60fbf3167ec7;p=platform%2Fupstream%2Fopencv.git Merge pull request #19423 from LaurentBerger:houg_acc Return accumulator value in HoughLines algorithm * try to solve #17050 use cv_wrap_as add python test parameters * review * move wrapper to imgproc/bindings.hpp --- diff --git a/modules/imgproc/include/opencv2/imgproc/bindings.hpp b/modules/imgproc/include/opencv2/imgproc/bindings.hpp new file mode 100644 index 0000000..c69527a --- /dev/null +++ b/modules/imgproc/include/opencv2/imgproc/bindings.hpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGPROC_BINDINGS_HPP +#define OPENCV_IMGPROC_BINDINGS_HPP + +// This file contains special overloads for OpenCV bindings +// No need to use these functions in C++ code. + +namespace cv { + +/** @brief Finds lines in a binary image using the standard Hough transform and get accumulator. + * + * @note This function is for bindings use only. Use original function in C++ code + * + * @sa HoughLines + */ +CV_WRAP static inline +void HoughLinesWithAccumulator( + InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0, + double min_theta = 0, double max_theta = CV_PI +) +{ + std::vector lines_acc; + HoughLines(image, lines_acc, rho, theta, threshold, srn, stn, min_theta, max_theta); + Mat(lines_acc).copyTo(lines); +} + +} // namespace + +#endif // OPENCV_IMGPROC_BINDINGS_HPP diff --git a/modules/imgproc/misc/objc/gen_dict.json b/modules/imgproc/misc/objc/gen_dict.json index 043baa5..7897bde 100644 --- a/modules/imgproc/misc/objc/gen_dict.json +++ b/modules/imgproc/misc/objc/gen_dict.json @@ -1,4 +1,7 @@ { + "AdditionalImports" : { + "Imgproc" : [ "\"imgproc/bindings.hpp\"" ] + }, "enum_ignore_list" : [ "MorphShapes_c", "SmoothMethod_c" diff --git a/modules/python/test/test_houghlines.py b/modules/python/test/test_houghlines.py index 8deae54..3ecfbfe 100644 --- a/modules/python/test/test_houghlines.py +++ b/modules/python/test/test_houghlines.py @@ -64,6 +64,9 @@ class houghlines_test(NewOpenCVTests): self.assertGreater(float(matches_counter) / len(testLines), .7) + lines_acc = cv.HoughLinesWithAccumulator(dst, rho=1, theta=np.pi / 180, threshold=150, srn=0, stn=0) + self.assertEqual(lines_acc[0,0,2], 192.0) + self.assertEqual(lines_acc[1,0,2], 187.0) if __name__ == '__main__': NewOpenCVTests.bootstrap()