如何获取Python OpenCV实时流的最后一帧?

2024-05-19 03:20:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python OpenCV从RTSP实时流获取帧。在处理帧时,有时我需要暂停剪辑并恢复最新帧(意味着应该跳转最后/最新帧)

cap = cv2.VideoCapture(clip_url)
while (ret):
   ret,image_np = cap.read()
   time.sleep (1) # Just for ex, I am pausing, but next time it should read the latest frame

我试图得到长度/帧数,但它总是显示负值

totalframes = cap.get(cv2.CAP_PROP_FRAME_COUNT)

Tags: imageurlreadcliptime剪辑npsleep

热门问题