Merge pull request #142 from DeltaNeverUsed/patch-2

fix: serious performance issue with numpy linalg.inv on linux
This commit is contained in:
Prohurtz 2025-06-26 19:50:33 -05:00 committed by GitHub
commit e2956e0a45
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)