MIVisionX

MIVisionX toolkit is a set of comprehensive computer vision and machine intelligence libraries, utilities, and applications bundled into a single toolkit. AMD MIVisionX also delivers a highly optimized open-source implementation of the Khronos OpenVX™ and OpenVX™ Extensions.

Object detection with video decoding sample

This sample shows how to run video decoding and object detection using pre-trained YoloV2 Caffe Model

The sample demonstrates the use of mv_compile utility to do video decoding and inference.

The sample has two .cpp files, mvobjdetect.cpp and visualize.cpp. But it needs extra header files, .cpp files, and inference deployment library which is generated by mv_compile utility to completely build and execute the application.

Prerequisites

Sample - Detection Using Pre-Trained CAFFE Model

Step 1. Download pre-trained YoloV2 caffe model - yoloV2Tiny20.caffemodel

[!TIP]

wget https://github.com/kiritigowda/YoloV2NCS/raw/master/models/caffemodels/yoloV2Tiny20.caffemodel

Step 2. compile model for OpenVX backend using mv_compile utility

The mv_compile utility generates deployment library, header files, and .cpp files required to run inference for the specified model.

[!TIP]

mv_compile --model yoloV2Tiny20.caffemodel --install_folder mvdeploy --input_dims 1,3,416,416

[!NOTE]

  • There will be a file libmv_deploy.so (under ./lib), weights.bin and mvtestdeploy sample app (under ./bin)
  • There will be mv_extras folder for extra post-processing helper functions
  • Open mvdeploy_api.h to go through API functions supported for inference deployment

Step 3. Make sure mvtestdeploy utility runs

mvtestdeploy is a pre-generated application built in Step 3 which shows how to deploy inference for an input image file

[!TIP]

cd mvdeploy
./bin/mvtestdeploy /opt/rocm/share/mivisionx/samples/mv_objdetect/data/images/img_04.JPG output.bin --install_folder . --t 100

[!NOTE] This runs inference for an input file and generate output for N number of iterations.

Step 4. Build mvobjdetect example

TODO:

[!TIP]

cp /opt/rocm/share/mivisionx/samples/mv_objdetect/mvobjdetect.cpp .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/visualize.cpp .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/visualize.h .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/CMakeLists.txt .

Step 5. cmake and make mvobjdetect

[!TIP]

mkdir mv_build
cd mv_build
cmake ../
make -j

[!NOTE] If build directory exists from previous build, name the new build directly differently (eg: mv_build).

Step 6. Run object detection with video/image

```

[!TIP]

cd ..
./mv_build/mvobjdetect /opt/rocm/share/mivisionx/samples/mv_objdetect/data/images/img_04.JPG --install_folder . --bb 20 0.2 0.4 --v

[!NOTE]

  • Make sure the input image and video file exist and specified with full path
  • For Video - ./mv_build/mvobjdetect <PATH TO VIDEO FILE> --install_folder . --bb 20 0.2 0.4 --v
  • For hardware decode use --hwdec 1

Step 7. Run object detection with multiple video streams (e.g batch 4, 8 and 16)

[!TIP] For batch size 4

mkdir mvcompile-4 && cd mvcompile-4
wget https://github.com/kiritigowda/YoloV2NCS/raw/master/models/caffemodels/yoloV2Tiny20.caffemodel
mv_compile --model yoloV2Tiny20.caffemodel --install_folder mvdeploy-4 --input_dims 4,3,416,416
cd mvdeploy-4/
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/mvobjdetect.cpp .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/visualize.cpp .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/visualize.h .
cp /opt/rocm/share/mivisionx/samples/mv_objdetect/CMakeLists.txt .
mkdir mv_build && cd mv_build
cmake ../ && make -j8
cd ../
./mv_build/mvobjdetect <Videos_4.txt> --install_folder . --bb 20 0.2 0.4 --v

[!IMPORTANT] *Videos_4.txt has the names of input video files with full path.

  • Use the ../data/Videos/Videos_4.txt file. Modify it to specify your input files.
  • The last bit (:0 / :1) chooses software or hardware mode for decoding.

Step 10. Sample output for multiple video object detection

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Author

Rajy Rawther - mivisionx.support@amd.com