I am trying to read a rtsp stream from my Ip camera using Opencv and running Linux. The camera is a Floureon IPC 360 from China. I am trying to develop some facial recognition code.
I am using the following code:
import numpy as np
import cv2
vcap = cv2.VideoCapture("rtsp://192.168.1.240:554/realmonitor?channel=0")
print(vcap)
while(1):
ret, frame = vcap.read()
print (ret,frame)
cv2.imshow('VIDEO', frame)
#cv2.imwrite('messigray.png',frame)
cv2.waitKey(1)
$ python w.py
<VideoCapture 0x7fc685598230>
(False, None)
Traceback (most recent call last):
File "w.py", line 9, in <module>
cv2.imshow('VIDEO', frame)
cv2.error: OpenCV(4.1.0) /io/opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
cv2.imshow is failing as the frame is 'None' & (ret is False).
In a separate window I can run openRTSP :
./openRTSP -4 -P 10 -F cam_eight -t -d 8 rtsp://192.168.1.240:554/realmonitor?channel=0
Which creates me a nice mp4 file that I can play: 107625 Sep 12 19:08 cam_eight-00000-00010.mp4
OpenRTSP works with or without the t (tcp). I have also tried supplying the admin:123456 credentials to the cv2.VideoCapture line, which openRTSP doesn't appear to require.
Any ideas why cv2.VideoCapture is apparently failing ?
I have tried variants of the above code, but nothing seems to work. I have enabled ONVIF on the camera