【发布时间】:2015-06-20 15:39:08
【问题描述】:
对于它的生命,我无法让 CUDA 模块在 OpenCV3.0 Beta 下与 Visual Studio 2013 64Bit Professional、CUDA SDK 6.5 和 Win7 64Bit 一起工作。半年前,我使用的示例代码在 OpenCV3.0 Alpha 上完美运行。现在我什至无法让 cv::cuda::flip 工作;该代码一直有效,直到它应该将 Mat 上传到 CUDA,但随后它停止工作。
有人可以提供一个工作示例代码,这样我就可以看到我在哪里忽略了某些东西?
我之前做过的所有步骤:
在使用 CMake 和 MSVC2013 Professional 启用 CUDA 和 OpenGL 构建 OpenCV3.0Beta 后,我在 Debug and Release /X64 Config 中构建了 OpenCV.sln(表示成功构建:每个 266)。之后,我分别在 modules/smaples/include 和 data-folder 的 Debug/Release X64-Config 中构建了 INSTALL.vcxproj,因此它们都被复制到了 install-folder。
在属性 C++ 常规下:
D:\OpenCV\GebautmitCUDAohneTBB\install\include D:\Programme\glew-1.12.0\include D:\Programme\freeglut\include
在属性链接器常规下:
D:\OpenCV\GebautmitCUDAohneTBB\install\x64\vc12\lib D:\Programme\glew-1.12.0\lib\Release\x64 D:\Programme\freeglut\lib\x64
在属性链接器输入下:
通常的 OpenCV 库, glew32.lib, freeglut.lib
这是我的示例代码:
#if defined _MSC_VER && _MSC_VER >= 1400
#pragma warning(disable : 4100)
#endif
#include <iostream>
#include <iomanip>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"
using namespace std;
using namespace cv;
using namespace cv::cuda;
int main() {
/*
if (getCudaEnabledDeviceCount() == 0)
{
return cerr << "No GPU found or the library is compiled without CUDA support" << endl, -1;
}
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
*/
Mat image, image2, imagedownloaded, demoimage, grayimage;
image = imread("fruits.jpg", 1);
if (image.channels() == 1)
{
cout << "1 channel";
}
else
{
cout << "3 channel";
}
cv::cvtColor(image, image, COLOR_BGR2GRAY);
GpuMat image_gpu, gray_gpu, demo_gpu, image_gpu2;
image_gpu2.upload(image);
cv::cuda::demosaicing(image_gpu2, demo_gpu, COLOR_BayerGR2BGR, 3);
demo_gpu.download(demoimage);
if (demoimage.channels() == 1)
{
cout << "1 channel";
}
else
{
cout << "3 channel";
}
imshow("bla2", image);
imshow("bla3", demoimage);
waitKey();
return 0;
}
谁能指出我忘记了什么,所以它会再次起作用?
谢谢。
【问题讨论】:
标签: c++ opencv visual-studio-2012