1

I'm actually developing in Android and I've created a program that the user has to upload a picture of his shop with all the things that he's selling and he's sold (it's about a game). I'm actually in the last part, I need to detect what are those sold items.

Unfortunately the picture has low quality because it's done with a mobile phone. But, I think that if I clean the image using Grey, Thresh and Canny methods of cv2 I can after read the information with OCR tesseract.

Then I'm going to show you the structure of all the images with I'm working in this final part:

  1. First
  2. Second

After if I do for example a simple Grey process for the second image I got the following:

  1. Third

And finally if I execute all the following code I got this result:

img = cv2.imread('recorte.jpg')
gray = get_grayscale(img)
thresh = thresholding(gray)
opening = opening(gray)
canny = canny(gray)
  1. Result

I know, the result is too far of being professional, but I actually need help. If I execut tesseract I got the folowing result:

reels Ae coe vel boise)

In Summary, I think that I'm working in the well direction, the only thing that I have to do is clean correctly the image, use tesseract with a properly configuration and finaly get a good result. Hopes that you can help me. Thank you!

Sergi
  • 21
  • 3
  • how about ie. `img[ img < 100 ] = 255` to replace very dark pixels with white pixels in gray image? OR `img = ~img` to invert colors in gray image? OR maybe you should try `inRange` or `HSL` colors: [How to detect two different colors using `cv2.inRange` in Python-OpenCV?](https://stackoverflow.com/questions/48109650/how-to-detect-two-different-colors-using-cv2-inrange-in-python-opencv) – furas May 19 '20 at 17:45

1 Answers1

0

Would the following be what you're looking for:

img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)

enter image description here

K41F4r
  • 1,443
  • 1
  • 16
  • 36