问题描述
首先感谢您的关注.我正在尝试使用 opencv 和 ip 摄像头进行流式传输,但它只返回[tcp @ 000001d5fce13580] uri 中缺少端口".我已经在 VLC 上进行了测试,也用 JavaCV 进行了测试,并且在两者上都可以使用.我已经检查了 MPEG 并且没问题.有没有人经历过这个并且可以提供帮助?
我和:
- WIN10
- OpenCV 4.5.1
代码:
将 numpy 导入为 np导入 cv2def runCam():打印(cv2.getBuildInformation())video_src = "rtsp://admin:[email protected]:554/Streaming/channels/1/";帽 = cv2.VideoCapture(video_src, cv2.CAP_FFMPEG)为真:ret, frame = cap.read()尝试:cv2.resizeWindow('Stream IP Camera OpenCV', 120300, 800)cv2.imshow('Stream IP Camera OpenCV', frame)除了例外,例如:template = "发生了 {0} 类型的异常.参数:\n{1!r}"message = template.format(type(ex).__name__, ex.args)打印(消息)休息如果 cv2.waitKey(1) &0xFF == ord('q'):休息cap.release()cv2.destroyAllWindows()运行摄像头()
OPENCV 构建信息:
RESOLVED
问题出在我的密码上,由于某种原因,当密码包含#"时,opencv 的 VideoCapture 会感到困惑.当我在 javacv 和 VLC 中测试它并且它工作时,我没有用另一个密码测试它并且浪费了很多时间:(但是现在我发现我更改了密码并且它已经工作了.我希望它可以帮助那些谁有同样的问题要注意特殊的密码字符.
First of all, thank you for your attention.I'm trying to stream with opencv and ip camera, but it only returns "[tcp @ 000001d5fce13580] Port missing in uri". I have already tested on VLC and also tested with JavaCV and it works on both. I already checked the MPEG and it's OK. Has anyone been through this and can help?
I am with:
- WIN10
- OpenCV 4.5.1
CODE:
import numpy as np
import cv2
def runCam():
print(cv2.getBuildInformation())
video_src = "rtsp://admin:[email protected]:554/Streaming/channels/1/"
cap = cv2.VideoCapture(video_src, cv2.CAP_FFMPEG)
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)
break
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
runCam()
OPENCV BUILD INFO: https://gist.github.com/nathancn/745f543e3a6cd13d012855759bd0940d
I USE HIKVISION IP CAM MODEL DS-2CD2621G0-IS
ERROR RETURNED:
RESOLVED
The problem was with my password, for some reason opencv's VideoCapture gets confused when the password contains "#". As I tested it in javacv and VLC and it worked, I had not tested it with another password and wasted a lot of time with it :( But now that I found out I changed the password and it already worked. I hope it helps those who have the same problem to be aware of special password characters .
这篇关于cv2.videoCapture 仅返回“uri 中缺少端口";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!