Hrishikesh Paranjpe
Hrishikesh Paranjpe

Reputation: 1

OCR with Google Cloud Vision python API

I am using the Google Cloud Vision Python API for performing OCR, in order to extract info from a document, like an ID proof. Is there a way to crop the image in such a way that only the part with concentrated text is retained? I tried using cropHint but it simply eliminates the borders.

The function in my code is somewhat like:

def detect_text(path):

    """Detects text in the file."""

    vision_client = vision.Client()

    with io.open(path, 'rb') as image_file:
        content = image_file.read()

    image = vision_client.image(content=content)

    texts = image.detect_text()

Upvotes: 0

Views: 1373

Answers (1)

dizcology
dizcology

Reputation: 170

You will have to walk through the response and process the bounding boxes' coordinates. See this page for some examples of the API response.

Upvotes: 1

Related Questions