Skip to main content

A cross-platform, compact GUI application for the optical distortion calibration of fluid-immersed endoscopes.

Project description

endocal is a cross-platform, compact GUI application for the optical distortion calibration of fluid-immersed endoscopes. It uses the OpenCV camera calibration module.

endocal was developed by Dzhoshkun I. Shakir as part of the GIFT-Surg project at the Translational Imaging Group in the Centre for Medical Image Computing at University College London (UCL).


  • Lightweight, compact GUI application for optical distortion calibration of endoscopes

  • Command-line application for generating ASCII DXF files for use in calibration target fabrication (translatedfrom Matlab scripts developed by Daniil I. Nikitichev)

The detailed changelog is available on GitHub.

System requirements

  • Python

  • pip

  • OpenCV (installed with Python support)

  • For live calibration: a video source supported by OpenCV (see esp. the OpenCV tutorials related to video IO)

  • PyYAML

  • NumPy

  • So far endocal has been tested on the following operating systems:

    • Ubuntu 16.04.3 LTS 64-bit

    • Ubuntu 14.04.3 LTS 64-bit

    • elementary OS Freya 0.3.2 64-bit

    • macOS Sierra 10.12.6

    • OS X El Capitan 10.11.3

    • Windows 10 Professional 64-bit


Installing endocal

pip install endocal

Testing your installation

  • Launch the test application by running endocal-test.

  • This screenshot shows you what to expect on launching the application.

  • To perform an optical distortion calibration, follow the instructions shown in red on top of the application window.

  • While acquiring calibration data, detected calibration pattern blobs will be emphasized with a virtual overlay as in this acquisition-mode screenshot.

  • All data for each calibration will be saved in a human-readably time-stamped, uniquely-named folder within a root folder named tmp-sample_002 created within the folder where the application was launched. For instance tmp-sample_002/2018-02-08-11-03-19-AHDHO for a calibration run on 8 February 2018 at 11:03 am. The saved data includes:

    • A YAML file named calibration.yml with the computed calibration parameters

    • Frames used for calibration saved as indexed image files, e.g. frame_009.jpg

  • After performing a calibration, the application will automatically show the undistorted images in real time to the right of the application window as in this undistortion-mode screenshot.

Uninstalling endocal

pip uninstall endocal



endocal --help shows details of what input parameters are expected. Some examples are provided below:

  • Offline calibration by using all frames saved as indexed image files in a /data/offline folder:

endocal --pattern-specs 3 11 3 1 --output-folder ./calibration-results --input /data/offline/frame_%03d.jpg
  • Live calibration using a real-time video stream from an endoscope provided by a frame-grabber (assuming the frame-grabber is mounted as /dev/video0):

endocal --input 0 --pattern-specs 3 11 3 1 --output-folder ./calibration-results
  • Using a 700 x 700 sub-frame of the whole endoscopic video frame (whose full size is e.g. 1920 x 1080):

endocal --input 0 --pattern-specs 3 11 3 1 --output-folder ./calibration-results --roi 620 200 700 700

ASCII DXF file generation

dxf --help shows details of what input parameters are expected.

For instance to generate an asymmetric grid of circles each with a diameter of 1 mm to be etched by a laser cutter with a beam width of 45 μm (microns):

dxf --laser-beam-width 45 --diameter 1 --output-file output.dxf

Here the grid is saved to file output.dxf and the corresponding (ellipse) legend to output-legend.dxf (legend filename always inferred from main DXF filename).


Please check out these hints in case you encounter any issues with endocal.


This work was supported through an Innovative Engineering for Health award by the Wellcome Trust [WT101957], the Engineering and Physical Sciences Research Council (EPSRC) [NS/A000027/1] and a National Institute for Health Research Biomedical Research Centre UCLH/UCL High Impact Initiative.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

endocal-18.2.13-py2.py3-none-any.whl (5.5 MB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page