赞
踩
想看一下opencv读取rtsp码流并存图的时间消耗,代码如下:
import time
import cv2
cap = cv2.VideoCapture(" rtsp://admin:xxxx2021@116.xxx.90.xxx:554/h264/ch1/main/av_stream")
ret,frame = cap.read()
for i in range(10):
start_time = time.time()
cv2.imwrite("./img/temp.jpeg", frame)
end_time = time.time()
print("process time is :", end_time - start_time)
结果发现报错:
OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): rtsp://admin:xxxx2021@116.xxx.90.xxx:554/h264/
之前经常用,并没有出现过,查了一些解决方案,没效果,最后发现问题在
cap = cv2.VideoCapture(" rtsp://admin:xxxx2021@116.xxx.90.xxx:554/h264/ch1/main/av_stream")
双引号中的rtsp地址前不能有空格,如下
cap = cv2.VideoCapture("rtsp://admin:xxxx2021@116.xxx.90.xxx:554/h264/ch1/main/av_stream")
问题解决。
附带bmp,jpg和png格式存图的时间消耗做参考
save jpg time is : 0.04970407485961914
save png time is : 0.11170268058776855
save bmp time is : 0.00502777099609375
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。