Skip to content

Commit 94e1126

Browse files
Merge pull request opencv#19423 from LaurentBerger:houg_acc
Return accumulator value in HoughLines algorithm * try to solve opencv#17050 use cv_wrap_as add python test parameters * review * move wrapper to imgproc/bindings.hpp
1 parent 2b787eb commit 94e1126

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
5+
#ifndef OPENCV_IMGPROC_BINDINGS_HPP
6+
#define OPENCV_IMGPROC_BINDINGS_HPP
7+
8+
// This file contains special overloads for OpenCV bindings
9+
// No need to use these functions in C++ code.
10+
11+
namespace cv {
12+
13+
/** @brief Finds lines in a binary image using the standard Hough transform and get accumulator.
14+
*
15+
* @note This function is for bindings use only. Use original function in C++ code
16+
*
17+
* @sa HoughLines
18+
*/
19+
CV_WRAP static inline
20+
void HoughLinesWithAccumulator(
21+
InputArray image, OutputArray lines,
22+
double rho, double theta, int threshold,
23+
double srn = 0, double stn = 0,
24+
double min_theta = 0, double max_theta = CV_PI
25+
)
26+
{
27+
std::vector<Vec3f> lines_acc;
28+
HoughLines(image, lines_acc, rho, theta, threshold, srn, stn, min_theta, max_theta);
29+
Mat(lines_acc).copyTo(lines);
30+
}
31+
32+
} // namespace
33+
34+
#endif // OPENCV_IMGPROC_BINDINGS_HPP

modules/imgproc/misc/objc/gen_dict.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"AdditionalImports" : {
3+
"Imgproc" : [ "\"imgproc/bindings.hpp\"" ]
4+
},
25
"enum_ignore_list" : [
36
"MorphShapes_c",
47
"SmoothMethod_c"

modules/python/test/test_houghlines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def test_houghlines(self):
6464

6565
self.assertGreater(float(matches_counter) / len(testLines), .7)
6666

67+
lines_acc = cv.HoughLinesWithAccumulator(dst, rho=1, theta=np.pi / 180, threshold=150, srn=0, stn=0)
68+
self.assertEqual(lines_acc[0,0,2], 192.0)
69+
self.assertEqual(lines_acc[1,0,2], 187.0)
6770

6871
if __name__ == '__main__':
6972
NewOpenCVTests.bootstrap()

0 commit comments

Comments
 (0)