auto create file for IBO

This commit is contained in:
Prohurtz 2023-01-25 16:48:43 -06:00
parent a67535ce01
commit 0622820491
4 changed files with 27 additions and 14 deletions

1
EyeTrackApp/IBO.csv Normal file
View File

@ -0,0 +1 @@

View File

@ -248,28 +248,28 @@ class EyeProcessor:
def HSRACM(self): def HSRACM(self):
cx, cy, thresh, gray_frame = External_Run_HSRACS.HSRACS(self) cx, cy, thresh, gray_frame = External_Run_HSRACS.HSRACS(self)
self.current_image_gray = gray_frame self.current_image_gray = gray_frame
# thresh = gray_frame
if self.prev_x == None: if self.prev_x == None:
self.prev_x = cx self.prev_x = cx
self.prev_y = cy self.prev_y = cy
#print(self.prev_x, self.prev_y, cx, cy) #print(self.prev_x, self.prev_y, cx, cy)
# #filter values with too much movement
# 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
print(self.blinkvalue) eyeopen = intense(cx, cy, self.current_image_gray)
out_x, out_y = cal_osc(self, cx, cy) out_x, out_y = cal_osc(self, cx, cy)
if cx == 0: if cx == 0:
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.blinkvalue)) #update app self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen)) #update app
else: else:
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.blinkvalue)) self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen))
# else: # else:
# print("EYE MOVED TOO FAST") # print("EYE MOVED TOO FAST")
# self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, 0, 0, 0, False)) # self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, 0, 0, 0, False))
def HSFM(self): def HSFM(self):
cx, cy, frame = External_Run_HSF.HSFS(self) cx, cy, frame = External_Run_HSF.HSFS(self)
eyeopen = intense(cx, cy, self.current_image_gray) #not sure if i want this run on every algo or on the system.. eyeopen = intense(cx, cy, self.current_image_gray)
out_x, out_y = cal_osc(self, cx, cy) out_x, out_y = cal_osc(self, cx, cy)
if cx == 0: if cx == 0:
self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, eyeopen)) #update app self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, eyeopen)) #update app

View File

@ -10,16 +10,27 @@ OSCport=9000 #VR Chat OSC port
client = udp_client.SimpleUDPClient(OSCip, OSCport) client = udp_client.SimpleUDPClient(OSCip, OSCport)
#higher intensity means more closed/ more white/less pupil #higher intensity means more closed/ more white/less pupil
# HOW THIS WORKS: #Hm I need an acronym for this, any ideas?
# Here is my idea: #IBO Intensity Based Openess
# HOW THIS WORKS:
# we get the intensity of pupil area from HSF crop, When the eyelid starts to close, the pupil starts being obstructed by skin which is generally lighter than the pupil. # we get the intensity of pupil area from HSF crop, When the eyelid starts to close, the pupil starts being obstructed by skin which is generally lighter than the pupil.
# This causes the intensity to increase. We save all of the darkest intensities of each pupil position to calculate for pupil movement. # This causes the intensity to increase. We save all of the darkest intensities of each pupil position to calculate for pupil movement.
# ex. when you look up there is less pupil visible, which results in an uncalculated change in intensity even though the eyelid has not moved in a meaningful way. # ex. when you look up there is less pupil visible, which results in an uncalculated change in intensity even though the eyelid has not moved in a meaningful way.
# We compare the darkest intensity of that area, to the lightest (global) intensity to find the appropriate openness state via a float. # We compare the darkest intensity of that area, to the lightest (global) intensity to find the appropriate openness state via a float.
fname = "test_list.txt"
data = pd.read_csv(fname, sep=",")
#TODO we need more pixel points for smooth operation, lets get this setup in hsrac and add a .25 or .33 range? fname = "IBO.csv" #TODO Expose as setting
try:
data = pd.read_csv(fname, sep=",")
except:
cf = open(fname, "w")
cf.write("xy,intensity")
cf.close()
data = pd.read_csv(fname, sep=",")
#TODO we need more pixel points for smooth operation, lets get this setup in hsrac
def intense(x, y, frame): def intense(x, y, frame):
upper_x = x + 25 upper_x = x + 25
@ -77,7 +88,7 @@ def intense(x, y, frame):
print(intensity, maxp, minp, x, y) print(intensity, maxp, minp, x, y)
# eyeopen = max(0.0, min(1.0, eyeopen)) # eyeopen = max(0.0, min(1.0, eyeopen))
# print(f"EYEOPEN: {eyeopen}") # print(f"EYEOPEN: {eyeopen}")
client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(eyeopen)) # open r client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(eyeopen)) # open r
client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(eyeopen)) client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(eyeopen))
except: except:
print('[INFO] Something went wrong, assuming blink.') print('[INFO] Something went wrong, assuming blink.')

View File

@ -45,7 +45,8 @@ class VRChatOSC:
except: except:
continue continue
#eye_info.blink #eye_info.blink
if not eye_info.blink: print(eye_info.blink)
if eye_info.blink > 0.1: #if eye is not "closed" this will need tuning
if self.config.tracker_single_eye == 1 or self.config.tracker_single_eye == 2: if self.config.tracker_single_eye == 1 or self.config.tracker_single_eye == 2:
self.client.send_message("/avatar/parameters/LeftEyeX", eye_info.x) # only one eye is detected or there is an error. Send mirrored data to both eyes. self.client.send_message("/avatar/parameters/LeftEyeX", eye_info.x) # only one eye is detected or there is an error. Send mirrored data to both eyes.
self.client.send_message("/avatar/parameters/RightEyeX", eye_info.x) self.client.send_message("/avatar/parameters/RightEyeX", eye_info.x)