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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 15.0+ x86-64

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

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.4.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.4.0.tar.gz.

File metadata

  • Download URL: cheshm-2.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 0f0e9cc834b5552644ed757bab18c63403660f6fb8c47bb305101106f1d4915a
MD5 9a8c7ef32a8f4ca223d4aa4499ce41f5
BLAKE2b-256 9a235f863b26d95d6bbc85669895f453c73819e9e068b3316dace9d30c546793

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.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.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4491afa24f30f6a5822258890b970266e5ed1db3e9602be4b4fe98a8be31ec20
MD5 b21f9bb0b3b531c8ca346d7d0e9939e8
BLAKE2b-256 bfed76f47363f80799ae46250d6823ce5e092bacac8a55b6a4819e902bea3776

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 be22173f39dc84cde5af7114a4e3ce47372f73d80fff0229e5328dd7412ea4f4
MD5 7b280e81bb571642ebc152bba7d30353
BLAKE2b-256 b1e7dd657cdbde87479e0884a51e57dff68186642c9ec3b95a6ae78ce34e1ab1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 f32bb91d93f923cbc85e86b0a1a855168445d7137c9e37afde4b045fe60076e0
MD5 c32d6bb3168948400835e58bd5cd73dd
BLAKE2b-256 154dc9c80e0eaa655c9255f0ce252d34e01af36fdad639a80db70b1f519e695b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e6bea2bd4ddefdf4bfb250c20fe2e835d6b5c3c10819bbce421d229a7b971d66
MD5 c30026055bdf175d65faa15a2f44c60c
BLAKE2b-256 b0a911dfdc4ab4924466d7d9641e4e5aa9e9449f3128da5e53fae41387aa726e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.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.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 665a03ee68e3a3925ca488f53239ab70f45e41771e538a1e5238ca544634120a
MD5 b9dbcfd6aefe880f22fb3e6ee5b82ebe
BLAKE2b-256 6164e796555ba1e22351006798978ef65f790df918d65a850094ac5a75f18c35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1e4944db55bb382e7fb094601c72579c0ae5f8070074cea33b3f629639bfd9b4
MD5 41c31e2c717d1e6e7b3689888d312b7d
BLAKE2b-256 54ad5a2c86e040e985a420315e3ea165e5a5c13e499f8888caa1c67f1358d6c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 6de2a617b3eddd7acc9f68e73fc8b0c1f784c1108258ab86cb8399982acf44f0
MD5 74ef7597a496bfd024505d14ecb51d44
BLAKE2b-256 9bb241af1725591257a8631b3926744544f1b2ce399a74b8dcc548535c375c27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 714ba3914d6bb849b753c79ff69ccb39dd72fc48b160db7f013828503cc42a8c
MD5 92a7de5ede82b8c25e146467572a3155
BLAKE2b-256 542421596baaffa7135b28564efc267a33e445fc2e000ca8b1447f89d86c0113

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.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.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bc1d0dcdd66c4f98ca095672139494351a484e057f655ca8602b96f3ee065357
MD5 12bce8d1fa5670f2c7c315c10eb196ae
BLAKE2b-256 840226777a9bea528b2821260424adb70200e5d7f8c8e8fecce45d244207fdd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c093ed2800abca89c4b9c1f8d242aa840e3e712ee0e06baea5b4f8df77419cc4
MD5 32953c2883c80168612e08274db9969a
BLAKE2b-256 73796028b769cf4e7f989fd38a69cef71beb1e9a9279cb13d21a747d2b446b64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 cff8d387eaa10cb01ff117accfebd69267cd2c93cf440bec0767cf50054e0f05
MD5 e4d60ef11d7f29be3c8cbb36fedac96a
BLAKE2b-256 fb12477cd5975a6def647a98ea44899f58eb6f106001ac773480e860d65f00ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a28e81ddff25779bc6b6655bd814bbfb7e714082e0239681168e4404193f0843
MD5 a4eee60ba36f9187cf0f6b20ca0532f3
BLAKE2b-256 7c307a091874cf0769f97646058720cbbe36923b03bfe9392400d09ef54065a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.4.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.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 61290130f8d22255c570b3eefec889928163b4ba7a1852a679809aa1762623f2
MD5 7139b81fb8fc42f8cb58c0bf4fd445fa
BLAKE2b-256 38ceeb2d2252fb318408a41f8fa973313447367ef08a15bb0a1eeb6456157cb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7f548f44b1175c9d75a7d67a4ba549ece1618f7b2fb468057fc340ad107426c4
MD5 403ecb121bb8a362fc21a0f81e3442a4
BLAKE2b-256 c3eca9f088a722499d6924d3ecf9f10712a3eab04864d81dd7c5a75391729f19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b0cadd162e85b6f7c4bc5d64410702422000c36e7515c1162e940d261968db02
MD5 c35ee80a940f33dfd988e22f276bef93
BLAKE2b-256 35f202236dadf9d11fc0bd377bd4069e177424618e9107191f5e8bbf2b0e6599

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.4.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1dad1794a4a5b0dfe7bb3887614796ca9ff4e5e3d46d549d4576c59daef42c81
MD5 7b221249a5c1595dcf0559ee6336a60b
BLAKE2b-256 17edd7dba538d2e5fade91683a022088b3a65b67b8631c91c81dce233dd2545e

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