Hi all,
I’m facing to a problem that I don’t know if is caused by OpenCV or Gstreamer.
If my Python script tries to write to an offline RTMP server, Pyhon remains stucked and there is no way to recover it.
I need to kill process with “-9” in order to terminate it brutally.
I solved using a workaround, before to push frame to RTMP server I try to open a socket connection to RTMP port 1935 in order to check if port is open.
I suppose that I found the same issue in VideoCapture.
In my application each time that I try to get a frame, I try to open a socket client to RTSP IP camera server.
If IP Camera RTSP replies before timeout, I get the frame otherwise I close the capture using: cap.release():
...
while True:
# ----------------------------------------------------------------------------- #
if videoClass.checkCamera(config['source'], 1) is False: # <<--- My class to check if RTSP server is OPEN
if cap.isOpened():
cap.release()
continue
else:
if cap.isOpened() is False:
cap = cv2.VideoCapture(gst_pipeline)
# ----------------------------------------------------------------------------- #
if cap.isOpened():
ret, frame_read = cap.read()
...
Each time that I initialize VideoCapture the previous resource should be release but in my Jetson Nano RAM usage increase till kill process cause of out of memory.
However, OpenCV is not very performant. Most of it does not even use the GPU and the parts that do are buggy. If you simply with to dump video to file, or even do analysis on video, you may want to use Nvidia’s gstreamer elements exclusively, with no OpenCV at all.
Also easy to use and fast if you like Python is the jetson-inference project. Though not as fully featured as DeepStream, it’s a lot easier to work with.
Consider that I’m able to reach 18-20 Fps using YoloV3-Tiny-prn at a resolution of 576x320 with a very better detection then ssd-mobilenet-v1/v2 or ssd-inception-v2