ISP Tuning Introduction

[中文]

Note

This document is automatically translated using AI. Please excuse any detailed errors. The official English version is still in progress.

Note

The ISP Tuning content below uses the hardware ISP of the ESP32-P4 as an example.

Why ISP Tuning Is Needed

Raw data from an image sensor cannot be used directly for display or recognition. The sensor’s dark current and defective pixels, optical attenuation of the lens, spectral response of the filter, and color-temperature differences of the ambient light source can all make the raw image too dark, color-cast, vignetted, or noisy. The ISP (Image Signal Processor) corrects the sensor data stage by stage and converts it into an image that matches human perception or the needs of an algorithm. ISP Tuning determines the parameters of each ISP processing module for a specific camera module and application.

Sensors fall into two types:

  • RAW (Bayer) sensors: they output only unprocessed Bayer data. Image processing depends entirely on the ESP32-P4 ISP and the esp_ipa algorithms. Tuning for the specific module is required to reach the target image quality. Examples include the SC2336 and GC4053.

  • YUV/RGB sensors: they integrate an ISP and can output a processed image directly. Tuning on the ESP side is usually unnecessary. Examples include the GC0308 and OV5640.

ISP parameters are strongly tied to the camera module and the application. The main factors are:

  • Sensor: black level, noise level, defective-pixel distribution, and the spectral response of each color channel differ between sensors.

  • Lens: the optical structure of the lens determines the brightness falloff at the edges of the image (vignetting) and the degree of color nonuniformity. LSC parameters must be calibrated again when the lens changes.

  • IR filter: the filter’s cutoff wavelength changes the sensor’s color response under different light sources. AWB and CCM parameters must be calibrated again when the filter changes.

  • Application: indoor or outdoor, bright light or low light, viewing by eye or machine recognition. Each case makes a different tradeoff among brightness, color, sharpness, and noise.

Therefore, even with the same sensor model, calibration must be repeated whenever the lens, filter, or module structure changes. Subjective tuning must also be repeated when the application changes.

Common Image-Quality Problems

Symptom

Possible cause

Related module

The whole image looks gray, and dark areas have a color cast

Black level was not subtracted correctly

BLC

Bright or dark dots appear at fixed positions

Defective sensor pixels

DPC

The edges are dark, or the center and edges have inconsistent color

Lens shading

LSC

White objects look yellow, blue, or green, and the color changes noticeably under different light sources

White balance is inaccurate

AWB

Colors are dull or differ greatly from the real object

Color reproduction is inaccurate

CCM, saturation

The image is overexposed, too dark, or the brightness fluctuates repeatedly

The exposure strategy is unsuitable

AE/AGC

The image looks gray, contrast is low, or detail in dark areas is lost

Brightness mapping is unsuitable

Gamma, contrast

Noise is obvious in low light

Noise reduction is too weak

Noise reduction

Note

Some image-quality problems are caused by hardware factors such as lens focus, module assembly, fill light, or light leakage in the structure. They cannot be solved by Tuning and should be ruled out before Tuning.

Tuning is usually unnecessary in these cases:

  • A YUV/RGB sensor is used.

  • A RAW sensor is used for which esp_cam_sensor already provides a default IPA JSON, the sensor, lens, and filter of the module match the module corresponding to that default JSON, and the default image quality already meets the application.

ISP Pipeline and Configuration

Image processing on the ESP32-P4 is done jointly by the ISP hardware, the esp_ipa algorithm library, and the esp_video framework. Together they form a closed control loop that runs frame by frame:

  • ISP hardware: processes the RAW data from the sensor frame by frame with BLC, LSC, noise reduction, demosaic, CCM, gamma, sharpening, and other stages. It also outputs statistics such as AE, AWB, histogram, sharpness, and AF.

  • esp_ipa algorithm library: reads the ISP statistics of each frame and the sensor’s current exposure and gain, then calculates the exposure time, gain, white-balance gain, CCM, gamma, and noise-reduction and sharpening strength required for the next frame.

  • esp_video framework: the ISP pipeline controller calls esp_ipa and applies the results to the ISP hardware and the sensor.

The behavior of each esp_ipa algorithm is determined by an IPA JSON configuration file. At build time, esp_ipa converts the JSON file into C configuration code and compiles it into the firmware. esp_ipa is released as a precompiled library, and the algorithms themselves cannot be modified. The final deliverable of ISP Tuning is therefore the IPA JSON configuration file for the corresponding camera module.

ISP pipeline of ESP32-P4 chips at v3.0 and later

ESP32-P4 ISP pipeline

The ISP pipeline of ESP32-P4 chips at v3.0 and later is divided into three processing domains:

  • RAW domain: BLC → DPC → BF (noise reduction) → LSC → Demosaic.

  • RGB domain: WBG (white-balance gain) → CCM → Gamma → RGB2YUV.

  • YUV domain: SHARP (sharpening) → COLOR (brightness, contrast, saturation, hue) → CROP.

The AWB, AE, HIST, and AF modules output statistics for esp_ipa to calculate parameters.

Main ISP modules

Module

Function

JSON field

BLC

Subtracts the sensor black-level offset

acc.blc

DPC

Corrects defective sensor pixels

dpc (supported in esp_ipa v2.5.0 and later)

BF

Noise reduction in the Bayer domain

adn.bf

LSC

Compensates for lens vignetting and color nonuniformity

acc.lsc

Demosaic

Interpolates Bayer data into RGB data

adn.demosaic

AWB / WBG

Calculates red and blue channel gains and corrects the light-source color cast

awb

CCM

Corrects color and improves color reproduction

acc.ccm

Gamma

Adjusts brightness mapping and contrast

aen.gamma

SHARP

Enhances edges and detail

aen.sharpen

COLOR

Adjusts contrast and saturation

aen.contrast, acc.saturation

AE

Calculates the sensor exposure time and gain

agc

IAN

Analyzes ambient color temperature and brightness for use by other algorithms

ian

For the detailed description of each field, see the esp_ipa JSON configuration description.

IPA and JSON configuration:
  • File structure: the JSON file uses the sensor name (such as SC2336) as the root node, with a configuration field for each algorithm under it. Global fields include version, writable, and description.

  • Linked parameters: noise reduction, sharpening, CCM, saturation, and similar parameters are usually configured in steps by sensor gain or color temperature. At runtime, esp_ipa selects the corresponding parameters from the current gain and color temperature, so Tuning must cover different illumination levels and light sources.

  • Integration: in menuconfig, either the default JSON provided by esp_cam_sensor or a path to a custom JSON file can be selected. The JSON is compiled into the firmware.

  • Multiple configurations: several JSON files can be compiled in for the same sensor. Each file must set a unique description. At runtime, esp_video_isp_pipeline_enum_ipa_configs() enumerates the configurations and esp_video_isp_pipeline_set_ipa_config() switches among them. This is useful for different scenes or for comparing several sets of tuning parameters.

  • Online parameter adjustment: after writable is set to true, parameters generated from that JSON can be modified at runtime, so the effect of an adjustment can be viewed immediately during debugging.

Using the Tuning Tool

ESP ISP Tuning Tool is a Windows desktop tool. For online use, connect an ESP32-P4 development board that has the calibration firmware flashed, such as the ESP32-P4-Function-EV-Board. Ethernet or USB (the board’s USB 2.0 High-Speed OTG interface) is supported. The tool mainly contains these pages:

  • Tuning: calibrate BLC, LSC, K, AWB, and CCM offline, tune Gamma and Sharpen, and generate a JSON file with JSON Tool.

  • Live: adjust exposure and the parameters of each ISP module online, send them to the development board, capture images, and preview the result in real time.

  • Tool: auxiliary functions such as image-to-Lab conversion, image preview, and gamma-curve generation.

  • Analysis: analyze image quality. It does not generate calibration results.

The tool supports offline calibration (import existing images, with no development board connected) and online calibration (capture, calibration, and download form a closed loop in the same project).

For more information, see the camera sensor technical support policy.