2016-02-29 377 views
3

我在CPU上试过Hough,运行良好,速度稍慢。所以,我想在OpenCV的CUDA运行霍夫,但它表明这个错误,即使我有GpuMat -霍夫变换中的OpenCV GPU错误(功能未实现)

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

这是我的代码(我流从现场摄像机帧,所以在while循环中) -

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

对此有何帮助?

回答

4

经过大量的试验和错误,我终于找到了解决方案。实际上detect的输出应该是GpuMat而不是vect2d。我早就想到了这一点,但OpenCV的文档非常混乱。这里是编辑的代码 -

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