diff --git a/EyeTrackApp/blob.py b/EyeTrackApp/blob.py index 01bf125..5a01a2c 100644 --- a/EyeTrackApp/blob.py +++ b/EyeTrackApp/blob.py @@ -36,47 +36,10 @@ class EyeId(IntEnum): BOTH = 2 SETTINGS = 3 -def circle_crop(self): - global cct - print(cct) - if cct == 0: - try: - ht, wd = self.current_image_gray.shape[:2] - radius = int(float(self.lkg_projected_sphere["axes"][0])) - self.xc = int(float(self.lkg_projected_sphere["center"][0])) - self.yc = int(float(self.lkg_projected_sphere["center"][1])) - if radius < 10: #minimum size - radius = 10 - # draw filled circle in white on black background as mask - mask = np.zeros((ht, wd), dtype=np.uint8) - mask = cv2.circle(mask, (self.xc, self.yc), radius, 255, -1) - # create white colored background - color = np.full_like(self.current_image_gray, (255)) - # apply mask to image - masked_img = cv2.bitwise_and(self.current_image_gray, self.current_image_gray, mask=mask) - # apply inverse mask to colored image - masked_color = cv2.bitwise_and(color, color, mask=255 - mask) - # combine the two masked images - self.current_image_gray = cv2.add(masked_img, masked_color) - return self.current_image_gray - except: - return self.current_image_gray - pass - else: - cct = cct - 1 - return self.current_image_gray + def BLOB(self): global cct # define circle - if self.eye_id in [EyeId.LEFT] and self.settings.gui_circular_crop_left: - self.current_image_gray = circle_crop(self) - else: - pass - - if self.eye_id in [EyeId.RIGHT] and self.settings.gui_circular_crop_right: - self.current_image_gray = circle_crop(self) - else: - pass _, larger_threshold = cv2.threshold(self.current_image_gray, int(self.settings.gui_threshold), 255, cv2.THRESH_BINARY) @@ -114,10 +77,10 @@ def BLOB(self): #out_x, out_y = cal_osc(self, cx, cy) #filter and calibrate values - print("S:KLJGHLDKIJGHLKS") + self.failed = 0 return cx, cy, larger_threshold - print("S:KLJGHLDKIJGHLKS") + self.failed = self.failed + 1 return 0, 0, larger_threshold \ No newline at end of file diff --git a/EyeTrackApp/eye_processor.py b/EyeTrackApp/eye_processor.py index ae8b761..8b1090c 100644 --- a/EyeTrackApp/eye_processor.py +++ b/EyeTrackApp/eye_processor.py @@ -334,8 +334,14 @@ class EyeProcessor: self.current_algorithm = EyeInfoOrigin.RANSAC def BLOBM(self): - - print("LSKDGFHL") + if self.eye_id in [EyeId.LEFT] and self.settings.gui_circular_crop_left: + self.current_image_gray, self.cct = circle_crop(self.current_image_gray, self.xc, self.yc, self.cc_radius, self.cct) + else: + pass + if self.eye_id in [EyeId.RIGHT] and self.settings.gui_circular_crop_right: + self.current_image_gray, self.cct = circle_crop(self.current_image_gray, self.xc, self.yc, self.cc_radius, self.cct) + else: + pass self.rawx, self.rawy, self.thresh = BLOB(self) self.out_x, self.out_y = cal.cal_osc(self, self.rawx, self.rawy) @@ -362,6 +368,8 @@ class EyeProcessor: if self.failed == 3 and self.fourthalgo != None: self.fourthalgo() + else: + self.failed = self.failed + 1 if self.failed == 4 and self.fithalgo != None: self.fithalgo() diff --git a/EyeTrackApp/eyetrackapp.py b/EyeTrackApp/eyetrackapp.py index 6f2bc0b..6da2bca 100644 --- a/EyeTrackApp/eyetrackapp.py +++ b/EyeTrackApp/eyetrackapp.py @@ -263,7 +263,6 @@ def main(): window[ALGO_SETTINGS_NAME].update(visible=False) config.eye_display_id = EyeId.SETTINGS config.save() - print("EE") elif values[ALGO_SETTINGS_RADIO_NAME] and config.eye_display_id != EyeId.ALGOSETTINGS: @@ -277,7 +276,6 @@ def main(): window[ALGO_SETTINGS_NAME].update(visible=True) config.eye_display_id = EyeId.ALGOSETTINGS config.save() - print("Easljghk") # Otherwise, render all for eye in eyes: diff --git a/EyeTrackApp/intensity_based_openness.py b/EyeTrackApp/intensity_based_openness.py index ed47f70..58af5a5 100644 --- a/EyeTrackApp/intensity_based_openness.py +++ b/EyeTrackApp/intensity_based_openness.py @@ -228,7 +228,7 @@ class IntensityBasedOpeness: else: self.filterlist.pop() self.filterlist.append(intensity) - print(len(str(intensity))) + if len(str(intensity)) >= 8: #filter abnormally high values print('filter, assume blink') intensity = self.maxval