fix: max recall ocr improve

This commit is contained in:
283375 2023-10-07 13:16:32 +08:00
parent 07df8e3b56
commit d52d545864
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
2 changed files with 4 additions and 4 deletions

View File

@ -146,9 +146,9 @@ class DeviceV2Ocr:
contours, _ = cv2.findContours( contours, _ = cv2.findContours(
roi_closed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE roi_closed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE
) )
rects = sorted( rects = [cv2.boundingRect(c) for c in contours]
[cv2.boundingRect(c) for c in contours], key=lambda r: r[0], reverse=True rects = [r for r in rects if r[2] > 5 and r[3] > 5]
) rects = sorted(rects, key=lambda r: r[0], reverse=True)
max_recall_roi = crop_xywh(roi, rects[0]) max_recall_roi = crop_xywh(roi, rects[0])
return ocr_digits_by_contour_knn(max_recall_roi, self.knn_model) return ocr_digits_by_contour_knn(max_recall_roi, self.knn_model)

View File

@ -56,7 +56,7 @@ BYD_MIN_HSV = np.array([170, 50, 50], np.uint8)
BYD_MAX_HSV = np.array([179, 210, 198], np.uint8) BYD_MAX_HSV = np.array([179, 210, 198], np.uint8)
MAX_RECALL_PURPLE_MIN_HSV = np.array([125, 0, 0], np.uint8) MAX_RECALL_PURPLE_MIN_HSV = np.array([125, 0, 0], np.uint8)
MAX_RECALL_PURPLE_MAX_HSV = np.array([130, 100, 150], np.uint8) MAX_RECALL_PURPLE_MAX_HSV = np.array([145, 100, 150], np.uint8)
def mask_gray(__img_bgr: Mat): def mask_gray(__img_bgr: Mat):