首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gpu::cvtColor(input_gpu,output_gpu,CV_BGR2GRAy)

gpu::cvtColor(input_gpu,output_gpu,CV_BGR2GRAy)
EN

Stack Overflow用户
提问于 2015-09-07 23:49:43
回答 1查看 3.7K关注 0票数 0

我正在尝试学习如何在OpenCV中使用图形处理器程序。我已经用CUDA构建了一切,如果我运行

代码语言:javascript
复制
cout << " Number of devices " << cv::gpu::getCudaEnabledDeviceCount() << endl;

我得到的答案是1个设备,所以至少有些东西看起来是有效的。然而,我尝试了下面的代码,它只是打印出消息,然后什么也没有发生。它被卡住了

代码语言:javascript
复制
cv::gpu::cvtColor(input_gpu, output_gpu, CV_BGR2GRAY);

以下是代码

代码语言:javascript
复制
#include<iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/gpu/gpu.hpp>
#include <opencv2/opencv.hpp>

using std::cout;
using std::endl;

int main(void){
    cv::Mat input = cv::imread("image.jpg");

    if (input.empty()){
        cout << "Image Not Found" << endl;
        return -1;
    }
    cv::Mat output;

    // Declare the input and output GpuMat
    cv::gpu::GpuMat input_gpu;
    cv::gpu::GpuMat output_gpu;

    cout << "Number of devices: " << cv::gpu::getCudaEnabledDeviceCount() << endl;
    // Copy the input cv::Mat to device.
    // Device memory will be allocated automatically according to the parameters of input image
    input_gpu.upload(input);
    // Convert the input image to grayScale on GPU
    cv::gpu::cvtColor(input_gpu, output_gpu, CV_BGR2GRAY);

    //// Copy the result from GPU back to host

    output_gpu.download(output);

    cv::imshow("Input", input);
    cv::imshow("Output", output);
    cv::waitKey(0);
    return 0;
}

我刚刚发现了this的问题,这似乎是Maxwell架构的问题,但这篇文章已经发布了一年多了。有没有其他人遇到过同样的问题?我使用的是windows 7、Visual Studio 2013和Nvidia Geforce GTX 770。

/ Erik

EN

回答 1

Stack Overflow用户

发布于 2015-09-08 15:16:56

好吧,我真的不知道问题是什么,但是在CMake中,我把CUDA_GENERATION改成了开普勒,这是我的图形处理器的微架构,然后我重新编译了它,现在代码可以正常工作了。

有趣的是,只有费米和开普勒可供选择,所以我不知道麦克斯韦是否会有问题。

/ Erik

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32442287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档