Opencv problem with capturing rtsp stream using gstreamer on jetson nano

I having some problem to run my openalpr python code with a logitech camera.
My code as below:
openalpr_camera.txt (1.8 KB)
I run the code, the result was like this:

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module rtspsrc0 reported: Could not open resource for reading and writing.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Traceback (most recent call last):
File “”, line 67, in
File “”, line 37, in main
sys.exit(‘Failed to open video file!’)
NameError: global name ‘sys’ is not defined

But it was fine to open the camera with:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! jpegdec ! video/x-raw,framerate=30/1,width=1280,height=720 ! videoconvert ! xvimagesink

How can I make the camera work on my code? Thank you!

In the code, the camera is v4l2 source and it is opened as RTSP source. You can modfify it byreferring to this sample:
Sony camera module cannot be opened with OpenCV on Xavier

thank you very much, Now my program work with an usb camera.