The delay of Gstreamer pipeline in Opencv videoCapture()

Hi everyone,

I have encountered a confusing problem on my jetson TX2. When I use gst command line:

gst-launch-1.0 rtspsrc location=rtsp://192.168.1.168/main latency=30 ! decodebin ! autovideosink

I got the real-time video from my IP camera. But when I tested it by using opencv VideoCapture(), the video is not in real-time, and the delay is accumulating over time.

cap = cv2.VideoCapture("rtspsrc location=rtsp://192.168.1.168/main  latency=30 ! decodebin ! videoconvert ! appsink")

Could someone help me? Best wishes to you all!

Please refer to https://devtalk.nvidia.com/default/topic/1024245/jetson-tx2/opencv-3-3-and-integrated-camera-problems-/post/5210735/#5210735

Hi DaneLLL,

Thank you very much for you reply. My IP camera is connected with the TX2 by using an Internet cable, not the onboard camera. I built the OpenCV with Gstreamer support and I was able to open the camera, the only problem is that the video is not in real time, the delay is accumulating over time.

Best wishes

Hi,
One performance bottleneck is to do RGBA to BGR conversion via ‘videoconvert’. You shall see improvement by giving I420/NV12 to appsink. In this case you can avoid the SW conversion.

We do see improvement in running the sample and share the information. Also other users can share their experience/suggestion.

Hi DaneLLL,
Thank you very much for your reply! You are right, it seems the bottleneck is ‘videoconvert’. I setup the same environment and code on a server, It runs in real-time.
After I change the code to the following on TX2:

cap = cv2.VideoCapture("rtspsrc location=rtsp://192.168.1.168/main  latency=30 ! decodebin ! nvvidconv ! appsink")

The video can run in real-time without delay. But the video is grey. How can I set it to rgb?

Best wishes

Hi DaneLLL,
I recompiled opencv by the clue in above link. It works fine. Thank you very much for your help.