请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册
首页 社区 AI 如何在visual studio中像使用opencv一样使用caffe ...

如何在visual studio中像使用opencv一样使用caffe

猿梦 2022-11-19 03:36:48
思路我们都知道在Visual Studio中使用OpenCV是非常方便的,只要配置好相关的路径,建立一个属性表就可以了。接触过Caffe的可能会知道,在Caffe的例程中并没有怎么说如何建立一个属性表,就能够使用Caffe提供的一些函数去构造程序。话说一个月前刚刚在Github上帮一个老外解决了这个问题,所以这里也写一下我的方法。要用Caffe,就是 include 、lib 、dll,和OpenCV一样,搞好这三个即可,推荐大家配置Release版本的,所以在编译Caffe的时候,换成Release模式也编译一次。实现观察caffe-master的第三方程序包,毫无疑问,这个与caffe-master本文件夹都需要加上去的。所以在属性表里,先后需要include以下这些:(路径请自行修改)D:\caffe-master\includeD:\NugetPackages\boost.1.59.0.0\lib\native\includeD:\NugetPackages\glog.0.3.3.0\build\native\includeD:\NugetPackages\gflags.2.1.2.1\build\native\includeD:\NugetPackages\protobuf-v120.2.6.1\build\native\includeC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\includeD:\NugetPackages\OpenBLAS.0.2.14.1\lib\native\includeD:\caffe-master\include\caffe\layersD:\NugetPackages\OpenCV.2.4.10\build\native\includeD:\NugetPackages\OpenCV.2.4.10\build\native\include\opencvD:\NugetPackages\OpenCV.2.4.10\build\native\include\opencv我们可以看到,这个第三方程序包里面已经有OpenCV了,所以我们没必要把OpenCV的属性表添加。然后,我们需要添加lib:(路径请自行修改)D:\NugetPackages\boost_date_time-vc120.1.59.0.0\lib\native\address-model-64\libD:\NugetPackages\boost_filesystem-vc120.1.59.0.0\lib\native\address-model-64\libD:\NugetPackages\boost_system-vc120.1.59.0.0\lib\native\address-model-64\libD:\caffe-master\Build\x64\ReleaseD:\NugetPackages\boost_thread-vc120.1.59.0.0\lib\native\address-model-64\libD:\NugetPackages\boost_chrono-vc120.1.59.0.0\lib\native\address-model-64\libD:\NugetPackages\protobuf-v120.2.6.1\build\native\lib\x64\v120\ReleaseD:\NugetPackages\OpenCV.2.4.10\build\native\lib\x64\v120\ReleaseD:\NugetPackages\glog.0.3.3.0\build\native\lib\x64\v120\Debug\dynamicD:\NugetPackages\gflags.2.1.2.1\build\native\x64\v120\dynamic\LibD:\NugetPackages\hdf5-v120-complete.1.8.15.2\lib\native\lib\x64D:\NugetPackages\OpenBLAS.0.2.14.1\lib\native\lib\x64C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\lib\x最后一项是CUDA的配置路径,找一下应该就可以找到。那么我们的附加依赖项需要添加:libcaffe.liblibprotobuf.libopencv_highgui2410.libopencv_core2410.libopencv_imgproc2410.liblibglog.libgflags.liblibopenblas.dll.ahdf5.libhdf5_hl.libcublas.libcublas_device.libcuda.libcudadevrt.libcudnn.libcudart.libcufft.libcudart_static.libcudnn_static.libcufftw.libcusparse.libcusolver.libcurand.libnppc.libOpenCL.lib对了,最后别忘了配置环境变量哟,配置完之后重启一遍:D:\NugetPackages\gflags.2.1.2.1\build\native\x64\v120\dynamic\LibD:\NugetPackages\hdf5-v120-complete.1.8.15.2\lib\native\bin\x64D:\NugetPackages\glog.0.3.3.0\build\native\bin\x64\v120\Release\dynamicD:\NugetPackages\OpenBLAS.0.2.14.1\lib\native\bin\x64D:\NugetPackages\gflags.2.1.2.1\build\native\x64\v120\dynamic\LibD:\NugetPackages\OpenCV.2.4.10\build\native\bin\x64\v120\Release这里还是建议大家建立一个属性表,方便后面的程序添加,就像这样:那么在做完这些之后,我们就可以在新建工程里使用Caffe的接口了

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册