mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
fix: fix several bugs that caused crashes
This commit is contained in:
parent
cfe7c73c44
commit
a8cf676730
@ -710,8 +710,10 @@ def fine_detection(img_gray, pupil_rect_coarse):
|
|||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return pupil_rect_fine, center_fitting
|
try:
|
||||||
|
return pupil_rect_fine, center_fitting
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def detect_edges(img_pupil_blur):
|
def detect_edges(img_pupil_blur):
|
||||||
tau1 = 1 - 20.0 / img_pupil_blur.shape[1]
|
tau1 = 1 - 20.0 / img_pupil_blur.shape[1]
|
||||||
@ -965,6 +967,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
|
|
||||||
def External_Run_AHSF(frame_gray):
|
def External_Run_AHSF(frame_gray):
|
||||||
|
|
||||||
average_color = np.mean(frame_gray)
|
average_color = np.mean(frame_gray)
|
||||||
|
|
||||||
# Create a new image of the desired size (square) with the average color
|
# Create a new image of the desired size (square) with the average color
|
||||||
@ -978,9 +981,9 @@ def External_Run_AHSF(frame_gray):
|
|||||||
right_padding = new_image_size - frame_gray.shape[1] - left_padding
|
right_padding = new_image_size - frame_gray.shape[1] - left_padding
|
||||||
|
|
||||||
# Add padding to the image
|
# Add padding to the image
|
||||||
pframe_gray = cv2.copyMakeBorder(frame_gray, top_padding, bottom_padding, left_padding, right_padding,
|
frame_gray = cv2.copyMakeBorder(frame_gray, top_padding, bottom_padding, left_padding, right_padding,
|
||||||
cv2.BORDER_CONSTANT, value=average_color)
|
cv2.BORDER_CONSTANT, value=average_color)
|
||||||
|
frame_clear_resize = frame_gray.copy()
|
||||||
|
|
||||||
# while True:
|
# while True:
|
||||||
# if not cap.isOpened():
|
# if not cap.isOpened():
|
||||||
@ -995,10 +998,12 @@ def External_Run_AHSF(frame_gray):
|
|||||||
|
|
||||||
# frame_gray = cv2.resize(frame_gray, (100, 100))
|
# frame_gray = cv2.resize(frame_gray, (100, 100))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wmax = min(
|
wmax = min(
|
||||||
(frame_gray.shape[1] * 0.3), 180
|
(frame_gray.shape[1] * 0.3), 240
|
||||||
) # likes to crash, might need more tuning still
|
) # likes to crash, might need more tuning still
|
||||||
wmin = min((frame_gray.shape[1] * 0.1), 180)
|
wmin = min((frame_gray.shape[1] * 0.1), 240)
|
||||||
params = {
|
params = {
|
||||||
"ratio_downsample": 0.3,
|
"ratio_downsample": 0.3,
|
||||||
"use_init_rect": False,
|
"use_init_rect": False,
|
||||||
@ -1025,6 +1030,8 @@ def External_Run_AHSF(frame_gray):
|
|||||||
# print(ellipse_rect)
|
# print(ellipse_rect)
|
||||||
# Pupil_rect, Outer_rect, max_response, mu_inner, mu_outer = coarse_detection(frame_gray, params)
|
# Pupil_rect, Outer_rect, max_response, mu_inner, mu_outer = coarse_detection(frame_gray, params)
|
||||||
image_brg = frame_gray # cv2.cvtColor(frame_gray, cv2.COLOR_GRAY2BGR)
|
image_brg = frame_gray # cv2.cvtColor(frame_gray, cv2.COLOR_GRAY2BGR)
|
||||||
|
|
||||||
|
|
||||||
# show
|
# show
|
||||||
# cv2.rectangle(
|
# cv2.rectangle(
|
||||||
# image_brg,
|
# image_brg,
|
||||||
@ -1037,7 +1044,7 @@ def External_Run_AHSF(frame_gray):
|
|||||||
# 2,
|
# 2,
|
||||||
# )
|
# )
|
||||||
cv2.rectangle(
|
cv2.rectangle(
|
||||||
image_brg,
|
frame_gray,
|
||||||
(outer_rect_coarse[0], outer_rect_coarse[1]),
|
(outer_rect_coarse[0], outer_rect_coarse[1]),
|
||||||
(
|
(
|
||||||
outer_rect_coarse[0] + outer_rect_coarse[2],
|
outer_rect_coarse[0] + outer_rect_coarse[2],
|
||||||
@ -1055,7 +1062,7 @@ def External_Run_AHSF(frame_gray):
|
|||||||
minor_diameter = min(width, height)
|
minor_diameter = min(width, height)
|
||||||
average_diameter = (major_diameter + minor_diameter) / 2
|
average_diameter = (major_diameter + minor_diameter) / 2
|
||||||
# print(x_center, y_center)
|
# print(x_center, y_center)
|
||||||
return frame_gray, x_center, y_center, average_diameter
|
return frame_gray, frame_clear_resize, x_center, y_center, average_diameter
|
||||||
|
|
||||||
# return frame_gray, 0.0, 0.0, 0.0
|
# return frame_gray, 0.0, 0.0, 0.0
|
||||||
# if imshow_enable:
|
# if imshow_enable:
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 425 B |
@ -200,7 +200,7 @@ class EyeProcessor:
|
|||||||
"\033[91m[ERROR] Size of frames to display are of unequal sizes.\033[0m"
|
"\033[91m[ERROR] Size of frames to display are of unequal sizes.\033[0m"
|
||||||
)
|
)
|
||||||
|
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
def capture_crop_rotate_image(self):
|
def capture_crop_rotate_image(self):
|
||||||
# Get our current frame
|
# Get our current frame
|
||||||
@ -394,10 +394,12 @@ class EyeProcessor:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
self.hasrac_en = True
|
self.hasrac_en = True
|
||||||
self.current_image, self.rawx, self.rawy, self.radius = External_Run_AHSF(
|
self.current_image_gray, resize_img, self.rawx, self.rawy, self.radius = External_Run_AHSF(
|
||||||
self.current_image_gray
|
self.current_image_gray
|
||||||
)
|
)
|
||||||
self.thresh = self.current_image_gray
|
self.current_image_gray_clean = resize_img
|
||||||
|
|
||||||
|
self.thresh = resize_img
|
||||||
(
|
(
|
||||||
self.rawx,
|
self.rawx,
|
||||||
self.rawy,
|
self.rawy,
|
||||||
@ -526,7 +528,7 @@ class EyeProcessor:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
self.current_image, self.rawx, self.rawy, self.radius = External_Run_AHSF(
|
self.current_image_gray, resize_img, self.rawx, self.rawy, self.radius = External_Run_AHSF(
|
||||||
self.current_image_gray
|
self.current_image_gray
|
||||||
)
|
)
|
||||||
self.thresh = self.current_image_gray
|
self.thresh = self.current_image_gray
|
||||||
|
|||||||
@ -267,6 +267,7 @@ def RANSAC3D(self, hsrac_en):
|
|||||||
# Crop first to reduce the amount of data to process.
|
# Crop first to reduce the amount of data to process.
|
||||||
# frame = frame[0:len(frame) - 5, :]
|
# frame = frame[0:len(frame) - 5, :]
|
||||||
# To reduce the processing data, blur.
|
# To reduce the processing data, blur.
|
||||||
|
|
||||||
frame_gray = cv2.GaussianBlur(frame, (5, 5), 0)
|
frame_gray = cv2.GaussianBlur(frame, (5, 5), 0)
|
||||||
|
|
||||||
# this will need to be adjusted everytime hardware is changed (brightness of IR, Camera postion, etc)m
|
# this will need to be adjusted everytime hardware is changed (brightness of IR, Camera postion, etc)m
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user