~~tag> VIM3 OpenCV~~ ====== OpenCV DNN Usage ====== For [[:VIM3]] only, not for [[:VIM3L]]. ===== Install Dependencies ===== Before installing the OpenCV package, you need to install the dependencies. ```shell sudo apt update sudo apt install python3 python3-dev python3-numpy cmake libgtk2.0-dev ``` ===== Install OpenCV ===== Get the OpenCV package and install it. ```shell wget https://dl.khadas.com/development/opencv_4.8.1.deb sudo dpkg -i opencv_4.8.1.deb ``` ===== Run Test ===== ==== Get demo source ==== Get the example repository from [[kg>OpenCV_NPU_Demo]]. ```shell cd ~ git clone https://github.com/khadas/OpenCV_NPU_Demo.git ``` ==== Compile ==== Compile with cmake tool. ```shell cd ~/OpenCV_NPU_Demo/cpp_demo mkdir build && cd build cmake .. make ``` ==== Run ==== After the operation is successful, you can see that the camera has captured the face. ```shell cd ~/OpenCV_NPU_Demo/cpp_demo/build ./detect-camera 1 ../../model/yunet_int8.onnx ``` For example my cam device node is ''/dev/video1'', 2nd argument must be ''1'' {{products:sbc:vim3:npu:opencv-c.jpeg}} ===== Quantize Model ===== We suggest that quantize your model before running on VIM3. If your model performs bad after quantizing, without quantification is okay. Get [[https://github.com/opencv/opencv_zoo/tree/main/tools/quantize|quantized model]]