示例#1
0
 def delete_card_by_id(cls, card_id):
     cards = db.session.query(Card).filter(Card.id == card_id)
     for card in cards:
         if card.is_image:
             OCR.delete_ocr_by_card_id(card.id)
     cards.delete()
     db.session.commit()
示例#2
0
def card_ocr_text(card_id):
    """
    Returns the OCR text of a card if it is an image card.
    """
    ocr = OCR.get_ocr_by_card_id(card_id)
    if not ocr:
        return error(Error.NO_OCR_TEXT)
    return ok({
        "ocr": {
            "card_id": ocr.card_id,
            "text": ocr.text
        }
    })
示例#3
0
def async_ocr(app, image_path, card_id):
    with app.app_context():
        text = ocr(image_path)
        OCR.add_ocr(card_id, text)