'Google Vision API normalize image

I'm using Google Vison API with PHP.

I want to analyze image and extract table data from it.

The image will not always be aligned or in the same size.

I've got reference image which I'm looking for words that I know will always be there and then I'm trying to compare to the current image and fix positions

For each word I've got the bounds(top left, top right, bottom right, bottom left)

I've draw the bounds of the words. reference image => red, current image => green enter image description here

Next I've compared the top red and green rectangles and shift them all based on the differences. adjusted image => cyan. enter image description here

The top one is correct because he was the reference. the others just shift but the distance between them are not correct.

What is the best practice to normalize the image based on reference image.

Thanks.



Solution 1:[1]

The API returns the height and width: https://cloud.google.com/vision/docs/reference/rest/v1/AnnotateImageResponse#page

You could use those numbers and the numbers from your golden image to know how much to shift the boxes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brendan