问题描述
我正在尝试使用OpenCvSharp
包括GPU.我在Microsoft Visual Studio 2013中使用Nuget软件包管理器安装了OpenCvSharp.
I am trying to include GPU using OpenCvSharp
. I installed the OpenCvSharp by using Nuget Package Manager in Microsoft Visual Studio 2013.
我已经包含了这些行
using OpenCvSharp;
using OpenCvSharp.CPlusPlus;
using OpenCvSharp.CPlusPlus.Gpu;
但是当我检查设备数量
//GPU
int count = Cv2Gpu.GetCudaEnabledDeviceCount();
//int count = Cv2Gpu.ge
Console.WriteLine("The GPU Device count is " + count.ToString());
它总是返回0.
现在它还说如果OpenCv
没有用CUDA
编译,那么它总是返回0.它甚至没有得到DeviceDetails
.
Now it also says if OpenCv
is not compiled with CUDA
then it always returns 0.it does not even get DeviceDetails
.
推荐答案
我已经通过构建opencv_core.dll和opencv_gpu.dll解决了此问题.
I have resolved this problem by building the opencv_core.dll and opencv_gpu.dll.
用Cmake制作opencv的源代码,并且不要忘记先配置源代码就选择"withcuda"选项.
Make the source code of opencv with Cmake and dont forget to select "withcuda" option while configuring the source code first.
生成后,然后在构建文件夹中打开OpenCv解决方案,并首先构建opencv_core,然后构建opencv_gpu.
after generation then open OpenCv solution in build folder and first build opencv_core and then opencv_gpu.
一旦您将bin文件夹中的dll替换为opencvsharp软件包文件夹中的dll.现在再次构建项目.现在,该项目会将新的dll复制到所需的文件夹中.
once you got the dll in the bin folder replace them in the opencvsharp package folder. Now build the project again. Now the project will copy the new dll's to the required folder.
这篇关于使用NUGET PAckage Manager安装的OpenCvSharp未检测到CUDA设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!