SSD-windows caffe 编译,基于BVLC-windows版本

这篇博客记录了如何使用BVLC版本的caffe编译windows下的ssd,不喜欢微软版caffe的可以使用这个。


准备工作:

  1. cmake-gui
  2. BVLC版本caffe-windows
  3. Microsoft版本ssd-caffe


1.CPU模式

  1. 解压BVLC版本caffe-windows。
  2. 解压Microsoft版本ssd-caffe。
  3. 进入解压后的caffe-windows,删除include,matlab,models,python,scripts文件夹,并将ssd-caffe下的这几个文件夹复制过来。注意:将ssd-caffe的include复制过来后,删除这个文件夹里面的proto文件夹。
  4. 在caffe-windows中的include/caffe文件夹下添加一个新文件夹3rdparty,并在这个文件夹下新建一个文件,命名为hungarian.h
  5. 删除caffe-windows/src/caffe文件夹下所有文件,保留CmakeLiset.txt和caffe-windows/src/caffe/test/CmakeList.txt两个文件。将ssd-caffe下对应的src/caffe文件复制过去。注意不要覆盖两个CmakeList.txt文件。
  6. 在caffe-windows/src/caffe文件夹下新建一个文件夹3rdparty,进入3rdparty文件夹,新建一个文件,命名为hungarian.cpp
  7. 修改detection_output_layer.hpp文件,注释掉
  8. //#include <boost/regex.hpp>
  9. 修改detection_output_layer.cpp,注释掉
    //boost::regex exp("\"(null|true|false|-?[0-9]+(\\.[0-9]+)?)\"");
    /*std::string rv = boost::regex_replace(ss.str(), exp, "$1");
              outfile << rv.substr(rv.find("["), rv.rfind("]") - rv.find("["))
                  << std::endl << "]" << std::endl;*/

  10. 使用cmake-gui生成解决方案
  11. 打开解决方案,在caffe工程属性中添加附加包含目录caffe-windows/src,注意:不做这一步编译时候会报错找不到gtest
  12. 编译caffe工程
  13. 编译ALL_BUILD工程
  14. 编译INSTALL工程


2.GPU模式

在CPU模式的基础上继续做修改

  1. 修改bbox_util.cu,注释掉所有带thrust的语句
    //#include "thrust/functional.h"
    //#include "thrust/sort.h"

    /*thrust::sort_by_key(&confidences[0], &confidences[0] + num_remain, &idx[0],
          thrust::greater<Dtype>());*/

  2. 修改detection_output_layer.cu,注释掉boost::regex的语句
     //boost::regex exp("\"(null|true|false|-?[0-9]+(\\.[0-9]+)?)\"");

    /*std::string rv = boost::regex_replace(ss.str(), exp, "$1");
              outfile << rv.substr(rv.find("["), rv.rfind("]") - rv.find("["))
                  << std::endl << "]" << std::endl;*/
  3. 使用cmake生成解决方案
  4. 打开解决方案,在caffe工程属性中添加附加包含目录caffe-windows/src,注意:不做这一步编译时候会报错找不到gtest
  5. 编译caffe工程
  6. 编译ALL_BUILD工程
  7. 编译INSTALL工程
工程链接:https://github.com/liuwei1023/SSD



Q&A

1.错误 2 error LNK2019: 无法解析的外部符号 "public: __cdecl cv::VideoWriter::VideoWriter(class cv::String const &,int,double,class cv::Size_<int>,bool)" (??0VideoWriter@cv@@QEAA@AEBVString@1@HNV?$Size_@H@1@_N@Z),该符号在函数 "void __cdecl caffe::VisualizeBBox<float>(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class caffe::Blob<float> const *,float,class std::vector<class cv::Scalar_<double>,class std::allocator<class cv::Scalar_<double> > > const &,class std::map<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$VisualizeBBox@M@caffe@@YAXAEBV?$vector@VMat@cv@@V?$allocator@VMat@cv@@@std@@@std@@PEBV?$Blob@M@0@MAEBV?$vector@V?$Scalar_@N@cv@@V?$allocator@V?$Scalar_@N@cv@@@std@@@2@AEBV?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) 中被引用



解决:这个错误是链接器里面没有加入opencv的lib导致的。在报错的项目属性中找到链接器--输入。在里面加入xxxxxxxxxxx\opencv_videoio310.lib这个lib,注意写全这个lib的路径。



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值