def find_possible_chars_in_scene(img_thresh) -> [PossibleChar]: list_of_possible_chars: [PossibleChar] = [] int_count_of_possible_chars: int = 0 img_thresh_copy = img_thresh.copy() contours, npa_hierarchy = cv2.findContours(img_thresh_copy, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) height, width = img_thresh.shape img_contours = np.zeros((height, width, 3), np.uint8) for i in range(0, len(contours)): if not SUPER_SPEED_MODE: cv2.drawContours(img_contours, contours, i, SCALAR_WHITE, 3) possible_char = PossibleChar.PossibleChar(contours[i]) if DetectChars.check_if_possible_char(possible_char): int_count_of_possible_chars = int_count_of_possible_chars + 1 list_of_possible_chars.append(possible_char) if NO_ERROR_PRINT_ENABLED: print("\n[F:Find Possible Chars in Scene] - len(contours) = " + str(len(contours))) print("\n[F:Find Possible Chars in Scene] - int_count_of_possible_chars = " + str(int_count_of_possible_chars)) if SHOW_IMAGE: cv2.imshow("[F:Find Possible Chars in Scene] - Contours", img_contours) if SAVE_IMAGE: cv2.imwrite("./output/showImage/4-Find Possible Chars-Contours.jpg", img_contours) return list_of_possible_chars
def find_possible_chars_in_scene(img_thresh): list_of_possible_chars = [] count_of_possible_chars = 0 img_thresh_copy = img_thresh.copy() img_contours, contours, hierarchy = cv2.findContours( img_thresh_copy, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) height, width = img_thresh.shape img_contours = np.zeros((height, width, 3), np.uint8) for i in range(0, len(contours)): if PlateRecognition.showSteps: cv2.drawContours(img_contours, contours, i, PlateRecognition.SCALAR_WHITE) possible_char = PossibleChar.PossibleChar(contours[i]) if DetectChars.check_if_possible_char(possible_char): count_of_possible_chars = count_of_possible_chars + 1 list_of_possible_chars.append(possible_char) return list_of_possible_chars