【问题标题】:Can't use opencv to read my ip camera video无法使用 opencv 读取我的网络摄像机视频
【发布时间】:2022-08-02 18:45:42
【问题描述】:

您好,我是 opencv 的初学者,我正在尝试通过 HIKVISION IP 摄像头创建实时对象检测程序。使用 RTSP 但当我运行代码时出现此错误

ip_add 就像rtsp://login:password@ip_address:554/streaming/channels/101

cap = cv2.VideoCapture(Ip_add, cv2.CAP_FFMPEG)

while True:
_, frame = cap.read()
frame = cv2.resize(frame, dsize=(1400, 600))

(class_ids, scores, bboxes) = model.detect(frame)

for class_id, score, bbox in zip(class_ids, scores, bboxes):
    (x, y, w, h) = bbox
    cv2.putText(frame, classes[class_id], (x, y - 10), cv2.FONT_HERSHEY_PLAIN, 2,(200, 0, 50),2)
    cv2.rectangle(frame, (x, y), (x + w, y + h), (200, 0, 50), 2)
cv2.imshow(\"IP Camera\", frame)
if cv2.waitKey(1) == ord(\"q\"):
    break
cap.release()
cv2.destroyAllWindows()

有人可以帮帮我吗 ?

  • 对不起...这是我得到的错误:[h264 @ 0000021c7162b0c0] 不存在的 PPS 0 引用 [h264 @ 0000021c7162b0c0] 不存在的 PPS 0 引用 [h264 @ 0000021c7162b0c0] decode_slice_header 错误 [h264 @ 000000021c 帧! [h264 @ 0000021c7162b0c0] 引用了不存在的 PPS 0 [h264 @ 0000021c7162b0c0] 引用了不存在的 PPS 0 [h264 @ 0000021c7162b0c0] decode_slice_header 错误 [h264 @ 0000021c7162b0c0] 没有帧!
  • 它可以与 FFplay(shell 命令)一起使用吗? ffplay rtsp://login:password@ip_address:554/streaming/channels/101

标签: python opencv rtsp


【解决方案1】:

我终于通过使用imutils而不是opencv来读取实时视频流解决了这个问题。

import cv2
import imutils
from imutils.video import VideoStream

rtsp_url = "rtsp://login:passzord@ipaddress/streaming/channels/101"
video_stream = VideoStream(rtsp_url).start()

while True:
frame = video_stream.read()
if frame is None:
    continue

frame = imutils.resize(frame,width=1200)

frame = cv2.resize(frame, dsize=(1400, 600))


cv2.imshow('Ip Camera ', frame)
key = cv2.waitKey(1) & 0xFF
if key == ord('q'):
    break

cv2.destroyAllWindows()
video_stream.stop()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 2016-11-20
    • 2013-07-11
    • 2019-12-19
    • 1970-01-01
    • 2014-03-27
    • 2021-09-13
    相关资源
    最近更新 更多