.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/undistorted_camera.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_undistorted_camera.py: Correcting Lens Distortion ========================== This example demonstrates how to use `UndistortedCamera` to correct for the barrel or pincushion distortion often present in wide-angle camera lenses. .. GENERATED FROM PYTHON SOURCE LINES 10-16 .. code-block:: Python import datetime from arguslib.camera.camera import Camera from arguslib.camera.undistorted_camera import UndistortedCamera dt = datetime.datetime(2025, 3, 25, 9, 0, 0) .. GENERATED FROM PYTHON SOURCE LINES 17-23 Standard Camera with Lens Distortion ------------------------------------ When we plot an image from a standard `Camera` object, especially one with a wide-angle lens, we can often see the effects of lens distortion. Notice how straight lines appear to curve near the edges of the image. .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python cam = Camera.from_config("COBALT", "3-7") ax = cam.show(dt) .. image-sg:: /auto_examples/images/sphx_glr_undistorted_camera_001.png :alt: undistorted camera :srcset: /auto_examples/images/sphx_glr_undistorted_camera_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 27-34 Correcting Distortion with `UndistortedCamera` ---------------------------------------------- The `UndistortedCamera` class applies a correction based on the camera's calibration parameters, effectively "unwarping" the image. The resulting plot shows a much more natural, rectilinear view, as if seen through a distortion-free lens. .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: Python undistorted_cam = UndistortedCamera.from_config("COBALT", "3-7") ax = undistorted_cam.show(dt) .. image-sg:: /auto_examples/images/sphx_glr_undistorted_camera_002.png :alt: undistorted camera :srcset: /auto_examples/images/sphx_glr_undistorted_camera_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.512 seconds) .. _sphx_glr_download_auto_examples_undistorted_camera.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: undistorted_camera.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: undistorted_camera.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: undistorted_camera.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_