libovmatting
libovmatting copied to clipboard
A C++ library for Background Matting
libovmatting
A C++ library for Background Matting using openvino and deep learning models.
Now support models such as BackgroundMattingV2, MODNet.
1 Application scenes
...
2 License
The code of libovmatting is released under the MIT License.
3 Development environment
CentOS 7
Ubuntu
Windows 10
4 Usage
4.1 Install openvino
Please refer https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html
Use version: openvino_2021.2.185
4.2 Build libovmatting library and test program
Clone the project
$git clone https://github.com/kingpeter2015/libovmatting.git
4.2.1 Ubuntu/CentOS
$cd libovmatting
$mkdir build
$cmake ..
$make
Run the test program
$cd ./build/
$LD_LIBRARY_PATH=./:$(LD_LIBRARY_PATH) ./sample
4.2.2 Windows 10
Install Visual Studio 2019
open Win64\ovmatting.sln
build and run in the Visual Studio IDE
5 About Source Code
5.1 Directory Structure
- Win64: Windows Solution and projects
- include: contains header files. ovmatter.h is api header file
- libovmatting: CMakefiles for compile libovmatting.so under linux
- samples: four samples using libovmatting library
- share: contains model files which are used by openvino inference engine.
- src: contains source code files
main.cpp: startup point of demos
5.2 Please Attention !!!
- 'include/ovmatter.h' is one only sdk header file which exposes api to applications.
- libovmatting library only supports two matting method: METHOD_BACKGROUND_MATTING_V2 and METHOD_MODNET. They are defined in include/ovmatter.h
- METHOD_BACKGROUND_MATTING_V2 method uses cnn model defined 'pytorch_mobilenetv2.bin/pytorch_mobilenetv2.xml'.
- METHOD_MODNET method uses cnn model defined in 'modnet.bin/modnet.xml'
if you want to use your own model, you can do following steps:
- Add a enum item in enum OV_MATTER_API MattingMethod which is defined in include/ovmatter.h
- declare and implement a new ovmatter class, and inherit 'MatterBaseImpl', then write a new cnn that uses your own models
That's all, have fun !
6 Reference
OpenVINO https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html
BackgroundMattingV2 https://github.com/PeterL1n/BackgroundMattingV2
MODNet https://github.com/ZHKKKe/MODNet