Bretina - Python Image Testing Framework
Bretina is a python package designed to support testing of the images.
Bretina is designed as an extension of the python unit test module. Provides set of assertions which can be used to verify correctness of the image.
In typical application, content of the device LCD display is captured with a camera and Bretina is used to verify correctness of the defined regions in the image - such as region color, presence of an icon, correctness of the text representation and other aspects.
Documentation
can be found on https://docs.benderrobotics.com/bretina (Not publicly available ATM).
Download and install latest release
Bretina can be downloaded from within the internal BR network by calling:
$ pip install bretina
For optical character recognition Bretina offers two engines:
To change the OCR engine set the bretina.OCR_ENGINE to either OcrEngine.TESSERACT
or OcrEngine.PADDLE. By default OcrEngine.TESSERACT is set.
PaddleOCR local models
By default PaddleOCR downloads its models from the internet on first use. To use
models bundled locally instead, install the models extra. The bretina-models
package is hosted on the Bender Robotics private PyPI, so it has to be passed as
the extra index:
$ pip install bretina[models] --extra-index-url https://pypi.benderrobotics.com
When the bretina-models package is available, PaddleOCR automatically uses the
local models instead of downloading them.
PaddleOCR on Windows
PaddleOCR's native library (paddlepaddle) requires the Microsoft Visual C++
Redistributable (x64). Without it, the first Paddle OCR call fails with
ImportError: DLL load failed while importing libpaddle: The specified module could not be found.. Install the latest redistributable from
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-supported-redistributable-version
and reboot.
Tesseract usage
To utilize Tesseract, it has to be installed as a standalone application
and registered into system PATH. Installation files can be downloaded from
https://github.com/tesseract-ocr/tesseract (tested with Tesseract version 5).
Windows installer is provided by Mannheim University Library at
https://github.com/UB-Mannheim/tesseract/wiki.
After the installation, add path to the tesseract.exe to your system PATH.
For the best OCR performance install the slower, but more accurate datasets
tessdata_best (https://github.com/tesseract-ocr/tessdata_best). Extract the
downloaded archive into the installation directory of the tesseract OCR.
This is an expected structure of the tesseract installation directory:
C:\Program Files\Tesseract-OCR- tesseract installation\tessdata- original tessdata datasetafr.traineddata- ...
\tessdata_best- extracted best datasetafr.traineddata- ...
Working with the source
Clone the repository first, then check out devel for the latest version, or a
feature/* branch for the cutting edge one.
$ git checkout devel
Development setup
Install the package in editable mode with the development dependencies:
$ pip install -e .[dev]
Do this before anything else. The version is derived from the git tags by
setuptools-scm, which writes the generated src/bretina/__version__.py at
install and build time. A freshly cloned, never installed checkout has no such
file, so import bretina fails until you install or build once.
Install the git hooks as well, so the formatting and lint gate runs before every commit instead of failing in CI:
$ pre-commit install
Building the wheel
$ python -m build
The wheel and the source distribution are written to dist/.
VS Code tasks
The recommended entry point for everyday work are the tasks in
.vscode/tasks.json, run through Terminal > Run Task.... They are the same
commands CI runs, so a green task means a green pipeline (usually):
| Task | Command | Purpose |
|---|---|---|
install (dev) |
pip install -e .[dev] |
editable install with the dev dependencies |
build |
python -m build |
build the wheel and the sdist |
lint |
ruff check |
lint the package and the tests |
format |
yapf -i -r src tests tools docs/conf.py |
reformat in place |
typing |
mypy |
type check |
test |
pytest |
run the whole test suite |
Neither ruff nor mypy takes a path argument, both are configured in pyproject.toml.
Metadata
Release files for bretina 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bretina-1.0.0.tar.gz | 4.0 MB | Without provenance | Details for bretina-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bretina-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for bretina-1.0.0-py3-none-any.whl |
Total release size: 4.0 MB
Release files / bretina-1.0.0.tar.gz
| Download URL | bretina-1.0.0.tar.gz |
|---|---|
| Size | 4.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39c94eb71287aa907201e8649528b4b077f71c4f2c36a0b67e3570d83b0e746f
|
|
BLAKE2b-256 checksum How to use checksums |
1e8795124add489e1f373274ef22b79ef3313610531a62408c901d444d9ada91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / bretina-1.0.0-py3-none-any.whl
| Download URL | bretina-1.0.0-py3-none-any.whl |
|---|---|
| Size | 65.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32c74640b65dd7c99173a6d4abf913e05db63bdc024c8a66d201e29f315e2c93
|
|
BLAKE2b-256 checksum How to use checksums |
8ff4719ad722986ef5a8c29cd56dfc38769923d44a253579caf5f9d383fd48ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for bretina 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.