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.

2
  • I take it *:*@{} is a place-holder for a valid user:pass@host Jun 30, 2019 at 23:07
  • This is just an example. I used the user and password
    – Hamed
    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()
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
    – Hamed
    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
    – UM Igor
    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

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:PASSWOR[email protected]:554//cam/realmonitor?channel=1&subtype=1')

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.