Skip to content

Pranay-Pandey/BarCode_Reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarCode_Reader

This repository contains a solution for recognizing barcodes on the items in an image containing multiple grocery items with a single-colored background. The solution uses OpenCV and Zbar libraries for barcode recognition and object detection.

Dependencies

  • OpenCV
  • pyzbar
  • Numpy
  • dbr
  • ultralytics

Initial Thought

  1. Import the required libraries
  2. Define the function to detect objects in the image using OpenCV's feature-based object detection method
  3. Define the function to recognize barcodes in the detected objects using Zbar library
  4. Loop through all the detected objects and use the barcode recognition function to recognize barcodes in each object
  5. Draw bounding boxes of different colors around the objects based on the results of the barcode recognition:
    • Blue for successfully recognized barcodes
    • Yellow for partially recognized barcodes
    • Red for objects without barcodes
    • Black for each item in the image
  6. Print the value of every barcode and the number of times each barcode appears in the image

How to Run

  1. Clone or download the repository
  2. Install the required dependencies
  3. Run the solution by executing the main file in the terminal or command prompt

Key Results


The rest of the results can be found in the Output Folder.

Solution Procedure:

The following steps are performed in the solution:

  • The image is loaded.
  • Yolo Object detection is applied on the image and all the objects present in the image are identified.
  • The identified objects are cropped and passed to the Fine object getter method which uses clustering of corners present in the image to identify individual items.
  • The cropped images of individual items are processed to detect barcode present in them. For barcode detection Pyzbar and Dynamsoft barcode reader libraries are used.
  • The images are coloured accordingly to indicate successful barcode detection or not.
  • Finally, Barcode detection is applied directly on the whole image to see if there is any left out barcode.

Running the Code

From Python

The main code for barcode identification is present in the file main.py. To run the code from python, follow the instructions below:

  1. Make a new python script to get the results
  2. import main
    

    file = main.main_func("Image_name/path")

    img_output = file[0] barcode_coordinates = file[1]

From Command Line Interface

To run the code from the Command Line Interface, follow the instructions below:

  1. Open your terminal or command prompt
  2. Change the directory to the project directory using the cd command
  3. Run the following command:
    python main.py [image_file/loc] [optional_arguments]

Notebook

The basic script.ipynb file is the raw Jupyter Notebook that was used for training and experimentation and also for finding the hyperparameter's optimal values, etc. You can use this notebook for understanding the implementation of the code and other approches.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published