码迷,mamicode.com
首页 > 编程语言 > 详细

使用SSD目标检测c++接口编译问题解决记录

时间:2018-10-09 12:20:05      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:tps   span   测试   erer   util   ror   ssd   enc   version   

本来SSD做测试的Python接口用起来也是比较方便的,但是如果部署集成的话,肯定要用c++环境,于是动手鼓捣了一下。

编译用的cmake,写的CMakeList.txt,期间碰到一些小问题,简单记录一下问题以及解决方法。

当然前提是你本地的caffe环境没啥问题。各种依赖都安好了。。

1.error: ‘AnnotatedDatum’ has not been declared    AnnotatedDatum* anno_datum);

/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:192:40: error: ‘AnnotatedDatum_AnnotationType’ does not name a type
     const std::string& encoding, const AnnotatedDatum_AnnotationType type,
                                        ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:194:5: error: ‘AnnotatedDatum’ has not been declared
     AnnotatedDatum* anno_datum);
     ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:199:11: error: ‘AnnotatedDatum_AnnotationType’ does not name a type
     const AnnotatedDatum_AnnotationType type, const string& labeltype,
           ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:200:49: error: ‘AnnotatedDatum’ has not been declared
     const std::map<string, int>& name_to_label, AnnotatedDatum* anno_datum) {
                                                 ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:208:5: error: ‘AnnotatedDatum’ has not been declared
     AnnotatedDatum* anno_datum);
     ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:212:5: error: ‘AnnotatedDatum’ has not been declared
     AnnotatedDatum* anno_datum);
     ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:215:22: error: ‘AnnotatedDatum’ has not been declared
     const int width, AnnotatedDatum* anno_datum);
                      ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:218:30: error: ‘LabelMap’ has not been declared
     const string& delimiter, LabelMap* map);
                              ^
/home/jiawenhao/ssd/caffe/include/caffe/util/io.hpp:221:32: error: ‘LabelMap’ has not been declared
       bool include_background, LabelMap* map) {
                                ^

这个问题拿去google了一下,https://github.com/BVLC/caffe/issues/5671提示说是

caffe.pb.h这个文件有问题。

在本地find了一下,技术分享图片

发现是有这个文件的,

于是在/ssd/caffe/include/caffe下 mkdir一下 proto,然后把 caffe.bp.h 复制过来就好了

如果没有 caffe.pb.h可以用命令生成这个文件,生成方法google一下就好了。。。。

2.链接库的问题。错误提示说明用到了这个库,但是程序没找到。在CMakeList.txt里填上 libflags.so即可 ,其他so库同理。

/usr/bin/ld: CMakeFiles/ssd_detect.dir/ssd_detect.cpp.o: undefined reference to symbol _ZN6google14FlagRegistererC1EPKcS2_S2_S2_PvS3_
/usr/lib/x86_64-linux-gnu/libgflags.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/ssd_detect.dir/build.make:102: recipe for target ssd_detect failed
make[2]: *** [ssd_detect] Error 1

 

技术分享图片

 

 

这个是CMakeList.txt内容。 就是指定好include路径,还有需要用到的各种库的路径。

cmake_minimum_required (VERSION 2.8)  
add_definitions(-std=c++11)
project (ssd_detect)  
  
add_executable(ssd_detect ssd_detect.cpp)  
  
include_directories (/home/yourpath/ssd/caffe/include      
    /usr/include    
    /usr/local/include  
    /usr/local/cuda/include    
         
     )  
  
target_link_libraries(ssd_detect  
     /home/yourpath/ssd/caffe/build/lib/libcaffe.so
     /usr/local/lib/libopencv_core.so 
     /usr/local/lib/libopencv_imgproc.so
     /usr/local/lib/libopencv_imgcodecs.so 
    /usr/local/lib/libopencv_highgui.so
    /usr/local/lib/libopencv_videoio.so
    /usr/lib/x86_64-linux-gnu/libgflags.so     
    /usr/lib/x86_64-linux-gnu/libglog.so    
    /usr/lib/x86_64-linux-gnu/libprotobuf.so    
    /usr/lib/x86_64-linux-gnu/libboost_system.so    
    )  

 

使用SSD目标检测c++接口编译问题解决记录

标签:tps   span   测试   erer   util   ror   ssd   enc   version   

原文地址:https://www.cnblogs.com/hellowooorld/p/9759522.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!