capturing rtsp camera using OpenCV python

2019-03-22 16:35发布

I have a remote camera streaming through rtsp protocol and am trying to access it in OpenCV 2.13.1 using python with following code.

camera = cv2.VideoCapture("rtsp://admin:<port>@<ip>/xyz/video.smp")

However, when I do that I get the following warning

WARNING: Couldn't read movie file rtsp://admin:<port>@<ip>/xyz/video.smp

I have also tried doing this:

camera = cv2.VideoCapture.open("rtsp://admin:<port>@<ip>/xyz/video.smp")

but when I do this I get this error:

`AttributeError: 'builtin_function_or_method' object has no attribute` 'open'

I did searched quite a bit about this problem but couldn't get the idea that works for me. Any help would be appreciated.

1条回答
爷的心禁止访问
2楼-- · 2019-03-22 16:50

Credit from RTSP stream and OpenCV (Python):

vcap = cv.VideoCapture("rtsp://192.168.1.2:8080/out.h264")
while(1):
    ret, frame = vcap.read()
    cv.imshow('VIDEO', frame)
    cv.waitKey(1)
查看更多
登录 后发表回答