Commit bdb4ff93 authored by Andrey Filippov's avatar Andrey Filippov

Implemented ground plane extraction (so far hard-coded parameters) and

rendering rectified 3D model to that plane
parent 9d1a83ef
......@@ -1768,7 +1768,7 @@ public class ErsCorrection extends GeometryCorrection {
int tiles2 = tilesX2 * tilesY2;
if (debug_level > 0) {
String title3 = scene_QuadClt.getImageName()+"-pXpYD_comprison";
String title3 = scene_QuadClt.getImageName()+"-pXpYD_comparison";
String [] titles3 = {"orig","restored","diff"};
double [][] dbg_img3 = new double [titles3.length][tiles2];
for (int i = 0; i < dbg_img3.length; i++) {
......@@ -1858,6 +1858,16 @@ public class ErsCorrection extends GeometryCorrection {
scene_xyzatr[1]);
}
public static double [] applyXYZATR(
double [][] reference_xyzatr,
double [] scene_xyz) {
return applyXYZATR(
reference_xyzatr[0],
reference_xyzatr[1],
scene_xyz);
}
public static double [][] invertXYZATR(
double [][] source_xyzatr){
return invertXYZATR(
......@@ -1883,6 +1893,22 @@ public class ErsCorrection extends GeometryCorrection {
}
// is it correct? Made of combineXYZATR()
public static double [] applyXYZATR(
double [] reference_xyz,
double [] reference_atr,
double [] scene_xyz)
{
Rotation ref_rotation= new Rotation(RotationOrder.YXZ, ROT_CONV, reference_atr[0],reference_atr[1],reference_atr[2]); // null
Vector3D ref_offset = new Vector3D(reference_xyz);
Vector3D scene_offset = new Vector3D(scene_xyz);
Vector3D offset = ref_offset.add(ref_rotation.applyTo(scene_offset));
double [] xyz = offset.toArray();
return xyz;
}
public static double [][] invertXYZATR(
double [] source_xyz,
double [] source_atr)
......
......@@ -100,7 +100,7 @@ public class OpticalFlow {
case FAIL_REASON_LMA: return "FAIL_REASON_LMA";
case FAIL_REASON_INTERSCENE: return "FAIL_REASON_INTERSCENE";
case FAIL_REASON_MIN: return "FAIL_REASON_MIN";
case FAIL_REASON_MAX: return "FAIL_REASON_MAXv";
case FAIL_REASON_MAX: return "FAIL_REASON_MAX";
case FAIL_REASON_NULL: return "FAIL_REASON_NULL";
case FAIL_REASON_EMPTY: return "FAIL_REASON_EMPTY";
case FAIL_REASON_ROLL: return "FAIL_REASON_ROLL";
......@@ -5796,8 +5796,39 @@ public class OpticalFlow {
} // if (generate_mapped) {
// debugging 3D model
int [] whs = new int[3];
double [] x0y0 = new double[2];
if (export3d) { //combo_dsn_final had strength 1.0e-4 where it should not? Reset it?
/* */
boolean use_lma = true; // ;
double discard_low = 0.01; // fraction of all pixels
double discard_high = 0.5; // fraction of all pixels
double discard_adisp = 0.2; // discard above/below this fraction of average height
double discard_rdisp = 0.02; // discard above/below this fraction of average height
double pix_size = 0.005; // hdr_x0y0, // in meters
int max_image_width = 3200; // increase pixel size as a power of 2 until image fits
// boolean crop_empty = true;
// int crop_extra = 20;
// int [] tex_pals = {0,1,2};
// int tex_palette_start = 0; //
// int tex_palette_end = 12;
int [] hdr_whs = new int[3];
double [] hdr_x0y0 = new double[2];
double [][] to_ground_xyxatr = quadCLTs[ref_index].getGround(
use_lma, // boolean use_lma,
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
/**/
boolean ok_3d = TexturedModel.output3d( // quadCLTs have same image name, and everything else
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
......
This diff is collapsed.
......@@ -51,21 +51,37 @@ public class TriMesh {
{{0,0},{1,0},{ 1,1}}};// TRI_RIGHT_DOWN
public String texture_image;
public double [][] texture_pixels=null; // alternative texture representation [chn][pix]
public int texture_width; // texture width when provided as an array
public double [][] worldXYZ;
public double [][] texCoord;
public int [][] triangles;
public TriMesh (
String texture_image,
double [][] texture_pixels,
int texture_width,
double [][] worldXYZ,
double [][] texCoord,
int [][] triangles) {
this.texture_image = texture_image;
this.texture_image = texture_image;
this.texture_pixels = texture_pixels;
this.texture_width = texture_width;
this.worldXYZ = worldXYZ;
this.texCoord = texCoord;
this.triangles = triangles;
this.triangles = (triangles!=null) ? triangles :new int[0][]; // maybe not needed?
}
public String getImage() {return texture_image;}
int [][] getTriangles() {return triangles;}
public double [][] getTexturePixels(){
return texture_pixels;
}
public int getTextureWidth() {
return texture_width;
}
public int getTextureHeight() {
return texture_pixels[0].length/texture_width;
}
double [][] getTexCoord() {
return texCoord;
}
......@@ -2276,6 +2292,8 @@ public class TriMesh {
if (tri_meshes != null) {
tri_meshes.add(new TriMesh(
texturePath, // String texture_image,
null, // double [][] texture_pixels,
0, // lin_width, // int texture_width,
worldXYZ, // double [][] worldXYZ,
texCoord, // double [][] texCoord,
triangles)); // int [][] triangles
......@@ -2293,6 +2311,8 @@ public class TriMesh {
WavefrontExport wfOutput, // output WSavefront if not null
ArrayList<TriMesh> tri_meshes,
String texturePath,
double [][] lin_texture, // null or rendering rectilinear hdr image
int lin_width,
String id,
String class_name,
Rectangle bounds,
......@@ -2503,6 +2523,8 @@ public class TriMesh {
if (tri_meshes != null) {
tri_meshes.add(new TriMesh(
texturePath, // String texture_image,
lin_texture, // double [][] texture_pixels,
lin_width, // int texture_width,
worldXYZ, // double [][] worldXYZ,
texCoord, // double [][] texCoord,
triangles)); // int [][] triangles
......
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