我在CPU上试过Hough,运行正常,只是有点慢。所以,我试图在OpenCV CUDA上运行Hough,但它显示了这个错误,即使我有GpuMat -
OpenCV错误:在cv :: _ InputArray :: getGpuMat,文件PATH \ opencv-sources \ modules \ core \ src中没有实现函数/功能(getGpuMat仅适用于cuda :: GpuMat和cuda :: HostMem) \ matrix.cpp,第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...
...
}
对此有何帮助?
答案 0 :(得分: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);
...
}