Lens distortion using the spherical distortion model
pip install git+https://github.com/dompm/spherical_distortion.git
from sphericaldistortion import crop_panorama, distort, undistort
crop = crop_panorama('data/pano.jpg', # panorama or path to panorama
height=900, # height of the cropped image
width=1200, # width of the cropped image
f=830, # focal length in pixels
xi=0.75, # distortion parameter
az=0, # azimuth of the camera in radians
el=-0.35, # elevation of the camera in radians
roll=0 # roll of the camera in radians
)
Pano | Result |
---|---|
![]() |
![]() |
distorted_image = distort('data/straight_crop.jpg', # image or path to image
f=320, # focal length in pixels
xi=0.75 # distortion parameter
)
Input | Result |
---|---|
![]() |
![]() |
undistorted_image = undistort('data/distorted_crop.jpg', # image or path to image
f=830, # focal lenght in pixels
xi=0.75 # distortion parameter
)
Input | Result |
---|---|
![]() |
![]() |