代码:
from imutils.video import VideoStream
import cv2
# Read rtsp stream
rtsp = u"rtsp://admin:admin@10.64.1.31:554/1/h264major"
#vs = VideoStream(src=0).start() # for capturing from webcam
vs = VideoStream(src=rtsp).start()
while True:
frame = vs.read()
# show the output frame
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()
这可能是由于RTSP链接的utf-8等编码问题造成的吗?还有其他选择吗?
已解决:我的可执行文件旁边包含opencv_ffmpeg320_64.dll。
答案 0 :(得分:2)
我的可执行文件旁边包含opencv_ffmpeg320_64.dll。 或者,将该DLL文件复制到python目录中的DLLs文件夹