Application for tracking various objects and estimating their speed in video stream.
git clone https://github.com/vnkrtv/video-tracker.git && cd video-tracker
git pull --recurse-submodules
git submodule init
git submodule update --remote --recursive
Installing all system requirements described in this article
After installing them is's able to build OpenCV
cd contrib/opencv
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_GSTREAMER=ON -D WITH_FFMPEG=ON [-D WITH_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1]..
make [-j 9]
sudo make install
cd contrib/dlib/dlib
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=1 -D USE_AVX_INSTRUCTIONS=ON [-D DLIB_USE_CUDA=1] ..
make [-j 9]
sudo make install
cmake -DCMAKE_BUILD_TYPE=RELEASE .
cmake --build cmake-build-release --target video_tracker [-- -j 9]
Options:
-h, --help Show help
--video-src, -v [string] Video source (video file, ip camera, video device)
--model-path, -m [string] MobileNetSSD folder path
--output, -o [string] Output file name. By default, processed video stream is not
saving
--classes, -c [integer...] Set of detected classes ID. Full set could be found
in README. Default classes: persons and cars
--confidence, -t [number] Model's confidence coefficient. Default value: 0.4
--no-window Does not show named window with video stream. False
by default
--cuda Use GPU with CUDA
MobileNet is using in project for objects detection. Model is pre-trained and taken from https://github.com/chuanqi305/MobileNet-SSD//. It was trained in Caffe-SSD framework. This model can detect 20 classes. Available classes can be found in table below:
Class name | Class ID |
---|---|
background | 0 |
aeroplane | 1 |
bicycle | 2 |
bird | 3 |
boat | 4 |
bottle | 5 |
bus | 6 |
car | 7 |
cat | 8 |
chair | 9 |
cow | 10 |
dining table | 11 |
dog | 12 |
horse | 13 |
motorbike | 14 |
person | 15 |
potted plant | 16 |
sheep | 17 |
sofa | 18 |
train | 19 |
tv monitor | 20 |
To make application detect multiple classes, you need specify special -c, --classes
flag. Example:
video_tracker --video-src /dev/video0 --model-path MobileNetSSD --classes {8,12}
- in this case app will detectObjects only cats and dogs using camera /dev/video0