Streaming From Jetson Nano to Windows PC using OpenCV and Gstreamer

I am trying to view live camera footage from a Jetson Nano on a PC running Windows 10. My Jetson is using a Rspberry Pi camera v2.1. I also downloaded gstreamer on my PC.

Here is the Python code that I run from the Jetson side, abridged for clarity and with my IP address redacted:

import cv2

print (cv2.version)
dispW= 640
dispH= 480
flip=2

camSet=‘nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=’+str(flip)+’ ! video/x-raw, width=‘+str(dispW)+’, height=‘+str(dispH)+’, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink’

cam = cv2.VideoCapture(camSet)

out = cv2.VideoWriter(“appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! video/x-raw, format=BGRx ! nvvidconv ! omxh264enc ! video/x-h264, stream-format=byte-stream ! h264parse ! rtph264pay pt=96 config-interval=1 ! udpsink host= port=1234”, cv2.CAP_GSTREAMER, 0, 25.0, (1920, 1080))

while True :

ret,frame = cam.read()
cv2.imshow('piCam',frame)
if ret:
    out.write(frame)
key = cv2.waitKey(1)
if key==ord('q'):
    print("Quit")
    break

cam.release()
out.release()
cv2.destroyAllWindows()

On my Windows PC, I open up the Command Prompt, navigate to C:\gstreamer\1.0\msvc_x86_64\bin and I run the following command:

gst-launch-1.0 -v udpsrc port=1234
caps = “application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96” !
rtph264depay ! decodebin ! videoconvert ! autovideosink

However, all that shows up is a window that’s completely black. I am able to see the video fine on my Jetson Nano.
Any help into this matter would be greatly appreciated.

Hi,
Please try this sample and check if you can see camera preview:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL
To make sure the camera source is good. And then try this sample:
OpenvCV, Gstreamer, Python camera capture/access and streaming to RTP

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.