Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Lenscal DLL provides functions to quickly find lens correction register settings that will best correct the image brightness and color shading distortion caused by the camera's optical system.
The library supports all Bayer sensors with built-in lens correction, and most SOC sensors.SOCs not supported are: MT9V125 (SOC0354), MT9V111 (SOC0360), MT9V112 (SOC0366), MT9M111 (SOC1310) and MT9M112 (SOC1320)including SOC sensors.

Sensors not supported are: MT9P001 (A-5100) and MT9P006 (A-51HD-plus).


The input to the calibration is an image of a flat, gray field. The output is a list of the lens correction registers and their values. To get a good calibration requires careful setup of the camera system under test and correct use of the Lenscal functions and their parameters. Contact your Aptina field application engineer for assistance.
Two kinds of lens correction circuits are in use on Aptina sensors, what I'll call the orthogonal type and the polynomial type. The orthogonal type uses sets of horizontal and vertical gain curves added together to create a two-dimensional gain. The polynomial type uses a two-dimensional polynomial function. The calibration algorithms and parameters are different for each. The orthogonal type sensors are MT9D111 (SOC2010), MT9D112 (SOC2020), MT9D012 (A-2020), MT9T012 (A-3120). All others are polynomial type.

...

Here is partial C/C++ code to calibrate an A-3130 AR1337 sensor from a raw Bayer image file, and write the register values to a file in the DevWare .ini file format. Error checking removed for brevity:
#include "midlib2.h"
#include "lenscal.h"
void *lc;
CalibParams params = {sizeof(params), 100, 24, 1, 400, 300, 0.0, 1.0, 0};
params.nXedgeIgnore = -1;
params.nYedgeIgnore = -1;
lc = lc_Create(lc_SensorType("MT9T013AR1337"), 1, -1);
lc_LoadInputImageFile(lc, "capture0001.raw", 0, -1, -1, -1);
lc_FindSolution(lc, &params);
lc_DumpRegFile(lc, "lclenscal-MI3130AR1337.ini", REGFMT_DEVWARE_INI, NULL, NULL);
lc_Destroy(lc);

Here is partial C/C++ code to run a simulation of the A-3130 AR1337 lens correction on a captured raw Bayer image using register settings loaded from an ini file, and write the simulated image to a file:
#include "midlib2.h"
#include "lenscal.h"
void *lc;
lc = lc_Create(lc_SensorType("MT9T013AR1337"), 1, -1);
lc_LoadInputImageFile(lc, "capture0002.raw", 0, -1, -1, -1);
lc_LoadInputIniFile(lc, "lclenscal-MI3130AR1337.ini", NULL);
lc_SimulateCorrectedImage(lc, "corrected.raw", RAW_UNKNOWN, -1);
lc_Destroy(lc);

...

sensorType

The midlib sensor type value symbol for the sensor to be calibrated. See , from midlib2.h. You can use lc_SensorType() to get this value from a part number.

nRev

The revision of the sensor in case there are variations in the lens correction registers between different rev's. For A-3120 or A-5100 use 7Use 1 here since the sensor rev rarely matters.

nPolynomialOrder

Use -1 normally, or use 4 for sensors that use the polynomial LC system, 0 for all others. A non-zero value will force the library to generate a polynomial calibration, even if the sensor type uses the orthogonal curves system. The maximum value is 8. You can pass -1 to use the value appropriate to the sensor type.

...

szSensorDataPath

A filename for a sensor data file to use, or the name of a directory to search for the sensor data file based on the sensorType and nRev parameters.

sensorType

The midlib sensor type value symbol for the sensor to be calibrated. See , from midlib2.h. You can use lc_SensorType() to get this value from a part number.

nRev

The revision of the sensor in case there are variations in the lens correction registers between different rev's. For A-3120 or A-5100 use 7Use 1 here since the sensor rev rarely matters.

nPolynomialOrder

Use -1 normally, or use 4 for sensors that use the polynomial LC system, 0 for all others. A non-zero value will force the library to generate a polynomial calibration, even if the sensor type uses the orthogonal curves system. The maximum value is 8. Pass -1 to use the default polynomial order for the sensor type.

...