Commit 019655f7 authored by Andrey Filippov's avatar Andrey Filippov

Parallel projection, not yet done with center projection bounds with IMS

parent 8b5bd41b
...@@ -470,6 +470,9 @@ public class CLTParameters { ...@@ -470,6 +470,9 @@ public class CLTParameters {
// parameters for ground maps generation // parameters for ground maps generation
public boolean gmap_render_hdr = true; // generate textures w/o normalization to generate undistorted 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) public boolean gmap_en = true; // generate ground map from a drone (enables gmap_render_hdr)
public boolean gmap_parallel_proj = true; // Use parallel projection (map)
public boolean gmap_update_range = false; // for parallel only
// extracting ground projection plane // extracting ground projection plane
public boolean gmap_use_lma = true; // ; public boolean gmap_use_lma = true; // ;
public double gmap_discard_low = 0.01; // fraction of all pixels public double gmap_discard_low = 0.01; // fraction of all pixels
...@@ -1612,7 +1615,10 @@ public class CLTParameters { ...@@ -1612,7 +1615,10 @@ public class CLTParameters {
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_render_hdr", this.gmap_render_hdr+""); // boolean
properties.setProperty(prefix+"gmap_en", this.gmap_en+""); // boolean properties.setProperty(prefix+"gmap_en", this.gmap_en+""); // boolean
properties.setProperty(prefix+"gmap_parallel_proj", this.gmap_parallel_proj+""); // boolean
properties.setProperty(prefix+"gmap_update_range", this.gmap_update_range+""); // boolean
properties.setProperty(prefix+"gmap_use_lma", this.gmap_use_lma+""); // 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_low", this.gmap_discard_low+""); // double
properties.setProperty(prefix+"gmap_discard_high", this.gmap_discard_high+""); // double properties.setProperty(prefix+"gmap_discard_high", this.gmap_discard_high+""); // double
...@@ -2629,6 +2635,8 @@ public class CLTParameters { ...@@ -2629,6 +2635,8 @@ public class CLTParameters {
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_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_en")!=null) this.gmap_en=Boolean.parseBoolean(properties.getProperty(prefix+ "gmap_en"));
if (properties.getProperty(prefix+"gmap_parallel_proj")!=null) this.gmap_parallel_proj=Boolean.parseBoolean(properties.getProperty(prefix+"gmap_parallel_proj"));
if (properties.getProperty(prefix+"gmap_update_range")!=null) this.gmap_update_range=Boolean.parseBoolean(properties.getProperty(prefix+ "gmap_update_range"));
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_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_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_high")!=null) this.gmap_discard_high=Double.parseDouble(properties.getProperty(prefix+ "gmap_discard_high"));
...@@ -3875,10 +3883,17 @@ public class CLTParameters { ...@@ -3875,10 +3883,17 @@ public class CLTParameters {
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.addMessage ("Ground map export");
gd.addMessage ("Use of IMS/GNSS data is "+(imp.ims_use? "ENABLED":"DISABLED")+" (see 'IMS' configuration tab)");
gd.addCheckbox ("Generate/save linear 32-bit textures", this.gmap_render_hdr, // true; // enable change FG pixel to opaque from transparent 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."); "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 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."); "Render fixed-scale projection of the 3D model to a ground plane, such as for the UAS-generated imagery.");
gd.addCheckbox ("Parallel (not center) projection (maps)", this.gmap_parallel_proj, // true; // enable change FG pixel to opaque from transparent
"Parallel-project objects to a plane surface. If unchecked - use center (from the camera) projection.");
gd.addCheckbox ("Fit all model (parallel only)", this.gmap_update_range, // true; // enable change FG pixel to opaque from transparent
"Recalculate (increase) image size to fit all model elements. Unchecked - limit by plane intersection with the camera FOV.");
gd.addCheckbox ("Use only LMA disparity for ground", this.gmap_use_lma, // true; // enable change FG pixel to opaque from transparent 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."); "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,"", gd.addNumericField("Discard low fraction", this.gmap_discard_low, 4,6,"",
...@@ -5103,6 +5118,8 @@ public class CLTParameters { ...@@ -5103,6 +5118,8 @@ public class CLTParameters {
this.gmap_render_hdr= gd.getNextBoolean(); this.gmap_render_hdr= gd.getNextBoolean();
this.gmap_en= gd.getNextBoolean(); this.gmap_en= gd.getNextBoolean();
this.gmap_parallel_proj= gd.getNextBoolean();
this.gmap_update_range= gd.getNextBoolean();
this.gmap_use_lma= gd.getNextBoolean(); this.gmap_use_lma= gd.getNextBoolean();
this.gmap_discard_low= gd.getNextNumber(); this.gmap_discard_low= gd.getNextNumber();
this.gmap_discard_high= gd.getNextNumber(); this.gmap_discard_high= gd.getNextNumber();
......
...@@ -2738,6 +2738,20 @@ public class OpticalFlow { ...@@ -2738,6 +2738,20 @@ public class OpticalFlow {
public static double [][] transformToWorldXYZ( public static double [][] transformToWorldXYZ(
final double [] disparity_ref, // invalid tiles - NaN in disparity final double [] disparity_ref, // invalid tiles - NaN in disparity
final QuadCLT quadClt, // now - may be null - for testing if scene is rotated ref final QuadCLT quadClt, // now - may be null - for testing if scene is rotated ref
int threadsMax){
return transformToWorldXYZ(
disparity_ref, // invalid tiles - NaN in disparity
quadClt, // now - may be null - for testing if scene is rotated ref
ZERO3,
ZERO3,
threadsMax);
}
public static double [][] transformToWorldXYZ(
final double [] disparity_ref, // invalid tiles - NaN in disparity
final QuadCLT quadClt, // now - may be null - for testing if scene is rotated ref
double [] reference_xyz, // this view position in world coordinates (typically ZERO3)
double [] reference_atr, // this view orientation relative to world frame (typically ZERO3)
int threadsMax) int threadsMax)
{ {
TileProcessor tp = quadClt.getTileProcessor(); TileProcessor tp = quadClt.getTileProcessor();
...@@ -2764,8 +2778,8 @@ public class OpticalFlow { ...@@ -2764,8 +2778,8 @@ public class OpticalFlow {
centerY, // double py, // pixel coordinate Y in the reference view centerY, // double py, // pixel coordinate Y in the reference view
disparity, // double disparity, // reference disparity disparity, // double disparity, // reference disparity
true, // boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear true, // boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear
ZERO3, // double [] reference_xyz, // this view position in world coordinates (typically ZERO3) reference_xyz, // double [] reference_xyz, // this view position in world coordinates (typically ZERO3)
ZERO3); // double [] reference_atr, // this view orientation relative to world frame (typically ZERO3) reference_atr); // double [] reference_atr, // this view orientation relative to world frame (typically ZERO3)
} }
} }
}; };
...@@ -5251,6 +5265,52 @@ public class OpticalFlow { ...@@ -5251,6 +5265,52 @@ public class OpticalFlow {
ego_comment); // String comment); ego_comment); // String comment);
} }
} }
boolean test_ground = false; // true;
if (test_ground) {
final boolean use_lma = clt_parameters.gmap_use_lma ; // true; // ;
final double discard_low = clt_parameters.gmap_discard_low ; //0.01; // fraction of all pixels
final double discard_high = clt_parameters.gmap_discard_high ; //0.5; // fraction of all pixels
final double discard_adisp = clt_parameters.gmap_discard_adisp ; //0.2; // discard above/below this fraction of average height
final double discard_rdisp = clt_parameters.gmap_discard_rdisp ; //0.02; // discard above/below this fraction of average height
final double pix_size = clt_parameters.gmap_pix_size ; //0.005; // hdr_x0y0, // in meters
final int max_image_width = clt_parameters.gmap_max_image_width ; //4000; // 3200; // increase pixel size as a power of 2 until image fits
// final double range_disparity_offset = clt_parameters.imp.range_disparity_offset;// double range_disparity_offset
boolean use_parallel_proj = false; // true;
int [] hdr_whs = new int[3];
double [] hdr_x0y0 = new double[2];
double [][] to_ground_xyzatr = quadCLTs[ref_index].getGroundNoIms(
clt_parameters, // CLTParameters clt_parameters,
use_lma, // boolean use_lma,
use_parallel_proj, // boolean use_parallel_proj,
range_disparity_offset,// double range_disparity_offset
discard_low, // double discard_low, // fraction of all pixels
discard_high, // double discard_high, // fraction of all pixels
discard_adisp, // double discard_adisp, // discard above/below this fraction of average height
discard_rdisp, // double discard_rdisp // discard above/below this fraction of average height
pix_size, // double pix_size, // in meters
max_image_width, // int max_image_width // increase pixel size as a power of 2 until image fits
hdr_x0y0, // double [] x0y0, // initialize to double[2] to return width, height
hdr_whs, // int [] whs, // initialize to int[3] to return {width, height, scale reduction}
debugLevel); // int debug_level
quadCLTs[ref_index].getErsCorrection().printVectors (to_ground_xyzatr[0], to_ground_xyzatr[1]);
double [][] to_ground_xyzatr_ims = quadCLTs[ref_index].getGroundIms(
clt_parameters, // CLTParameters clt_parameters,
use_lma, // boolean use_lma,
use_parallel_proj, // boolean use_parallel_proj,
range_disparity_offset,// double range_disparity_offset
discard_low, // double discard_low, // fraction of all pixels
discard_high, // double discard_high, // fraction of all pixels
discard_adisp, // double discard_adisp, // discard above/below this fraction of average height
discard_rdisp, // double discard_rdisp // discard above/below this fraction of average height
pix_size, // double pix_size, // in meters
max_image_width, // int max_image_width // increase pixel size as a power of 2 until image fits
hdr_x0y0, // double [] x0y0, // initialize to double[2] to return width, height
hdr_whs, // int [] whs, // initialize to int[3] to return {width, height, scale reduction}
debugLevel); // int debug_level
quadCLTs[ref_index].getErsCorrection().printVectors (to_ground_xyzatr_ims[0], to_ground_xyzatr_ims[1]);
System.out.println("getGroundIms Done");
}
if (test_ers) { // only debug feature if (test_ers) { // only debug feature
test_ers0 = quadCLTs.length -1; // make it always == reference ! test_ers0 = quadCLTs.length -1; // make it always == reference !
......
...@@ -2454,6 +2454,8 @@ public class TexturedModel { ...@@ -2454,6 +2454,8 @@ public class TexturedModel {
{ {
final boolean map_en = clt_parameters.gmap_en; final boolean map_en = clt_parameters.gmap_en;
final boolean render_hdr = clt_parameters.gmap_render_hdr || map_en;// true; //false; // true; // generate textures w/o normalization to generate undistorted final boolean render_hdr = clt_parameters.gmap_render_hdr || map_en;// true; //false; // true; // generate textures w/o normalization to generate undistorted
final boolean use_parallel_proj = clt_parameters.gmap_parallel_proj; // Use parallel projection (map)
final boolean update_range = clt_parameters.gmap_update_range; // for parallel only
final boolean use_lma = clt_parameters.gmap_use_lma ; // true; // ; final boolean use_lma = clt_parameters.gmap_use_lma ; // true; // ;
final double discard_low = clt_parameters.gmap_discard_low ; //0.01; // fraction of all pixels final double discard_low = clt_parameters.gmap_discard_low ; //0.01; // fraction of all pixels
...@@ -2585,26 +2587,6 @@ public class TexturedModel { ...@@ -2585,26 +2587,6 @@ public class TexturedModel {
double[][] ds_fg_bg = {ds_fg[0], ds_bg[0].clone()}; double[][] ds_fg_bg = {ds_fg[0], ds_bg[0].clone()};
double[][] ss_fg_bg = {ds_fg[1], ds_bg[1]}; double[][] ss_fg_bg = {ds_fg[1], ds_bg[1]};
/*
for (int i = 0; i < dls_bg[0].length; i++) {
if (Math.abs(ds_fg_bg[1][i]-ds_fg_bg[0][i]) < tex_fg_bg) {
ds_fg_bg[1][i] = Double.NaN;
}
}
if (debugLevel > -2) {
System.out.println("Limiting non-infinity objects' disparity to "+min_obj_disparity+
", infinity_disparity = "+infinity_disparity);
}
for (int nl = 0; nl < ds_fg_bg.length; nl++) {
for (int i = 0; i < dls_bg[nl].length; i++) {
if ((nl != sky_layer) || !sky_tiles[i]) {
if (ds_fg_bg[nl][i] < min_obj_disparity) {
ds_fg_bg[nl][i] = min_obj_disparity;
}
}
}
}
*/
if (show_bs_debug) { if (show_bs_debug) {
String [] dbg_titles = {"FG","BG","BS"}; String [] dbg_titles = {"FG","BG","BS"};
double [][] dbg_img = {ds_fg_bg[0], ds_fg_bg[1],combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY].clone()}; double [][] dbg_img = {ds_fg_bg[0], ds_fg_bg[1],combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY].clone()};
...@@ -3000,36 +2982,73 @@ public class TexturedModel { ...@@ -3000,36 +2982,73 @@ public class TexturedModel {
if (render_hdr) { if (render_hdr) {
int [] hdr_whs = new int[3]; int [] hdr_whs = new int[3];
double [] hdr_x0y0 = new double[2]; double [] hdr_x0y0 = new double[2];
double [][] to_ground_xyxatr = scenes[ref_index].getGround( double [][] to_ground_xyzatr = scenes[ref_index].getGround(
use_lma, // boolean use_lma, clt_parameters, // CLTParameters clt_parameters,
use_lma, // boolean use_lma,
use_parallel_proj, // boolean use_parallel_proj,
range_disparity_offset,// double range_disparity_offset range_disparity_offset,// double range_disparity_offset
discard_low, // double discard_low, // fraction of all pixels discard_low, // double discard_low, // fraction of all pixels
discard_high, // double discard_high, // fraction of all pixels discard_high, // double discard_high, // fraction of all pixels
discard_adisp, // double discard_adisp, // discard above/below this fraction of average height discard_adisp, // double discard_adisp, // discard above/below this fraction of average height
discard_rdisp, // double discard_rdisp // discard above/below this fraction of average height discard_rdisp, // double discard_rdisp // discard above/below this fraction of average height
pix_size, // double pix_size, // in meters pix_size, // double pix_size, // in meters
max_image_width, // int max_image_width // increase pixel size as a power of 2 until image fits max_image_width, // int max_image_width // increase pixel size as a power of 2 until image fits
hdr_x0y0, // double [] x0y0, // initialize to double[2] to return width, height hdr_x0y0, // double [] x0y0, // initialize to double[2] to return width, height
hdr_whs, // int [] whs, // initialize to int[3] to return {width, height, scale reduction} hdr_whs, // int [] whs, // initialize to int[3] to return {width, height, scale reduction}
debugLevel); // int debug_level debugLevel); // int debug_level
if (to_ground_xyxatr == null) { if (to_ground_xyzatr == null) {
System.out.println("***** Failed to detect flat ground surface, skipping rendering and output files generation *****"); System.out.println("***** Failed to detect flat ground surface, skipping rendering and output files generation *****");
} else { } else {
double scaled_pixel_size = pix_size * hdr_whs[2];
if (use_parallel_proj) {
if (update_range ) {
double [][] bounds = Render3D.getBounds(
tri_meshes, // final ArrayList<TriMesh> tri_meshes,
to_ground_xyzatr, // final double [][] xyzatr_toground,
debugLevel); // int debugLevel) // debug level
hdr_x0y0[0] = bounds[0][0];
hdr_x0y0[1] = bounds[1][0];
hdr_whs[0] = (int) Math.ceil((bounds[0][1]-bounds[0][0])/scaled_pixel_size);
hdr_whs[1] = (int) Math.ceil((bounds[1][1]-bounds[1][0])/scaled_pixel_size);
if (debugLevel > -2) {
System.out.println("Updated parameters for rendering:top left corner=["+hdr_x0y0[0]+"m, "+hdr_x0y0[1]+"m]");
System.out.println(" : width="+hdr_whs[0]+"pix, height="+hdr_whs[1]+"pix, scale level="+hdr_whs[2]);
System.out.println(" : pixel size: ="+(1000*scaled_pixel_size)+"mm");
}
} else {
if (debugLevel > -2) {
System.out.println("Keeping conservative parameters for rendering:top left corner=["+hdr_x0y0[0]+"m, "+hdr_x0y0[1]+"m]");
System.out.println(" : width="+hdr_whs[0]+"pix, height="+hdr_whs[1]+"pix, scale level="+hdr_whs[2]);
System.out.println(" : pixel size: ="+(1000*scaled_pixel_size)+"mm");
}
}
}
Render3D render3D = new Render3D ( Render3D render3D = new Render3D (
//x3d_dir, // String x3d_dir, //x3d_dir, // String x3d_dir,
//ref_scene.correctionsParameters.getModelName(ref_scene.getImageName()), // String model_name, //ref_scene.correctionsParameters.getModelName(ref_scene.getImageName()), // String model_name,
scenes[ref_index], // QuadCLT ref_scene, // all coordinates relative to this scene scenes[ref_index], // QuadCLT ref_scene, // all coordinates relative to this scene
to_ground_xyxatr, // double [][] plane_xyzatr, // projection plane center relative to reference scene to_ground_xyzatr, // double [][] plane_xyzatr, // projection plane center relative to reference scene
pix_size * hdr_whs[2], // double pixel_size, // in meters scaled_pixel_size, // double pixel_size, // in meters
hdr_x0y0, // double [] x0_y0, // usually negative - top-left point of the output render hdr_x0y0, // double [] x0_y0, // usually negative - top-left point of the output render
hdr_whs[0], // int out_width, // output rendered image width in pixels hdr_whs[0], // int out_width, // output rendered image width in pixels
hdr_whs[1]); // int out_height); // output rendered image height in pixels hdr_whs[1]); // int out_height); // output rendered image height in pixels
boolean last_is_alpha = true; // last channel in textures slices is alpha boolean last_is_alpha = true; // last channel in textures slices is alpha
double [][] full_render =render3D.render3dPlane( double [][] full_render;
tri_meshes, // final ArrayList<TriMesh> tri_meshes, if (use_parallel_proj) {
last_is_alpha, // final boolean last_is_alpha, full_render =render3D.render3dPlaneParallelProj(
scenes[ref_index], //final QuadCLT ref_scene, // all coordinates relative to this scene tri_meshes, // final ArrayList<TriMesh> tri_meshes,
debugLevel); //int debugLevel) last_is_alpha, // final boolean last_is_alpha,
// scenes[ref_index], //final QuadCLT ref_scene, // all coordinates relative to this scene
debugLevel); //int debugLevel)
} else {
full_render =render3D.render3dPlaneCenterProj(
tri_meshes, // final ArrayList<TriMesh> tri_meshes,
last_is_alpha, // final boolean last_is_alpha,
// scenes[ref_index], //final QuadCLT ref_scene, // all coordinates relative to this scene
debugLevel); //int debugLevel)
}
// String model_name = ref_scene.correctionsParameters.getModelName(ref_scene.getImageName()); // String model_name = ref_scene.correctionsParameters.getModelName(ref_scene.getImageName());
String suffix ="-RECT"; String suffix ="-RECT";
if (clt_parameters.tex_um) { if (clt_parameters.tex_um) {
......
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