Commit fec6933a authored by Andrey Filippov's avatar Andrey Filippov

DSI filtering with intrascene correlations

parent a2860c84
......@@ -142,10 +142,12 @@ public class EyesisCorrectionParameters {
public int rig_batch_adjust_aux = 0;
public int rig_batch_adjust_rig = 0;
public int rig_batch_adjust_main_gt = 0; // adjust main camera using rig disparity as ground truth
public int rig_batch_adjust_aux_gt = 0; // adjust aux camera using rig disparity as ground truth (TODO: finish geometry in derivatives)
public int rig_batch_adjust_rig_gt = 0; // adjust rig after main and aux are adjusted with rig GT (late rig adjustment)
public boolean clt_batch_dsi1 = true; // experimental for interscene
public boolean clt_batch_apply_man = false; // Apply (and disable) manual pixel shift
public boolean clt_batch_extrinsic = false; // Calibrate extrinsic parameters for each set
public boolean clt_batch_poly = false; // Calculate fine polynomial correction for each set
......@@ -285,6 +287,7 @@ public class EyesisCorrectionParameters {
cp.rig_batch_adjust_aux_gt = this.rig_batch_adjust_aux_gt;
cp.rig_batch_adjust_rig_gt = this.rig_batch_adjust_rig_gt;
cp.clt_batch_dsi1= this.clt_batch_dsi1;
cp.clt_batch_apply_man= this.clt_batch_apply_man;
cp.clt_batch_extrinsic= this.clt_batch_extrinsic;
cp.clt_batch_poly= this.clt_batch_poly;
......@@ -463,6 +466,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"rig_batch_adjust_aux_gt", this.rig_batch_adjust_aux_gt+"");
properties.setProperty(prefix+"rig_batch_adjust_rig_gt", this.rig_batch_adjust_rig_gt+"");
properties.setProperty(prefix+"clt_batch_dsi1", this.clt_batch_dsi1+"");
properties.setProperty(prefix+"clt_batch_apply_man", this.clt_batch_apply_man+"");
properties.setProperty(prefix+"clt_batch_extrinsic", this.clt_batch_extrinsic+"");
properties.setProperty(prefix+"clt_batch_poly", this.clt_batch_poly+"");
......@@ -620,6 +624,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"rig_batch_adjust_aux_gt")!=null) this.rig_batch_adjust_aux_gt=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_aux_gt"));
if (properties.getProperty(prefix+"rig_batch_adjust_rig_gt")!=null) this.rig_batch_adjust_rig_gt=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_rig_gt"));
if (properties.getProperty(prefix+"clt_batch_dsi1")!= null) this.clt_batch_dsi1=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi1"));
if (properties.getProperty(prefix+"clt_batch_apply_man")!= null) this.clt_batch_apply_man=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_apply_man"));
if (properties.getProperty(prefix+"clt_batch_extrinsic")!= null) this.clt_batch_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_extrinsic"));
if (properties.getProperty(prefix+"clt_batch_poly")!= null) this.clt_batch_poly=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_poly"));
......@@ -991,6 +996,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Repeat aux camera field adjustment (late, with GT disparity from rig)", this.rig_batch_adjust_aux_gt, 0);
gd.addNumericField("Repeat 2-quad camera rig field adjustment (late, after all others)", this.rig_batch_adjust_rig_gt, 0);
gd.addCheckbox ("Experimental DSI", this.clt_batch_dsi1); // 21
gd.addCheckbox ("Apply (and disable) manual pixel shift", this.clt_batch_apply_man); // 21
gd.addCheckbox ("Calibrate extrinsic parameters for each set", this.clt_batch_extrinsic); // 22
gd.addCheckbox ("Calculate fine polynomial correction for each set", this.clt_batch_poly); // 23
......@@ -1083,6 +1089,7 @@ public class EyesisCorrectionParameters {
this.rig_batch_adjust_aux_gt = (int) gd.getNextNumber();
this.rig_batch_adjust_rig_gt = (int) gd.getNextNumber();
this.clt_batch_dsi1= gd.getNextBoolean(); // 21
this.clt_batch_apply_man= gd.getNextBoolean(); // 21
this.clt_batch_extrinsic= gd.getNextBoolean(); // 22
this.clt_batch_poly= gd.getNextBoolean(); // 23
......
......@@ -24,6 +24,9 @@
package com.elphel.imagej.tileprocessor;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.commons.math3.complex.Quaternion;
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
......@@ -43,6 +46,51 @@ public class ErsCorrection extends GeometryCorrection {
Quaternion[] ers_quaternion_dt; // per scan line
double [][] ers_atr; // azimuth-tilt-roll per scan line
double [][] ers_atr_dt; // angular velocities per scan line
/**
* Position+orientation (world XYZ, Azimuth, Tilt, Roll) of other scenes relative to the position of this camera.
* Positions/orientations are sampled during scanning of the center line
*/
HashMap <String, XyzAtr> scenes_poses = null;
public class XyzAtr {
double [] xyz;
double [] atr;
public XyzAtr() {
xyz = new double[3];
atr = new double[3];
}
public XyzAtr(String s) {
ArrayList<Double> lxyzatr = new ArrayList<Double>();
for (String snumber : s.split(","))
lxyzatr.add(Double.parseDouble(snumber));
Double [] xyzatr = new Double[6];
xyzatr = lxyzatr.toArray(xyzatr);
xyz = new double [] {xyzatr[0],xyzatr[1],xyzatr[2]};
atr = new double [] {xyzatr[3],xyzatr[4],xyzatr[5]};
}
public String toString() {
return String.format("%f, %f, %f, %f, %f, %f",xyz[0],xyz[1],xyz[2],atr[0],atr[1],atr[2]);
}
public double [] getXYZ() {
return xyz;
}
public double [] getATR() {
return atr;
}
public void setXYZ(double [] d) {
xyz[0] = d[0];
xyz[1] = d[1];
xyz[2] = d[2];
}
public void setATR(double [] d) {
atr[0] = d[0];
atr[1] = d[1];
atr[2] = d[2];
}
}
public ErsCorrection(GeometryCorrection gc) {
debugLevel = gc.debugLevel;
line_time = gc.line_time; // 26.5E-6; // duration of sensor scan line (for ERS)
......
......@@ -3483,7 +3483,7 @@ ImageDtt.startAndJoin(threads);
if (scan.isProcessed()) titles[nscan] += "+P"; else titles[nscan]+="-P";
if (scan.isCombo()) titles[nscan] += "+C"; else titles[nscan]+="-C";
if (scan.getTextureTiles()!=null) titles[nscan] += "+T"; else titles[nscan]+="-T";
dbg_img[nscan] = getShowScan(scan)[slice];
dbg_img[nscan] = getShowScan(scan, false)[slice];
if (dbg_img[nscan] != null) num_slices++;
}
}
......@@ -3502,10 +3502,21 @@ ImageDtt.startAndJoin(threads);
return ds_only ? SCAN_TITLES_DS : SCAN_TITLES;
}
public void showScan(
CLTPass3d scan,
String in_title)
{
showScan(
scan,
in_title,
false);
}
public void showScan(
CLTPass3d scan,
String in_title,
boolean measured_only)
{
String [] titles = getScanTitles();
String title=in_title;
......@@ -3514,7 +3525,7 @@ ImageDtt.startAndJoin(threads);
if (scan.isCombo()) title+="+C"; else title+="-C";
if (scan.getTextureTiles()!=null) title+="+T"; else title+="-T";
double [][] dbg_img = getShowScan(scan);
double [][] dbg_img = getShowScan(scan, measured_only);
(new ShowDoubleFloatArrays()).showArrays(
dbg_img,
tilesX,
......@@ -3646,7 +3657,7 @@ ImageDtt.startAndJoin(threads);
CLTPass3d scan,
boolean force_final)
{
double [][] dbg_img = getShowScan(scan);
double [][] dbg_img = getShowScan(scan, false);
double [][] ds = new double [2][];
if (!force_final && (dbg_img[2] != null)) {
ds[0] = dbg_img[2]; // disparity
......@@ -3662,7 +3673,8 @@ ImageDtt.startAndJoin(threads);
}
public double [][] getShowScan(
CLTPass3d scan)
CLTPass3d scan,
boolean measured_only)
{
int NUM_SLICES=getScanTitles().length;
int this_IMG_TONE_RGB = 21;
......@@ -3682,6 +3694,8 @@ ImageDtt.startAndJoin(threads);
// boolean [] ly_force = scan.getLazyEyeForceDisparity();
int tlen = tilesX*tilesY;
if (scan.tile_op == null) measured_only = false;
boolean [] measured = new boolean [tlen];
double [][] dbg_img = new double[NUM_SLICES][];
if (scan.tile_op != null) dbg_img[ 0] = new double[tlen];
if (scan.disparity != null) dbg_img[ 2] = new double[tlen];
......@@ -3693,7 +3707,10 @@ ImageDtt.startAndJoin(threads);
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx < tilesX; tx++){
int nt = ty*tilesX + tx;
if (scan.tile_op != null) dbg_img[ 0][nt] = scan.tile_op[ty][tx];
if (scan.tile_op != null) {
dbg_img[ 0][nt] = scan.tile_op[ty][tx];
measured[nt] = scan.tile_op[ty][tx] > 0;
}
if (scan.disparity != null) dbg_img[ 2][nt] = scan.disparity[ty][tx];
if (scan.selected != null) dbg_img[10][nt] = scan.selected[nt]? 1.0:0.0;
if (scan.border_tiles != null) dbg_img[11][nt] = scan.border_tiles[nt]? 1.0:0.0;
......@@ -3751,6 +3768,14 @@ ImageDtt.startAndJoin(threads);
}
}
}
if (measured_only) {
for (int n = 0; n < dbg_img.length; n++) if (dbg_img[n] != null) {
dbg_img[n] = dbg_img[n].clone(); // prevent modifications of the original data !
for (int i = 0; i < tlen; i++) if (!measured[i]){
dbg_img[n][i] = Double.NaN;
}
}
}
return dbg_img;
}
......
......@@ -8346,6 +8346,46 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main.tp.resetCLTPasses();
if (!ok) break;
}
if (quadCLT_main.correctionsParameters.clt_batch_dsi1){
System.out.println("Trying experimental features DSI/ERS");
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"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
double [][] dsi_ly = quadCLT_main.filterByLY(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.ly_inf_min_narrow, // double inf_min,
clt_parameters.ly_inf_max_narrow, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
dsi[DSI_DISPARITY_MAIN] = dsi_ly[0];
dsi[DSI_STRENGTH_MAIN] = dsi_ly[1];
// if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
saveDSIMain ();
// }
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
// copy regardless of ML generation
// See if it will copy all files, not just the main camera ones
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
}
}
// Generate 4 main camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img){
if (clt_parameters.gpu_use_main) {
......
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