![]() So code() function returns the data containing the barcode, the type of barcode, as well as the location points as a rectangle and a polygon. To make things clear, the following is how each obj looked like if we print it: Decoded(data=b'43770929851162', type='I25', rect=Rect(left=62, top=0, width=694, height=180), polygon=) ![]() We then iterate over all detected barcodes and draw a rectangle around the barcode and prints the type and the data of the barcode. I have wrapped every functionality into a function, the first function we gonna discuss is the following: def decode(image):ĭecode() function takes an image as a numpy array, and uses code() that is responsible for decoding all barcodes from a single image and returns a bunch of useful information about each barcode detected. I have few images to test with, you can use any image you want from the internet or your own disk, but you can get my test images in this directory. Once you have these installed, open up a new Python file and import them: from pyzbar import pyzbar To get started, we need to install few libraries: pip3 install pyzbar opencv-python Related: How to Extract Frames from Video in Python. Today, we see barcodes everywhere, especially in products in supermarkets.īarcodes can be read by an optical barcode scanner, but in this tutorial, we will make a script in Python that is able to read and decode barcodes, as well as a drawing where they're located in a given image. ![]() ![]() Disclosure: This post may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.Ī barcode is a method of representing data in a visual and machine-readable form, it consists of bars and spaces. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |