From 0d300a43d5cbee1dc8fb999221ab0d1c13c96798 Mon Sep 17 00:00:00 2001 From: Prohurtz <48768484+RedHawk989@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:28:54 -0800 Subject: [PATCH] fix IBO dual eye --- .gitignore | 1 + EyeTrackApp/eye_processor.py | 16 ++++++++++++++-- EyeTrackApp/eyetrack_settings.backup | 1 + EyeTrackApp/intensity_eye_open.py | 15 ++++++--------- EyeTrackApp/osc.py | 3 +-- 5 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 EyeTrackApp/eyetrack_settings.backup diff --git a/.gitignore b/.gitignore index 22aa2f6..cb6417a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ EyeTrackApp/eyetrack_settings.json EyeTrackApp/build EyeTrackApp/dist EyeTrackApp/IBO_LEFT.png +EyeTrackApp/IBO_RIGHT.png diff --git a/EyeTrackApp/eye_processor.py b/EyeTrackApp/eye_processor.py index 69d1aeb..4229222 100644 --- a/EyeTrackApp/eye_processor.py +++ b/EyeTrackApp/eye_processor.py @@ -108,7 +108,7 @@ class EyeProcessor: ): self.config = config self.settings = settings - + self.eye_id = eye_id # Cross-thread communication management self.capture_queue_incoming = capture_queue_incoming self.image_queue_outgoing = image_queue_outgoing @@ -253,7 +253,7 @@ class EyeProcessor: # if (cx - self.prev_x) <= 45 and (cy - self.prev_y) <= 45 : # self.prev_x = cx # self.prev_y = cy - self.eyeopen = intense(cx, cy, uncropframe, self) + self.eyeopen = intense(cx, cy, uncropframe, self.eye_id) out_x, out_y = cal_osc(self, cx, cy) #print(self.eyeoffx, self.eyeopen) @@ -329,6 +329,10 @@ class EyeProcessor: #set algo priorities + + + + if self.settings.gui_HSF: if self.er_hsf is None: self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius, self.settings.gui_HSF_radius) @@ -391,6 +395,14 @@ class EyeProcessor: print("\033[94m[INFO] Exiting Tracking thread\033[0m") return + #try: + # (self.eye_id, eye_info) = self.msg_queue.get(block=True, timeout=0.1) + # print(self.eye_id) + #except: + #print('eeeeeeee') + #pass + + if self.config.roi_window_w <= 0 or self.config.roi_window_h <= 0: # At this point, we're waiting for the user to set up the ROI window in the GUI. # Sleep a bit while we wait. diff --git a/EyeTrackApp/eyetrack_settings.backup b/EyeTrackApp/eyetrack_settings.backup new file mode 100644 index 0000000..5282ce9 --- /dev/null +++ b/EyeTrackApp/eyetrack_settings.backup @@ -0,0 +1 @@ +{"version": 1, "right_eye": {"rotation_angle": 168, "roi_window_x": 225, "roi_window_y": 161, "roi_window_w": 101, "roi_window_h": 68, "focal_length": 30, "capture_source": "http://192.168.1.43:4747/video", "gui_circular_crop": false}, "left_eye": {"rotation_angle": 37, "roi_window_x": 146, "roi_window_y": 108, "roi_window_w": 115, "roi_window_h": 110, "focal_length": 30, "capture_source": "http://192.168.0.62", "gui_circular_crop": false}, "settings": {"gui_flip_x_axis_left": false, "gui_flip_x_axis_right": false, "gui_flip_y_axis": false, "gui_RANSAC3D": true, "gui_HSF": true, "gui_BLOB": false, "gui_BLINK": true, "gui_HSRAC": true, "gui_HSF_radius": 15, "gui_min_cutoff": "0.0004", "gui_speed_coefficient": "0.9", "gui_osc_address": "127.0.0.1", "gui_osc_port": 9000, "gui_osc_receiver_port": 9001, "gui_osc_recenter_address": "/avatar/parameters/etvr_recenter", "gui_osc_recalibrate_address": "/avatar/parameters/etvr_recalibrate", "gui_blob_maxsize": 25.0, "gui_blob_minsize": 10.0, "gui_recenter_eyes": false, "gui_eye_falloff": false, "tracker_single_eye": 2, "gui_blink_sync": false, "gui_threshold": 65, "gui_HSRACP": 1, "gui_RANSAC3DP": 2, "gui_HSFP": 3, "gui_BLOBP": 4, "gui_skip_autoradius": true, "gui_thresh_add": 20, "gui_update_check": true}, "eye_display_id": 0} \ No newline at end of file diff --git a/EyeTrackApp/intensity_eye_open.py b/EyeTrackApp/intensity_eye_open.py index b3560c6..a1d7b99 100644 --- a/EyeTrackApp/intensity_eye_open.py +++ b/EyeTrackApp/intensity_eye_open.py @@ -2,8 +2,8 @@ import numpy as np import time import os import cv2 -import queue from enum import IntEnum +from osc import EyeId #higher intensity means more closed/ more white/less pupil #Hm I need an acronym for this, any ideas? @@ -88,7 +88,7 @@ def newdata(frameshape): return np.zeros(frameshape, dtype=np.uint32) -def check_and_load(frameshape, now_data): +def check_and_load(frameshape, now_data, fname): # In the future, both eyes may be processed at the same time. Therefore, data should be passed as arguments. req_newdata = False # Not very clever, but increase the width by 1px to save the maximum value. @@ -117,23 +117,20 @@ def check_and_load(frameshape, now_data): return now_data -def intense(x, y, frame, self): +def intense(x, y, frame, eye_id): global lct, data e = False - - try: - (eye_id, eye_info) = self.msg_queue.get(block=True, timeout=0.1) - except: - pass + print(eye_id) if eye_id in [EyeId.RIGHT]: fname = "IBO_RIGHT.png" eye = "RIGHT" if eye_id in [EyeId.LEFT]: fname = "IBO_LEFT.png" eye = "LEFT" + # 0 in data is used as the initial value. # When assigning a value, +1 is added to the value to be assigned. - data = check_and_load(frame.shape[:2], data) + data = check_and_load(frame.shape[:2], data, fname) int_x, int_y = int(x), int(y) # upper_x = min(int_x + 25, frame.shape[1]) #TODO make this a setting diff --git a/EyeTrackApp/osc.py b/EyeTrackApp/osc.py index b8d7f74..11c60f4 100644 --- a/EyeTrackApp/osc.py +++ b/EyeTrackApp/osc.py @@ -17,8 +17,7 @@ class EyeId(IntEnum): from config import EyeTrackConfig class VRChatOSC: - # Use a tuple of blink (true, blinking, false, not), x, y for now. Probably clearer as a class but - # we're stuck in python 3.6 so still no dataclasses. God I hate python. + # Use a tuple of blink (true, blinking, false, not), x, y for now. def __init__(self, cancellation_event: threading.Event, msg_queue: queue.Queue[tuple[bool, int, int]], main_config: EyeTrackConfig,): self.main_config = main_config self.config = main_config.settings