mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
bug fix
This commit is contained in:
parent
5578da7c99
commit
0e99fd3f21
@ -1,4 +1,4 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: py -3.6 ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|||||||
@ -33,10 +33,10 @@ class VRChatOSC:
|
|||||||
self.client.send_message("/avatar/parameters/LeftEye", eye_info.x)
|
self.client.send_message("/avatar/parameters/LeftEye", eye_info.x)
|
||||||
self.client.send_message("/avatar/parameters/EyesY", eye_info.y)
|
self.client.send_message("/avatar/parameters/EyesY", eye_info.y)
|
||||||
if was_blinking:
|
if was_blinking:
|
||||||
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
|
self.client.send_message("/avatar/parameters/LeftEyeLid", float(0))
|
||||||
self.client.send_message("/avatar/parameters/RightEyeLid", float(1))
|
self.client.send_message("/avatar/parameters/RightEyeLid", float(0))
|
||||||
was_blinking = False
|
was_blinking = False
|
||||||
else:
|
else:
|
||||||
self.client.send_message("/avatar/parameters/LeftEyeLid", float(0))
|
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
|
||||||
self.client.send_message("/avatar/parameters/RightEyeLid", float(0))
|
self.client.send_message("/avatar/parameters/RightEyeLid", float(1))
|
||||||
was_blinking = True
|
was_blinking = True
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class CameraWidget:
|
|||||||
self.gui_restart_calibration = f"-RESTARTCALIBRATION{widget_id}-"
|
self.gui_restart_calibration = f"-RESTARTCALIBRATION{widget_id}-"
|
||||||
self.gui_recenter_eye = f"-RECENTEREYE{widget_id}-"
|
self.gui_recenter_eye = f"-RECENTEREYE{widget_id}-"
|
||||||
self.gui_mode_readout = f"-APPMODE{widget_id}-"
|
self.gui_mode_readout = f"-APPMODE{widget_id}-"
|
||||||
self.gui_show_color_image = f"-SHOWCOLORIMAGE{widget_id}-"
|
# self.gui_show_color_image = f"-SHOWCOLORIMAGE{widget_id}-"
|
||||||
self.gui_roi_message = f"-ROIMESSAGE{widget_id}-"
|
self.gui_roi_message = f"-ROIMESSAGE{widget_id}-"
|
||||||
|
|
||||||
self.osc_queue = osc_queue
|
self.osc_queue = osc_queue
|
||||||
@ -57,7 +57,7 @@ class CameraWidget:
|
|||||||
[
|
[
|
||||||
sg.Text("Threshold"),
|
sg.Text("Threshold"),
|
||||||
sg.Slider(
|
sg.Slider(
|
||||||
range=(0, 100),
|
range=(0, 110),
|
||||||
default_value=self.config.threshold,
|
default_value=self.config.threshold,
|
||||||
orientation="h",
|
orientation="h",
|
||||||
key=self.gui_threshold_slider,
|
key=self.gui_threshold_slider,
|
||||||
@ -84,11 +84,11 @@ class CameraWidget:
|
|||||||
[
|
[
|
||||||
sg.Button("Restart Calibration", key=self.gui_restart_calibration),
|
sg.Button("Restart Calibration", key=self.gui_restart_calibration),
|
||||||
sg.Button("Recenter Eye", key=self.gui_recenter_eye),
|
sg.Button("Recenter Eye", key=self.gui_recenter_eye),
|
||||||
sg.Checkbox(
|
#sg.Checkbox(
|
||||||
"Show Color Image:",
|
# "Show Color Image:",
|
||||||
default=self.config.show_color_image,
|
# default=self.config.show_color_image,
|
||||||
key=self.gui_show_color_image,
|
# key=self.gui_show_color_image,
|
||||||
),
|
#),
|
||||||
],
|
],
|
||||||
[sg.Text("Mode:"), sg.Text("Calibrating", key=self.gui_mode_readout)],
|
[sg.Text("Mode:"), sg.Text("Calibrating", key=self.gui_mode_readout)],
|
||||||
[sg.Image(filename="", key=self.gui_tracking_image)],
|
[sg.Image(filename="", key=self.gui_tracking_image)],
|
||||||
@ -210,9 +210,9 @@ class CameraWidget:
|
|||||||
self.config.vrc_eye_position_scalar = int(values[self.gui_scalar_slider])
|
self.config.vrc_eye_position_scalar = int(values[self.gui_scalar_slider])
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if self.config.show_color_image != values[self.gui_show_color_image]:
|
# if self.config.show_color_image != values[self.gui_show_color_image]:
|
||||||
self.config.show_color_image = values[self.gui_show_color_image]
|
# self.config.show_color_image = values[self.gui_show_color_image]
|
||||||
changed = True
|
# changed = True
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
self.main_config.save()
|
self.main_config.save()
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import json
|
|||||||
@dataclass
|
@dataclass
|
||||||
class EyeTrackCameraConfig:
|
class EyeTrackCameraConfig:
|
||||||
threshold: "int" = 0
|
threshold: "int" = 0
|
||||||
rotation_angle: "int" = 0
|
rotation_angle: "int" = 50
|
||||||
roi_window_x: "int" = 0
|
roi_window_x: "int" = 0
|
||||||
roi_window_y: "int" = 0
|
roi_window_y: "int" = 0
|
||||||
roi_window_w: "int" = 0
|
roi_window_w: "int" = 0
|
||||||
@ -20,7 +20,7 @@ class EyeTrackCameraConfig:
|
|||||||
focal_length: "int" = 30
|
focal_length: "int" = 30
|
||||||
capture_source: "Union[int, str, None]" = None
|
capture_source: "Union[int, str, None]" = None
|
||||||
vrc_eye_position_scalar: "int" = 3000
|
vrc_eye_position_scalar: "int" = 3000
|
||||||
show_color_image: "bool" = False
|
#show_color_image: "bool" = False
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILE_NAME = "eyetrack_settings.json"
|
CONFIG_FILE_NAME = "eyetrack_settings.json"
|
||||||
|
|||||||
@ -198,23 +198,23 @@ class EyeProcessor:
|
|||||||
def output_images_and_update(
|
def output_images_and_update(
|
||||||
self, threshold_image, output_information: EyeInformation
|
self, threshold_image, output_information: EyeInformation
|
||||||
):
|
):
|
||||||
if self.config.show_color_image:
|
# if self.config.show_color_image:
|
||||||
image_stack = np.concatenate(
|
# image_stack = np.concatenate(
|
||||||
(
|
# (
|
||||||
self.current_image,
|
# self.current_image,
|
||||||
cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),
|
# cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),
|
||||||
cv2.cvtColor(threshold_image, cv2.COLOR_GRAY2BGR),
|
# cv2.cvtColor(threshold_image, cv2.COLOR_GRAY2BGR),
|
||||||
),
|
# ),
|
||||||
axis=1,
|
# axis=1,
|
||||||
)
|
# )
|
||||||
else:
|
# else:
|
||||||
image_stack = np.concatenate(
|
image_stack = np.concatenate(
|
||||||
(
|
(
|
||||||
cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),
|
cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),
|
||||||
cv2.cvtColor(threshold_image, cv2.COLOR_GRAY2BGR),
|
cv2.cvtColor(threshold_image, cv2.COLOR_GRAY2BGR),
|
||||||
),
|
),
|
||||||
axis=1,
|
axis=1,
|
||||||
)
|
)
|
||||||
self.image_queue_outgoing.put((image_stack, output_information))
|
self.image_queue_outgoing.put((image_stack, output_information))
|
||||||
self.previous_image = self.current_image
|
self.previous_image = self.current_image
|
||||||
self.previous_rotation = self.config.rotation_angle
|
self.previous_rotation = self.config.rotation_angle
|
||||||
@ -258,7 +258,7 @@ class EyeProcessor:
|
|||||||
# something to do blob tracking on.
|
# something to do blob tracking on.
|
||||||
_, larger_threshold = cv2.threshold(
|
_, larger_threshold = cv2.threshold(
|
||||||
self.current_image_gray,
|
self.current_image_gray,
|
||||||
int(self.config.threshold + 25),
|
int(self.config.threshold + 15),
|
||||||
255,
|
255,
|
||||||
cv2.THRESH_BINARY,
|
cv2.THRESH_BINARY,
|
||||||
)
|
)
|
||||||
@ -273,7 +273,7 @@ class EyeProcessor:
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# define circle
|
# define circle
|
||||||
try:
|
try:
|
||||||
ht, wd = self.current_image_gray.shape[:2]
|
ht, wd = self.current_image_gray.shape[:2]
|
||||||
@ -310,7 +310,7 @@ class EyeProcessor:
|
|||||||
raise RuntimeError("No contours found for image")
|
raise RuntimeError("No contours found for image")
|
||||||
except:
|
except:
|
||||||
self.output_images_and_update(
|
self.output_images_and_update(
|
||||||
larger_threshold, EyeInformation(InformationOrigin.FAILURE, 0, 0, False)
|
larger_threshold, EyeInformation(InformationOrigin.FAILURE, 0, 0, 0, False)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ class EyeProcessor:
|
|||||||
|
|
||||||
self.output_images_and_update(
|
self.output_images_and_update(
|
||||||
larger_threshold,
|
larger_threshold,
|
||||||
EyeInformation(InformationOrigin.BLOB, out_x, out_y, w, False),
|
EyeInformation(InformationOrigin.BLOB, out_x, out_y, 0, False),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
self.output_images_and_update(
|
self.output_images_and_update(
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: py -3.6 ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|||||||
@ -25,11 +25,11 @@ class VRChatOSC:
|
|||||||
self.client = udp_client.SimpleUDPClient(VRChatOSC.OSC_IP, VRChatOSC.OSC_PORT)
|
self.client = udp_client.SimpleUDPClient(VRChatOSC.OSC_IP, VRChatOSC.OSC_PORT)
|
||||||
self.cancellation_event = cancellation_event
|
self.cancellation_event = cancellation_event
|
||||||
self.msg_queue = msg_queue
|
self.msg_queue = msg_queue
|
||||||
|
yl = 0
|
||||||
|
yr = 0
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Set blinking status to true when we start, just so we make sure we get to an eyelid open state
|
|
||||||
# no matter what.
|
|
||||||
was_blinking = True
|
|
||||||
while True:
|
while True:
|
||||||
if self.cancellation_event.is_set():
|
if self.cancellation_event.is_set():
|
||||||
print("Exiting OSC Queue")
|
print("Exiting OSC Queue")
|
||||||
@ -39,41 +39,55 @@ class VRChatOSC:
|
|||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
continue
|
continue
|
||||||
# If we're not blinking, set position
|
# If we're not blinking, set position
|
||||||
|
print(eye_info.blink)
|
||||||
if not eye_info.blink:
|
if not eye_info.blink:
|
||||||
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
||||||
self.client.send_message(
|
self.client.send_message(
|
||||||
"/avatar/parameters/RightEye", eye_info.x
|
"/avatar/parameters/RightEyeX", eye_info.x
|
||||||
)
|
|
||||||
self.client.send_message(
|
|
||||||
"/avatar/parameters/EyesDilation", eye_info.pupil_dialation
|
|
||||||
)
|
)
|
||||||
|
# self.client.send_message(
|
||||||
|
# "/avatar/parameters/EyesDilation", eye_info.pupil_dialation
|
||||||
|
#)
|
||||||
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
||||||
self.client.send_message(
|
self.client.send_message(
|
||||||
"/avatar/parameters/LeftEye", eye_info.x
|
"/avatar/parameters/LeftEyeX", eye_info.x
|
||||||
)
|
|
||||||
self.client.send_message(
|
|
||||||
"/avatar/parameters/EyesDilation", eye_info.pupil_dialation
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.client.send_message("/avatar/parameters/EyesY", eye_info.y)
|
|
||||||
if was_blinking:
|
|
||||||
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
|
||||||
self.client.send_message(
|
|
||||||
"/avatar/parameters/LeftEyeLid", float(1)
|
|
||||||
)
|
|
||||||
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
|
||||||
self.client.send_message(
|
|
||||||
"/avatar/parameters/RightEyeLid", float(1)
|
|
||||||
)
|
|
||||||
was_blinking = False
|
|
||||||
else:
|
|
||||||
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
||||||
|
yl = eye_info.y
|
||||||
|
print('left y', yl)
|
||||||
|
|
||||||
|
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
||||||
|
yr = eye_info.y
|
||||||
|
print('right y', yr)
|
||||||
|
|
||||||
|
try:
|
||||||
|
y = abs((yl + yr) / 2)
|
||||||
|
self.client.send_message("/avatar/parameters/EyesY", y)
|
||||||
|
except:
|
||||||
|
print('Y ERROR')
|
||||||
|
|
||||||
|
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
||||||
|
|
||||||
self.client.send_message(
|
self.client.send_message(
|
||||||
"/avatar/parameters/LeftEyeLid", float(0)
|
"/avatar/parameters/LeftEyeLid", float(0)
|
||||||
)
|
)
|
||||||
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
||||||
|
|
||||||
self.client.send_message(
|
self.client.send_message(
|
||||||
"/avatar/parameters/RightEyeLid", float(0)
|
"/avatar/parameters/RightEyeLid", float(0)
|
||||||
)
|
)
|
||||||
was_blinking = True
|
|
||||||
|
else:
|
||||||
|
if eye_id in [EyeId.LEFT, EyeId.BOTH]:
|
||||||
|
|
||||||
|
self.client.send_message(
|
||||||
|
"/avatar/parameters/LeftEyeLid", float(1)
|
||||||
|
)
|
||||||
|
if eye_id in [EyeId.RIGHT, EyeId.BOTH]:
|
||||||
|
|
||||||
|
self.client.send_message(
|
||||||
|
"/avatar/parameters/RightEyeLid", float(1)
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user