0

I am trying to list all the video inside a folder onto a listbox and open the video using VideoCapture and imshhow module from opencv but keep getting empty frames.

Tried with all the possible ways I can find online but still couldn't figure it out.

from tkinter import*
import tkinter as tk
import cv2
import os
root=tk.Tk()
sizex = 600
sizey = 400
posx  = 40
posy  = 20

comma="'"
def CurSelet(evt):
    value=str((mylistbox.get(ANCHOR)))
    value=comma+value+comma
    print (value)
    cap = cv2.VideoCapture('test.mp4')
    while 1:
        ret,frame=cap.read()
        if ret:
            cv2.imshow("test",frame)

mylistbox=Listbox(root,width=60,height=10,font=('times',13))
mylistbox.bind('<<ListboxSelect>>',CurSelet)
mylistbox.place(x=32,y=90)

# get the list of files
flist = os.listdir()



# THE ITEMS INSERTED WITH A LOOP
for item in flist:
        mylistbox.insert(tk.END, item)  
root.mainloop()

No errors but only empty frames.

Amirul Iqram
  • 313
  • 1
  • 3
  • 13
  • is the video `test.mp4` exists in your current directory? – Shan Ali Sep 14 '19 at 12:14
  • Read [While Loop Locks Application](https://stackoverflow.com/questions/28639228/python-while-loop-locks-application) – stovfl Sep 14 '19 at 13:03
  • Sorry Shan Ali, the value is supposed to be value because it's the string obtained from the listbox but still getting empty frames and I cannot figure out why. – Amirul Iqram Sep 14 '19 at 14:17

0 Answers0