Commit 4bbac7dc authored by Andrey Filippov's avatar Andrey Filippov

Testing LMA with multi-scene LY

parent 816eae59
......@@ -329,6 +329,7 @@ public class CLTParameters {
public double lyms_inf_range_offs = 0.05; // Add to the disparity distribution mode for infinity center
public double lyms_inf_range = 0.15; // Consider infinity tiles that are within +/- half of this range from infinity center
//non-infinity parameters
public int lyms_margin = 6; // discard tiles from each side
public double lyms_min_inf_str = 0.2; // Minimal strength of infinity tiles
public double lyms_min_fg_str = 0.4; // Minimal strength of non-infinity tiles
public int lyms_clust_size = 4; // cluster size (same in both directions) for measuring LY data
......@@ -1263,6 +1264,7 @@ public class CLTParameters {
properties.setProperty(prefix+"lyms_far_fract", this.lyms_far_fract +"");
properties.setProperty(prefix+"lyms_inf_range_offs", this.lyms_inf_range_offs +"");
properties.setProperty(prefix+"lyms_inf_range", this.lyms_inf_range +"");
properties.setProperty(prefix+"lyms_margin", this.lyms_margin +"");
properties.setProperty(prefix+"lyms_min_inf_str", this.lyms_min_inf_str +"");
properties.setProperty(prefix+"lyms_min_fg_str", this.lyms_min_fg_str +"");
properties.setProperty(prefix+"lyms_clust_size", this.lyms_clust_size +"");
......@@ -2104,6 +2106,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"lyms_far_fract")!=null) this.lyms_far_fract=Double.parseDouble(properties.getProperty(prefix+"lyms_far_fract"));
if (properties.getProperty(prefix+"lyms_inf_range_offs")!=null) this.lyms_inf_range_offs=Double.parseDouble(properties.getProperty(prefix+"lyms_inf_range_offs"));
if (properties.getProperty(prefix+"lyms_inf_range")!=null) this.lyms_inf_range=Double.parseDouble(properties.getProperty(prefix+"lyms_inf_range"));
if (properties.getProperty(prefix+"lyms_margin")!=null) this.lyms_margin=Integer.parseInt(properties.getProperty(prefix+"lyms_margin"));
if (properties.getProperty(prefix+"lyms_min_inf_str")!=null) this.lyms_min_inf_str=Double.parseDouble(properties.getProperty(prefix+"lyms_min_inf_str"));
if (properties.getProperty(prefix+"lyms_min_fg_str")!=null) this.lyms_min_fg_str=Double.parseDouble(properties.getProperty(prefix+"lyms_min_fg_str"));
if (properties.getProperty(prefix+"lyms_clust_size")!=null) this.lyms_clust_size=Integer.parseInt(properties.getProperty(prefix+"lyms_clust_size"));
......@@ -3057,6 +3060,8 @@ public class CLTParameters {
gd.addNumericField("Infinity full range", this.lyms_inf_range, 4,6,"pix",
"Consider infinity tiles that are within +/- half of this range from infinity center");
gd.addMessage ("--- LY data measurement ---");
gd.addNumericField("LY Margin", this.lyms_margin, 0,3,"tiles",
"Discard tiles from border");
gd.addNumericField("Minimal strength (infinity)", this.lyms_min_inf_str, 4,6,"",
"Minimal strength of infinity tiles");
gd.addNumericField("Minimal strength (non-infinity)", this.lyms_min_fg_str, 4,6,"",
......@@ -4036,6 +4041,7 @@ public class CLTParameters {
this.lyms_far_fract= gd.getNextNumber();
this.lyms_inf_range_offs= gd.getNextNumber();
this.lyms_inf_range= gd.getNextNumber();
this.lyms_margin= (int) gd.getNextNumber();
this.lyms_min_inf_str= gd.getNextNumber();
this.lyms_min_fg_str= gd.getNextNumber();
this.lyms_clust_size= (int) gd.getNextNumber();
......
......@@ -100,6 +100,7 @@ import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.ErsCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.MLStats;
import com.elphel.imagej.tileprocessor.MultisceneLY;
import com.elphel.imagej.tileprocessor.QuadCLT;
import com.elphel.imagej.tileprocessor.SymmVector;
import com.elphel.imagej.tileprocessor.TwoQuadCLT;
......@@ -7379,6 +7380,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
* @return
*/
public boolean adjustLYSeries(boolean use_aux) {
MultisceneLY.MSLY_MODE adjust_mode = MultisceneLY.MSLY_MODE.INF_NOINF;
long startTime = System.nanoTime();
// load needed sensor and kernels files
if (!prepareRigImages())
......@@ -7436,9 +7438,10 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
try {
TWO_QUAD_CLT.adjustLYSeries(
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
adjust_mode, // MultisceneLY.MSLY_MODE adjust_mode,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, // EyesisCorrectionParameters.RGBParameters rgbParameters,
......
......@@ -117,6 +117,10 @@ public class ExtrinsicAdjustment {
public final int num_sensors;
public double dbg_delta = 0; // 1.0E-5; // if not 0 - use delta instead of the derivatives in getJacobianTransposed
public void setForceDisparity(boolean [] force_disparity) {
this.force_disparity = force_disparity;
}
public double [] getOldNewRMS() {
double [] on_rms = new double[2];
......@@ -291,13 +295,13 @@ public class ExtrinsicAdjustment {
s += "Port"+suffix+": [";
for (int p = 0; p < num_sensors; p++) s += String.format(hfmt, p, "");s+="]\n";
s += "DD"+suffix+"= [";
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[indx_dd0 + p]);s+="]" + String.format(" # avg = "+dfmta+"\n", avg_dd);
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[indx_dd0 + p]);s+="]" + String.format(" # avg = "+dfmta+" (should be 0)\n", avg_dd);
s += "ND"+suffix+"= [";
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[indx_nd0 + p]);s+="]" + String.format(" # avg = "+dfmta+"\n", avg_nd);
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[indx_nd0 + p]);s+="]" + String.format(" # avg = "+dfmta+" (May be non-0, especially large S1)\n", avg_nd);
s += "DX"+suffix+"= [";
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[INDX_X0 + 2 * p + 0]);s+="]" + String.format(" # avg = "+dfmta+"\n", avg_x);
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[INDX_X0 + 2 * p + 0]);s+="]" + String.format(" # avg = "+dfmta+" (should be 0)\n", avg_x);
s += "DY"+suffix+"= [";
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[INDX_X0 + 2 * p + 1]);s+="]" + String.format(" # avg = "+dfmta+"\n", avg_y);
for (int p = 0; p < num_sensors; p++) s += String.format(dfmt, avg[INDX_X0 + 2 * p + 1]);s+="]" + String.format(" # avg = "+dfmta+" (should be 0)\n", avg_y);
return s;
}
/*
......@@ -457,19 +461,6 @@ public class ExtrinsicAdjustment {
x0y0, // double[][] data,
"nondistorted X0Y0");// String title);
}
/*
this.par_mask = geometryCorrection.getParMask(
use_disparity, // has_disparity, // boolean use_disparity,
use_aztilts, // Adjust azimuths and tilts excluding disparity
use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
common_roll,// boolean common_roll,
corr_focalLength, // boolean corr_focalLength);
ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
ers_forw, // Enable ERS correction of the camera linear movement in z direction
ers_side, // Enable ERS correction of the camera linear movement in x direction
ers_vert, // Enable ERS correction of the camera linear movement in y direction
manual_par_sel); // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
*/
boolean [] filtered_infinity = null;
double [] dfe = null;
......@@ -496,20 +487,7 @@ public class ExtrinsicAdjustment {
inf_min_disparity, // double min_infinity,
inf_max_disparity); // double max_infinity
}
/*
this.weights = getWeights( // will ignore window for infinity (already used for selection)
measured_dsxy, // double [][] measured_dsxy,
(use_disparity? force_disparity: null), // boolean [] force_disparity, // same dimension as dsdn, true if disparity should be controlled
filtered_infinity, // boolean [] filtered_infinity,
dfe, // double [] distance_from_edge,// to reduce weight of the mountain ridge, increase clouds (or null)
min_num_forced, // int min_num_forced,
infinity_right_left, // boolean infinity_right_left, // each halve should have > min_num_forced, will calculate separate average
weight_infinity, // double weight_infinity, // total weight of infinity tiles fraction (0.0 - 1.0)
weight_disparity, // double weight_disparity, // disparity weight relative to the sum of 8 lazy eye values of the same tile
weight_disparity_inf, // double weight_disparity_inf, // disparity weight relative to the sum of 8 lazy eye values of the same tile for infinity
max_disparity_far, // double max_disparity_far) // reduce weights of near tiles proportional to sqrt(max_disparity_far/disparity)
max_disparity_use);
*/
int [] inf_stat = setWeights( // number right, number left
measured_dsxy, // double [][] measured_dsxy,
(use_disparity? force_disparity: null), // boolean [] force_disparity, // same dimension as dsdn, true if disparity should be controlled
......@@ -2366,7 +2344,7 @@ public class ExtrinsicAdjustment {
if (rslt == null) {
return false; // need to check
}
if (debug_level > 1) {
if (debug_level > -3) { // > 0) {
System.out.println("LMA step "+iter+": {"+rslt[0]+","+rslt[1]+"} full RMS= "+good_or_bad_rms[0]+
" ("+initial_rms[0]+"), pure RMS="+good_or_bad_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda);
}
......
......@@ -14,6 +14,8 @@ public class MultisceneLY {
public int threadsMax = 100; // maximal number of threads to launch
public boolean updateStatus = true;
public int numSens;
public static enum MSLY_MODE {INF_ONLY, NOINF_ONLY, INF_NOINF};
public static String [] SINF_NOINF= {"inf","noinf"};
public MultisceneLY (
int numSens,
int threadsMax, // maximal number of threads to launch
......@@ -563,6 +565,7 @@ public class MultisceneLY {
* infinity [0][] and non-infinity - [1][].
* @param corr_vector_delta null or extrinsic vector offset, applied to all scenes.
* Only ERS parameters will be different, all the rest are the same for all scenes.
* @param nrefine number of disparity refines for non-infinity.
* @param threadsMax maximal number of threads to use.
* @param debug_level debug level, will show debug images if >-2.
* @return [2][clusters][LY_sclices] LY data for infinity [0][][] and non-infinity[1][][].
......@@ -577,6 +580,7 @@ public class MultisceneLY {
final double dbg_disparity_offset,
final int [][] in_num_tiles, // null or number of tiles per cluster to multiply strength
final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
final int nrefine, // number of disparity refines for non-inf
final int threadsMax,
final int debug_level){
final double [][][] inf_noinf_lazy_eye_data = new double [2][][];
......@@ -587,6 +591,7 @@ public class MultisceneLY {
int clustersX = (int) Math.ceil(1.0 * tilesX / clt_parameters.lyms_clust_size);
int clustersY = (int) Math.ceil(1.0 * tilesY / clt_parameters.lyms_clust_size);
int clusters = clustersX * clustersY;
int numSens = last_scene.tp.getNumSensors();
final int [][] num_tiles = (in_num_tiles != null)? in_num_tiles : (new int [2][]);
for (int i = 0; i < num_tiles.length; i++) {
num_tiles[i] = new int [clusters];
......@@ -628,7 +633,8 @@ public class MultisceneLY {
num_tiles[0], // final int [] num_tiles,
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level); // final int debug_level);
debug_level, // final int debug_level);
((debug_level >-2)?"INF":null)); // String debug_suffix);
// now for non-infinity:
double [][] target_disparities_noinf = MultisceneLY.useTilesLY(
clt_parameters.lyms_clust_size, // final int clust_size,
......@@ -661,7 +667,50 @@ public class MultisceneLY {
num_tiles[1], // final int [] num_tiles,
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level); // final int debug_level);
debug_level, // final int debug_level);
((debug_level >-2)?"NOINF":null)); // String debug_suffix);
if (debug) {
showLY(
clt_parameters, // CLTParameters clt_parameters,
last_scene.getGeometryCorrection(), // GeometryCorrection gc,
clustersX, // int clustersX,
clustersY, // int clustersY,
inf_noinf_lazy_eye_data[1], // double [][] ly_data,
"LY_noinf-initial"); // String title);
}
for (int n = 0; n < nrefine; n++) {
// modify target disparity with disparity difference
updateTargetDisparities(
clt_parameters, // final CLTParameters clt_parameters,
last_scene.tp, // final TileProcessor tp,
target_disparities_noinf, // double [][] target_disparities,
inf_noinf_lazy_eye_data[1], // double [][] ly_data)
threadsMax); // final int threadsMax);
inf_noinf_lazy_eye_data[1] = MultisceneLY.getLYData( // TODO: show lazy_eye_data[][]
clt_parameters, // final CLTParameters clt_parameters,
clt_parameters.lyms_clust_size, // final int clust_size,
scenes, // final QuadCLT [] scenes, // ordered by increasing timestamps
target_disparities_noinf, // final double[][] target_disparities,
num_tiles[1], // final int [] num_tiles,
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level, // final int debug_level);
((debug_level >-2)?("NOINF"+n):null)); // String debug_suffix);
if (debug) {
showLY(
clt_parameters, // CLTParameters clt_parameters,
last_scene.getGeometryCorrection(), // GeometryCorrection gc,
clustersX, // int clustersX,
clustersY, // int clustersY,
inf_noinf_lazy_eye_data[1], // double [][] ly_data,
"LY_noinf-"+n); // String title);
}
}
if (target_disparities != null) {
target_disparities[0] = target_disparities_inf;
target_disparities[1] = target_disparities_noinf;
......@@ -669,6 +718,84 @@ public class MultisceneLY {
return inf_noinf_lazy_eye_data;
}
public static void showLY(
CLTParameters clt_parameters,
GeometryCorrection gc,
int clustersX,
int clustersY,
double [][] ly_data,
String title
) {
ExtrinsicAdjustment ea = new ExtrinsicAdjustment (
gc, // GeometryCorrection gc,
clt_parameters.lyms_clust_size, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY)
int numSens = gc.getNumSensors();
double [][] dbg_cluster = new double [ExtrinsicAdjustment.get_INDX_LENGTH(numSens)][clustersY * clustersX];
for (int i = 0; i < dbg_cluster.length; i++) {
Arrays.fill(dbg_cluster[i], Double.NaN);
}
for (int n = 0; n < ly_data.length; n++) {
if (ly_data[n] != null) {
for (int i = 0; i < ExtrinsicAdjustment.get_INDX_LENGTH(numSens); i++ ) {
dbg_cluster[i][n] = ly_data[n][i];
}
}
}
(new ShowDoubleFloatArrays()).showArrays(
dbg_cluster,
clustersX,
clustersY,
true,
title,
ea.data_titles); // ExtrinsicAdjustment.DATA_TITLES);
}
private static void updateTargetDisparities(
final CLTParameters clt_parameters,
final TileProcessor tp,
final double [][] target_disparities,
final double [][] ly_data,
final int threadsMax)
{
final int clust_size = clt_parameters.lyms_clust_size;
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
final int clustersX = (int) Math.ceil(1.0 * tilesX / clust_size);
final int clustersY = (int) Math.ceil(1.0 * tilesY / clust_size);
final int clusters = clustersX * clustersY;
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nClust = ai.getAndIncrement(); nClust < clusters; nClust = ai.getAndIncrement()) if (ly_data[nClust] != null) {
int clustX = nClust % clustersX;
int clustY = nClust / clustersX;
double disp_diff = ly_data[nClust][ExtrinsicAdjustment.INDX_DIFF];
for (int ctY = 0; ctY < clust_size; ctY++) {
int tileY = clustY * clust_size + ctY;
if (tileY < tilesY) {
for (int ctX = 0; ctX < clust_size; ctX++) {
int tileX = clustX * clust_size + ctX;
if (tileX < tilesX) {
int nTile = tileY*tilesX+tileX;
for (int nscene = 0; nscene < target_disparities.length; nscene++){
if ((target_disparities[nscene] != null) && !Double.isNaN(target_disparities[nscene][nTile])) {
target_disparities[nscene][nTile] += disp_diff;
}
}
}
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
/**
......@@ -682,6 +809,7 @@ public class MultisceneLY {
* Only ERS parameters will be different, all the rest are the same for all scenes.
* @param threadsMax maximal number of threads
* @param debug_level debug level. Generates debug images if >-2.
* @param debug_suffix - add to image name, null - no images
* @return Lazy Eye data [clusters][LY_sclices]
*/
public static double [][] getLYData(
......@@ -692,7 +820,8 @@ public class MultisceneLY {
final int [] num_tiles, // null or number of tiles per cluster to multiply strength
final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
final int threadsMax,
final int debug_level){
final int debug_level,
final String debug_suffix){
int last_scene_index = scenes.length-1;
QuadCLT last_scene = scenes[last_scene_index];
int numSens = last_scene.getNumSensors();
......@@ -704,7 +833,7 @@ public class MultisceneLY {
final int clusters = clustersX * clustersY;
final int num_pairs = Correlation2d.getNumPairs(last_scene.getNumSensors());
boolean show_corr = debug_level > -2;
boolean show_corr = (debug_suffix != null) ; //debug_level > -2;
final float [][][] fclt_corr = show_corr ? (new float [tilesX * tilesY][][]) : null;
final double [][][][][] dcorr_td_acc = new double[num_pairs][][][][];
......@@ -931,7 +1060,7 @@ public class MultisceneLY {
wh[0],
wh[1],
true,
last_scene.getImageName()+"-CORR-DECIMATED"+clust_size,
last_scene.getImageName()+"-CORR-DECIMATED"+clust_size+"-"+debug_suffix,
titles);
double [][] disparity_map_decimated = ImageDtt.corr2d_decimate( // not used in lwir
disparity_map, // final float [][] corr2d_img,
......@@ -947,7 +1076,7 @@ public class MultisceneLY {
wh[0],
wh[1],
true,
"disparity_map_decimated",
"disparity_map_decimated"+"-"+debug_suffix,
ImageDtt.getDisparityTitles(last_scene.getNumSensors(),last_scene.isMonochrome()) // ImageDtt.DISPARITY_TITLES
);
......@@ -1131,12 +1260,90 @@ public class MultisceneLY {
return combo_pXpYD;
}
public static double [][] mergeLY(
MSLY_MODE adjust_mode,
double [][][] lazy_eye_data2,
boolean [] force_disparity // null or [clusters]
)
{
double [][] lazy_eye_data = null;
int clusters = 0;
for (int i = 0; i < lazy_eye_data2.length; i++) {
if (lazy_eye_data2[i] != null) {
clusters = lazy_eye_data2[i].length;
break;
}
}
if (adjust_mode == MSLY_MODE.INF_NOINF) {
if ((lazy_eye_data2.length < 2) || (lazy_eye_data2[1] == null)) {
adjust_mode = MSLY_MODE.INF_ONLY;
} else if (lazy_eye_data2[0] == null) {
adjust_mode = MSLY_MODE.NOINF_ONLY;
}
}
switch (adjust_mode) {
case INF_ONLY:
if (lazy_eye_data2[0] == null) {
return null;
}
lazy_eye_data = lazy_eye_data2[0];
if (force_disparity != null) {
for (int i = 0; i < clusters; i++) {
force_disparity[i] = lazy_eye_data[i] != null;
}
}
break;
case NOINF_ONLY:
if ((lazy_eye_data2.length > 1) && (lazy_eye_data2[1] == null)) {
return null;
}
lazy_eye_data = lazy_eye_data2[1];
if (force_disparity != null) {
for (int i = 0; i < clusters; i++) {
force_disparity[i] = false;
}
}
break;
case INF_NOINF: // both lazy_eye_data2[0] and lazy_eye_data2[1] are non-nulls
if (force_disparity != null) {
for (int i = 0; i < clusters; i++) {
force_disparity[i] = (lazy_eye_data2[0][i] != null) && (lazy_eye_data2[1][i] != null); // do not process w/o noinf
}
}
lazy_eye_data = new double [clusters][];
for (int i = 0; i < clusters; i++) if (lazy_eye_data2[1][i] != null){
lazy_eye_data[i] = lazy_eye_data2[1][i].clone();
if (lazy_eye_data2[0][i] != null) {
for (int n = 0;n < lazy_eye_data2[0][i].length; n++) {
switch (n){
case ExtrinsicAdjustment.INDX_DISP:
case ExtrinsicAdjustment.INDX_STRENGTH:
case ExtrinsicAdjustment.INDX_TARGET:
case ExtrinsicAdjustment.INDX_DIFF:
lazy_eye_data[i][n] = lazy_eye_data2[0][i][n];
}
}
}
}
break;
}
return lazy_eye_data;
}
public boolean processLYdata(
final CLTParameters clt_parameters,
MSLY_MODE adjust_mode,
final QuadCLT [] scenes, // ordered by increasing timestamps
final double [][][] lazy_eye_data,
final int debugLevel
) {
final double [][][] lazy_eye_data2,
final boolean [][] valid_tile, // tile with lma and single correlation maximum
final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
boolean update_disparity, // re-measure disparity before measuring LY
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) {
int last_scene_index = scenes.length-1;
QuadCLT last_scene = scenes[last_scene_index];
int numSens = last_scene.getNumSensors();
......@@ -1153,20 +1360,20 @@ public class MultisceneLY {
clt_parameters.lyms_clust_size, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY)
double [][][] dbg_cluster = new double [lazy_eye_data.length][ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors())][clustersY * clustersX];
for (int m = 0; m < lazy_eye_data.length; m++) {
double [][][] dbg_cluster = new double [lazy_eye_data2.length][ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors())][clustersY * clustersX];
for (int m = 0; m < lazy_eye_data2.length; m++) {
for (int i = 0; i < dbg_cluster.length; i++) {
Arrays.fill(dbg_cluster[m][i], Double.NaN);
}
for (int n = 0; n < lazy_eye_data[m].length; n++) {
if (lazy_eye_data[m][n] != null) {
for (int n = 0; n < lazy_eye_data2[m].length; n++) {
if (lazy_eye_data2[m][n] != null) {
for (int i = 0; i < ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors()); i++ ) {
dbg_cluster[m][i][n] = lazy_eye_data[m][n][i];
dbg_cluster[m][i][n] = lazy_eye_data2[m][n][i];
}
}
}
}
for (int m = 0; m < lazy_eye_data.length; m++) {
for (int m = 0; m < lazy_eye_data2.length; m++) {
(new ShowDoubleFloatArrays()).showArrays(
dbg_cluster[m],
clustersX,
......@@ -1175,8 +1382,8 @@ public class MultisceneLY {
last_scene.getImageName()+"-lazy_eye_data-"+m,
ea.data_titles); // ExtrinsicAdjustment.DATA_TITLES);
}
ea.showInput(lazy_eye_data[0],"first_data-inf");
ea.showInput(lazy_eye_data[1],"first_data-noinf");
ea.showInput(lazy_eye_data2[0],"first_data-inf");
ea.showInput(lazy_eye_data2[1],"first_data-noinf");
return true;
}
......@@ -1195,7 +1402,7 @@ public class MultisceneLY {
boolean use_tarz, // derivatives by tarz, not symmetrical vectors
final int debugLevel)
{
final String [] sinf_noinf= {"inf","noinf"};
// final String [] sinf_noinf= {"inf","noinf"};
// delta = 0.001;
/*double [] parameter_scales4 = { // multiply delay for each parameter
......@@ -1235,7 +1442,7 @@ public class MultisceneLY {
300, // 2.943408022525927E-0, // 4, // 17 10000x vy
500.0}; // 390.6185365641268}; //4}; // 18 100000x vz
// delta = 0.001; // should be 0.001
final boolean debug_img = true; // false;
final boolean debug_img = false; // true; // false;
final int last_scene_index = scenes.length-1;
final QuadCLT last_scene = scenes[last_scene_index];
final int numSens = last_scene.getNumSensors();
......@@ -1299,7 +1506,7 @@ public class MultisceneLY {
for (int nly = 0; nly < ly_initial2.length; nly++) if (ly_initial2[nly] != null ) {
ea.showInput(
ly_initial2[nly], // double[][] data,
"drv_reference-"+sinf_noinf[nly]);// String title);
"drv_reference-"+SINF_NOINF[nly]);// String title);
}
System.out.println("Initial:\n"+last_scene.getGeometryCorrection().getCorrVector().toString(true)); // true - short out
double min_strength = 0.1; // 0.23
......@@ -1315,7 +1522,7 @@ public class MultisceneLY {
}
}
}
int nrefine = 4;
for (int npar = 0; npar < num_pars; npar++) {
// perform asymmetric delta
double [] par_inc = new double [num_pars];
......@@ -1341,62 +1548,17 @@ public class MultisceneLY {
0.0, // final double dbg_disparity_offset,
null, // final int [][] in_num_tiles, // null or number of tiles per cluster to multiply strength
corr_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
nrefine, // final int nrefine, // number of disparity refines for non-inf
threadsMax, // final int threadsMax,
debugLevel); // final int debug_level);
/// if (update_disparity) {
/// CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
/// clt_parameters,
/// scanIndex,
/// false, // final boolean save_textures,
/// 0, // final int clust_radius,
/// tp.threadsMax, // maximal number of threads to launch
/// false, // updateStatus,
/// debugLevelInner -1); // - 1); // -5-1
/// }
/// CLTMeasureLY( // perform single pass according to prepared tiles operations and disparity // USED in lwir
/// clt_parameters,
/// scanIndex, // final int scanIndex,
// only combine and calculate once, next passes keep
// remeasure each pass - target disparity is the same, but vector changes
/// 0, // bg_scan, // (num_iter >0)? -1: bg_scan, // final int bgIndex, // combine, if >=0
/// tp.threadsMax, // maximal number of threads to launch
/// false, // updateStatus,
/// debugLevelInner -1); // - 1); // -5-1
/// ly = scan.getLazyEyeData();
if (debug_img) {
for (int nly = 0; nly < ly2.length; nly++) if (ly2[nly] != null ) {
ea.showInput(
ly2[nly], // double[][] data,
"drv_par-"+sinf_noinf[nly]);// String title);
"drv_par-"+SINF_NOINF[nly]);// String title);
}
}
// Tested - no difference
// CLTMeasureLY( // perform single pass according to prepared tiles operations and disparity // USED in lwir
// clt_parameters,
// scanIndex, // final int scanIndex,
// // only combine and calculate once, next passes keep
// // remeasure each pass - target disparity is the same, but vector changes
// 0, // bg_scan, // (num_iter >0)? -1: bg_scan, // final int bgIndex, // combine, if >=0
// tp.threadsMax, // maximal number of threads to launch
// false, // updateStatus,
// debugLevelInner -1); // - 1); // -5-1
// ly = scan.getLazyEyeData();
// ea.showInput(
// ly, // double[][] data,
// "drv_par"+npar+"-B");// String title);
// if (debugLevel > -3) {
// System.out.println(ea.stringWeightedLY(
// ly, // double [][] data,
// null, // double [][] ref_data,
// min_strength, // double min_strength,
// pfmt, // int [] format,
// "_"+titles[npar])); // String suffix))
// }
for (int nly = 0; nly < ly_diff2.length; nly++) if (ly_diff2[nly] != null ) {
for (int cluster = 0; cluster < clusters; cluster++) if ((ly_initial2[nly][cluster] != null) && (ly2[nly][cluster]!=null)){
......@@ -1422,7 +1584,7 @@ public class MultisceneLY {
ly_initial2[nly], // double [][] ref_data,
min_strength, // double min_strength,
pfmt, // int [] format,
"_d"+titles[npar]+"-"+sinf_noinf[nly])); // String suffix))
"_d"+titles[npar]+"-"+SINF_NOINF[nly])); // String suffix))
if (debug_img) {
// check nd bug
......@@ -1445,7 +1607,7 @@ public class MultisceneLY {
clustersX,
clustersY,
true,
"ND_test_npar-_"+npar+"-"+sinf_noinf[nly],
"ND_test_npar-_"+npar+"-"+SINF_NOINF[nly],
sens_titles);
}
}
......@@ -1470,7 +1632,7 @@ public class MultisceneLY {
if (mode == 0) {
dbg_img2[nly][par][pix] = -ly_diff2[nly][par][indx][cluster];
} else {
dbg_img2[nly][par][pix] = ly_diff2[nly][par][indx][cluster];
dbg_img2[nly][par][pix] = ly_diff2[nly][par][indx][cluster];
}
}
}
......@@ -1482,7 +1644,7 @@ public class MultisceneLY {
width,
height,
true,
"dLY_dpar_"+delta+"DINV"+(update_disparity?"U":"")+"-"+sinf_noinf[nly],
"dLY_dpar_"+delta+"DINV"+(update_disparity?"U":"")+"-"+SINF_NOINF[nly],
titles);
}
dbg_img2 = new double [ly_diff2.length][num_pars][width*height];
......@@ -1511,7 +1673,7 @@ public class MultisceneLY {
width,
height,
true,
"dLY_dpar_"+delta+"DINV"+(update_disparity?"U":"")+"-XY"+"-"+sinf_noinf[nly],
"dLY_dpar_"+delta+"DINV"+(update_disparity?"U":"")+"-XY"+"-"+SINF_NOINF[nly],
titles);
}
return;
......
......@@ -11103,7 +11103,8 @@ if (debugLevel > -100) return true; // temporarily !
public void adjustLYSeries(
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
CLTParameters clt_parameters,
MultisceneLY.MSLY_MODE adjust_mode,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
......@@ -11139,7 +11140,7 @@ if (debugLevel > -100) return true; // temporarily !
// temporarily fix wrong sign:
ErsCorrection ers = (ErsCorrection) (quadCLTs[i].getGeometryCorrection());
if (reset_from_extrinsics) { // extrinsics vector "IMU" parameters
System.out.println("Reset ERS parameters from intraframe extrinsics");
System.out.println("Reset ERS parameters from intraframe extrinsics");
ers.setupERSfromExtrinsics();
}
quadCLTs[i].setDSRBG(
......@@ -11148,41 +11149,42 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
boolean proc_infinity = true;
boolean proc_infinity = (adjust_mode == MultisceneLY.MSLY_MODE.INF_ONLY) || (adjust_mode == MultisceneLY.MSLY_MODE.INF_NOINF); // true;
boolean lma_only = true; // use clt_parameters
double dbg_disparity_offset = 0.0; // 0.1
double inf_disp_ref = 0.0;
int last_scene_index = quadCLTs.length-1;
QuadCLT last_scene = quadCLTs[last_scene_index];
String composite_suffix = "-INTER-INTRA-LMA";
String num_corr_max_suffix = "-NUM-CORR-MAX";
int [] wh = new int[2];
double [][] composite_ds = last_scene.readDoubleArrayFromModelDirectory(
composite_suffix, // String suffix,
0, // int num_slices, // (0 - all)
wh); // int [] wh)
String composite_suffix = "-INTER-INTRA-LMA";
String num_corr_max_suffix = "-NUM-CORR-MAX";
int [] wh = new int[2];
double [][] composite_ds = last_scene.readDoubleArrayFromModelDirectory(
composite_suffix, // String suffix,
0, // int num_slices, // (0 - all)
wh); // int [] wh)
// composite_ds == null if no file
MultisceneLY multisceneLY = new MultisceneLY (
quadCLTs[0].getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
// read interscene composite data
// read interscene composite data
boolean [][] is_scene_infinity = null; // per scene, per tile - is infinity.
int tilesX = last_scene.tp.getTilesX();
int tilesY = last_scene.tp.getTilesY();
int clustersX = (int) Math.ceil(1.0 * tilesX / clt_parameters.lyms_clust_size);
int clustersY = (int) Math.ceil(1.0 * tilesY / clt_parameters.lyms_clust_size);
int clusters = clustersX * clustersY;
// int [] num_tiles = new int [clusters]; // may be null;; // null;
// boolean [] inf_cluster = new boolean [clusters]; // null;
// int [] num_tiles = new int [clusters]; // may be null;; // null;
// boolean [] inf_cluster = new boolean [clusters]; // null;
boolean debug = debugLevel > -2;
if (proc_infinity) {
double [] inf_avg = new double[1];
boolean [] ref_inf = MultisceneLY.getComboInfinity(
......@@ -11197,13 +11199,13 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.lyms_min_fg_str, // double min_fg_str,
inf_avg, // double [] inf_avg,
debug); // boolean debug)
is_scene_infinity = MultisceneLY.infinityPerScene(
quadCLTs, // QuadCLT [] scenes,
inf_avg[0], // double inf_disp_ref, // average disparity at infinity for ref scene
ref_inf, // boolean [] infinity_ref,
debug, // boolean debug,
threadsMax); // int threadsMax)
quadCLTs, // QuadCLT [] scenes,
inf_avg[0], // double inf_disp_ref, // average disparity at infinity for ref scene
ref_inf, // boolean [] infinity_ref,
debug, // boolean debug,
threadsMax); // int threadsMax)
inf_disp_ref = inf_avg[0];
}
// Read or generate+save number of correlation maximums per scene, per tile
......@@ -11211,8 +11213,8 @@ if (debugLevel > -100) return true; // temporarily !
int [][] numCorrMax = new int [quadCLTs.length][]; // ->
double [][] dNumCorrMax =last_scene.readDoubleArrayFromModelDirectory(
num_corr_max_suffix, // String suffix,
0, // int num_slices, // (0 - all)
wh); // int [] wh)
0, // int num_slices, // (0 - all)
wh); // int [] wh)
if ((dNumCorrMax != null) && (dNumCorrMax.length == numCorrMax.length)) {
for (int nscene = 0; nscene < numCorrMax.length; nscene++) {
numCorrMax[nscene] = new int[dNumCorrMax[nscene].length];
......@@ -11235,7 +11237,7 @@ if (debugLevel > -100) return true; // temporarily !
dNumCorrMax[nscene][i] = numCorrMax[nscene][i];
}
}
last_scene.saveDoubleArrayInModelDirectory( // error
num_corr_max_suffix, // String suffix,
null, // null, // String [] labels, // or null
......@@ -11248,46 +11250,197 @@ if (debugLevel > -100) return true; // temporarily !
for (int nscene = 0; nscene < numCorrMax.length; nscene++) {
for (int nTile = 0; nTile < numCorrMax[nscene].length; nTile++) {
valid_tile[nscene][nTile] = numCorrMax[nscene][nTile] == 1; // only single-maximum
if (clt_parameters.lyms_margin > 0) {
int tileX = nTile % tilesX;
int tileY = nTile / tilesX;
if ( (tileY < clt_parameters.lyms_margin) ||
(tileX < clt_parameters.lyms_margin) ||
(tileY >= (tilesY - clt_parameters.lyms_margin)) ||
(tileX >= (tilesX - clt_parameters.lyms_margin))) {
valid_tile[nscene][nTile] = false;
}
}
}
}
int [][] num_tiles2 = new int[2][];
double [][][] target_disparities = new double [2][][];
double [][][] lazy_eye_data = MultisceneLY.getLYDataInfNoinf(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, // final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
target_disparities, // final double[][] target_disparities,
dbg_disparity_offset, // final double dbg_disparity_offset,
num_tiles2, // final int [][] in_num_tiles, // null or number of tiles per cluster to multiply strength
null, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debugLevel); // final int debug_level);
boolean use_tarz = false; // true; //false;
double delta = 0.001; // 0.01;
boolean debug_derivs = false;
ExtrinsicAdjustment ea = new ExtrinsicAdjustment (
last_scene.getErsCorrection(), // GeometryCorrection gc,
clt_parameters.lyms_clust_size, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY)
boolean [] force_disparity = new boolean[clusters];
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
// int max_tries = 5; // organize cycle with comparing results
int max_tries = clt_parameters.lym_iter; // 25;
double inf_min = -1.0;
double inf_max = 1.0;
double [] old_new_rms = new double [2];
double min_sym_update = clt_parameters.getLymChange(last_scene.isAux()); // 4e-6; // stop iterations if no angle changes more than this
double comp_diff = min_sym_update + 1; // (> min_sym_update)
boolean use_tarz = false; // true; //false;
double delta = 0.001; // 0.01;
MultisceneLY.debugLYDerivatives(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data, // double [][][] lazy_eye_data2, // inf, no_inf
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, //final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
false, // boolean update_disparity, // re-measure disparity before measuring LY
threadsMax, // final int threadsMax, // maximal number of threads to launch
true, // final boolean updateStatus,
delta, // double delta,
use_tarz, // boolean use_tarz, // derivatives by tarz, not symmetrical vectors
debugLevel); // final int debugLevel);
if (debugLevel > -200) {
return;
double [] disparity_offset = new double [clusters]; // 0.1
if (dbg_disparity_offset != 0.0) {
Arrays.fill(disparity_offset, dbg_disparity_offset);
}
int nrefine = 4;
for (int num_iter = 0; num_iter < max_tries; num_iter++){
// (re-)measure LY here, update all scenes? or just accumulater difference?
double [][][] lazy_eye_data2 = MultisceneLY.getLYDataInfNoinf(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, // final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
target_disparities, // final double[][] target_disparities,
dbg_disparity_offset, // final double dbg_disparity_offset,
num_tiles2, // final int [][] in_num_tiles, // null or number of tiles per cluster to multiply strength
null, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
nrefine, // final int nrefine, // number of disparity refines for non-inf
threadsMax, // final int threadsMax,
debugLevel); // final int debug_level);
if (debug_derivs && (num_iter == 0)) { // only once if any
MultisceneLY.debugLYDerivatives(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data2, // double [][][] lazy_eye_data2, // inf, no_inf
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, //final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
false, // boolean update_disparity, // re-measure disparity before measuring LY
threadsMax, // final int threadsMax, // maximal number of threads to launch
true, // final boolean updateStatus,
delta, // double delta,
use_tarz, // boolean use_tarz, // derivatives by tarz, not symmetrical vectors
debugLevel); // final int debugLevel);
}
for (int nly = 0; nly < lazy_eye_data2.length; nly++) if (lazy_eye_data2[nly] != null ) {
ea.showInput(
lazy_eye_data2[nly], // double[][] data,
"drv_reference-"+MultisceneLY.SINF_NOINF[nly]);// String title);
}
double [][] lazy_eye_data = MultisceneLY.mergeLY(
adjust_mode, // MSLY_MODE adjust_mode,
lazy_eye_data2, // double [][][] lazy_eye_data2,
force_disparity); // boolean [] force_disparity // null or [clusters]
ea.setForceDisparity(force_disparity);
ea.showInput(
lazy_eye_data, // double[][] data,
"ly_combo-"+lazy_eye_data.toString());// String title);
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
inf_min, //double inf_min_disparity, // minimal disparity for infinity
inf_max, // double inf_max_disparity, // minimal disparity for infinity
clt_parameters.ly_inf_min_broad, // inf_min_disp_abs, // minimal disparity for infinity (absolute)
clt_parameters.ly_inf_max_broad, // maximal disparity for infinity (absolute)
clt_parameters.ly_inf_tilt, // boolean en_infinity_tilt, // select infinity tiles form right/left tilted (false - from average)
clt_parameters.ly_right_left, // boolean infinity_right_left, // balance weights between right and left halves of infinity
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_min_forced, // int min_num_forced, // minimal number of clusters with forced disparity to use it
// data, using just radial distortions
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_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
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)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
clt_parameters.ly_weight_disparity, //0.0, // double weight_disparity, // 0.0 disparity weight relative to the sum of 8 lazy eye values of the same tile
clt_parameters.ly_weight_disparity_inf,//0.5, // double weight_disparity_inf,// 0.5 disparity weight relative to the sum of 8 lazy eye values of the same tile for infinity
clt_parameters.ly_max_disparity_far, //5.0, // double max_disparity_far, // 5.0 reduce weights of near tiles proportional to sqrt(max_disparity_far/disparity)
clt_parameters.ly_max_disparity_use, //5.0, // double max_disparity_use, // 5.0 (default 1000)disable near objects completely - use to avoid ERS
0.0, // clt_parameters.ly_inf_min_dfe, //1.75,// double min_dfe, // = 1.75;
0.0, // clt_parameters.ly_inf_max_dfe, //5.0, // double max_dfe, // = 5.0; // <=0 - disable feature
// moving objects filtering
false, // clt_parameters.ly_moving_en, // boolean moving_en, // enable filtering areas with potentially moving objects
clt_parameters.ly_moving_apply, // boolean moving_apply, // apply filtering areas with potentially moving objects
clt_parameters.ly_moving_sigma, // double moving_sigma, // blurring sigma for moving objects = 1.0;
clt_parameters.ly_max_mov_disparity, // double max_mov_disparity, // disparity limit for moving objects detection = 75.0;
clt_parameters.ly_rad_to_hdiag_mov, // double rad_to_hdiag_mov, // radius to half-diagonal ratio to remove high-distortion corners = 0.7 ; // 0.8
clt_parameters.ly_max_mov_average, // double max_mov_average, // do not attempt to detect moving objects if ERS is not accurate for terrain = .25;
clt_parameters.ly_mov_min_L2, // double mov_min_L2, // threshold for moving objects = 0.75;
lazy_eye_data, // scan.getLazyEyeData(), // dsxy, // double [][] measured_dsxy,
force_disparity, // scan.getLazyEyeForceDisparity(), // null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
last_scene.getGeometryCorrection().getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel) >=2 to show images
if (debugLevel > -2){
System.out.println("Old extrinsic corrections:");
System.out.println(last_scene.getGeometryCorrection().getCorrVector().toString());
}
if (corr_vector != null) {
CorrVector diff_corr = corr_vector.diffFromVector(last_scene.getGeometryCorrection().getCorrVector());
comp_diff = diff_corr.getNorm(); // apply this to all scenes
if (debugLevel > -2){
System.out.println("New extrinsic corrections:");
System.out.println(corr_vector.toString());
}
if (debugLevel > -3){
System.out.println("Increment extrinsic corrections:");
System.out.println(diff_corr.toString());
}
last_scene.gpuResetCorrVector(); // next time GPU will need to set correction vector (and re-calculate offsets?)
if (apply_extrinsic){
// Apply correction to all scenes (adding, as ERS can be different)
// will need to update all scenes GC (write back to disk), but only after all are done
for (int i = 0; i < quadCLTs.length; i++) {
QuadCLT scene = quadCLTs[i];
CorrVector scene_vector = scene.getGeometryCorrection().getCorrVector();
scene_vector.incrementVector(diff_corr, 1.0); // no scale here
scene.getGeometryCorrection().setCorrVector(scene_vector);
}
System.out.println("Extrinsic correction updated (can be disabled by setting clt_parameters.ly_corr_scale = 0.0) ");
} else {
System.out.println("Correction is not applied according clt_parameters.ly_corr_scale == 0.0) ");
}
} else {
if (debugLevel > -3){
System.out.println("LMA failed"); // What now?
}
}
boolean done = (comp_diff < min_sym_update) || (num_iter == (max_tries - 1));
// System.out.println("done="+done);
if (debugLevel > -10) { // should work even in batch mode
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + old_new_rms[0]+
" final RMS = " + old_new_rms[1]+ " (debugLevel = "+debugLevel+")");
}
if (debugLevel > -10) {
if ((debugLevel > -3) || done) {
System.out.println("New extrinsic corrections:");
System.out.println(last_scene.getGeometryCorrection().getCorrVector().toString());
}
}
if (comp_diff < min_sym_update) {
break;
}
inf_disp_ref = 0.0; // after first adjustment set infinity to 0.0
}
// Now update correction vector for all scenes to disk - how was it read?
// update
if (debugLevel > -200) {
return;
}
// debug images
if (debugLevel > -2) {
double [][] dbg_numCorrMax = new double[numCorrMax.length][];
......@@ -11319,49 +11472,22 @@ if (debugLevel > -100) return true; // temporarily !
new String[] {"inf tiles", "noinf tiles"});
}
if (lazy_eye_data != null) {
multisceneLY.processLYdata(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data, // final double [][][] lazy_eye_data,
debugLevel); // final int debugLevel
/*
ExtrinsicAdjustment ea = new ExtrinsicAdjustment (
last_scene.getErsCorrection(), // GeometryCorrection gc,
clt_parameters.lyms_clust_size, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY)
double [][][] dbg_cluster = new double [lazy_eye_data.length][ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors())][clustersY * clustersX];
for (int m = 0; m < lazy_eye_data.length; m++) {
for (int i = 0; i < dbg_cluster.length; i++) {
Arrays.fill(dbg_cluster[m][i], Double.NaN);
}
for (int n = 0; n < lazy_eye_data[m].length; n++) {
if (lazy_eye_data[m][n] != null) {
for (int i = 0; i < ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors()); i++ ) {
dbg_cluster[m][i][n] = lazy_eye_data[m][n][i];
}
}
}
}
for (int m = 0; m < lazy_eye_data.length; m++) {
(new ShowDoubleFloatArrays()).showArrays(
dbg_cluster[m],
clustersX,
clustersY,
true,
last_scene.getImageName()+"-lazy_eye_data-"+m,
ea.data_titles); // ExtrinsicAdjustment.DATA_TITLES);
}
*/
// Testing next step
/* TODO: move all adjustments there?
if (lazy_eye_data != null) {
multisceneLY.processLYdata( // TODO: move all adjustments there?
clt_parameters, // final CLTParameters clt_parameters,
adjust_mode, // MSLY_MODE adjust_mode,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data2, // final double [][][] lazy_eye_data,
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, // final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
false, // boolean update_disparity, // re-measure disparity before measuring LY
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
*/
if (debugLevel > -2) {
System.out.println("adjustLYSeries() Done");
}
......
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