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:
@@ -107,22 +107,22 @@ class DFWINDOW:
|
||||
|
||||
@staticmethod
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
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)
|
||||
|
||||
bottom_to_ignore = 160
|
||||
|
||||
Reference in New Issue
Block a user