OpenCV GPU Error (Function Not Implemented) in Hough Transform

你。 提交于 2019-12-10 19:08:27

问题


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?


回答1:


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);
    ...
}


来源:https://stackoverflow.com/questions/35700595/opencv-gpu-error-function-not-implemented-in-hough-transform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!