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.4.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.4.1-cp313-cp313-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.4.1-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.4.1-cp313-cp313-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

cheshm-2.4.1-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.4.1-cp312-cp312-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

cheshm-2.4.1-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.4.1-cp311-cp311-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

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

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

cheshm-2.4.1-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.4.1-cp310-cp310-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.4.1-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.4.1.tar.gz.

File metadata

  • Download URL: cheshm-2.4.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.4.1.tar.gz
Algorithm Hash digest
SHA256 becedc2121e3fef6983e2d1a562f61ef94d3a4cd78bb4367ebdeaeaba110da2a
MD5 d9f5fedd3d843e923f08bfa4291b9326
BLAKE2b-256 44f3e55143314fdf6525ccb99aa04b31804a7325ef62657c12fe9051dd27d920

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.1-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.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ff41043e98a61a6390da2bcc8e9e9ca53651674b50ab8568364cfbee36715341
MD5 ceb0fd6f6eeae14265a8111fb91d5bad
BLAKE2b-256 0095fc2c05bef03100ba36764a570e8483d5159943bd02787848a542fb26dd54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 54bf157cc30ceea12805899ad15433c7f226ae24e716bd4f38cd5f51cebfe990
MD5 16f35616a3b1910d2f1b7f88b1100e05
BLAKE2b-256 1fcf51a2e1c494447bb9f63f7380d53957af3816f974979a838241db6adf941f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 35bc4cc973da41c0a08871022f4a3bee48146f921c6355e9820a4499869e95dc
MD5 5b6d900b9818c4818a4ca6ba8bd544d7
BLAKE2b-256 e741f1bfe6e01d1c02bc16953d1682a9c9572551d2654cf4d8edbb9dda95a60d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b9c6dbbe97d47e8852dcbe21d48fdd6eb029693f56553919e63c82db4dd60bd8
MD5 632a46dec6fd4731cb59a7ebda65f700
BLAKE2b-256 260c113fc508d309b191fe20d497d5f843a01f836d8e7acef64b70dae64e022e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.1-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.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 09288bac879bb604143563fc8510cb4229ecd51780df425450fb403da18ae549
MD5 beac1c3acada554d5317b1339a914fb4
BLAKE2b-256 4b2cc31360664bece80a4d77bf6a6afbbae8ab63ee660f2423f178831034c7b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7e0c5c5018c7699ce578edf812fa0eb95961048108214f1d6d2a270e08389dbd
MD5 c3dd4699e9e804ca99d3c7c0788daf58
BLAKE2b-256 569f4d1c817dc00de7e33d7934514f2fe45b0349c1cca8b909fe9489be29882c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 3f79e361ac6d89ba1cf1657faee2abef9bc5f15d247631c26920f728f229614c
MD5 47ebf280cb19e30db79ee06b99cf510d
BLAKE2b-256 e09da852941d308e0dbedb423909ba52c18e0649aa784e7692e70455ff267c13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4e53f6ad9560bbc0e64f9a06abc752ef203dadaa77ec946df25dcb6587eb76aa
MD5 02e023f9b2b9b4769250e155a20c4bf9
BLAKE2b-256 05fd248c6c1e23052d2246ab189006d12b81b6e8093c5d360a543bd0219d13ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.1-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.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b85c02069a8abf8340cb5e2884aa90cfbc601dc16f96595fc8301c9975d65c7a
MD5 96c245e66b9189fad1757cc360e3050d
BLAKE2b-256 87012c3bcbd1e986e82984122371f853713a8e824308d0f5faeca86113175d17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 44dd00d1bd7e406726ef5a80acf72dd3c2e066a3a60037f61b813044e4eb54e4
MD5 d7b017ab0b50d29de854055df11a996d
BLAKE2b-256 af94041c37d351faa53c515c30d688ec8bbfad524816edfe5f3738ef03329340

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 c58dda02e01b7a5917824428cf78f49fd610c263e949bd1c7769fd189c2fc482
MD5 8133808cbbdda5e8de5fbdf1602bde76
BLAKE2b-256 22dda3afde30ecc136ae054ce5377dbbe8253d98ab851ceb1789c177067b94a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d5ba998c16b327fd363a2a84a03df43826380029a39b46c588b25c4d677f89b3
MD5 82af56db6b37c9864911357afefbbacf
BLAKE2b-256 a519076ac625d7cdcbde68fa6c737f8c1b8506a25518362e00787a8feb99dcdc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.1-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.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 54206de6fe8b0c19d845e2033ab2368aedc8bb128aaf030892d9a687689bc969
MD5 3e6b2536b6d0639a6aa72e83456cbb5e
BLAKE2b-256 da28e549b6b0ee794312f32ec1f660f547459487ef362c8e7b2d1573c97f076a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 06ee38d72f40d196fdb27c140a56615a4706d1f890adf8fd1e47f8f6569d28b1
MD5 6092b69064ca884a8f88ff0c65d2c60f
BLAKE2b-256 8dafdb9e8aa91d2e549b705346167865c0356b3dec6eb0b148f4e39559bad9a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0e80ffc6b5aa72d1c1e694e12775a661f6de81fdfd463c3dea7c0891432e499d
MD5 37a46cc27ead02c9b249588fbcad7ac8
BLAKE2b-256 7dc4f9047f68b0a2527007a7805d84ea131aa2824d9c71cc853bc4d133ad2f42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7e0134ed03dba6aaeaf2fca39a29a3aa058b802df90ca31f06a71b35339eb03f
MD5 9590788f1ebe6540c2ab156cd10a3ccd
BLAKE2b-256 e8f66045667465e946ca3ea3e10c21fed8d23f9e49c61815b318844d65fd4486

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