コード例 #1
0
def get_card_number_and_edition(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_number_and_edition_bounds(
        image_width, image_height)

    number_and_edition_image_section = image[top:top + height,
                                             left:left + width]

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_number.jpg"),
                number_and_edition_image_section)

    # if DEBUG:
    # cv2.imshow("Image", number_and_edition_image_section)
    # cv2.waitKey(500)

    text = pytesser.mat_to_string(number_and_edition_image_section)

    card_number = re.search(CARD_NUMBER_RE, text)
    edition = re.search(EDITION_RE, text, re.MULTILINE)

    if card_number:
        card_number = card_number.group(0)[:3]

    if edition:
        edition = edition.group(0)[:3]

    return card_number, edition
コード例 #2
0
def get_card_name(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_card_name_bounds(image_width, image_height)

    card_name_image_section = image[top:top + height, left:left + width]

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_name.jpg"), card_name_image_section)

    return pytesser.mat_to_string(card_name_image_section, "mtg", psm=pytesser.PSM_SINGLE_LINE)
コード例 #3
0
def get_card_name(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_card_name_bounds(image_width, image_height)

    card_name_image_section = image[top:top + height, left:left + width]

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_name.jpg"),
                card_name_image_section)

    return pytesser.mat_to_string(card_name_image_section,
                                  "mtg",
                                  psm=pytesser.PSM_SINGLE_LINE)
コード例 #4
0
def get_card_text(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_card_text_bounds(image_width, image_height)

    card_text_image_section = image[top:top + height, left:left + width]

    #if DEBUG:
    #    cv2.imshow("Text", card_text_image_section)
    #    cv2.waitKey(500)

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_text.jpg"), card_text_image_section)

    return pytesser.mat_to_string(card_text_image_section, "eng")
コード例 #5
0
def get_card_text(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_card_text_bounds(image_width, image_height)

    card_text_image_section = image[top:top + height, left:left + width]

    #if DEBUG:
    #    cv2.imshow("Text", card_text_image_section)
    #    cv2.waitKey(500)

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_text.jpg"),
                card_text_image_section)

    return pytesser.mat_to_string(card_text_image_section, "eng")
コード例 #6
0
def get_card_number_and_edition(image):
    image_height, image_width = image.shape[:2]
    left, top, width, height = _get_number_and_edition_bounds(image_width, image_height)

    number_and_edition_image_section = image[top:top + height, left:left + width]

    cv2.imwrite(os.path.join(LATEST_DIR, "latest_number.jpg"), number_and_edition_image_section)

    # if DEBUG:
    # cv2.imshow("Image", number_and_edition_image_section)
    # cv2.waitKey(500)

    text = pytesser.mat_to_string(number_and_edition_image_section)

    card_number = re.search(CARD_NUMBER_RE, text)
    edition = re.search(EDITION_RE, text, re.MULTILINE)

    if card_number:
        card_number = card_number.group(0)[:3]

    if edition:
        edition = edition.group(0)[:3]

    return card_number, edition