NPU Demo and source code

Hello, guys! I faced a problem:
I’ve cloned repo from this adress, cause it has been moved:

But when I try to launch detect_demo_x11_usb I get this error:
“error while loading shared libraries: libopencv_imgproc.so.4.2: cannot open shared object file: No such file or directory”
I tried to get OpenCV binaries with command “sudo apt install libopencv-dev python3-opencv” as it described here: Application Source Code [Khadas Docs], but this command installs 4.5.4 version, not 4.2. Maybe you have some advice for this case? Please, help me, I’ve stuck with it.

Ok, I’ve manage with openCV4.2. build and now I have this trace while trying lauch the demo:

root@Khadas:~/aml_npu_demo_binaries/detect_demo# ./detect_demo_x11_usb /dev/video0 -m 3
W Detect_api:[det_set_log_level:19]Set log level=1
W Detect_api:[det_set_log_level:21]output_format not support Imperfect, default to DET_LOG_TERMINAL
W Detect_api:[det_set_log_level:26]Not exist VSI_NN_LOG_LEVEL, Setenv set_vsi_log_error_level
det_set_log_config Debug
E [compute_node:379]Create node[0] NBG fail
E [vnn_CreateYolotiny:328]CHECK STATUS(-1:A generic error code, used when no other describes the error.)
E [model_create:62]CHECK PTR 62
E Detect_api:[det_set_model:225]Model_create fail, file_path=nn_data, dev_type=2
det_set_model fail. ret=-4
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
error tvin-port use -1
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
[ WARN:0] global /root/opencv-4.2.0/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
[API:aml_v4l2src_streamoff:381]Enter
[API:aml_v4l2src_streamoff:384]Exit
[API:aml_v4l2src_disconnect:363]Enter
change_divide_framerate, L69, dev , change_frame 0
[API:aml_v4l2src_disconnect:368]Exit
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
error tvin-port use -1
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
[API:aml_v4l2src_streamoff:381]Enter
[API:aml_v4l2src_streamoff:384]Exit
[API:aml_v4l2src_disconnect:363]Enter
change_divide_framerate, L69, dev , change_frame 0
[API:aml_v4l2src_disconnect:368]Exit
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video0
driver : uvcvideo
device : Rapoo Camera: Rapoo Camera
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
error tvin-port use -1
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.2.0) /root/opencv-4.2.0/modules/imgproc/src/resize.cpp:4048: error: (-215:Assertion failed) inv_scale_x > 0 in function ‘resize’

Aborted

Could you tell me, what is wrong here?

Hello @Ivan_Zhukov

@Louis-Cheng-Liu will help you then.

@numbqq thank you for reply!
@Louis-Cheng-Liu if you need some additional data I’ll provide it.

Hello @Ivan_Zhukov ,

Which kernel do you use?

Hello @Ivan_Zhukov ,

The version is too old. Maybe some libraries are not compatible.

I have recompiled detect_demo_x11_usb and run on VIM3 with 5.15kernel. It can run normally.
khadas/aml_npu_demo_binaries (github.com)

You also can compile by yourself. This is the document.
Application Source Code [Khadas Docs]

Currently I use 5.15 kernel

Thank you, I’ll try this!

I performed ./INSTALL
And after I performed ./detect_demo_x11_usb and got this:

root@Khadas:~/aml_npu_demo_binaries/detect_demo# ./detect_demo_x11_usb -d /dev/video0 -m 0
-bash: ./detect_demo_x11_usb: Permission denied

Hello @Ivan_Zhukov ,

The file does not have permission to run. Give it permission.

chmod +x detect_demo_x11_usb

TY so much, it works! I have 1 more question:
This demo performs about 5-10fps, are there any ways to increase it’s fps? May be some settings of configurations

Hello @Ivan_Zhukov ,

This demo uses YOLOv2, v3 and v4. There are old YOLO version. You can try to use YOLOv8. YOLOv8 has different versions with different number of parameters. You can choose the smallest one.

However, YOLO is a big model. If you think YOLOV8 infers slowly, too, you can try to use other smaller target detection model.

Model input size also affects inference speed. You can try to modify model input size.

Thank you for information. I’ve tried to run this demo on VIM4Pro, but unsuccessfully. Is it possible to run this demo on VIM4?

Hello @Ivan_Zhukov ,

No, VIM4 uses another demo. You can refer this.
VIM4 NPU Notes [Khadas Docs]

Hello, @Louis-Cheng-Liu , thank you, I’ll try it!