CAC in VPAC3-VISS or VPAC3L-VISS is very similar to LDC in VPAC.
To prepare the CAC LUT for DCC tuning tool input, we may use similar matlab/octave script as LDC.
You may refer to the LDC FAQ in the link below for more details.
e2e.ti.com/.../faq-tda4vm-how-to-create-a-ldc-mesh-lut-for-fisheye-distortion-correction-on-tda4
In the example below, we have an RGGB sensor of 1280x768 resolution and we would like to shift R and B pixel to align with G pixels in CAC.
Let's assume a simple radial CAC model with "cac_shift_1" and "cac_shift_2" in code below.
The first column of them is the distance from image center (in the unit of pixels), and second column is the amount we would like shift along the radial direction (also in the unit of pixels).
CAC center (x=hc, y=vc) is at the image center.
The sample code below makes a CAC LUT for DCC tuning tool input.
cac_shift_1 = [0, 0; 400, 0; 600, -2; 800, -4; 1000, -6; 1100, -8; 1300, -11]; cac_shift_2 = [0, 0; 400, 0; 600, +2; 800, +4; 1000, +6; 1100, +8; 1300, +11]; im_sz = [768, 1280]; hc = im_sz(2) / 2; vc = im_sz(1) / 2; make_cac_lut('cac_lut_m.txt', im_sz, hc, vc, cac_shift_1, cac_shift_2);
The implementation of "make_cac_lut" is straightforward (similar to the LDC FAQ).
Firstly, we find out the CAC LUT down-sampling factor by calling "find_block_s" (line #3).
Secondly, we prepare horizontal and vertical shifts for R and B pixels with the radial model by calling "prep_cac_dxdy" (line #4, #5).
Thirdly, we convert the shifts into proper integer format in 4 columns by calling "prep_cac_text_lut" (line #6).
Finally, we create the CAC LUT text file and print out the relevant CAC parameters (line #7~#10)
function [] = make_cac_lut(fout, im_sz, hc, vc, cac_radial_shift_1, cac_radial_shift_2) block_s = find_block_s(im_sz); [mesh_dx1, mesh_dy1] = prep_cac_dxdy(im_sz, hc, vc, cac_radial_shift_1, block_s); [mesh_dx2, mesh_dy2] = prep_cac_dxdy(im_sz, hc, vc, cac_radial_shift_2, block_s); mesh_lut = prep_cac_text_lut(mesh_dx1, mesh_dy1, mesh_dx2, mesh_dy2); dlmwrite(fout, mesh_lut, 'delimiter', '\t'); disp(['image size: ', int2str(im_sz(2)), ' x ', int2str(im_sz(1))]) disp(['CAC LUT size: ', int2str(size(mesh_dx1,2)), ' x ', int2str(size(mesh_dx1,1))]) disp(['CAC down-sampling: ', int2str(block_s)]) %------------------------------------------------------------------------------------------------------------------------- function [dx, dy] = prep_cac_dxdy(im_sz, hc, vc, lca_radial_curve, block_s) [xt, yt] = meshgrid( [0:ceil(im_sz(2)/block_s)]*block_s, [0:ceil(im_sz(1)/block_s)]*block_s); [phi, ro] = cart2pol(xt - hc, yt - vc); ro1 = interp1(lca_radial_curve(:,1), lca_radial_curve(:,2), ro); [xt, yt] = pol2cart(phi, ro1); dx = round(-xt * 8); dy = round(-yt * 8); %------------------------------------------------------------------------------------------------------------------------- function [cac_text_lut] = prep_cac_text_lut(mesh1_dx, mesh1_dy, mesh2_dx, mesh2_dy) mesh1_dx = min(64, max(-64, mesh1_dx)); mesh1_dy = min(32, max(-32, mesh1_dy)); dx1 = mesh1_dx'; dy1 = mesh1_dy'; mesh1_lut0 = [dx1(:), dy1(:)]; mesh2_dx = min(64, max(-64, mesh2_dx)); mesh2_dy = min(32, max(-32, mesh2_dy)); dx2 = mesh2_dx'; dy2 = mesh2_dy'; mesh2_lut0 = [dx2(:), dy2(:)]; cac_text_lut = [mesh1_lut0, mesh2_lut0]; %------------------------------------------------------------------------------------------------------------------------- function [block_s] = find_block_s(imsz) block_s = 0; for k = 4:4:128 if ceil(imsz(1) / k + 1) * ceil(imsz(2) / k + 1) <= 2048 block_s = k; break; end end
After executing the code, you will see the printing as below
image size: 1280 x 768 CAC LUT size: 55 x 33 CAC down-sampling: 24
You may enter these numbers in tuning tool and use the generated LUT text file as input.
Note: this is one example e2e thread about using the CAC matlab script -- https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1298405/cac-matlab-script-issue