OpenCV 计数帧但不读取它们
OpenCV counts frames but doesnt read them
我下载了一个视频数据集,我正在尝试访问它的帧。这是下面的代码,它可以正确计算视频帧,但是当我打印帧时它 returns 零矩阵。这段代码有什么问题?非常感谢任何帮助。
(我也可以在 opencv window 中正确看到帧:cv2.imshow('a',frame)
def get_video_files(glob_path):
video_count,frames=0,0
frame_list=[]
for file in os.scandir(glob_path): #each video in the path
video_count+=1
cap = cv2.VideoCapture(file.path)
while True:
status, frame = cap.read()
if not status:
break
frames += 1
print(frame)
frame_list.append(frame)
cap.release()
print (str(video_count)+' videos and '+str(frames)+' frames are found. Average frame count is '+"{:.3f}".format((frames/video_count))) #RETURNS LOGICAL RESULTS
print(frame_list) #RETURNS ZERO MATRICES
我解决了,问题是Google Colab无法访问我的本地
我下载了一个视频数据集,我正在尝试访问它的帧。这是下面的代码,它可以正确计算视频帧,但是当我打印帧时它 returns 零矩阵。这段代码有什么问题?非常感谢任何帮助。
(我也可以在 opencv window 中正确看到帧:cv2.imshow('a',frame)
def get_video_files(glob_path):
video_count,frames=0,0
frame_list=[]
for file in os.scandir(glob_path): #each video in the path
video_count+=1
cap = cv2.VideoCapture(file.path)
while True:
status, frame = cap.read()
if not status:
break
frames += 1
print(frame)
frame_list.append(frame)
cap.release()
print (str(video_count)+' videos and '+str(frames)+' frames are found. Average frame count is '+"{:.3f}".format((frames/video_count))) #RETURNS LOGICAL RESULTS
print(frame_list) #RETURNS ZERO MATRICES
我解决了,问题是Google Colab无法访问我的本地