霍夫变换中的 OpenCV GPU 错误(未实现函数) [英] OpenCV GPU Error (Function Not Implemented) in Hough Transform

查看:123
本文介绍了霍夫变换中的 OpenCV GPU 错误(未实现函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 错误:在 cv::_InputArray::getGpuMat 文件 PATH\opencv-sources\modules\core\src 中未实现函数/特性(getGpuMat 仅适用于 cuda::GpuMat 和 cuda::HostMem)\matrix.cpp,第 1454 行

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 循环中)-

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

对此有帮助吗?

推荐答案

经过多次尝试和错误,我终于找到了解决方案.实际上 detect 中的输出应该是 GpuMat 而不是 vect2d.我早就想通了,但是 OpenCV 的文档非常混乱.这是编辑后的代码 -

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

这篇关于霍夫变换中的 OpenCV GPU 错误(未实现函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆