为什么CV :: Cuda :: CV ::重新映射是错误的吗?
我使用cv :: cuda :: remap
而不是cv :: remap
利用CUDA加速度来加快视频不合格。该程序的两个版本均可正常运行,但是,虽然相机矩阵,失真系数,MAP1和MAP2来自cv :: initundististortrectifymap()
都是相同的,但CPU的未呈现结果图像版本cv :: remap
是正确的,如下:
但是CUDA版本cv :: cuda :: remap
导致问题:
CPU版本的代码段如下:
cv::cuda::GpuMat gpuMat(m_height, m_width, CV_8UC4, (void *)dpFrame);
cv::Mat mat;
gpuMat.download(mat);
cv::remap(mat, mat, m_map1, m_map2, cv::INTER_LINEAR);
gpuMat.upload(mat);
:
cv::cuda::GpuMat gpuMat(m_height, m_width, CV_8UC4, (void *)dpFrame);
cv::cuda::remap(gpuMat, gpuMat, m_gpuMap1, m_gpuMap2, cv::INTER_LINEAR);
GPU版本 他们,dpframe
是类型cudeviceptr
,m_map1
和m_map2
是由cv :: initundististortortectifymap
计算的/code>,m_gpumap1
和m_gpumap2
是类型cv :: cuda :: gpumat
通过上传m_map1
和m_map2
获得。
cv :: remap
和cv :: cuda :: remap
是相同的算法,为什么它们的结果不同?我尝试了两个版本的OpENCV 455和460,并且两种版本都不起作用。
我被困在这里,不知道该如何前进。任何建议都非常感谢。谢谢。
I use cv::cuda::remap
instead of cv::remap
to take advantage of CUDA acceleration to speed up video undistortion. Both versions of the program can run normally, but, while the camera matrix, distortion coefficients, map1 and map2 which come from cv::initUndistortRectifyMap()
are all the same, the undistorted result image of the CPU version cv::remap
is correct as follow:
but the CUDA version cv::cuda::remap
results in a problem:
The code snippet for the CPU version is as follows:
cv::cuda::GpuMat gpuMat(m_height, m_width, CV_8UC4, (void *)dpFrame);
cv::Mat mat;
gpuMat.download(mat);
cv::remap(mat, mat, m_map1, m_map2, cv::INTER_LINEAR);
gpuMat.upload(mat);
GPU version:
cv::cuda::GpuMat gpuMat(m_height, m_width, CV_8UC4, (void *)dpFrame);
cv::cuda::remap(gpuMat, gpuMat, m_gpuMap1, m_gpuMap2, cv::INTER_LINEAR);
Among them, dpFrame
is of type CUdeviceptr
, m_map1
and m_map2
are calculated by cv::initUndistortRectifyMap
, m_gpuMap1
and m_gpuMap2
are of type cv::cuda::GpuMat
obtained by uploading m_map1
and m_map2
to GPU.
cv::remap
and cv::cuda::remap
are the same algorithm, why are their results different? I tried both versions of OpenCV 455 and 460, and neither works.
I'm stuck here and don't know how to go forward. Any suggestions are really appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Okey,我还尝试了您的代码并获得了类似的结果。经过几次测试,我最终得到了正确的结果。
我的代码只需翻转重新映射的图像。这是您输入的代码结果:
代码
输入
输出
然后我只添加一个新的声明
cv :: cuda :: gpumat
,然后将其放入ressize
函数的输出中。这是代码。新输出
我对为什么的问题没有明确的答案。由于我们处理GPU,因此最好定义不同类型的输入和输出
ressize
的输出。Okey, I also tried your code and got the similar results. I ended up with getting a correct result after a few tests.
My code simply flips an image with remap. Here is your code result to my input:
Code
Input
Output
Then I just add a new declaration of
cv::cuda::GpuMat
and put it to output ofresize
function. Here is the code.New Output
I dont have a clear answer to the question why. Since we deal with gpu, it seems better to define different types for input and output of
resize