Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

Pytesseract OCR shipping labels

Hello all,
I recently joined this forum and upgraded and I love it here!

Anyways, my issue is i have shipping labels from UPS for my business and I want to use a script in python to extract the name of the recipient on the shipping label, the reference numbers, and the tracking number. Issue is when I run this script:

Code
import cv2
import pytesseract
# Load image
img = cv2.imread("example_image.jpg")
# Convert image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Apply threshold to convert to binary image
threshold_img = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
# Pass the image through pytesseract
text = pytesseract.image_to_string(threshold_img)
# Print the extracted text
print(text)

It’s inaccurate as shipping labels have different font sizes and the text can be quite close to each others (horizontally)


[Image: IMG-2928.png]
You want a script that can scan the shipping label, and then extract the recognized string name correct?
[Image: 12XdAdJ.gif]
I figured it out thanks ! Had to use simple rectangles with openCV and then resize it a throw that into pytesseract image to string function !


Possibly Related Threads...
Thread / Author Replies Views Last Post
by passivebankrollJun 10, 2018 06:52 AM 3 136 Jun 10, 2018 06:52 AM
Last Post: Elitas
by OkmomFeb 15, 2018 01:21 PM 0 86 Feb 15, 2018 01:21 PM
Last Post: Okmom
by SyyKNov 18, 2015 12:35 PM 3 182 Nov 18, 2015 12:35 PM
Last Post: code42fun