add HSRAC visualizations.

(something might be wrong with IBO)
This commit is contained in:
Prohurtz 2023-04-12 21:04:38 -05:00
parent 87c2f1f7eb
commit d0fcfe7f9a
3 changed files with 13 additions and 13 deletions

View File

@ -208,7 +208,6 @@ class EyeProcessor:
self.previous_image = self.current_image
self.previous_rotation = self.config.rotation_angle
except: # If this fails it likely means that the images are not the same size for some reason.
print(self.current_image_gray.shape, threshold_image.shape)
print('\033[91m[ERROR] Size of frames to display are of unequal sizes.\033[0m')
pass

View File

@ -20,7 +20,7 @@ from utils.misc_utils import clamp
thresh_add = 10
imshow_enable = False
imshow_enable = True
calc_print_enable = False
save_video = False
skip_autoradius = False
@ -424,7 +424,7 @@ class HSRAC_cls(object):
# If empty, go to next loop
y, x = ori_frame.shape
th_frame = cv2.resize(th_frame, (x, y))
return int(center_x), int(center_y), th_frame, frame, blink_bd
return int(center_x), int(center_y), th_frame, ori_frame, blink_bd
cnt_ind = None
max_area = -1
for i, cnt in enumerate(contours):
@ -463,7 +463,7 @@ class HSRAC_cls(object):
if imshow_enable:#imsave_flg:
cv2.circle(ori_frame, (int(center_x), int(center_y)), 3, (128, 0, 0), -1)
cv2.drawContours(ori_frame, contours, -1, (255, 0, 0), 1)
#cv2.drawContours(ori_frame, contours, -1, (255, 0, 0), 1)
cv2.circle(ori_frame, (int(cx), int(cy)), 2, (255, 0, 0), -1)
# cx1, cy1, w1, h1, theta1 = fit_rotated_ellipse(maxcnt.reshape(-1, 2))
cv2.ellipse(
@ -477,11 +477,11 @@ class HSRAC_cls(object):
1,
)
# cv2.imshow("crop", cropped_image)
# cv2.imshow("frame", frame)
if imshow_enable:
cv2.imshow("ori_frame", ori_frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
pass
# # cv2.imshow("frame", frame)
# if imshow_enable:
# cv2.imshow("ori_frame", ori_frame)
# if cv2.waitKey(1) & 0xFF == ord("q"):
# pass
# cv_end_time = timeit.default_timer()
# self.timedict["ransac"].append(cv_end_time - ransac_start_time)

View File

@ -221,11 +221,11 @@ class IntensityBasedOpeness:
else:
maxp = self.data[int_y, int_x]
minp = self.maxval
diffp = minp - maxp if (minp - maxp) != 0 else 1
diffp = minp - maxp
eyeopen = (intensity - maxp) / diffp
eyeopen = 1 - eyeopen
# eyeopen = eyeopen - 0.2
# print(intensity, maxp, minp, x, y)
print(eyeopen, intensity, maxp, minp, x, y)
# print(f"EYEOPEN: {eyeopen}")
# print(int(x), int(y), eyeopen, maxp, minp)
# print(self.data[0, -1])
@ -233,6 +233,7 @@ class IntensityBasedOpeness:
if changed and ((time.time() - self.lct) > 5): # save every 5 seconds if something changed to save disk usage
self.save()
self.lct = time.time()
filter_eyeopen = (eyeopen + self.prev_val) / 2
# print(self.prev_val, eyeopen, intensity, self.maxval)
# filter_eyeopen = (eyeopen + self.prev_val) / 2
self.prev_val = eyeopen
return filter_eyeopen
return eyeopen#filter_eyeopen