I'm trying to find a way to get the UPC plus the 5 number supplement barcode using Python or NodeJS.
So far I've tried using pyzbar in Python via this code.
img = Image.open(requests.get(url, stream=True).raw)
img = ImageOps.grayscale(img)
results = decode(img)
That only returns the main UPC code. Not the supplemental code.
This is an example of an image I'm trying to read this from.
Install the dependencies (on mac + python):
$ brew install zbar
$ pip install pyzbar
$ pip install opencv-python
You can define the symbols to ZBar. Please try this python code:
import cv2
import pyzbar.pyzbar as pyzbar
from pyzbar.wrapper import ZBarSymbol
img = cv2.imread('barcode.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcodes = pyzbar.decode(gray, [ZBarSymbol.EAN13, ZBarSymbol.EAN5])
for barcode in barcodes:
print('{}: {}'.format(barcode.type, barcode.data))
I've tested it with this image:
The result is:
EAN5: b'07900'
EAN13: b'9791234567896'
(BTW, for your image this code scans just the EAN13 part. Maybe you have to use a bigger image, or increase the contrast)