From 3e7a1083e26a4318500fa46a426b81af6cfa21ea Mon Sep 17 00:00:00 2001 From: PallasNeko <124042774+PallasNeko@users.noreply.github.com> Date: Fri, 17 Mar 2023 16:08:29 +0900 Subject: [PATCH] Temporary symptomatic fix --- EyeTrackApp/hsrac.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/EyeTrackApp/hsrac.py b/EyeTrackApp/hsrac.py index 1a1dcdc..378ecad 100644 --- a/EyeTrackApp/hsrac.py +++ b/EyeTrackApp/hsrac.py @@ -152,8 +152,12 @@ def fit_rotated_ellipse(data, P): cu = c * cy * cy + cx * (a * cx + b * cy) - P[4] # here: https://stackoverflow.com/questions/327002/which-is-faster-in-python-x-5-or-math-sqrtx # and : https://gist.github.com/zed/783011 - w = math.sqrt(cu / (a * tc2 + b_tcs + c * ts2)) - h = math.sqrt(cu / (a * ts2 - b_tcs + c * tc2)) + try: + # For some reason, a negative value may cause an error. + w = math.sqrt(cu / (a * tc2 + b_tcs + c * ts2)) + h = math.sqrt(cu / (a * ts2 - b_tcs + c * tc2)) + except ValueError: + return None error_sum = data # sum(data) # print("fitting error = %.3f" % (error_sum))