项目作者: xyfer17

项目描述 :
object detection using mobilenetV2 SSDlite model
高级语言: C++
项目地址: git://github.com/xyfer17/Object-detection-caffe.git
创建时间: 2021-01-14T18:51:17Z
项目社区:https://github.com/xyfer17/Object-detection-caffe

开源协议:MIT License

下载


Object-detection-caffe

detection

Steps to build Caffe-SSD for object detection:

Step 1:

Note: Please make sure that you have Ubuntu 16.04 as the OS environment before running this module

  • Check that you have gcc version 6 or greater which is supported by caffe. Please follow the steps mentioned over here to install gcc-6.
  • Install all dependencies:

    1. $ sudo add-apt-repository ppa:lkoppel/opencv
    2. $ sudo apt-get update
    3. $ sudo apt install libopencv-calib3d3.2 libopencv-core3.2 libopencv-features2d3.2 libopencv-flann3.2 libopencv-highgui3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-ml3.2 libopencv-objdetect3.2 libopencv-photo3.2 libopencv-shape3.2 libopencv-stitching3.2 libopencv-superres3.2 libopencv-video3.2 libopencv-videoio3.2 libopencv-videostab3.2 libopencv-viz3.2 libopencv3.2-jni libopencv3.2-java libopencv-contrib3.2
    4. $ sudo apt install libopencv-calib3d-dev libopencv-core-dev libopencv-features2d-dev libopencv-flann-dev libopencv-highgui-dev libopencv-imgcodecs-dev libopencv-imgproc-dev libopencv-ml-dev libopencv-objdetect-dev libopencv-photo-dev libopencv-shape-dev libopencv-stitching-dev libopencv-superres-dev libopencv-video-dev libopencv-videoio-dev libopencv-videostab-dev libopencv-viz-dev libopencv-contrib-dev libopencv-dev
    5. $ sudo apt-get install libopencv-dev python3-opencv
    6. $ sudo apt-get install libopenblas-dev
    7. $ sudo apt-get install libboost-all-dev
    8. $ sudo apt install python3-pip
    9. $ pip3 install protobuf==3.11.3
    10. $ sudo apt-get install libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev
    11. $ sudo apt-get install python3-dev python-dev
    12. $ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
  • Build boost library from source.

    1. $ wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz
    2. $ tar xzvf boost_1_66_0.tar.gz
    3. $ cd boost_1_66_0/
    4. $ sudo apt-get update
    5. $ sudo apt-get install build-essential autotools-dev libicu-dev libbz2-dev
    6. $ ./bootstrap.sh --prefix=/usr/local/
    7. $ ./b2 -j8 variant=release link=shared threading=multi runtime-link=shared
    8. $ sudo ./b2 -j8 install
  • Build protobuf library from source.Download protobuf-all-version-3.11.4.tar.gz from here, extract file and build it using below commands.

    1. $ sudo apt-get install autoconf automake libtool curl make g++ unzip cpio
    2. cd protobuf-3.11.4
    3. ./configure
    4. make
    5. make check
    6. sudo make install
    7. sudo ldconfig

    Step 2:

  • For ssdlite I have used python 2.7, because python 3 had issues. Ubuntu’s deafult python would do the task or make sure you have python 2.7 on your system.

    1. git clone https://github.com/xyfer17/ssd-caffe.git
    2. cd ssd-caffe
  • Follow the below command to build the ssd-caffe

    1. make all
    2. make test
    3. make runtest
    4. make pycaffe

    Inference process

  • clone this repository using the below command

    1. $ git clone https://github.com/xyfer17/Object-detection-caffe.git
    2. $ cd Object-detection-caffe/src
  • Follow this step to add your image file which you want to test using the detection model.

  • open inference.cpp file using your text-editor and the search the below code inside it.
    1. cv::Mat cv_img = cv::imread("img/3.jpg")
  • replace img/3.jpg to your image file path .

  • After this follow these command for execution process

    1. $ g++ -o app inference.cpp -I /****/ssd-caffe/include/ -I /***/ssd-caffe/.build_release/src/ `pkg-config --libs --cflags opencv` -L /****/ssd-caffe/build/lib/ -lcaffe -lglog -lboost_system -lprotobuf -DCPU_ONLY=1
    1. $ export LD_LIBRARY_PATH=/path-to/ssd-caffe/build/lib/:$LD_LIBRARY_PATH
    2. $ export LD_LIBRARY_PATH=/path-to/boost_1_66_0/stage/lib/:$LD_LIBRARY_PATH
    3. $ ./app