From a02af4a12bb5ef8ec4c46602593daefc98a8d2c8 Mon Sep 17 00:00:00 2001 From: xolodilnik Date: Wed, 3 Jun 2015 18:17:10 +0300 Subject: [PATCH] modules/ximgproc/include/opencv2/ximgproc/fast_hough_transform.hpp moved from modules/ximgproc/include/opencv2/ximgproc.hpp HoughPoint2Line returned Vec4i instead of OutputArray --- modules/ximgproc/include/opencv2/ximgproc.hpp | 1 + .../ximgproc}/fast_hough_transform.hpp | 16 +++++----- .../perf/perf_fast_hough_transform.cpp | 1 - .../ximgproc/samples/fast_hough_transform.cpp | 4 +-- modules/ximgproc/src/fast_hough_transform.cpp | 32 +++++++++---------- .../test/test_fast_hough_transform.cpp | 3 +- 6 files changed, 26 insertions(+), 31 deletions(-) rename modules/ximgproc/include/{ => opencv2/ximgproc}/fast_hough_transform.hpp (94%) diff --git a/modules/ximgproc/include/opencv2/ximgproc.hpp b/modules/ximgproc/include/opencv2/ximgproc.hpp index 69c0e7fe7..778efcfff 100644 --- a/modules/ximgproc/include/opencv2/ximgproc.hpp +++ b/modules/ximgproc/include/opencv2/ximgproc.hpp @@ -40,6 +40,7 @@ #include "ximgproc/edge_filter.hpp" #include "ximgproc/structured_edge_detection.hpp" #include "ximgproc/seeds.hpp" +#include "ximgproc/fast_hough_transform.hpp" /** @defgroup ximgproc Extended Image Processing @{ diff --git a/modules/ximgproc/include/fast_hough_transform.hpp b/modules/ximgproc/include/opencv2/ximgproc/fast_hough_transform.hpp similarity index 94% rename from modules/ximgproc/include/fast_hough_transform.hpp rename to modules/ximgproc/include/opencv2/ximgproc/fast_hough_transform.hpp index 68edec0f2..375bced2b 100644 --- a/modules/ximgproc/include/fast_hough_transform.hpp +++ b/modules/ximgproc/include/opencv2/ximgproc/fast_hough_transform.hpp @@ -130,7 +130,7 @@ typedef enum { * The function calculates the fast Hough transform for full, half or quarter * range of angles. */ -CV_EXPORTS_W void FastHoughTransform( InputArray src, +CV_EXPORTS_W void FastHoughTransform( InputArray src, OutputArray dst, int dstMatDepth, int angleRange = ARO_315_135, @@ -139,9 +139,9 @@ CV_EXPORTS_W void FastHoughTransform( InputArray src, /** * @brief Calculates coordinates of line segment corresponded by point in Hough space. -* @param line Coordinates of line segment corresponded by point in Hough space. * @param houghPoint Point in Hough space. * @param srcImgInfo The source (input) image of Hough transform. +* @param line Coordinates of line segment corresponded by point in Hough space. * @param angleRange The part of Hough space where point is situated, see cv::AngleRangeOption * @param makeSkew Specifies to do or not to do image skewing, see cv::HoughDeskewOption * @param rules Specifies strictness of line segment calculating, see cv::RulesOption @@ -152,12 +152,12 @@ CV_EXPORTS_W void FastHoughTransform( InputArray src, * * The function calculates coordinates of line segment corresponded by point in Hough space. */ -CV_EXPORTS_W void HoughPoint2Line( OutputArray line, - const Point &houghPoint, - const Mat &srcImgInfo, - int angleRange = ARO_315_135, - int makeSkew = HDO_DESKEW, - int rules = RO_IGNORE_BORDERS ); +CV_EXPORTS_W void HoughPoint2Line( const Point &houghPoint, + InputArray srcImgInfo, + Vec4i &line, + int angleRange = ARO_315_135, + int makeSkew = HDO_DESKEW, + int rules = RO_IGNORE_BORDERS ); } }// namespace cv::ximgproc diff --git a/modules/ximgproc/perf/perf_fast_hough_transform.cpp b/modules/ximgproc/perf/perf_fast_hough_transform.cpp index 63cd04bca..94c8ad2ed 100644 --- a/modules/ximgproc/perf/perf_fast_hough_transform.cpp +++ b/modules/ximgproc/perf/perf_fast_hough_transform.cpp @@ -42,7 +42,6 @@ //M*/ #include "perf_precomp.hpp" -#include "fast_hough_transform.hpp" namespace cvtest { diff --git a/modules/ximgproc/samples/fast_hough_transform.cpp b/modules/ximgproc/samples/fast_hough_transform.cpp index 7489fe17e..13584fa9e 100644 --- a/modules/ximgproc/samples/fast_hough_transform.cpp +++ b/modules/ximgproc/samples/fast_hough_transform.cpp @@ -47,8 +47,6 @@ #include -#include "fast_hough_transform.hpp" - #include #include #include @@ -197,7 +195,7 @@ bool getLocalExtr(vector &lines, for (size_t i = 0; i < weightedPoints.size(); ++i) { Vec4i houghLine(0, 0, 0, 0); - HoughPoint2Line(houghLine, weightedPoints[i].second, src); + HoughPoint2Line(weightedPoints[i].second, src, houghLine); lines.push_back(houghLine); } return true; diff --git a/modules/ximgproc/src/fast_hough_transform.cpp b/modules/ximgproc/src/fast_hough_transform.cpp index 52abb773c..ec968a628 100644 --- a/modules/ximgproc/src/fast_hough_transform.cpp +++ b/modules/ximgproc/src/fast_hough_transform.cpp @@ -42,7 +42,6 @@ //M*/ #include "precomp.hpp" -#include "fast_hough_transform.hpp" namespace cv { namespace ximgproc { @@ -836,23 +835,25 @@ static void crossSegments(Point &point, point.y = cvRound(line1.u.y + mul * (line1.v.y - line1.u.y)); } -void HoughPoint2Line(OutputArray line, - const Point &houghPoint, - const Mat &srcImgInfo, - int angleRange, - int makeSkew, - int rules) +void HoughPoint2Line(const Point &houghPoint, + InputArray srcImgInfo, + Vec4i &line, + int angleRange, + int makeSkew, + int rules) { - int const cols = srcImgInfo.cols; - int const rows = srcImgInfo.rows; + Mat srcImgInfoMat = srcImgInfo.getMat(); + + int const cols = srcImgInfoMat.cols; + int const rows = srcImgInfoMat.rows; CV_Assert(houghPoint.y >= 0); CV_Assert(houghPoint.x < cols + rows); int quad = 0; Point rawPoint(0, 0); - getRawPoint(rawPoint, quad, houghPoint, srcImgInfo, angleRange, makeSkew); - bool ret = checkRawPoint(rawPoint, quad, srcImgInfo); + getRawPoint(rawPoint, quad, houghPoint, srcImgInfoMat, angleRange, makeSkew); + bool ret = checkRawPoint(rawPoint, quad, srcImgInfoMat); if (!(rules & RO_IGNORE_BORDERS)) { CV_Assert(ret); @@ -906,8 +907,7 @@ void HoughPoint2Line(OutputArray line, if (!ret) { - Vec4i pts(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); - Mat(pts).copyTo(line); + line = Vec4i(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); return; } @@ -933,8 +933,7 @@ void HoughPoint2Line(OutputArray line, break; } - Vec4i pts(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); - Mat(pts).copyTo(line); + line = Vec4i(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); return; } @@ -1021,8 +1020,7 @@ void HoughPoint2Line(OutputArray line, break; } - Vec4i pts(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); - Mat(pts).copyTo(line); + line = Vec4i(dstLine.v.x, dstLine.v.y, dstLine.u.x, dstLine.u.y); } //----------------------------------------------------------------------------- diff --git a/modules/ximgproc/test/test_fast_hough_transform.cpp b/modules/ximgproc/test/test_fast_hough_transform.cpp index 94819be4a..c94117485 100644 --- a/modules/ximgproc/test/test_fast_hough_transform.cpp +++ b/modules/ximgproc/test/test_fast_hough_transform.cpp @@ -42,7 +42,6 @@ //M*/ #include "test_precomp.hpp" -#include "fast_hough_transform.hpp" namespace cvtest { @@ -288,7 +287,7 @@ int TestFHT::validate_line(Mat const& fht, Point fht_max(-1, -1); minMaxLoc(fht_channels[ch], 0, 0, 0, &fht_max); Vec4i src_line; - HoughPoint2Line(src_line, fht_max, src, + HoughPoint2Line(fht_max, src, src_line, ARO_315_135, HDO_DESKEW, RO_STRICT); double const a = src_line[1] - src_line[3];