0

我想通过使用 vlc 播放器获取实时网络摄像头图像来更新 gui 上的图像元素。通常我使用 cv2.videoCapture 来获取帧。获得框架后,我正在更新窗口 ['image']。但我无法通过使用 vlc 来实现。让我更详细地解释一下。这是我的gui代码:

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!!

如您所见,有图像元素。正如我所说,我通过从 videoCapture 获取帧来更新这个元素。如何使用 vlc 库获取和更新帧?也许我不应该使用图像元素。还有其他选择吗?

我尝试使用类似的东西:

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

但我不明白如何更新我的 gui。谢谢你。

4

0 回答 0