问题
Hello im learning opencv and im reading a ip camera through rtsp://
videoStream = "rtsp://admin:123456@10.0.0.1:554/Streaming/Channels/1"
capture = cv2.VideoCapture(videoStream)
im reading this stream and im making a facial detection in opencv
but after 1 or 2 minutes my script crashes whit a h264
message and my opencv
code gives me a error:
[h264 @ 0x27e49570] error while decoding MB 55 12, bytestream -12
no video
and if i use a webcan it not happening
some one can help me whit how is the best way to get a ip camera streaming for facial detection?
回答1:
Before you process any frames, you can ensure that the camera is open and that obtained frames are valid.
videoStream = "rtsp://admin:123456@10.0.0.1:554/Streaming/Channels/1"
capture = cv2.VideoCapture(videoStream)
while True:
if capture.isOpened():
status, frame = capture.read()
if status:
# Process frames here
...
If you are unable to access the camera or get corrupted frames, you can catch this with cv2.error
.
try:
...
except cv2.error as e:
...
来源:https://stackoverflow.com/questions/54754291/opencv-cv2-videocapture-stopping-to-read-rtsp-ip-camera