Crates.io | grocer |
lib.rs | grocer |
version | 0.1.2 |
source | src |
created_at | 2024-05-13 06:26:30.80924 |
updated_at | 2024-06-04 21:43:36.088813 |
description | A simple Rust library for reading UPC barcodes from images. |
homepage | |
repository | |
max_upload_size | |
id | 1238019 |
size | 11,684 |
A simple Rust library for reading UPC barcodes from images.
Add grocer to your Cargo.toml
file.
[dependencies]
grocer = "0.1.2"
It's simple to read a barcode from an image file with minimal code.
use grocer;
fn main() {
let scan_settings = grocer::ScannerSettings { high_speed: false, };
let barcode: grocer::Barcode = grocer::scan_upc("images/image.png", scan_settings);
println!("Code: {}", barcode.code);
}
Scans can take a while mostly because the barcode can be anywhere in the image and needs to be found first. The whole image is scanned and every white section is checked to see if it is the leading quiet zone on the left side of a barcode.
To fix it, for now you can compile with --release and it should go much faster.
I'm working on adding features soon that allow the user to cut down on reliability for speed if the application calls for it. For instance, if you know the barcode is always in the center of the image, changing the settings would allow for very fast scanning because it's easier to look for the barcode.
Help me out! If you have images of barcodes that won't scan with this library, let me know! Please send me any images that don't scan (buzzqrd@protonmail.com). I want to make sure that this library is able to work for all barcodes within reason, and it will really help to test it on a wide variety of barcodes. I've been taking lots of pictures of barcodes and testing them with grocer. I've mostly had complete success, but I had some issues with a green barcode that I found, so im working on making the black-white boundary auto-adjust to capture a wider range of color-printed barcodes.
If you want to send a barcode to me, make sure it's a supported format (UPC-A for now) and email me at buzzqrd@protonmail.com.
Thank you!
0.1.0: Initial release - Basic barcode scanning - UPC-A support
0.1.1: Updated docs - Updates to some documentation
0.1.2: Important features update - More accurate scanning methods - Structs for settings selection - Return structs for barcode info - Rejects any barcodes of the wrong size (UPC-A = 12 chars)