mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-04-18 21:10:17 +00:00
fix: previous refactor issues
This commit is contained in:
parent
c640754d87
commit
ea2b663e83
@ -49,7 +49,7 @@ BYD_MAX_HSV = np.array([179, 210, 198], np.uint8)
|
||||
|
||||
def mask_gray(__img_bgr: Mat):
|
||||
# bgr_value_equal_mask = all(__img_bgr[:, 1:] == __img_bgr[:, :-1], axis=1)
|
||||
bgr_value_equal_mask = max(__img_bgr, axis=2) - min(__img_bgr, axis=2) <= 5
|
||||
bgr_value_equal_mask = np.max(__img_bgr, axis=2) - np.min(__img_bgr, axis=2) <= 5
|
||||
img_bgr = __img_bgr.copy()
|
||||
img_bgr[~bgr_value_equal_mask] = np.array([0, 0, 0], __img_bgr.dtype)
|
||||
img_bgr = cv2.erode(img_bgr, cv2.getStructuringElement(cv2.MORPH_RECT, (2, 2)))
|
||||
|
@ -44,7 +44,7 @@ def preprocess_hog(digit_rois):
|
||||
|
||||
def ocr_digits_by_contour_samples(__roi_gray: Mat, size: Tuple[int, int]):
|
||||
roi = __roi_gray.copy()
|
||||
contours = cv2.findContours(roi, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
|
||||
contours, _ = cv2.findContours(roi, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
|
||||
rects = sorted([cv2.boundingRect(c) for c in contours], key=lambda r: r[0])
|
||||
digit_rois = [cv2.resize(crop_xywh(roi, rect), size) for rect in rects]
|
||||
return preprocess_hog(digit_rois)
|
||||
|
Loading…
x
Reference in New Issue
Block a user