Lens Distortion Correction (DeWarp) Plug-in
Overview and Features
The Lens Distortion Correction tool is a DevWareX plug-in. It is intended for use with the MT9V126, MT9V128, and ASX343AT System on Chip (SOC).
The Distortion Correction tool can be used to generate Distortion Correction configuration settings for wide angle lens sensor module. It provides:
Wide angle lens calibration tool
Image Distortion Correction configuration tool
Perspective correction configuration tool
Miscellaneous: Import/Export configuration settings etc.
Simulation mode which enables the user to apply distortion and perspective correction settings on static images.
Basic operation
To start the Distortion Correction tool GUI window, follow the following steps are:
Run DevWareX, go to the main menu->Plug-ins-> Lens Distortion Correction (DeWarp) Tools and the Lens Distortion Correction (DeWarp) Tools dialog is shown as follows:
Fig. 1 Distortion Correction DevWareX Plug-in
The tool can operate in one of two modes: SOC Hardware or Software Simulation. In SOC Hardware mode the process of correcting the lens distortion and adjusting the perspective of the image are done by the system hardware. In the Software Simulation mode, these processes are done by a simulation of the system hardware by DevWare. In order to operate in SOC Hardware an Aptina Imaging Demo camera has to be installed connected to your computer.
When selecting one of these modes, DevWareX will automatically switch the sensor to the output format which corresponds with your selected mode. For SOC Hardware DevWareX will set the sensor to output Dewarp+Overlay CCIR656 Interlaced image. For Software Simulation DevWareX will set the sensor to output 640x480 YCbCr/RGB Progressive image.
You can also change the sensor output mode directly by clicking the Control button in the DevWareX toolbar, which brings up the Sensor Control dialog. In there access Digital Video Output and make sure 640x480 YCbCr/RGB Progressive is selected if you want to apply Distortion Correction settings to DevWareX software simulator, Or Dewarp+Overlay CCIR656 Interlaced if you want to apply the current Distortion Correction setting to sensor.
In Software Simulation mode, the Distortion Correction output format can be specified via Format: in the Output Mode group. Three modes supported: NTSC, PAL and Progressive. In SOC Hardware the output format is determined by the sensor settings and it can be modified by the DevWareX sensor control pages.
In Software Simulation mode the Distortion Correction effect can be seen more clearly by selecting Circle Overlay, ten circles with different image heights will be shown on the current frame sensor output, check Enable and you can see what will happen to those circles after Distortion Correction processing. Check Open picture-in-picture if you want to see both images before and after Distortion Correction at the same time. These options are available in Software Simulation mode only.
The Distortion Correction Tool provides a default distortion correction setting for the Marshal wide angle lens. You can import a different setting by click Load Settings… or save the current settings for later use by click Save Settings…
Use Save Data... to save only the Calibration Data. On the Timiing, you can use Write to INI file... to save all settings in a DevWareX INI file format.
You can find default settings which come with the tool in the folder
<installation-path>\Plugins\Default Lens Correction
You can apply the current Distortion Correction tool setting to either the software simulator or to the sensor by clicking the corresponding radio box at the bottom of Distortion Correction Tools, and then click on Apply button. If Software Simulation is selected, make sure Enable gets checked so that the new Distortion Correction setting can take effect in the DevWareX display window.
Lens Calibration Tool
The Lens calibration tool supports two modes: mathematical model based calibration and measurement based calibration.
Measurement based lens calibration
Check Calibration Lens to enable measurement based calibration. This mode allows the user to capture a set of images and use the information to create a text file.
Hardware/environment
Computer with two monitors with each monitor on a separate table are required, one is for displaying target images and the other is for DevWareX operations. Two tables should be used in order to minimize the table vibration during image capturing. The vibration needs to be less than 1 pixel in the sensor.
Other hardware includes Demo2 system with fine adjustment for height control and SOC 360 or MI360 with a wide angle lens mount.
The key issues to consider are [1]:
The monitor must be normal to the optical bench (no tilt)
The camera must be parallel to the monitor
An accurate measurement of the optical center of the lens is very important; the Cross-Hair image target can be used for this purpose.
An accurate flat-fielding of the image, make sure the experiment setup is not touched during image capturing.
The illumination of the room can be controlled ( lights need to be turned off during data collections)
Workflow
Specify the directory under which captured images will be stored in the edit box next to Images button. Or click Images button to browse to the target location. Enter Lens Name, and it will affect names of all captured images (ex: Largan).
Four target images are provided in this process:
crossHairWithLensFallOff_9Rings.bmp; captured image crossHairImage_largan.bmp
radialRingsWithLensFallOff_9Rings.bmp; captured image targetImage_largan.bmp
flatFieldWithLensFallOff_9Rings.bmp; captured image ffImage_largan.bmp
In this mode, seven steps are required in order to complete the procedure.
Click on Load Crosshair Target button, the cross-hair target image will be displayed on one of the monitors, double click to maximize the image.
Adjust lens focus; adjust camera height so that the image of the crosshairs shows up as straight lines at the center (co-ordinates [319,239]) of the DevWareX display. If it is not possible to adjust the camera so that the straight –lines line up the center of the display, then the optical center of the lens is not at the center of the sensor. Record the values of the horizontal and vertical co-ordinates where the cross-hair lines are straight (from Devware) and enter them in the Horizontal and Vertical edit boxes respectively, click on Capture Crosshair Target button.
Click on Load Flatfield Target button, double click to maximize the image.
Adjust DevWareX gains and exposure so that the average intensity in the image is around 200 digital counts and no part of the image is saturated. To check the average digital count, draw a graph through a column / row near the center of the image. Make sure aperture correction is disabled in Devware. Click on Capture Flatfield Target button.
Click on Load Scene Target button, double click to maximize the image
Click on Capture Scene Target button.
Click on Calibrate Button to initiate the distortion measurements.
Please note all the finished steps will get checked so the user does not have to do it again. If all the required images have already been captured before and stored at the specified location, you can directly go to step 7.
Example of an image of the cross-hair target, notice that the lines should be straight enough. See figure 2 (step 2).
Fig. 2 Captured crosshair target
Figure 3 is an example of captured flat-field image (step 4).
Fig. 3 Captured flat field image
Figure 4 shows an example of the calibration target image captured by an wide angle lens (step 6).
Fig. 4 Captured calibration target image
Notice
A grid line image may be used to locate the optical center of the lens. Find the point where both the horizontal and vertical line straight up and enter their coordinates to Horizontal and Vertical edit boxes respectively. Other steps are the same, instead of maximizing the flat-field image and the calibration target image display window; you may need to resize and move the window so that the tiny dot in the center of the image should be positioned at the optical center of the lens.
Fig. 5 Grid Line image