Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV GPU Error (Function Not Implemented) in Hough Transform

I have tried Hough on CPU, and it runs fine, just a little slow. So, I am trying to run Hough on OpenCV CUDA, but it shows this error, even if I have GpuMat -

OpenCV Error: The function/feature is not implemented (getGpuMat is available only for cuda::GpuMat and cuda::HostMem) in cv::_InputArray::getGpuMat, file PATH\opencv-sources\modules\core\src\matrix.cpp, line 1454

This is my code (I stream frames from live camera, so inside a while loop) -

Ptr<HoughLinesDetector> houghLines = createHoughLinesDetector(1, CV_PI / 180, 120);
vector<Vec2d> tmpLines;
vector<Vec2d> lines;
GpuMat imgCanny;
... 
while(true) {
    ...
    houghLines->detect(imgCanny, tmpLines);
    houghLines->downloadResults(tmpLines, lines); // Error occurs here...
    ...
}

Any help on this?

like image 747
FadedCoder Avatar asked Jun 28 '26 19:06

FadedCoder


1 Answers

After lots of trials and errors, I finally found the solution. Actually the output in detect should be a GpuMat not a vect2d. I would have figured this out earlier, but the documentation of OpenCV is very confusing. Here's the edited code -

Ptr<HoughLinesDetector> houghLines = createHoughLinesDetector(1, CV_PI / 180, 120);
GpuMat tmpLines; // This should be GpuMat...
vector<Vec2d> lines;
GpuMat imgCanny;
... 
while(true) {
    ...
    houghLines->detect(imgCanny, tmpLines);
    houghLines->downloadResults(tmpLines, lines);
    ...
}
like image 119
FadedCoder Avatar answered Jul 01 '26 11:07

FadedCoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!