Metadata-Version: 2.5
Name: simplevision
Version: 1.0.10
Summary: Run SimpleVision computer-vision pipelines from Python — a student-friendly companion to the SimpleVision editor.
Project-URL: Homepage, https://github.com/AutoElecAB/SimpleVision
Project-URL: Source, https://github.com/AutoElecAB/SimpleVision
Project-URL: Issues, https://github.com/AutoElecAB/SimpleVision/issues
Project-URL: Changelog, https://github.com/AutoElecAB/SimpleVision/blob/main/CHANGELOG.md
Author-email: AutoElec AB <tornblomanton@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: computer-vision,education,image-processing,opencv,pipelines
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Requires-Python: >=3.11
Requires-Dist: matplotlib>=3.8
Requires-Dist: numpy>=1.26
Requires-Dist: opencv-python>=4.9
Requires-Dist: pillow-heif>=0.18
Requires-Dist: pillow>=10.0
Requires-Dist: pygrabber>=0.2; platform_system == 'Windows'
Requires-Dist: pyserial>=3.5
Requires-Dist: scipy>=1.11
Requires-Dist: tokenizers>=0.20
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: gpu
Requires-Dist: nvidia-cublas-cu12; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: nvidia-cuda-nvrtc-cu12; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: nvidia-cuda-runtime-cu12; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: nvidia-cudnn-cu12<10,>=9.0; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: nvidia-cufft-cu12; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: nvidia-curand-cu12; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: onnxruntime-gpu<1.27,>=1.26; (platform_system == 'Linux') and extra == 'gpu'
Requires-Dist: onnxruntime-windowsml<1.27,>=1.24; (platform_system == 'Windows') and extra == 'gpu'
Provides-Extra: hardware
Provides-Extra: ocr
Requires-Dist: rapidocr-onnxruntime>=1.3; extra == 'ocr'
Description-Content-Type: text/markdown

# simplevision

Run [SimpleVision](https://github.com/AutoElecAB/SimpleVision) computer-vision
pipelines from Python.

SimpleVision is a learning tool for students: you build a vision pipeline
visually in the desktop editor (threshold, blob detect, color match,
geometric match, OCR, …), tick the measurements you care about, and the
editor saves the pipeline as a single `.simplevision` JSON file. This
library is the companion that runs that pipeline from Python so you can
plug the measurements into your own code.

## Install

```bash
pip install simplevision
```

OCR is optional (it pulls in RapidOCR + ONNX Runtime, ~300 MB):

```bash
pip install "simplevision[ocr]"
```

## Use it

Open your pipeline in the SimpleVision editor, tick the measurements you
want in **Output Control**, and save. Then in Python:

```python
from simplevision import Pipeline

p = Pipeline.load("my_pipeline.simplevision")
p.run()

# Each name below is one you typed in the editor's Output Control panel.
if p.outputs.MatchPercentage[0] > 0.85:
    print("Match found at", p.outputs.Centroids[0])
```

Pass your own frame to `p.run()` to process many images through the same
pipeline:

```python
import cv2
for path in ["frame_001.png", "frame_002.png", "frame_003.png"]:
    p.run(path)
    print(path, "->", p.outputs.Count)
```

`print(p.outputs)` shows everything readably — handy while you're getting
oriented.

## Live graph loops

A graph with a webcam Load node keeps the camera open between runs and
processes the newest frame. Use a context manager to release the camera
when you finish or interrupt the loop:

```python
from simplevision import Graph

try:
    with Graph.load("main.simplevision") as graph:
        while True:
            graph.run()
            print(graph.outputs)
except KeyboardInterrupt:
    pass
```

You can also call `graph.close()` in a `finally` block. Passing an explicit
image to `graph.run(image)` releases any webcam previously opened by that
graph. The first webcam run includes camera startup; subsequent runs reuse
the stream and discard old frames while image processing runs.

## Pattern Match: scale and rotation

In the editor, open **Pattern Match → Settings** and enable **Search different
sizes** and/or **Search different angles**. Save the project after changing
the ranges; `Graph.load(...).run()` and `Pipeline.load(...).run()` use those
same settings. Existing projects keep both searches off.

Scale is a percentage of the saved template: 50% is half-size, 100% is the
original, and 150% is one and a half times the size. Angles are degrees;
positive values turn counterclockwise. Both endpoints are included, along
with 100% and 0° when those values lie within the chosen ranges.

For a first trial, use scale 50–150% in steps of 10% and rotation −30–30° in
steps of 10°. Wider ranges and smaller steps take longer; searches are limited
to 256 size/angle combinations. Size changes and rotation within the image
are covered, but perspective tilt is not corrected.

The existing Count, Scores and Positions outputs include the combined matches,
with duplicate detections suppressed across sizes and angles. Output Control
also offers **Angles** and **Scales**, in the same best-score-first order.
Scales are factors (`1.5` means 150%), while Angles are degrees. The viewer
shows each match's rotated outline, score, scale and angle.

## What's in the package

- `simplevision.Pipeline`, `simplevision.Outputs`, `simplevision.Point` —
  the student-facing API.
- `simplevision.runtime` — the execution engine. You normally don't
  import this directly; the desktop app uses it as a sidecar and
  `Pipeline.run()` drives it under the hood. The runtime is documented
  in [`docs/pipeline-spec.md`](https://github.com/AutoElecAB/SimpleVision/blob/main/docs/pipeline-spec.md)
  if you want to build pipelines without the editor.

## License

Apache-2.0. See `LICENSE` and `NOTICE`.
