010_blob_detection是OpenCV通过设置blob参数过滤图像的示例程序。
2.1 C++应用Demo
C++应用Demo工程结构:
010_blob_detection/CPP$ tree . -L 1
.
├── blob.cpp
├── blob.jpg
└── CMakeLists.txt
0 directories, 3 files
确认OpenCV安装路径:
$ find /home/daniel/ -name "OpenCVConfig.cmake"
/home/daniel/OpenCV/installation/opencv-4.9.0/lib/cmake/opencv4/
/home/daniel/OpenCV/opencv/build/OpenCVConfig.cmake
/home/daniel/OpenCV/opencv/build/unix-install/OpenCVConfig.cmake
$ export OpenCV_DIR=/home/daniel/OpenCV/installation/opencv-4.9.0/lib/cmake/opencv4/
C++应用Demo工程编译执行:
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build . --config Release
$ cd ..
$ ./build/blob
2.2 Python应用Demo
Python应用Demo工程结构:
010_blob_detection/Python$ tree . -L 1
.
├── blob.jpg
└── blob.py
0 directories, 2 files
Python应用Demo工程执行:
$ workoncv-4.9.0
$ python blob.py