Pupil, glint, and limbus detection on grayscale eye images, plus iris-texture rigid alignment of two eye images.
Project description
cheshm
Cheshm is a cross-platform (Linux, macOS, Windows) C++ library with Python bindings. It packages pupil, glint, and limbus detectors for grayscale eye images, plus rigid alignment of two eye images (glint, pupil, or iris-texture based) and helpers for saving the resulting visualizations to PNG.
To annotate eye images with cheshm's detectors, see EyE Annotation Tool.
Install
uv add cheshm
or with pip:
pip install cheshm
Detectors
| Kind | Detector | Paper | Licence |
|---|---|---|---|
| pupil | Simple | — | MIT |
| pupil | Starburst | Li, Winfield, Parkhurst 2005 | GPL |
| pupil | Swirski2D | Świrski, Bulling, Dodgson 2012 | MIT |
| pupil | ExCuSe | Fuhl et al. 2015 | non-commercial |
| pupil | ElSe | Fuhl et al. 2016 | non-commercial |
| pupil | PuRe | Santini, Fuhl, Kasneci 2018 | non-commercial |
| pupil | PuReST | Santini, Fuhl, Kasneci 2018 | non-commercial |
| pupil | PupilLabs2D | Kassner, Patera, Bulling 2014 | LGPL-3.0-or-later |
| glint | Simple | — | MIT |
| limbus | Daugman integro-differential | Daugman 1993 | MIT |
| limbus | Daugman active contour | Daugman 2007 | MIT |
| limbus | Pupil-guided active contour | Daugman 2007 variant | MIT |
The top-level LICENSE is MIT and covers the framework code; each detector ships its own LICENSE file with the detector's terms. Installing the project from PyPI installs all detectors, but only the ones you import are loaded into your process — so the licence that governs your use is the licence of the detectors you imported:
from cheshm.pupil_detectors.Simple import detect_pupil # MIT
from cheshm.pupil_detectors.Starburst import detect_pupil # GPL
from cheshm.pupil_detectors.ExCuSe import detect_pupil # non-commercial
from cheshm.pupil_detectors.ElSe import detect_pupil # non-commercial
from cheshm.pupil_detectors.PuRe import detect_pupil # non-commercial
from cheshm.pupil_detectors.PuReST import PuReST # non-commercial (stateful tracker)
from cheshm.pupil_detectors.PupilLabs2D import detect_pupil # LGPL-3.0
from cheshm.glint_detectors.Simple import detect_glints # MIT
from cheshm.limbus_detectors.daugman.integro_differential import detect_limbus # MIT
from cheshm.limbus_detectors.daugman.active_contour import detect_limbus # MIT
from cheshm.limbus_detectors.daugman.pupil_guided import detect_limbus # MIT
Single-eye contract
Every public function operates on one eye at a time — a single grayscale image. Callers with two eyes call cheshm twice and combine the results.
Alignment
cheshm.align.align_eye_images(ref_img, tgt_img, ref_det, tgt_det, *, step1, step2) registers tgt_img onto ref_img with up to a two-step rigid transform. Either step can be enabled independently:
- Step 1 (translation) anchors on glint centroids (
step1="glint"), pupil centres (step1="pupil"), or is skipped (step1=None). - Step 2 (iris-texture refinement, optional) refines
(dx, dy, theta)by minimising mean absolute intensity difference inside an iris-barrel mask built from the limbus + pupil geometry.
Set step1="glint", step2=False for pure glint alignment, step1="pupil", step2=False for pure pupil-centre alignment, step1=None, step2=True for iris-only, or any combination.
Visualization
cheshm.viz writes PNGs that show detector and alignment outputs:
save_detection_overlay(out_path, img, detections, *, style, label)— draws pupil, glint, and limbus overlays onimg.styleis a dict keyed by element (pupil_contour,pupil_ellipse,pupil_center,pupil_mask,glint_contour,glint_ellipse,glint_center,limbus_curve,limbus_center) where each value is{show, color, thickness, alpha}.save_diff_heatmap(out_path, ref, aligned)— colour-mapped|ref − aligned|.save_alignment_overlay(out_path, ref, aligned)— blended reference + aligned image.save_alignment_comparison(out_path, ref, target, aligned)— 4-panel: ref | aligned | diff-before | diff-after.
GUI
cheshm-gui opens a Dear PyGui workbench for tuning detector parameters interactively on a folder of images.
cheshm-gui # empty workbench
cheshm-gui path/to/folder # open a folder of eye images
cheshm-gui path/to/a.png p2.png # open specific files
Development
Cheshm ships precompiled wheels on PyPI for Linux, macOS, and Windows on Python 3.10–3.13, so end users never need to build anything. This section is for users who want to build from source. Building from source needs CMake, a C++20 compiler, OpenCV, and (for PupilLabs2D) Eigen3.
The project uses uv for environment management and scikit-build-core to drive CMake. First-time setup:
cd path/to/cheshm
uv sync
This creates .venv/, installs runtime + build deps, and builds the C++ extensions in editable mode (per [tool.scikit-build] in pyproject.toml).
After changing any C/C++ source, force a recompile:
uv sync --reinstall-package cheshm
Plain uv sync will not notice C/C++ source edits — only pyproject.toml changes.
After changing a binding's signature (a core.cpp under bindings/python/src/), regenerate the matching _core.pyi:
./scripts/regen_stubs.sh
Commit the updated .pyi alongside the .cpp. CI verifies the committed stubs match what stubgen would emit and fails the PR if they drift.
Repo layout
include/cheshm/ public C++ headers (libcheshm_cpp)
helpers/ shared image-processing helpers (edges, ellipses, image, shape)
pupil/<Det>/ per-pupil-detector headers
glint/Simple/ per-glint-detector headers
limbus/Daugman/ Daugman family (active_contour, integro_differential, pupil_guided)
align/ rigid alignment headers
viz/ visualization headers
src/ C++ algorithm implementations
bindings/python/
cheshm/ Python package (PyPI)
src/ nanobind C++ glue, one CMake per detector
third_party/poolstl/ vendored parallel-STL backend
Name
In Persian (Farsi), Cheshm (چشم) literally means "eye".
Logo
The nazar / cheshm amulet image is from pngegg.
Acknowledgments
This work received funding from the European Union's Horizon Europe research and innovation funding program under grant agreement No 101072410, Eyes4ICU project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 cheshm-2.0.0.tar.gz.
File metadata
- Download URL: cheshm-2.0.0.tar.gz
- Upload date:
- Size: 3.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0e6a983e049f1becc71051169ee654b4421e542c388db20a6e92972965a2883
|
|
| MD5 |
fb77a4e0d0c9fbd57b757b56091e6d8d
|
|
| BLAKE2b-256 |
ea45a3690a92576eb740dc8952651622204d5a97cdafde5ba03e4f5f0a048752
|
File details
Details for the file cheshm-2.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a869c86cd85c6819f37bcb4d56fe58faa732ddfdd300445945761ebb844b785b
|
|
| MD5 |
4a80cba439e10ea7093305718ba54e4d
|
|
| BLAKE2b-256 |
cb3066a3b2d4c28eb45182642b1501e3d4a4074800afe32ba60c10a93c827514
|
File details
Details for the file cheshm-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 21.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b932146997dcf1e96c94bb95f63575360f2c2747aa6ac4cf2efc6c1b6e9e505
|
|
| MD5 |
d85ab2971a464ea2f1cb61c2b1895c15
|
|
| BLAKE2b-256 |
8de6498966c86983e1ca5f871dda0a4d2160fa2067e9b6002b24bdcebf96393c
|
File details
Details for the file cheshm-2.0.0-cp313-cp313-macosx_15_0_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp313-cp313-macosx_15_0_x86_64.whl
- Upload date:
- Size: 33.2 MB
- Tags: CPython 3.13, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
329709fc08ec969a2ae4cf9b37a3ab9741d3b163c2dcbbd075a422fe97da062e
|
|
| MD5 |
959e0a0d8cc7cf593dfd5bf73dafa7cf
|
|
| BLAKE2b-256 |
27d355cc0c6c08f40c0379675e3255d3cc96261eb41d23d7385810fb2e8d01ba
|
File details
Details for the file cheshm-2.0.0-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 15.7 MB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4256d98168cd272f8c9f1ca9ee9a53acc7e68a475200bbc75721e63d4ba3e196
|
|
| MD5 |
d82d3edd4855dea1d25e1c6498c878d2
|
|
| BLAKE2b-256 |
d37eed062f8f192f0c550d164f3f4cb375c237e2329cbb0ded0cb05e7bd47fbc
|
File details
Details for the file cheshm-2.0.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
538d8f0f841a8b5f1bbeb182d8db62e063da04caeb2e4de886afd1febfd3bdf0
|
|
| MD5 |
2e7b0ea30cd82d338467606150f27861
|
|
| BLAKE2b-256 |
af3151d75422b9dc711506cb9033151a5fadd8ae148e433f4031fe67e6785653
|
File details
Details for the file cheshm-2.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 21.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c695b91c29fd5180f924c2e5f91d89b2597afd6dd9bb2fa420884ed9db06927
|
|
| MD5 |
d31b94583d1d69557cc83647d3d75a35
|
|
| BLAKE2b-256 |
7fbb1d9d88473d015cb84465344fb3d9a82079806da3d7a4c0829cd5c62aaa23
|
File details
Details for the file cheshm-2.0.0-cp312-cp312-macosx_15_0_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp312-cp312-macosx_15_0_x86_64.whl
- Upload date:
- Size: 33.2 MB
- Tags: CPython 3.12, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e23f2c3126f1b247992189b1008d788e5d571629bb722b400bd4b73ddadbea67
|
|
| MD5 |
22d84d86c004d4705aa58d260e85ff0d
|
|
| BLAKE2b-256 |
f9da4109d734403573a2a361fa1b8f4f9c05e3e69af23a4f8f38b86e9e5b75e4
|
File details
Details for the file cheshm-2.0.0-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 15.7 MB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de0d6f4abe065f98185726901ed1e2bb4a4d4dcf57014d3f967ce88c514bec5
|
|
| MD5 |
0f0a72cc48056acb5a04eb840b07f8ce
|
|
| BLAKE2b-256 |
c66022a44faaabbceffeec54d708c2cdfc9f5d9c9b25664e1cd6a58f2ad7f262
|
File details
Details for the file cheshm-2.0.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb186a59e39ecce9df602cdfa6d7616d7af7c71fa2b9152f5eac3575a5851db
|
|
| MD5 |
e59a2a5356bb90f1c2d84660a612b89d
|
|
| BLAKE2b-256 |
101bbe4572d4df6904066a53289b9e7745dc30d558874a988eab27531a055525
|
File details
Details for the file cheshm-2.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 21.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
436f73e382d5d5185ffdff1a5a24d7ecdb9f10783cbadc4d0339d7c06b35c0f5
|
|
| MD5 |
efe9b47327324c882f3b814ff6f308dd
|
|
| BLAKE2b-256 |
c9beeadb70dcc25b4b0098ca20d07f2acb0ffb51b95e2cca74d181c80a5ee691
|
File details
Details for the file cheshm-2.0.0-cp311-cp311-macosx_15_0_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp311-cp311-macosx_15_0_x86_64.whl
- Upload date:
- Size: 33.2 MB
- Tags: CPython 3.11, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
601060a8dc1c6815c92d9ffd54a9186a9ac0ecdf5adcbf5848f63993e71d45c4
|
|
| MD5 |
a095a91925adb238924a961fe14c91a2
|
|
| BLAKE2b-256 |
df3973650b8265c3a389c90676de5826044ebd12f2aebc5ea41dee86901b6997
|
File details
Details for the file cheshm-2.0.0-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 15.7 MB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aa1d64818e012bc2a661332bfc7ad72841045684beb50058ab082d2dcaa2b1f
|
|
| MD5 |
ca0661799d848fa18b21b11510f39824
|
|
| BLAKE2b-256 |
14f9cb34884bf9c1bc6a09321d3f84dfa660a9a9439d1b46a4d49d8a3e61be4d
|
File details
Details for the file cheshm-2.0.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7884bf112d06d8556ea9709af91873107ed4f34a2b56ca4cbaf176da0268104
|
|
| MD5 |
051645e108396268742bdfafe374491f
|
|
| BLAKE2b-256 |
cb8690fcd6ecf66f89527547a2b90faf5c740c80f49761586caa7d72b938ffbc
|
File details
Details for the file cheshm-2.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 21.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb18d412353b25280474daaac2aa5bbd6b5f5db973452d438535ec26e100ff10
|
|
| MD5 |
0c7d00aa9877713912175f0aff9b1717
|
|
| BLAKE2b-256 |
d10e0db276e88cfc1742805be1620aecd314dd43c4685415145252837364f673
|
File details
Details for the file cheshm-2.0.0-cp310-cp310-macosx_15_0_x86_64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp310-cp310-macosx_15_0_x86_64.whl
- Upload date:
- Size: 33.2 MB
- Tags: CPython 3.10, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2fef6eb74802ab34fde60a0ea19cc6a0176cd706830f2588370d4bccd64cb5d
|
|
| MD5 |
55c67cfa735bc40e1c6ab540b71ac571
|
|
| BLAKE2b-256 |
2f6d7aecdf29886158d9205186e9120f17492cbd24caa24f2d74cf75a80ef3ec
|
File details
Details for the file cheshm-2.0.0-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: cheshm-2.0.0-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 15.7 MB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a1031603761b1bb6182c868dcfec7a48ececef9d32fd333cce1bac313f8040f
|
|
| MD5 |
b173d73132a780e8a5b964289ebb2940
|
|
| BLAKE2b-256 |
0ebf16cdad8c5e8be57c9266aba1579e35d4165797cffb6c424d0a03085b87ac
|