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.


Sample - Detection Using Pre-Trained CAFFE Model

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

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

Step 2. compile model for OPENCL-ROCm-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.

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

Step 4. Build mvobjdetect example


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

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

* Sample

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 ./mv_build/mvobjdetect - --install_folder . --bb 20 0.2 0.4 --v

**Note:** Make sure the input image and video file exist and specified with full path

### Step 7. Run object detection with multiple video streams (e.g batch 4, 8 and 16)
* Go through steps 3 to 6, this time compiling the model for a batch of `4`.  
* Also this sample can do batch of 8 and 16 decoding as well.  
	* For **batch 8:** `--input_dims 8,3,416,416`  and create `Videos_8.txt` file with 8 input streams  
	* For **batch 16:** `--input_dims 16,3,416,416` and create `Videos_16.txt` file with 16 input streams

cd .. mv_compile –model yoloV2Tiny20.caffemodel –install_folder mvdeploy_batch4 –input_dims 4,3,416,416 cd mvdeploy_batch4 cp ../mvobjdetect.cpp ../visualize.cpp ../visualize.h ../CMakeLists.txt . mkdir mv_build4 cd mv_build4 cmake ../ make -j cd .. ./mv_build4/mvobjdetect - --install_folder . --bb 20 0.2 0.4 --v ``` **Note:**

Step 10. Sample output for multiple video object detection


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


Rajy Rawther - mivisionx.support@amd.com