Skip to main content

A library for grading Data Matrix codes via GS1 QA metrics

Project description

GS1Grader for UDI Vision Inspection

Banner

GS1Grader is a Python library for grading Data Matrix codes using GS1 quality metrics with modulation and symbol contrast implementation essential for UDI (Unique Device Identification) compliance in medical devices.

Prerequisites

Before installing GS1Grader, you need to install some system dependencies:

Ubuntu/Debian

sudo apt-get update
sudo apt-get install -y \
    libdmtx0b \
    ffmpeg \
    libsm6 \
    libxext6

Mac OS

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install the required dependencies
brew install libdmtx
brew install ffmpeg
brew install uv
brew install poetry

These system dependencies are required for proper functioning of OpenCV and pylibdmtx.

Installation with uv

create a virtual environment using uv and a suitable Python version (3.11 or higher):

uv venv .venv --python 3.11
source .venv/bin/activate

You can now install GS1Grader using pip:

uv pip install gs1grader

Or if you want to install from source:

# Clone the repo
git clone https://github.com/Ceyeborg/GS1Grader.git
cd GS1Grader

poetry install

Usage

Here's a simple example of how to use GS1Grader:

from gs1grader.grader_api import DataMatrixGradeAPI

# Create a grading API instance
grader_api = DataMatrixGradeAPI()

# Grade an image using the modulation grader
grade, explanation = grader_api.grade_datamatrix(
    image_path="path/to/your/datamatrix.png",
    grade_type="modulation",
    explanation_path="."
)

# Print the results
print(f"Grade: {grade}")
if explanation:
    print(f"Explanation: {explanation}")

Available Grading Methods

The library currently supports the following grading methods:

  • modulation: Evaluates the modulation quality of the Data Matrix
  • symbol_contrast: Evaluates the symbol contrast quality

API Reference

DataMatrixGradeAPI

The main class for grading Data Matrix codes.

Methods:

  • grade_datamatrix(image_path: str, grade_type: str, explain: bool = False):
    • image_path: Path to the Data Matrix image file
    • grade_type: Type of grading to perform ("modulation" or "symbol_contrast")
    • explanation_path: Provide a path to save png of the detailed explanation of the grade (optional)
    • Returns: A tuple of (grade, explanation)

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.

The AGPL-3.0 is a copyleft license that requires anyone who distributes your code or a derivative work to make the source available under the same terms, and also requires you to provide the source code to users who interact with your software as a service.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gs1grader-0.1.3.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gs1grader-0.1.3-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file gs1grader-0.1.3.tar.gz.

File metadata

  • Download URL: gs1grader-0.1.3.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for gs1grader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 516b81edbe2646ad27c844062d179a254bd9e551ae11a8a629680c8920c563eb
MD5 e36018838509d11a90ee694633ada7e1
BLAKE2b-256 ecee317402dcdb5d0a92b76144480eb53f103ae2e376984ce985af9fd6d555e2

See more details on using hashes here.

File details

Details for the file gs1grader-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: gs1grader-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for gs1grader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bfce11cadcfb50e4c2965b2b6805fece75ff47512555eb0c60557d843116b73c
MD5 fdc4e6b0211144a241205936d602dec4
BLAKE2b-256 da175d45dc7a158d7fa16e48c3839817724a6f22160f3a22b0d4a1f093801ff6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page