Commit 508ee2cb authored by Andrey Filippov's avatar Andrey Filippov
Browse files

added new surface generation, working on resolving 'impossible triangle' conflicts

parent dfe9ae9d
Loading
Loading
Loading
Loading
+18 −6
Original line number Original line Diff line number Diff line
@@ -2171,7 +2171,8 @@ public class EyesisCorrectionParameters {
  		public double     plMaxEigen           =   0.3;  // Maximal eigenvalue of a plane 
  		public double     plMaxEigen           =   0.3;  // Maximal eigenvalue of a plane 
  		public boolean    plDbgMerge           =   true; // Combine 'other' plane with current
  		public boolean    plDbgMerge           =   true; // Combine 'other' plane with current
  		public double     plWorstWorsening     =   3.0;  // Worst case worsening after merge
  		public double     plWorstWorsening     =   3.0;  // Worst case worsening after merge
  		public double     plOKMergeEigen       =   0.01; // If result of the merged planes is below, OK to bypass worst worsening
  		public double     plOKMergeEigen       =   0.03; // If result of the merged planes is below, OK to bypass worst worsening
  		public double     plMaxWorldSin2       =   0.1;  // Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable
  		public double     plWeakWorsening      =   1.0;  // Relax merge requirements for weaker planes
  		public double     plWeakWorsening      =   1.0;  // Relax merge requirements for weaker planes
  		public boolean    plMutualOnly         =   true; // keep only mutual links, remove weakest if conflict
  		public boolean    plMutualOnly         =   true; // keep only mutual links, remove weakest if conflict
  		public boolean    plFillSquares        =   true; // Add diagonals to full squares
  		public boolean    plFillSquares        =   true; // Add diagonals to full squares
@@ -2217,12 +2218,13 @@ public class EyesisCorrectionParameters {
  		public double     msScaleProj          =   1.5;  // Scale projection of the plane ellipsoid 
  		public double     msScaleProj          =   1.5;  // Scale projection of the plane ellipsoid 
  		public double     msFractUni           =   0.3;  // Spread this fraction of the ellipsoid weight among extended (double) supertile
  		public double     msFractUni           =   0.3;  // Spread this fraction of the ellipsoid weight among extended (double) supertile
  		
  		
		public boolean    tsNoEdge             = true;   // Do not assigned tiles to thesurface edges (not having all 8 neighbors)
		public boolean    tsNoEdge             = true;   // Do not assign tiles to the surface edges (not having all 8 neighbors)
		public boolean    tsUseCenter          = true;   // Only assign outside of 8x8 center if no suitable alternative
  		public double     tsMaxDiff            = 0.3;    // Maximal disparity difference when assigning tiles
  		public double     tsMaxDiff            = 0.3;    // Maximal disparity difference when assigning tiles
		public double     tsMinDiffOther       = 0.35;   // Minimal disparity difference to be considered as a competitor surface
		public double     tsMinDiffOther       = 0.35;   // Minimal disparity difference to be considered as a competitor surface
		public double     tsMinStrength        = 0.05;   // Minimal tile correlation strength to be assigned
		public double     tsMinStrength        = 0.05;   // Minimal tile correlation strength to be assigned
		public double     tsMaxStrength        = 10.0;   // Maximal tile correlation strength to be assigned
		public double     tsMaxStrength        = 10.0;   // Maximal tile correlation strength to be assigned
		public double     tsMinSurface         = 0.0001; // Minimal surface strength at the tile location
		public double     tsMinSurface         = 0.001;  // Minimal surface strength at the tile location
		public int        tsMoveDirs           = 3;      // Allowed tile disparity correction: 1 increase, 2 - decrease, 3 - both directions
		public int        tsMoveDirs           = 3;      // Allowed tile disparity correction: 1 increase, 2 - decrease, 3 - both directions
		public double     tsSurfStrPow         = 0.0;    // Raise surface strengths ratio to this power when comparing candidates
		public double     tsSurfStrPow         = 0.0;    // Raise surface strengths ratio to this power when comparing candidates
		public double     tsAddStrength        = 0.01;   // Add to strengths when calculating pull of assigned tiles
		public double     tsAddStrength        = 0.01;   // Add to strengths when calculating pull of assigned tiles
@@ -2517,6 +2519,7 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"plDbgMerge",       this.plDbgMerge+"");
			properties.setProperty(prefix+"plDbgMerge",       this.plDbgMerge+"");
			properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
			properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
			properties.setProperty(prefix+"plOKMergeEigen",   this.plOKMergeEigen +"");
			properties.setProperty(prefix+"plOKMergeEigen",   this.plOKMergeEigen +"");
			properties.setProperty(prefix+"plMaxWorldSin2",   this.plMaxWorldSin2 +"");
			properties.setProperty(prefix+"plWeakWorsening",  this.plWeakWorsening +"");
			properties.setProperty(prefix+"plWeakWorsening",  this.plWeakWorsening +"");
			properties.setProperty(prefix+"plMutualOnly",     this.plMutualOnly+"");
			properties.setProperty(prefix+"plMutualOnly",     this.plMutualOnly+"");
			properties.setProperty(prefix+"plFillSquares",    this.plFillSquares+"");
			properties.setProperty(prefix+"plFillSquares",    this.plFillSquares+"");
@@ -2557,6 +2560,7 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"msFractUni",       this.msFractUni +"");
			properties.setProperty(prefix+"msFractUni",       this.msFractUni +"");


			properties.setProperty(prefix+"tsNoEdge",         this.tsNoEdge+"");
			properties.setProperty(prefix+"tsNoEdge",         this.tsNoEdge+"");
			properties.setProperty(prefix+"tsUseCenter",      this.tsUseCenter+"");
			properties.setProperty(prefix+"tsMaxDiff",        this.tsMaxDiff +"");
			properties.setProperty(prefix+"tsMaxDiff",        this.tsMaxDiff +"");
			properties.setProperty(prefix+"tsMinDiffOther",   this.tsMinDiffOther +"");
			properties.setProperty(prefix+"tsMinDiffOther",   this.tsMinDiffOther +"");
			properties.setProperty(prefix+"tsMinStrength",    this.tsMinStrength +"");
			properties.setProperty(prefix+"tsMinStrength",    this.tsMinStrength +"");
@@ -2842,6 +2846,7 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"plDbgMerge")!=null)        this.plDbgMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plDbgMerge"));
  			if (properties.getProperty(prefix+"plDbgMerge")!=null)        this.plDbgMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plDbgMerge"));
  			if (properties.getProperty(prefix+"plWorstWorsening")!=null)  this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening"));
  			if (properties.getProperty(prefix+"plWorstWorsening")!=null)  this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening"));
  			if (properties.getProperty(prefix+"plOKMergeEigen")!=null)    this.plOKMergeEigen=Double.parseDouble(properties.getProperty(prefix+"plOKMergeEigen"));
  			if (properties.getProperty(prefix+"plOKMergeEigen")!=null)    this.plOKMergeEigen=Double.parseDouble(properties.getProperty(prefix+"plOKMergeEigen"));
  			if (properties.getProperty(prefix+"plMaxWorldSin2")!=null)    this.plMaxWorldSin2=Double.parseDouble(properties.getProperty(prefix+"plMaxWorldSin2"));
  			if (properties.getProperty(prefix+"plWeakWorsening")!=null)   this.plWeakWorsening=Double.parseDouble(properties.getProperty(prefix+"plWeakWorsening"));
  			if (properties.getProperty(prefix+"plWeakWorsening")!=null)   this.plWeakWorsening=Double.parseDouble(properties.getProperty(prefix+"plWeakWorsening"));
  			if (properties.getProperty(prefix+"plMutualOnly")!=null)      this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));
  			if (properties.getProperty(prefix+"plMutualOnly")!=null)      this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));


@@ -2885,6 +2890,7 @@ public class EyesisCorrectionParameters {




  			if (properties.getProperty(prefix+"tsNoEdge")!=null)          this.tsNoEdge=Boolean.parseBoolean(properties.getProperty(prefix+"tsNoEdge"));
  			if (properties.getProperty(prefix+"tsNoEdge")!=null)          this.tsNoEdge=Boolean.parseBoolean(properties.getProperty(prefix+"tsNoEdge"));
  			if (properties.getProperty(prefix+"tsUseCenter")!=null)       this.tsUseCenter=Boolean.parseBoolean(properties.getProperty(prefix+"tsUseCenter"));
  			if (properties.getProperty(prefix+"tsMaxDiff")!=null)         this.tsMaxDiff=Double.parseDouble(properties.getProperty(prefix+"tsMaxDiff"));
  			if (properties.getProperty(prefix+"tsMaxDiff")!=null)         this.tsMaxDiff=Double.parseDouble(properties.getProperty(prefix+"tsMaxDiff"));
  			if (properties.getProperty(prefix+"tsMinDiffOther")!=null)    this.tsMinDiffOther=Double.parseDouble(properties.getProperty(prefix+"tsMinDiffOther"));
  			if (properties.getProperty(prefix+"tsMinDiffOther")!=null)    this.tsMinDiffOther=Double.parseDouble(properties.getProperty(prefix+"tsMinDiffOther"));
  			if (properties.getProperty(prefix+"tsMinStrength")!=null)     this.tsMinStrength=Double.parseDouble(properties.getProperty(prefix+"tsMinStrength"));
  			if (properties.getProperty(prefix+"tsMinStrength")!=null)     this.tsMinStrength=Double.parseDouble(properties.getProperty(prefix+"tsMinStrength"));
@@ -3196,6 +3202,7 @@ public class EyesisCorrectionParameters {
  			gd.addCheckbox    ("Combine 'other' plane with the current (unused)",                              this.plDbgMerge);
  			gd.addCheckbox    ("Combine 'other' plane with the current (unused)",                              this.plDbgMerge);
  			gd.addNumericField("Worst case worsening after merge",                                             this.plWorstWorsening,  6);
  			gd.addNumericField("Worst case worsening after merge",                                             this.plWorstWorsening,  6);
  			gd.addNumericField("If result of the merged planes is below, OK to bypass worst worsening",        this.plOKMergeEigen,  6);
  			gd.addNumericField("If result of the merged planes is below, OK to bypass worst worsening",        this.plOKMergeEigen,  6);
  			gd.addNumericField("Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable", this.plMaxWorldSin2,  6);
  			gd.addNumericField("Relax merge requirements for weaker planes",                                   this.plWeakWorsening,  6);
  			gd.addNumericField("Relax merge requirements for weaker planes",                                   this.plWeakWorsening,  6);
  			gd.addCheckbox    ("Keep only mutual links, remove weakest if conflict",                           this.plMutualOnly);
  			gd.addCheckbox    ("Keep only mutual links, remove weakest if conflict",                           this.plMutualOnly);


@@ -3240,7 +3247,8 @@ public class EyesisCorrectionParameters {


  			gd.addMessage     ("--- Tiles assignment ---");
  			gd.addMessage     ("--- Tiles assignment ---");
  			 
  			 
  			gd.addCheckbox    ("Do not assigned tiles to the surface edges (not having all 8 neighbors)",         this.tsNoEdge);
  			gd.addCheckbox    ("Do not assign tiles to the surface edges (not having all 8 neighbors)",           this.tsNoEdge);
  			gd.addCheckbox    ("Only assign outside of 8x8 center if no suitable alternative",                    this.tsUseCenter);
  			gd.addNumericField("Maximal disparity difference when assigning tiles",                               this.tsMaxDiff,  6);
  			gd.addNumericField("Maximal disparity difference when assigning tiles",                               this.tsMaxDiff,  6);
  			gd.addNumericField("Minimal disparity difference to be considered as a competitor surface",           this.tsMinDiffOther,  6);
  			gd.addNumericField("Minimal disparity difference to be considered as a competitor surface",           this.tsMinDiffOther,  6);
  			gd.addNumericField("Minimal tile correlation strength to be assigned",                                this.tsMinStrength,  6);
  			gd.addNumericField("Minimal tile correlation strength to be assigned",                                this.tsMinStrength,  6);
@@ -3534,6 +3542,7 @@ public class EyesisCorrectionParameters {
  			this.plDbgMerge=            gd.getNextBoolean();
  			this.plDbgMerge=            gd.getNextBoolean();
  			this.plWorstWorsening=      gd.getNextNumber();
  			this.plWorstWorsening=      gd.getNextNumber();
  			this.plOKMergeEigen=        gd.getNextNumber();
  			this.plOKMergeEigen=        gd.getNextNumber();
  			this.plMaxWorldSin2=        gd.getNextNumber();
  			this.plWeakWorsening=       gd.getNextNumber();
  			this.plWeakWorsening=       gd.getNextNumber();
  			this.plMutualOnly=          gd.getNextBoolean();
  			this.plMutualOnly=          gd.getNextBoolean();


@@ -3576,6 +3585,7 @@ public class EyesisCorrectionParameters {
  			this.msFractUni=            gd.getNextNumber();
  			this.msFractUni=            gd.getNextNumber();


  			this.tsNoEdge=              gd.getNextBoolean();
  			this.tsNoEdge=              gd.getNextBoolean();
  			this.tsUseCenter=           gd.getNextBoolean();
  			this.tsMaxDiff=             gd.getNextNumber();
  			this.tsMaxDiff=             gd.getNextNumber();
  			this.tsMinDiffOther=        gd.getNextNumber();
  			this.tsMinDiffOther=        gd.getNextNumber();
  			this.tsMinStrength=         gd.getNextNumber();
  			this.tsMinStrength=         gd.getNextNumber();
@@ -3626,7 +3636,8 @@ public class EyesisCorrectionParameters {
  		
  		
  		public boolean showTsDialog() {
  		public boolean showTsDialog() {
  			GenericDialog gd = new GenericDialog("Set CLT tiles to surfaces assignment parameters");
  			GenericDialog gd = new GenericDialog("Set CLT tiles to surfaces assignment parameters");
  			gd.addCheckbox    ("Do not assigned tiles to the surface edges (not having all 8 neighbors)",         this.tsNoEdge);
  			gd.addCheckbox    ("Do not assign tiles to the surface edges (not having all 8 neighbors)",           this.tsNoEdge);
  			gd.addCheckbox    ("Only assign outside of 8x8 center if no suitable alternative",                    this.tsUseCenter);
  			gd.addNumericField("Maximal disparity difference when assigning tiles",                               this.tsMaxDiff,  6);
  			gd.addNumericField("Maximal disparity difference when assigning tiles",                               this.tsMaxDiff,  6);
  			gd.addNumericField("Minimal disparity difference to be considered as a competitor surface",           this.tsMinDiffOther,  6);
  			gd.addNumericField("Minimal disparity difference to be considered as a competitor surface",           this.tsMinDiffOther,  6);
  			gd.addNumericField("Minimal tile correlation strength to be assigned",                                this.tsMinStrength,  6);
  			gd.addNumericField("Minimal tile correlation strength to be assigned",                                this.tsMinStrength,  6);
@@ -3659,6 +3670,7 @@ public class EyesisCorrectionParameters {
  			gd.showDialog();
  			gd.showDialog();
  			if (gd.wasCanceled()) return false;
  			if (gd.wasCanceled()) return false;
  			this.tsNoEdge=              gd.getNextBoolean();
  			this.tsNoEdge=              gd.getNextBoolean();
  			this.tsUseCenter=           gd.getNextBoolean();
  			this.tsMaxDiff=             gd.getNextNumber();
  			this.tsMaxDiff=             gd.getNextNumber();
  			this.tsMinDiffOther=        gd.getNextNumber();
  			this.tsMinDiffOther=        gd.getNextNumber();
  			this.tsMinStrength=         gd.getNextNumber();
  			this.tsMinStrength=         gd.getNextNumber();
+14 −10
Original line number Original line Diff line number Diff line
@@ -5233,10 +5233,11 @@ public class QuadCLT {
        			  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
        			  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
        			  "X3D-"+scanIndex);
        			  "X3D-"+scanIndex);
			  }
			  }
			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73);
			  generateClusterX3d(
			  generateClusterX3d(
					  x3dOutput,
					  x3dOutput,
					  texturePath,
					  texturePath,
					  "shape_id-"+(scanIndex - next_pass), // id
					  scan.bounds,
					  scan.bounds,
					  scan.selected,
					  scan.selected,
					  scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
					  scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
@@ -5286,7 +5287,8 @@ public class QuadCLT {
		  tp.showScan(
		  tp.showScan(
				  tp.clt_3d_passes.get(next_pass-1),   // CLTPass3d   scan,
				  tp.clt_3d_passes.get(next_pass-1),   // CLTPass3d   scan,
				  "after_pass2-"+(next_pass-1)); //String title)
				  "after_pass2-"+(next_pass-1)); //String title)
		  tp.thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
//		  tp.thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
		  tp.thirdPassSetupSurf( // prepare tile tasks for the second pass based on the previous one(s)
				  clt_parameters,
				  clt_parameters,
				  clt_parameters.bgnd_range, // double            disparity_far, 
				  clt_parameters.bgnd_range, // double            disparity_far, 
				  clt_parameters.grow_disp_max, // other_range, //double            disparity_near,   //
				  clt_parameters.grow_disp_max, // other_range, //double            disparity_near,   //
@@ -5323,11 +5325,6 @@ public class QuadCLT {
					  threadsMax,  // maximal number of threads to launch                         
					  threadsMax,  // maximal number of threads to launch                         
					  updateStatus,
					  updateStatus,
					  debugLevel);
					  debugLevel);
/**			  
			  if ((scanIndex == 49) || (scanIndex == 54) ) tp.showScan(
					  scan, // tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
					  "MEASURED-"+scanIndex);
*/					  
		  }
		  }


		  // TEMPORARY EXIT
		  // TEMPORARY EXIT
@@ -5353,13 +5350,14 @@ public class QuadCLT {


			  CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
			  CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);


/*			  
			  if ((scanIndex == 73) ) {
			  if ((scanIndex == 73) ) {
				  tp.showScan(
				  tp.showScan(
						  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
						  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
						  "SELECTED-"+scanIndex);
						  "SELECTED-"+scanIndex);
			  }
			  }



*/


			  // TODO: use new updated disparity, for now just what was forced for the picture
			  // TODO: use new updated disparity, for now just what was forced for the picture
			  double [] scan_disparity = new double [tilesX * tilesY];
			  double [] scan_disparity = new double [tilesX * tilesY];
@@ -5383,17 +5381,21 @@ public class QuadCLT {
					  scan_disparity[i] = sdw;
					  scan_disparity[i] = sdw;
				  }
				  }
			  }
			  }

/*
			  if ((scanIndex == 73)) {
			  if ((scanIndex == 73)) {
				  tp.showScan(
				  tp.showScan(
						  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
						  tp.clt_3d_passes.get(scanIndex), // CLTPass3d   scan,
						  "X3D-"+scanIndex);
						  "X3D-"+scanIndex);
			  }
			  }
			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 73);
*/			  
//			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex < 3);
			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73);
			  
//			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
//			  boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
			  generateClusterX3d(
			  generateClusterX3d(
					  x3dOutput,
					  x3dOutput,
					  texturePath,
					  texturePath,
					  "shape_id-"+(scanIndex - next_pass), // id
					  scan.bounds,
					  scan.bounds,
					  scan.selected,
					  scan.selected,
					  scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
					  scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
@@ -5429,6 +5431,7 @@ public class QuadCLT {
	  public void generateClusterX3d(
	  public void generateClusterX3d(
			  X3dOutput  x3dOutput,
			  X3dOutput  x3dOutput,
			  String     texturePath,
			  String     texturePath,
			  String     id,
			  Rectangle  bounds,
			  Rectangle  bounds,
			  boolean [] selected,
			  boolean [] selected,
			  double []  disparity,
			  double []  disparity,
@@ -5486,6 +5489,7 @@ public class QuadCLT {


		  x3dOutput.addCluster(
		  x3dOutput.addCluster(
				  texturePath,
				  texturePath,
				  id,
				  texCoord,
				  texCoord,
				  worldXYZ,
				  worldXYZ,
				  triangles);
				  triangles);
Loading