mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
cleanup
This commit is contained in:
parent
cb341ccd98
commit
5e9ac84e07
@ -59,10 +59,6 @@ class SettingsWidget:
|
|||||||
# Define the window's contents
|
# Define the window's contents
|
||||||
self.general_settings_layout = [
|
self.general_settings_layout = [
|
||||||
|
|
||||||
# [
|
|
||||||
# sg.Button("Recenter Eye", key=self.gui_recenter_eye, button_color = '#6f4ca1'),
|
|
||||||
|
|
||||||
# ],
|
|
||||||
[
|
[
|
||||||
sg.Checkbox(
|
sg.Checkbox(
|
||||||
"Flip Left Eye X Axis",
|
"Flip Left Eye X Axis",
|
||||||
@ -95,7 +91,6 @@ class SettingsWidget:
|
|||||||
|
|
||||||
[
|
[
|
||||||
sg.Text("Tracking Algorithim Settings:", background_color='#242224'),
|
sg.Text("Tracking Algorithim Settings:", background_color='#242224'),
|
||||||
# sg.InputText(self.config.capture_source, key=self.gui_camera_addr),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[sg.Checkbox(
|
[sg.Checkbox(
|
||||||
@ -128,35 +123,15 @@ class SettingsWidget:
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Text("Filter Paramaters:", background_color='#242224'),
|
sg.Text("Filter Paramaters:", background_color='#242224'),
|
||||||
|
|
||||||
# sg.InputText(self.config.capture_source, key=self.gui_camera_addr),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
||||||
sg.Text("Min Frequency Cutoff", background_color='#424042'),
|
sg.Text("Min Frequency Cutoff", background_color='#424042'),
|
||||||
sg.InputText(self.config.gui_min_cutoff, key=self.gui_min_cutoff),
|
sg.InputText(self.config.gui_min_cutoff, key=self.gui_min_cutoff),
|
||||||
|
|
||||||
|
|
||||||
#sg.Slider(
|
|
||||||
# range=(0, 10),
|
|
||||||
# default_value=self.config.gui_min_cutoff,
|
|
||||||
# orientation="h",
|
|
||||||
# key=self.gui_min_cutoff,
|
|
||||||
# background_color='#424042'
|
|
||||||
#),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Text("Speed Coefficient", background_color='#424042'),
|
sg.Text("Speed Coefficient", background_color='#424042'),
|
||||||
sg.InputText(self.config.gui_speed_coefficient, key=self.gui_speed_coefficient),
|
sg.InputText(self.config.gui_speed_coefficient, key=self.gui_speed_coefficient),
|
||||||
|
|
||||||
# sg.Text("Speed Coefficient", background_color='#424042'),
|
|
||||||
#sg.Slider(
|
|
||||||
# range=(0, 20),
|
|
||||||
# default_value=9,
|
|
||||||
# orientation="h",
|
|
||||||
# key=self.gui_speed_coefficient_slider,
|
|
||||||
# background_color='#424042'
|
|
||||||
# ),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Text("OSC Settings:", background_color='#242224'),
|
sg.Text("OSC Settings:", background_color='#242224'),
|
||||||
@ -182,34 +157,16 @@ class SettingsWidget:
|
|||||||
sg.InputText(self.config.gui_osc_recalibrate_address, key=self.gui_osc_recalibrate_address),
|
sg.InputText(self.config.gui_osc_recalibrate_address, key=self.gui_osc_recalibrate_address),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
#[sg.Image(filename="", key=self.gui_tracking_image)],
|
|
||||||
# [
|
|
||||||
# sg.Graph(
|
|
||||||
# (200, 200),
|
|
||||||
# (-100, 100),
|
|
||||||
# (100, -100),
|
|
||||||
# background_color="white",
|
|
||||||
# key=self.gui_output_graph,
|
|
||||||
# drag_submits=True,
|
|
||||||
# enable_events=True,
|
|
||||||
# ),
|
|
||||||
# sg.Text("Please set an Eye Cropping.", key=self.gui_roi_message, background_color='#424042', visible=False),
|
|
||||||
# ],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
self.widget_layout = [
|
self.widget_layout = [
|
||||||
[
|
[
|
||||||
sg.Text("General Settings:", background_color='#242224'),
|
sg.Text("General Settings:", background_color='#242224'),
|
||||||
# sg.InputText(self.config.capture_source, key=self.gui_camera_addr),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color='#424042' ),
|
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color='#424042' ),
|
||||||
#sg.Column(self.algo_settings_layout, key=self.gui_algo_settings_layout, background_color='#424042' ),
|
|
||||||
# sg.Column(self.roi_layout, key=self.gui_roi_layout, background_color='#424042', visible=False),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
# [
|
# [
|
||||||
# sg.Button(
|
# sg.Button(
|
||||||
# "Save Settings", key=self.gui_save_button, button_color = '#6f4ca1'
|
# "Save Settings", key=self.gui_save_button, button_color = '#6f4ca1'
|
||||||
@ -217,33 +174,10 @@ class SettingsWidget:
|
|||||||
#],
|
#],
|
||||||
]
|
]
|
||||||
|
|
||||||
self.cancellation_event = Event()
|
self.cancellation_event = Event() # Set the event until start is called, otherwise we can block if shutdown is called.
|
||||||
# Set the event until start is called, otherwise we can block if shutdown is called.
|
|
||||||
self.cancellation_event.set()
|
self.cancellation_event.set()
|
||||||
# self.capture_event = Event()
|
|
||||||
# self.capture_queue = Queue()
|
|
||||||
# self.roi_queue = Queue()
|
|
||||||
|
|
||||||
self.image_queue = Queue()
|
self.image_queue = Queue()
|
||||||
|
|
||||||
# self.ransac = EyeProcessor(
|
|
||||||
# self.config,
|
|
||||||
# self.cancellation_event,
|
|
||||||
# self.capture_event,
|
|
||||||
# self.capture_queue,
|
|
||||||
# self.image_queue,
|
|
||||||
# )
|
|
||||||
|
|
||||||
# self.camera_status_queue = Queue()
|
|
||||||
#self.camera = Camera(
|
|
||||||
# self.config,
|
|
||||||
# 0,
|
|
||||||
# self.cancellation_event,
|
|
||||||
#self.capture_event,
|
|
||||||
# self.camera_status_queue,
|
|
||||||
#self.capture_queue,
|
|
||||||
#)
|
|
||||||
|
|
||||||
|
|
||||||
def started(self):
|
def started(self):
|
||||||
return not self.cancellation_event.is_set()
|
return not self.cancellation_event.is_set()
|
||||||
@ -253,18 +187,12 @@ class SettingsWidget:
|
|||||||
if not self.cancellation_event.is_set():
|
if not self.cancellation_event.is_set():
|
||||||
return
|
return
|
||||||
self.cancellation_event.clear()
|
self.cancellation_event.clear()
|
||||||
#self.ransac_thread = Thread(target=self.ransac.run)
|
|
||||||
# self.ransac_thread.start()
|
|
||||||
# self.camera_thread = Thread(target=self.camera.run)
|
|
||||||
# self.camera_thread.start()
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
# If we're not running yet, bail
|
# If we're not running yet, bail
|
||||||
if self.cancellation_event.is_set():
|
if self.cancellation_event.is_set():
|
||||||
return
|
return
|
||||||
self.cancellation_event.set()
|
self.cancellation_event.set()
|
||||||
# self.ransac_thread.join()
|
|
||||||
#self.camera_thread.join()
|
|
||||||
|
|
||||||
def render(self, window, event, values):
|
def render(self, window, event, values):
|
||||||
# If anything has changed in our configuration settings, change/update those.
|
# If anything has changed in our configuration settings, change/update those.
|
||||||
@ -296,14 +224,8 @@ class SettingsWidget:
|
|||||||
|
|
||||||
if self.config.gui_speed_coefficient != values[self.gui_speed_coefficient]:
|
if self.config.gui_speed_coefficient != values[self.gui_speed_coefficient]:
|
||||||
self.config.gui_speed_coefficient = values[self.gui_speed_coefficient]
|
self.config.gui_speed_coefficient = values[self.gui_speed_coefficient]
|
||||||
|
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
||||||
#if self.config.rotation_angle != values[self.gui_rotation_slider]:
|
|
||||||
# self.config.rotation_angle = int(values[self.gui_rotation_slider])
|
|
||||||
# changed = True
|
|
||||||
# print(self.config.gui_flip_x_axis, values[self.gui_flip_x_axis])
|
|
||||||
if self.config.gui_flip_x_axis_right != values[self.gui_flip_x_axis_right]:
|
if self.config.gui_flip_x_axis_right != values[self.gui_flip_x_axis_right]:
|
||||||
self.config.gui_flip_x_axis_right = values[self.gui_flip_x_axis_right]
|
self.config.gui_flip_x_axis_right = values[self.gui_flip_x_axis_right]
|
||||||
changed = True
|
changed = True
|
||||||
@ -330,67 +252,7 @@ class SettingsWidget:
|
|||||||
self.config.gui_blob_maxsize = values[self.gui_blob_maxsize]
|
self.config.gui_blob_maxsize = values[self.gui_blob_maxsize]
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
#print(self.config.gui_flip_x_axis, values[self.gui_flip_x_axis])
|
|
||||||
# if values[self.gui_flip_x_axis] != self.config.gui_flip_x_axis:
|
|
||||||
# values[self.gui_flip_x_axis] = self.config.gui_flip_x_axis
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
self.main_config.save()
|
self.main_config.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# elif self.camera.camera_status == CameraState.CONNECTING:
|
|
||||||
# window[self.gui_mode_readout].update("Camera Connecting")
|
|
||||||
# elif self.camera.camera_status == CameraState.DISCONNECTED:
|
|
||||||
# window[self.gui_mode_readout].update("CAMERA DISCONNECTED")
|
|
||||||
#elif needs_roi_set:
|
|
||||||
# window[self.gui_mode_readout].update("Awaiting Eye Cropping Setting")
|
|
||||||
#elif self.ransac.calibration_frame_counter != None:
|
|
||||||
# window[self.gui_mode_readout].update("Calibration")
|
|
||||||
# else:
|
|
||||||
# window[self.gui_mode_readout].update("Tracking")
|
|
||||||
|
|
||||||
# if self.in_roi_mode:
|
|
||||||
# try:
|
|
||||||
# if self.roi_queue.empty():
|
|
||||||
# self.capture_event.set()
|
|
||||||
# maybe_image = self.roi_queue.get(block=False)
|
|
||||||
# imgbytes = cv2.imencode(".ppm", maybe_image[0])[1].tobytes()
|
|
||||||
# graph = window[self.gui_roi_selection]
|
|
||||||
# if self.figure:
|
|
||||||
# graph.delete_figure(self.figure)
|
|
||||||
# INCREDIBLY IMPORTANT ERASE. Drawing images does NOT overwrite the buffer, the fucking
|
|
||||||
# graph keeps every image fed in until you call this. Therefore we have to make sure we
|
|
||||||
# erase before we redraw, otherwise we'll leak memory *very* quickly.
|
|
||||||
# graph.erase()
|
|
||||||
# graph.draw_image(data=imgbytes, location=(0, 0))
|
|
||||||
# if None not in (self.x0, self.y0, self.x1, self.y1):
|
|
||||||
# self.figure = graph.draw_rectangle(
|
|
||||||
# (self.x0, self.y0), (self.x1, self.y1), line_color="#6f4ca1"
|
|
||||||
# )
|
|
||||||
# except Empty:
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# if needs_roi_set:
|
|
||||||
# window[self.gui_roi_message].update(visible=True)
|
|
||||||
# window[self.gui_output_graph].update(visible=False)
|
|
||||||
# return
|
|
||||||
# try:
|
|
||||||
# window[self.gui_roi_message].update(visible=False)
|
|
||||||
# window[self.gui_output_graph].update(visible=True)
|
|
||||||
#(maybe_image, eye_info) = self.image_queue.get(block=False)
|
|
||||||
# imgbytes = cv2.imencode(".ppm", maybe_image)[1].tobytes()
|
|
||||||
# window[self.gui_tracking_image].update(data=imgbytes)
|
|
||||||
|
|
||||||
# Update the GUI
|
|
||||||
# graph = window[self.gui_output_graph]
|
|
||||||
# graph.erase()
|
|
||||||
|
|
||||||
# Relay information to OSC
|
|
||||||
# if eye_info.info_type != InformationOrigin.FAILURE:
|
|
||||||
self.osc_queue.put((EyeId.SETTINGS))
|
self.osc_queue.put((EyeId.SETTINGS))
|
||||||
#self.osc_queue.put((EyeId.SETTINGS))
|
|
||||||
# except Empty:
|
|
||||||
# return
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user