当前位置:   article > 正文

error: (-5:Bad argument) CAP_IMAGES: can‘t find starting number (in the name of file): rtsp://admin_error: (-5:bad argument) cap_images: can't find st

error: (-5:bad argument) cap_images: can't find starting number (in the name

想看一下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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

结果发现报错:
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")
  • 1

双引号中的rtsp地址前不能有空格,如下

cap = cv2.VideoCapture("rtsp://admin:xxxx2021@116.xxx.90.xxx:554/h264/ch1/main/av_stream")
  • 1

问题解决。
附带bmp,jpg和png格式存图的时间消耗做参考

save jpg time is : 0.04970407485961914
  • 1
save png time is : 0.11170268058776855
  • 1
save bmp time is : 0.00502777099609375
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/539502
推荐阅读
相关标签
  

闽ICP备14008679号