fix rotation edge bug?

revert HSRAC crop output to normal szie
This commit is contained in:
Prohurtz 2023-04-12 17:29:20 -05:00
parent e3a932fb5d
commit bbd8b96978
3 changed files with 29 additions and 17 deletions

View File

@ -208,6 +208,7 @@ 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
@ -242,12 +243,15 @@ class EyeProcessor:
rotation_matrix = cv2.getRotationMatrix2D(
img_center, self.config.rotation_angle, 1
)
avg_color_per_row = np.average(self.current_image, axis=0)
avg_color = np.average(avg_color_per_row, axis=0)
ar, ag, ab = avg_color
self.current_image = cv2.warpAffine(
self.current_image,
rotation_matrix,
(cols, rows),
borderMode=cv2.BORDER_CONSTANT,
borderValue=(64, 64, 64),#(255, 255, 255),
borderValue=(ar + 10, ag + 10, ab + 10),#(255, 255, 255),
)
return True
except:

View File

@ -31,7 +31,7 @@ SETTINGS_RADIO_NAME = "-SETTINGSRADIO-"
page_url = "https://github.com/RedHawk989/EyeTrackVR/releases/latest"
appversion = "EyeTrackApp 0.2.0 BETA 2"
appversion = "EyeTrackApp 0.2.0 BETA 3"
def main():

View File

@ -243,8 +243,8 @@ class HSRAC_cls(object):
def single_run(self):
# Temporary implementation to run
if imshow_enable:
ori_frame = self.current_image_gray.copy() # debug code
# if imshow_enable:
ori_frame = self.current_image_gray.copy() # debug code
blink_bd = False
if self.now_modeo == self.cv_modeo[1]:
@ -422,6 +422,8 @@ class HSRAC_cls(object):
if not contours:
# 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
cnt_ind = None
max_area = -1
@ -439,7 +441,9 @@ class HSRAC_cls(object):
# ransac_data is None==maxcnt.shape[0]<sample_num
# go to next loop
# pass
return int(center_x), int(center_y), th_frame, frame, blink_bd
y, x = ori_frame.shape
th_frame = cv2.resize(th_frame, (x, y))
return int(center_x), int(center_y), th_frame, ori_frame, blink_bd
# crop_start_time = timeit.default_timer()
cx, cy, w, h, theta = ransac_data
@ -462,16 +466,16 @@ class HSRAC_cls(object):
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(
# ori_frame,
# (cx, cy),
# (int(w), int(h)),
# theta * 180.0 / np.pi,
# 0.0,
# 360.0,
# (50, 250, 200),
# 1,
# )
cv2.ellipse(
ori_frame,
(cx, cy),
(int(w), int(h)),
theta * 180.0 / np.pi,
0.0,
360.0,
(50, 250, 200),
1,
)
# cv2.imshow("crop", cropped_image)
# cv2.imshow("frame", frame)
if imshow_enable:
@ -484,9 +488,13 @@ class HSRAC_cls(object):
# self.timedict["total_cv"].append(cv_end_time - cv_start_time)
try:
return int(cx), int(cy), th_frame, frame, blink_bd
y, x = ori_frame.shape
th_frame = cv2.resize(th_frame, (x, y))
return int(cx), int(cy), th_frame, ori_frame, blink_bd
except:
return int(center_x), int(center_y), th_frame, frame, blink_bd
y, x = ori_frame.shape
th_frame = cv2.resize(th_frame, (x, y))
return int(center_x), int(center_y), th_frame, ori_frame, blink_bd