Search code examples
androidocrgoogle-cloud-visionabbyy

OCR not working when background color & text color almost similar


We are facing one issue when we try to scan bag. The main reason behind that the text color on the bag which are embroidered are almost same as bag's color. So it can not scan exact text which is written on the bag.

To get actual idea I have attached image.

In attached image we want to scan bag's id (D1 150491). Let me know if we have to do extra effort to scan this type of image.

Note: We have tried two SDK

enter image description here


Solution

  • As has been suggested in the comments to your question, there is not really much that can be done besides pre-processing your image. Google Cloud Vision API (and probably all other OCR platforms out there) will not be able to recognize a text such as the one you present in this image.

    In order to improve the recognition for images such as this one, you should apply some pre-processing techniques, among which you could consider (but not limited to) the ones mentioned in the comments:

    • Applying filters: edge detection, using some of the popular methods such as Canny or Sobel (have some examples here).
    • Image binarization: consists in setting a threshold in the gray level of the image, in such a way that the background has one colour (either white or black) and the letters have another. You can have a look at some examples here, although I do not think this will work for your case, as the gray level of the letters and the rest of the image seems quite similar (only a little bit of brightness in the letters due to its volume).
    • Play around: change the brightness and contrast of the image, and you might be able to get some results. However, this process is difficult to automate, and the same values will probably not work for different images.

    In short, there is no easy way to do this, and you will have to pre-process the images in order to get something that can actually be understood by the models behind the Vision API.