- The project is divided into four modules
- The first module YuNet.cpp load the YuNet class, and we will load the trained YuNet model
- The second module config.cpp are some constants in the project
- The third module util.cpp some of the functions in the project
- In the main method module main.cpp, we will call the above three modules and write the call logic
- This project mainly calls opencv4.10.0
- This project contains a total of four functions, using '-mode' in the parameters to achieve function switching, and the mode can be switched in real time at runtime.
- Normal Face Detection: Normal Mode (Button n)
- Blur Processing: Blur Mode (Button b)
- Pixelation: Pixel mode (button p)
- Mask mode: Mask mode (button m)
- Parameter adjustments
- Blurring:
- Reduce Blur: Press button c
- Increase Blur: press button v
- Pixelation:
- To reduce the pixel block size: press button c
- To induce the pixel block size: press buttonv
- mask:
- After pressing the U button, the input is displayed in the command line, and the covered photo can be changed by entering the legal photo path
- Blurring:
- -mode: set the initial mode(normal, blur, pixel, mask), default is mask
- -blur_kernel_size: takes effect only in blur mode. Set the initial blur kernel size, the default value is 5*5
- -pixel_size: Takes effect only in pixel mode. Sets the initial pixel block size, the default value is 10
- -mask: takes effect only in mask mode. Specify the path of the mask image, and the default image name is mask1.jpg.
- -device: specifies the device ID of the camera, which is 0 by default
- Default parameters
./main- Specify the parameter to run
./main -mode mask -mask /path/to/image.png
./main -mode normal -mask /path/to/image.png
./main -mode blur -mask /path/to/image.png -blur_kernel_size 5
./main -mode pixel -mask /path/to/image.png -pixel_size 10- System setup
We strongly recommend your OpenCV version >= 4.10.0, and c++ version >= 17, here we use gcc-9 to compile.
- Build the project
Since the original version of OpenCV on Jetson nano is 4.1, we download and build a 4.10 version OpenCV.
If you have already have the suggested environment, you can skip this paragraph. If you want to know how to download and build an OpenCV on specific version, follow the instructions below.
Be patient! It will take more than 3 hours to build OpenCV on Jetson Nano. 😭
cd ~
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
git checkout 4.10.0
cd ../opencv_contrib
git checkout 4.10.0
cd ~/opencv-4.10
mkdir build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/opencv-4.10.0 \
-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-DWITH_CUDA=OFF \
-DWITH_CUDNN=OFF \
-DBUILD_opencv_python3=OFF \
-DBUILD_opencv_python2=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DCMAKE_C_COMPILER=gcc-9 \
-DCMAKE_CXX_COMPILER=g++-9You can build your own repo by specifying the environment you want.
cd privacy/
mkdir build && cd build
cmake .. -DOpenCV_DIR=/opt/opencv-4.10.0/lib/cmake/opencv4 -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9 -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)Run the code on Jetson Nano with a CSI camera.
./privacy -ct=csi