根据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出来的代码,并做了整理。
我主要做了3个修改:

  1. 删掉了多余的头文件和cmake要include的目录位置。删掉了不需要链接的so文件。

  2. 在src目录的CMakeLists.txt增加了 faster_rcnn_path 变量,这样对cmake编译环境来说,只需要把这个变量更新为你自己的py-faster-rcnn的路径即可。不用再修改其他的CMakeLists.txt了。

  3. 不用再手动拷贝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’.

Refer to https://github.com/BVLC/caffe/issues/5711

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值