mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
fis HSRAC, fix HSF radius sliders
This commit is contained in:
parent
056e21d6e2
commit
d5252124a4
@ -352,7 +352,7 @@ class CameraWidget:
|
||||
line_color="white",
|
||||
)
|
||||
if not np.isnan(eye_info.blink):
|
||||
graph.draw_line((-100,eye_info.blink * 100), (-100,100), color="#6f4ca1", width=10)
|
||||
graph.draw_line((-100,eye_info.blink * 200), (-100,100), color="#6f4ca1", width=10)
|
||||
else:
|
||||
graph.draw_line((-100, 0.0 * 200), (-100, 100), color="black", width=10)
|
||||
|
||||
|
||||
@ -296,7 +296,7 @@ class EyeProcessor:
|
||||
# todo: add process to initialise er_hsrac when resolution changes
|
||||
self.rawx, self.rawy, self.thresh, self.radius = self.er_hsf.run(self.current_image_gray)
|
||||
self.rawx, self.rawy, self.thresh = RANSAC3D(self, True)
|
||||
print(self.radius)
|
||||
#print(self.radius)
|
||||
#if self.prev_x is None:
|
||||
# self.prev_x = self.rawx
|
||||
# self.prev_y = self.rawy
|
||||
@ -399,7 +399,15 @@ 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)
|
||||
if self.eye_id in [EyeId.LEFT]:
|
||||
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius, self.settings.gui_HSF_radius_left)
|
||||
else:
|
||||
pass
|
||||
if self.eye_id in [EyeId.RIGHT]:
|
||||
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius,
|
||||
self.settings.gui_HSF_radius_right)
|
||||
else:
|
||||
pass
|
||||
algolist[self.settings.gui_HSFP] = self.HSFM
|
||||
else:
|
||||
if self.er_hsf is not None:
|
||||
@ -407,7 +415,17 @@ class EyeProcessor:
|
||||
|
||||
if self.settings.gui_HSRAC:
|
||||
if self.er_hsf is None:
|
||||
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius, self.settings.gui_HSF_radius)
|
||||
|
||||
if self.eye_id in [EyeId.LEFT]:
|
||||
|
||||
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius, self.settings.gui_HSF_radius_left)
|
||||
else:
|
||||
pass
|
||||
if self.eye_id in [EyeId.RIGHT]:
|
||||
self.er_hsf = External_Run_HSF(self.settings.gui_skip_autoradius,
|
||||
self.settings.gui_HSF_radius_right)
|
||||
else:
|
||||
pass
|
||||
algolist[self.settings.gui_HSRACP] = self.HSRACM
|
||||
else:
|
||||
if self.er_hsf is not None:
|
||||
|
||||
@ -35,7 +35,7 @@ SETTINGS_RADIO_NAME = "-SETTINGSRADIO-"
|
||||
ALGO_SETTINGS_RADIO_NAME = "-ALGOSETTINGSRADIO-"
|
||||
|
||||
page_url = "https://github.com/RedHawk989/EyeTrackVR/releases/latest"
|
||||
appversion = "EyeTrackApp 0.2.0 BETA 5"
|
||||
appversion = "EyeTrackApp 0.2.0 BETA 5.1"
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@ -229,7 +229,7 @@ class IntensityBasedOpeness:
|
||||
self.filterlist.pop()
|
||||
self.filterlist.append(intensity)
|
||||
|
||||
if intensity >= np.percenile(self.filterlist, 99): # filter abnormally high values
|
||||
if intensity >= np.percentile(self.filterlist, 99): # filter abnormally high values
|
||||
print('filter, assume blink')
|
||||
intensity = self.maxval
|
||||
|
||||
|
||||
@ -142,6 +142,23 @@ def fit_rotated_ellipse(data, P):
|
||||
|
||||
return (cx, cy, w, h, theta)
|
||||
|
||||
|
||||
|
||||
def get_center_noclamp(center_xy, radius):
|
||||
center_x, center_y = center_xy
|
||||
upper_x = center_x + radius
|
||||
lower_x = center_x - radius
|
||||
upper_y = center_y + radius
|
||||
lower_y = center_y - radius
|
||||
|
||||
ransac_upper_x = center_x + max(20, radius)
|
||||
ransac_lower_x = center_x - max(20, radius)
|
||||
ransac_upper_y = center_y + max(20, radius)
|
||||
ransac_lower_y = center_y - max(20, radius)
|
||||
ransac_xy_offset = (ransac_lower_x, ransac_lower_y)
|
||||
return center_x, center_y, upper_x, lower_x, upper_y, lower_y, ransac_lower_x, ransac_lower_y, ransac_upper_x, ransac_upper_y, ransac_xy_offset
|
||||
|
||||
|
||||
cct = 300
|
||||
ransac_lower_x = 100
|
||||
ransac_lower_y = 100
|
||||
@ -151,14 +168,13 @@ cy = 0
|
||||
|
||||
def RANSAC3D(self, hsrac_en):
|
||||
f = False
|
||||
ranf = False
|
||||
global cct, ransac_lower_y, ransac_lower_x, cx, cy
|
||||
|
||||
|
||||
if hsrac_en:
|
||||
ransac_upper_x = self.rawx + max(15, self.radius)
|
||||
ransac_lower_x = self.rawx - max(15, self.radius)
|
||||
ransac_upper_y = self.rawy + max(15, self.radius)
|
||||
ransac_lower_y = self.rawy - max(15, self.radius)
|
||||
center_x, center_y, upper_x, lower_x, upper_y, lower_y, ransac_lower_x, ransac_lower_y, ransac_upper_x, ransac_upper_y, ransac_xy_offset = get_center_noclamp(
|
||||
(self.rawx, self.rawy), self.radius)
|
||||
|
||||
frame = safe_crop(self.current_image_gray_clean, ransac_lower_x, ransac_lower_y, ransac_upper_x, ransac_upper_y, 1)
|
||||
|
||||
@ -230,16 +246,18 @@ def RANSAC3D(self, hsrac_en):
|
||||
pass
|
||||
|
||||
cx, cy, w, h, theta = ransac_data
|
||||
print(int(cx), int(cy))
|
||||
# print(cx, cy)
|
||||
#cxi, cyi, wi, hi = int(cx), int(cy), int(w), int(h)
|
||||
|
||||
cv2.drawContours(self.current_image_gray, contours, -1, (255, 0, 0), 1)
|
||||
cv2.circle(self.current_image_gray, (cx, cy), 2, (0, 0, 255), -1)
|
||||
#cv2.drawContours(self.current_image_gray, contours, -1, (255, 0, 0), 1)
|
||||
# cv2.circle(self.current_image_gray, (cx, cy), 2, (0, 0, 255), -1)
|
||||
# cx1, cy1, w1, h1, theta1 = fit_rotated_ellipse(maxcnt.reshape(-1, 2))
|
||||
cv2.ellipse(self.current_image_gray, (cx, cy), (w, h), theta * 180.0 / np.pi, 0.0, 360.0, (50, 250, 200), 1, )
|
||||
# cv2.ellipse(self.current_image_gray, (cx, cy), (w, h), theta * 180.0 / np.pi, 0.0, 360.0, (50, 250, 200), 1, )
|
||||
|
||||
#img = newImage2[y1:y2, x1:x2]
|
||||
except:
|
||||
ranf = True
|
||||
pass
|
||||
|
||||
self.current_image_gray = frame
|
||||
@ -288,16 +306,17 @@ def RANSAC3D(self, hsrac_en):
|
||||
|
||||
except:
|
||||
f = True
|
||||
# Draw our image and stack it for visual output
|
||||
if hsrac_en:
|
||||
csy = newFrame2.shape[0]
|
||||
csx = newFrame2.shape[1]
|
||||
|
||||
ransac_xy_offset = (ransac_lower_x, ransac_lower_y)
|
||||
# cx = clamp((cx - 20) + center_x, 0, csx)
|
||||
# cy = clamp((cy - 20) + center_y, 0, csy)
|
||||
cx = int(clamp(cx + ransac_xy_offset[0], 0, csx))
|
||||
cy = int(clamp(cy + ransac_xy_offset[1], 0, csy))
|
||||
if ranf:
|
||||
cx = self.rawx
|
||||
cy = self.rawy
|
||||
else:
|
||||
# print(int(cx), int(clamp(cx + ransac_lower_x, 0, csx)), ransac_lower_x, csx, "y", int(cy), int(clamp(cy + ransac_lower_y, 0, csy)), ransac_lower_y, csy)
|
||||
cx = int(clamp(cx + ransac_lower_x, 0, csx)) #dunno why this is being weird
|
||||
cy = int(clamp(cy + ransac_lower_y, 0, csy))
|
||||
|
||||
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user