Forums - Build OpenCV and SNPE on RB5

2 posts / 0 new
Last post
Build OpenCV and SNPE on RB5
22imonreal
Join Date: 10 Feb 21
Posts: 80
Posted: Wed, 2021-09-01 00:34

Hello,

I have been redirected here from https://developer.qualcomm.com/forum/qdn-forums/hardware/qualcomm-roboti...

I tried following the example in https://developer.qualcomm.com/project/object-detection-tensorflow-lite#....

but I get the follwing error:



 /home/src/webcam-detect-tflite  ./webcam-detector
Loading model: mobilenet_quant_v1_224.tflite

(process:8785): GStreamer-CRITICAL **: 13:24:22.731: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
OpenCV | GStreamer warning: GStreamer: unable to query pipeline state (/home/src/opencv-wayland/modules/videoio/src/cap_gstreamer.cpp:421)
(DEBUG) try_init_v4l2 VIDIOC_QUERYCAP "/dev/video0": Inappropriate ioctl for device
Unable to stop the stream: Inappropriate ioctl for device
Failed to open VideoCapture.
 

If I change the api in the OpenCV code in main.cpp from cv::CAP_ANY to cv::CAP_V4L2, I get the follwing error:

(DEBUG) try_init_v4l2 VIDIOC_QUERYCAP "/dev/video0": Inappropriate ioctl for device
Unable to stop the stream: Inappropriate ioctl for device

If I try to build OpenCV Wayland with

-D WITH_LIBV4L=ON

I get:

Failed to query video capabilities: Inappropriate ioctl for device
libv4l2: error getting capabilities: Inappropriate ioctl for device
VIDEOIO ERROR: V4L: device /dev/video0: Unable to query number of channels

If I try to list the video devices in the RB5, I get the following:


sh-4.4# ls -ltrh /dev/video*
crw-rw---- 1 root video 81,  1 Feb 23  2021 /dev/video1
crw-rw---- 1 root video 81, 33 Feb 23  2021 /dev/video33
crw-rw---- 1 root video 81, 32 Feb 23  2021 /dev/video32
crw-rw---- 1 root video 81,  0 Feb 23  2021 /dev/video0
sh-4.4# sudo apt-get install v4l-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
v4l-utils is already the newest version (1.14.2-1).
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
sh-4.4# v4l2-ctl --list-devices
msm_vidc_vdec ():
    /dev/video32
    /dev/video33
    /dev/radio0
    /dev/v4l-subdev2
    /dev/v4l-subdev3
    /dev/v4l-subdev4
    /dev/v4l-subdev5
    /dev/v4l-subdev6
    /dev/v4l-subdev7

VIDIOC_QUERYCAP: failed: Inappropriate ioctl for device
/dev/video0: not a v4l2 node
sh-4.4# sudo v4l2-ctl --device=/dev/video0 --all
VIDIOC_QUERYCAP: failed: Inappropriate ioctl for device
/dev/video0: not a v4l2 node
sh-4.4# sudo v4l2-ctl --device=/dev/video1 --all
VIDIOC_QUERYCAP: failed: Inappropriate ioctl for device
/dev/video1: not a v4l2 node

Please help me resolve the above issues.

Thanks.

 

 

  • Up0
  • Down0
SahilBandar
Join Date: 23 May 18
Posts: 37
Posted: Tue, 2021-09-07 20:28

Hi 22imonreal,

The camera which is connected on CAM port of RB5 won't support directly with VideoCapture with camera id.
Reason for that is ioctl call for Camera drivers of RB5's Camera  is not matching with the V4L2's ioctl call.

For making it work out, you can create the gstreamer pipeline for the camera using qtiqmmfsrc element for input source.

Please follow the steps in order to resolve your problem,

You can stream the video on TCP using Gstreamer & process by OpenCV's VideoCapture
 
Open shell of RB5 & run following command for creating the TCP Streaming Pipeline,
gst-launch-1.0 -e qtiqmmfsrc name=qmmf ! video/x-h264,format=NV12, width=1280, height=720,framerate=30/1 ! h264parse config-interval=1 ! mpegtsmux name=muxer ! queue ! tcpserversink port=8900 host=<RB5_IP_ADDRESS>

NOTE: Please keep running the above pipeline in seperate terminal.

Now, you can use VideoCapture, and pass streaming URL to get the frames using OpenCV, Please refer below Example,

import cv2

cap = cv2.VideoCapture("tcp://<RB5_IP_ADDRESS>:8900") #rb5 ip & port (same from command)
while(cap.isOpened()):
    ret, frame = cap.read()
    
    #
    # Write your code here
    # 

    break
cap.release()
 

Hope this will resolve your issue,

Thanks & Regards,
Sahil Bandar

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.