gpt4 book ai didi

python - uri 警告 : Error opening file with Python OpenCV cv2. VideoCapture() 中缺少端口

转载 作者:可可西里 更新时间:2023-11-01 10:41:15 27 4
gpt4 key购买 nike

当我尝试流式传输 ipcam 时,我遇到了如下所示的错误

"[tcp @ 000000000048c640] Port missing in uri warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901)"

import numpy as np
import cv2
cv2.__file__
cap = cv2.VideoCapture('http://admin:password@http://192.168.1.***/')
#cap = cv2.VideoCapture('https://www.youtube.com/watch?v=Mus_vwhTCq0')

while(True):

ret, frame = cap.read()
try:
cv2.resizeWindow('Stream IP Camera OpenCV', 120300, 800)
cv2.imshow('Stream IP Camera OpenCV',frame)
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
print (message)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

cap.release()
cv2.destroyAllWindows()

最佳答案

首先打开 VLC 播放器并确保您的 ipcam 流链接有效。如果成功,我们现在可以检查 OpenCV 是否可以使用 isOpened() 连接到相机并检查帧检索状态:

while True:
if cap.isOpened():
ret, frame = cap.read()
if ret:
# Process here

关于python - uri 警告 : Error opening file with Python OpenCV cv2. VideoCapture() 中缺少端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55451597/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com