{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Correcting Lens Distortion\n\nThis example demonstrates how to use `UndistortedCamera` to correct for the\nbarrel or pincushion distortion often present in wide-angle camera lenses.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import datetime\nfrom arguslib.camera.camera import Camera\nfrom arguslib.camera.undistorted_camera import UndistortedCamera\n\ndt = datetime.datetime(2025, 3, 25, 9, 0, 0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Standard Camera with Lens Distortion\n\nWhen we plot an image from a standard `Camera` object, especially one with a\nwide-angle lens, we can often see the effects of lens distortion. Notice how\nstraight lines appear to curve near the edges of the image.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "cam = Camera.from_config(\"COBALT\", \"3-7\")\nax = cam.show(dt)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Correcting Distortion with `UndistortedCamera`\n\nThe `UndistortedCamera` class applies a correction based on the camera's\ncalibration parameters, effectively \"unwarping\" the image. The resulting\nplot shows a much more natural, rectilinear view, as if seen through a\ndistortion-free lens.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "undistorted_cam = UndistortedCamera.from_config(\"COBALT\", \"3-7\")\nax = undistorted_cam.show(dt)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.5" } }, "nbformat": 4, "nbformat_minor": 0 }