Revert pixel search back to slower mean

- *NotBlack* functions reverted to slower np.mean, to fix edge cases with np.max
This commit is contained in:
Doc
2026-01-13 22:59:30 -05:00
parent 4c01b72b54
commit 98b2e3352b

View File

@@ -107,22 +107,22 @@ class DFWINDOW:
@staticmethod @staticmethod
def firstNotBlackX(img) -> int: def firstNotBlackX(img) -> int:
first_x = np.where(np.max(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=0) > 5)[0][0] first_x = np.where(np.mean(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=0) > 10)[0][0]
return int(first_x) return int(first_x)
@staticmethod @staticmethod
def lastNotBlackX(img) -> int: def lastNotBlackX(img) -> int:
first_x = np.where(np.max(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=0) > 5)[0][-1] first_x = np.where(np.mean(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=0) > 10)[0][-1]
return int(first_x) return int(first_x)
@staticmethod @staticmethod
def firstNotBlackY(img) -> int: def firstNotBlackY(img) -> int:
first_y = np.where(np.max(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=1) > 5)[0][0] first_y = np.where(np.mean(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=1) > 10)[0][0]
return int(first_y) return int(first_y)
@staticmethod @staticmethod
def lastNotBlackY(img) -> int: def lastNotBlackY(img) -> int:
first_y = np.where(np.max(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=1) > 5)[0][-1] first_y = np.where(np.mean(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), axis=1) > 10)[0][-1]
return int(first_y) return int(first_y)
bottom_to_ignore = 160 bottom_to_ignore = 160