Color Control Matrix and Tone Curves in camera_override.isp

I am working on a Jetson Nano module on a custom carrier board connected to 2 x Sony IMX415 sensors.
I need to customize the camera_override.isp file to include:

  • a Color Correction Matrix

  • a Tone Curve for each RGB color channel

I discovered that it is quite simple to add the color correction matrix such as:

colorCorrection.srgbMatrix[0] = { 1.5662, -0.3302, 0.0268};
colorCorrection.srgbMatrix[1] = { -0.5544, 1.8120, -0.8347};
colorCorrection.srgbMatrix[2] = { -0.0118, -0.4818, 1.8079};

What is not clear is how to input the tone curves.
Apparently each curve is as follow:
tc.v2.user.presets[0].Gamma.Value=2.4000;
tc.v2.user.presets[0].UserCurve.Enable=FALSE;
tc.v2.user.presets[0].UserCurve.Points={ 0.0000, 0.0000, 0.2500, 0.2500, 0.5000, 0.5000, 0.7500, 0.7500, 1.0000, 1.0000 };
tc.v2.user.presets[0].CurveControl.Enable=TRUE;
tc.v2.user.presets[0].CurveControl.AdjustHighlights=0.7500;
tc.v2.user.presets[0].CurveControl.MidtoneBrightness=0.5000;
tc.v2.user.presets[0].CurveControl.MidtoneContrast=0.5000;
tc.v2.user.presets[0].CurveControl.AdjustShadows=0.2500;
tc.v2.user.presets[0].Brightness.Enable=FALSE;
tc.v2.user.presets[0].Brightness.Value=1.0000;

There are 9 element in the tc.v2.user.preset vector and I don’t know for which RGB channel are applicable.

These other parameters are undocumented:

  • are such parameters mandatory ?
  • or optional ?
  • which is the meaning ?

tc.v2.user.UseIndices={ 0, 0, 0, 0, 0, 0, 0, 0, 0 };
tc.v2.user.FlashUseIndices= { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
tc.v2.UseAxisX={ 1068.0000, 2136.0000, 9970.0000, 14242.0000 };
tc.v2.UseAxisY={ 1.0000, 1.0000, 1.0000, 1.0000 };
tc.v2.FlashUseAxisX={ 1068.0000, 2136.0000, 9970.0000, 14242.0000 };
tc.v2.FlashUseAxisY={ 1.0000, 1.0000, 1.0000, 1.0000 };
tc.v2.initStats.brightness=3811;
tc.v2.initStats.tcdre=1.0;

Thanks

Andrea

Please consult the ISP tuning problem with scaling partner.

You should be able to use the argus API for the CCM and tone map instead of the override file.

Have a check below API in the multimedia API document.

Argus::IAutoControlSettings::setColorCorrectionMatrix() and Argus::IAutoControlSettings::setToneMapCurve(),

Are there any examples ?
I didn’t find any specific example in the Multimedia samples.
Thanks

Andrea

Have a check these code snippet.

const float r0[] = {1.1f, 0.0f, 0.0f};
const float r1[] = {0.0f, 0.9f, 0.0f};
const float r2[] = {0.0f, 0.0f, 1.2f};

std::vector<float> testColorCorrectionMatrix = getVectorMatrix(r0, r1, r2);
std::vector<float> testInvalidColorCorrectionMatrix = getVectorMatrix(r0, r1, r2);
setColorCorrectionMatrix(testColorCorrectionMatrix));


{
	float toneval[129]=
		{0.000000,
		0.056696,
		0.112414,
		0.159335,
		0.193548,
		0.226784,
		0.254154,
		0.282502,
		0.304008,
		0.324536,
		0.346041,
		0.364614,
		0.384164,
		0.399805,
		0.416422,
		0.431085,
		0.443793,
		0.457478,
		0.471163,
		0.481916,
		0.494624,
		0.506354,
		0.517107,
		0.529814,
		0.542522,
		0.555230,
		0.566960,
		0.577713,
		0.588465,
		0.599218,
		0.609971,
		0.619746,
		0.629521,
		0.639296,
		0.649071,
		0.657869,
		0.665689,
		0.674487,
		0.682307,
		0.690127,
		0.697947,
		0.705767,
		0.714565,
		0.722385,
		0.730205,
		0.738025,
		0.745846,
		0.753666,
		0.761486,
		0.767351,
		0.773216,
		0.777126,
		0.782014,
		0.786901,
		0.791789,
		0.795699,
		0.800587,
		0.804497,
		0.809384,
		0.813294,
		0.817204,
		0.821114,
		0.825024,
		0.828934,
		0.832845,
		0.836755,
		0.840665,
		0.844575,
		0.847507,
		0.851417,
		0.855327,
		0.858260,
		0.862170,
		0.865103,
		0.869013,
		0.871945,
		0.874878,
		0.878788,
		0.881720,
		0.884653,
		0.887586,
		0.890518,
		0.893451,
		0.896383,
		0.899316,
		0.902248,
		0.905181,
		0.908113,
		0.911046,
		0.913979,
		0.916911,
		0.918866,
		0.921799,
		0.924731,
		0.927664,
		0.929619,
		0.932551,
		0.935484,
		0.937439,
		0.940371,
		0.942326,
		0.945259,
		0.948192,
		0.950147,
		0.952102,
		0.955034,
		0.956989,
		0.959922,
		0.960899,
		0.962854,
		0.965787,
		0.967742,
		0.969697,
		0.972630,
		0.974585,
		0.976540,
		0.978495,
		0.981427,
		0.983382,
		0.985337,
		0.987292,
		0.989247,
		0.991202,
		0.993157,
		0.995112,
		0.997067,
		0.998045,
		0.999022,
		1.000000};
	std::vector<float> curves(129,0);
	uint32_t curve_size;
    IAutoControlSettings *iAutoControlSettings =
        interface_cast<IAutoControlSettings>(iRequest->getAutoControlSettings());

    curve_size = iAutoControlSettings->getToneMapCurveSize(RGB_CHANNEL_R);
    iAutoControlSettings->setToneMapCurveEnable(true);
    for(int cnt = 0; cnt < curve_size;cnt++)
	{
		curves[cnt] = toneval[cnt];
		iAutoControlSettings->setToneMapCurve(RGB_CHANNEL_R, curves);
		iAutoControlSettings->setToneMapCurve(RGB_CHANNEL_G, curves);
		iAutoControlSettings->setToneMapCurve(RGB_CHANNEL_B, curves);

	}
}
1 Like

Why is the setToneMapCurve being called in the loop. That doesn’t seem necessary.

1 Like

You are right, doesn’t necessary set it in the loop.