etpack 5.1.2
Python 3.8
OpenCV-python 4.5.5.64 installed via pip3
I have deployed a Python program on the system. This program is a UI interface created using PyQt5. When I click a button on this UI, it launches yolov5’s detect.py. I modified this script to pull an H.264 format RTSP stream from a wireless camera. The real-time video results from detect.py are displayed on the UI interface. Everything works fine when using the opencv-python package downloaded via pip3.
However, after uninstalling the original opencv-python package and attempting to compile OpenCV 4.5.5:
import sys
import cv2
def read_cam():
cap = cv2.VideoCapture("filesrc location=test.mkv ! matroskademux ! h264parse ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink sync=0 ")
if cap.isOpened():
count = 0;
while True:
ret_val, img = cap.read();
if not ret_val:
break;
count = count + 1
if count % 150 == 0:
print("decoded frames:", count)
else:
print("rtsp open failed")
cap.release()
if __name__ == '__main__':
read_cam()
It can not work:
Opening in BLOCKING MODE
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element capsfilter1, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element capsfilter0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element nvvconv0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element h264parse0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element filesrc0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.922:
Trying to dispose element pipeline0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
[ WARN:0@0.151] global /home/orange/Desktop/opencv-4.5.5/modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
(python3:17020): GStreamer-CRITICAL **: 11:41:13.923:
Trying to dispose element videoconvert0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
[ WARN:0@0.151] global /home/orange/Desktop/opencv-4.5.5/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
(python3:17020): GStreamer-CRITICAL **: 11:41:13.923:
Trying to dispose element appsink0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python3:17020): GStreamer-CRITICAL **: 11:41:13.923:
Trying to dispose element nvv4l2decoder0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
rtsp open failed
(python3:17020): GStreamer-CRITICAL **: 11:41:13.939: gst_element_post_message: assertion 'GST_IS_ELEMENT (element)' failed
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Delayed linking failed.
Additional debug info:
./grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
failed delayed linking some pad of GstMatroskaDemux named matroskademux0 to some pad of GstH264Parse named h264parse0
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data stream error.
Additional debug info:
matroska-demux.c(5732): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
Hi,
If the error is only shown with your self-build OpenCV, it may be something wrong in building the package. You may try to use this script to build 4.5.4 and see if it works:
Hello, I used a shell script from the website to install OpenCV, but my JetPack 5.1.2 failed to install v4l2ucp, so I skipped it. After the installation was complete, the test program still reported error:
but I can successfully run the program when using the SSH protocol communication feature of MobaXterm. MobaXterm’s SSH protocol supports X11 forwarding, so I can see the results of the program’s execution.