fix IBO dual eye

This commit is contained in:
Prohurtz 2023-02-12 18:28:54 -08:00
parent 5ec32e5b96
commit 0d300a43d5
5 changed files with 23 additions and 13 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ EyeTrackApp/eyetrack_settings.json
EyeTrackApp/build EyeTrackApp/build
EyeTrackApp/dist EyeTrackApp/dist
EyeTrackApp/IBO_LEFT.png EyeTrackApp/IBO_LEFT.png
EyeTrackApp/IBO_RIGHT.png

View File

@ -108,7 +108,7 @@ class EyeProcessor:
): ):
self.config = config self.config = config
self.settings = settings self.settings = settings
self.eye_id = eye_id
# Cross-thread communication management # Cross-thread communication management
self.capture_queue_incoming = capture_queue_incoming self.capture_queue_incoming = capture_queue_incoming
self.image_queue_outgoing = image_queue_outgoing 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 : # if (cx - self.prev_x) <= 45 and (cy - self.prev_y) <= 45 :
# self.prev_x = cx # self.prev_x = cx
# self.prev_y = cy # 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) out_x, out_y = cal_osc(self, cx, cy)
#print(self.eyeoffx, self.eyeopen) #print(self.eyeoffx, self.eyeopen)
@ -329,6 +329,10 @@ class EyeProcessor:
#set algo priorities #set algo priorities
if self.settings.gui_HSF: if self.settings.gui_HSF:
if self.er_hsf is None: if self.er_hsf is None:
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius, self.settings.gui_HSF_radius) 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") print("\033[94m[INFO] Exiting Tracking thread\033[0m")
return 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: 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. # At this point, we're waiting for the user to set up the ROI window in the GUI.
# Sleep a bit while we wait. # Sleep a bit while we wait.

View File

@ -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}

View File

@ -2,8 +2,8 @@ import numpy as np
import time import time
import os import os
import cv2 import cv2
import queue
from enum import IntEnum from enum import IntEnum
from osc import EyeId
#higher intensity means more closed/ more white/less pupil #higher intensity means more closed/ more white/less pupil
#Hm I need an acronym for this, any ideas? #Hm I need an acronym for this, any ideas?
@ -88,7 +88,7 @@ def newdata(frameshape):
return np.zeros(frameshape, dtype=np.uint32) 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. # In the future, both eyes may be processed at the same time. Therefore, data should be passed as arguments.
req_newdata = False req_newdata = False
# Not very clever, but increase the width by 1px to save the maximum value. # 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 return now_data
def intense(x, y, frame, self): def intense(x, y, frame, eye_id):
global lct, data global lct, data
e = False e = False
print(eye_id)
try:
(eye_id, eye_info) = self.msg_queue.get(block=True, timeout=0.1)
except:
pass
if eye_id in [EyeId.RIGHT]: if eye_id in [EyeId.RIGHT]:
fname = "IBO_RIGHT.png" fname = "IBO_RIGHT.png"
eye = "RIGHT" eye = "RIGHT"
if eye_id in [EyeId.LEFT]: if eye_id in [EyeId.LEFT]:
fname = "IBO_LEFT.png" fname = "IBO_LEFT.png"
eye = "LEFT" eye = "LEFT"
# 0 in data is used as the initial value. # 0 in data is used as the initial value.
# When assigning a value, +1 is added to the value to be assigned. # 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) int_x, int_y = int(x), int(y)
# upper_x = min(int_x + 25, frame.shape[1]) #TODO make this a setting # upper_x = min(int_x + 25, frame.shape[1]) #TODO make this a setting

View File

@ -17,8 +17,7 @@ class EyeId(IntEnum):
from config import EyeTrackConfig from config import EyeTrackConfig
class VRChatOSC: class VRChatOSC:
# Use a tuple of blink (true, blinking, false, not), x, y for now. Probably clearer as a class but # Use a tuple of blink (true, blinking, false, not), x, y for now.
# we're stuck in python 3.6 so still no dataclasses. God I hate python.
def __init__(self, cancellation_event: threading.Event, msg_queue: queue.Queue[tuple[bool, int, int]], main_config: EyeTrackConfig,): def __init__(self, cancellation_event: threading.Event, msg_queue: queue.Queue[tuple[bool, int, int]], main_config: EyeTrackConfig,):
self.main_config = main_config self.main_config = main_config
self.config = main_config.settings self.config = main_config.settings