This is a tool for generating, tweaking and applying lens distortion correction parameters on videos captured with wide angle/ fisheye lenses.
This tool is based on the OpenCV library https://github.com/opencv/opencv and the CVUI lib https://github.com/Dovyski/cvui
To generate the camera paramaters (camera instrinsic matrix and lens destortion coefficents), take (10 to 30) photos of the calibration pattern in different poses. http://docs.opencv.org/2.4/_downloads/pattern.png
Usage : ./DistortionCorrection imges_dir
Example : /DistortionCorrection "data/patternImages/"
images_dir
directory of calibration pattern images.
CamaraParams.yaml
Computed camera Parameters.
This mode will launch an intaractive GUI that will allow you to tweak the camera parameters in the initial .yaml
file from Mode 1 for more visually appealing results. Once you are done with tweaking, press the space, escape or enter key to save the outputs.
Usage : ./DistortionCorrection one_image InCameraParams.yaml DisplayScaleFactor
Example 1 : /DistortionCorrection "ExampleData/image.jpg" "data/DistCoeffs.yaml" 2.5
Example 2 : /DistortionCorrection "ExampleData/image.jpg" "data/DistCoeffs.yaml"
InCamaraParams.yaml
- input camera Parameters.
one_image
- a single frame of the video to be corrected.
DisplayScaleFactor
- optional - display scale factor (use when frame size is too large to fit in screen).
CamaraParams.yaml
- Tweaked camera Parameters.
CorrectedImage.jpg
- Distortion Corrected image.
This script takes an input video and output directory and a .yaml
file, and produces distortion-corrected images.
Usage : ./DistortionCorrection CamaraParams.yaml inputVid Output
Example 1: ./DistortionCorrection "CamaraParams.yaml" "data/in_video.mp4" "data/out_video.mp4"
Example 2: ./DistortionCorrection "CamaraParams.yaml" "data/in_video.mp4" "data/out_images/*.jpg"
CamaraParams.yaml
- camera Parameters file (generted by mode 1 or 2).
inputVid
- Input video to be undistorted.
Output
- If this is an .mp4
file, it'll write a video stream. If it uses a pattern like directory/*.png
or directory/*.jpg
, it'll write a series of images.