4

we are using google vision ocr for gathering text from receipts. In some cases the receipt have some text written in vertical , like vat information and some other.

The question is that google vision read efficiently only the text in the main orientation (horizontal by example) and discards all the text written in the same receipt in vertical orientation instead in horizontal. Is there a parameter to set up for tell google vision to acquire also the text in vertical orientation?

I have put online an example with an image with text in two orientations .

https://drive.google.com/file/d/0B8kZz-q27lGGSUl5V3RjXzBLNnc/view?usp=sharing

Text recognized from g-vision : Horizontal text line

Text I've expected to be recognized: Horizontal text line Vertical text line

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
TECL Sarce
  • 41
  • 1
  • 3

2 Answers2

3

I know it is late response, maybe somebody will benefit from it in the future... you can force the detector to recognize ONLY vertical text by doing a frame rotation before applying the detector on like this: in setRotation() method in the CameraSource. write:

outputFrame = new Frame.Builder()
                        .setImageData(mPendingFrameData, 
                          mPreviewSize.getWidth(),
                                mPreviewSize.getHeight(), 
                         ImageFormat.NV21)
                        .setId(mPendingFrameId)
                        .setTimestampMillis(mPendingTimeMillis)
                        .setRotation(mRotation)
                        .build();
mRotation = 2; (for vertical text direction from bottom to top)
mRotation = 1; (for vertical text direction from top to bottom)
farahkh
  • 51
  • 7
  • CameraSource doesn't have a setRotation method. – maxwell79 May 14 '20 at 03:34
  • here you are rotating the Frame object not the CameraSource object. – farahkh May 22 '20 at 02:03
  • Can you give some context. setRotation is from which library? Also @farakh can you update the code which we can replicate, like an image input path, read, this method and an output path. I'm mostly into Python and Scala, this seems to be Java, if I'm not mistaking. – Aakash Basu Jun 02 '20 at 10:23
0

I think that's a limitation of the Google Vision API. I've searched on how to do that too, and eventually used this solution. But if you need just one of them vertical or horizontal like I did, you can use client side rotate (please see here on how to crop and rotate before upload).

Paul Kertscher
  • 9,416
  • 5
  • 32
  • 57