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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bretina-1.0.0.tar.gz.
File metadata
- Download URL: bretina-1.0.0.tar.gz
- Upload date:
- Size: 4.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c94eb71287aa907201e8649528b4b077f71c4f2c36a0b67e3570d83b0e746f
|
|
| MD5 |
218dfa57bb73b230c2be0802128d2a0b
|
|
| BLAKE2b-256 |
1e8795124add489e1f373274ef22b79ef3313610531a62408c901d444d9ada91
|
File details
Details for the file bretina-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bretina-1.0.0-py3-none-any.whl
- Upload date:
- Size: 65.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c74640b65dd7c99173a6d4abf913e05db63bdc024c8a66d201e29f315e2c93
|
|
| MD5 |
d14420c3f73f56543de7f498d82325eb
|
|
| BLAKE2b-256 |
8ff4719ad722986ef5a8c29cd56dfc38769923d44a253579caf5f9d383fd48ab
|