我在 CPU 上试过 Hough,它运行良好,只是有点慢。所以,我试图在 OpenCV CUDA 上运行 Hough,但它显示了这个错误,即使我有 GpuMat -



这是我的代码(我从实时摄像头流式传输帧,因此在 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...
    ...
}

这有什么帮助吗?

最佳答案

经过大量的试验和错误,我终于找到了解决方案。实际上 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);
    ...
}

关于c++ - 霍夫变换中的 OpenCV GPU 错误(函数未实现),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35700595/

10-11 04:20