<p>转到您的相机设置(网络配置)并检查de rtsp端口,在我的情况下是555。</p>
<p>我有一个海康威视DS-2CD2D14WD,在我的情况下,我必须使用以下:</p>
<p>rtsp://yourusername:yourpassword@172.16.30.248:555/Streaming/channels/2/</p>
<p>你可以在一个类似VLC播放器的程序中测试你的配置。</p>
<p>IP地址后的路径可以根据您的型号而更改,请检查<br/>
其他海康威视型号的此页:</p>
<p><a href="https://www.ispyconnect.com/man.aspx?n=Hikvision" rel="nofollow noreferrer">https://www.ispyconnect.com/man.aspx?n=Hikvision</a>。</p>
<p>我建议您查看这个github页面:</p>
<p><a href="https://github.com/JFF-Bohdan/pynvr.git" rel="nofollow noreferrer">https://github.com/JFF-Bohdan/pynvr.git</a></p>
<p>请告诉我这些信息对你是否有用。</p>
<p>示例:</p>
<pre><code>import numpy as np
import cv2
cap = cv2.VideoCapture()
cap.open("rtsp://yourusername:yourpassword@172.16.30.248:555/Streaming/channels/2/")
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',ret)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
</code></pre>