I installed opencv3 installation link on my raspberrypi 3 and i've tested this, everything is ok, but when i try to read the ipcamera video stream encountered this error
self.stream = cv2.VideoCapture("rtsp://*:*@{}:525/stream2".format(ip_camera_address))
'NoneType' object has no attribute '__array_interface__'
Reading the webcam with the usb interface and everything is ok
I think my problem is in ffmpeg library, I try to install this library but it won't fix.
3 Answers 3
if you need run USBcam
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
if you need run IPcam
import cv2
cap = cv2.VideoCapture('rtsp://username:[email protected]/1')
while(True):
ret, frame = cap.read()
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
-
It is a true method for read video stream at IP camera, But my problem is fix ffmpeg in openCV ,My sintex is true because I have tested this on my PC, But this does not work properly on raspberryHamed– Hamed2019年07月03日 18:00:30 +00:00Commented Jul 3, 2019 at 18:00
-
This is often and I had something working on the PC but it does not work on raspberries, try gstreamerUM Igor– UM Igor2019年07月04日 12:00:43 +00:00Commented Jul 4, 2019 at 12:00
I install opencv again [best link for install this] and i try to install FFmpeg from repository. affter installation of ffmepg i tried to read ipcamera video stream with this script
Note : after finshing opencv cmake, FFmpeg subitems most all get YES.
self.stream = cv2.VideoCapture("rtsp://user:password@{}:525/stream2".format(ip_camera_address))
And It worked successfully.
This tutorial help me to install ffmpeg on raspberry pi link
First check your camera providers correct address format:
I used Dahua IPC-HFW2231S camera
Take a look to correct structure https://www.camera-sdk.com/p_6658-how-to-connect-to-your-dahua-ip-camera-onvif.html
Examples to my camera https://dahuawiki.com/Remote_Access/RTSP_via_VLC
And the working code below. subtype (Sub stream) can be changed between main stream and sub stream.
cap=cv2.VideoCapture('rtsp://admin:[email protected]:554//cam/realmonitor?channel=1&subtype=1')
-
Please take a moment to review Markdown formatting.Seamus– Seamus2021年04月21日 21:22:17 +00:00Commented Apr 21, 2021 at 21:22
*:*@{}
is a place-holder for a validuser:pass@host