0

I want to update image element on the gui by using vlc player to get real time webcam images. Normally I was using cv2.videoCapture to get frame. After getting frame I was updating window['image']. But I couldn't make it by using vlc. Let me explain more detaily. Here the my gui codes:

col1 = [[sg.Image(filename='', key='image0')],
        [sg.Text('Kamera 1 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text0')]]
col2 = [[sg.Image(filename='', key='image1')],
        [sg.Text('Kamera 2 Durumu :', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text1')]]
col3 = [[sg.Image(filename='', key='image2')],
        [sg.Text('Kamera 3 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text2')]]
col4 = [[sg.Image(filename='', key='image3')],
        [sg.Text('Kamera 4 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text3')]]
col5 = [[sg.Image(filename='', key='image4')],
        [sg.Text('Kamera 5 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text4')]]
col6 = [[sg.Image(filename='', key='image5')],
        [sg.Text('Kamera 6 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text5')]]
col7 = [[sg.Image(filename='', key='image6')],
        [sg.Text('Kamera 7 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text6')]]
col8 = [[sg.Image(filename='', key='image7')],
        [sg.Text('Kamera 8 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text7')]]
col9 = [[sg.Image(filename='', key='image8')],
        [sg.Text('Kamera 9 Durumu:', justification='left', size=(30, 1), font=("Times New Roman", 10), key='Text8')]]
col10 = [[sg.Text('Aktif Kamera Sayısı:', justification='left', size=(50, 1), font=("Times New Roman", 20), key='Text10')],
         [sg.Text('Dolu İstasyon Sayısı:', justification='left', size=(50, 1), font=("Times New Roman", 20), key='Text11')],
         [sg.Text('Kamera 1 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text12')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Red", "Green"), key='progbar1')],
         [sg.Text('Kamera 2 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text13')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color ("Green", "Red"), key='progbar2')],
         [sg.Text('Kamera 3 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text14')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color ("Green", "Red"), key='progbar3')],
         [sg.Text('Kamera 4 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text15')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Red", "Green"), key='progbar4')],
         [sg.Text('Kamera 5 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text16')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Green", "Red"), key='progbar5')],
         [sg.Text('Kamera 6 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text17')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Green", "Red"), key='progbar6')],
         [sg.Text('Kamera 7 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text18')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Green", "Red"), key='progbar7')],
         [sg.Text('Kamera 8 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text19')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Red", "Green"), key='progbar8')],
         [sg.Text('Kamera 9 Müşteri Durumu:', justification='left', size=(50, 1), font=("Times New Roman", 19), key='Text20')],
         [sg.ProgressBar(75, orientation='h', size=(35, 20), border_width=4, bar_color=("Green", "Red"), key='progbar9')]]

column1_1 = [[sg.Frame(layout=col1, title=''), sg.Frame(layout=col2, title=''), sg.Frame(layout=col3, title='')],
         [sg.Frame(layout=col4, title=''), sg.Frame(layout=col5, title=''), sg.Frame(layout=col6, title='')],
         [sg.Frame(layout=col7, title=''), sg.Frame(layout=col8, title=''), sg.Frame(layout=col9, title='')]]

column1_2 = [[sg.Column(col10, element_justification='c')]]

layout = [[sg.Frame(layout=column1_1, title=''), sg.Frame(layout=column1_2, title='')]]

window = sg.Window("İstasyon Kontrol", layout).Finalize()
window.Maximize()

while True:  # The Event Loop
    
    window['image...'].update(...) ---> Example!!

As you can see, there are image elements. As I said, I was updating this element by getting frames from videoCapture. How can I get and update frames by using vlc library? Maybe I shouldn't use image element. Is there another option?

I tried to use something like:

player = vlci.media_player_new()
video = vlci.media_new(sources)
player.set_media(video)

But I didn't understand how can I update my gui. Thank you.

YusufUcan
  • 49
  • 5

0 Answers0