#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;
}
我感觉我配置的环境应该没问题啊,