GStreamer Camera Visible in cmd GST-Launch, but not Python CV2 Video Capture

Hi all, any and all advice here would be greatly appreciated!

I’m trying to initialize a camera for reading video frames in Python using CV2’s VideoCapture utility and the GStreamer pipeline below:

pipe = "v4l2src device=/dev/video0 ! video/x-raw, format=BGRx ! videoflip method=rotate-180 ! videoconvert ! videoscale ! video/x-raw ! queue ! appsink sync=False"
capture_device = cv2.VideoCapture(pipe, cv2.CAP_GSTREAMER)

I’ve also tested and confirmed that using the following get-launch-1.0 command on the command line gives a live video stream:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=BGRx ! videoflip method=rotate-180 ! videoconvert ! videoscale ! video/x-raw ! queue ! ximagesink sync=False

jtop shows OpenCV version 4.5.1 and is compiled for CUDA, however cv2.version in the script described above shows OpenCV version 4.5.4-dev.

Any advice would be hugely helpful. Thank you again in advance!

Hi,
Please check if you can see correct version in executing the commands:

nvidia@tegra-ubuntu:~$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__

And may try this sample:
V4l2src using OpenCV Gstreamer is not working in Jetson Xavier NX - #3 by DaneLLL