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.1.1.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.1.1-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cheshm-2.1.1-cp313-cp313-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

cheshm-2.1.1-cp313-cp313-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cheshm-2.1.1-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

cheshm-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cheshm-2.1.1-cp312-cp312-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

cheshm-2.1.1-cp312-cp312-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

cheshm-2.1.1-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

cheshm-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cheshm-2.1.1-cp311-cp311-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

cheshm-2.1.1-cp311-cp311-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

cheshm-2.1.1-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

cheshm-2.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cheshm-2.1.1-cp310-cp310-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.1.1-cp310-cp310-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: cheshm-2.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 39caf6610492346d5b079dfc7f4c8ae890de955f9e960061432969ff92ff9b5d
MD5 08f6b3e9dd549c6a6e7cb87e5235dc47
BLAKE2b-256 73f47135b40e18462a0cccf6cd94ae7ae1859c5cbd5fd9d23149e6c93c36c74c

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 27bb8b02834eb195a01edd4c166a9f63283c83aa2fcefb451046bcb4a802c0aa
MD5 154b323c94929711230503e5683e977e
BLAKE2b-256 e52fdceb3929358c67574ab75809b1d15f0104f456bccc13ec58a6ada50e3eb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9cc7cccbe14f1f0f403f0f89a6d1ce135e344235369fb0b6b2cacf6709ad059f
MD5 23fe63f34c96be1047ae1d0aa06d3797
BLAKE2b-256 4514a0c7d26186f6f8f0c479fa6ae72a2e16ce6ae9ceaf8abc5a99441abe462d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 4511dca8007c7dcbdc0e888868bdd6b10fa712c775f55f9460da67b72800b49a
MD5 c6fd8644eed1868e6acb9bd8f2555f45
BLAKE2b-256 abec6bc6c33c6bdf54d7b6831a6bfa8e170a5dc1456189bffb1b6f60a7682225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f2a0b49d41a2ba44409f2d2e58d454bbdf930062682cdc9c23976bf7b5ce8711
MD5 d5f1db7ed69bd69e32f4b35d15bc2bca
BLAKE2b-256 55de42d7a1503fd3b378f51e1149e1186f62da72f35d92748d3246c532bc9597

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9c61fe4c946f487e8e935d41fa115a2390b1e1921c0ef5aecc1331580b74d535
MD5 2792d8ec744a9b75e2b441c3b985728c
BLAKE2b-256 7fea4681818e1c3ce69ed34f99ec580ad3e288c5865b973d1ce44e867407c618

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 5a1623c90fe3e8c7294ccc51148128f9b01d91859858a361c384626ef3394634
MD5 5e574ff6cf26afc781cc7e38d46ccf4a
BLAKE2b-256 f010b5ab7886026f804d6ae30079ad0696bf99db7fd638ca6d84cd582ef5043b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b3eaa19517990025b121c7d0a5c9d17ab9735a114ff1cd7c480e2dd841aafb13
MD5 34b78286a6fa9d871102c29357acb54e
BLAKE2b-256 afc458768fa38136acb9c5f76a48d2eb4f69585c72cdb3d2c904ea9593e7d7d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 26e9e4714397fe01a6adbcdc56e26f10b0f62fbc569a28060d6fbc52eab09406
MD5 d9354f7ca240877f0bc2fdcead04f718
BLAKE2b-256 eb43088194c82e1d64dfaf60b9107aab2ac26f2e0133b0731c792b6b12bdd766

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 17fe3dc0941650319d7b5a2d427b002f104f96cfaee4e98803048e3bcc4cf6fb
MD5 3ae82f9d63293a3e1e7423eab2e0b316
BLAKE2b-256 17967acb525e6eca3f9054aea68eba47645125853b9f8a88add0e2ab099f89a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2c260319e76dab498220b9d835221d51e62d274db0a2a2a19f3907a8eb06405e
MD5 439c93bb169addee51c87a3a85b6de7c
BLAKE2b-256 02334861d46c42b5b642cd85e01fd3c7a340752d4373ce870de663bdd52699be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 89ccb4a597e131a7ee76cf187e1176b8133e92a3fe903ceac1af859d31715490
MD5 c6c8bb1d2137624d48b800b005f86b03
BLAKE2b-256 0303a965184decbcf8973256820bcc287595ac134f72c6c4a01df4f5540dcf0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 393100b91a65f12c05a55c5e3ba9390dd36f513241a70a9aa91149b6b5d37dbe
MD5 88f27727b36d979522a0ad9c842929c2
BLAKE2b-256 b5f694f626b11b607e9ac11fc93e7f5e333c7800505cce7e804d16b9e92ee828

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fe30dd540364bf244ef99d60fa591df30a445649c525c6ef75f091fbf67177ad
MD5 d679043d4393cbc6b8e29ec10316eca4
BLAKE2b-256 8ffb948adf42faf4c67998100cc60b67bc8804c10346106a1635be994f23b2ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 859e7847c784af28d194fb38819dfa1b5af914ae5748b91c82df3ab786bd4c80
MD5 fe3cf0f957e2cf23ccde82274f9139a1
BLAKE2b-256 e25fdcb8cb61475d420248384251d084b3096b3a30c875dbbb17b0bc9676d848

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 08e03e364b3ec1e71ce351afbb289544d63edc5bfff4af74a9a700bbb6fbf177
MD5 1fc9f2f44821ff924260f8ccdf1a1a61
BLAKE2b-256 565f08098d4b3cdaa300598c867fefb99bdb20cf195ffbd26affa21b0479b8c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 995112ba0a96c907079d352254412c47da2d3313a94f94eaad84f94dc986c80b
MD5 08f711172f59142e64403567deed4dc1
BLAKE2b-256 207ec26e65ee368f189a49a3157d379bbfb333776038e64e45d3e9e93be55859

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