Tool/software:
Hi Gang Hua
Creating a new thread since requested.
Since we had multiple conversations, consolidating my issues here
We are in the process of tuning the ISP (SDK 9_00_02_05) for IMX662 Sensor. The sensor supports gain and exposure control. The Gain range varies from 0dB to 30dB and Exposure range varies from 60us to 16600us. The gain is mapped in multiples of 10 ie 0 for 0dB, 10 for 1dB and 300 for 30dB. We have mapped it accordingly in get_imx662_ae_dyn_params() in gsttiovxisp.c. You can have a look at the patch for reference.
diff --git a/opt/edgeai-gst-plugins/ext/tiovx/gsttiovxisp.c b/opt/edgeai-gst-plugins/ext/tiovx/gsttiovxisp.c index e815cf3..9ce3521 100644 --- a/opt/edgeai-gst-plugins/ext/tiovx/gsttiovxisp.c +++ b/opt/edgeai-gst-plugins/ext/tiovx/gsttiovxisp.c @@ -657,6 +657,8 @@ static int32_t get_ov2312_ae_dyn_params (IssAeDynamicParams * p_ae_dynPrms); static int32_t get_ox05b1s_ae_dyn_params (IssAeDynamicParams * p_ae_dynPrms); +static int32_t get_imx662_ae_dyn_params (IssAeDynamicParams * p_ae_dynPrms); + static void gst_tiovx_isp_map_2A_values (GstTIOVXISP * self, int exposure_time, int analog_gain, gint32 * exposure_time_mapped, gint32 * analog_gain_mapped); @@ -706,7 +708,8 @@ gst_tiovx_isp_class_init (GstTIOVXISPClass * klass) " SENSOR_ONSEMI_AR0233_UB953_MARS\n" " SENSOR_SONY_IMX219_RPI\n" " SENSOR_OX05B1S\n" - " SENSOR_OV2312_UB953_LI", + " SENSOR_OV2312_UB953_LI\n" + " SENSOR_SONY_IMX662", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY)); @@ -1854,6 +1857,8 @@ gst_tiovx_isp_postprocess (GstTIOVXMiso * miso) get_ov2312_ae_dyn_params (&sink_pad->sensor_in_data.ae_dynPrms); } else if (g_strcmp0 (self->sensor_name, "SENSOR_OX05B1S") == 0) { get_ox05b1s_ae_dyn_params (&sink_pad->sensor_in_data.ae_dynPrms); + } else if (g_strcmp0 (self->sensor_name, "SENSOR_SONY_IMX662") == 0) { + get_imx662_ae_dyn_params (&sink_pad->sensor_in_data.ae_dynPrms); } else { get_imx219_ae_dyn_params (&sink_pad->sensor_in_data.ae_dynPrms); } @@ -2066,6 +2071,34 @@ get_ox05b1s_ae_dyn_params (IssAeDynamicParams * p_ae_dynPrms) return status; } +static int32_t +get_imx662_ae_dyn_params (IssAeDynamicParams * p_ae_dynPrms) +{ + int32_t status = -1; + uint8_t count = 0; + + g_return_val_if_fail (p_ae_dynPrms, status); + + p_ae_dynPrms->targetBrightnessRange.min = 40; + p_ae_dynPrms->targetBrightnessRange.max = 50; + p_ae_dynPrms->targetBrightness = 45; + p_ae_dynPrms->threshold = 1; + p_ae_dynPrms->enableBlc = 1; + p_ae_dynPrms->exposureTimeStepSize = 1; + + p_ae_dynPrms->exposureTimeRange[count].min = 60; + p_ae_dynPrms->exposureTimeRange[count].max = 16600; + p_ae_dynPrms->analogGainRange[count].min = 0; + p_ae_dynPrms->analogGainRange[count].max = 300; + p_ae_dynPrms->digitalGainRange[count].min = 256; + p_ae_dynPrms->digitalGainRange[count].max = 256; + count++; + + p_ae_dynPrms->numAeDynParams = count; + status = 0; + return status; +} + static void gst_tiovx_isp_map_2A_values (GstTIOVXISP * self, int exposure_time, int analog_gain, gint32 * exposure_time_mapped, gint32 * analog_gain_mapped) @@ -2105,6 +2138,9 @@ gst_tiovx_isp_map_2A_values (GstTIOVXISP * self, int exposure_time, } else if (g_strcmp0 (self->sensor_name, "SENSOR_OX05B1S") == 0) { *exposure_time_mapped = (int) ((double)exposure_time * 2128 * 60 / 1000000 + 0.5); *analog_gain_mapped = analog_gain / 64; + } else if (g_strcmp0 (self->sensor_name, "SENSOR_SONY_IMX662") == 0) { + *exposure_time_mapped = exposure_time; + *analog_gain_mapped = analog_gain; } else { GST_ERROR_OBJECT (self, "Unknown sensor: %s", self->sensor_name); } diff --git a/opt/edgeai-tiovx-modules/src/tiovx_sensor_module.c b/opt/edgeai-tiovx-modules/src/tiovx_sensor_module.c index 447fcaf..ffb8e64 100644 --- a/opt/edgeai-tiovx-modules/src/tiovx_sensor_module.c +++ b/opt/edgeai-tiovx-modules/src/tiovx_sensor_module.c @@ -450,6 +450,10 @@ vx_status tiovx_init_sensor(SensorObj *sensorObj, char *objName) { sensorObj->sensorParams.dccId=5; } + else if(strcmp(sensorObj->sensor_name, "SENSOR_SONY_IMX662") == 0) + { + sensorObj->sensorParams.dccId=662; + } else { TIOVX_MODULE_ERROR("[SENSOR-MODULE] Invalid sensor name\n");
Also, we have configured the imx662_properties according to our sensor configuration. Attaching the same for reference
SENSOR_ID 662 PRJ_DIR ../imx662_output SENSOR_NAME imx662 SENSOR_DCC_NAME SENSOR_SONY_IMX662 SENSOR_WIDTH 1920 SENSOR_HEIGHT 1080 # 0=RGGB; 1=GRBG; 2=GBRG; 3=BGGR, 4=MONO COLOR_PATTERN 0 # sensor mode: 0 for linear (no decompanding), 1 for WDR (decompanding) WDR_MODE 0 # raw sensor image BIT_DEPTH: it may be 8, 10, or 12 for linear sensors; typically 12 for WDR mode because of companding BIT_DEPTH 10 # WDR BIT_DEPTH: WDR raw sensor image bitdepth after decompanding, typically 20 or 24 WDR_BIT_DEPTH 20 # WDR decompanding knee points (comma separated without spaces in between) WDR_KNEE_X 0,512,1408,2176,4095,65535 WDR_KNEE_Y 0,2048,16384,65536,1048063,1048063 # Sensor black level to subtract before decompanding (for linear sensors only and some Sony WDR sensors) BLACK_PRE 50 # Sensor black level to subtract after decompanding (for most WDR sensors and all linear sensors) BLACK_POST 0 # GAMMA value for compressing 20/24-bit WDR raw to 16-bit ISP internal # typically around 50 (0.5) for 24-bit WDR sensors and 70 (0.7) for 20-bit sensors GAMMA_PRE 0 # LSB location for H3A input bit range (from bit-H3A_INPUT_LSB to bit-H3A_INPUT_LSB+9) H3A_INPUT_LSB 0
We are using the below gstreamer pipeline for streaming
media-ctl -d /dev/media1 --set-v4l2 '"imx662 7-0042":0[fmt:SRGGB10_1X10/1920x1080]' gst-launch-1.0 v4l2src device=/dev/video2 io-mode=dmabuf-import ! \ video/x-bayer, width=1920, height=1080, framerate=30/1, format=rggb10 ! \ tiovxisp sink_0::device=/dev/v4l-subdev2 \ sensor-name="SENSOR_SONY_IMX662" \ dcc-isp-file=/opt/imaging/imx662/linear/dcc_viss.bin \ sink_0::dcc-2a-file=/opt/imaging/imx662/linear/dcc_2a.bin format-msb=9 ! \ video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! \ kmssink driver-name=tidss sync=false
What we noticed is irrespective of the configuration in get_imx662_ae_dyn_params() in gsttiovxisp.c and imx662_properties.txt, the exposure and gain always settle downs to minimum ie Gain=0 and Exposure=60us. We also tuned the ISP/VPAC as mentioned in https://www.ti.com/lit/an/sprad86a/sprad86a.pdf for multiple lighting conditions and still the behavior remained same. Also the images looked dark and AWB settling was also not proper. Attaching a sample image for reference.
And yes, AE is working in our TDA4VM as we enabled debug prints in the driver and noticed exposure being set to the Maximum (16600us) and then brought down to Minimum(60us). But after setting the exposure and gain once to minimum, the AE does not seem to work at all ie the exposure and gain remains same irrespective of the scene. We also tested with IMX219 setting and the AE algorithm seems to be working.
Lets us know, what could be the possible solutions for AE/AWB settling. Also let us know if you need details further from our end.
Thanks