根据py-faster-rcnn的demo.py修改成c++版本
注意:C++版本代码已更新。基本问题已修复。改动较多, 请参考 【更新】根据py-faster-rcnn的demo.py修改成c++版本。请参考最新代码和最新的readme。本文是对https://github.com/galian123/libfaster_rcnn_cpp的说明,此repo是我从XieQiang 的libfaster_rcnn_cpp fork出来的代码,并做了整理。
注意:C++版本代码已更新。基本问题已修复。改动较多, 请参考 【更新】根据py-faster-rcnn的demo.py修改成c++版本 。请参考最新代码和最新的readme。
本文是对https://github.com/galian123/libfaster_rcnn_cpp的说明,此repo是我从XieQiang 的libfaster_rcnn_cpp fork出来的代码,并做了整理。
我主要做了3个修改:
删掉了多余的头文件和cmake要include的目录位置。删掉了不需要链接的so文件。
在src目录的CMakeLists.txt增加了
faster_rcnn_path
变量,这样对cmake编译环境来说,只需要把这个变量更新为你自己的py-faster-rcnn的路径即可。不用再修改其他的CMakeLists.txt了。不用再手动拷贝gpu_nms.so文件了。这个拷贝操作是由cmake自动完成的。
下面是我整理后readme的内容:
Note:
This repo is forked from https://github.com/QiangXie/libfaster_rcnn_cpp .
But I found another similar code: https://github.com/YihangLou/FasterRCNN-Encapsulation-Cplusplus
Most of code is same.
And there is blog to explain the code: http://blog.csdn.net/xyy19920105/article/details/50440957
What I have done:
1. Delete redundant ‘include’ and undependent .so files
2. Set faster_rcnn_path
for all CMakeLists.txt.
You only need to set only one viarable (faster_rcnn_path
) to configure environment.
3. You don’t have to copy gpu_nms.so manually. This is done by cmake automatically now.
This project is Faster-rcnn detector C++ version demo, if you want to learn more about Faster-rcnn, please click py-faster-rcnn.
0. Precondition
Make sure your py-faster-rcnn
works well.
1. Download code
git clone https://github.com/galian123/libfaster_rcnn_cpp
2 set faster_rcnn_path
in src/CMakeLists.txt
Like this : set(faster_rcnn_path "~/git/py-faster-rcnn/")
If you forget to set faster_rcnn_path
, error will happen if you run cmake ..
.
CMake Error at src/CMakeLists.txt:4 (message):
Error: please set ${faster_rcnn_path} before run cmake.
${faster_rcnn_path} is where your 'py-faster-rcnn' exists.
-- Configuring incomplete, errors occurred!
3 Modify main.cpp
Set your path of test.prototxt
and .caffemodel
file in main.cpp
.
4 Build
Current folder is libfaster_rcnn_cpp
.
mkdir build
cd build
cmake ..
make
5 Run the program
Current folder is libfaster_rcnn_cpp
.
NOTE: run main
in ./bin
folder. Because hardcode ‘test1.jpg’ is in bin
folder.
cd bin
./main
This program will detect test1.jpg in bin folder, and print the detected vehicle bounding box, then rectangle bounding box and saved as test.jpg. If you need modify this project to do more, see main.cpp.
6 TODO
Make main(main.cpp) can receive arguments, or save settings to yaml file.
7 Fix protobuf version error
I1222 20:17:27.105358 24948 layer_factory.hpp:77] Creating layer proposal
[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.4.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): This program requires version 3.4.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
Aborted (core dumped)
Solution:
Run pip show protobuf
to show protobuf version in python (installed via pip).
Run protoc --version
to show protobuf version (installed via apt-get).
These two version are not same.
Uninstall protobuf: sudo pip uninstall protobuf
Install protobuf with version 2.6.1: sudo pip install protobuf==2.6.1
Then recompile `py-faster-rcnn’.
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)