我有以下代码从视频文件中读取帧并存储为jpg。如果我直接从相机读取帧,代码工作正常,但对于视频文件,它不会读取帧
cap = cv2.VideoCapture('C:/Users/lostpanda.mp4')
#cap = cv2.VideoCapture(0)
count = 0
while cap.isOpened():
ret,frame = cap.read()
print(ret,frame)
cv2.imshow('window-name', frame)
name = 'C:/Users/video_testing/video-frames/' + str(count) + '.jpg'
#cv2.imwrite("frame%d.jpg" % count, frame)
cv2.imwrite(name,frame)
count = count + 1
if cv2.waitKey(10) & 0xFF == ord('q'):
break
谢谢
您可以尝试以下方法:
相关问题 更多 >
编程相关推荐