@@ -35,6 +35,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
35
35
self .gui_vertical_flip = f"-VERTICALFLIP{ widget_id } -"
36
36
self .gui_horizontal_flip = f"-HORIZONTALFLIP{ widget_id } -"
37
37
self .use_calibration = f"-USECALIBRATION{ widget_id } -"
38
+ self .gui_refresh_button = f"-REFRESHCAMLIST{ widget_id } -"
38
39
self .osc_queue = osc_queue
39
40
self .main_config = main_config
40
41
self .cam_id = widget_id
@@ -165,10 +166,11 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
165
166
self .widget_layout = [
166
167
[
167
168
sg .Text ("Camera Address" , background_color = '#424042' ),
168
- sg .InputCombo (self .camera_list , default_value = self .config .capture_source ,
169
+ sg .InputCombo (values = self .camera_list , default_value = self .config .capture_source ,
169
170
key = self .gui_camera_addr ,
170
171
tooltip = "Enter the IP address or UVC port of your camera. (Include the 'http://')" ,
171
- enable_events = True )
172
+ enable_events = True ),
173
+ sg .Button ("Refresh List" , key = self .gui_refresh_button , button_color = '#539e8a' )
172
174
],
173
175
[
174
176
sg .Button ("Save and Restart Tracking" , key = self .gui_save_tracking_button , button_color = '#539e8a' ),
@@ -244,14 +246,18 @@ def render(self, window, event, values):
244
246
try :
245
247
self .config .use_ffmpeg = False
246
248
# Try storing ints as ints, for those using wired cameras.
247
- if value not in self .camera_list :
248
- self .config .capture_source = value
249
- else :
249
+ #if value not in self.camera_list:
250
+ # self.config.capture_source = value
250
251
#if "COM" not in value:
251
- ports = ("COM" , "/dev/tty" )
252
- if any (x in str (self .config .capture_source ) for x in ports ):
252
+ ports = ("COM" , "/dev/tty" )
253
+ if any (x in str (value ) for x in ports ):
254
+ self .config .capture_source = value
255
+ else :
256
+ cam = get_camera_index_by_name (value ) # Set capture_source to the UVC index. Otherwise treat value like an ipcam if we return none
257
+ if cam != None :
253
258
self .config .capture_source = get_camera_index_by_name (value )
254
- else : self .config .capture_source = value
259
+ else :
260
+ self .config .capture_source = value
255
261
except ValueError :
256
262
if value == "" :
257
263
self .config .capture_source = None
@@ -273,8 +279,6 @@ def render(self, window, event, values):
273
279
274
280
changed = True
275
281
276
-
277
-
278
282
if self .config .rotation_angle != values [self .gui_rotation_slider ]:
279
283
self .config .rotation_angle = int (values [self .gui_rotation_slider ])
280
284
changed = True
@@ -330,6 +334,13 @@ def render(self, window, event, values):
330
334
self .x0 , self .y0 = values [self .gui_roi_selection ]
331
335
self .x1 , self .y1 = values [self .gui_roi_selection ]
332
336
337
+ if (event == self .gui_refresh_button ):
338
+ print ("Refreshed Cameralist" )
339
+ self .camera_list = list_camera_names ()
340
+ print (self .camera_list )
341
+ window [self .gui_camera_addr ].update (values = self .camera_list )
342
+
343
+
333
344
if event == self .gui_restart_calibration :
334
345
self .babble_cnn .calibration_frame_counter = 1500
335
346
PlaySound ('Audio/start.wav' , SND_FILENAME | SND_ASYNC )
0 commit comments