When I try to use python code as followings, I got errors belows.
cv2.VideoCapture(0)
[ WARN:0@13.146] global cap_v4l.cpp:1119 tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.
Also, this command works as well.
$ gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! ‘video/x-raw(memory:NVMM),height=640,width=480,framerate=30/1’ ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! queue ! appsink drop=1
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 1920 x 1536 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.122018, max 6.309574; Exposure Range min 16000, max 660000000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 0
Output Stream W = 1920 H = 1536
seconds to Run = 0
Frame Rate = 29.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
$ v4l2-ctl --all
Driver Info:
Driver name : tegra-video
Card type : vi-output, imx623 32-0044
Bus info : platform:tegra-capture-vi:4
Driver version : 5.10.104
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-camrtc-ca
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info :
Media version : 5.10.104
Hardware revision: 0x00000003 (3)
Driver version : 5.10.104
Interface Info:
ID : 0x03000017
Type : V4L Video
Entity Info:
ID : 0x00000015 (21)
Name : vi-output, imx623 32-0044
Function : V4L2 I/O
Pad 0x01000016 : 0: Sink
Link 0x0200001b: from remote pad 0x100000f of entity ‘13e40000.host1x:nvcsi@15a00000-’: Data, Enabled
Priority: 2
Video input : 0 (Camera 4: no power)
Format Video Capture:
Width/Height : 1920/1536
Pixel Format : ‘YUYV’
Field : None
Bytes per Line : 3840
Size Image : 5898240
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Hi,
It looks like gstreamer is not enabled in the OpenCv package. Do you use OpenCV package installed through SDKManager? Or you manually build the packge?
OpenCV(4.8.0) /io/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! appsink in function ‘icvExtractPattern’
Hi,
Your OpenCV is 4.8.0 and gstreamer is disabled. If you use the package installed through SDKManager, it it this version:
nvidia@tegra-ubuntu:~$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.4'
>>>
OpenCV(4.5.4) /tmp/pip-req-build-frgo6bcn/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! appsink in function ‘icvExtractPattern’
And install SDK Components through SDKManager. This should reset to use default package.
Working log will be like:
$ python3 ./ocv_nvarguscamerasrc.py
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3840 x 2160 FR = 59.999999 fps Duration = 16666667 ; Analog Gain rang
e min 1.000000, max 44.400002; Exposure Range min 44000, max 478696000;
GST_ARGUS: 1920 x 1080 FR = 59.999999 fps Duration = 16666667 ; Analog Gain rang
e min 1.000000, max 177.000000; Exposure Range min 58000, max 184611000;
GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain rang
e min 1.000000, max 30.000000; Exposure Range min 864000, max 20480000;
GST_ARGUS: 1920 x 1080 FR = 59.999999 fps Duration = 16666667 ; Analog Gain rang
e min 1.000000, max 177.000000; Exposure Range min 859000, max 15649000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 3
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 59.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstrea
mer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: sta
tus=0, value=-1, duration=-1
Gtk-Message: 09:05:08.652: Failed to load module "canberra-gtk-module"