mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
new optimized version
This commit is contained in:
@@ -46,16 +46,23 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
namespace hough
|
||||
{
|
||||
void linesAccum_gpu(DevMem2Db src, DevMem2D_<uint> accum, float rho, float theta);
|
||||
unsigned int buildPointList_gpu(DevMem2Db src, unsigned int* list);
|
||||
void linesAccum_gpu(const unsigned int* list, unsigned int count, DevMem2D_<unsigned int> accum, float rho, float theta);
|
||||
unsigned int linesGetResult_gpu(DevMem2D_<uint> accum, float2* out, int* voices, unsigned int maxSize, float rho, float theta, float threshold, bool doSort);
|
||||
}
|
||||
}}}
|
||||
|
||||
void cv::gpu::HoughLinesTransform(const GpuMat& src, GpuMat& accum, float rho, float theta)
|
||||
void cv::gpu::HoughLinesTransform(const GpuMat& src, GpuMat& accum, GpuMat& buf, float rho, float theta)
|
||||
{
|
||||
using namespace cv::gpu::device;
|
||||
using namespace cv::gpu::device::hough;
|
||||
|
||||
CV_Assert(src.type() == CV_8UC1);
|
||||
CV_Assert(src.cols < std::numeric_limits<unsigned short>::max());
|
||||
CV_Assert(src.rows < std::numeric_limits<unsigned short>::max());
|
||||
|
||||
ensureSizeIsEnough(1, src.size().area(), CV_32SC1, buf);
|
||||
|
||||
unsigned int count = buildPointList_gpu(src, buf.ptr<unsigned int>());
|
||||
|
||||
const int numangle = cvRound(CV_PI / theta);
|
||||
const int numrho = cvRound(((src.cols + src.rows) * 2 + 1) / rho);
|
||||
@@ -63,7 +70,7 @@ void cv::gpu::HoughLinesTransform(const GpuMat& src, GpuMat& accum, float rho, f
|
||||
ensureSizeIsEnough(numangle + 2, numrho + 2, CV_32SC1, accum);
|
||||
accum.setTo(cv::Scalar::all(0));
|
||||
|
||||
hough::linesAccum_gpu(src, accum, rho, theta);
|
||||
linesAccum_gpu(buf.ptr<unsigned int>(), count, accum, rho, theta);
|
||||
}
|
||||
|
||||
void cv::gpu::HoughLinesGet(const GpuMat& accum, GpuMat& lines, float rho, float theta, int threshold, bool doSort, int maxLines)
|
||||
@@ -83,13 +90,13 @@ void cv::gpu::HoughLinesGet(const GpuMat& accum, GpuMat& lines, float rho, float
|
||||
|
||||
void cv::gpu::HoughLines(const GpuMat& src, GpuMat& lines, float rho, float theta, int threshold, bool doSort, int maxLines)
|
||||
{
|
||||
cv::gpu::GpuMat accum;
|
||||
HoughLines(src, lines, accum, rho, theta, threshold, doSort, maxLines);
|
||||
cv::gpu::GpuMat accum, buf;
|
||||
HoughLines(src, lines, accum, buf, rho, theta, threshold, doSort, maxLines);
|
||||
}
|
||||
|
||||
void cv::gpu::HoughLines(const GpuMat& src, GpuMat& lines, GpuMat& accum, float rho, float theta, int threshold, bool doSort, int maxLines)
|
||||
void cv::gpu::HoughLines(const GpuMat& src, GpuMat& lines, GpuMat& accum, GpuMat& buf, float rho, float theta, int threshold, bool doSort, int maxLines)
|
||||
{
|
||||
HoughLinesTransform(src, accum, rho, theta);
|
||||
HoughLinesTransform(src, accum, buf, rho, theta);
|
||||
HoughLinesGet(accum, lines, rho, theta, threshold, doSort, maxLines);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user