Commit af9b88ff authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Implemented configurable parameters for ground plane rendering. Added

disabling ERS in the inter-scene LMA if there is not enough data (not in
all 4 quadrants)
parent 4e3cc252
Loading
Loading
Loading
Loading
+179 −0
Original line number Original line Diff line number Diff line
@@ -467,6 +467,24 @@ public class CLTParameters {
	public boolean    gltf_emissive =     false; // true;   // Use emissive textures
	public boolean    gltf_emissive =     false; // true;   // Use emissive textures
	public boolean    gltf_alpha_blend =  false; // true;   // Use alpha blend (false - opaque)
	public boolean    gltf_alpha_blend =  false; // true;   // Use alpha blend (false - opaque)
	
	
	// parameters for ground maps generation
	public boolean    gmap_render_hdr =      true; //  generate textures w/o normalization to generate undistorted
	public boolean    gmap_en =              true; //  generate ground map from a drone (enables gmap_render_hdr)
	// extracting ground projection plane
	public boolean    gmap_use_lma =         true;  // ;
	public double     gmap_discard_low =     0.01;  // fraction of all pixels
	public double     gmap_discard_high =    0.5;   // fraction of all pixels
	public double     gmap_discard_adisp =   0.2;   // discard above/below this fraction of average height 
	public double     gmap_discard_rdisp =   0.02;  // discard above/below this fraction of average height
	public double     gmap_pix_size =        0.005; // hdr_x0y0,       // in meters
	public int        gmap_max_image_width = 4000; // 3200;  // increase pixel size as a power of 2 until image fits
	public boolean    gmap_crop_empty =      true;
	public int        gmap_crop_extra =      20;
	public int []     gmap_tex_pals =        {0,1,2};
	
	
	public boolean    show_textures    = true;  // show generated textures
	public boolean    show_textures    = true;  // show generated textures
	public boolean    debug_filters    = false;// show intermediate results of filtering
	public boolean    debug_filters    = false;// show intermediate results of filtering
	// not used anywhere so far
	// not used anywhere so far
@@ -1593,6 +1611,19 @@ public class CLTParameters {
		properties.setProperty(prefix+"gltf_emissive",              this.gltf_emissive+"");
		properties.setProperty(prefix+"gltf_emissive",              this.gltf_emissive+"");
		properties.setProperty(prefix+"gltf_alpha_blend",           this.gltf_alpha_blend+"");
		properties.setProperty(prefix+"gltf_alpha_blend",           this.gltf_alpha_blend+"");
		properties.setProperty(prefix+"gmap_render_hdr",            this.gmap_render_hdr+"");            // boolean 
		properties.setProperty(prefix+"gmap_en",                    this.gmap_en+"");                    // boolean 
		properties.setProperty(prefix+"gmap_use_lma",               this.gmap_use_lma+"");               // boolean 
		properties.setProperty(prefix+"gmap_discard_low",           this.gmap_discard_low+"");           // double
		properties.setProperty(prefix+"gmap_discard_high",          this.gmap_discard_high+"");          // double
		properties.setProperty(prefix+"gmap_discard_adisp",         this.gmap_discard_adisp+"");         // double
		properties.setProperty(prefix+"gmap_discard_rdisp",         this.gmap_discard_rdisp+"");         // double
		properties.setProperty(prefix+"gmap_pix_size",              this.gmap_pix_size+"");              // double
		properties.setProperty(prefix+"gmap_max_image_width",       this.gmap_max_image_width+"");       // int     
		properties.setProperty(prefix+"gmap_crop_empty",            this.gmap_crop_empty+"");            // boolean 
		properties.setProperty(prefix+"gmap_crop_extra",            this.gmap_crop_extra+"");            // int     
		properties.setProperty(prefix+"gmap_tex_pals",              CLTParameters.arr_to_str(this.gmap_tex_pals)); // int[]
		
		properties.setProperty(prefix+"show_textures",              this.show_textures+"");
		properties.setProperty(prefix+"show_textures",              this.show_textures+"");
		properties.setProperty(prefix+"debug_filters",              this.debug_filters+"");
		properties.setProperty(prefix+"debug_filters",              this.debug_filters+"");
@@ -2595,6 +2626,19 @@ public class CLTParameters {
		if (properties.getProperty(prefix+"gltf_emissive")!=null)                 this.gltf_emissive=Boolean.parseBoolean(properties.getProperty(prefix+"gltf_emissive"));
		if (properties.getProperty(prefix+"gltf_emissive")!=null)                 this.gltf_emissive=Boolean.parseBoolean(properties.getProperty(prefix+"gltf_emissive"));
		if (properties.getProperty(prefix+"gltf_alpha_blend")!=null)              this.gltf_alpha_blend=Boolean.parseBoolean(properties.getProperty(prefix+"gltf_alpha_blend"));
		if (properties.getProperty(prefix+"gltf_alpha_blend")!=null)              this.gltf_alpha_blend=Boolean.parseBoolean(properties.getProperty(prefix+"gltf_alpha_blend"));
		if (properties.getProperty(prefix+"gmap_render_hdr")!=null)      this.gmap_render_hdr=Boolean.parseBoolean(properties.getProperty(prefix+   "gmap_render_hdr"));
		if (properties.getProperty(prefix+"gmap_en")!=null)              this.gmap_en=Boolean.parseBoolean(properties.getProperty(prefix+           "gmap_en"));
		if (properties.getProperty(prefix+"gmap_use_lma")!=null)         this.gmap_use_lma=Boolean.parseBoolean(properties.getProperty(prefix+      "gmap_use_lma"));
		if (properties.getProperty(prefix+"gmap_discard_low")!=null)     this.gmap_discard_low=Double.parseDouble(properties.getProperty(prefix+    "gmap_discard_low"));
		if (properties.getProperty(prefix+"gmap_discard_high")!=null)    this.gmap_discard_high=Double.parseDouble(properties.getProperty(prefix+   "gmap_discard_high"));
		if (properties.getProperty(prefix+"gmap_discard_adisp")!=null)   this.gmap_discard_adisp=Double.parseDouble(properties.getProperty(prefix+  "gmap_discard_adisp"));
		if (properties.getProperty(prefix+"gmap_discard_rdisp")!=null)   this.gmap_discard_rdisp=Double.parseDouble(properties.getProperty(prefix+  "gmap_discard_rdisp"));
		if (properties.getProperty(prefix+"gmap_pix_size")!=null)        this.gmap_pix_size=Double.parseDouble(properties.getProperty(prefix+       "gmap_pix_size"));
		if (properties.getProperty(prefix+"gmap_max_image_width")!=null) this.gmap_max_image_width=Integer.parseInt(properties.getProperty(prefix+  "gmap_max_image_width"));
   		if (properties.getProperty(prefix+"gmap_crop_empty")!=null)      this.gmap_crop_empty=Boolean.parseBoolean(properties.getProperty(prefix+   "gmap_crop_empty"));
		if (properties.getProperty(prefix+"gmap_crop_extra")!=null)      this.gmap_crop_extra=Integer.parseInt(properties.getProperty(prefix+       "gmap_crop_extra"));// int     
		if (properties.getProperty(prefix+"gmap_tex_pals")!=null)        this.gmap_tex_pals=CLTParameters.str_to_iarr(properties.getProperty(prefix+"gmap_tex_pals"));
		
		if (properties.getProperty(prefix+"show_textures")!=null)                 this.show_textures=Boolean.parseBoolean(properties.getProperty(prefix+"show_textures"));
		if (properties.getProperty(prefix+"show_textures")!=null)                 this.show_textures=Boolean.parseBoolean(properties.getProperty(prefix+"show_textures"));
		if (properties.getProperty(prefix+"debug_filters")!=null)                 this.debug_filters=Boolean.parseBoolean(properties.getProperty(prefix+"debug_filters"));
		if (properties.getProperty(prefix+"debug_filters")!=null)                 this.debug_filters=Boolean.parseBoolean(properties.getProperty(prefix+"debug_filters"));
@@ -3828,6 +3872,33 @@ public class CLTParameters {
		gd.addCheckbox    ("glTF use emissive textures",                                                             this.gltf_emissive);
		gd.addCheckbox    ("glTF use emissive textures",                                                             this.gltf_emissive);
		gd.addCheckbox    ("glTF use alpha blend",                                                                   this.gltf_alpha_blend);
		gd.addCheckbox    ("glTF use alpha blend",                                                                   this.gltf_alpha_blend);
		gd.addMessage     ("Ground map export");
		gd.addCheckbox ("Generate/save linear 32-bit textures",    this.gmap_render_hdr, // true; // enable change FG pixel to opaque from transparent
				"Generate and save textures w/o normalization as 32-bit Tiff files. This option will be automatically activated if ground plane maps are used.");
		gd.addCheckbox ("Render ground-plane maps",                this.gmap_en, // true; // enable change FG pixel to opaque from transparent
				"Render fixed-scale projection of the 3D model to a ground plane, such as for the UAS-generated imagery.");
		gd.addCheckbox ("Use only LMA disparity for ground",       this.gmap_use_lma, // true; // enable change FG pixel to opaque from transparent
				"Use only LMA-generated disparity to find the ground plane to project the map.");
		gd.addNumericField("Discard low fraction",                 this.gmap_discard_low,  4,6,"",
				"Discard lowest tiles (ditches) up to this fraction of all available tiles when finding the ground plane for the map projection.");
		gd.addNumericField("Discard high fraction",                this.gmap_discard_high,  4,6,"",
				"Discard highest tiles (vegetation, structure) up to this fraction of all available tiles when finding the ground plane for the map projection.");
		gd.addNumericField("Disparity absolute range",             this.gmap_discard_adisp,  4,6,"",
				"Discard tiles with the absolute value of the absolute disparity difference to the ground plane exceeds this value.");
		gd.addNumericField("Disparity absolute range",             this.gmap_discard_rdisp,  4,6,"",
				"Discard tiles with the absolute value of the relative (to the ground plane disparity) disparity difference to the ground plane exceeds this value.");
		gd.addNumericField("Rendered map pixel size",              this.gmap_pix_size,  4,6,"m",
				"Rendered absolute pixel size in meters.");
		gd.addNumericField("Maximal rendered image width",         this.gmap_max_image_width, 0,3,"",
				"Maximal output image size in pixels. Increase pixel size in the power-of-two ratio if calculated image width exceeds this value.");
		gd.addCheckbox ("Crop empty map areas",                    this.gmap_crop_empty, // true; // enable change FG pixel to opaque from transparent
				"Crop the map output from four directions while only undefined pixels are removed.");
		gd.addNumericField("Crop maps extra",                      this.gmap_crop_extra, 0,3,"pix",  // minimal neighbors to keep alpha
				"Additionally crop map by this number of pixels from each of the four directions.");
		gd.addStringField ("LWIR palettes to render the maps",     CLTParameters.arr_to_str(this.gmap_tex_pals), 40,
				"Enter space-separated list of the palette numbers, such as, such as '0 1 2'");
		
		
		gd.addMessage     ("Earlier 3D generation parameters");
		gd.addMessage     ("Earlier 3D generation parameters");
		gd.addCheckbox    ("Show generated textures",                                                                this.show_textures);
		gd.addCheckbox    ("Show generated textures",                                                                this.show_textures);
		gd.addCheckbox    ("show intermediate results of filtering",                                                 this.debug_filters);
		gd.addCheckbox    ("show intermediate results of filtering",                                                 this.debug_filters);
@@ -5027,6 +5098,20 @@ public class CLTParameters {
		this.gltf_emissive=         gd.getNextBoolean();
		this.gltf_emissive=         gd.getNextBoolean();
		this.gltf_alpha_blend=      gd.getNextBoolean();
		this.gltf_alpha_blend=      gd.getNextBoolean();
		
		
		this.gmap_render_hdr=       gd.getNextBoolean();
		this.gmap_en=               gd.getNextBoolean();
		this.gmap_use_lma=          gd.getNextBoolean();
		this.gmap_discard_low=      gd.getNextNumber();
		this.gmap_discard_high=     gd.getNextNumber();
		this.gmap_discard_adisp=    gd.getNextNumber();
		this.gmap_discard_rdisp=    gd.getNextNumber();
		gmap_pix_size=              gd.getNextNumber();
		this.gmap_max_image_width= (int) gd.getNextNumber();
		this.gmap_crop_empty=       gd.getNextBoolean();
		this.gmap_crop_extra= (int) gd.getNextNumber();
		
		this.gmap_tex_pals =           CLTParameters.str_to_iarr(gd.getNextString());
		
		this.show_textures=         gd.getNextBoolean();
		this.show_textures=         gd.getNextBoolean();
		this.debug_filters=         gd.getNextBoolean();
		this.debug_filters=         gd.getNextBoolean();
		this.min_smth=              gd.getNextNumber();
		this.min_smth=              gd.getNextNumber();
@@ -5889,4 +5974,98 @@ public class CLTParameters {
		}
		}
		return true;
		return true;
	}
	}
	
// conversion of multiple parameters in a line
	public static String arr_to_str(int [] arr) {
		String s = "";
		for (int c:arr) s+=c+" ";
		return s.trim();
	}
	public static String arr_to_str(double [] arr) {
		String s = "";
		for (double c:arr) s+=c+" ";
		return s.trim();
	}
	public static String arr_to_str(boolean [] arr) {
		String s = "";
		for (boolean c:arr) s+= (c?1:0)+" ";
		return s.trim();
	}
	public static String arr_to_str(String [] arr) {
		String s = "";
		for (int i = 0; i < arr.length; i++) {
			s += arr[i].trim();
			if (i < (arr.length - 1)){
				s += ",";
			}
		}
		return s;
	}
	public static boolean [] str_to_barr(String s) {
		int [] iarr = str_to_iarr(s);
		if (iarr == null) return null;
		boolean [] barr = new boolean [iarr.length];
		for (int i = 0; i < barr.length; i++) {
			barr[i] = iarr[i] != 0;
		}
		return barr;
	}
	public static int [] str_to_iarr(String s) {
		String [] sa;
		if (s.indexOf(",") >= 0) {
			sa = s.trim().split(",");
		} else {
			sa = s.trim().split(" ");
		}
		int [] iarr = new int [sa.length];
		for (int i = 0; i < sa.length; i++) {
			iarr[i]=Integer.parseInt(sa[i].trim());
		}
		return iarr;
	}
	public static double [] str_to_darr(String s) {
		String [] sa;
		if (s.indexOf(",") >= 0) {
			sa = s.trim().split(",");
		} else {
			sa = s.trim().split(" ");
		}
		double [] darr = new double [sa.length];
		for (int i = 0; i < sa.length; i++) {
			darr[i]=Double.parseDouble(sa[i].trim());
		}
		return darr;
	}
	public static String [] str_to_sarr(String s) {
		String [] sa;
		if (s.indexOf(",") >= 0) {
			sa = s.trim().split(",");
		} else {
			sa = s.trim().split(" ");
		}
		String [] sarr = new String [sa.length];
		for (int i = 0; i < sa.length; i++) {
			sarr[i]=sa[i].trim();
		}
		return sarr;
	}
	
	
	
	
	
	
	
	
	
}
}
 No newline at end of file
Loading