Commit 37f405a5 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Implemented MPO export for EO/LWIR dual-quad rig

parent 26cdc535
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ public class EyesisCorrectionParameters {
  		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
  		public boolean clt_batch_4img =       true;  // Create a set of 4 images, usually for disparity = 0
  		public boolean clt_batch_4img_aux =   true;  // Create a set of 4 images, usually for disparity = 0 for AUX camera
  		public boolean clt_batch_explore =    true;  // 1-st step of 3d reconstruction - explore disparities for each tile
  		public boolean clt_batch_surf =       true;  // Create super-tile 2.5d surfaces
  		public boolean clt_batch_assign =     true;  // Assign tiles to surfaces
@@ -286,6 +287,7 @@ public class EyesisCorrectionParameters {
  			cp.clt_batch_extrinsic=		this.clt_batch_extrinsic;
  			cp.clt_batch_poly=    		this.clt_batch_poly;
  			cp.clt_batch_4img=    		this.clt_batch_4img;
  			cp.clt_batch_4img_aux=      this.clt_batch_4img_aux;
  			cp.clt_batch_explore=       this.clt_batch_explore;
  			cp.clt_batch_surf=    		this.clt_batch_surf;
  			cp.clt_batch_assign=    	this.clt_batch_assign;
@@ -461,6 +463,7 @@ public class EyesisCorrectionParameters {
    		properties.setProperty(prefix+"clt_batch_extrinsic",   this.clt_batch_extrinsic+"");
    		properties.setProperty(prefix+"clt_batch_poly",        this.clt_batch_poly+"");
    		properties.setProperty(prefix+"clt_batch_4img",        this.clt_batch_4img+"");
    		properties.setProperty(prefix+"clt_batch_4img_aux",    this.clt_batch_4img_aux+"");
    		properties.setProperty(prefix+"clt_batch_explore",     this.clt_batch_explore+"");
    		properties.setProperty(prefix+"clt_batch_surf",        this.clt_batch_surf+"");
    		properties.setProperty(prefix+"clt_batch_assign",      this.clt_batch_assign+"");
@@ -616,6 +619,7 @@ public class EyesisCorrectionParameters {
			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"));
			if (properties.getProperty(prefix+"clt_batch_4img")!= null)      this.clt_batch_4img=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_4img"));
			if (properties.getProperty(prefix+"clt_batch_4img_aux")!= null)  this.clt_batch_4img_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_4img_aux"));
			if (properties.getProperty(prefix+"clt_batch_explore")!= null)   this.clt_batch_explore=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_explore"));
			if (properties.getProperty(prefix+"clt_batch_surf")!= null)      this.clt_batch_surf=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_surf"));
			if (properties.getProperty(prefix+"clt_batch_assign")!= null)    this.clt_batch_assign=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_assign"));
@@ -983,6 +987,7 @@ public class EyesisCorrectionParameters {
    		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
    		gd.addCheckbox    ("Create a set of 4 images, usually for disparity = 0",                this.clt_batch_4img);      // 24
    		gd.addCheckbox    ("Create a set of 4 images for AUX (LWIR) camera",                     this.clt_batch_4img_aux);      // 24
    		gd.addCheckbox    ("1-st step of 3d reconstruction - explore disparities for each tile", this.clt_batch_explore);   // 25
    		gd.addCheckbox    ("Create super-tile 2.5d surfaces",                                    this.clt_batch_surf);      // 26
    		gd.addCheckbox    ("Assign tiles to surfaces",                                           this.clt_batch_assign);    // 27
@@ -993,8 +998,9 @@ public class EyesisCorrectionParameters {

    		gd.addCheckbox    ("Create DSI combo image",                                             this.clt_batch_dsi,
    				"Save main camera, dual-quad rig and optionally aux camera combo DSI image with the model");
    		gd.addCheckbox    ("Include aux camera DSI data in the combo DSI",                       this.clt_batch_dsi_aux,
    				"Currently DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time");
    		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."+
    		" EO+LWIR - generate a separate GT+AUX file");
    		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");
    		gd.addCheckbox    ("Save all parameters with the model",                                 this.clt_batch_save_all,
@@ -1073,6 +1079,7 @@ public class EyesisCorrectionParameters {
    		this.clt_batch_extrinsic=    gd.getNextBoolean(); // 22
    		this.clt_batch_poly=         gd.getNextBoolean(); // 23
    		this.clt_batch_4img=         gd.getNextBoolean(); // 24
    		this.clt_batch_4img_aux=     gd.getNextBoolean(); // 24
    		this.clt_batch_explore=      gd.getNextBoolean(); // 25
    		this.clt_batch_surf=         gd.getNextBoolean(); // 26
    		this.clt_batch_assign=       gd.getNextBoolean(); // 27
+4 −4
Original line number Diff line number Diff line
@@ -5231,16 +5231,16 @@ private Panel panel1,
				ds[l][i] = f_ds[l][i];
			}
		}
		String [] titles = {"disparity","strength"};
		(new ShowDoubleFloatArrays()) .showArrays(ds,  width, height, true, title, titles);
		String [] rslt_titles = split_fg_bg ? QuadCLT.FGBG_TITLES_AUX  :QuadCLT.FGBG_TITLES_ADJ; // last 2 will be 0;

		(new ShowDoubleFloatArrays()) .showArrays(ds,  width, height, true, title, QuadCLT.FGBG_TITLES_ADJ);

		int tile_size =  CLT_PARAMETERS.transform_size;
		int [] wh_aux =  QUAD_CLT_AUX.getGeometryCorrection().getSensorWH();
		int tilesX_aux = wh_aux[0] / tile_size;
		int tilesY_aux = wh_aux[1] / tile_size;

//		int num_slices = split_fg_bg? 7:2;
		String [] fgbg_titles = {"disparity","strength", "rms","rms-split","fg-disp","fg-str","bg-disp","bg-str"};
		String [] rslt_titles = split_fg_bg ? fgbg_titles  :titles;

		double [][] ds_aux = QUAD_CLT_AUX.depthMapMainToAux(
				ds, // double [][] ds,
+6 −6
Original line number Diff line number Diff line
@@ -2202,18 +2202,18 @@ B = |+dy0 -dy1 -2*dy3 |
			int [] pq = per_quad.clone();
			Arrays.sort(per_quad);
			if (debugLevel > -20) {
				System.out.print(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
				System.out.println(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
			}
			if (per_quad[1] < min_per_quadrant) {
				if (debugLevel > -20) {
					System.out.print(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
					System.out.println(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
				}
				return null;
			}

			if (num_inf < min_inf) {
				if (debugLevel > -20) {
					System.out.print(String.format("Too few tiles at infinity: %d minimum is %d", num_inf, min_inf));
					System.out.println(String.format("Too few tiles at infinity: %d minimum is %d", num_inf, min_inf));
				}
				return null;
			}
@@ -2810,19 +2810,19 @@ B = |+dy0 -dy1 -2*dy3 |
		Arrays.sort(per_quad);
		if (per_quad[1] < min_per_quadrant) {
			if (debugLevel > -20) {
				System.out.print(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
				System.out.println(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
			}
			return null;
		}

		if (num_inf < min_inf) {
			if (debugLevel > -20) {
				System.out.print(String.format("Too few tiles at infinity (<%4f): %d minimum is %d", inf_max_disparity, num_inf, min_inf));
				System.out.println(String.format("Too few tiles at infinity (<%4f): %d minimum is %d", inf_max_disparity, num_inf, min_inf));
			}
			return null;
		}
		if (debugLevel > -20) {
			System.out.print(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
			System.out.println(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
		}

		double inf_fraction_limited =  (inf_fraction >= 0.0) ?((inf_fraction > 1.0) ? 1.0 : inf_fraction):0.0;
+61 −2
Original line number Diff line number Diff line
@@ -251,6 +251,8 @@ public class BiQuadParameters {
	public boolean ml_copyJP4 =                true;   // Copy source jp4 files when running "Ground truth" command

	public int     ml_hwidth =                 4;      // Half-width of the ML tiles to export (0-> 1x1, 1->3x3, 2 -> 5x5)

// For dual-quad rig mode
	public double  ml_disparity_sweep  =       2.0;    // Disparity sweep around ground truth, each side
	public int     ml_sweep_steps =            1;      // Number of disparity sweep steps

@@ -268,6 +270,15 @@ public class BiQuadParameters {
	public boolean ml_main_rnd =               true;    // generate ML from main camera DSI with random offset
	public boolean ml_rig_rnd =                true;    // generate ML from rig DSI (GT) with random offset

// for EO+LWIR mode
	public boolean ml_aux_ag =                 true;    // aux (lwir) mode - generate 2dcorr for GT (average disparity)
	public boolean ml_aux_fg =                 true;    // aux (lwir) mode - generate 2dcorr for GT (foreground disparity)
	public boolean ml_aux_bg =                 true;    // aux (lwir) mode - generate 2dcorr for GT (background disparity)
	public double  ml_aux_low =                 0.0;    // aux (lwir) mode - disparity sweep low
	public double  ml_aux_high =               10.0;    // aux (lwir) mode - disparity sweep high
	public double  ml_aux_step =                0.1;    // aux (lwir) mode - disparity sweep step( >= 0 - no sweep)

// common
	public boolean ml_keep_aux =               false; // true; // include auxiliary camera data in the ML output
	public boolean ml_keep_inter =             false; // true; // include inter-camera correlation data in the ML output
	public boolean ml_keep_hor_vert =          true; // include combined horizontal and vertical pairs data in the ML output
@@ -678,7 +689,7 @@ public class BiQuadParameters {
		gd.addCheckbox    ("Randomize offset",                                                                    this.ml_randomize,
				"Each tile will have individual offset, but it the range between the filename and next higher. Reduces sweep steps by 1");

		gd.addMessage("Enhancing main camera dsi for generation of the ml files");
		gd.addMessage("Enhancing main camera dsi for generation of the ml files (dual quad rig mode");

		gd.addNumericField("Max disparity difference between rig and main camera",                                this.ml_rig_tolerance,  3,6,"",
				"Replace main camera disparity if it differs from rig by more than this");
@@ -693,6 +704,7 @@ public class BiQuadParameters {
		gd.addNumericField("Extrapolated tile strength",                                                          this.ml_new_strength,  3,6,"",
				"Assign this fraction of average neighbors strength strength to the tiles where strength is unknown (expanded tiles with extrapolated target)");

		gd.addMessage("Dual-quad rig mode (8 identical cameras)");

		gd.addCheckbox    ("Generate ML 2d correlations from main camera DSI",                                    this.ml_main,
				"Target disparity/convergence extracted from the main camera DSI, filtered and expanded");
@@ -701,6 +713,25 @@ public class BiQuadParameters {
		gd.addCheckbox    ("Generate ML from rig DSI (GT) with random offset",                                    this.ml_rig_rnd,
				"Main camera data is not used, offset is just random from the rig (ground truth)");

		gd.addMessage("AUX mode (4×EO + 4×LWIR, different resolution)");

		gd.addCheckbox    ("Generate 2D correlation for GT (average disparity)",                                  this.ml_aux_ag,
				"Generate 2D correlation using tile weighted average disparity as target disparity");
		gd.addCheckbox    ("Generate 2D correlation for GT (foreground disparity)",                               this.ml_aux_fg,
				"Generate 2D correlation using tile weighted foreground average disparity as target disparity");
		gd.addCheckbox    ("Generate 2D correlation for GT (background disparity)",                               this.ml_aux_bg,
				"Generate 2D correlation using tile weighted background average disparity as target disparity");

		gd.addNumericField("AUX (LWIR) camera disparity sweep low (start)",                                       this.ml_aux_low,  3,6,"",
				"Perform disparity sweep for AUX (LWIR) camera, starting with this disparity");
		gd.addNumericField("AUX (LWIR) camera disparity sweep high (end)",                                        this.ml_aux_high,  3,6,"",
				"Perform disparity sweep for AUX (LWIR) camera, up to (inclusive) this disparity");
		gd.addNumericField("AUX (LWIR) camera disparity sweep step (<=0 - no sweep generation)",                  this.ml_aux_step,  3,6,"",
				"Perform disparity sweep for AUX (LWIR) camera with this disparity step. Values <=0.0 disable sweep.");

		gd.addMessage("Common ML generation parameters");


		gd.addCheckbox    ("Include auxiliary camera data in the ML output",                                      this.ml_keep_aux,
				"ML output will have the second set of the layers for the auxiliary camera. Disparity values should be scaled for the camera baseline");
		gd.addCheckbox    ("Keep inter-camera correlation data",                                                  this.ml_keep_inter,
@@ -932,6 +963,13 @@ public class BiQuadParameters {
		this.ml_main_rnd=                   gd.getNextBoolean();
		this.ml_rig_rnd=                    gd.getNextBoolean();

		this.ml_aux_ag=                     gd.getNextBoolean();
		this.ml_aux_fg=                     gd.getNextBoolean();
		this.ml_aux_bg=                     gd.getNextBoolean();
		this.ml_aux_low=                    gd.getNextNumber();
		this.ml_aux_high=                   gd.getNextNumber();
		this.ml_aux_step=                   gd.getNextNumber();

		this.ml_keep_aux=                   gd.getNextBoolean();
		this.ml_keep_inter=                 gd.getNextBoolean();
		this.ml_keep_tbrl=                  gd.getNextBoolean();
@@ -1155,6 +1193,13 @@ public class BiQuadParameters {
		properties.setProperty(prefix+"ml_main_rnd",               this.ml_main_rnd+"");
		properties.setProperty(prefix+"ml_rig_rnd",                this.ml_rig_rnd+"");

		properties.setProperty(prefix+"ml_aux_ag",                 this.ml_aux_ag+"");
		properties.setProperty(prefix+"ml_aux_fg",                 this.ml_aux_fg+"");
		properties.setProperty(prefix+"ml_aux_bg",                 this.ml_aux_bg+"");
		properties.setProperty(prefix+"ml_aux_low",                this.ml_aux_low+"");
		properties.setProperty(prefix+"ml_aux_high",               this.ml_aux_high+"");
		properties.setProperty(prefix+"ml_aux_step",               this.ml_aux_step+"");

		properties.setProperty(prefix+"ml_keep_aux",               this.ml_keep_aux+"");
		properties.setProperty(prefix+"ml_keep_inter",             this.ml_keep_inter+"");
		properties.setProperty(prefix+"ml_keep_tbrl",              this.ml_keep_tbrl+"");
@@ -1377,6 +1422,13 @@ public class BiQuadParameters {
		if (properties.getProperty(prefix+"ml_main_rnd")!=null)             this.ml_main_rnd=Boolean.parseBoolean(properties.getProperty(prefix+"ml_main_rnd"));
		if (properties.getProperty(prefix+"ml_rig_rnd")!=null)              this.ml_rig_rnd=Boolean.parseBoolean(properties.getProperty(prefix+"ml_rig_rnd"));

		if (properties.getProperty(prefix+"ml_aux_ag")!=null)              this.ml_aux_ag=Boolean.parseBoolean(properties.getProperty(prefix+"ml_aux_ag"));
		if (properties.getProperty(prefix+"ml_aux_fg")!=null)              this.ml_aux_fg=Boolean.parseBoolean(properties.getProperty(prefix+"ml_aux_fg"));
		if (properties.getProperty(prefix+"ml_aux_bg")!=null)              this.ml_aux_bg=Boolean.parseBoolean(properties.getProperty(prefix+"ml_aux_bg"));
		if (properties.getProperty(prefix+"ml_aux_low")!=null)             this.ml_aux_low=Double.parseDouble(properties.getProperty(prefix+"ml_aux_low"));
		if (properties.getProperty(prefix+"ml_aux_high")!=null)            this.ml_aux_high=Double.parseDouble(properties.getProperty(prefix+"ml_aux_high"));
		if (properties.getProperty(prefix+"ml_aux_step")!=null)            this.ml_aux_step=Double.parseDouble(properties.getProperty(prefix+"ml_aux_step"));

		if (properties.getProperty(prefix+"ml_keep_aux")!=null)             this.ml_keep_aux=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_aux"));
		if (properties.getProperty(prefix+"ml_keep_inter")!=null)           this.ml_keep_inter=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_inter"));
		if (properties.getProperty(prefix+"ml_keep_tbrl")!=null)            this.ml_keep_tbrl=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_tbrl"));
@@ -1590,6 +1642,13 @@ public class BiQuadParameters {
		bqp.ml_main_rnd =               this.ml_main_rnd;
		bqp.ml_rig_rnd =                this.ml_rig_rnd;

		bqp.ml_aux_ag =                 this.ml_aux_ag;
		bqp.ml_aux_fg =                 this.ml_aux_fg;
		bqp.ml_aux_bg =                 this.ml_aux_bg;
		bqp.ml_aux_low =                this.ml_aux_low;
		bqp.ml_aux_high =               this.ml_aux_high;
		bqp.ml_aux_step =               this.ml_aux_step;

		bqp.ml_keep_aux =               this.ml_keep_aux;
		bqp.ml_randomize =              this.ml_randomize;

+3 −3
Original line number Diff line number Diff line
@@ -289,7 +289,7 @@ public class Correlation2d {
    		    		tcorr[col],
    		    		fat_zero/scale_value);

    		 if (first_col < 0) {// accummulate all channels in frst non-null color ( 0 for color, 2 for mono?)
    		 if (first_col < 0) {// accummulate all channels in first non-null color ( 0 for color, 2 for mono?)
    			 first_col = col; // first non-empty color (2, green) or 0 for color images
    			 for (int n = 0; n < 4; n++) {
    				 for (int i = 0; i < transform_len; i++) {
@@ -1150,7 +1150,7 @@ public class Correlation2d {
    				double fc1 = full_corr[2 * ndir + 1][findx++]; // 1 - bottom, 3 (right)
    				double cc = 0.0;
    				if (offset >= 0.0) {
    					if ((fc0 > 0.0) && (fc1 > 0.0)) {
    					if ((fc0 > -offset) && (fc1 > -offset)) {
    						cc = Math.sqrt((fc0 + offset) * (fc1 + offset)) - offset;
    					}
    				} else {
Loading