double[]dd_deriv=newdouble[3];// derivatives by dependent dd_pre_lars, dd_last and nd_last (calculated on demand) with sign according to first/second in a pair
double[]dd_deriv=newdouble[3];// derivatives by dependent dd_pre_lars, dd_last and nd_last (calculated on demand) with sign according to first/second in a pair
(adjust_ly?imgdtt_params.lma_cost_wy:0.0),// imgdtt_params.lma_cost_wy, // double cost_lazyeye_par, // cost for each of the non-zero disparity corrections lma_cost_wy
(adjust_ly?imgdtt_params.lma_cost_wy:0.0),// imgdtt_params.lma_cost_wy, // double cost_lazyeye_par, // cost for each of the non-zero disparity corrections lma_cost_wy
(adjust_ly?imgdtt_params.lma_cost_wxy:0.0)//imgdtt_params.lma_cost_wxy // double cost_lazyeye_odtho // cost for each of the non-zero ortho disparity corrections lma_cost_wxy
(adjust_ly?imgdtt_params.lma_cost_wxy:0.0)//imgdtt_params.lma_cost_wxy // double cost_lazyeye_odtho // cost for each of the non-zero ortho disparity corrections lma_cost_wxy
);
);
lma.setMatrices(disp_dist);
lma.setMatrices(disp_dist);
lma.initMatrices();// should be called after initVector and after setMatrices
lma.initMatrices();// should be called after initVector and after setMatrices
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs[cTile],// corrs, // double [][] corrs,
corrs[cTile],// corrs, // double [][] corrs,
...
@@ -3055,6 +3105,7 @@ public class ImageDttCPU {
...
@@ -3055,6 +3105,7 @@ public class ImageDttCPU {
disp_str[cTile]=null;
disp_str[cTile]=null;
if(lma2!=null){
if(lma2!=null){
dbg_num_good_lma++;
disp_str[cTile]=lma2.lmaDisparityStrength(
disp_str[cTile]=lma2.lmaDisparityStrength(
imgdtt_params.lmas_max_rel_rms,// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_max_rel_rms,// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_min_strength,// minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lmas_min_strength,// minimal composite strength (sqrt(average amp squared over absolute RMS)
...
@@ -3064,53 +3115,176 @@ public class ImageDttCPU {
...
@@ -3064,53 +3115,176 @@ public class ImageDttCPU {
imgdtt_params.lma_str_scale,// convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_scale,// convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset// convert lma-generated strength to match previous ones - add to result
imgdtt_params.lma_str_offset// convert lma-generated strength to match previous ones - add to result
double[][]disp_dist_cons=newdouble[numSensors][];// used to correct 3D correlations
corr_wnd, // double [][] corr_wnd, // correlation window to save on re-calculation of the window
double[]disp_str_cons={0.0,0.0};
corr_wnd_inv_limited, // corr_wnd_inv_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
intnum_tiles=0;
corrs, // [tIndex], // double [][] corrs,
doublesum_w=0.0;
disp_dist, // [tIndex],
doublesum_wd=0.0;
rXY, // double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
}
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs,// corrs, // double [][][] corrs,
doublew=disp_str[nTile][1];
disp_dist,
sum_w+=w;
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
System.out.println("Will run new LMA for clustX="+clustX+", clustY="+clustY);
if(disp_dist_cons!=null){
System.out.println("disp_dist_cons[0]="+disp_dist_cons[0]+", disp_dist_cons[0]="+disp_dist_cons[0]+" (this tile - weighted average will be discarded)");
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs_cons,// corrs, // double [][] corrs,
disp_dist_cons,
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
// all that are not null in corr_tiles
correlation2d.selectAll(),// longToArray(imgdtt_params.dbg_pair_mask), // int pair_mask, // which pairs to process
// TODO: Verify sign is correct (disparity, not X0)?
disp_str_combo,// null, // disp_str, //corr_stat[0], // double xcenter, // preliminary center x in pixels for largest baseline
disp_str_combo,// disp_str_cons, // double[] poly_ds, // null or pair of disparity/strength
imgdtt_params.ortho_vasw_pwr,// double vasw_pwr, // value as weight to this power,
clust_lma_debug_level+0,// tdl, // tile_lma_debug_level, // +2, // int debug_level,
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs,// corrs, // double [][][] corrs,
disp_dist,
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
// all that are not null in corr_tiles
correlation2d.selectAll(),// longToArray(imgdtt_params.dbg_pair_mask), // int pair_mask, // which pairs to process
disp_str,//corr_stat[0], // double xcenter, // preliminary center x in pixels for largest baseline
imgdtt_params.ortho_vasw_pwr,// double vasw_pwr, // value as weight to this power,
clust_lma_debug_level+0,// // +2, // int debug_level,
clustX,// int tileX, // just for debug output
clustY);// int tileY
}
if(lma2!=null){
if(lma2!=null){
double[][]ddnd=lma2.getDdNd();
double[][]ddnd=lma2.getDdNd();
double[]stats=lma2.getStats(num_good_tiles);
double[]stats=lma2.getStats(num_good_tiles);
...
@@ -3123,29 +3297,85 @@ public class ImageDttCPU {
...
@@ -3123,29 +3297,85 @@ public class ImageDttCPU {
1.0,// imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
1.0,// imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
0.0);// imgdtt_params.lma_str_offset); // convert lma-generated strength to match previous ones - add to result
0.0);// imgdtt_params.lma_str_offset); // convert lma-generated strength to match previous ones - add to result
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd,// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corr_wnd_inv_limited,// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corr_tiles,// corrs, // double [][] corrs,
corr_tiles,// corrs, // double [][] corrs,
...
@@ -12725,21 +12956,18 @@ public class ImageDttCPU {
...
@@ -12725,21 +12956,18 @@ public class ImageDttCPU {
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width,// final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height,// final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset,// final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp,// final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileY,// final int debug_tileY,
clt_parameters.tileY,// final int debug_tileY,
threadsMax,// final int threadsMax, // maximal number of threads to launch
threadsMax,// final int threadsMax, // maximal number of threads to launch
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width,// final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height,// final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset,// final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp,// final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileY,// final int debug_tileY,
clt_parameters.tileY,// final int debug_tileY,
threadsMax,// final int threadsMax, // maximal number of threads to launch
threadsMax,// final int threadsMax, // maximal number of threads to launch
...
@@ -8203,6 +8209,10 @@ public class QuadCLTCPU {
...
@@ -8203,6 +8209,10 @@ public class QuadCLTCPU {
intop=ImageDtt.setImgMask(0,0xf);
intop=ImageDtt.setImgMask(0,0xf);
op=ImageDtt.setPairMask(op,0xf);
op=ImageDtt.setPairMask(op,0xf);
op=ImageDtt.setForcedDisparity(op,true);
op=ImageDtt.setForcedDisparity(op,true);
bg_scan.setSelected(bg_sel);
combo_scan.setSelected(combo_use);
bg_scan.setStrength(data[1]);// will not be used
combo_scan.setStrength(data[3]);
for(intty=0;ty<height;ty++){
for(intty=0;ty<height;ty++){
for(inttx=0;tx<width;tx++){
for(inttx=0;tx<width;tx++){
intindx=ty*width+tx;
intindx=ty*width+tx;
...
@@ -8218,6 +8228,123 @@ public class QuadCLTCPU {
...
@@ -8218,6 +8228,123 @@ public class QuadCLTCPU {
returntrue;
returntrue;
}
}
// for now works only from file (using
publicvoidupdateScansForLY(
intbg_scan_indx,
intcombo_scan_indx,
booleantop_bg,// all above bg is bg
intfill_gaps_bg,// 1 - in 4 directions by 1, 2 - in 8 directions by 1,
intfill_gaps_combo,// 1 - in 4 directions by 1, 2 - in 8 directions by 1,
booleanuse_strength,// weight average disparity by strength
doublescale_derivative_strength// 1.0 - new strength - average of neibs, 0.5 - only 1/2 of neibs
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.tileStep,// final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.getMcorrSelLY(getNumSensors()),// final int mcorr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width,// final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height,// final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset,// final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp,// final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileX,// final int debug_tileX,
clt_parameters.tileY,// final int debug_tileY,
clt_parameters.tileY,// final int debug_tileY,
threadsMax,// final int threadsMax, // maximal number of threads to launch
threadsMax,// final int threadsMax, // maximal number of threads to launch
...
@@ -12533,9 +12702,10 @@ public class QuadCLTCPU {
...
@@ -12533,9 +12702,10 @@ public class QuadCLTCPU {
finalintthreadsMax,// maximal number of threads to launch
finalintthreadsMax,// maximal number of threads to launch
finalbooleanupdateStatus,
finalbooleanupdateStatus,
doubledelta,
doubledelta,
booleanuse_tarz,// derivatives by tarz, notg symmetrical vectors
finalintdebugLevel)
finalintdebugLevel)
{
{
delta=0.0003;
// delta = 0.001;
/*double [] parameter_scales4 = { // multiply delay for each parameter
/*double [] parameter_scales4 = { // multiply delay for each parameter