其他分享
首页 > 其他分享> > Jetson TX2板载摄像头(一)

Jetson TX2板载摄像头(一)

作者:互联网

一、参考资料

How to Capture and Display Camera Video with Python on Jetson TX2
tegra-cam.py
gstreamer基础教程
英伟达Jetson TX2 /NX/AGX上使用 Python 硬解码网络相机h264视频流

二、板载摄像头相关信息

在这里插入图片描述

tx2@tx2:~/Desktop$ python tele_gram.py 
Called with args:
Namespace(image_height=1080, image_width=1920, rtsp_latency=200, rtsp_uri=None, use_rtsp=False, use_usb=False, video_dev=1)
OpenCV version: 4.4.0
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 2592 x 1944 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 2592 x 1458 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 22000, max 358733000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 1 
   Output Stream W = 2592 H = 1458 
   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.
[ WARN:0] global /home/tx2/panbo/software/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 17:42:26.830: Failed to load module "canberra-gtk-module"
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success

三、打开板载摄像头

def open_cam_onboard(width, height):
    gst_elements = str(subprocess.check_output('gst-inspect-1.0'))
    if 'nvcamerasrc' in gst_elements:
        # On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
        gst_str = ('nvcamerasrc ! '
                   'video/x-raw(memory:NVMM), '
                   'width=(int)2592, height=(int)1458, '
                   'format=(string)I420, framerate=(fraction)30/1 ! '
                   'nvvidconv ! '
                   'video/x-raw, width=(int){}, height=(int){}, '
                   'format=(string)BGRx ! '
                   'videoconvert ! appsink').format(width, height)
    elif 'nvarguscamerasrc' in gst_elements:
        gst_str = ('nvarguscamerasrc ! '
                   'video/x-raw(memory:NVMM), '
                   'width=(int)1920, height=(int)1080, '
                   'format=(string)NV12, framerate=(fraction)30/1 ! '
                   'nvvidconv flip-method=2 ! '
                   'video/x-raw, width=(int){}, height=(int){}, '
                   'format=(string)BGRx ! '
                   'videoconvert ! appsink').format(width, height)
    else:
        raise RuntimeError('onboard camera source not found!')
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
参数解释:
gst_str = ('nvarguscamerasrc ! '
                   'video/x-raw(memory:NVMM), '
                   'width=(int)1920, height=(int)1080, '
                   'format=(string)NV12, framerate=(fraction)30/1 ! '
                   'nvvidconv flip-method=2 ! '
                   'video/x-raw, width=(int){}, height=(int){}, '
                   'format=(string)BGRx ! '
                   'videoconvert ! appsink').format(960, 640)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

视频流:1920*1080 @30fps
显示窗口:960*640

四、板载摄像头工具包

参考博客 Jetson TX2板载摄像头(二)

标签:板载,gst,int,ARGUS,height,width,Jetson,TX2,GST
来源: https://blog.csdn.net/m0_37605642/article/details/121300143