Skip to main content

Pupil, glint, and limbus detection on grayscale eye images, plus iris-texture rigid alignment of two eye images.

Project description

cheshm

PyPI version Downloads License DOI

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.

cheshm GUI

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 on img. style is 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.

Funded by EU Eyes4ICU

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

cheshm-2.3.0.tar.gz (3.3 MB view details)

Uploaded Source

Built Distributions

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

cheshm-2.3.0-cp313-cp313-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cheshm-2.3.0-cp313-cp313-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

cheshm-2.3.0-cp313-cp313-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cheshm-2.3.0-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

cheshm-2.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cheshm-2.3.0-cp312-cp312-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

cheshm-2.3.0-cp312-cp312-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

cheshm-2.3.0-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

cheshm-2.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cheshm-2.3.0-cp311-cp311-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

cheshm-2.3.0-cp311-cp311-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

cheshm-2.3.0-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

cheshm-2.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cheshm-2.3.0-cp310-cp310-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.3.0-cp310-cp310-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file cheshm-2.3.0.tar.gz.

File metadata

  • Download URL: cheshm-2.3.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

Hashes for cheshm-2.3.0.tar.gz
Algorithm Hash digest
SHA256 e7588ab3456809aa5d6d77c3e6d01cfdacfcbb7a1af20238340eaff0090387c9
MD5 887c68c6c8f45f2e1a74ba6f49592542
BLAKE2b-256 92a6fc77562e5bacd414892baed40d54f97bd31fd2e3925cc72098233bf0e8a4

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.7 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

Hashes for cheshm-2.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a27e1b9259ad0ec90b2af39544f360a15a45ffb9f01760c6ce3227d0b372f57c
MD5 394b414fd117959637a0f6273595fa66
BLAKE2b-256 111335405e2d8864b97e6c4c3a8092d6168d21a3243c049be87d43c974f8cdf4

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 434d8d87b35e19a732e0b12cdbf7a0c154f19e5a493081227596b36c69d8592f
MD5 33282805ed223d8858d6d519f539f1b0
BLAKE2b-256 db012f44df1430a94e6cb4159260368a76aa20ccef7b2811f67031c1d3ae1f8b

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 c3a636b91c5f18396c786433f493553f56acb79c40c55ec329009432def9de0c
MD5 650d2481a554b06ca619329f6d5f8af5
BLAKE2b-256 432192121846b741d506290a923350e8c18a552831e968e2349becfa91b34b7c

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 414634dffa71b1a80e46b864838be988872c622c07c78b9218b1b5dda0be6632
MD5 f960a30d76aa231d779f7f3eccd45bcd
BLAKE2b-256 acf49b4c57bd29a1126a2d00c4ee1b57760beb4668080d867feb439caa4bd76b

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 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

Hashes for cheshm-2.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bc31cf4c8ef1002cbc3d98597a5b66e1d3fc3a5fde66f61e8dbc0aba74b84aba
MD5 b8dc68f2343b5503e7a1e3f810a998b3
BLAKE2b-256 e546b0768532439a531b8dfd79999786a82ff7fe1cc3434ed120ea2db0288503

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c20b68cc45ed8e9c326b70be112e3d5130ed1fc703c3d228bff1b00e9b165dc3
MD5 eb7c1c6affc9bb9bb35a43858ad39951
BLAKE2b-256 568c421e196c88bd9d6d136069792385911117f1697b931f899249753954bd95

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b2623aa7b89b87aff31c1aef9dd77a6eae437200e4e6da3e7a1a033b8c79a39d
MD5 ad5179792d3e3bfbd2dac947fa80c95e
BLAKE2b-256 677d3765192affffffec6d73d3ce818db9a7ec65a484efc598469298098099b5

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f33a262fb3d795b94c0d4c640245348d59e7b84f72e8c6c1c88b337722e57698
MD5 32bc8d52b870dc3758fad687c36ac95a
BLAKE2b-256 b8c04463d04055ac91bff4f48a8c53ff9d0935c2d70d3cd8fc6d0f48a74d8484

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.7 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

Hashes for cheshm-2.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fab3ef30846b90a16d1e09025943895ae6043d5e5d31114ed8ef323628394110
MD5 0b37ef928250a0dbfb4046d28286b3ac
BLAKE2b-256 221cdadf51d75476532b05140814adaefb9fcc70a3460b7161a9dd724232cd43

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 80ab409027352693b5b495f4715363fd69f419022e88c618a9279cca88fc7b7f
MD5 9d653a3aecb118a590e37958f13a7b44
BLAKE2b-256 48161ad69383f7b12054522f9f89a022be5179757173e60d6eee3aed7b6ba69d

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 481296b5befd60b6a9849b81dd282bb2eb330705df1a3764be7a6999808f4a1f
MD5 63ff09ce7934795f9dbcc36eacfcae93
BLAKE2b-256 90414660300b9de5cc33f86bc9c02b5f53b76026b7a6982f401ab5d49281076e

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c19bc58b42a083c2f0a9ef4e3f1b2eb14dc6cf937d244d8e180dc454a896675f
MD5 dcad43afa4a5e7b08d4b895256ba6bb5
BLAKE2b-256 8c249412c74b494550be76ea733131451d343f8acde7eb150366eed4a52a62b6

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.7 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

Hashes for cheshm-2.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2b0be6e3b6b0607cdbea9d5f301141c7d970463627d1eac78d88184d868fd8e8
MD5 9acd41b1f4259cda0a79085ab0698308
BLAKE2b-256 d9aec4028f2fbeff80313540d14dce257fbe1f70fc233971a82dc1eb475308ff

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 72eca04c62a574190cf7d6bfeeb70b92ce2c39b97515be06988ef9d664eb2fef
MD5 05682092b6b448f1415a9b43caa432b6
BLAKE2b-256 75d1deea18ef0ed9e01a27496bd6684417bc0412312f6c34ba14a9482fb5d468

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp310-cp310-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 e82eb9a26973c9216eb062691816fabfd05037c095522e6de970ecddc52314d9
MD5 6d30b41e3ecf2ea49a2a56009252e21c
BLAKE2b-256 e9c315512b1525313968d5ac2e555b4ca6e8ff78b4fb7f08beb7aa05d0a10e00

See more details on using hashes here.

File details

Details for the file cheshm-2.3.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.3.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b86244ca06f77d9b3eb2e9979114f62c0032616a27b6bd3fdbbedc9e352f2a6b
MD5 5e81e130af112d8f2931a008b908a4ab
BLAKE2b-256 2f0035113d8aa5598fd78b29a0a86ad870b3e834be693c4749c12afb0c26f560

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