add blink time extender, fix single eye osc, force eyes to be on correct sides + more

This commit is contained in:
Prohurtz 2022-09-19 18:41:24 -07:00
parent 67cd6b5494
commit d1ad33cf1c
4 changed files with 38 additions and 28 deletions

View File

@ -7,7 +7,7 @@ from queue import Queue, Empty
from camera import Camera, CameraState
from osc import EyeId
import cv2
from playsound import playsound
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
class CameraWidget:
def __init__(self, widget_id: EyeId, main_config: EyeTrackConfig, osc_queue: Queue):
@ -238,7 +238,7 @@ class CameraWidget:
self.x1, self.y1 = values[self.gui_roi_selection]
elif event == self.gui_restart_calibration:
self.ransac.calibration_frame_counter = 300
playsound("Audio/start.wav")
PlaySound('Audio/start.wav', SND_FILENAME|SND_ASYNC)
elif event == self.gui_recenter_eye:
self.ransac.recenter_eye = True

View File

@ -13,7 +13,7 @@ import time
import statistics
from one_euro_filter import OneEuroFilter
from sympy import symbols, Eq, solve
from playsound import playsound
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
class InformationOrigin(Enum):
RANSAC = 1
BLOB = 2
@ -374,8 +374,8 @@ class EyeProcessor:
self.calibration_frame_counter = None
self.recenter_eye = False
self.xoff = cx
self.yoff = cy
playsound("Audio/compleated.wav")
self.yoff = cy
PlaySound('Audio/compleated.wav', SND_FILENAME|SND_ASYNC)
elif self.calibration_frame_counter != None:
if cx > self.xmax:
self.xmax = cx
@ -530,10 +530,7 @@ class EyeProcessor:
self.current_image, cv2.COLOR_BGR2GRAY
)
try:
print(int(float(self.lkg_projected_sphere["axes"][0])), int(float(self.lkg_projected_sphere["axes"][1])))
except:
print('nah')
try:
ht, wd = self.current_image_gray.shape[:2]
@ -663,7 +660,7 @@ class EyeProcessor:
self.recenter_eye = False
self.xoff = exm
self.yoff = eym
playsound("Audio/compleated.wav")
PlaySound('Audio/compleated.wav', SND_FILENAME|SND_ASYNC)
elif self.calibration_frame_counter != None: # TODO reset calibration values on button press
if exm > self.xmax:
self.xmax = exm

View File

@ -105,7 +105,7 @@ def main():
settings[0].widget_layout,
vertical_alignment="top",
key=SETTINGS_NAME,
visible=(config.eye_display_id in [EyeId.SETTINGS, EyeId.BOTH]),
visible=(config.eye_display_id in [EyeId.SETTINGS]),
background_color='#424042',
),
],

View File

@ -2,7 +2,7 @@ from pythonosc import udp_client
import queue
import threading
from enum import IntEnum
import time
class EyeId(IntEnum):
RIGHT = 0
@ -19,12 +19,13 @@ class VRChatOSC:
self.main_config = main_config
self.config = main_config.settings
self.client = udp_client.SimpleUDPClient(self.config.gui_osc_address, self.config.gui_osc_port) # use OSC port and address that was set in the config
self.client = udp_client.SimpleUDPClient(self.config.gui_osc_address, int(self.config.gui_osc_port)) # use OSC port and address that was set in the config
self.cancellation_event = cancellation_event
self.msg_queue = msg_queue
def run(self):
start = time.time()
last_blink = 0
yl = 621
yr = 621
sx = 0
@ -43,7 +44,6 @@ class VRChatOSC:
if not eye_info.blink:
if eye_id in [EyeId.RIGHT]:
sx = eye_info.x
yr = eye_info.y
@ -71,29 +71,42 @@ class VRChatOSC:
self.client.send_message("/avatar/parameters/EyesY", y)
se = 0
if rec != 1 and lec != 1:
if rec == 0 or lec == 0:
print("here")
se = 1
self.client.send_message("/avatar/parameters/LeftEyeX", sx) # only one eye is detected or there is an error. Send mirrored data to both eyes.
self.client.send_message("/avatar/parameters/RightEyeX", sx)
self.client.send_message("/avatar/parameters/EyesY", sy)
self.client.send_message("/avatar/parameters/RightEyeLid", float(0))# old param open right
self.client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(0.8)) # open r
self.client.send_message("/avatar/parameters/LeftEyeLid", float(0))# old param open left
self.client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(0.8)) # open left eye
else:
if eye_id in [EyeId.LEFT]:
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
self.client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(0))
if last_blink > 0.5:
for i in range(4):
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
self.client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(0))
last_blink = time.time()
if eye_id in [EyeId.RIGHT]:
self.client.send_message("/avatar/parameters/RightEyeLid", float(1))
self.client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(0)) # close eye
if last_blink > 0.5:
for i in range(4):
self.client.send_message("/avatar/parameters/RightEyeLid", float(1))
self.client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(0)) # close eye
last_blink = time.time()
if se == 1:
self.client.send_message("/avatar/parameters/RightEyeLid", float(1)) #close eye
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
self.client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(0)) # close eye
self.client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(0))
if last_blink > 0.5:
for i in range(4):
self.client.send_message("/avatar/parameters/RightEyeLid", float(1)) #close eye
self.client.send_message("/avatar/parameters/LeftEyeLid", float(1))
self.client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(0)) # close eye
self.client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(0))
last_blink = time.time()