fix: serious performance issue with numpy linalg.inv on linux

This commit is contained in:
DeltaNeverUsed 2025-05-25 23:04:53 +02:00 committed by GitHub
parent ab441f2ce0
commit 07eb11ebe3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -238,7 +238,7 @@ class EyeProcessor:
borderValue=(255, 255, 255),
)
inv_matrix = np.linalg.inv(np.vstack((matrix, [0, 0, 1])))[:-1]
inv_matrix = cv2.invertAffineTransform(matrix)
# calculate crop corner locations in original image space
corners = np.matmul([[0, 0, 1], [roi_w, 0, 1], [0, roi_h, 1], [roi_w, roi_h, 1]], np.transpose(inv_matrix))
fits_in_bounds = all(0 <= x <= img_w and 0 <= y <= img_h for (x, y) in corners)