sbaban 2015-07-22 11:58 采纳率: 0%
浏览 5500
已结题

cuda opencv GPU模块的使用出错

#include
#include
#include
#include
#include
#include
#include

int main()
{
int num_devices = cv::gpu::getCudaEnabledDeviceCount();
if (num_devices <= 0)
{
std::cerr << "There is no devoce" << std::endl;
return -1;
}
int enable_device_id = -1;
for (int i = 0; i < num_devices; i++)
{
cv::gpu::DeviceInfo dev_info(i);
if (dev_info.isCompatible())
{
enable_device_id = i;
}
}
if (enable_device_id < 0)
{
std::cerr << "GPU module isn't built for GPU" << std::endl;
return -1;
}

cv::gpu::setDevice(enable_device_id);

cv::Mat src_image = cv::imread("test.jpg");
cv::Mat dst_image;

cv::gpu::GpuMat d_dst_img;
cv::gpu::GpuMat d_src_img(src_image);//upload src image to gpu

//为什么从这以后的代码不执行了

printf("abcd");//测试使用
//cv::gpu::cvtColor(d_src_img, d_dst_img, CV_BGR2GRAY);
//d_dst_img.download(dst_image);//download dst image to cpu
//cv::imshow("test", dst_image);
cv::imshow("test", src_image);
cv::waitKey(5000);
return 0;
}
我感觉我配置的环境应该没问题啊,

  • 写回答

2条回答

  • oyljerry 2015-07-22 12:43
    关注

    代码不执行是后面代码没生效还是代码出错异常了。先要定位具体出错的函数,然后看是否参数等不正确

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料