mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
intensity dual eye & bug hunting
This commit is contained in:
parent
ba7ada67cc
commit
6e2f8b0847
@ -242,7 +242,7 @@ class EyeProcessor:
|
||||
pass
|
||||
|
||||
def BLINKM(self):
|
||||
self.blinkvalue = BLINK(self)
|
||||
self.eyeoffx = BLINK(self)
|
||||
|
||||
|
||||
def HSRACM(self):
|
||||
@ -256,43 +256,43 @@ class EyeProcessor:
|
||||
# if (cx - self.prev_x) <= 45 and (cy - self.prev_y) <= 45 :
|
||||
# self.prev_x = cx
|
||||
# self.prev_y = cy
|
||||
eyeopen = intense(cx, cy, uncropframe)
|
||||
self.eyeopen = intense(cx, cy, uncropframe)
|
||||
out_x, out_y = cal_osc(self, cx, cy)
|
||||
|
||||
if cx == 0:
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen)) #update app
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.eyeopen)) #update app
|
||||
else:
|
||||
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen))
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.eyeopen))
|
||||
# else:
|
||||
# print("EYE MOVED TOO FAST")
|
||||
# self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, 0, 0, 0, False))
|
||||
def HSFM(self):
|
||||
cx, cy, frame = External_Run_HSF.HSFS(self)
|
||||
eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
self.eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
out_x, out_y = cal_osc(self, cx, cy)
|
||||
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, self.eyeopen)) #update app
|
||||
else:
|
||||
self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, eyeopen))
|
||||
self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, self.eyeopen))
|
||||
|
||||
def RANSAC3DM(self):
|
||||
cx, cy, thresh = RANSAC3D(self)
|
||||
eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
self.eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
out_x, out_y = cal_osc(self, cx, cy)
|
||||
if cx == 0:
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.RANSAC, out_x, out_y, 0, eyeopen)) #update app
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.RANSAC, out_x, out_y, 0, self.eyeopen)) #update app
|
||||
else:
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.RANSAC, out_x, out_y, 0, eyeopen))
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.RANSAC, out_x, out_y, 0, self.eyeopen))
|
||||
|
||||
def BLOBM(self):
|
||||
cx, cy, thresh = BLOB(self)
|
||||
eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
self.eyeopen = intense(cx, cy, self.current_image_gray)
|
||||
out_x, out_y = cal_osc(self, cx, cy)
|
||||
if cx == 0:
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen)) #update app
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.eyeopen)) #update app
|
||||
else:
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, eyeopen))
|
||||
self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, out_x, out_y, 0, self.eyeopen))
|
||||
|
||||
|
||||
|
||||
|
||||
@ -983,7 +983,7 @@ class HSRAC_cls(object):
|
||||
## default_radius = 14
|
||||
|
||||
frame = self.current_image_gray
|
||||
frame = cv2.copyMakeBorder(frame, 21, 21, 21, 21, cv2.BORDER_CONSTANT, value=[255, 255, 255]) # add a border to prevent overcropping the image.
|
||||
# frame = cv2.copyMakeBorder(frame, 21, 21, 21, 21, cv2.BORDER_CONSTANT, value=[255, 255, 255]) # add a border to prevent overcropping the image.
|
||||
|
||||
if self.now_modeo == self.cv_modeo[1]:
|
||||
# adjustment of radius
|
||||
@ -1091,17 +1091,17 @@ class HSRAC_cls(object):
|
||||
# print('Pixel position:', center_xy)
|
||||
|
||||
|
||||
if imshow_enable:
|
||||
if self.now_modeo != self.cv_modeo[0] and self.now_modeo != self.cv_modeo[1]:
|
||||
if 0 in cropped_image.shape:
|
||||
# if imshow_enable:
|
||||
# if self.now_modeo != self.cv_modeo[0] and self.now_modeo != self.cv_modeo[1]:
|
||||
# if 0 in cropped_image.shape:
|
||||
# If shape contains 0, it is not detected well.
|
||||
pass
|
||||
else:
|
||||
# pass
|
||||
# else:
|
||||
|
||||
cv2.imshow("crop", cropped_image)
|
||||
cv2.imshow("frame", frame)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
pass
|
||||
# cv2.imshow("crop", cropped_image)
|
||||
# cv2.imshow("frame", frame)
|
||||
# if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
# pass
|
||||
|
||||
if self.now_modeo == self.cv_modeo[0]:
|
||||
# Moving from first_frame to the next mode
|
||||
@ -1129,7 +1129,6 @@ class HSRAC_cls(object):
|
||||
lower_y = center_y - 20
|
||||
|
||||
# Crop the image using the calculated bounds
|
||||
|
||||
frame_gray = frame_gray[lower_y:upper_y, lower_x:upper_x]
|
||||
frame = frame_gray
|
||||
# this will need to be adjusted everytime hardware is changed (brightness of IR, Camera postion, etc)m
|
||||
@ -1176,7 +1175,7 @@ class HSRAC_cls(object):
|
||||
|
||||
crop_start_time = timeit.default_timer()
|
||||
cx, cy, w, h, theta = ransac_data
|
||||
print(cx, cy)
|
||||
# print(cx, cy)
|
||||
if w >= 2.1 * h: #new blink detection algo lmao this works pretty good actually
|
||||
print("RAN BLINK")
|
||||
#return center_x, center_y, frame, frame, True
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import time
|
||||
|
||||
from enum import IntEnum
|
||||
#higher intensity means more closed/ more white/less pupil
|
||||
|
||||
#Hm I need an acronym for this, any ideas?
|
||||
#IBO Intensity Based Openess
|
||||
|
||||
class EyeId(IntEnum):
|
||||
RIGHT = 0
|
||||
LEFT = 1
|
||||
BOTH = 2
|
||||
SETTINGS = 3
|
||||
|
||||
# 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.
|
||||
@ -13,8 +19,14 @@ import time
|
||||
# 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.
|
||||
|
||||
fname = "IBO.csv" #TODO Expose as setting
|
||||
|
||||
if EyeId.RIGHT:
|
||||
fname = "IBO_RIGHT.csv"
|
||||
if EyeId.LEFT:
|
||||
fname = "IBO_LEFT.csv"
|
||||
|
||||
lct = time.time()
|
||||
|
||||
try:
|
||||
data = pd.read_csv(fname, sep=",")
|
||||
except:
|
||||
@ -27,15 +39,18 @@ except:
|
||||
|
||||
def intense(x, y, frame):
|
||||
global lct
|
||||
|
||||
upper_x = int(x) + 25 #TODO make this a setting
|
||||
lower_x = int(x) - 25
|
||||
upper_y = int(y) + 25
|
||||
lower_y = int(y) - 25
|
||||
frame = frame[lower_y:upper_y, lower_x:upper_x]
|
||||
|
||||
print(x, y, int(x), int(y), upper_x, upper_y, lower_x, lower_y)
|
||||
try:
|
||||
xy = int(str(int(x)) + str(int(y)) + str(int(x)+int(y)))
|
||||
intensity = np.sum(frame)
|
||||
intensity = np.sum(frame) #why is this outputting 0s?
|
||||
# print(intensity, upper_x, upper_y, lower_x, lower_y)
|
||||
except:
|
||||
return 0.0 #TODO find how on earth a hyphen gets thrown into this
|
||||
|
||||
@ -78,9 +93,10 @@ def intense(x, y, frame):
|
||||
#eyeopen = (intensity - minp) / (maxp - minp)
|
||||
eyeopen = (intensity - maxp) / (minp - maxp)
|
||||
eyeopen = 1 - eyeopen
|
||||
eyeopen = eyeopen - 0.2
|
||||
# print(intensity, maxp, minp, x, y)
|
||||
print(f"EYEOPEN: {eyeopen}")
|
||||
|
||||
# print(f"EYEOPEN: {eyeopen}")
|
||||
# print(int(x), int(y), eyeopen, maxp, minp)
|
||||
|
||||
except:
|
||||
print('[INFO] Something went wrong, assuming blink.')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user