Commit 00ba5f14 authored by Andrey Filippov's avatar Andrey Filippov

Tested basic DSI generation for LWIR

parent 9a970304
...@@ -160,7 +160,8 @@ public class EyesisCorrectionParameters { ...@@ -160,7 +160,8 @@ public class EyesisCorrectionParameters {
public boolean clt_batch_genMl = true; // Generate ML output public boolean clt_batch_genMl = true; // Generate ML output
public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected
public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model
public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data
public boolean clt_batch_dsi_aux_full=false; // more than just preExpandCLTQuad3d() (same as for Lazy Eye
public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model
public boolean clt_batch_save_all = true; // Save all parameters with the model public boolean clt_batch_save_all = true; // Save all parameters with the model
...@@ -302,6 +303,7 @@ public class EyesisCorrectionParameters { ...@@ -302,6 +303,7 @@ public class EyesisCorrectionParameters {
cp.clt_batch_dsi= this.clt_batch_dsi; cp.clt_batch_dsi= this.clt_batch_dsi;
cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux; cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux;
cp.clt_batch_dsi_aux_full= this.clt_batch_dsi_aux_full;
cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics; cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics;
cp.clt_batch_save_all= this.clt_batch_save_all; cp.clt_batch_save_all= this.clt_batch_save_all;
...@@ -482,6 +484,7 @@ public class EyesisCorrectionParameters { ...@@ -482,6 +484,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+""); properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+"");
properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+""); properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+"");
properties.setProperty(prefix+"clt_batch_dsi_aux_full", this.clt_batch_dsi_aux_full+"");
properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+""); properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+"");
properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+""); properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+"");
...@@ -640,6 +643,7 @@ public class EyesisCorrectionParameters { ...@@ -640,6 +643,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi")); if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux")); if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux_full")!= null) this.clt_batch_dsi_aux_full=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux_full"));
if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics")); if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics"));
if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all")); if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all"));
...@@ -1015,6 +1019,10 @@ public class EyesisCorrectionParameters { ...@@ -1015,6 +1019,10 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Include/genarate separate aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux, gd.addCheckbox ("Include/genarate separate aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux,
"8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+ "8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+
" EO+LWIR - generate a separate GT+AUX file"); " EO+LWIR - generate a separate GT+AUX file");
gd.addCheckbox ("Additional steps to calculate Auf DSI (more than for LY adjustment)", this.clt_batch_dsi_aux_full,
"(Not yet tested)");
gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics, gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics,
"This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated"); "This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated");
gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all, gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all,
...@@ -1103,6 +1111,7 @@ public class EyesisCorrectionParameters { ...@@ -1103,6 +1111,7 @@ public class EyesisCorrectionParameters {
this.clt_batch_dbg1= gd.getNextBoolean(); // 29 this.clt_batch_dbg1= gd.getNextBoolean(); // 29
this.clt_batch_dsi= gd.getNextBoolean(); this.clt_batch_dsi= gd.getNextBoolean();
this.clt_batch_dsi_aux= gd.getNextBoolean(); this.clt_batch_dsi_aux= gd.getNextBoolean();
this.clt_batch_dsi_aux_full= gd.getNextBoolean();
this.clt_batch_save_extrinsics= gd.getNextBoolean(); this.clt_batch_save_extrinsics= gd.getNextBoolean();
this.clt_batch_save_all= gd.getNextBoolean(); this.clt_batch_save_all= gd.getNextBoolean();
if (clt_parameters != null) { if (clt_parameters != null) {
...@@ -1291,6 +1300,10 @@ public class EyesisCorrectionParameters { ...@@ -1291,6 +1300,10 @@ public class EyesisCorrectionParameters {
extensions[0] = sourceSuffix; extensions[0] = sourceSuffix;
prefixes[0] = sourcePrefix; prefixes[0] = sourcePrefix;
MultipleExtensionsFileFilter setFilter = new MultipleExtensionsFileFilter(prefixes,extensions,"Image sets"); MultipleExtensionsFileFilter setFilter = new MultipleExtensionsFileFilter(prefixes,extensions,"Image sets");
MultipleExtensionsFileFilter setFilterMain = new MultipleExtensionsFileFilter(
new String[] {prefixes[0]},new String[] {extensions[0]},"Image sets main");
MultipleExtensionsFileFilter setFilterAux = new MultipleExtensionsFileFilter(
new String[] {prefixes[1]},new String[] {extensions[1]},"Image sets main");
DirectoryChoser dc = new DirectoryChoser( DirectoryChoser dc = new DirectoryChoser(
setFilter, setFilter,
...@@ -1319,16 +1332,27 @@ public class EyesisCorrectionParameters { ...@@ -1319,16 +1332,27 @@ public class EyesisCorrectionParameters {
ArrayList<File> setFilesList = new ArrayList<File>(); // list of set files ArrayList<File> setFilesList = new ArrayList<File>(); // list of set files
for (int nFile=0;nFile<files.length;nFile++) { for (int nFile=0;nFile<files.length;nFile++) {
// String [] setChnFiles = files[nFile].list(setFilter); // String [] setChnFiles = files[nFile].list(setFilter);
File [] setChnFiles = files[nFile].listFiles(setFilter); File [] setChnFiles = files[nFile].listFiles(setFilter);
File [] setMainChnFiles = files[nFile].listFiles(setFilterMain);
File [] setAuxChnFiles = files[nFile].listFiles(setFilterAux);
int num_match = setChnFiles.length; int num_match = setChnFiles.length;
if ( (num_match == num_chn_files) || // all files for main and aux if (num_match == num_chn_files) {
(num_match == num_chn_main) || // only main camera files // || // all files for main and aux
(num_match == num_chn_aux)) // only aux camera files // (setMainChnFiles.length == num_chn_main) || // has all needed main camera files
{ // only use sets of exact number of files // (setAuxChnFiles.length == num_chn_aux)) // has all needed camera files
// { // only use sets of exact number of files
setDirList.add(files[nFile]); setDirList.add(files[nFile]);
for (File f: setChnFiles) { for (File f: setChnFiles) {
setFilesList.add(f); setFilesList.add(f);
} }
} else if ((setMainChnFiles.length == num_chn_main) || (setAuxChnFiles.length == num_chn_aux)) {
setDirList.add(files[nFile]);
if (setMainChnFiles.length == num_chn_main) {
for (File f: setMainChnFiles) setFilesList.add(f);
}
if (setAuxChnFiles.length == num_chn_aux) {
for (File f: setAuxChnFiles) setFilesList.add(f);
}
} }
} }
String [] sourceSetPaths = new String[setDirList.size()]; String [] sourceSetPaths = new String[setDirList.size()];
......
...@@ -269,7 +269,7 @@ public class PolynomialApproximation { ...@@ -269,7 +269,7 @@ public class PolynomialApproximation {
this.debugLevel); this.debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation( // no use
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
int debugLevel int debugLevel
...@@ -312,8 +312,8 @@ public class PolynomialApproximation { ...@@ -312,8 +312,8 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) 1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel); this.debugLevel);
} }
/*
public double [][] quadraticApproximation( public double [][] quadraticApproximation( // no use
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
double thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) double thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
...@@ -328,7 +328,7 @@ public class PolynomialApproximation { ...@@ -328,7 +328,7 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) 1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel); this.debugLevel);
} }
*/
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -441,8 +441,12 @@ public class PolynomialApproximation { ...@@ -441,8 +441,12 @@ public class PolynomialApproximation {
} }
} }
} }
int zDim=data[0][1].length; int zDim = 0; // =data[0][1].length;
for (int i = 0; i < data.length; i++) if (data[i] != null){
zDim =data[i][1].length;
break;
}
double w,z,x,x2,x3,x4,y,y2,y3,y4,wz; double w,z,x,x2,x3,x4,y,y2,y3,y4,wz;
int i,j,n=0; int i,j,n=0;
...@@ -465,7 +469,7 @@ public class PolynomialApproximation { ...@@ -465,7 +469,7 @@ public class PolynomialApproximation {
SZ02[i]=0.0; SZ02[i]=0.0;
SZ20[i]=0.0; SZ20[i]=0.0;
} }
for (i=0;i<data.length;i++) { for (i=0;i<data.length;i++) if (data[i] != null){
w=(data[i].length>2)? data[i][2][0]:1.0; w=(data[i].length>2)? data[i][2][0]:1.0;
if (w>0) { if (w>0) {
n++; n++;
...@@ -585,7 +589,7 @@ public class PolynomialApproximation { ...@@ -585,7 +589,7 @@ public class PolynomialApproximation {
} }
return ABCDEF; return ABCDEF;
} }
// calcualte "volume" made of the matrix row-vectors, placed orthogonally // calculate "volume" made of the matrix row-vectors, placed orthogonally
// to be compared to determinant // to be compared to determinant
public double normMatix(double [][] a) { public double normMatix(double [][] a) {
double d,norm=1.0; double d,norm=1.0;
......
...@@ -64,14 +64,15 @@ public class CLTPass3d{ ...@@ -64,14 +64,15 @@ public class CLTPass3d{
// texture_selection is only used for the GPU and if not null means it is for the GPU // texture_selection is only used for the GPU and if not null means it is for the GPU
public boolean [] texture_selection = null; // use by the GPU to set texture to generate public boolean [] texture_selection = null; // use by the GPU to set texture to generate
public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity for this tile, regardless of results public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity for this tile, regardless of results
public int clust_radius = 0; // 0 - no clusters, 1 = 1x1 (same as 0, just different program), 2 - 3x3, 3 - 5x5
public boolean is_combo = false; public boolean is_combo = false;
public boolean is_measured = false; public boolean is_measured = false;
public String texture = null; // relative (to x3d) path public String texture = null; // relative (to x3d) path
public Rectangle texture_bounds; // in tiles, not pixels ! public Rectangle texture_bounds; // in tiles, not pixels !
public int dbg_index; public int dbg_index;
public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY
public int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY; // set to -1 to ignore and always use just CM (also applies to lma_strength - next) public int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY; // set to -1 to ignore and always use just CM (also applies to lma_strength - next)
public double [][] tiles_RBGA = null; public double [][] tiles_RBGA = null;
SuperTiles superTiles = null; SuperTiles superTiles = null;
...@@ -96,7 +97,14 @@ public class CLTPass3d{ ...@@ -96,7 +97,14 @@ public class CLTPass3d{
} }
} }
public int getClustRadius() {
return clust_radius;
}
public void setClustRadius (int clust_radius) {
this.clust_radius = clust_radius;
}
public TileProcessor getTileProcessor() public TileProcessor getTileProcessor()
{ {
return this.tileProcessor; return this.tileProcessor;
...@@ -606,32 +614,38 @@ public class CLTPass3d{ ...@@ -606,32 +614,38 @@ public class CLTPass3d{
return calc_disparity_combo; return calc_disparity_combo;
} }
} }
public double [] getDisparityLMA() {
if (calc_disparity == null) conditionDisparity(); // sets has_lma;
double [] disparityLMA = calc_disparity.clone();
for (int i = 0; i < disparityLMA.length; i++) {
if (!has_lma[i]) {
disparityLMA[i] = Double.NaN;
}
}
return disparityLMA;
}
// methods to "condition" measured disparity values // methods to "condition" measured disparity values
public void conditionDisparity() public void conditionDisparity()
{ {
/*
conditionDisparity(disparity_index);
}
public void conditionDisparity(int disparity_index) // only called from above
{
*/
int tilesX = tileProcessor.getTilesX(); int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY(); int tilesY = tileProcessor.getTilesY();
double corr_magic_scale = tileProcessor.getMagicScale(); double corr_magic_scale = tileProcessor.getMagicScale();
double corr_magic_scale_LMA = 1.0; double corr_magic_scale_LMA = 1.0;
// int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY;
// this.disparity_index = disparity_index;
calc_disparity = new double[tilesY*tilesX]; calc_disparity = new double[tilesY*tilesX];
calc_disparity_hor = new double[tilesY*tilesX]; calc_disparity_hor = new double[tilesY*tilesX];
calc_disparity_vert = new double[tilesY*tilesX]; calc_disparity_vert = new double[tilesY*tilesX];
double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null; double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null;
double [] lma_strength = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index+1] : null;
has_lma = (lma_disparity != null) ? new boolean[tilesX * tilesY] : null;
for (int i = 0; i < tilesY; i++){ for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){ for (int j = 0; j < tilesX; j++){
int indx = i * tilesX + j; int indx = i * tilesX + j;
if ((lma_disparity != null) && !Double.isNaN(lma_disparity[indx])) { if ((lma_disparity != null) && !Double.isNaN(lma_disparity[indx]) && (lma_strength[indx] > 0.0)) {
calc_disparity[indx] = lma_disparity[indx]/corr_magic_scale_LMA + this.disparity[i][j]; calc_disparity[indx] = lma_disparity[indx]/corr_magic_scale_LMA + this.disparity[i][j];
has_lma[indx] = true;
} else { } else {
calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j]; calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j];
} }
...@@ -654,10 +668,11 @@ public class CLTPass3d{ ...@@ -654,10 +668,11 @@ public class CLTPass3d{
int tilesX = tileProcessor.getTilesX(); int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY(); int tilesY = tileProcessor.getTilesY();
double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null; double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null;
double [] lma_strength = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index+1] : null;
boolean [] lma_defined = new boolean[tilesX * tilesY]; boolean [] lma_defined = new boolean[tilesX * tilesY];
if (lma_disparity != null) { if (lma_disparity != null) {
for (int i = 0; i < lma_disparity.length; i++) { for (int i = 0; i < lma_disparity.length; i++) {
lma_defined[i] = !Double.isNaN(lma_disparity[i]); lma_defined[i] = !Double.isNaN(lma_disparity[i]) && (lma_strength[i] > 0);
} }
} }
return lma_defined; return lma_defined;
......
...@@ -2439,7 +2439,7 @@ public class ExtrinsicAdjustment { ...@@ -2439,7 +2439,7 @@ public class ExtrinsicAdjustment {
this.last_ymfx); // modifies this.last_ymfx (weights and subtracts fx) this.last_ymfx); // modifies this.last_ymfx (weights and subtracts fx)
this.initial_rms = this.last_rms.clone(); this.initial_rms = this.last_rms.clone();
this.good_or_bad_rms = this.last_rms.clone(); this.good_or_bad_rms = this.last_rms.clone();
if (debug_level > -1) { if (debug_level > 1) {
showDerivatives(0); showDerivatives(0);
showDerivatives(1); showDerivatives(1);
showDerivatives(2); showDerivatives(2);
......
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