0
votes

I have a video dataset downloaded and I am trying to access its frames. Here is the code below, it counts video frames correctly but when i print frames it returns zero matrice. What is wrong with this code? Any help is highly appreciated.

(Also I can see frames correctly in an 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
1
What do you expect to be printed? It prints some (almost) meaningless text in the console window like: [[ 0, 0, 0],[ 0, 0, 0],[ 0, 0, 0],...,[255, 255, 255],[255, 255, 255],[255, 255, 255]],....Rotem

1 Answers

0
votes

I solved it, the problem is Google Colab can not access my local.