【发布时间】:2019-03-18 21:22:58
【问题描述】:
我需要将 opencv::gpumat 转换为推力::device_vector,然后执行推力::copy_if,然后将生成的推力::device_vector 再次复制到 cv::gpumat。
如何从 cv::gpumat 转换为推力::device_vector 反之亦然?
我的代码(如下)给出了编译错误: 错误:需要一个类型说明符
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
nvcc:Cuda 编译工具,8.0 版,V8.0.44
推力 v1.8
ubuntu 16.04
我的代码:
#include <thrust/random.h>
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>
#include <opencv2/core/cuda.hpp>
int main(void)
{
cv::Mat input_host(1,100,CV_32F);
cv::Mat output_host(1,100,CV_32F);
cv::randu(input_host, cv::Scalar(-10), cv::Scalar(10));
cv::cuda::GpuMat input_device(1, 100, CV_32F);
input_device.upload(input_host);
thrust::device_ptr<CV_32F> input_ptr(input_device.ptr());
thrust::device_vector<CV_32F> input_device_vector (input_ptr,100);
return 0;
}
【问题讨论】:
-
该链接提供了如何从原始指针到 gpuMat 的想法。我需要先将 gpuMat 转换为推力::device_ptr,然后从 device_ptr 转换为 gpuMat
标签: compiler-errors cuda opencv3.0 thrust