Commit ee9c0264 authored by Andrey Filippov's avatar Andrey Filippov

Implemented main camera field correction from the DSI of the dual camera

rig.
parent b3afa1ab
...@@ -863,7 +863,7 @@ public class AlignmentCorrection { ...@@ -863,7 +863,7 @@ public class AlignmentCorrection {
* @param samples_list sample list generated by selectInfinityTiles method, each element references measurement series, * @param samples_list sample list generated by selectInfinityTiles method, each element references measurement series,
* tile index and (possibly modified) weight of each tile * tile index and (possibly modified) weight of each tile
* @param tilesX number of tiles in each data line * @param tilesX number of tiles in each data line
* @param magic_coeff still not understood coefficient that reduces reported disparity value. Seems to be around 0.85 * @param magic_coeff understood - interaction of the CM maximum and correlation window
* @param mismatch_list data to calculate extrinsic corrections or null * @param mismatch_list data to calculate extrinsic corrections or null
* @param debugLevel debug level * @param debugLevel debug level
* @return per sub-camera, per direction (x,y) 6 quadratic polynomial coefficients, same format as fine_geometry_correction() * @return per sub-camera, per direction (x,y) 6 quadratic polynomial coefficients, same format as fine_geometry_correction()
...@@ -1083,13 +1083,12 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1083,13 +1083,12 @@ B = |+dy0 -dy1 -2*dy3 |
double [] centerXY = { double [] centerXY = {
tileX * qc.tp.getTileSize() + qc.tp.getTileSize()/2,// - shiftX; tileX * qc.tp.getTileSize() + qc.tp.getTileSize()/2,// - shiftX;
tileY * qc.tp.getTileSize() + qc.tp.getTileSize()/2};//- shiftY; tileY * qc.tp.getTileSize() + qc.tp.getTileSize()/2};//- shiftY;
double disparity_task = disp_scan_start + disp_scan_step * s.series; double disparity_task = disp_scan_start + disp_scan_step * s.series; // Not needed even with known disparity
double disparity_meas = disp_strength[s.series * NUM_SLICES + 0][s.tile]; double disparity_meas = disp_strength[s.series * NUM_SLICES + 0][s.tile];
double strength = disp_strength[s.series * NUM_SLICES + 1][s.tile]; double strength = disp_strength[s.series * NUM_SLICES + 1][s.tile];
// final double disp_scan_start, if (Double.isNaN(disparity_meas)) {
// final double disp_scan_step, System.out.println("infinityMismatchCorrection(): disparity_meas=NaN: s.tile= "+s.tile);
// final int disp_scan_count, }
mismatch_list.add(new Mismatch( mismatch_list.add(new Mismatch(
allow_dispatity && (s.series == 0), // true, //false, // public boolean use_disparity; // adjust dx0+dx1+dy0+dy1 == 0 allow_dispatity && (s.series == 0), // true, //false, // public boolean use_disparity; // adjust dx0+dx1+dy0+dy1 == 0
centerXY, centerXY,
...@@ -2234,13 +2233,14 @@ System.out.println("test1234"); ...@@ -2234,13 +2233,14 @@ System.out.println("test1234");
} }
ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>()); ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>());
// inf_and_ly here has filtered disparity and offsets, should be process clt_parameters.ly_inf_disp before filters // inf_and_ly here has filtered disparity and offsets, should be process clt_parameters.ly_inf_disp before filters
// for rig with known disparity - use series = 0 - it will allow disparity adjustment
double [][][] mismatch_corr_coefficients = infinityMismatchCorrection( double [][][] mismatch_corr_coefficients = infinityMismatchCorrection(
clt_parameters.disp_scan_start, // final double disp_scan_start, clt_parameters.disp_scan_start, // final double disp_scan_start,
clt_parameters.disp_scan_step, // final double disp_scan_step, clt_parameters.disp_scan_step, // final double disp_scan_step,
use_poly, // final boolean use_poly, use_poly, // final boolean use_poly,
clt_parameters.fcorr_quadratic, // final boolean use_quadratic, clt_parameters.fcorr_quadratic, // final boolean use_quadratic,
true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical, true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
// tool alte to restore disparity - should be dome earlier // too late to restore disparity - should be dome earlier
false, // final boolean use_disparity, // for infinity false, // final boolean use_disparity, // for infinity
true, // clt_parameters.ly_inf_disp, //final boolean allow_dispatity, true, // clt_parameters.ly_inf_disp, //final boolean allow_dispatity,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -2310,6 +2310,477 @@ System.out.println("test1234"); ...@@ -2310,6 +2310,477 @@ System.out.println("test1234");
return mismatch_corr_coefficients; return mismatch_corr_coefficients;
} }
public double [][][] lazyEyeCorrectionFromGT(
final boolean use_poly, // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor
final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity) always true
final double fcorr_radius,
final double min_strength_in,
final double strength_pow,
final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final double lazyEyeDispVariation, // maximal full disparity difference between the tile and 8 neighborxs
final double lazyEyeDispRelVariation,
final double ly_norm_disp, // = 5.0; // Reduce weight of higher disparity tiles
final int smplSide, // = 2; // Sample size (side of a square)
final int smplNum, // = 3; // Number after removing worst (should be >1)
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
final double hist_disp_min,
final double hist_disp_step,
final int hist_num_bins,
final double hist_sigma,
final double hist_max_diff,
final int hist_min_samples,
final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
final double inf_fraction, // fraction of the weight for the infinity tiles
final double inf_max_disparity, // use all smaller disparities as inf_fraction
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] scans_14, // here - always 14 - infinity and non-infinity
double [][][] gt_disparity_strength, // 1 pair for each 14 entries of scans_14 (normally - just 1 scan
final boolean filter_ds, //
final boolean filter_lyf, // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
int tilesX,
double magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
int debugLevel){
// final double lazyEyeDispRelVariation = 0.02;
final int dbg_nTile = -34145; // 37005; // -59038;
final int num_scans = scans_14.length/NUM_ALL_SLICES;
final int num_tiles = scans_14[0].length;
final int tilesY = num_tiles/tilesX;
final boolean [] center_mask = getCenterMask(fcorr_radius, tilesX, tilesY);
final double [][] scans = new double [num_scans * NUM_SLICES][];
// final double [][] comp_strength_rms = new double [num_scans][num_tiles];
for (int ns = 0; ns < num_scans; ns++){
final double [] min_weights = new double [num_tiles];
for (int nTile = 0; nTile < num_tiles; nTile++){
if (nTile == dbg_nTile) {
System.out.println("lazyEyeCorrectionFromGT(), nTile="+nTile);
}
double w = scans_14[ns * NUM_ALL_SLICES + INDEX_14_WEIGHT][nTile];
for (int i = 0; i < INDICES_14_WEIGHTS.length; i++) {
w = Math.min(w, scans_14[ns * NUM_ALL_SLICES + INDICES_14_WEIGHTS[i]][nTile]);
}
min_weights[nTile] = w * gt_disparity_strength[ns][1][nTile];
}
for (int i = 0; i < INDICES_14_10.length; i++){
if (i == INDEX_10_WEIGHT) {
scans[ns * NUM_SLICES + i] = min_weights;
} else {
scans[ns * NUM_SLICES + i] = scans_14[ns * NUM_ALL_SLICES + INDICES_14_10[i]];
}
}
}
if (debugLevel > 0) { // -2) { // 100) {
if (debugLevel > -3) { // -1) { // -2) { // 100) {
double [][] dbg_scans = new double[scans.length][];
for (int i = 0; i < dbg_scans.length;i++) {
dbg_scans[i] = scans[i].clone();
if (i != 1) {
for (int j = 0; j < dbg_scans[i].length; j++) if (scans[1][j]<=0.0) {
dbg_scans[i][j] = Double.NaN;
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_scans, tilesX, tilesY, true, "scans_pre-disp");
}
}
// Add disparity to dx0, dx1, dy2, dy3 pairs (here - always)
if ( restore_disp_inf) { // && false) { // ==clt_parameters.inf_restore_disp
for (int nTile = 0; nTile < num_tiles; nTile++) if (scans[INDEX_10_WEIGHT][nTile] > 0){
for (int i = 0; i < INDICES_10_DISP.length; i++) {
scans[INDICES_10_DISP[i]][nTile] += scans[INDEX_10_DISPARITY][nTile];
}
}
}
if (debugLevel > 0) { // -2) { // 100) {
if (debugLevel > -3) { // -1) { // -2) { // 100) {
double [][] dbg_scans = new double[scans.length][];
for (int i = 0; i < dbg_scans.length;i++) {
dbg_scans[i] = scans[i].clone();
if (i != 1) {
for (int j = 0; j < dbg_scans[i].length; j++) if (scans[1][j]<=0.0) {
dbg_scans[i][j] = Double.NaN;
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_scans, tilesX, tilesY, true, "scans_post-disp");
}
}
// FIXME: Seems that disparity should be combined with dxy for BG scan before that
// For GT - keep it here or remove?
double[][] filtered_scans;
if (filter_ds) {
filtered_scans = filterDisparityStrength (
scans, // final double[][] disp_strength_in, // [1][37006] >0, [21][37006] = NaN
min_strength_in, // final double strength_floor,
strength_pow, // final double strength_pow,
lazyEyeSmplSide, // final int smplSide, // = 2; // Sample size (side of a square)
lazyEyeSmplNum, // final int smplNum, // = 3; // Number after removing worst (should be >1)
lazyEyeSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
tilesX);// final int tilesX);
} else {
filtered_scans = scans;
}
if (debugLevel > 0) { // -2) { // 100) {
{
double [][] dbg_scans = new double[scans.length][];
for (int i = 0; i < dbg_scans.length;i++) {
dbg_scans[i] = filtered_scans[i].clone();
if (i != 1) {
for (int j = 0; j < dbg_scans[i].length; j++) if (filtered_scans[1][j]<=0.0) {
dbg_scans[i][j] = Double.NaN;
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_scans, tilesX, tilesY, true, "filtered_scans");
}
if (debugLevel > -3) { // -1) { // -2) { // 100) {
double [][] dbg_scans = new double[scans.length][];
for (int i = 0; i < dbg_scans.length;i++) {
dbg_scans[i] = scans[i].clone();
if (i != 1) {
for (int j = 0; j < dbg_scans[i].length; j++) if (scans[1][j]<=0.0) {
dbg_scans[i][j] = Double.NaN;
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_scans, tilesX, tilesY, true, "scans-after");
(new showDoubleFloatArrays()).showArrays(gt_disparity_strength[0], tilesX, tilesY, true, "gt_disparity_strength");
}
}
if (debugLevel > -2) {
System.out.println("lazyEyeCorrectionFromGT() 1: removing tiles with residual disparity absoulte value > "+lazyEyeCompDiff);
}
double [][] combo_mismatch = new double [NUM_SLICES][num_tiles];
for (int ns = 0; ns < num_scans; ns++){
for (int nTile = 0; nTile < num_tiles; nTile++) {
if ((nTile == dbg_nTile) || (nTile == 24971)){
System.out.println("lazyEyeCorrectionFromGT().1: nTile="+nTile); // filtered_scans[2][37005] = NaN
}
// double w = filtered_scans[ns * NUM_SLICES + 1][nTile];
// if ((w > 0.0) && (gt_disparity_strength[ns][1][nTile] > 0.0)){ // filtered strength may be non-zero where gt_disparity_strength[ns][1][nTile] is -> NaN
// reversing - use GT strength, but skip if there is no filtered?
double w = gt_disparity_strength[ns][1][nTile]; // GT data
if ((w > 0.0) && (filtered_scans[ns * NUM_SLICES + 1][nTile] > 0.0)){ // filtered strength may be non-zero where gt_disparity_strength[ns][1][nTile] is -> NaN
double disp = filtered_scans[ns * NUM_SLICES + 0][nTile];
if (Math.abs(disp) <= lazyEyeCompDiff) {
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] += filtered_scans[ns * NUM_SLICES + i][nTile] * w;
}
//FIXME: ???? target_disparity is not 0 for bg
// combo_mismatch combines both infinity and regular for the same tile, mixing "disparity" and "target disparity" with weights and magic_scale
// Seems to be wrong, as target_disparity is only estimated disparity, not measured. Or is it measured for non-infinity?
// At least bg scan is measured with disparity =0, even as target_disparity is not 0
// combo data is later used as a non-infinity to correct all but disparity
combo_mismatch[0][nTile] += gt_disparity_strength[ns][0][nTile] * w;
combo_mismatch[1][nTile] += w;
}
}
}
}
for (int nTile = 0; nTile < num_tiles; nTile++) {
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrectionFromGT().2: nTile="+nTile);
}
double w = combo_mismatch[1][nTile];
if (w > 0.0){
for (int i = 0; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] /= w;
}
} else {
for (int i = 0; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] = Double.NaN;
}
}
}
// reduce influence of high disparity, using combined disparity
// double norm_ly_disparity = 100.0; // disabling
for (int nTile = 0; nTile < num_tiles; nTile++) {
if ((combo_mismatch[0][nTile] > 0) && (combo_mismatch[0][nTile] > ly_norm_disp)) { // why 1-st term?
combo_mismatch[1][nTile] *= ly_norm_disp/combo_mismatch[0][nTile];
}
}
// instance of class to operate navigation over tiles
// compare tile disparity (combo) with those of neighbors, discard if too different
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX);
for (int nTile = 0; nTile < num_tiles; nTile++) if (combo_mismatch[1][nTile] > 0.0){
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrectionFromGT().3: nTile="+nTile);
}
double d = combo_mismatch[0][nTile];
double lev = lazyEyeDispVariation + lazyEyeDispRelVariation * d;
for (int dir = 0; dir <8; dir++){
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ((nTile1 >= 0) && (combo_mismatch[1][nTile1] > 0.0)){
if (Math.abs(combo_mismatch[0][nTile1] - d) > lev) {
combo_mismatch[1][nTile] = 0.0;
combo_mismatch[0][nTile] = Double.NaN;
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] = Double.NaN;
}
break;
}
}
}
}
// here combo_mismatch[2][37005] = Double.NaN,combo_mismatch[1][37005] != 0.0, combo_mismatch[0][37005] = 0.0
if (debugLevel > 0) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
}
// if (clt_parameters.lyf_filter) {
if (filter_lyf) {
combo_mismatch = filterLazyEyePairs (
combo_mismatch, // final double[][] samples_in,
clt_parameters.lyf_smpl_side , // 8, // final int smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.lyf_rms_max , // 0.25, // final double rms_max, TODO: find reasonable one not critical?
clt_parameters.lyf_frac_keep , // 0.5, // final double frac_keep,
clt_parameters.lyf_min_samples , // 5, // final int min_samples,
clt_parameters.lyf_norm_center , // true, // final boolean norm_center, // if there are more tiles that fit than minsamples, replace with a single equal weight
tilesX); // final int tilesX);
}
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "filtered_mismatch" , prefixes);
}
// no need to extract and filter infinity data
// make all zero strength tiles to have NaN values to use histrograms in ImageJ
for (int nt = 0; nt < combo_mismatch[INDEX_10_WEIGHT].length; nt++ ) {
if (combo_mismatch[INDEX_10_WEIGHT][nt] == 0.0) {
for (int i = 0; i < NUM_SLICES; i++) if (i != INDEX_10_WEIGHT){
combo_mismatch[i][nt] = Double.NaN;
}
}
}
// static final int INDEX_10_WEIGHT = 1;
System.out.println("test123");
if ((debugLevel > -1) && (hist_smpl_side > 0)) { // 0) {
String [] titles = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, tilesY, true, "inf_and_ly",titles);
int step = hist_smpl_side; // should be the same for both filters
int tilesX1 = tilesX/step;
int tilesY1 = tilesY/step;
int num_tiles1 = tilesX1 * tilesY1;
double [][] dbg_img = new double [combo_mismatch.length][num_tiles1];
for (int tY = 0; tY < tilesY1; tY++) {
for (int tX = 0; tX < tilesX1; tX++) {
int nTile1 = tX + tY*tilesX1;
for (int sY = 0; sY < step; sY ++) {
for (int sX = 0; sX < step; sX ++) {
int nTile = (sX + step * tX) + (sY + step * tY) * tilesX;
double w = combo_mismatch[1][nTile];
if (w > 0.0){
for (int i = 0; i < NUM_SLICES; i++) if (i != 1) {
dbg_img[i][nTile1] += w * combo_mismatch[i][nTile];
}
dbg_img[1][nTile1] += w;
}
}
}
double w = dbg_img[1][nTile1];
if (w > 0.0){
for (int i = 0; i < NUM_SLICES; i++) if (i != 1) {
dbg_img[i][nTile1] /= w;
}
} else {
for (int i = 0; i < NUM_SLICES; i++) if (i != 1) {
dbg_img[i][nTile1] = Double.NaN;
}
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX1, tilesY1, true, "inf_and_ly8",titles);
}
System.out.println("test1234a");
// create list for infinity data
// /clt_parameters.ly_inf_en,
// adjust weight to balance infinity data and lazy eye one, so "infinity" (or really far) tiles impact is not too small even
// if there is little of infinity in the scene. As the ground truth (rig data) is known, infinity does not need to be guessed
// from the images
// final double inf_fraction, // fraction of the weight for the infinity tiles
// final double inf_max_disparity, // use all smaller disparities as inf_fraction
double [] total_weights = new double[2];
for (int nTile = 0; nTile < combo_mismatch[INDEX_10_WEIGHT].length; nTile++ ) if (center_mask[nTile]){
if (combo_mismatch[INDEX_10_DISPARITY][nTile] <= inf_max_disparity) {
total_weights[0] += combo_mismatch[INDEX_10_WEIGHT][nTile];
} else {
total_weights[1] += combo_mismatch[INDEX_10_WEIGHT][nTile];
}
}
double inf_fraction_limited = (inf_fraction >= 0.0) ?((inf_fraction > 1.0) ? 1.0 : inf_fraction):0.0;
double [] weights = {
inf_fraction_limited * (total_weights[0] + total_weights[1]) / total_weights[0],
(1.0 - inf_fraction_limited) * (total_weights[0] + total_weights[1]) / total_weights[1],
};
if (weights[0]> weights[1]) {
if (debugLevel>-1) {
System.out.println("Boosting weights of far tiles (weights[0]="+weights[0]+", weights[1]="+weights[1]+", so keeping original weights");
}
for (int nTile = 0; nTile < num_tiles; nTile++) {
if (combo_mismatch[INDEX_10_DISPARITY][nTile] <= inf_max_disparity) {
combo_mismatch[1][nTile] *= weights[0];
} else {
combo_mismatch[1][nTile] *= weights[1];
}
}
} else {
if (debugLevel>-1) {
System.out.println("There are already more far tiles than requested (weights[0]="+weights[0]+", weights[1]="+weights[1]+", so keeping original weights");
}
}
ArrayList<Sample> samples_list = new ArrayList<Sample>();
for (int nTile = 0; nTile < num_tiles; nTile++) if (combo_mismatch[INDEX_10_WEIGHT][nTile] > 0.0) {
samples_list.add(new Sample(0, nTile, combo_mismatch[INDEX_10_WEIGHT][nTile])); // first should be 0 to use disparity
if (Double.isNaN(combo_mismatch[INDEX_10_DISPARITY][nTile] )) {
System.out.println("lazyEyeCorrectionFromGT(): Double.isNaN(combo_mismatch["+INDEX_10_DISPARITY+"]["+nTile+"])");
}
}
if (debugLevel > 1) {
double inf_weight = 0.0;
for (Sample s: samples_list) {
inf_weight += s.weight;
}
System.out.println("lazyEyeCorrectionFromGT(): number of all samples="+samples_list.size()+", total weight = "+inf_weight);
}
if (debugLevel > 1) {
String [] titles = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(filtered_scans, tilesX, tilesY, true, "filtered_scans_a" , titles);
}
if (debugLevel > 1) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
}
ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>());
// inf_and_ly here has filtered disparity and offsets, should be process clt_parameters.ly_inf_disp before filters
// for rig with known disparity - use series = 0 - it will allow disparity adjustment
double [][][] mismatch_corr_coefficients = infinityMismatchCorrection(
clt_parameters.disp_scan_start, // final double disp_scan_start,
clt_parameters.disp_scan_step, // final double disp_scan_step,
use_poly, // final boolean use_poly,
clt_parameters.fcorr_quadratic, // final boolean use_quadratic,
true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
// too late to restore disparity - should be dome earlier
false, // final boolean use_disparity, // for infinity
true, // clt_parameters.ly_inf_disp, //final boolean allow_dispatity,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
combo_mismatch, // double [][] disp_strength,
samples_list, // ArrayList<Sample> samples_list,
tilesX, // int tilesX,
magic_coeff, // double , // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
mismatch_list, // ArrayList<Mismatch> mismatch_list,
debugLevel); // int debugLevel)
if (debugLevel > -2) {
System.out.println("===== lazyEyeCorrectionFromGT(): correction coefficients =====");
if (mismatch_corr_coefficients != null) {
show_fine_corr(
mismatch_corr_coefficients,
"mismatch_corr_coefficients");
} else {
System.out.println("Are null - non-null are for poly correction only");
}
}
if (!use_poly && (mismatch_list != null)){
double [] old_new_rms = new double[1];
boolean apply_extrinsic = true;
int solveCorr_debug = ((clt_parameters.lym_iter == 1) && (clt_parameters.ly_par_sel != 0))? 2 : debugLevel;
GeometryCorrection.CorrVector corr_vector = solveCorr (
clt_parameters.ly_inf_en, // boolean use_disparity, // if true will ignore disparity data even if available (was false)
clt_parameters.ly_aztilt_en,// boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.ly_diff_roll_en,// boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
clt_parameters.ly_inf_force, // boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength, // boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_par_sel, //int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
// 2); // debugLevel); // 2); // 1); // int debugLevel)
solveCorr_debug); // debugLevel); // 2); // 1); // int debugLevel)
//TODO: ** Put 2 here to debug derivative images (diff_dmv_dsym - does not match yet, probably different "addition" of angles)
if (debugLevel > -1){
System.out.println("Old extrinsic corrections:");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
System.out.println("Delta extrinsic corrections:");
System.out.println(corr_vector.toString());
}
if (apply_extrinsic){
qc.geometryCorrection.getCorrVector().incrementVector(corr_vector, clt_parameters.ly_corr_scale);
if (debugLevel > -1){
System.out.println("New extrinsic corrections:");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
}
}
mismatch_corr_coefficients = new double [1][2][];
mismatch_corr_coefficients[0][0] = corr_vector.toSymArray(null);
mismatch_corr_coefficients[0][1] = old_new_rms;
} else {
if (debugLevel > -2){
System.out.println("Extrinsic parameters (tilt, azimuth, roll) of subcameras is disabled, use_poly="+
use_poly+" (should be false for extrinsics)");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
}
return mismatch_corr_coefficients;
}
return mismatch_corr_coefficients;
}
public double [][] combineCltMismatches( public double [][] combineCltMismatches(
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][][] clt_mismatches, double [][][] clt_mismatches,
...@@ -2458,6 +2929,9 @@ System.out.println("test1234"); ...@@ -2458,6 +2929,9 @@ System.out.println("test1234");
for (int n = 0; n < 2* NUM_SENSORS; n++){ for (int n = 0; n < 2* NUM_SENSORS; n++){
// jt[npar][2 * NUM_SENSORS * indx + n] = j_partial[n][npar]; // here Jacobian was not transposed // jt[npar][2 * NUM_SENSORS * indx + n] = j_partial[n][npar]; // here Jacobian was not transposed
jt[npar][2 * NUM_SENSORS * indx + n] = jt_partial[npar][n]; jt[npar][2 * NUM_SENSORS * indx + n] = jt_partial[npar][n];
if (Double.isNaN(jt_partial[npar][n])) {
System.out.println("getJacobianTransposed(): npar="+npar+", indx="+indx+", n="+n);
}
} }
} }
if (debugLevel > 0){ if (debugLevel > 0){
...@@ -2700,6 +3174,9 @@ System.out.println("test1234"); ...@@ -2700,6 +3174,9 @@ System.out.println("test1234");
for (int j = i; j < jt.length; j++){ for (int j = i; j < jt.length; j++){
for (int k = 0; k < jt[0].length; k++){ for (int k = 0; k < jt[0].length; k++){
jtj[i][j] += jt[i][k] * jt[j][k] * w[k]; jtj[i][j] += jt[i][k] * jt[j][k] * w[k];
if (Double.isNaN(jtj[i][j])) {
System.out.println("i="+i+", j="+j+", k="+k);
}
} }
} }
} }
......
...@@ -2856,11 +2856,29 @@ public class EyesisCorrectionParameters { ...@@ -2856,11 +2856,29 @@ public class EyesisCorrectionParameters {
public double gr_unique_tol = 0.15; // Do not re-measure correlation if target disparity differs from some previous by this public double gr_unique_tol = 0.15; // Do not re-measure correlation if target disparity differs from some previous by this
public double gr_unique_pretol = 0.5; // Larger tolerance for expanding (not refining) public double gr_unique_pretol = 0.5; // Larger tolerance for expanding (not refining)
public boolean ft_mod_strength = true; // When set, multiply each tile strength by the number of selected neighbors
public boolean ft_clusterize_by_highest = true; // Clusterize using disparity horizontal maximums for fronto planes and minimums - for horizontal. False - use histograms
public double ft_clust_sigma = 0.7; // Blur disparity before argmax/argmin for initial clusterization
public double ft_disp_arange_vert = 0.07; // Absolute disparity range for fronto clusters
public double ft_disp_rrange_vert = 0.01; // Relative disparity range for fronto clusters
public double ft_disp_arange_hor = 0.035; // Absolute disparity range for horizontal clusters
public double ft_disp_rrange_hor = 0.005; // Relative disparity range for horizontal clusters
public double ft_tolerance_above_near = 100.0; // Actual disparity positive tolerance over blurred disparity argmax range
public double ft_tolerance_below_near = -0.01; // Actual disparity negative tolerance under blurred disparity argmax range
public double ft_tolerance_above_far = 0.07; // Actual disparity positive tolerance over blurred disparity argmin range
public double ft_tolerance_below_far = 0.1; // Actual disparity negative tolerance under blurred disparity argmin range
public int ft_hor_vert_overlap = 2; // Allow clusters tile sharing between fronto and horizontal. 2 - 1 tile in 8 directions, 1 - 1 tile in 4 directions
public int ft_used_companions = 5; // Cell that has this many new used companions is considered used (borders and already use3d are considered used too)
public int ft_used_true_companions = 1; // There should be at least this many new selected tiles among neighbors.,
public boolean plPreferDisparity = false;// Always start with disparity-most axis (false - lowest eigenvalue) public boolean plPreferDisparity = false;// Always start with disparity-most axis (false - lowest eigenvalue)
public double plDispNorm = 5.0; // Normalize disparities to the average if above (now only for eigenvalue comparison) public double plDispNorm = 5.0; // Normalize disparities to the average if above (now only for eigenvalue comparison)
public double plFrontoTol = 0.0; // for compatibility with old //0.1; // Fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable public double plFrontoTol = 0.0; // for compatibility with old //0.1; // Fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
public double plFrontoRms = 0.05; // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes public double plFrontoRms = 0.05; // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
public double plFrontoOffs = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable public double plFrontoOffs = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
public double PlFrontoPow = 1.0; // increase weight even more
public double plBlurBinVert = 1.2; // Blur disparity histograms for constant disparity clusters by this sigma (in bins) public double plBlurBinVert = 1.2; // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
public double plBlurBinHor = 0.8; // Blur disparity histograms for horizontal clusters by this sigma (in bins) public double plBlurBinHor = 0.8; // Blur disparity histograms for horizontal clusters by this sigma (in bins)
public double plMaxDiffVert = 0.4; // Maximal normalized disparity difference when initially assigning to vertical plane public double plMaxDiffVert = 0.4; // Maximal normalized disparity difference when initially assigning to vertical plane
...@@ -3100,6 +3118,8 @@ public class EyesisCorrectionParameters { ...@@ -3100,6 +3118,8 @@ public class EyesisCorrectionParameters {
public boolean replaceWeakOutliers = true; // false; public boolean replaceWeakOutliers = true; // false;
public boolean debug_initial_discriminate = false;
public boolean dbg_migrate = true; public boolean dbg_migrate = true;
// other debug images // other debug images
...@@ -3522,11 +3542,27 @@ public class EyesisCorrectionParameters { ...@@ -3522,11 +3542,27 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"gr_unique_tol", this.gr_unique_tol +""); properties.setProperty(prefix+"gr_unique_tol", this.gr_unique_tol +"");
properties.setProperty(prefix+"gr_unique_pretol", this.gr_unique_pretol +""); properties.setProperty(prefix+"gr_unique_pretol", this.gr_unique_pretol +"");
properties.setProperty(prefix+"ft_mod_strength", this.ft_mod_strength +"");
properties.setProperty(prefix+"ft_clusterize_by_highest", this.ft_clusterize_by_highest +"");
properties.setProperty(prefix+"ft_clust_sigma", this.ft_clust_sigma +"");
properties.setProperty(prefix+"ft_disp_arange_vert", this.ft_disp_arange_vert +"");
properties.setProperty(prefix+"ft_disp_rrange_vert", this.ft_disp_rrange_vert +"");
properties.setProperty(prefix+"ft_disp_arange_hor", this.ft_disp_arange_hor +"");
properties.setProperty(prefix+"ft_disp_rrange_hor", this.ft_disp_rrange_hor +"");
properties.setProperty(prefix+"ft_tolerance_above_near", this.ft_tolerance_above_near +"");
properties.setProperty(prefix+"ft_tolerance_below_near", this.ft_tolerance_below_near +"");
properties.setProperty(prefix+"ft_tolerance_above_far", this.ft_tolerance_above_far +"");
properties.setProperty(prefix+"ft_tolerance_below_far", this.ft_tolerance_below_far +"");
properties.setProperty(prefix+"ft_hor_vert_overlap", this.ft_hor_vert_overlap +"");
properties.setProperty(prefix+"ft_used_companions", this.ft_used_companions +"");
properties.setProperty(prefix+"ft_used_true_companions", this.ft_used_true_companions +"");
properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+""); properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+"");
properties.setProperty(prefix+"plDispNorm", this.plDispNorm +""); properties.setProperty(prefix+"plDispNorm", this.plDispNorm +"");
properties.setProperty(prefix+"plFrontoTol", this.plFrontoTol +""); properties.setProperty(prefix+"plFrontoTol", this.plFrontoTol +"");
properties.setProperty(prefix+"plFrontoRms", this.plFrontoRms +""); properties.setProperty(prefix+"plFrontoRms", this.plFrontoRms +"");
properties.setProperty(prefix+"plFrontoOffs", this.plFrontoOffs +""); properties.setProperty(prefix+"plFrontoOffs", this.plFrontoOffs +"");
properties.setProperty(prefix+"PlFrontoPow", this.PlFrontoPow +"");
properties.setProperty(prefix+"plBlurBinVert", this.plBlurBinVert +""); properties.setProperty(prefix+"plBlurBinVert", this.plBlurBinVert +"");
properties.setProperty(prefix+"plBlurBinHor", this.plBlurBinHor +""); properties.setProperty(prefix+"plBlurBinHor", this.plBlurBinHor +"");
...@@ -3741,6 +3777,7 @@ public class EyesisCorrectionParameters { ...@@ -3741,6 +3777,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"taEnMismatch", this.taEnMismatch +""); properties.setProperty(prefix+"taEnMismatch", this.taEnMismatch +"");
properties.setProperty(prefix+"debug_initial_discriminate", this.debug_initial_discriminate+"");
properties.setProperty(prefix+"dbg_migrate", this.dbg_migrate+""); properties.setProperty(prefix+"dbg_migrate", this.dbg_migrate+"");
properties.setProperty(prefix+"dbg_early_exit", this.dbg_early_exit+""); properties.setProperty(prefix+"dbg_early_exit", this.dbg_early_exit+"");
...@@ -4168,11 +4205,30 @@ public class EyesisCorrectionParameters { ...@@ -4168,11 +4205,30 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"gr_unique_tol")!=null) this.gr_unique_tol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_tol")); if (properties.getProperty(prefix+"gr_unique_tol")!=null) this.gr_unique_tol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_tol"));
if (properties.getProperty(prefix+"gr_unique_pretol")!=null) this.gr_unique_pretol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_pretol")); if (properties.getProperty(prefix+"gr_unique_pretol")!=null) this.gr_unique_pretol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_pretol"));
if (properties.getProperty(prefix+"ft_mod_strength")!=null) this.ft_mod_strength=Boolean.parseBoolean(properties.getProperty(prefix+"ft_mod_strength"));
if (properties.getProperty(prefix+"ft_clusterize_by_highest")!=null) this.ft_clusterize_by_highest=Boolean.parseBoolean(properties.getProperty(prefix+"ft_clusterize_by_highest"));
if (properties.getProperty(prefix+"ft_clust_sigma")!=null) this.ft_clust_sigma=Double.parseDouble(properties.getProperty(prefix+"ft_clust_sigma"));
if (properties.getProperty(prefix+"ft_disp_arange_vert")!=null) this.ft_disp_arange_vert=Double.parseDouble(properties.getProperty(prefix+"ft_disp_arange_vert"));
if (properties.getProperty(prefix+"ft_disp_rrange_vert")!=null) this.ft_disp_rrange_vert=Double.parseDouble(properties.getProperty(prefix+"ft_disp_rrange_vert"));
if (properties.getProperty(prefix+"ft_disp_arange_hor")!=null) this.ft_disp_arange_hor=Double.parseDouble(properties.getProperty(prefix+"ft_disp_arange_hor"));
if (properties.getProperty(prefix+"ft_disp_rrange_hor")!=null) this.ft_disp_rrange_hor=Double.parseDouble(properties.getProperty(prefix+"ft_disp_rrange_hor"));
if (properties.getProperty(prefix+"ft_tolerance_above_near")!=null) this.ft_tolerance_above_near=Double.parseDouble(properties.getProperty(prefix+"ft_tolerance_above_near"));
if (properties.getProperty(prefix+"ft_tolerance_below_near")!=null) this.ft_tolerance_below_near=Double.parseDouble(properties.getProperty(prefix+"ft_tolerance_below_near"));
if (properties.getProperty(prefix+"ft_tolerance_above_far")!=null) this.ft_tolerance_above_far=Double.parseDouble(properties.getProperty(prefix+"ft_tolerance_above_far"));
if (properties.getProperty(prefix+"ft_tolerance_below_far")!=null) this.ft_tolerance_below_far=Double.parseDouble(properties.getProperty(prefix+"ft_tolerance_below_far"));
if (properties.getProperty(prefix+"ft_hor_vert_overlap")!=null) this.ft_hor_vert_overlap=Integer.parseInt(properties.getProperty(prefix+"ft_hor_vert_overlap"));
if (properties.getProperty(prefix+"ft_used_companions")!=null) this.ft_used_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_companions"));
if (properties.getProperty(prefix+"ft_used_true_companions")!=null) this.ft_used_true_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_true_companions"));
if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity")); if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm")); if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm"));
if (properties.getProperty(prefix+"plFrontoTol")!=null) this.plFrontoTol=Double.parseDouble(properties.getProperty(prefix+"plFrontoTol")); if (properties.getProperty(prefix+"plFrontoTol")!=null) this.plFrontoTol=Double.parseDouble(properties.getProperty(prefix+"plFrontoTol"));
if (properties.getProperty(prefix+"plFrontoRms")!=null) this.plFrontoRms=Double.parseDouble(properties.getProperty(prefix+"plFrontoRms")); if (properties.getProperty(prefix+"plFrontoRms")!=null) this.plFrontoRms=Double.parseDouble(properties.getProperty(prefix+"plFrontoRms"));
if (properties.getProperty(prefix+"plFrontoOffs")!=null) this.plFrontoOffs=Double.parseDouble(properties.getProperty(prefix+"plFrontoOffs")); if (properties.getProperty(prefix+"plFrontoOffs")!=null) this.plFrontoOffs=Double.parseDouble(properties.getProperty(prefix+"plFrontoOffs"));
if (properties.getProperty(prefix+"PlFrontoPow")!=null) this.PlFrontoPow=Double.parseDouble(properties.getProperty(prefix+"PlFrontoPow"));
if (properties.getProperty(prefix+"plBlurBinVert")!=null) this.plBlurBinVert=Double.parseDouble(properties.getProperty(prefix+"plBlurBinVert")); if (properties.getProperty(prefix+"plBlurBinVert")!=null) this.plBlurBinVert=Double.parseDouble(properties.getProperty(prefix+"plBlurBinVert"));
if (properties.getProperty(prefix+"plBlurBinHor")!=null) this.plBlurBinHor=Double.parseDouble(properties.getProperty(prefix+"plBlurBinHor")); if (properties.getProperty(prefix+"plBlurBinHor")!=null) this.plBlurBinHor=Double.parseDouble(properties.getProperty(prefix+"plBlurBinHor"));
...@@ -4390,6 +4446,7 @@ public class EyesisCorrectionParameters { ...@@ -4390,6 +4446,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"taEnMismatch")!=null) this.taEnMismatch=Boolean.parseBoolean(properties.getProperty(prefix+"taEnMismatch")); if (properties.getProperty(prefix+"taEnMismatch")!=null) this.taEnMismatch=Boolean.parseBoolean(properties.getProperty(prefix+"taEnMismatch"));
if (properties.getProperty(prefix+"debug_initial_discriminate")!=null) this.debug_initial_discriminate=Boolean.parseBoolean(properties.getProperty(prefix+"debug_initial_discriminate"));
if (properties.getProperty(prefix+"dbg_migrate")!=null) this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate")); if (properties.getProperty(prefix+"dbg_migrate")!=null) this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate"));
if (properties.getProperty(prefix+"dbg_early_exit")!=null) this.dbg_early_exit=Integer.parseInt(properties.getProperty(prefix+"dbg_early_exit")); if (properties.getProperty(prefix+"dbg_early_exit")!=null) this.dbg_early_exit=Integer.parseInt(properties.getProperty(prefix+"dbg_early_exit"));
...@@ -4904,6 +4961,37 @@ public class EyesisCorrectionParameters { ...@@ -4904,6 +4961,37 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Do not re-measure correlation if target disparity differs from some previous less", this.gr_unique_tol, 6); gd.addNumericField("Do not re-measure correlation if target disparity differs from some previous less", this.gr_unique_tol, 6);
gd.addNumericField("Larger tolerance for expanding (not refining)", this.gr_unique_pretol, 6); gd.addNumericField("Larger tolerance for expanding (not refining)", this.gr_unique_pretol, 6);
gd.addTab ("Alt CLusterize", "Alternative initial tiles clusterization");
gd.addCheckbox ("Modify cluster strengths", this.ft_mod_strength,
"Supplement sum of strengths with other parameters, such as density and height ");
gd.addCheckbox ("Enable alternative initial tile clusterization", this.ft_clusterize_by_highest,
"Clusterize using disparity horizontal maximums for fronto planes and minimums - for horizontal. False - use histograms");
gd.addNumericField("Disparity blur sigma", this.ft_clust_sigma, 4, 6,"pix",
"Blur disparity before finding each line max (for fronto planes ) or min (for horizontal planes) during initial clusterization");
gd.addNumericField("Absolute disparity range for fronto clusters", this.ft_disp_arange_vert, 4, 6,"pix",
"Disparity range for blurred disparity (down from max disparity) for fronto planes");
gd.addNumericField("Relative disparity range for fronto clusters", this.ft_disp_rrange_vert, 4, 6,"pix/pix",
"Increase disparity range for fronto clusters for each disparity pixel");
gd.addNumericField("Absolute disparity range for horizontal clusters", this.ft_disp_arange_hor, 4, 6,"pix",
"Disparity range for blurred disparity (up from min disparity to horizontal difference) for horizontal planes");
gd.addNumericField("Relative disparity range for horizontal clusters", this.ft_disp_rrange_hor, 4, 6,"pix/pix",
"Increase disparity range for horizontal clusters for each disparity pixel");
gd.addNumericField("Actual disparity positive tolerance over blurred disparity max range", this.ft_tolerance_above_near, 4, 6,"pix",
"Allow measured tile disparity above cluster disparity range for fronto clusters");
gd.addNumericField("Actual disparity negative tolerance over blurred disparity max range", this.ft_tolerance_below_near, 4, 6,"pix",
"Allow measured tile disparity below cluster disparity range for fronto planes");
gd.addNumericField("Actual disparity positive tolerance over blurred disparity min range", this.ft_tolerance_above_far, 4, 6,"pix",
"Allow measured tile disparity above cluster disparity range for horizontal planes");
gd.addNumericField("Actual disparity negative tolerance over blurred disparity min range", this.ft_tolerance_below_far, 4, 6,"pix",
"Allow measured tile disparity below cluster disparity range for horizontal planes");
gd.addNumericField("Fronto/horizontal selections overlap", this.ft_hor_vert_overlap, 0,6,"",
"Allow clusters tile sharing between fronto and horizontal. 2 - 1 tile in 8 directions, 1 - 1 tile in 4 directions");
gd.addNumericField("Mark as used if has used/disabled neighbors ", this.ft_used_companions, 0,6,"",
"Cell that has this many new used companions is considered used (borders and already use3d are considered used too)");
gd.addNumericField("Minimal number of new used cells among new/old used and marginal tiles", this.ft_used_true_companions, 0,6,"",
"There should be at least this many new selected tiles among neighbors");
gd.addTab ("Plane Det", "Planes detection"); gd.addTab ("Plane Det", "Planes detection");
gd.addMessage ("--- Planes detection ---"); gd.addMessage ("--- Planes detection ---");
...@@ -4915,6 +5003,8 @@ public class EyesisCorrectionParameters { ...@@ -4915,6 +5003,8 @@ public class EyesisCorrectionParameters {
"Target half-thikness of the fronto planes. Similar to sqrt(plMaxEigen) for other planes"); "Target half-thikness of the fronto planes. Similar to sqrt(plMaxEigen) for other planes");
gd.addNumericField("Fronto offset", this.plFrontoOffs, 4,6,"pix", gd.addNumericField("Fronto offset", this.plFrontoOffs, 4,6,"pix",
"Increasing weights of the near tiles by using difference between tile disparity and reduced by this value average as weight. If <= 0 - disable feature"); "Increasing weights of the near tiles by using difference between tile disparity and reduced by this value average as weight. If <= 0 - disable feature");
gd.addNumericField("Fronto power", this.PlFrontoPow, 4,6,"pix",
"Increasing weights of the near tiles by even more (see previous parameter) by raising disparity difference to this power");
gd.addNumericField("Blur disparity histograms for constant disparity clusters by this sigma (in bins)", this.plBlurBinVert, 6); gd.addNumericField("Blur disparity histograms for constant disparity clusters by this sigma (in bins)", this.plBlurBinVert, 6);
gd.addNumericField("Blur disparity histograms for horizontal clusters by this sigma (in bins)", this.plBlurBinHor, 6); gd.addNumericField("Blur disparity histograms for horizontal clusters by this sigma (in bins)", this.plBlurBinHor, 6);
gd.addNumericField("Maximal normalized disparity difference when initially assigning to vertical plane", this.plMaxDiffVert, 6); gd.addNumericField("Maximal normalized disparity difference when initially assigning to vertical plane", this.plMaxDiffVert, 6);
...@@ -5144,6 +5234,8 @@ public class EyesisCorrectionParameters { ...@@ -5144,6 +5234,8 @@ public class EyesisCorrectionParameters {
gd.addTab ("Debug", "Other debug images"); gd.addTab ("Debug", "Other debug images");
gd.addMessage ("--- Other debug images ---"); gd.addMessage ("--- Other debug images ---");
// clt_parameters.debug_initial_discriminate, // final boolean debug_initial_discriminate,
gd.addCheckbox ("Debug initial clusterization of the supertile tiles", this.debug_initial_discriminate);
gd.addCheckbox ("Test new mode after migration", this.dbg_migrate); gd.addCheckbox ("Test new mode after migration", this.dbg_migrate);
gd.addNumericField("Temporay exit stage (0- normal execution)", this.dbg_early_exit, 0,6,"","Temporary exit at intermediate stage (0 - normal)"); gd.addNumericField("Temporay exit stage (0- normal execution)", this.dbg_early_exit, 0,6,"","Temporary exit at intermediate stage (0 - normal)");
...@@ -5567,11 +5659,27 @@ public class EyesisCorrectionParameters { ...@@ -5567,11 +5659,27 @@ public class EyesisCorrectionParameters {
this.gr_unique_tol= gd.getNextNumber(); this.gr_unique_tol= gd.getNextNumber();
this.gr_unique_pretol= gd.getNextNumber(); this.gr_unique_pretol= gd.getNextNumber();
this.ft_mod_strength= gd.getNextBoolean();
this.ft_clusterize_by_highest= gd.getNextBoolean();
this.ft_clust_sigma= gd.getNextNumber();
this.ft_disp_arange_vert= gd.getNextNumber();
this.ft_disp_rrange_vert= gd.getNextNumber();
this.ft_disp_arange_hor= gd.getNextNumber();
this.ft_disp_rrange_hor= gd.getNextNumber();
this.ft_tolerance_above_near= gd.getNextNumber();
this.ft_tolerance_below_near= gd.getNextNumber();
this.ft_tolerance_above_far= gd.getNextNumber();
this.ft_tolerance_below_far= gd.getNextNumber();
this.ft_hor_vert_overlap= (int) gd.getNextNumber();
this.ft_used_companions= (int) gd.getNextNumber();
this.ft_used_true_companions= (int) gd.getNextNumber();
this.plPreferDisparity= gd.getNextBoolean(); this.plPreferDisparity= gd.getNextBoolean();
this.plDispNorm= gd.getNextNumber(); this.plDispNorm= gd.getNextNumber();
this.plFrontoTol = gd.getNextNumber(); this.plFrontoTol = gd.getNextNumber();
this.plFrontoRms = gd.getNextNumber(); this.plFrontoRms = gd.getNextNumber();
this.plFrontoOffs = gd.getNextNumber(); this.plFrontoOffs = gd.getNextNumber();
this.PlFrontoPow = gd.getNextNumber();
this.plBlurBinVert= gd.getNextNumber(); this.plBlurBinVert= gd.getNextNumber();
this.plBlurBinHor= gd.getNextNumber(); this.plBlurBinHor= gd.getNextNumber();
...@@ -5790,6 +5898,7 @@ public class EyesisCorrectionParameters { ...@@ -5790,6 +5898,7 @@ public class EyesisCorrectionParameters {
this.taEnFlaps= gd.getNextBoolean(); this.taEnFlaps= gd.getNextBoolean();
this.taEnMismatch= gd.getNextBoolean(); this.taEnMismatch= gd.getNextBoolean();
this.debug_initial_discriminate= gd.getNextBoolean();
this.dbg_migrate= gd.getNextBoolean(); this.dbg_migrate= gd.getNextBoolean();
this.dbg_early_exit = (int) gd.getNextNumber(); this.dbg_early_exit = (int) gd.getNextNumber();
......
...@@ -584,6 +584,7 @@ private Panel panel1, ...@@ -584,6 +584,7 @@ private Panel panel1,
// addButton("CLT 2*4 images - 2", panelClt4, color_conf_process); // addButton("CLT 2*4 images - 2", panelClt4, color_conf_process);
// addButton("CLT 2*4 images - 3", panelClt4, color_conf_process); // addButton("CLT 2*4 images - 3", panelClt4, color_conf_process);
addButton("SHOW extrinsics", panelClt4, color_configure); addButton("SHOW extrinsics", panelClt4, color_configure);
addButton("RIG DSI", panelClt4, color_conf_process);
addButton("MAIN extrinsics", panelClt4, color_process); addButton("MAIN extrinsics", panelClt4, color_process);
addButton("AUX extrinsics", panelClt4, color_process); addButton("AUX extrinsics", panelClt4, color_process);
addButton("RIG extrinsics", panelClt4, color_conf_process); addButton("RIG extrinsics", panelClt4, color_conf_process);
...@@ -4263,83 +4264,14 @@ private Panel panel1, ...@@ -4263,83 +4264,14 @@ private Panel panel1,
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
clt3d(adjust_extrinsics, adjust_poly); clt3d(adjust_extrinsics, adjust_poly);
/*
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
QuadCLT.PREFIX,
PROPERTIES,
EYESIS_CORRECTIONS,
CORRECTION_PARAMETERS);
if (DEBUG_LEVEL > 0){
System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
}
}
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return;
EYESIS_CORRECTIONS.initSensorFiles(DEBUG_LEVEL);
int numChannels=EYESIS_CORRECTIONS.getNumChannels();
CHANNEL_GAINS_PARAMETERS.modifyNumChannels(numChannels);
if (!QUAD_CLT.CLTKernelsAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Reading CLT kernels");
}
QUAD_CLT.readCLTKernels(
CLT_PARAMETERS,
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
if (DEBUG_LEVEL > 1){
QUAD_CLT.showCLTKernels(
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
}
}
if (!QUAD_CLT.geometryCorrectionAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Calculating geometryCorrection");
}
if (!QUAD_CLT.initGeometryCorrection(DEBUG_LEVEL+2)){
return;
}
}
QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
// NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
// CONVOLVE_FFT_SIZE, //int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
*/
return; return;
} else if (label.equals("AUX extrinsics") || label.equals("AUX Poly corr")) { } else if (label.equals("AUX extrinsics") || label.equals("AUX Poly corr")) {
boolean adjust_extrinsics = label.equals("AUX extrinsics") || label.equals("AUX Poly corr"); boolean adjust_extrinsics = label.equals("AUX extrinsics") || label.equals("AUX Poly corr");
boolean adjust_poly = label.equals("AUX Poly corr"); boolean adjust_poly = label.equals("AUX Poly corr");
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
clt3d_aux(adjust_extrinsics, adjust_poly);
/*
if (QUAD_CLT_AUX == null){ if (QUAD_CLT_AUX == null){
if (EYESIS_CORRECTIONS_AUX == null) { if (EYESIS_CORRECTIONS_AUX == null) {
EYESIS_CORRECTIONS_AUX = new EyesisCorrections(SYNC_COMMAND.stopRequested,CORRECTION_PARAMETERS.getAux()); EYESIS_CORRECTIONS_AUX = new EyesisCorrections(SYNC_COMMAND.stopRequested,CORRECTION_PARAMETERS.getAux());
...@@ -4408,6 +4340,7 @@ private Panel panel1, ...@@ -4408,6 +4340,7 @@ private Panel panel1,
true, true,
PROPERTIES); PROPERTIES);
} }
*/
return; return;
} else if (label.equals("CLT planes")) { } else if (label.equals("CLT planes")) {
...@@ -4518,6 +4451,7 @@ private Panel panel1, ...@@ -4518,6 +4451,7 @@ private Panel panel1,
///======================================== ///========================================
QUAD_CLT.batchCLT3d( QUAD_CLT.batchCLT3d(
TWO_QUAD_CLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters, DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
// NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters, // NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
...@@ -4614,6 +4548,13 @@ private Panel panel1, ...@@ -4614,6 +4548,13 @@ private Panel panel1,
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
groundTruth(); groundTruth();
return; return;
/* ======================================================================== */
} else if (label.equals("RIG DSI")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
rigDSI();
return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Show biscan")) { } else if (label.equals("Show biscan")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
...@@ -5004,7 +4945,13 @@ private Panel panel1, ...@@ -5004,7 +4945,13 @@ private Panel panel1,
} }
if (TWO_QUAD_CLT == null) { if (TWO_QUAD_CLT == null) {
TWO_QUAD_CLT = new TwoQuadCLT(); TWO_QUAD_CLT = new TwoQuadCLT(QUAD_CLT,QUAD_CLT_AUX);
} else {
// is it needed to update main/aux? Or it never changes?
TWO_QUAD_CLT.quadCLT_main=QUAD_CLT;
TWO_QUAD_CLT.quadCLT_aux=QUAD_CLT_AUX;
// will need to make sure that miScan image is not from the previous scene
} }
return true; return true;
} }
...@@ -5155,6 +5102,83 @@ private Panel panel1, ...@@ -5155,6 +5102,83 @@ private Panel panel1,
// boolean adjust_extrinsics = label.equals("MAIN extrinsics") || label.equals("CLT Poly corr"); // boolean adjust_extrinsics = label.equals("MAIN extrinsics") || label.equals("CLT Poly corr");
// boolean adjust_poly = label.equals("CLT Poly corr"); // boolean adjust_poly = label.equals("CLT Poly corr");
public boolean clt3d_aux(
boolean adjust_extrinsics,
boolean adjust_poly
) {
if (QUAD_CLT_AUX == null){
if (EYESIS_CORRECTIONS_AUX == null) {
EYESIS_CORRECTIONS_AUX = new EyesisCorrections(SYNC_COMMAND.stopRequested,CORRECTION_PARAMETERS.getAux());
}
QUAD_CLT_AUX = new QuadCLT (
QuadCLT.PREFIX_AUX,
PROPERTIES,
EYESIS_CORRECTIONS_AUX,
CORRECTION_PARAMETERS.getAux());
if (DEBUG_LEVEL > 0){
System.out.println("Created new QuadCLT instance for AUX camera, will need to read CLT kernels for aux camera");
}
}
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
EYESIS_CORRECTIONS_AUX.initSensorFiles(DEBUG_LEVEL);
int numChannelsAux=EYESIS_CORRECTIONS_AUX.getNumChannels();
CHANNEL_GAINS_PARAMETERS_AUX.modifyNumChannels(numChannelsAux);
if (!QUAD_CLT_AUX.CLTKernelsAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Reading AUX CLT kernels");
}
QUAD_CLT_AUX.readCLTKernels(
CLT_PARAMETERS,
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
if (DEBUG_LEVEL > 1){
QUAD_CLT_AUX.showCLTKernels(
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
}
}
if (!QUAD_CLT_AUX.geometryCorrectionAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Calculating geometryCorrection for AUX camera");
}
if (!QUAD_CLT_AUX.initGeometryCorrection(DEBUG_LEVEL+2)){
return false;
}
}
QUAD_CLT_AUX.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly,
TWO_QUAD_CLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS_AUX, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
return true;
}
public boolean clt3d( public boolean clt3d(
boolean adjust_extrinsics, boolean adjust_extrinsics,
boolean adjust_poly boolean adjust_poly
...@@ -5206,6 +5230,7 @@ private Panel panel1, ...@@ -5206,6 +5230,7 @@ private Panel panel1,
QUAD_CLT.processCLTQuads3d( QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics, adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly, adjust_poly, // boolean adjust_poly,
TWO_QUAD_CLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters, DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
// NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters, // NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
...@@ -5218,9 +5243,6 @@ private Panel panel1, ...@@ -5218,9 +5243,6 @@ private Panel panel1,
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) { if (configPath!=null) {
saveTimestampedProperties( // save config again saveTimestampedProperties( // save config again
configPath, // full path or null configPath, // full path or null
...@@ -5272,6 +5294,53 @@ private Panel panel1, ...@@ -5272,6 +5294,53 @@ private Panel panel1,
return true; return true;
} }
public boolean rigDSI() {
long startTime=System.nanoTime();
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) {
boolean OK = clt3d(
false, // boolean adjust_extrinsics,
false); // boolean adjust_poly);
if (! OK) {
String msg = "DSI data is not available and \"CLT 3D\" failed";
IJ.showMessage("Error",msg);
System.out.println(msg);
return false;
}
}
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Creating a dual camera rig DSI from a single camera DSI ++++++++++++++");
}
boolean OK = (TWO_QUAD_CLT.rigInitialScan( // actually there is no sense to process multiple image sets. Combine with other processing?
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL -2) != null);
if (!OK) {
System.out.println("rigDSI(): Processing FAILED at "+
IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec, --- Free memory="+
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return false;
}
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
System.out.println("rigDSI(): Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec, --- Free memory="+
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
}
public boolean batchRig() { public boolean batchRig() {
long startTime=System.nanoTime(); long startTime=System.nanoTime();
/* if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) { /* if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) {
......
...@@ -35,6 +35,8 @@ public class LinkPlanes { ...@@ -35,6 +35,8 @@ public class LinkPlanes {
public double plFrontoTol; // = 0.2; plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable public double plFrontoTol; // = 0.2; plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
public double plFrontoRms; // = 0.05; // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes public double plFrontoRms; // = 0.05; // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
public double plFrontoOffs; // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable public double plFrontoOffs; // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
public double PlFrontoPow; // = 1.0; // increase weight even more
public double plMinStrength; // = 0.1; // Minimal total strength of a plane public double plMinStrength; // = 0.1; // Minimal total strength of a plane
public double plMaxEigen; // = 0.05; // Maximal eigenvalue of a plane public double plMaxEigen; // = 0.05; // Maximal eigenvalue of a plane
public double plEigenFloor; // = 0.01; // Add to eigenvalues of each participating plane and result to validate connections public double plEigenFloor; // = 0.01; // Add to eigenvalues of each participating plane and result to validate connections
...@@ -139,6 +141,7 @@ public class LinkPlanes { ...@@ -139,6 +141,7 @@ public class LinkPlanes {
plFrontoTol = clt_parameters.plFrontoTol; plFrontoTol = clt_parameters.plFrontoTol;
plFrontoRms = clt_parameters.plFrontoRms; plFrontoRms = clt_parameters.plFrontoRms;
plFrontoOffs = clt_parameters.plFrontoOffs; plFrontoOffs = clt_parameters.plFrontoOffs;
PlFrontoPow = clt_parameters.PlFrontoPow;
plMaxOverlap = clt_parameters.plMaxOverlap; plMaxOverlap = clt_parameters.plMaxOverlap;
...@@ -3994,6 +3997,7 @@ public class LinkPlanes { ...@@ -3994,6 +3997,7 @@ public class LinkPlanes {
plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
debugLevel, // final int debugLevel) debugLevel, // final int debugLevel)
dbg_tileX, dbg_tileX,
dbg_tileY); dbg_tileY);
...@@ -4519,6 +4523,7 @@ public class LinkPlanes { ...@@ -4519,6 +4523,7 @@ public class LinkPlanes {
plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
debugLevel, // final int debugLevel) debugLevel, // final int debugLevel)
dbg_tileX, dbg_tileX,
dbg_tileY); dbg_tileY);
...@@ -4613,6 +4618,7 @@ public class LinkPlanes { ...@@ -4613,6 +4618,7 @@ public class LinkPlanes {
plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature plFrontoTol, // final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes plFrontoRms, // final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable plFrontoOffs, // final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
debugLevel, // final int debugLevel) debugLevel, // final int debugLevel)
dbg_tileX, dbg_tileX,
dbg_tileY); dbg_tileY);
......
...@@ -5668,6 +5668,7 @@ public class QuadCLT { ...@@ -5668,6 +5668,7 @@ public class QuadCLT {
public void processCLTQuads3d( public void processCLTQuads3d(
boolean adjust_extrinsics, boolean adjust_extrinsics,
boolean adjust_poly, boolean adjust_poly,
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters, EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
...@@ -5700,7 +5701,20 @@ public class QuadCLT { ...@@ -5700,7 +5701,20 @@ public class QuadCLT {
scaleExposures, //output // double [] scaleExposures scaleExposures, //output // double [] scaleExposures
saturation_imp, //output // boolean [][] saturation_imp, saturation_imp, //output // boolean [][] saturation_imp,
debugLevel); // int debugLevel); debugLevel); // int debugLevel);
// if (adjust_extrinsics && (debugLevel >-2)) {
// boolean tmp_exit = (debugLevel > -10); // == true;
// System.out.println("processCLTQuads3d(): adjust_extrinsics="+adjust_extrinsics);
// if (tmp_exit) {
// System.out.println("will now exit. To continue - change variable tmp_exit in debugger" );
// if (tmp_exit) {
// return;
// }
// }
// }
boolean use_rig = (twoQuadCLT != null) && (twoQuadCLT.getBiScan(0) != null);
if (!adjust_extrinsics || !use_rig) {
// Difficult to fix: adjust extrinsics for aux - when it is adjusted alone, it will not match tiles to those of a rig!
// can use only far tiles with small gradients?
// once per quad here // once per quad here
preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
...@@ -5715,16 +5729,28 @@ public class QuadCLT { ...@@ -5715,16 +5729,28 @@ public class QuadCLT {
debugLevel); debugLevel);
// adjust extrinsics here // adjust extrinsics here
}
if (adjust_extrinsics) { if (adjust_extrinsics) {
if (use_rig) {
System.out.println("Adjust extrinsics using rig data here");
extrinsicsCLTfromGT(
twoQuadCLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevel + 2); // final int debugLevel)
} else {
System.out.println("Adjust extrinsics here"); System.out.println("Adjust extrinsics here");
extrinsicsCLT( extrinsicsCLT(
// twoQuadCLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
adjust_poly, adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus, updateStatus,// final boolean updateStatus,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
}
} else { } else {
expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
...@@ -6205,8 +6231,10 @@ public class QuadCLT { ...@@ -6205,8 +6231,10 @@ public class QuadCLT {
double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction
int bg_scan = 0; int bg_scan = 0;
int combo_scan= tp.clt_3d_passes.size()-1; int combo_scan= tp.clt_3d_passes.size()-1;
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) { if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
// if (!batch_mode && (debugLevel >-1)) { // if (!batch_mode && (debugLevel >-1)) {
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan, tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
"bg_scan"); //String title) "bg_scan"); //String title)
...@@ -6215,6 +6243,13 @@ public class QuadCLT { ...@@ -6215,6 +6243,13 @@ public class QuadCLT {
"combo_scan-"+combo_scan); //String title) "combo_scan-"+combo_scan); //String title)
} }
boolean [] bg_sel = null;
boolean [] bg_use = null;
double [] combo_disp = null;
double [] combo_str = null;
boolean [] combo_use = null;
double [] combo_overexp = null;
int num_combo = 0;
double [][] filtered_bgnd_disp_strength = tp.getFilteredDisparityStrength( double [][] filtered_bgnd_disp_strength = tp.getFilteredDisparityStrength(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,// List, first, last - to search for the already tried disparity tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,// List, first, last - to search for the already tried disparity
bg_scan, // final int measured_scan_index, // will not look at higher scans bg_scan, // final int measured_scan_index, // will not look at higher scans
...@@ -6238,10 +6273,11 @@ public class QuadCLT { ...@@ -6238,10 +6273,11 @@ public class QuadCLT {
clt_parameters.tileX, // dbg_x, // final int dbg_x, clt_parameters.tileX, // dbg_x, // final int dbg_x,
clt_parameters.tileX, // dbg_y, // final int dbg_y, clt_parameters.tileX, // dbg_y, // final int dbg_y,
debugLevelInner); // final int debugLevel) debugLevelInner); // final int debugLevel)
// prepare re-measurements of background // prepare re-measurements of background
boolean [] bg_sel = tp.clt_3d_passes.get(bg_scan).getSelected(); bg_sel = tp.clt_3d_passes.get(bg_scan).getSelected();
boolean [] bg_use = new boolean [bg_sel.length]; bg_use = new boolean [bg_sel.length];
// double [] bg_disp = tp.clt_3d_passes.get(bg_scan).getDisparity(0); // double [] bg_disp = tp.clt_3d_passes.get(bg_scan).getDisparity(0);
double [] bg_str = tp.clt_3d_passes.get(bg_scan).getStrength(); double [] bg_str = tp.clt_3d_passes.get(bg_scan).getStrength();
double [] bg_overexp = tp.clt_3d_passes.get(bg_scan).getOverexposedFraction(); double [] bg_overexp = tp.clt_3d_passes.get(bg_scan).getOverexposedFraction();
for (int nTile = 0 ; nTile < bg_use.length; nTile++) { for (int nTile = 0 ; nTile < bg_use.length; nTile++) {
...@@ -6258,10 +6294,10 @@ public class QuadCLT { ...@@ -6258,10 +6294,10 @@ public class QuadCLT {
null); // double [] disparity); // null for 0 null); // double [] disparity); // null for 0
// Prepare measurement of combo-scan - remove low strength and what was used for background // Prepare measurement of combo-scan - remove low strength and what was used for background
double [] combo_disp = tp.clt_3d_passes.get(combo_scan).getDisparity(0); combo_disp = tp.clt_3d_passes.get(combo_scan).getDisparity(0);
double [] combo_str = tp.clt_3d_passes.get(combo_scan).getStrength(); combo_str = tp.clt_3d_passes.get(combo_scan).getStrength();
boolean [] combo_use = new boolean [bg_sel.length]; combo_use = new boolean [bg_sel.length];
double [] combo_overexp = tp.clt_3d_passes.get(combo_scan).getOverexposedFraction(); combo_overexp = tp.clt_3d_passes.get(combo_scan).getOverexposedFraction();
for (int nTile = 0 ; nTile < bg_use.length; nTile++) { for (int nTile = 0 ; nTile < bg_use.length; nTile++) {
if (!bg_use[nTile] && if (!bg_use[nTile] &&
(combo_str[nTile] > clt_parameters.fcorr_inf_strength) && (combo_str[nTile] > clt_parameters.fcorr_inf_strength) &&
...@@ -6270,7 +6306,7 @@ public class QuadCLT { ...@@ -6270,7 +6306,7 @@ public class QuadCLT {
combo_use[nTile] = true; combo_use[nTile] = true;
} }
} }
int num_combo = tp.clt_3d_passes.get(combo_scan).setTileOpDisparity( num_combo = tp.clt_3d_passes.get(combo_scan).setTileOpDisparity(
combo_use, // boolean [] selection, combo_use, // boolean [] selection,
combo_disp); // double [] disparity); combo_disp); // double [] disparity);
if (debugLevel > -1) { if (debugLevel > -1) {
...@@ -6278,6 +6314,8 @@ public class QuadCLT { ...@@ -6278,6 +6314,8 @@ public class QuadCLT {
} }
// measure combo // measure combo
CLTMeasure( // perform single pass according to prepared tiles operations and disparity CLTMeasure( // perform single pass according to prepared tiles operations and disparity
image_data, // first index - number of image in a quad image_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
...@@ -6417,6 +6455,13 @@ public class QuadCLT { ...@@ -6417,6 +6455,13 @@ public class QuadCLT {
} }
double [][] target_disparity = {tp.clt_3d_passes.get(bg_scan).getDisparity(0), tp.clt_3d_passes.get(combo_scan).getDisparity(0)}; double [][] target_disparity = {tp.clt_3d_passes.get(bg_scan).getDisparity(0), tp.clt_3d_passes.get(combo_scan).getDisparity(0)};
// TODO: fix above for using GT
// use lazyEyeCorrectionFromGT(..) when ground truth data is available
double [][][] new_corr = ac.lazyEyeCorrection( double [][][] new_corr = ac.lazyEyeCorrection(
adjust_poly, // final boolean use_poly, adjust_poly, // final boolean use_poly,
true, // final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity) true, // final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity)
...@@ -6501,6 +6546,174 @@ public class QuadCLT { ...@@ -6501,6 +6546,174 @@ public class QuadCLT {
} }
public boolean extrinsicsCLTfromGT(
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean adjust_poly,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run;
int debugLevelInner = batch_mode ? -5: debugLevel;
// boolean update_disp_from_latest = clt_parameters.lym_update_disp ; // true;
int max_tries = clt_parameters.lym_iter; // 25;
double min_sym_update = clt_parameters.lym_change; // 4e-6; // stop iterations if no angle changes more than this
double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction
if ((twoQuadCLT == null) || (twoQuadCLT.getBiScan(0) == null)){
System.out.println("Rig data is not available, aborting");
return false;
}
BiScan scan = twoQuadCLT.getBiScan(0);
double [][] rig_disp_strength = scan.getDisparityStrength(
true, // final boolean only_strong,
true, // final boolean only_trusted,
true) ; // final boolean only_enabled);
if (debugLevel > 20) {
boolean tmp_exit = true;
System.out.println("extrinsicsCLTfromGT()");
if (tmp_exit) {
System.out.println("will now exit. To continue - change variable tmp_exit in debugger" );
if (tmp_exit) {
return false;
}
}
}
CLTPass3d comboScan = tp.compositeScan(
rig_disp_strength[0], // final double [] disparity,
rig_disp_strength[1], // final double [] strength,
null, // final boolean [] selected,
debugLevel); // final int debugLevel)
// comboScan will remain the same through iterations, no need to update disparity (maybe shrink selection?
AlignmentCorrection ac = new AlignmentCorrection(this);
// iteration steps
double comp_diff = min_sym_update + 1; // (> min_sym_update)
for (int num_iter = 0; num_iter < max_tries; num_iter++){
double [][] combo_mismatch = new double[12][];
CLTMeasure( // perform single pass according to prepared tiles operations and disparity
image_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
comboScan, // final CLTPass3d scan,
false, // final boolean save_textures,
true, // final boolean save_corr,
combo_mismatch, // final double [][] mismatch, // null or double [12][]
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner - 1);
double [][] scans14 = new double [14][];
scans14[14 * 0 + 0] = comboScan.disparity_map[ImageDtt.DISPARITY_INDEX_CM]; // .getDisparity(0);
scans14[14 * 0 + 1] = comboScan.getStrength();
for (int i = 0; i < combo_mismatch.length; i++) {
scans14[14 * 0 + 2 + i] = combo_mismatch[i];
}
if (debugLevelInner > 0) {
(new showDoubleFloatArrays()).showArrays(scans14, tp.getTilesX(), tp.getTilesY(), true, "scans_14"); // , titles);
}
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel > 1)) {
tp.showScan(
comboScan, // CLTPass3d scan,
"combo_scan-"+num_iter+"_iter"); //String title)
}
double [][][] new_corr;
final boolean filter_ds = false; // true;
final boolean filter_lyf = false; // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
final double inf_max_disparity = 2.0;
double [][][] gt_disparity_strength = {rig_disp_strength};
new_corr = ac.lazyEyeCorrectionFromGT(
adjust_poly, // final boolean use_poly,
true, // final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity)
clt_parameters.fcorr_radius, // final double fcorr_radius,
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
0.8*clt_parameters.disp_scan_step, // 1.5, // final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
clt_parameters.ly_smpl_side, // 3, // final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
clt_parameters.ly_smpl_num, // 5, // final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.ly_smpl_rms, // 0.1, // final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.ly_disp_var, // 0.2, // final double lazyEyeDispVariation, // 0.2, maximal full disparity difference between tgh tile and 8 neighborxs
clt_parameters.ly_disp_rvar, // 0.2, // final double lazyEyeDispRelVariation, // 0.02 Maximal relative full disparity difference to 8 neighbors
clt_parameters.ly_norm_disp, // final double ly_norm_disp, // = 5.0; // Reduce weight of higher disparity tiles
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
clt_parameters.ly_inf_frac, // 0.5, // final double inf_fraction, // fraction of the weight for the infinity tiles
inf_max_disparity, // final double inf_max_disparity, // use all smaller disparities as inf_fraction
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scans14, // disp_strength, // scans, // double [][] disp_strength,
gt_disparity_strength, // double [][][] gt_disparity_strength, // 1 pair for each 14 entries of scans_14 (normally - just 1 scan
filter_ds, // final boolean filter_ds, //
filter_lyf, // final boolean filter_lyf, // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
tp.getTilesX(), // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevelInner - 1); // + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
comp_diff = 0.0;
int num_pars = 0;
if (adjust_poly) {
apply_fine_corr(
new_corr,
debugLevelInner + 2);
for (int n = 0; n < new_corr.length; n++){
for (int d = 0; d < new_corr[n].length; d++){
for (int i = 0; i < new_corr[n][d].length; i++){
comp_diff += new_corr[n][d][i] * new_corr[n][d][i];
num_pars++;
}
}
}
comp_diff = Math.sqrt(comp_diff/num_pars);
if (debugLevel > -2) {
if ((debugLevel > -1) || (comp_diff < min_poly_update)) {
System.out.println("#### fine correction iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_poly_update+")");
}
}
if (comp_diff < min_poly_update) { // add other parameter to exit from poly
break;
}
} else {
for (int i = 0; i < new_corr[0][0].length; i++){
comp_diff += new_corr[0][0][i] * new_corr[0][0][i];
}
comp_diff = Math.sqrt(comp_diff);
if (debugLevel > -2) {
if ((debugLevel > -1) || (comp_diff < min_sym_update)) {
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]);
System.out.println("New extrinsic corrections:");
System.out.println(geometryCorrection.getCorrVector().toString());
}
}
if (comp_diff < min_sym_update) {
break;
}
}
}
return (comp_diff < (adjust_poly ? min_poly_update : min_sym_update));
}
public boolean expandCLTQuad3d( public boolean expandCLTQuad3d(
// ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path" // ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -8175,8 +8388,8 @@ public class QuadCLT { ...@@ -8175,8 +8388,8 @@ public class QuadCLT {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
final int dbg_x = 295; final int dbg_x = -295-debugLevel;
final int dbg_y = 160; final int dbg_y = -160-debugLevel;
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
...@@ -8192,7 +8405,7 @@ public class QuadCLT { ...@@ -8192,7 +8405,7 @@ public class QuadCLT {
if (tile_op[ty][tx] != 0) numTiles ++; if (tile_op[ty][tx] != 0) numTiles ++;
} }
System.out.println("CLTMeasure("+scanIndex+"): numTiles = "+numTiles); System.out.println("CLTMeasure("+scanIndex+"): numTiles = "+numTiles);
if (tile_op[dbg_y][dbg_x] != 0){ if ((dbg_y >= 0) && (dbg_x >= 0) && (tile_op[dbg_y][dbg_x] != 0)){
System.out.println("CLTMeasure("+scanIndex+"): tile_op["+dbg_y+"]["+dbg_x+"] = "+tile_op[dbg_y][dbg_x]); System.out.println("CLTMeasure("+scanIndex+"): tile_op["+dbg_y+"]["+dbg_x+"] = "+tile_op[dbg_y][dbg_x]);
} }
} }
...@@ -8284,6 +8497,137 @@ public class QuadCLT { ...@@ -8284,6 +8497,137 @@ public class QuadCLT {
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity
final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final CLTPass3d scan,
final boolean save_textures,
final boolean save_corr,
final double [][] mismatch, // null or double [12][]
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final int dbg_x = -295-debugLevel;
final int dbg_y = -160-debugLevel;
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
double [] disparity = scan.getDisparity();
double [] strength = scan.getStrength();
boolean [] selection = scan.getSelected();
if (selection == null) {
selection = new boolean[tilesX*tilesY];
for (int nTile = 0; nTile < selection.length; nTile++) {
selection[nTile] = !Double.isNaN(disparity[nTile]) && (strength[nTile] > 0.0);
}
scan.setSelected(selection);
}
if ((scan.disparity == null) || (scan.tile_op == null)) {
scan.setTileOpDisparity(
scan.getSelected(), // boolean [] selection,
scan.getDisparity()); // double [] disparity)
}
int [][] tile_op = scan.tile_op;
double [][] disparity_array = scan.disparity;
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
if (debugLevel > -1){
int numTiles = 0;
for (int ty = 0; ty < tile_op.length; ty ++) for (int tx = 0; tx < tile_op[ty].length; tx ++){
if (tile_op[ty][tx] != 0) numTiles ++;
}
System.out.println("CLTMeasure(): numTiles = "+numTiles);
if ((dbg_y >= 0) && (dbg_x >= 0) && (tile_op[dbg_y][dbg_x] != 0)){
System.out.println("CLTMeasure(): tile_op["+dbg_y+"]["+dbg_x+"] = "+tile_op[dbg_y][dbg_x]);
}
}
double min_corr_selected = clt_parameters.min_corr;
double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] shiftXY = new double [4][2];
if (!clt_parameters.fine_corr_ignore) {
double [][] shiftXY0 = {
{clt_parameters.fine_corr_x_0,clt_parameters.fine_corr_y_0},
{clt_parameters.fine_corr_x_1,clt_parameters.fine_corr_y_1},
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
shiftXY = shiftXY0;
}
double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt();
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
mismatch, // null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
disparity_map, // [12][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.corr_sigma,
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
scan.disparity_map = disparity_map;
scan.texture_tiles = texture_tiles;
scan.is_measured = true;
scan.is_combo = false;
scan.resetProcessed();
return scan;
}
public ImagePlus [] conditionImageSetBatch( // used in batchCLT3d public ImagePlus [] conditionImageSetBatch( // used in batchCLT3d
final int nSet, // index of the 4-image set final int nSet, // index of the 4-image set
final EyesisCorrectionParameters.CLTParameters clt_parameters, final EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -8539,6 +8883,7 @@ public class QuadCLT { ...@@ -8539,6 +8883,7 @@ public class QuadCLT {
} }
public void batchCLT3d( public void batchCLT3d(
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters, EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
...@@ -8710,6 +9055,7 @@ public class QuadCLT { ...@@ -8710,6 +9055,7 @@ public class QuadCLT {
if (ok) { if (ok) {
System.out.println("Adjusting extrinsics"); System.out.println("Adjusting extrinsics");
extrinsicsCLT( extrinsicsCLT(
// twoQuadCLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly, false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
...@@ -8734,6 +9080,7 @@ public class QuadCLT { ...@@ -8734,6 +9080,7 @@ public class QuadCLT {
if (ok) { if (ok) {
System.out.println("Adjusting polynomial fine crorection"); System.out.println("Adjusting polynomial fine crorection");
extrinsicsCLT( extrinsicsCLT(
// twoQuadCLT, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // adjust_poly, true, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
......
...@@ -2525,23 +2525,28 @@ public class SuperTiles{ ...@@ -2525,23 +2525,28 @@ public class SuperTiles{
final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0]) final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
final boolean show_histograms, final boolean show_histograms,
final boolean [][] hor_planes, // returns plane types (hor/vert) final boolean [][] hor_planes, // returns plane types (hor/vert)
// Parameters for alternative initial planes that use lowest disparity for fronto planes, and farthest - for horizontal
final boolean mod_strength, // = true; // FIXME: make a parameter. when set, multiply each tile strength by the number of selected neighbors
final boolean clusterize_by_highest, // = true;
final double clust_sigma, // = 0.7;
final double disp_arange_vert, // = 0.07;
final double disp_rrange_vert, // = 0.01;
final double disp_arange_hor, // = 0.035;
final double disp_rrange_hor, // = 0.005;
final double tolerance_above_near, // = 100.0; // 0.07; any?
final double tolerance_below_near, // = -0.01;
final double tolerance_above_far, // = 0.07;
final double tolerance_below_far, // = 0.1; // 100.0; // any farther
final int hor_vert_overlap, // = 2;
final int used_companions, // = 5; // cell that has this many new used companions is considered used (borders and already use3d are considered used too)
final int used_true_companions, // = 1; // there should be at least this many new selected tiles among neighbors.,
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
{ {
final int used_companions = 5; // cell that has this many new used companions is considered used (borders and already use3d are considered used too)
final int used_true_companions = 1; // there should be at least this many new selected tiles among neighbors.,
final double clust_sigma = 0.7;
final double disp_arange = 0.07;
final double disp_rrange = 0.01;
final double tolerance_above_near = 100.0; // 0.07; any?
final double tolerance_below_near = -0.01;
final double tolerance_above_far = 0.07;
final double tolerance_below_far = 0.1; // 100.0; // any farther
final int hor_vert_overlap = 2;
final boolean clusterize_by_highest = true;
final boolean mod_strength = true; // FIXME: make a parameter. when set, multiply each tile strength by the number of selected neighbors
final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY();
final int superTileSize = tileProcessor.getSuperTileSize(); final int superTileSize = tileProcessor.getSuperTileSize();
...@@ -2664,8 +2669,8 @@ public class SuperTiles{ ...@@ -2664,8 +2669,8 @@ public class SuperTiles{
stMeasSel, // final int stMeasSel, // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert stMeasSel, // final int stMeasSel, // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
plDispNorm, // final double plDispNorm, // to increase weight of nearer planes plDispNorm, // final double plDispNorm, // to increase weight of nearer planes
clust_sigma, // final double sigma, clust_sigma, // final double sigma,
0.5 * disp_arange, // final double disp_arange, disp_arange_hor, // final double disp_arange,
0.5 * disp_rrange, // final double disp_rrange, disp_rrange_hor, // final double disp_rrange,
tolerance_above_far,// final double tolerance_above, tolerance_above_far,// final double tolerance_above,
tolerance_below_far,// final double tolerance_below, tolerance_below_far,// final double tolerance_below,
plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection
...@@ -2703,8 +2708,8 @@ public class SuperTiles{ ...@@ -2703,8 +2708,8 @@ public class SuperTiles{
stMeasSel, // final int stMeasSel, // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert stMeasSel, // final int stMeasSel, // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
plDispNorm, // final double plDispNorm, // to increase weight of nearer planes plDispNorm, // final double plDispNorm, // to increase weight of nearer planes
clust_sigma, // final double sigma, clust_sigma, // final double sigma,
disp_arange, // final double disp_arange, disp_arange_vert, // final double disp_arange,
disp_rrange, // final double disp_rrange, disp_rrange_vert, // final double disp_rrange,
tolerance_above_near, // final double tolerance_above, tolerance_above_near, // final double tolerance_above,
tolerance_below_near, // final double tolerance_below, tolerance_below_near, // final double tolerance_below,
plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection
...@@ -3127,6 +3132,7 @@ public class SuperTiles{ ...@@ -3127,6 +3132,7 @@ public class SuperTiles{
//FIXME: use following 2 parameters //FIXME: use following 2 parameters
final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
final double fronto_pow, // = 1.0; // increase weight even more
// now for regenerated planes - just null as it is not known if it is hor or vert // now for regenerated planes - just null as it is not known if it is hor or vert
final boolean [][] hor_planes, // plane types (hor/vert) final boolean [][] hor_planes, // plane types (hor/vert)
final int debugLevel, final int debugLevel,
...@@ -3191,6 +3197,7 @@ public class SuperTiles{ ...@@ -3191,6 +3197,7 @@ public class SuperTiles{
fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
dl); // int debugLevel); dl); // int debugLevel);
if ((st_planes != null) && (!st_planes.isEmpty())){ if ((st_planes != null) && (!st_planes.isEmpty())){
...@@ -3238,6 +3245,7 @@ public class SuperTiles{ ...@@ -3238,6 +3245,7 @@ public class SuperTiles{
fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
dl - 1); // int debugLevel); dl - 1); // int debugLevel);
} }
...@@ -3313,6 +3321,7 @@ public class SuperTiles{ ...@@ -3313,6 +3321,7 @@ public class SuperTiles{
final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
final double PlFrontoPow, // = 1.0; // increase weight even more
final GeometryCorrection geometryCorrection, final GeometryCorrection geometryCorrection,
final boolean correct_distortions, final boolean correct_distortions,
...@@ -3335,11 +3344,27 @@ public class SuperTiles{ ...@@ -3335,11 +3344,27 @@ public class SuperTiles{
final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0]) final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
final boolean show_histograms, final boolean show_histograms,
// Parameters for alternative initial planes that use lowest disparity for fronto planes, and farthest - for horizontal
final boolean mod_strength, // = true; // FIXME: make a parameter. when set, multiply each tile strength by the number of selected neighbors
final boolean clusterize_by_highest, // = true;
final double clust_sigma, // = 0.7;
final double disp_arange_vert, // = 0.07;
final double disp_rrange_vert, // = 0.01;
final double disp_arange_hor, // = 0.035;
final double disp_rrange_hor, // = 0.005;
final double tolerance_above_near, // = 100.0; // 0.07; any?
final double tolerance_below_near, // = -0.01;
final double tolerance_above_far, // = 0.07;
final double tolerance_below_far, // = 0.1; // 100.0; // any farther
final int hor_vert_overlap, // = 2;
final int used_companions, // = 5; // cell that has this many new used companions is considered used (borders and already use3d are considered used too)
final int used_true_companions, // = 1; // there should be at least this many new selected tiles among neighbors.,
final boolean debug_initial_discriminate,
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
{ {
final boolean debug_initial_discriminate = true; // false; // true;
// use both horizontal and const disparity tiles to create tile clusters // use both horizontal and const disparity tiles to create tile clusters
// Add max_diff (maximal disparity difference while extracting initial tile selection) and max_tries (2..3) parameters // Add max_diff (maximal disparity difference while extracting initial tile selection) and max_tries (2..3) parameters
...@@ -3373,6 +3398,22 @@ public class SuperTiles{ ...@@ -3373,6 +3398,22 @@ public class SuperTiles{
show_histograms, // final boolean show_histograms, show_histograms, // final boolean show_histograms,
hor_planes, // final boolean [][] hor_planes, hor_planes, // final boolean [][] hor_planes,
// Parameters for alternative initial planes that use lowest disparity for fronto planes, and farthest - for horizontal
mod_strength, // final boolean mod_strength, // = true; // FIXME: make a parameter. when set, multiply each tile strength by the number of selected neighbors
clusterize_by_highest, // final boolean clusterize_by_highest, // = true;
clust_sigma, // final double clust_sigma, // = 0.7;
disp_arange_vert, // final double disp_arange_vert, // = 0.07;
disp_rrange_vert, // final double disp_rrange_vert, // = 0.01;
disp_arange_hor, // final double disp_arange_hor, // = 0.035;
disp_rrange_hor, // final double disp_rrange_hor, // = 0.005;
tolerance_above_near, // final double tolerance_above_near, // = 100.0; // 0.07; any?
tolerance_below_near, // final double tolerance_below_near, // = -0.01;
tolerance_above_far, // final double tolerance_above_far, // = 0.07;
tolerance_below_far, // final double tolerance_below_far, // = 0.1; // 100.0; // any farther
hor_vert_overlap, // final int hor_vert_overlap, // = 2;
used_companions, // final int used_companions, // = 5; // cell that has this many new used companions is considered used (borders and already use3d are considered used too)
used_true_companions, // final int used_true_companions, // = 1; // there should be at least this many new selected tiles among neighbors.,
debugLevel+(debug_initial_discriminate? 2:0), // final int debugLevel, debugLevel+(debug_initial_discriminate? 2:0), // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
...@@ -3413,8 +3454,9 @@ public class SuperTiles{ ...@@ -3413,8 +3454,9 @@ public class SuperTiles{
plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // double fronto_pow, // = 1.0; // increase weight even more
hor_planes, // final boolean [][] hor_planes, // returns plane types (hor/vert) hor_planes, // final boolean [][] hor_planes, // returns plane types (hor/vert)
debugLevel + 1, // 0, // 1, // + 2, // 1, // final int debugLevel, debugLevel + 0, // 1, // 0, // 1, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes
...@@ -3473,6 +3515,7 @@ public class SuperTiles{ ...@@ -3473,6 +3515,7 @@ public class SuperTiles{
final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
final double PlFrontoPow, // = 1.0; // increase weight even more
final GeometryCorrection geometryCorrection, final GeometryCorrection geometryCorrection,
final boolean correct_distortions, final boolean correct_distortions,
...@@ -3576,6 +3619,7 @@ public class SuperTiles{ ...@@ -3576,6 +3619,7 @@ public class SuperTiles{
plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0
PlFrontoPow, // double fronto_pow, // = 1.0; // increase weight even more
null, // final boolean [][] hor_planes, // plane types (hor/vert) null, // final boolean [][] hor_planes, // plane types (hor/vert)
debugLevel, // + 2, // 1, // final int debugLevel, debugLevel, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
...@@ -6844,6 +6888,7 @@ public class SuperTiles{ ...@@ -6844,6 +6888,7 @@ public class SuperTiles{
// FIXME: the following 2 parameters are not yet used // FIXME: the following 2 parameters are not yet used
final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
final double fronto_pow, // = 1.0; // increase weight even more
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
...@@ -6938,7 +6983,8 @@ public class SuperTiles{ ...@@ -6938,7 +6983,8 @@ public class SuperTiles{
boolean OK = this_pd.removeOutliers( // getPlaneFromMeas should already have run boolean OK = this_pd.removeOutliers( // getPlaneFromMeas should already have run
fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
fronto_offs, //double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight.
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
disp_strength, disp_strength,
targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant)
max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant)
...@@ -7060,7 +7106,7 @@ public class SuperTiles{ ...@@ -7060,7 +7106,7 @@ public class SuperTiles{
//FIXME: use following 2 parameters //FIXME: use following 2 parameters
final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes final double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable final double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
final double fronto_pow, // = 1.0; // increase weight even more
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
...@@ -7284,7 +7330,8 @@ public class SuperTiles{ ...@@ -7284,7 +7330,8 @@ public class SuperTiles{
OK = bpd[np][npip].removeOutliers( // getPlaneFromMeas should already have run OK = bpd[np][npip].removeOutliers( // getPlaneFromMeas should already have run
fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
fronto_offs, //double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
disp_strength, disp_strength,
targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant)
max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant)
......
...@@ -1350,6 +1350,7 @@ public class TilePlanes { ...@@ -1350,6 +1350,7 @@ public class TilePlanes {
double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
double fronto_pow, // = 1.0; // increase weight even more
double [][][] disp_str, // calculate just once when removing outliers (null - OK, will generate it) double [][][] disp_str, // calculate just once when removing outliers (null - OK, will generate it)
double inTargetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) double inTargetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant)
int maxRemoved, // maximal number of tiles to remove (not a constant) int maxRemoved, // maximal number of tiles to remove (not a constant)
...@@ -1470,7 +1471,7 @@ public class TilePlanes { ...@@ -1470,7 +1471,7 @@ public class TilePlanes {
almost_fronto, // boolean fronto_mode, almost_fronto, // boolean fronto_mode,
fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
this.mlfp, this.mlfp,
debugLevel-1) != null); debugLevel-1) != null);
...@@ -1516,6 +1517,8 @@ public class TilePlanes { ...@@ -1516,6 +1517,8 @@ public class TilePlanes {
this.smplMode, this.smplMode,
almost_fronto, // boolean fronto_mode, almost_fronto, // boolean fronto_mode,
fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable fronto_offs, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
this.mlfp, this.mlfp,
debugLevel-0) != null); // will show image debugLevel-0) != null); // will show image
if (!OK) { // restore how it was if (!OK) { // restore how it was
...@@ -1561,7 +1564,9 @@ public class TilePlanes { ...@@ -1561,7 +1564,9 @@ public class TilePlanes {
smplMode, // = true; // Use sample mode (false - regular tile mode) smplMode, // = true; // Use sample mode (false - regular tile mode)
false, // boolean fronto_mode, false, // boolean fronto_mode,
0.0, //double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable 0.0, // double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
1.0, // double fronto_pow, // = 1.0; // increase weight even more
mlfp, mlfp,
debugLevel); debugLevel);
...@@ -1606,6 +1611,7 @@ public class TilePlanes { ...@@ -1606,6 +1611,7 @@ public class TilePlanes {
boolean fronto_mode, boolean fronto_mode,
double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
double fronto_pow, // = 1.0; // increase weight even more
MeasuredLayersFilterParameters mlfp, MeasuredLayersFilterParameters mlfp,
int debugLevel) int debugLevel)
...@@ -1823,7 +1829,11 @@ public class TilePlanes { ...@@ -1823,7 +1829,11 @@ public class TilePlanes {
if (w > 0.0){ if (w > 0.0){
double d = disp_str[nl][0][indx]; double d = disp_str[nl][0][indx];
if (d > d0) { if (d > d0) {
w *= (d-d0)/fronto_offs; // more weight of the near pixels, same weight of the centre pixels double kw = (d-d0)/fronto_offs; // more weight of the near pixels, same weight of the centre pixels
if (fronto_pow != 1.00) {
kw = Math.pow(kw, fronto_pow);
}
w *= kw; // increase influence of near pixels even more
disp_str[nl][1][indx] = w; disp_str[nl][1][indx] = w;
sw += w; sw += w;
swz += w * d; swz += w * d;
...@@ -4280,6 +4290,7 @@ public class TilePlanes { ...@@ -4280,6 +4290,7 @@ public class TilePlanes {
double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
double fronto_pow, // = 1.0; // increase weight even more
int debugLevel) int debugLevel)
{ {
if (debugLevel > 2) { if (debugLevel > 2) {
...@@ -4371,6 +4382,7 @@ public class TilePlanes { ...@@ -4371,6 +4382,7 @@ public class TilePlanes {
fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature fronto_tol, // double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter fronto_rms, // double fronto_rms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes. May be tighter
fronto_offs, //double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable fronto_offs, //double fronto_offs, // = 0.2; // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
fronto_pow, // double fronto_pow, // = 1.0; // increase weight even more
disp_strength, disp_strength,
plTargetEigen, // targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) plTargetEigen, // targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant)
max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant)
......
...@@ -704,14 +704,6 @@ public class TileProcessor { ...@@ -704,14 +704,6 @@ public class TileProcessor {
CLTPass3d combo_pass =new CLTPass3d(this); CLTPass3d combo_pass =new CLTPass3d(this);
final int tlen = tilesX * tilesY; final int tlen = tilesX * tilesY;
// final int disparity_index = usePoly ? ImageDtt.DISPARITY_INDEX_POLY : ImageDtt.DISPARITY_INDEX_CM;
// combo_pass.tile_op = new int [tilesY][tilesX]; // for just non-zero
// combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// for (int i = 0; i< ImageDtt.QUAD; i++) combo_pass.disparity_map[ImageDtt.IMG_DIFF0_INDEX + i] = new double[tlen];
// for now - will copy from the best full correlation measurement
// combo_pass.texture_tiles = new double [tilesY][tilesX][][];
// combo_pass.max_tried_disparity = new double [tilesY][tilesX];
combo_pass.is_combo = true; combo_pass.is_combo = true;
combo_pass.calc_disparity = disparity.clone(); //new double [tlen]; combo_pass.calc_disparity = disparity.clone(); //new double [tlen];
combo_pass.calc_disparity_combo = disparity.clone(); //new double [tlen]; combo_pass.calc_disparity_combo = disparity.clone(); //new double [tlen];
...@@ -5344,6 +5336,7 @@ public class TileProcessor { ...@@ -5344,6 +5336,7 @@ public class TileProcessor {
clt_parameters.plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable clt_parameters.plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0
clt_parameters.PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
geometryCorrection, geometryCorrection,
clt_parameters.correct_distortions, clt_parameters.correct_distortions,
...@@ -5365,6 +5358,24 @@ public class TileProcessor { ...@@ -5365,6 +5358,24 @@ public class TileProcessor {
clt_parameters.stHighMix, // stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above clt_parameters.stHighMix, // stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
world_hor, // final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0]) world_hor, // final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
clt_parameters.show_histograms, // final boolean show_histograms, clt_parameters.show_histograms, // final boolean show_histograms,
clt_parameters.ft_mod_strength, // final boolean mod_strength, // when set, multiply each tile strength by the number of selected neighbors
clt_parameters.ft_clusterize_by_highest, // final boolean clusterize_by_highest = true;
clt_parameters.ft_clust_sigma, // final double clust_sigma = 0.7;
clt_parameters.ft_disp_arange_vert, // final double disp_arange_vert = 0.07;
clt_parameters.ft_disp_rrange_vert, // final double disp_rrange_vert = 0.01;
clt_parameters.ft_disp_arange_hor, // final double disp_arange_hor = 0.035;
clt_parameters.ft_disp_rrange_hor, // final double disp_rrang_hor = 0.005;
clt_parameters.ft_tolerance_above_near, // final double tolerance_above_near = 100.0; // 0.07; any?
clt_parameters.ft_tolerance_below_near, // final double tolerance_below_near = -0.01;
clt_parameters.ft_tolerance_above_far, // final double tolerance_above_far = 0.07;
clt_parameters.ft_tolerance_below_far, // final double tolerance_below_far = 0.1; // 100.0; // any farther
clt_parameters.ft_hor_vert_overlap, // final int hor_vert_overlap = 2;
clt_parameters.ft_used_companions, // final int used_companions = 5; // cell that has this many new used companions is considered used (borders and already use3d are considered used too)
clt_parameters.ft_used_true_companions, // final int used_true_companions = 1; // there should be at least this many new selected tiles among neighbors.,
//clt_parameters.ft_
clt_parameters.debug_initial_discriminate, // final boolean debug_initial_discriminate,
clt_parameters.batch_run?-3:debugLevel, // -1, // debugLevel, // final int debugLevel) clt_parameters.batch_run?-3:debugLevel, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -5418,6 +5429,7 @@ public class TileProcessor { ...@@ -5418,6 +5429,7 @@ public class TileProcessor {
clt_parameters.plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable clt_parameters.plFrontoTol, // final double plFrontoTol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable
clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0
clt_parameters.PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
geometryCorrection, geometryCorrection,
clt_parameters.correct_distortions, clt_parameters.correct_distortions,
clt_parameters.stSmplMode, // final boolean smplMode, // = true; // Use sample mode (false - regular tile mode) clt_parameters.stSmplMode, // final boolean smplMode, // = true; // Use sample mode (false - regular tile mode)
...@@ -5531,6 +5543,7 @@ public class TileProcessor { ...@@ -5531,6 +5543,7 @@ public class TileProcessor {
clt_parameters.plFrontoTol, //final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature clt_parameters.plFrontoTol, //final double fronto_tol, // fronto tolerance (pix) - treat almost fronto as fronto (constant disparity). <= 0 - disable this feature
clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes clt_parameters.plFrontoRms, // final double plFrontoRms, // Target rms for the fronto planes - same as sqrt(plMaxEigen) for other planes
clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 clt_parameters.plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0
clt_parameters.PlFrontoPow, // final double PlFrontoPow, // = 1.0; // increase weight even more
debugLevel, // 1, // final int debugLevel) debugLevel, // 1, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -5859,7 +5872,7 @@ public class TileProcessor { ...@@ -5859,7 +5872,7 @@ public class TileProcessor {
0, // int nlayer, // over multi-layer - do not render more than nlayer on top of each other 0, // int nlayer, // over multi-layer - do not render more than nlayer on top of each other
st.getPlanesMod(), // TilePlanes.PlaneData [][] planes, st.getPlanesMod(), // TilePlanes.PlaneData [][] planes,
st.getShellMap(), // shells, // int [][] shells, st.getShellMap(), // shells, // int [][] shells,
1000, // int max_shells, 5000, // int max_shells,
clt_parameters.plFuse,// boolean fuse, clt_parameters.plFuse,// boolean fuse,
false, // boolean show_connections, false, // boolean show_connections,
false, // boolean use_NaN, false, // boolean use_NaN,
......
...@@ -190,6 +190,7 @@ public class TileSurface { ...@@ -190,6 +190,7 @@ public class TileSurface {
s+= "] "; s+= "] ";
return s; return s;
} }
@Override
public String toString() public String toString()
{ {
...@@ -519,6 +520,7 @@ public class TileSurface { ...@@ -519,6 +520,7 @@ public class TileSurface {
final int dbg_tile = dbg_Y * stilesX + dbg_X; final int dbg_tile = dbg_Y * stilesX + dbg_X;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if (planes[nsTile] != null) { if (planes[nsTile] != null) {
...@@ -657,6 +659,7 @@ public class TileSurface { ...@@ -657,6 +659,7 @@ public class TileSurface {
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if (planes[nsTile] != null) { if (planes[nsTile] != null) {
...@@ -767,6 +770,7 @@ public class TileSurface { ...@@ -767,6 +770,7 @@ public class TileSurface {
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if (planes[nsTile] != null) { if (planes[nsTile] != null) {
...@@ -986,6 +990,7 @@ public class TileSurface { ...@@ -986,6 +990,7 @@ public class TileSurface {
// initialize result structure // initialize result structure
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
int dl = ((debugLevel > -1) && (nsTile == dbg_tile)) ? 3:0; int dl = ((debugLevel > -1) && (nsTile == dbg_tile)) ? 3:0;
...@@ -1019,6 +1024,7 @@ public class TileSurface { ...@@ -1019,6 +1024,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if (planes[nsTile] != null) { if (planes[nsTile] != null) {
...@@ -1135,6 +1141,7 @@ public class TileSurface { ...@@ -1135,6 +1141,7 @@ public class TileSurface {
final int dbg_tilesX = stilesX * superTileSize; final int dbg_tilesX = stilesX * superTileSize;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
int dbg_stX = nTile % dbg_tilesX; int dbg_stX = nTile % dbg_tilesX;
...@@ -1181,6 +1188,7 @@ public class TileSurface { ...@@ -1181,6 +1188,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
TileData [][] tileData_src_dbg= tileData_src; TileData [][] tileData_src_dbg= tileData_src;
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
...@@ -1248,6 +1256,7 @@ public class TileSurface { ...@@ -1248,6 +1256,7 @@ public class TileSurface {
final int dbg_tilesX = stilesX * superTileSize; final int dbg_tilesX = stilesX * superTileSize;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
...@@ -1335,6 +1344,7 @@ public class TileSurface { ...@@ -1335,6 +1344,7 @@ public class TileSurface {
final int dbg_tilesX = stilesX * superTileSize; final int dbg_tilesX = stilesX * superTileSize;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
...@@ -1450,6 +1460,7 @@ public class TileSurface { ...@@ -1450,6 +1460,7 @@ public class TileSurface {
final double [][][] disp_strength = new double [numLayers][2][tileData.length]; final double [][][] disp_strength = new double [numLayers][2][tileData.length];
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (tileData[nTile] != null){ if (tileData[nTile] != null){
...@@ -1485,6 +1496,7 @@ public class TileSurface { ...@@ -1485,6 +1496,7 @@ public class TileSurface {
final int [][][] connections = new int [numLayers][tileData.length][8]; final int [][][] connections = new int [numLayers][tileData.length][8];
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (tileData[nTile] != null) { if (tileData[nTile] != null) {
...@@ -1517,6 +1529,7 @@ public class TileSurface { ...@@ -1517,6 +1529,7 @@ public class TileSurface {
final int [][] generators = new int [numLayers][tileData.length]; final int [][] generators = new int [numLayers][tileData.length];
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (tileData[nTile] != null) { if (tileData[nTile] != null) {
...@@ -1543,6 +1556,7 @@ public class TileSurface { ...@@ -1543,6 +1556,7 @@ public class TileSurface {
final int [] surfaces = new int [tileData.length]; final int [] surfaces = new int [tileData.length];
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (tileData[nTile] != null) { if (tileData[nTile] != null) {
...@@ -1671,7 +1685,7 @@ public class TileSurface { ...@@ -1671,7 +1685,7 @@ public class TileSurface {
debugLevel, // final int debugLevel, debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y); dbg_Y); // final int dbg_Y);
if (debugLevel >- 1) { if (debugLevel >- 2) {
showSurfaceDS (tileData, "tileData"); showSurfaceDS (tileData, "tileData");
} }
this.tileData = tileData; this.tileData = tileData;
...@@ -1693,6 +1707,7 @@ public class TileSurface { ...@@ -1693,6 +1707,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) {
...@@ -2148,6 +2163,7 @@ public class TileSurface { ...@@ -2148,6 +2163,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) {
...@@ -2361,6 +2377,7 @@ public class TileSurface { ...@@ -2361,6 +2377,7 @@ public class TileSurface {
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nsTile = ai.getAndIncrement(); nsTile < nsTiles; nsTile = ai.getAndIncrement()) if (planes[nsTile] != null){ for (int nsTile = ai.getAndIncrement(); nsTile < nsTiles; nsTile = ai.getAndIncrement()) if (planes[nsTile] != null){
...@@ -2480,6 +2497,7 @@ public class TileSurface { ...@@ -2480,6 +2497,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tileLayers[fml].length; nTile = ai.getAndIncrement()) {
...@@ -2923,6 +2941,7 @@ public class TileSurface { ...@@ -2923,6 +2941,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nTile = ai.getAndIncrement(); nTile < tileLayers_src[fml].length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tileLayers_src[fml].length; nTile = ai.getAndIncrement()) {
...@@ -3092,6 +3111,7 @@ public class TileSurface { ...@@ -3092,6 +3111,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread] int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int nTile = ai.getAndIncrement(); nTile < tileLayers_src[fml].length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tileLayers_src[fml].length; nTile = ai.getAndIncrement()) {
...@@ -3877,6 +3897,7 @@ public class TileSurface { ...@@ -3877,6 +3897,7 @@ public class TileSurface {
final int [] tilesWH = {imageTilesX, imageTilesY}; final int [] tilesWH = {imageTilesX, imageTilesY};
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int iGClust = ai.getAndIncrement(); iGClust < sdata.length; iGClust = ai.getAndIncrement()) { for (int iGClust = ai.getAndIncrement(); iGClust < sdata.length; iGClust = ai.getAndIncrement()) {
int dl = ((debugLevel > -1) && (iGClust == dbg_X)) ? 1:0; int dl = ((debugLevel > -1) && (iGClust == dbg_X)) ? 1:0;
...@@ -4034,6 +4055,7 @@ public class TileSurface { ...@@ -4034,6 +4055,7 @@ public class TileSurface {
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int iGClust = ai.getAndIncrement(); iGClust < num_grown; iGClust = ai.getAndIncrement()) { for (int iGClust = ai.getAndIncrement(); iGClust < num_grown; iGClust = ai.getAndIncrement()) {
int num_subs = matchedGrown[iGClust].length; int num_subs = matchedGrown[iGClust].length;
...@@ -4230,6 +4252,7 @@ public class TileSurface { ...@@ -4230,6 +4252,7 @@ public class TileSurface {
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int iClust = ai.getAndIncrement(); iClust < num_clusters; iClust = ai.getAndIncrement()) { for (int iClust = ai.getAndIncrement(); iClust < num_clusters; iClust = ai.getAndIncrement()) {
int nClust = iClust + 1; // 1-based int nClust = iClust + 1; // 1-based
...@@ -4299,6 +4322,7 @@ public class TileSurface { ...@@ -4299,6 +4322,7 @@ public class TileSurface {
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int iparent = ai.getAndIncrement(); iparent < num_grown; iparent = ai.getAndIncrement()) { for (int iparent = ai.getAndIncrement(); iparent < num_grown; iparent = ai.getAndIncrement()) {
int num_parent = iparent + 1; // 1-based int num_parent = iparent + 1; // 1-based
...@@ -4492,6 +4516,7 @@ public class TileSurface { ...@@ -4492,6 +4516,7 @@ public class TileSurface {
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int numToSplit = ai.getAndIncrement(); numToSplit < num_clusters; numToSplit = ai.getAndIncrement()) { for (int numToSplit = ai.getAndIncrement(); numToSplit < num_clusters; numToSplit = ai.getAndIncrement()) {
if ((numToSplit + 1) == 74) { //177){ if ((numToSplit + 1) == 74) { //177){
...@@ -4548,6 +4573,7 @@ public class TileSurface { ...@@ -4548,6 +4573,7 @@ public class TileSurface {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int numToSplit = ai.getAndIncrement(); numToSplit < num_clusters; numToSplit = ai.getAndIncrement()) { for (int numToSplit = ai.getAndIncrement(); numToSplit < num_clusters; numToSplit = ai.getAndIncrement()) {
int numToSplit1 = numToSplit+1; int numToSplit1 = numToSplit+1;
...@@ -4746,6 +4772,7 @@ public class TileSurface { ...@@ -4746,6 +4772,7 @@ public class TileSurface {
// make sure even empty tiles have surface selection arrays defined // make sure even empty tiles have surface selection arrays defined
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) {
boolean not_empty = false; boolean not_empty = false;
...@@ -4810,6 +4837,7 @@ public class TileSurface { ...@@ -4810,6 +4837,7 @@ public class TileSurface {
// make sure even empty tiles have surface selection arrays defined // make sure even empty tiles have surface selection arrays defined
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) {
int nSurfTile = getSurfaceTileIndex(nTile); int nSurfTile = getSurfaceTileIndex(nTile);
...@@ -4833,6 +4861,7 @@ public class TileSurface { ...@@ -4833,6 +4861,7 @@ public class TileSurface {
// extend to the right // extend to the right
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) {
if (selection[nTile] != null) { if (selection[nTile] != null) {
...@@ -4862,6 +4891,7 @@ public class TileSurface { ...@@ -4862,6 +4891,7 @@ public class TileSurface {
// extend to the left // extend to the left
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < sel_in.length; nTile = ai.getAndIncrement()) {
if (selection_tmp[nTile] != null){ if (selection_tmp[nTile] != null){
......
...@@ -38,6 +38,47 @@ public class TwoQuadCLT { ...@@ -38,6 +38,47 @@ public class TwoQuadCLT {
public long startStepTime; // start of step processing public long startStepTime; // start of step processing
BiCamDSI biCamDSI_persistent; // may be removed later to save memory, now to be able to continue BiCamDSI biCamDSI_persistent; // may be removed later to save memory, now to be able to continue
PoleProcessor poleProcessor_persistent; PoleProcessor poleProcessor_persistent;
public QuadCLT quadCLT_main = null;
public QuadCLT quadCLT_aux = null;
public TwoQuadCLT(
QuadCLT quadCLT_main,
QuadCLT quadCLT_aux)
{
this.quadCLT_main = quadCLT_main;
this.quadCLT_aux = quadCLT_aux;
}
public QuadCLT getMain()
{
return quadCLT_main;
}
public QuadCLT getAux()
{
return quadCLT_aux;
}
public void resetRig(boolean all_cams)
{
biCamDSI_persistent = null;
poleProcessor_persistent = null;
if (all_cams) {
if ((quadCLT_main != null) && (quadCLT_main.tp != null)) {
quadCLT_main.tp.resetCLTPasses();
}
if ((quadCLT_aux != null) && (quadCLT_aux.tp != null)) {
quadCLT_aux.tp.resetCLTPasses();
}
}
}
public BiScan getBiScan(int indx) {
if ((biCamDSI_persistent == null) ||
(biCamDSI_persistent.biScans == null) ||
(biCamDSI_persistent.biScans.size() <= indx)) {
return null;
}
return biCamDSI_persistent.biScans.get(indx);
}
public void processCLTQuadCorrs( public void processCLTQuadCorrs(
QuadCLT quadCLT_main, QuadCLT quadCLT_main,
...@@ -157,8 +198,8 @@ public class TwoQuadCLT { ...@@ -157,8 +198,8 @@ public class TwoQuadCLT {
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters, EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
// CorrectionColorProc.ColorGainsParameters channelGainParameters_main, // CorrectionColorProc.ColorGainsParameters channelGainParameters_main,
// CorrectionColorProc.ColorGainsParameters channelGainParameters_aux, // CorrectionColorProc.ColorGainsParameters channelGainParameters_aux,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -222,8 +263,8 @@ public class TwoQuadCLT { ...@@ -222,8 +263,8 @@ public class TwoQuadCLT {
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters, debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters, colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
// channelGainParameters_main, // CorrectionColorProc.ColorGainsParameters channelGainParameters_main, // channelGainParameters_main, // CorrectionColorProc.ColorGainsParameters channelGainParameters_main,
// channelGainParameters_aux, // CorrectionColorProc.ColorGainsParameters channelGainParameters_aux, // channelGainParameters_aux, // CorrectionColorProc.ColorGainsParameters channelGainParameters_aux,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters, rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
scaleExposures_main, // double [] scaleExposures_main, // probably not needed here - restores brightness of the final image scaleExposures_main, // double [] scaleExposures_main, // probably not needed here - restores brightness of the final image
scaleExposures_aux, // double [] scaleExposures_aux, // probably not needed here - restores brightness of the final image scaleExposures_aux, // double [] scaleExposures_aux, // probably not needed here - restores brightness of the final image
...@@ -275,7 +316,7 @@ public class TwoQuadCLT { ...@@ -275,7 +316,7 @@ public class TwoQuadCLT {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel){ final int debugLevel){
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
// boolean batch_mode = false; // boolean batch_mode = false;
boolean infinity_corr = false; boolean infinity_corr = false;
double [][] scaleExposures= {scaleExposures_main, scaleExposures_aux}; double [][] scaleExposures= {scaleExposures_main, scaleExposures_aux};
boolean toRGB= quadCLT_main.correctionsParameters.toRGB; boolean toRGB= quadCLT_main.correctionsParameters.toRGB;
...@@ -308,7 +349,7 @@ public class TwoQuadCLT { ...@@ -308,7 +349,7 @@ public class TwoQuadCLT {
// for testing defined for a window, later the tiles to process will be calculated based on previous passes results // for testing defined for a window, later the tiles to process will be calculated based on previous passes results
int [][] tile_op_main = quadCLT_main.tp.setSameTileOp(clt_parameters, clt_parameters.tile_task_op, debugLevel); int [][] tile_op_main = quadCLT_main.tp.setSameTileOp(clt_parameters, clt_parameters.tile_task_op, debugLevel);
// int [][] tile_op_aux = quadCLT_aux.tp.setSameTileOp (clt_parameters, clt_parameters.tile_task_op, debugLevel); // int [][] tile_op_aux = quadCLT_aux.tp.setSameTileOp (clt_parameters, clt_parameters.tile_task_op, debugLevel);
double [][] disparity_array_main = quadCLT_main.tp.setSameDisparity(clt_parameters.disparity); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity double [][] disparity_array_main = quadCLT_main.tp.setSameDisparity(clt_parameters.disparity); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
...@@ -517,7 +558,7 @@ public class TwoQuadCLT { ...@@ -517,7 +558,7 @@ public class TwoQuadCLT {
texture_stack.addSlice("auxiliary", imp_texture_aux. getProcessor().getPixels()); texture_stack.addSlice("auxiliary", imp_texture_aux. getProcessor().getPixels());
ImagePlus imp_texture_stack = new ImagePlus(name+"-TEXTURES-D"+clt_parameters.disparity, texture_stack); ImagePlus imp_texture_stack = new ImagePlus(name+"-TEXTURES-D"+clt_parameters.disparity, texture_stack);
imp_texture_stack.getProcessor().resetMinAndMax(); imp_texture_stack.getProcessor().resetMinAndMax();
// imp_texture_stack.updateAndDraw(); // imp_texture_stack.updateAndDraw();
imp_texture_stack.show(); imp_texture_stack.show();
} }
} }
...@@ -590,7 +631,7 @@ public class TwoQuadCLT { ...@@ -590,7 +631,7 @@ public class TwoQuadCLT {
int iSubCam= iQuadComb - iAux * quad_main; int iSubCam= iQuadComb - iAux * quad_main;
// Uncomment to have master/aux names // Uncomment to have master/aux names
// String title=name+"-"+String.format("%s%02d", ((iAux>0)?"A":"M"),iSubCam); // String title=name+"-"+String.format("%s%02d", ((iAux>0)?"A":"M"),iSubCam);
String title=name+"-"+String.format("%02d", iQuadComb); String title=name+"-"+String.format("%02d", iQuadComb);
if (clt_parameters.corr_sigma > 0){ // no filter at all if (clt_parameters.corr_sigma > 0){ // no filter at all
...@@ -734,7 +775,7 @@ public class TwoQuadCLT { ...@@ -734,7 +775,7 @@ public class TwoQuadCLT {
// public double [][][][] getRigImageStacks( // public double [][][][] getRigImageStacks(
public void getRigImageStacks( public void getRigImageStacks(
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
QuadCLT quadCLT_main, QuadCLT quadCLT_main,
...@@ -783,7 +824,7 @@ public class TwoQuadCLT { ...@@ -783,7 +824,7 @@ public class TwoQuadCLT {
quadCLT_aux.image_data = double_stacks_aux; quadCLT_aux.image_data = double_stacks_aux;
quadCLT_main.saturation_imp = saturation_main; quadCLT_main.saturation_imp = saturation_main;
quadCLT_aux.saturation_imp = saturation_aux; quadCLT_aux.saturation_imp = saturation_aux;
// quadCLT_main.tp.resetCLTPasses(); // quadCLT_main.tp.resetCLTPasses();
quadCLT_main.tp.setTrustedCorrelation(clt_parameters.grow_disp_trust); quadCLT_main.tp.setTrustedCorrelation(clt_parameters.grow_disp_trust);
quadCLT_aux.tp.setTrustedCorrelation(clt_parameters.grow_disp_trust); quadCLT_aux.tp.setTrustedCorrelation(clt_parameters.grow_disp_trust);
} }
...@@ -844,7 +885,7 @@ public class TwoQuadCLT { ...@@ -844,7 +885,7 @@ public class TwoQuadCLT {
saturation_imp_aux, //output // boolean [][] saturation_imp, saturation_imp_aux, //output // boolean [][] saturation_imp,
debugLevel); // int debugLevel); debugLevel); // int debugLevel);
// Tempporarily processing individaully with the old code // Tempporarily processing individually with the old code
processInfinityRig( processInfinityRig(
quadCLT_main, // QuadCLT quadCLT_main, quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
...@@ -898,8 +939,8 @@ public class TwoQuadCLT { ...@@ -898,8 +939,8 @@ public class TwoQuadCLT {
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
// create two arrays of main and aux strengths and small disparity // create two arrays of main and aux strengths and small disparity
// public double inf_max_disp_main = 0.15; // public double inf_max_disp_main = 0.15;
// public double inf_max_disp_aux = 0.15; // public double inf_max_disp_aux = 0.15;
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
final int tilesY = quadCLT_main.tp.getTilesY(); final int tilesY = quadCLT_main.tp.getTilesY();
final int tile_op_all = clt_parameters.tile_task_op; //FIXME Use some constant? final int tile_op_all = clt_parameters.tile_task_op; //FIXME Use some constant?
...@@ -917,8 +958,8 @@ public class TwoQuadCLT { ...@@ -917,8 +958,8 @@ public class TwoQuadCLT {
double s_aux= disparity_bimap[ImageDtt.BI_ASTR_FULL_INDEX][nTile]; double s_aux= disparity_bimap[ImageDtt.BI_ASTR_FULL_INDEX][nTile];
if ((Math.abs(d_main) <= max_main_disparity) && (s_main > min_strength_main)) macro_pair[0][0][nTile] = s_main-min_strength_main; if ((Math.abs(d_main) <= max_main_disparity) && (s_main > min_strength_main)) macro_pair[0][0][nTile] = s_main-min_strength_main;
if ((Math.abs(d_aux) <= max_aux_disparity) && (s_aux > min_strength_aux)) macro_pair[1][0][nTile] = s_aux- min_strength_aux; if ((Math.abs(d_aux) <= max_aux_disparity) && (s_aux > min_strength_aux)) macro_pair[1][0][nTile] = s_aux- min_strength_aux;
// macro_pair[0][0][nTile] = s_main; // macro_pair[0][0][nTile] = s_main;
// macro_pair[1][0][nTile] = s_aux; // macro_pair[1][0][nTile] = s_aux;
} }
if (debugLevel >-2) { if (debugLevel >-2) {
double [][] dbg_macro = {macro_pair[0][0],macro_pair[1][0]}; double [][] dbg_macro = {macro_pair[0][0],macro_pair[1][0]};
...@@ -967,7 +1008,7 @@ public class TwoQuadCLT { ...@@ -967,7 +1008,7 @@ public class TwoQuadCLT {
ImageDtt.BIDISPARITY_TITLES); ImageDtt.BIDISPARITY_TITLES);
} }
/* /*
* ImageDtt.BIDISPARITY_TITLES.length * ImageDtt.BIDISPARITY_TITLES.length
public void clt_bi_macro( public void clt_bi_macro(
final EyesisCorrectionParameters.CLTParameters clt_parameters, final EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -1000,7 +1041,7 @@ public class TwoQuadCLT { ...@@ -1000,7 +1041,7 @@ public class TwoQuadCLT {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel0){ final int debugLevel0){
final int debugLevel = debugLevel0 + (clt_parameters.rig.rig_mode_debug?2:0); final int debugLevel = debugLevel0 + (clt_parameters.rig.rig_mode_debug?2:0);
// double [][][][] double_stacks = // double [][][][] double_stacks =
getRigImageStacks( getRigImageStacks(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
quadCLT_main, // QuadCLT quadCLT_main, quadCLT_main, // QuadCLT quadCLT_main,
...@@ -1014,7 +1055,7 @@ public class TwoQuadCLT { ...@@ -1014,7 +1055,7 @@ public class TwoQuadCLT {
quadCLT_main.tp.resetCLTPasses(); quadCLT_main.tp.resetCLTPasses();
quadCLT_aux.tp.resetCLTPasses(); quadCLT_aux.tp.resetCLTPasses();
/* /*
FIXME - make it work FIXME - make it work
prealignInfinityRig( prealignInfinityRig(
quadCLT_main, // QuadCLT quadCLT_main, quadCLT_main, // QuadCLT quadCLT_main,
...@@ -1024,10 +1065,10 @@ FIXME - make it work ...@@ -1024,10 +1065,10 @@ FIXME - make it work
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
if (debugLevel > -100) return true; // temporarily ! if (debugLevel > -100) return true; // temporarily !
*/ */
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
// perform full re-measure cycles // perform full re-measure cycles
double [][] disparity_bimap = null; double [][] disparity_bimap = null;
int [] num_new = new int[1]; int [] num_new = new int[1];
for (int num_full_cycle = 0; num_full_cycle < clt_parameters.rig.rig_adjust_full_cycles;num_full_cycle++) { for (int num_full_cycle = 0; num_full_cycle < clt_parameters.rig.rig_adjust_full_cycles;num_full_cycle++) {
...@@ -1226,7 +1267,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1226,7 +1267,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
// loop here with the same tileList // loop here with the same tileList
return true; return true;
} }
...@@ -1260,13 +1301,13 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1260,13 +1301,13 @@ if (debugLevel > -100) return true; // temporarily !
if (debugLevel> -1) { if (debugLevel> -1) {
biScan.showScan(quadCLT_main.image_name+"LastBiScan-"+scan_index, null); biScan.showScan(quadCLT_main.image_name+"LastBiScan-"+scan_index, null);
} }
// if (poleProcessor_persistent == null) { // if (poleProcessor_persistent == null) {
poleProcessor_persistent = new PoleProcessor( poleProcessor_persistent = new PoleProcessor(
biCamDSI_persistent, biCamDSI_persistent,
this, // TwoQuadCLT twoQuadCLT, this, // TwoQuadCLT twoQuadCLT,
quadCLT_main.tp.getTilesX(), quadCLT_main.tp.getTilesX(),
quadCLT_main.tp.getTilesY()); quadCLT_main.tp.getTilesY());
// } // }
PoleProcessor pp = poleProcessor_persistent; PoleProcessor pp = poleProcessor_persistent;
boolean [] selection = quadCLT_main.tp.rig_pre_poles_sel.clone(); boolean [] selection = quadCLT_main.tp.rig_pre_poles_sel.clone();
int num_bugs_corrected= pp.zero_tiles_check( int num_bugs_corrected= pp.zero_tiles_check(
...@@ -1323,8 +1364,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1323,8 +1364,8 @@ if (debugLevel > -100) return true; // temporarily !
final boolean updateStatus, final boolean updateStatus,
final int debugLevel)// throws Exception final int debugLevel)// throws Exception
{ {
// boolean combine_oldsel_far = clt_parameters.rig.rf_master_infinity; // = true; // boolean combine_oldsel_far = clt_parameters.rig.rf_master_infinity; // = true;
// boolean combine_oldsel_near = clt_parameters.rig.rf_master_near; // = false; // // boolean combine_oldsel_near = clt_parameters.rig.rf_master_near; // = false; //
if ((quadCLT_main.tp == null) || (quadCLT_main.tp.clt_3d_passes == null)) { if ((quadCLT_main.tp == null) || (quadCLT_main.tp.clt_3d_passes == null)) {
String msg = "DSI data not available. Please run\"CLT 3D\" first"; String msg = "DSI data not available. Please run\"CLT 3D\" first";
IJ.showMessage("ERROR",msg); IJ.showMessage("ERROR",msg);
...@@ -1347,7 +1388,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1347,7 +1388,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
CLTPass3d scan_bg = quadCLT_main.tp.clt_3d_passes.get( 0); // get bg scan CLTPass3d scan_bg = quadCLT_main.tp.clt_3d_passes.get( 0); // get bg scan
// quadCLT_main.tp.trimCLTPasses(false); // remove rig composite scan if any // quadCLT_main.tp.trimCLTPasses(false); // remove rig composite scan if any
// last but not including any rid data // last but not including any rid data
CLTPass3d scan_last = quadCLT_main.tp.clt_3d_passes.get( quadCLT_main.tp.clt_3d_passes_size -1); // get last one CLTPass3d scan_last = quadCLT_main.tp.clt_3d_passes.get( quadCLT_main.tp.clt_3d_passes_size -1); // get last one
...@@ -1358,7 +1399,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1358,7 +1399,7 @@ if (debugLevel > -100) return true; // temporarily !
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
final int tilesY = quadCLT_main.tp.getTilesY(); final int tilesY = quadCLT_main.tp.getTilesY();
BiCamDSI biCamDSI = new BiCamDSI( tilesX, tilesY, threadsMax); BiCamDSI biCamDSI = new BiCamDSI( tilesX, tilesY, threadsMax);
// boolean [][] dbg_sel = (debugLevel > -4)? new boolean [8][]:null;// was 4 // boolean [][] dbg_sel = (debugLevel > -4)? new boolean [8][]:null;// was 4
boolean [][] dbg_sel = (debugLevel > -2)? new boolean [8][]:null;// was 4 boolean [][] dbg_sel = (debugLevel > -2)? new boolean [8][]:null;// was 4
if (dbg_sel!=null) dbg_sel[0] = infinity_select; if (dbg_sel!=null) dbg_sel[0] = infinity_select;
if (dbg_sel!=null) dbg_sel[1] = was_select; if (dbg_sel!=null) dbg_sel[1] = was_select;
...@@ -1410,11 +1451,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1410,11 +1451,11 @@ if (debugLevel > -100) return true; // temporarily !
} }
if (dbg_sel!=null) dbg_sel[4] = selection.clone(); // far+near+old if (dbg_sel!=null) dbg_sel[4] = selection.clone(); // far+near+old
// if ((combine_oldsel_far || combine_oldsel_near) && (was_select != null) ) { // if ((combine_oldsel_far || combine_oldsel_near) && (was_select != null) ) {
// for (int nTile=0; nTile < selection.length; nTile++) { // for (int nTile=0; nTile < selection.length; nTile++) {
// selection[nTile] |= was_select[nTile] && (infinity_select[nTile]? combine_oldsel_far : combine_oldsel_near) ; // selection[nTile] |= was_select[nTile] && (infinity_select[nTile]? combine_oldsel_far : combine_oldsel_near) ;
// } // }
// } // }
boolean [] selection_lone = biCamDSI.selectLoneFar( boolean [] selection_lone = biCamDSI.selectLoneFar(
clt_parameters.rig.ltfar_trusted_s, // double min_far_strength, clt_parameters.rig.ltfar_trusted_s, // double min_far_strength,
clt_parameters.rig.ltfar_trusted_d, // double min_far_disparity, clt_parameters.rig.ltfar_trusted_d, // double min_far_disparity,
...@@ -1500,11 +1541,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1500,11 +1541,11 @@ if (debugLevel > -100) return true; // temporarily !
rig_disparity_strength[0], // double [] disparity, rig_disparity_strength[0], // double [] disparity,
rig_disparity_strength[1], // double [] strength) rig_disparity_strength[1], // double [] strength)
cond_sel); // boolean [] selected) cond_sel); // boolean [] selected)
// CLT ASSIGN needs best texture for each tile. Initially will just copy from teh previous master // CLT ASSIGN needs best texture for each tile. Initially will just copy from teh previous master
// composite scan, later - fill disparity gaps and re-measure // composite scan, later - fill disparity gaps and re-measure
/* /*
* TODO: interpolate disparities before measuring to fill gaps? * TODO: interpolate disparities before measuring to fill gaps?
public double [][][][][] getRigTextures( public double [][][][][] getRigTextures(
boolean need_master, boolean need_master,
...@@ -1520,8 +1561,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1520,8 +1561,8 @@ if (debugLevel > -100) return true; // temporarily !
*/ */
quadCLT_main.tp.trimCLTPasses(false); // remove rig composite scan if any quadCLT_main.tp.trimCLTPasses(false); // remove rig composite scan if any
// quadCLT_main.tp.rig_pre_poles_ds = f_rig_disparity_strength; // Rig disparity and strength before processing poles // quadCLT_main.tp.rig_pre_poles_ds = f_rig_disparity_strength; // Rig disparity and strength before processing poles
// quadCLT_main.tp.rig_pre_poles_sel = selection; // Rig tile selection before processing poles // quadCLT_main.tp.rig_pre_poles_sel = selection; // Rig tile selection before processing poles
quadCLT_main.tp.rig_pre_poles_ds = rig_disparity_strength; // Rig disparity and strength before processing poles quadCLT_main.tp.rig_pre_poles_ds = rig_disparity_strength; // Rig disparity and strength before processing poles
quadCLT_main.tp.rig_pre_poles_sel = selection; // Rig tile selection before processing poles quadCLT_main.tp.rig_pre_poles_sel = selection; // Rig tile selection before processing poles
quadCLT_main.tp.rig_post_poles_ds = null; quadCLT_main.tp.rig_post_poles_ds = null;
...@@ -1565,8 +1606,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1565,8 +1606,8 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
(debugLevel > -2) ? clt_parameters.poles.poles_debug_level:debugLevel);// (debugLevel > -2) ? clt_parameters.poles.poles_debug_level:debugLevel);//
// (debugLevel > -4) ? clt_parameters.poles.poles_debug_level:debugLevel);// // (debugLevel > -4) ? clt_parameters.poles.poles_debug_level:debugLevel);//
// debugLevel); // final int globalDebugLevel) // debugLevel); // final int globalDebugLevel)
num_bugs_corrected= pp.zero_tiles_check( num_bugs_corrected= pp.zero_tiles_check(
"post-poles", "post-poles",
...@@ -1596,11 +1637,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1596,11 +1637,11 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
rig_scan.texture_tiles = scan_last.texture_tiles; rig_scan.texture_tiles = scan_last.texture_tiles;
// scan_last // scan_last
quadCLT_main.tp.clt_3d_passes.add(rig_scan); quadCLT_main.tp.clt_3d_passes.add(rig_scan);
quadCLT_main.tp.saveCLTPasses(true); // rig pass quadCLT_main.tp.saveCLTPasses(true); // rig pass
// generate ML data if enabled // generate ML data if enabled
if (clt_parameters.rig.ml_generate) { if (clt_parameters.rig.ml_generate) {
outputMLData( outputMLData(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
...@@ -1694,8 +1735,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1694,8 +1735,8 @@ if (debugLevel > -100) return true; // temporarily !
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
final int debugLevel) // throws Exception final int debugLevel) // throws Exception
{ {
// quadCLT_main.writeKml(debugLevel); // quadCLT_main.writeKml(debugLevel);
// quadCLT_main.writeRatingFile(debugLevel); // quadCLT_main.writeRatingFile(debugLevel);
String [] sourceFiles_main=quadCLT_main.correctionsParameters.getSourcePaths(); String [] sourceFiles_main=quadCLT_main.correctionsParameters.getSourcePaths();
...@@ -1725,7 +1766,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1725,7 +1766,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
/* /*
for (String fname:path_list) { // path is already fiiltered fro the current (not first) set for (String fname:path_list) { // path is already fiiltered fro the current (not first) set
if (quadCLT_main.setGpsLla(fname)) { if (quadCLT_main.setGpsLla(fname)) {
break; break;
...@@ -1746,7 +1787,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1746,7 +1787,7 @@ if (debugLevel > -100) return true; // temporarily !
ts, // double timestamp, ts, // double timestamp,
quadCLT_main.gps_lla); // double [] lla) quadCLT_main.gps_lla); // double [] lla)
} }
*/ */
quadCLT_main.writeKml(debugLevel ); // alos generated with x3d model quadCLT_main.writeKml(debugLevel ); // alos generated with x3d model
String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory( String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory(
...@@ -1775,7 +1816,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1775,7 +1816,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
// System.out.println("jp4_copy_path = "+jp4_copy_path); // System.out.println("jp4_copy_path = "+jp4_copy_path);
// System.out.println("Do something useful here"); // System.out.println("Do something useful here");
} }
...@@ -1825,7 +1866,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1825,7 +1866,7 @@ if (debugLevel > -100) return true; // temporarily !
disparity_offset, // double disparity_offset, disparity_offset, // double disparity_offset,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
// disparity_bimap, // double [][] src_bimap, // disparity_bimap, // double [][] src_bimap,
rig_disparity_strength[0], // double [] disparity, rig_disparity_strength[0], // double [] disparity,
rig_disparity_strength[1], // double [] strength, rig_disparity_strength[1], // double [] strength,
...@@ -1869,7 +1910,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1869,7 +1910,7 @@ if (debugLevel > -100) return true; // temporarily !
{ {
final int refine_inter = 2; // 3; // 3 - dx, 2 - disparity final int refine_inter = 2; // 3; // 3 - dx, 2 - disparity
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
// final int tilesY = quadCLT_main.tp.getTilesY(); // final int tilesY = quadCLT_main.tp.getTilesY();
if ((quadCLT_main == null) || (quadCLT_aux == null)) { if ((quadCLT_main == null) || (quadCLT_aux == null)) {
System.out.println("QuadCLT instances are not initilaized"); System.out.println("QuadCLT instances are not initilaized");
return null; return null;
...@@ -1935,6 +1976,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1935,6 +1976,8 @@ if (debugLevel > -100) return true; // temporarily !
for (int i = 0; i < scale_bad.length; i++) scale_bad[i] = 1.0; for (int i = 0; i < scale_bad.length; i++) scale_bad[i] = 1.0;
for (int nref = 0; nref < clt_parameters.rig.num_inf_refine; nref++) { for (int nref = 0; nref < clt_parameters.rig.num_inf_refine; nref++) {
// refine infinity using inter correlation // refine infinity using inter correlation
double refine_tolerance = (nref > 0)?clt_parameters.rig.refine_tolerance:0.0;
// only for infinity to prevent remaining 0.0?
double [][] disparity_bimap_new = refineRigSel( double [][] disparity_bimap_new = refineRigSel(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
...@@ -1944,7 +1987,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -1944,7 +1987,7 @@ if (debugLevel > -100) return true; // temporarily !
refine_inter, // int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter refine_inter, // int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter
false, // boolean keep_inf, // keep expected disparity 0.0 if it was so false, // boolean keep_inf, // keep expected disparity 0.0 if it was so
0.0, // clt_parameters.rig.refine_min_strength , // double refine_min_strength, // do not refine weaker tiles 0.0, // clt_parameters.rig.refine_min_strength , // double refine_min_strength, // do not refine weaker tiles
clt_parameters.rig.refine_tolerance , // double refine_tolerance, // do not refine if absolute disparity below refine_tolerance , // double refine_tolerance, // do not refine if absolute disparity below
trusted_infinity, // tile_list, // ArrayList<Integer> tile_list, // or null trusted_infinity, // tile_list, // ArrayList<Integer> tile_list, // or null
num_new, // int [] num_new, num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -2023,7 +2066,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2023,7 +2066,7 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
// int [] num_new = new int[1]; // int [] num_new = new int[1];
boolean [] trusted_near = getTrustedDisparity( boolean [] trusted_near = getTrustedDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
...@@ -2161,7 +2204,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2161,7 +2204,7 @@ if (debugLevel > -100) return true; // temporarily !
// just testing - copy and run in pole detection mode (TODO: Remove) // just testing - copy and run in pole detection mode (TODO: Remove)
if (debugLevel > -100) return disparity_bimap; if (debugLevel > -100) return disparity_bimap;
// need to re-measure // need to re-measure
double [][] disparity_bimap_poles = measureNewRigDisparity( double [][] disparity_bimap_poles = measureNewRigDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
...@@ -2257,6 +2300,68 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2257,6 +2300,68 @@ if (debugLevel > -100) return true; // temporarily !
} }
public BiScan rigInitialScan(
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) // throws Exception
{
if (getBiScan(0) != null) {
return getBiScan(0);
};
final int tilesX = quadCLT_main.tp.getTilesX();
final int tilesY = quadCLT_main.tp.getTilesY();
BiCamDSI biCamDSI = new BiCamDSI( tilesX, tilesY,threadsMax);
System.out.println("rigInitialScan()");
double [][] disparity_bimap = prepareRefineExistingDSI(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
if (disparity_bimap == null) {
String msg = "Failed to get (and refine) initial rig DSI from the existing data";
System.out.println(msg);
IJ.showMessage("ERROR",msg);
return null;
}
biCamDSI.addBiScan(disparity_bimap, BiScan.BISCAN_SINGLECORR);
biCamDSI.getBiScan(0).calcTrusted( // finds strong trusted and validates week ones if they fit planes
clt_parameters.rig.pf_trusted_strength, // final double trusted_strength, // trusted correlation strength
clt_parameters.rig.pf_strength_rfloor, // final double strength_rfloor, // strength floor - relative to trusted
clt_parameters.rig.pf_cond_rtrusted, // final double cond_rtrusted, // minimal strength to consider - fraction of trusted
clt_parameters.rig.pf_strength_pow, // final double strength_pow, // raise strength-floor to this power
clt_parameters.rig.pf_smpl_radius, // final int smpl_radius,
clt_parameters.rig.pf_smpl_num, // final int smpl_num, // = 3; // Number after removing worst (should be >1)
clt_parameters.rig.pf_smpl_fract, // final double smpl_fract, // Number of friends among all neighbors
clt_parameters.rig.pf_max_adiff, // final double max_adiff, // Maximal absolute difference betweenthe center tile and friends
clt_parameters.rig.pf_max_rdiff, // final double max_rdiff, // Maximal relative difference between the center tile and friends
clt_parameters.rig.pf_max_atilt, // final double max_atilt, // = 2.0; // pix per tile
clt_parameters.rig.pf_max_rtilt, // final double max_rtilt, // = 0.2; // (pix / disparity) per tile
clt_parameters.rig.pf_smpl_arms, // final double smpl_arms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.rig.pf_smpl_rrms, // final double smpl_rrms, // = 0.005; // Maximal RMS/disparity in addition to smplRms
clt_parameters.rig.pf_damp_tilt, // final double damp_tilt, // = 0.001; // Tilt cost for damping insufficient plane data
clt_parameters.rig.pf_rwsigma, // final double rwsigma, // = 0.7; // influence of far neighbors diminish as a Gaussian with this sigma
clt_parameters.tileX, // final int dbg_x,
clt_parameters.tileY, // final int dbg_y,
debugLevel); // final int debugLevel);
if (clt_parameters.show_map && (debugLevel > 0) && clt_parameters.rig.rig_mode_debug){
biCamDSI.getLastBiScan(BiScan.BISCAN_SINGLECORR).showScan(
quadCLT_main.image_name+"-BISCAN_initial");
}
biCamDSI_persistent = biCamDSI;
return getBiScan(0);
}
public double [][] groundTruthByRigPlanes( public double [][] groundTruthByRigPlanes(
QuadCLT quadCLT_main, // tiles should be set QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux, QuadCLT quadCLT_aux,
...@@ -2265,16 +2370,43 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2265,16 +2370,43 @@ if (debugLevel > -100) return true; // temporarily !
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) // throws Exception final int debugLevel) // throws Exception
{ {
if (getBiScan(0) != null) {
if (getBiScan(1) != null) {
System.out.println("Expected just a single BiScan here, got "+(biCamDSI_persistent.biScans.size())+". Trimming");
while (biCamDSI_persistent.biScans.size()>1) {
biCamDSI_persistent.biScans.remove(1);
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
} else { // create a new one
if (rigInitialScan( quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel)== null) // final int debugLevel);
{
return null; // Failed to get
}
}
final int num_tries_strongest_by_fittest = 5; final int num_tries_strongest_by_fittest = 5;
final int num_full_cycles = clt_parameters.rig.pf_en_trim_fg? 3 : 1; // Number of full low-texture cycles that include growing flat LT and trimmin weak FG over BG final int num_full_cycles = clt_parameters.rig.pf_en_trim_fg? 3 : 1; // Number of full low-texture cycles that include growing flat LT and trimmin weak FG over BG
// final int num_cross_gaps_cycles = 12+ (num_simple_expand_cysles * dxy.length); // maximal number of adding new tiles cycles while "crossing the gaps) // final int num_cross_gaps_cycles = 12+ (num_simple_expand_cysles * dxy.length); // maximal number of adding new tiles cycles while "crossing the gaps)
final int min_cross_gaps_new = 20; // minimal number of the new added tiles final int min_cross_gaps_new = 20; // minimal number of the new added tiles
final int refine_inter = 2; // 3; // 3 - dx, 2 - disparity final int refine_inter = 2; // 3; // 3 - dx, 2 - disparity
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
final int tilesY = quadCLT_main.tp.getTilesY(); final int tilesY = quadCLT_main.tp.getTilesY();
/*
BiCamDSI biCamDSI = new BiCamDSI( tilesX, tilesY,threadsMax); BiCamDSI biCamDSI = new BiCamDSI( tilesX, tilesY,threadsMax);
System.out.println("groundTruthByRigPlanes()"); System.out.println("groundTruthByRigPlanes()");
double [][] disparity_bimap = prepareRefineExistingDSI( double [][] disparity_bimap = prepareRefineExistingDSI(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
...@@ -2294,12 +2426,21 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2294,12 +2426,21 @@ if (debugLevel > -100) return true; // temporarily !
biCamDSI.getLastBiScan(BiScan.BISCAN_SINGLECORR).showScan( biCamDSI.getLastBiScan(BiScan.BISCAN_SINGLECORR).showScan(
quadCLT_main.image_name+"-BISCAN_initial"); quadCLT_main.image_name+"-BISCAN_initial");
} }
*/
BiCamDSI biCamDSI = biCamDSI_persistent;
int [][] dxy = {{0, -1},{0,1},{-1,0},{1,0}}; int [][] dxy = {{0, -1},{0,1},{-1,0},{1,0}};
int num_simple_expand_cysles = 8; int num_simple_expand_cysles = 8;
final int num_cross_gaps_cycles = 12 + (num_simple_expand_cysles * dxy.length); // maximal number of adding new tiles cycles while "crossing the gaps) final int num_cross_gaps_cycles = 12 + (num_simple_expand_cysles * dxy.length); // maximal number of adding new tiles cycles while "crossing the gaps)
for (int num_fcycle = 0; num_fcycle < num_full_cycles; num_fcycle++) { for (int num_fcycle = 0; num_fcycle < num_full_cycles; num_fcycle++) {
// Grow tiles, cross gaps (do not trim yet // Grow tiles, cross gaps (do not trim yet
// //
int [] num_simple_added = new int[dxy.length];
for (int i = 0; i < num_simple_added.length; i++) {
num_simple_added[i] = -1;
}
for (int num_cycle = 0; num_cycle < num_cross_gaps_cycles; num_cycle++) { for (int num_cycle = 0; num_cycle < num_cross_gaps_cycles; num_cycle++) {
BiScan last_scan = biCamDSI.getLastBiScan(BiScan.BISCAN_SINGLECORR); BiScan last_scan = biCamDSI.getLastBiScan(BiScan.BISCAN_SINGLECORR);
if (clt_parameters.rig.lonefg_disp_incr > 0.0) { if (clt_parameters.rig.lonefg_disp_incr > 0.0) {
...@@ -2345,6 +2486,23 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2345,6 +2486,23 @@ if (debugLevel > -100) return true; // temporarily !
" strong trusted: "+trusted_stats[0]+ " neib trusted: "+trusted_stats[1]+" weak trusted: " + trusted_stats[2]); " strong trusted: "+trusted_stats[0]+ " neib trusted: "+trusted_stats[1]+" weak trusted: " + trusted_stats[2]);
} }
int num_added_tiles =0; int num_added_tiles =0;
if ((num_cycle < num_simple_expand_cysles * dxy.length) && (num_cycle >= dxy.length)) {
boolean all_last_zeros = true;
for (int i =0 ; i <=dxy.length; i++) {
if (num_simple_added[(num_cycle-1-i) % dxy.length] != 0) {
all_last_zeros = false;
break;
}
}
if (all_last_zeros) {
if (debugLevel > -4) {
System.out.println("==== groundTruthByRigPlanes() grow pass "+num_cycle+" of "+ num_cross_gaps_cycles+
" all "+(num_simple_added.length)+" direction expansions added 0 tiles, proceeding to low texture expansion ====");
}
num_cycle = num_simple_expand_cysles * dxy.length;
}
}
if (num_cycle < num_simple_expand_cysles * dxy.length) { if (num_cycle < num_simple_expand_cysles * dxy.length) {
// simple duplicating one step in 4 directions // simple duplicating one step in 4 directions
num_added_tiles = last_scan.suggestNewScan( num_added_tiles = last_scan.suggestNewScan(
...@@ -2358,7 +2516,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2358,7 +2516,7 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.tileY, // final int dbg_y, clt_parameters.tileY, // final int dbg_y,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
//TODO: add expanding FG over existing BG. Use "Strong enough" for FG to beat BG. Maybe expand by multiple steps? //TODO: add expanding FG over existing BG. Use "Strong enough" for FG to beat BG. Maybe expand by multiple steps?
num_simple_added[num_cycle % dxy.length] = num_added_tiles;
} else { } else {
// suggest new disparities, using plane surfaces (extending around that may cause false surfaces) // suggest new disparities, using plane surfaces (extending around that may cause false surfaces)
...@@ -2414,7 +2572,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2414,7 +2572,7 @@ if (debugLevel > -100) return true; // temporarily !
" suggestNewScan() -> "+num_added_tiles); " suggestNewScan() -> "+num_added_tiles);
} }
//num_cycle < num_cross_gaps_cycles; //num_cycle < num_cross_gaps_cycles;
// boolean last_cycle = (num_added_tiles < min_cross_gaps_new) || (num_cycle >= (num_cross_gaps_cycles-1)); // boolean last_cycle = (num_added_tiles < min_cross_gaps_new) || (num_cycle >= (num_cross_gaps_cycles-1));
boolean last_cycle = ((num_added_tiles < min_cross_gaps_new) && (num_cycle >= num_simple_expand_cysles * dxy.length)) || (num_cycle >= (num_cross_gaps_cycles-1)); boolean last_cycle = ((num_added_tiles < min_cross_gaps_new) && (num_cycle >= num_simple_expand_cysles * dxy.length)) || (num_cycle >= (num_cross_gaps_cycles-1));
if (clt_parameters.show_map && (debugLevel > -2) && clt_parameters.rig.rig_mode_debug){ if (clt_parameters.show_map && (debugLevel > -2) && clt_parameters.rig.rig_mode_debug){
if (last_cycle) // || (num_cycle < 2 * dxy.length)) if (last_cycle) // || (num_cycle < 2 * dxy.length))
...@@ -2525,7 +2683,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2525,7 +2683,7 @@ if (debugLevel > -100) return true; // temporarily !
// Measure provided tiles (break after, if it was the last cycle) // Measure provided tiles (break after, if it was the last cycle)
disparity_bimap = measureNewRigDisparity( double [][] disparity_bimap = measureNewRigDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
target_disparity, // double [] disparity, // Double.NaN - skip, ohers - measure target_disparity, // double [] disparity, // Double.NaN - skip, ohers - measure
...@@ -2544,7 +2702,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2544,7 +2702,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean [] trusted_measurements = getTrustedDisparity( boolean [] trusted_measurements = getTrustedDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux, quadCLT_aux, // QuadCLT quadCLT_aux,
// false, // boolean use_individual, // false, // boolean use_individual,
true, // boolean use_individual, true, // boolean use_individual,
0.8*clt_parameters.rig.min_trusted_strength, // double min_combo_strength, // check correlation strength combined for all 3 correlations 0.8*clt_parameters.rig.min_trusted_strength, // double min_combo_strength, // check correlation strength combined for all 3 correlations
clt_parameters.grow_disp_trust, // double max_trusted_disparity, // 4.0 -> change to rig_trust clt_parameters.grow_disp_trust, // double max_trusted_disparity, // 4.0 -> change to rig_trust
...@@ -2711,7 +2869,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2711,7 +2869,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("groundTruthByRigPlanes(): Processing low-textured areas with multi-tile correlation averaging"); System.out.println("groundTruthByRigPlanes(): Processing low-textured areas with multi-tile correlation averaging");
} }
// next method adds to the list of BiScans // next method adds to the list of BiScans
// double [][] ds_avg = // double [][] ds_avg =
//requires biCamDSI_persistent //requires biCamDSI_persistent
measureLowTextureAreas( measureLowTextureAreas(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
...@@ -2761,7 +2919,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2761,7 +2919,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean keep_weak = false; boolean keep_weak = false;
boolean keep_strong = false; boolean keep_strong = false;
double center_weight = 1.0; double center_weight = 1.0;
// from clt_parameters.rig // from clt_parameters.rig
double trusted_strength = clt_parameters.rig.pf_trusted_strength; double trusted_strength = clt_parameters.rig.pf_trusted_strength;
double cond_rtrusted = clt_parameters.rig.pf_cond_rtrusted; double cond_rtrusted = clt_parameters.rig.pf_cond_rtrusted;
double strength_rfloor = clt_parameters.rig.pf_strength_rfloor; double strength_rfloor = clt_parameters.rig.pf_strength_rfloor;
...@@ -2928,8 +3086,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2928,8 +3086,8 @@ if (debugLevel > -100) return true; // temporarily !
// boolean run_avg = false; // boolean run_avg = false;
// int lt_radius = 1; // int lt_radius = 1;
gd.showDialog(); gd.showDialog();
...@@ -3161,7 +3319,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3161,7 +3319,7 @@ if (debugLevel > -100) return true; // temporarily !
double boost_low_density, double boost_low_density,
int fourq_min, int fourq_min,
int fourq_gap, int fourq_gap,
// boolean run_avg, // boolean run_avg,
int lt_radius, int lt_radius,
boolean strong_only, boolean strong_only,
int need_tiles, int need_tiles,
...@@ -3202,7 +3360,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3202,7 +3360,7 @@ if (debugLevel > -100) return true; // temporarily !
if (debugLevel > -2){ if (debugLevel > -2){
System.out.println(" === showBiScan( parameters : ====="); System.out.println(" === showBiScan( parameters : =====");
// System.out.println(" scan_index= "+scan_index); // System.out.println(" scan_index= "+scan_index);
System.out.println(" show_smooth= "+show_smooth); System.out.println(" show_smooth= "+show_smooth);
System.out.println(" keep_unreliable= "+keep_unreliable); System.out.println(" keep_unreliable= "+keep_unreliable);
System.out.println(" keep_weak= "+keep_weak); System.out.println(" keep_weak= "+keep_weak);
...@@ -3234,7 +3392,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3234,7 +3392,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println(" fourq_min= "+fourq_min); System.out.println(" fourq_min= "+fourq_min);
System.out.println(" fourq_gap= "+fourq_gap); System.out.println(" fourq_gap= "+fourq_gap);
// System.out.println(" run_avg= "+run_avg); // System.out.println(" run_avg= "+run_avg);
System.out.println(" lt_radius= "+lt_radius); System.out.println(" lt_radius= "+lt_radius);
System.out.println(" strong_only= "+strong_only); System.out.println(" strong_only= "+strong_only);
System.out.println(" need_tiles= "+need_tiles); System.out.println(" need_tiles= "+need_tiles);
...@@ -3281,7 +3439,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3281,7 +3439,7 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.rig.pf_disp_afloor, // final double pf_disp_afloor, // = 0.1; // When selecting the best fit from the alternative disparities, divide by difference increased by this clt_parameters.rig.pf_disp_afloor, // final double pf_disp_afloor, // = 0.1; // When selecting the best fit from the alternative disparities, divide by difference increased by this
clt_parameters.rig.pf_disp_rfloor); // final double pf_disp_rfloor) // = 0.02; // Increase pf_disp_afloor for large disparities clt_parameters.rig.pf_disp_rfloor); // final double pf_disp_rfloor) // = 0.02; // Increase pf_disp_afloor for large disparities
if ((debugLevel > -2) && clt_parameters.rig.rig_mode_debug){ if ((debugLevel > -2) && clt_parameters.rig.rig_mode_debug){
System.out.println("groundTruthByRigPlanes(): Replacing strongest by fittest: ntry = "+nfit+", replaced "+num_replaced+" tiles"); System.out.println("measureLowTextureAreas(): Replacing strongest by fittest: ntry = "+nfit+", replaced "+num_replaced+" tiles");
} }
if (num_replaced == 0) { if (num_replaced == 0) {
break; break;
...@@ -3302,9 +3460,9 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3302,9 +3460,9 @@ if (debugLevel > -100) return true; // temporarily !
fg_disp_atolerance, // final double disp_atolerance, // = 0.1; // Maximal absolute disparity difference to qualifying neighbor fg_disp_atolerance, // final double disp_atolerance, // = 0.1; // Maximal absolute disparity difference to qualifying neighbor
fg_disp_rtolerance, // final double disp_rtolerance, // = 0.02; // Maximal relative (to absolute disparity) disparity difference to qualifying neighbor fg_disp_rtolerance, // final double disp_rtolerance, // = 0.02; // Maximal relative (to absolute disparity) disparity difference to qualifying neighbor
fg_min_neib); // final int min_neib) // minimal number of qualifying neighbors to promote FG tile fg_min_neib); // final int min_neib) // minimal number of qualifying neighbors to promote FG tile
// if ((debugLevel > -2) && clt_parameters.rig.rig_mode_debug){ // if ((debugLevel > -2) && clt_parameters.rig.rig_mode_debug){
if ((debugLevel > -2)){ if ((debugLevel > -2)){
System.out.println("groundTruthByRigPlanes(): Replacing BG with FG tiles, replaced "+num_replaced_fg+" tiles"); System.out.println("measureLowTextureAreas(): Replacing BG with FG tiles, replaced "+num_replaced_fg+" tiles");
} }
...@@ -3347,7 +3505,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3347,7 +3505,7 @@ if (debugLevel > -100) return true; // temporarily !
double [] dbg_presel = new double [pre_select.length]; double [] dbg_presel = new double [pre_select.length];
for (int i = 0; i < pre_select.length; i++) dbg_presel[i] = pre_select[i]? 1.0:0.0; for (int i = 0; i < pre_select.length; i++) dbg_presel[i] = pre_select[i]? 1.0:0.0;
double [][] dbg_dens_str = {density, dbg_presel}; double [][] dbg_dens_str = {density, dbg_presel};
// biScan.showScan(quadCLT_main.image_name+"-density-"+scan_index,dbg_dens_str); //list_index // biScan.showScan(quadCLT_main.image_name+"-density-"+scan_index,dbg_dens_str); //list_index
if (debugLevel > 0) { if (debugLevel > 0) {
biScan.showScan(quadCLT_main.image_name+"-density-"+biScan.list_index,dbg_dens_str); //list_index biScan.showScan(quadCLT_main.image_name+"-density-"+biScan.list_index,dbg_dens_str); //list_index
} }
...@@ -3430,7 +3588,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3430,7 +3588,7 @@ if (debugLevel > -100) return true; // temporarily !
biScan.showScan(quadCLT_main.image_name+"-smooth-"+biScan.list_index,ds2); biScan.showScan(quadCLT_main.image_name+"-smooth-"+biScan.list_index,ds2);
} }
// if (run_avg) { // if (run_avg) {
int tilesX = quadCLT_main.tp.getTilesX(); int tilesX = quadCLT_main.tp.getTilesX();
double [][] disparity_bimap = measureNewRigDisparity( double [][] disparity_bimap = measureNewRigDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
...@@ -3542,7 +3700,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3542,7 +3700,7 @@ if (debugLevel > -100) return true; // temporarily !
if (debugLevel > 0) { if (debugLevel > 0) {
System.out.println("groundTruthByRigPlanes(): refinement step="+nref+" num_new= "+num_new[0]+" tiles"); System.out.println("measureLowTextureAreas(): refinement step="+nref+" num_new= "+num_new[0]+" tiles");
} }
if (num_new[0] < clt_parameters.rig.pf_min_new) break; // currently will never happen if (num_new[0] < clt_parameters.rig.pf_min_new) break; // currently will never happen
if (( max_diff < min_change) || (nref == (num_lt_refine - 1))) { if (( max_diff < min_change) || (nref == (num_lt_refine - 1))) {
...@@ -3612,7 +3770,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3612,7 +3770,7 @@ if (debugLevel > -100) return true; // temporarily !
null, // final double [] smpl_radius_array, // space-variant radius null, // final double [] smpl_radius_array, // space-variant radius
expand_radius, // final int smpl_radius, expand_radius, // final int smpl_radius,
0, // final int smpl_num, // = 3; // Number after removing worst (should be >1) 0, // final int smpl_num, // = 3; // Number after removing worst (should be >1)
// 0.5 * smpl_fract, // final double smpl_fract, // Number of friends among all neighbors // 0.5 * smpl_fract, // final double smpl_fract, // Number of friends among all neighbors
smpl_fract, // final double smpl_fract, // Number of friends among all neighbors smpl_fract, // final double smpl_fract, // Number of friends among all neighbors
expand_sample_num, // ref_smpl_num, // final int smpl_num_narrow, // = 3; // Number after removing worst (should be >1) expand_sample_num, // ref_smpl_num, // final int smpl_num_narrow, // = 3; // Number after removing worst (should be >1)
ref_max_adiff, // final double max_adiff, // Maximal absolute difference between the center tile and friends ref_max_adiff, // final double max_adiff, // Maximal absolute difference between the center tile and friends
...@@ -3648,7 +3806,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3648,7 +3806,7 @@ if (debugLevel > -100) return true; // temporarily !
biScan.showScan(quadCLT_main.image_name+"-combo-expand"+biScan.list_index, ds_preexpanded); // already wrong strength biScan.showScan(quadCLT_main.image_name+"-combo-expand"+biScan.list_index, ds_preexpanded); // already wrong strength
} }
// double [][] ds_expanded = // double [][] ds_expanded =
avg_ds = biScan.getLTExpanded( avg_ds = biScan.getLTExpanded(
expand_tol, // final double tolerance, // should be not NaN over lt expand_tol, // final double tolerance, // should be not NaN over lt
ds_preexpanded, // final double [][] ds_lt, // should be not NaN over lt ds_preexpanded, // final double [][] ds_lt, // should be not NaN over lt
...@@ -3657,7 +3815,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3657,7 +3815,7 @@ if (debugLevel > -100) return true; // temporarily !
expanded_lt, // final boolean [] exp_sel, expanded_lt, // final boolean [] exp_sel,
weak); // final boolean [] trusted); weak); // final boolean [] trusted);
// TODO use fillAndSmooth() to calculate new weights (keeping disparity as it was) // TODO use fillAndSmooth() to calculate new weights (keeping disparity as it was)
/* /*
double [][] avg_ds_strength = biScan.fillAndSmooth( double [][] avg_ds_strength = biScan.fillAndSmooth(
ds_preexpanded[0], // final double [] src_disparity, ds_preexpanded[0], // final double [] src_disparity,
ds_preexpanded[1], // final double [] src_strength, // if not null will be used for weighted pull ds_preexpanded[1], // final double [] src_strength, // if not null will be used for weighted pull
...@@ -3670,7 +3828,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3670,7 +3828,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel+0); // final int debugLevel debugLevel+0); // final int debugLevel
avg_ds[1] = avg_ds_strength[1]; avg_ds[1] = avg_ds_strength[1];
*/ */
if (debugLevel > -4) { //-2) { if (debugLevel > -4) { //-2) {
biScan.showScan(quadCLT_main.image_name+"-lt-expanded"+biScan.list_index, avg_ds); biScan.showScan(quadCLT_main.image_name+"-lt-expanded"+biScan.list_index, avg_ds);
} }
...@@ -3709,7 +3867,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3709,7 +3867,7 @@ if (debugLevel > -100) return true; // temporarily !
// TODO: strength floor with averaged // TODO: strength floor with averaged
double avg_rfloor = 0.8 * strength_rfloor; double avg_rfloor = 0.8 * strength_rfloor;
double avg_cond_rtrusted = 0.8 * cond_rtrusted; double avg_cond_rtrusted = 0.8 * cond_rtrusted;
...@@ -3735,7 +3893,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3735,7 +3893,7 @@ if (debugLevel > -100) return true; // temporarily !
if (debugLevel > -2) { if (debugLevel > -2) {
System.out.println("groundTruthByRigPlanes() strong trusted: "+trusted_stats[0]+ System.out.println("measureLowTextureAreas() strong trusted: "+trusted_stats[0]+
" neib trusted: "+trusted_stats[1]+" weak trusted: " + trusted_stats[2]); " neib trusted: "+trusted_stats[1]+" weak trusted: " + trusted_stats[2]);
} }
...@@ -3759,7 +3917,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3759,7 +3917,7 @@ if (debugLevel > -100) return true; // temporarily !
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
final int lt_radius, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square final int lt_radius, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
final BiScan biScan, final BiScan biScan,
// final double [][] disparityStrength, // final double [][] disparityStrength,
final double min_disparity, // keep original disparity far tiles final double min_disparity, // keep original disparity far tiles
final double trusted_strength, // trusted correlation strength final double trusted_strength, // trusted correlation strength
final double avg_strength_rfloor, // strength floor - relative to trusted final double avg_strength_rfloor, // strength floor - relative to trusted
...@@ -3902,7 +4060,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3902,7 +4060,7 @@ if (debugLevel > -100) return true; // temporarily !
// combine with old results for tiles that were not re-measured // combine with old results for tiles that were not re-measured
// not needed here as so far everything selected is re-measured in the averaging mode) // not needed here as so far everything selected is re-measured in the averaging mode)
/* /*
for (int tileY = 0; tileY<tilesY;tileY++) { for (int tileY = 0; tileY<tilesY;tileY++) {
for (int tileX = 0; tileX<tilesX;tileX++) { for (int tileX = 0; tileX<tilesX;tileX++) {
int nTile = tileY * tilesX + tileX; int nTile = tileY * tilesX + tileX;
...@@ -3915,7 +4073,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3915,7 +4073,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
} }
*/ */
if (num_new != null) { if (num_new != null) {
num_new[0] = numMeas; num_new[0] = numMeas;
} }
...@@ -3937,7 +4095,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3937,7 +4095,7 @@ if (debugLevel > -100) return true; // temporarily !
{ {
final int refine_inter = 2; // use inter-cam disparity for refinement final int refine_inter = 2; // use inter-cam disparity for refinement
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
// final int tilesY = quadCLT_main.tp.getTilesY(); // final int tilesY = quadCLT_main.tp.getTilesY();
double [] suggestedLTMeasurements = biCamDSI.suggestLTTiles( double [] suggestedLTMeasurements = biCamDSI.suggestLTTiles(
disparity_bimap, // double [][] disparity_bimap, disparity_bimap, // double [][] disparity_bimap,
null, // boolean [] trusted, // may be null if disparity is alreasdy NaN-ed null, // boolean [] trusted, // may be null if disparity is alreasdy NaN-ed
...@@ -3976,7 +4134,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3976,7 +4134,7 @@ if (debugLevel > -100) return true; // temporarily !
ImageDtt.BIDISPARITY_TITLES); ImageDtt.BIDISPARITY_TITLES);
} }
// refine just the new suggested measurements // refine just the new suggested measurements
double [][] prev_bimap = null; double [][] prev_bimap = null;
int [] num_new = new int[1]; int [] num_new = new int[1];
double [] scale_bad = new double [suggestedLTMeasurements.length]; double [] scale_bad = new double [suggestedLTMeasurements.length];
...@@ -4039,15 +4197,15 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -4039,15 +4197,15 @@ if (debugLevel > -100) return true; // temporarily !
// combine new measured results with the previously known (new overwrites old // combine new measured results with the previously known (new overwrites old
for (int nTile = 0; nTile < disparity_bimap_lt[0].length; nTile++) { for (int nTile = 0; nTile < disparity_bimap_lt[0].length; nTile++) {
// if (trusted_lt[nTile] && // if (trusted_lt[nTile] &&
// (!trusted_near[nTile] || // (!trusted_near[nTile] ||
// (disparity_bimap_infinity[ImageDtt.BI_STR_ALL_INDEX][nTile] > disparity_bimap[ImageDtt.BI_STR_ALL_INDEX][nTile]))) { // (disparity_bimap_infinity[ImageDtt.BI_STR_ALL_INDEX][nTile] > disparity_bimap[ImageDtt.BI_STR_ALL_INDEX][nTile]))) {
// start with unconditional use of new // start with unconditional use of new
if (trusted_lt[nTile]) { if (trusted_lt[nTile]) {
for (int i = 0; i < disparity_bimap.length; i++) if (disparity_bimap!=null) { for (int i = 0; i < disparity_bimap.length; i++) if (disparity_bimap!=null) {
disparity_bimap[i][nTile] = disparity_bimap_lt[i][nTile]; disparity_bimap[i][nTile] = disparity_bimap_lt[i][nTile];
} }
// trusted_near[nTile] = true; // trusted_near[nTile] = true;
} }
} }
if (clt_parameters.show_map && (debugLevel > -2) && clt_parameters.rig.rig_mode_debug){ if (clt_parameters.show_map && (debugLevel > -2) && clt_parameters.rig.rig_mode_debug){
...@@ -4353,7 +4511,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -4353,7 +4511,7 @@ if (debugLevel > -100) return true; // temporarily !
double [] disparity = scan.getDisparity(); double [] disparity = scan.getDisparity();
double [] strength = scan.getOriginalStrength(); double [] strength = scan.getOriginalStrength();
// boolean [] selection = scan.getSelected(); // boolean [] selection = scan.getSelected();
boolean [] selection = new boolean [strength.length]; boolean [] selection = new boolean [strength.length];
for (int nTile = 0; nTile < selection.length; nTile++) { for (int nTile = 0; nTile < selection.length; nTile++) {
selection[nTile] = strength[nTile] > 0.0; selection[nTile] = strength[nTile] > 0.0;
...@@ -4837,7 +4995,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -4837,7 +4995,7 @@ if (debugLevel > -100) return true; // temporarily !
double disp_scale_main, // 1.0 double disp_scale_main, // 1.0
double disp_scale_aux, // ~0.58 double disp_scale_aux, // ~0.58
double disp_scale_inter, // ~4.86 double disp_scale_inter, // ~4.86
// double scale_step, // scale for "unstable tiles" // double scale_step, // scale for "unstable tiles"
int tileX, int tileX,
int tileY, int tileY,
int nTile) { int nTile) {
...@@ -4897,13 +5055,13 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -4897,13 +5055,13 @@ if (debugLevel > -100) return true; // temporarily !
if (Math.abs(diff_disp) < refine_tolerance) return false; if (Math.abs(diff_disp) < refine_tolerance) return false;
// or use extrapolate too? // or use extrapolate too?
if (debug_this) { if (debug_this) {
// System.out.println("disp_scale="+disp_scale); // System.out.println("disp_scale="+disp_scale);
if (prev_bimap != null) { if (prev_bimap != null) {
// System.out.println( // System.out.println(
/// "prepRefineTile(): prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile] = "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+ /// "prepRefineTile(): prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile] = "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+
// ", src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]="+src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+", diff_prev="+diff_prev+", diff_disp="+diff_disp); // ", src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]="+src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+", diff_prev="+diff_prev+", diff_disp="+diff_disp);
} else { } else {
// System.out.println("prepRefineTile(): src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]="+src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+", diff_prev="+diff_prev+", diff_disp="+diff_disp); // System.out.println("prepRefineTile(): src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]="+src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+", diff_prev="+diff_prev+", diff_disp="+diff_disp);
} }
} }
boolean from_prev = false; boolean from_prev = false;
...@@ -4914,23 +5072,23 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -4914,23 +5072,23 @@ if (debugLevel > -100) return true; // temporarily !
double new_disp; double new_disp;
if (Double.isNaN(diff_prev) || (diff_prev * diff_disp > 0)) { if (Double.isNaN(diff_prev) || (diff_prev * diff_disp > 0)) {
new_disp = src_bimap[ImageDtt.BI_TARGET_INDEX][nTile] + diff_disp*disp_scale; new_disp = src_bimap[ImageDtt.BI_TARGET_INDEX][nTile] + diff_disp*disp_scale;
// if (debug_this) System.out.println(" >> 1 => disparity_array["+tileY+"]["+tileX+"]="+new_disp); // if (debug_this) System.out.println(" >> 1 => disparity_array["+tileY+"]["+tileX+"]="+new_disp);
} else { // interpolate } else { // interpolate
new_disp = (src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]*diff_prev - prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]*diff_disp)/(diff_prev-diff_disp); new_disp = (src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]*diff_prev - prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]*diff_disp)/(diff_prev-diff_disp);
// if (debug_this) System.out.println(" >> 2 => disparity_array["+tileY+"]["+tileX+"]="+new_disp); // if (debug_this) System.out.println(" >> 2 => disparity_array["+tileY+"]["+tileX+"]="+new_disp);
} }
double ref_target = from_prev ? prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile] : src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]; double ref_target = from_prev ? prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile] : src_bimap[ImageDtt.BI_TARGET_INDEX][nTile];
if ((scale_bad != null) && (scale_bad[nTile] < 1.0)) { if ((scale_bad != null) && (scale_bad[nTile] < 1.0)) {
new_disp = ref_target * (1.0 - scale_bad[nTile]) + new_disp * scale_bad[nTile]; new_disp = ref_target * (1.0 - scale_bad[nTile]) + new_disp * scale_bad[nTile];
// if (debug_this) System.out.println(" scale_bad["+nTile+"]= "+scale_bad[nTile]+" , corrected new_disp="+new_disp+" (was "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+ // if (debug_this) System.out.println(" scale_bad["+nTile+"]= "+scale_bad[nTile]+" , corrected new_disp="+new_disp+" (was "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+
// ", prev "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+")"); // ", prev "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+")");
} else if (prev_bimap!=null){ } else if (prev_bimap!=null){
// if (debug_this) System.out.println("new_disp="+new_disp+" (was "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+ // if (debug_this) System.out.println("new_disp="+new_disp+" (was "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+
// ", prev "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+")"); // ", prev "+prev_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+")");
} }
if (debug_this) System.out.println("prepRefineTile():target_diff "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+","+diff_disp+","+scale_bad[nTile]); if (debug_this) System.out.println("prepRefineTile():target_diff "+ src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]+","+diff_disp+","+scale_bad[nTile]);
// if (Math.abs((new_disp - ref_target)/new_disp) < refine_tolerance) return false; // if (Math.abs((new_disp - ref_target)/new_disp) < refine_tolerance) return false;
if (Math.abs(new_disp - ref_target) < refine_tolerance) return false; if (Math.abs(new_disp - ref_target) < refine_tolerance) return false;
disparity_array[tileY][tileX] = new_disp; disparity_array[tileY][tileX] = new_disp;
tile_op[tileY][tileX] = tile_op_all; tile_op[tileY][tileX] = tile_op_all;
...@@ -5003,7 +5161,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5003,7 +5161,7 @@ if (debugLevel > -100) return true; // temporarily !
int tile_op_all = clt_parameters.tile_task_op; //FIXME Use some constant? int tile_op_all = clt_parameters.tile_task_op; //FIXME Use some constant?
final int tilesX = quadCLT_main.tp.getTilesX(); final int tilesX = quadCLT_main.tp.getTilesX();
final int tilesY = quadCLT_main.tp.getTilesY(); final int tilesY = quadCLT_main.tp.getTilesY();
// int ml_hwidth = 2; // int ml_hwidth = 2;
int ml_width = 2 * ml_hwidth + 1; int ml_width = 2 * ml_hwidth + 1;
double [][] ml_data = new double [ImageDtt.ML_TITLES.length][tilesX * tilesY * ml_width * ml_width]; double [][] ml_data = new double [ImageDtt.ML_TITLES.length][tilesX * tilesY * ml_width * ml_width];
...@@ -5016,8 +5174,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5016,8 +5174,8 @@ if (debugLevel > -100) return true; // temporarily !
int [][] tile_op = new int[tilesY][tilesX]; // common for both main and aux int [][] tile_op = new int[tilesY][tilesX]; // common for both main and aux
double [][] disparity_array = new double[tilesY][tilesX]; double [][] disparity_array = new double[tilesY][tilesX];
// double [] disparity = src_bimap[ImageDtt.BI_TARGET_INDEX]; // double [] disparity = src_bimap[ImageDtt.BI_TARGET_INDEX];
// double [] strength = src_bimap[ImageDtt.BI_STR_CROSS_INDEX]; // double [] strength = src_bimap[ImageDtt.BI_STR_CROSS_INDEX];
boolean [] selection = new boolean [strength.length]; boolean [] selection = new boolean [strength.length];
for (int nTile = 0; nTile < selection.length; nTile++) { for (int nTile = 0; nTile < selection.length; nTile++) {
selection[nTile] = strength[nTile] > 0.0; selection[nTile] = strength[nTile] > 0.0;
...@@ -5165,7 +5323,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5165,7 +5323,7 @@ if (debugLevel > -100) return true; // temporarily !
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) throws Exception final int debugLevel) throws Exception
{ {
// final boolean batch_mode = clt_parameters.batch_run; // final boolean batch_mode = clt_parameters.batch_run;
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel;
this.startTime=System.nanoTime(); this.startTime=System.nanoTime();
String [] sourceFiles=quadCLT_main.correctionsParameters.getSourcePaths(); String [] sourceFiles=quadCLT_main.correctionsParameters.getSourcePaths();
...@@ -5215,6 +5373,10 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5215,6 +5373,10 @@ if (debugLevel > -100) return true; // temporarily !
// optionally adjust main, aux, rig here // optionally adjust main, aux, rig here
for (int num_adjust_main = 0; num_adjust_main < quadCLT_main.correctionsParameters.rig_batch_adjust_main; num_adjust_main++) { for (int num_adjust_main = 0; num_adjust_main < quadCLT_main.correctionsParameters.rig_batch_adjust_main; num_adjust_main++) {
// FIXME: add optional second run of adjustments using rig data getBiScan() -> non-null, and so skip *.preExpandCLTQuad3d()
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
...@@ -5229,6 +5391,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5229,6 +5391,7 @@ if (debugLevel > -100) return true; // temporarily !
// adjust extrinsics here // adjust extrinsics here
System.out.println("Adjust main extrinsics here"); System.out.println("Adjust main extrinsics here");
quadCLT_main.extrinsicsCLT( quadCLT_main.extrinsicsCLT(
// this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly, false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
...@@ -5250,6 +5413,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5250,6 +5413,7 @@ if (debugLevel > -100) return true; // temporarily !
// adjust extrinsics here // adjust extrinsics here
System.out.println("Adjust aux extrinsics here"); System.out.println("Adjust aux extrinsics here");
quadCLT_aux.extrinsicsCLT( quadCLT_aux.extrinsicsCLT(
// this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly, false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
...@@ -5305,7 +5469,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5305,7 +5469,7 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevelInner); // final int debugLevel); debugLevelInner); // final int debugLevel);
} }
// ground truth and then all the rest // ground truth and then all the rest
quadCLT_main.tp.resetCLTPasses(); quadCLT_main.tp.resetCLTPasses();
quadCLT_aux.tp.resetCLTPasses(); quadCLT_aux.tp.resetCLTPasses();
...@@ -5341,7 +5505,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -5341,7 +5505,8 @@ if (debugLevel > -100) return true; // temporarily !
continue; continue;
} }
biCamDSI_persistent = null; // to save memory // biCamDSI_persistent = null; // to save memory
resetRig (false);
Runtime.getRuntime().gc(); Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment