1

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.

fcm
1,8792 gold badges19 silver badges31 bronze badges
asked Jun 30, 2019 at 18:09
2
  • I take it *:*@{} is a place-holder for a valid user:pass@host Commented Jun 30, 2019 at 23:07
  • This is just an example. I used the user and password Commented Jun 30, 2019 at 23:11

3 Answers 3

1

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()
Dmitry Grigoryev
28.3k6 gold badges55 silver badges148 bronze badges
answered Jul 1, 2019 at 10:21
2
  • 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 raspberry Commented 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 gstreamer Commented Jul 4, 2019 at 12:00
1

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.

enter image description here

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

answered Jul 4, 2019 at 17:38
0

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')

answered Apr 18, 2021 at 13:05
1
  • Please take a moment to review Markdown formatting. Commented Apr 21, 2021 at 21:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.