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

Uploaded CPython 3.13Windows x86-64

cheshm-2.1.0-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.0-cp313-cp313-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

cheshm-2.1.0-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.0-cp312-cp312-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

cheshm-2.1.0-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.0-cp311-cp311-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

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

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

cheshm-2.1.0-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.0-cp310-cp310-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.1.0-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.0.tar.gz.

File metadata

  • Download URL: cheshm-2.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 1dc949d1acac741fcb683bfb206328ad36f71dce88cb2d4314a6e81baa2a41ad
MD5 a6c65e09a993b096ad5b001a7085bdbe
BLAKE2b-256 dfc99d74bf5f3c9ebc53e8d0c6e11d4c14c4cc3968e326f234f8ad7b3f3cfa9b

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 622cf0dcc508e1ad28a1815f6fbd515461fde3a53dc5d4241e5aae256f1adfc1
MD5 abeab4d400005b78e5485ff044ea11a7
BLAKE2b-256 e9b8b51a8f6b8ba55692e714788af05f4deace759f031cdfb00dc45de1c2dd73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 25ef2ad433fdf69c370683c1489cd0da84f0672380f110658a5a3b4611e29d0e
MD5 0ad3f4afce45bf2f04565c9f6b7d09a6
BLAKE2b-256 da37ec37236f471ed00bcf2f4916f95bd5acc68d5d84653319c9693d5d483df1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 76b756ed7ed6add5f99da738ccf0f01bf0f3d00179fc3e11756aa45a135ac6b6
MD5 3a8e55207668039d8a7757e0ce7251b2
BLAKE2b-256 4e9d1b097a84a067dc0a4dcf123ee85b8a8c2f0b77cef908b079c693ab494587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 01367308ea0c8b941fd53ae310fe5d68e5ceb4ddcbb81b2bbb5aa52fbad00cce
MD5 b9cb12a77e3d687c3d8a481ddf0dad39
BLAKE2b-256 69a520d80efcca0f3e84e99a99e02b2383a36a1c95300fdbe931896013221672

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f358ad7faa42b2aaaf0e3829c9df8f61b4756fb3b08ea3b2c510a39ac663f9e3
MD5 6bfa9d30a412102d622a6436517aaba5
BLAKE2b-256 4648e30aaf315d4206b06bc23466bbe29bc626ec8d45aeea941348ebe062c741

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0fb6fd748e85eaeddd64331793e393f53a342d6b50fff3d1f2c77851e2c2f680
MD5 95ec6deed0807aaa1249d2436bf5e762
BLAKE2b-256 f39ad19c9b36b31bc5b8348520c9ef7f27daeeb55e14f951e37b9da675e602c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 38c29c8f070bac6928f2d9578ba8cb9e74124aa7d06f0518d0d6d30d18a8662a
MD5 99e920042048290e5c8d0784f5235955
BLAKE2b-256 a9ea241a0240647be82e7c9c517e57b55693494f6a63814a03cb35802fd5b6f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ac0c70ed5e8d07a11df1d9885e11518d84c292946dc6f9a4a4e092e353307aad
MD5 40e6afd83622099953278d5d31fba957
BLAKE2b-256 aa576ef73d0730866f2617eac06c5fe278661f6727c01d0c708d3a6744752710

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 06c94ec1f20fa0d4b35203ae79797759cb5b6413485bfb5e526e8e989f13b5a4
MD5 37b77a5b5477fb189a6600f508c18a2a
BLAKE2b-256 e928ea92071b6599376ead1dd70469f81a7dacb90522d507c4193673292d513f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 dca86bd2d4b67c35ed24c599eea102ec17368696cedaf88fa997fbe6f9618386
MD5 54037acf51a3babbaa1b3dbdccad4c24
BLAKE2b-256 1bc91125364a05d757e5f0e50f1675e0a5050a14765b761a12beeadd1ec072f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b858d47e46672969350e0f6584e23f6b4a46480a7f65618ca547a5231b39e69e
MD5 7f992b81f2192a398bc14b9165fdf689
BLAKE2b-256 b69a8b282bf49cd2ecc543228078cf38a5a1f5b0ff2f4d9a451ca85f68b668ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a35e895ee1bc0960741dac5b4b68b8c412e12030c5e924acd77104a2f338c1a6
MD5 c2e696e0d3413c9240b9077221d633b1
BLAKE2b-256 cda21e25b39bbd0a6314da874e08d02c94fb8ebc28c8dcf6b02e2d4471dcda9f

See more details on using hashes here.

File details

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

File metadata

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

Hashes for cheshm-2.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 82e9030aa2ab63cc9f352039b4470338eabe51146faebca5da9ab1a2bd3b8649
MD5 32524bc83f31862fda8dc20ece5d7570
BLAKE2b-256 86548ccb559ad30b649741b25e9882cb3bb8a9ef7d4cc0dd5cb1654a4b99d2df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6fefd4ad97d70632778a7f95de69baccfdd8279276297a66bde77f47fd10a491
MD5 102606b2517082f2d150f2bdfc9adb83
BLAKE2b-256 f328eb3161af60144daac3e74c5550799c903ef9d6a60073f2cdf4dac6e13c74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 2cbb8c6106a8726b4501e47e51dd193873f91b27c3dd7a485b37afd5e9889819
MD5 7f96ab65395973b8444459b03a727993
BLAKE2b-256 2ef410dc96a882485344088c8051f25519e2ad3b88bcf334ed8ee8fdf429cbf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.1.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e5939c443d9c47b938469548a4a9129966ee563d781871c394243fb888505d8b
MD5 08cbcf6f98f540ae5d77e16b64c48ae8
BLAKE2b-256 d56e7c3eb8dc91d13ca67b0c4411b23e43be80ec25a1cae7f7e8c450bbcf677f

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