mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
complete implimentation of per eye cirlcle crop in ransac
This commit is contained in:
parent
e554d8bf2c
commit
8d29d24127
@ -136,7 +136,6 @@ class EyeProcessor:
|
|||||||
self.er_hsf = None
|
self.er_hsf = None
|
||||||
self.er_hsrac = None
|
self.er_hsrac = None
|
||||||
self.er_daddy = None
|
self.er_daddy = None
|
||||||
|
|
||||||
self.ibo = IntensityBasedOpeness(eyeside=EyeLR.LEFT if self.eye_id is EyeId.LEFT else EyeLR.RIGHT if eye_id is EyeId.RIGHT else -1)
|
self.ibo = IntensityBasedOpeness(eyeside=EyeLR.LEFT if self.eye_id is EyeId.LEFT else EyeLR.RIGHT if eye_id is EyeId.RIGHT else -1)
|
||||||
self.roi_include_set = {"rotation_angle", "roi_window_x", "roi_window_y"}
|
self.roi_include_set = {"rotation_angle", "roi_window_x", "roi_window_y"}
|
||||||
|
|
||||||
@ -391,13 +390,6 @@ 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.
|
||||||
@ -407,7 +399,6 @@ class EyeProcessor:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If our ROI configuration has changed, reset our model and detector
|
# If our ROI configuration has changed, reset our model and detector
|
||||||
if (self.camera_model is None
|
if (self.camera_model is None
|
||||||
or self.detector_3d is None
|
or self.detector_3d is None
|
||||||
@ -445,32 +436,7 @@ class EyeProcessor:
|
|||||||
self.current_image, cv2.COLOR_BGR2GRAY
|
self.current_image, cv2.COLOR_BGR2GRAY
|
||||||
)
|
)
|
||||||
self.current_image_gray_clean = self.current_image_gray.copy() #copy this frame to have a clean image for blink algo
|
self.current_image_gray_clean = self.current_image_gray.copy() #copy this frame to have a clean image for blink algo
|
||||||
# print(self.settings.gui_RANSAC3D)
|
|
||||||
|
|
||||||
# BLINK(self)
|
|
||||||
|
|
||||||
# cx, cy, thresh = HSRAC(self)
|
|
||||||
# out_x, out_y = cal_osc(self, cx, cy)
|
|
||||||
# if cx == 0:
|
|
||||||
# self.output_images_and_update(thresh, EyeInfo(EyeInfoOrigin.HSRAC, out_x, out_y, 0, True)) #update app
|
|
||||||
# else:
|
|
||||||
# self.output_images_and_update(thresh, EyeInfo(EyeInfoOrigin.HSRAC, out_x, out_y, 0, self.blinkvalue))
|
|
||||||
|
|
||||||
|
|
||||||
# cx, cy, thresh = RANSAC3D(self)
|
|
||||||
# out_x, out_y = cal_osc(self, cx, cy)
|
|
||||||
# self.output_images_and_update(thresh, EyeInfo(EyeInfoOrigin.RANSAC, out_x, out_y, 0, False)) #update app
|
|
||||||
|
|
||||||
|
|
||||||
# cx, cy, larger_threshold = BLOB(self)
|
|
||||||
# out_x, out_y = cal_osc(self, cx, cy)
|
|
||||||
# self.output_images_and_update(larger_threshold, EyeInfo(EyeInfoOrigin.BLOB, out_x, out_y, 0, False)) #update app
|
|
||||||
|
|
||||||
#center_x, center_y, frame = HSF(self) #run algo
|
|
||||||
#out_x, out_y = cal_osc(self, center_x, center_y) #filter and calibrate
|
|
||||||
#self.output_images_and_update(frame, EyeInfo(EyeInfoOrigin.HSF, out_x, out_y, 0, False)) #update app
|
|
||||||
|
|
||||||
self.ALGOSELECT() #run our algos in priority order set in settings
|
self.ALGOSELECT() #run our algos in priority order set in settings
|
||||||
#self.BLOBM()
|
|
||||||
self.UPDATE()
|
self.UPDATE()
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,8 @@ Copyright (c) 2023 EyeTrackVR <3
|
|||||||
'''
|
'''
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from enums import EyeLR
|
||||||
|
|
||||||
|
|
||||||
def ellipse_model(data, y, f):
|
def ellipse_model(data, y, f):
|
||||||
"""
|
"""
|
||||||
@ -134,28 +136,15 @@ def fit_rotated_ellipse(data, P):
|
|||||||
return (cx, cy, w, h, theta)
|
return (cx, cy, w, h, theta)
|
||||||
|
|
||||||
|
|
||||||
def RANSAC3D(self):
|
def circle_crop(self):
|
||||||
f = False
|
|
||||||
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
|
||||||
thresh_add = 10
|
|
||||||
rng = np.random.default_rng()
|
|
||||||
|
|
||||||
# Convert the image to grayscale, and set up thresholding. Thresholds here are basically a
|
|
||||||
# low-pass filter that will set any pixel < the threshold value to 0. Thresholding is user
|
|
||||||
# configurable in this utility as we're dealing with variable lighting amounts/placement, as
|
|
||||||
# well as camera positioning and lensing. Therefore everyone's cutoff may be different.
|
|
||||||
#
|
|
||||||
# The goal of thresholding settings is to make sure we can ONLY see the pupil. This is why we
|
|
||||||
# crop the image earlier; it gives us less possible dark area to get confused about in the
|
|
||||||
# next step.
|
|
||||||
|
|
||||||
if self.config.gui_circular_crop == True:
|
|
||||||
if self.cct == 0:
|
if self.cct == 0:
|
||||||
try:
|
try:
|
||||||
ht, wd = self.current_image_gray.shape[:2]
|
ht, wd = self.current_image_gray.shape[:2]
|
||||||
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
||||||
self.xc = int(float(self.lkg_projected_sphere["center"][0]))
|
self.xc = int(float(self.lkg_projected_sphere["center"][0]))
|
||||||
self.yc = int(float(self.lkg_projected_sphere["center"][1]))
|
self.yc = int(float(self.lkg_projected_sphere["center"][1]))
|
||||||
|
if radius < 8: #minimum size TODO: make shure this size is enough
|
||||||
|
radius = 8
|
||||||
# draw filled circle in white on black background as mask
|
# draw filled circle in white on black background as mask
|
||||||
mask = np.zeros((ht, wd), dtype=np.uint8)
|
mask = np.zeros((ht, wd), dtype=np.uint8)
|
||||||
mask = cv2.circle(mask, (self.xc, self.yc), radius, 255, -1)
|
mask = cv2.circle(mask, (self.xc, self.yc), radius, 255, -1)
|
||||||
@ -171,9 +160,31 @@ def RANSAC3D(self):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.cct = self.cct - 1
|
self.cct = self.cct - 1
|
||||||
|
|
||||||
|
def RANSAC3D(self):
|
||||||
|
f = False
|
||||||
|
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
||||||
|
thresh_add = 10
|
||||||
|
rng = np.random.default_rng()
|
||||||
|
|
||||||
|
# Convert the image to grayscale, and set up thresholding. Thresholds here are basically a
|
||||||
|
# low-pass filter that will set any pixel < the threshold value to 0. Thresholding is user
|
||||||
|
# configurable in this utility as we're dealing with variable lighting amounts/placement, as
|
||||||
|
# well as camera positioning and lensing. Therefore everyone's cutoff may be different.
|
||||||
|
#
|
||||||
|
# The goal of thresholding settings is to make sure we can ONLY see the pupil. This is why we
|
||||||
|
# crop the image earlier; it gives us less possible dark area to get confused about in the
|
||||||
|
# next step.
|
||||||
|
|
||||||
|
if self.eye_id == EyeId.LEFT and self.config.gui_circular_crop_left == True: #TODO TEST function
|
||||||
|
circle_crop(self)
|
||||||
else:
|
else:
|
||||||
self.cct = 300
|
self.cct = 300
|
||||||
|
|
||||||
|
if self.eye_id == EyeId.RIGHT and self.config.gui_circular_crop_right == True:
|
||||||
|
circle_crop(self)
|
||||||
|
else:
|
||||||
|
self.cct = 300
|
||||||
|
|
||||||
# Crop first to reduce the amount of data to process.
|
# Crop first to reduce the amount of data to process.
|
||||||
newFrame2 = self.current_image_gray.copy()
|
newFrame2 = self.current_image_gray.copy()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user