Commit b267218c authored by Andrey Filippov's avatar Andrey Filippov

testing planes

parent 5467504f
...@@ -143,9 +143,14 @@ public class CLTPass3d{ ...@@ -143,9 +143,14 @@ public class CLTPass3d{
superTiles = null; superTiles = null;
} }
public boolean [] getSelected(){ public boolean [] getSelected(){
return selected; return selected;
} }
public void setSelected (boolean [] selected) {
this.selected = selected;
}
public void fixNaNDisparity() public void fixNaNDisparity()
{ {
......
This diff is collapsed.
...@@ -507,6 +507,7 @@ private Panel panel1, ...@@ -507,6 +507,7 @@ private Panel panel1,
addButton("CLT reset 3D", panelClt1, color_stop); addButton("CLT reset 3D", panelClt1, color_stop);
addButton("CLT 3D", panelClt1, color_conf_process); addButton("CLT 3D", panelClt1, color_conf_process);
addButton("CLT planes", panelClt1, color_conf_process); addButton("CLT planes", panelClt1, color_conf_process);
addButton("CLT OUT 3D", panelClt1, color_process);
add(panelClt1); add(panelClt1);
} }
...@@ -4756,6 +4757,9 @@ private Panel panel1, ...@@ -4756,6 +4757,9 @@ private Panel panel1,
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) { if (configPath!=null) {
saveTimestampedProperties( // save config again saveTimestampedProperties( // save config again
configPath, // full path or null configPath, // full path or null
...@@ -4772,14 +4776,88 @@ private Panel panel1, ...@@ -4772,14 +4776,88 @@ private Panel panel1,
System.out.println("QUAD_CLT is null, nothing to show"); System.out.println("QUAD_CLT is null, nothing to show");
return; return;
} }
//"CLT planes"
QUAD_CLT.showCLTPlanes( QUAD_CLT.showCLTPlanes(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
return; return;
} else if (label.equals("CLT OUT 3D")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
System.out.println("QUAD_CLT is null, nothing to show (will add previous steps)");
return;
}
String configPath=null;
if (EYESIS_CORRECTIONS.correctionsParameters.saveSettings) {
configPath=EYESIS_CORRECTIONS.correctionsParameters.selectResultsDirectory(
true,
true);
if (configPath==null){
String msg="No results directory selected, command aborted";
System.out.println("Warning: "+msg);
IJ.showMessage("Warning",msg);
return;
}
configPath+=Prefs.getFileSeparator()+"autoconfig";
try {
saveTimestampedProperties(
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
} catch (Exception e){
String msg="Failed to save configuration to "+configPath+", command aborted";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
return;
}
}
/*
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
*/
boolean OK = QUAD_CLT.output3d(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
if (!OK) {
String msg="Image data not initialized, run 'CLT 3D' command first";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
}
/*
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
*/
return;
// //
// End of buttons code // End of buttons code
} }
......
...@@ -51,6 +51,9 @@ public class QuadCLT { ...@@ -51,6 +51,9 @@ public class QuadCLT {
public double [][][] fine_corr = new double [4][2][6]; // per port, per x/y, set of 6 coefficient for fine geometric corrections public double [][][] fine_corr = new double [4][2][6]; // per port, per x/y, set of 6 coefficient for fine geometric corrections
TileProcessor tp = null; TileProcessor tp = null;
String image_name = null;
double [][][] image_data = null;
// magic scale should be set before using TileProcessor (calculated disparities depend on it) // magic scale should be set before using TileProcessor (calculated disparities depend on it)
...@@ -4474,6 +4477,30 @@ public class QuadCLT { ...@@ -4474,6 +4477,30 @@ public class QuadCLT {
} }
tp.showPlanes( tp.showPlanes(
clt_parameters, clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
debugLevel);
// CLTPass3d last_scan = tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1); // get last one
}
public void out3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
if (tp == null){
System.out.println("showCLTPlanes(): tp is null");
return;
}
if (tp.clt_3d_passes == null){
System.out.println("showCLTPlanes(): tp.clt_3d_passes is null");
return;
}
tp.showPlanes(
clt_parameters,
geometryCorrection,
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -4683,7 +4710,7 @@ public class QuadCLT { ...@@ -4683,7 +4710,7 @@ public class QuadCLT {
clt_parameters.colors_equalize, clt_parameters.colors_equalize,
channelFiles, channelFiles,
imp_srcs, imp_srcs,
setNames.get(nSet), // just for debug messeges == setNames.get(nSet) setNames.get(nSet), // just for debug messages == setNames.get(nSet)
debugLevel); debugLevel);
} }
// once per quad here // once per quad here
...@@ -4740,6 +4767,11 @@ public class QuadCLT { ...@@ -4740,6 +4767,11 @@ public class QuadCLT {
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
clt_parameters, clt_parameters,
threadsMax); threadsMax);
this.image_name = name;
this.image_data = image_data;
tp.resetCLTPasses(); tp.resetCLTPasses();
tp.setTrustedCorrelation(clt_parameters.grow_disp_trust); tp.setTrustedCorrelation(clt_parameters.grow_disp_trust);
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
...@@ -5083,16 +5115,20 @@ public class QuadCLT { ...@@ -5083,16 +5115,20 @@ public class QuadCLT {
geometryCorrection, geometryCorrection,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
2); // debugLevel); 0); // 2); // debugLevel);
// get images for predefined regions and disparities. First - with just fixed scans 1 .. list.size() // get images for predefined regions and disparities. First - with just fixed scans 1 .. list.size()
// TEMPORARY EXIT // TEMPORARY EXIT
if (tp.clt_3d_passes.size() > 0) { // Save tp.clt_3d_passes.size() to roll back without restarting the program
System.out.println("-------- temporary exit after secondPassSetup() ------- "); tp.saveCLTPasses();
return null; // just to fool compiler
}
if (tp.clt_3d_passes.size() > 0) {
System.out.println("-------- temporary exit after secondPassSetup() ------- ");
return null; // just to fool compiler
}
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan, tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
...@@ -5206,6 +5242,167 @@ public class QuadCLT { ...@@ -5206,6 +5242,167 @@ public class QuadCLT {
return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name"); return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// public ImagePlus output3d(
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (this.image_data == null){
return false;
}
tp.trimCLTPasses(); // make possible to run this method multiple time - remove extra passes added by it last time
int next_pass = tp.clt_3d_passes.size(); //
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass2-"+(next_pass-1)); //String title)
tp.thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
clt_parameters,
clt_parameters.bgnd_range, // double disparity_far,
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
geometryCorrection,
threadsMax, // maximal number of threads to launch
updateStatus,
0); // final int debugLevel)
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass3-"+(next_pass-1)); //String title)
// create x3d file
X3dOutput x3dOutput = new X3dOutput(
clt_parameters,
correctionsParameters,
geometryCorrection,
tp.clt_3d_passes);
x3dOutput.generateBackground();
String x3d_path= correctionsParameters.selectX3dDirectory(
true, // smart,
true); //newAllowed, // save
for (int scanIndex = next_pass; scanIndex < tp.clt_3d_passes.size(); scanIndex++){
if (debugLevel > 0){
System.out.println("FPGA processing scan #"+scanIndex);
}
CLTPass3d scan = CLTMeasure( // perform single pass according to prepared tiles operations and disparity
image_data, // first index - number of image in a quad
clt_parameters,
scanIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
/**
if ((scanIndex == 49) || (scanIndex == 54) ) tp.showScan(
scan, // tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"MEASURED-"+scanIndex);
*/
}
// TEMPORARY EXIT
// if (tp.clt_3d_passes.size() > 0) return null; // just to fool compiler
// int scan_limit = 10;
for (int scanIndex = next_pass; (scanIndex < tp.clt_3d_passes.size()) && (scanIndex < clt_parameters.max_clusters); scanIndex++){ // just temporary limiting
if (debugLevel > -1){
System.out.println("Generating cluster images (limit is set to "+clt_parameters.max_clusters+") largest, scan #"+scanIndex);
}
// ImagePlus cluster_image = getPassImage( // get image form a single pass
String texturePath = getPassImage( // get image from a single pass
clt_parameters,
colorProcParameters,
rgbParameters,
this.image_name+"-img"+scanIndex,
scanIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
if ((scanIndex == 73) ) {
tp.showScan(
tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"SELECTED-"+scanIndex);
}
// TODO: use new updated disparity, for now just what was forced for the picture
double [] scan_disparity = new double [tilesX * tilesY];
int indx = 0;
// boolean [] scan_selected = scan.getSelected();
for (int ty = 0; ty < tilesY; ty ++) for (int tx = 0; tx < tilesX; tx ++){
// scan_selected[indx] = scan.tile_op[ty][tx] != 0;
scan_disparity[indx++] = scan.disparity[ty][tx];
}
if (clt_parameters.avg_cluster_disp){
double sw = 0.0, sdw = 0.0;
for (int i = 0; i< scan_disparity.length; i++){
if (scan.selected[i] && !scan.border_tiles[i]){
double w = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][i];
sw +=w;
sdw += scan_disparity[i]*w;
}
}
sdw/=sw;
for (int i = 0; i< scan_disparity.length; i++){
scan_disparity[i] = sdw;
}
}
if ((scanIndex == 73)) {
tp.showScan(
tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"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 == 49) || (scanIndex == 54);
generateClusterX3d(
x3dOutput,
texturePath,
scan.bounds,
scan.selected,
scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
clt_parameters.transform_size,
clt_parameters.correct_distortions, // requires backdrop image to be corrected also
showTri, // (scanIndex < next_pass + 1) && clt_parameters.show_triangles,
clt_parameters.bgnd_range, // 0.3
clt_parameters.grow_disp_max, // other_range, // 2.0 'other_range - difference from the specified (*_CM)
clt_parameters.maxDispTriangle);
}
// now generate and save texture files (start with full, later use bounding rectangle?)
if (x3d_path != null){
x3d_path+=Prefs.getFileSeparator()+this.image_name+".x3d";
x3dOutput.generateX3D(x3d_path);
}
return true;
// return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
}
//*****************************************************************
public void generateClusterX3d( public void generateClusterX3d(
X3dOutput x3dOutput, X3dOutput x3dOutput,
String texturePath, String texturePath,
......
This diff is collapsed.
...@@ -764,10 +764,10 @@ public class TilePlanes { ...@@ -764,10 +764,10 @@ public class TilePlanes {
// double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile // double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
// double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2]; // double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2];
double [] px_py = getCenterPxPy(); double [] px_py = getCenterPxPy();
if ((px_py[0] == 1760) && (px_py[1] == 1056)){ // 27, 15 // if ((px_py[0] == 1760) && (px_py[1] == 1056)){ // 27, 15
System.out.println("getWorldXYZ, px_py = {"+px_py[0]+","+px_py[1]+"}"); // System.out.println("getWorldXYZ, px_py = {"+px_py[0]+","+px_py[1]+"}");
debugLevel = 2; // debugLevel = 2;
} // }
double px = px_py[0] + zxy[1]; double px = px_py[0] + zxy[1];
double py = px_py[1] + zxy[2]; double py = px_py[1] + zxy[2];
...@@ -780,6 +780,10 @@ public class TilePlanes { ...@@ -780,6 +780,10 @@ public class TilePlanes {
Matrix xyz = new Matrix(center_xyz, 3); // column matrix Matrix xyz = new Matrix(center_xyz, 3); // column matrix
Matrix dpxpy = new Matrix(vectors[0],3); // 3 rows, 1 column Matrix dpxpy = new Matrix(vectors[0],3); // 3 rows, 1 column
if (debugLevel > 0){ if (debugLevel > 0){
// if (sTileXY[0] == 27 ){
// System.out.println("STOP");
//
// }
System.out.println("getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"), correctDistortions="+correctDistortions+", xyz= {"+ System.out.println("getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"), correctDistortions="+correctDistortions+", xyz= {"+
xyz.get(0, 0)+","+xyz.get(1, 0)+","+xyz.get(2, 0)+"}, weight = "+getWeight()); xyz.get(0, 0)+","+xyz.get(1, 0)+","+xyz.get(2, 0)+"}, weight = "+getWeight());
// xyz.print(10, 6); // w,d // xyz.print(10, 6); // w,d
...@@ -842,7 +846,7 @@ public class TilePlanes { ...@@ -842,7 +846,7 @@ public class TilePlanes {
} }
norm_xyz.timesEquals(1.0/norm_xyz.normF()); // unity normal vector; norm_xyz.timesEquals(1.0/norm_xyz.normF()); // unity normal vector;
if (debugLevel > 0){ if (debugLevel > 1){
System.out.println("+getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"): unit plane normal={"+ System.out.println("+getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"): unit plane normal={"+
norm_xyz.get(0, 0)+", "+norm_xyz.get(1, 0)+", "+norm_xyz.get(2, 0)+"})"); norm_xyz.get(0, 0)+", "+norm_xyz.get(1, 0)+", "+norm_xyz.get(2, 0)+"})");
double dotprod = xyz.transpose().times(norm_xyz).get(0,0); double dotprod = xyz.transpose().times(norm_xyz).get(0,0);
...@@ -1070,7 +1074,7 @@ public class TilePlanes { ...@@ -1070,7 +1074,7 @@ public class TilePlanes {
int numRemoved = 0; int numRemoved = 0;
for (; (pd.getValue() > targetEigen) && (numRemoved < maxRemoved); numRemoved++){ for (; (pd.getValue() > targetEigen) && (numRemoved < maxRemoved); numRemoved++){
if (debugLevel > 2){ if (debugLevel > 2){
System.out.println("removePlaneOutliers(): numRemoved = "+numRemoved+" eigenValue = "+pd.getValue()+" target = "+targetEigen); System.out.println("removePlaneOutliers("+sTileXY[0]+":"+sTileXY[1]+"): numRemoved = "+numRemoved+" eigenValue = "+pd.getValue()+" target = "+targetEigen);
} }
// make a plane and find the worst (largest disparity difference) tile // make a plane and find the worst (largest disparity difference) tile
// z = -(x*Vx + y*Vy)/Vz // z = -(x*Vx + y*Vy)/Vz
......
This diff is collapsed.
...@@ -160,10 +160,11 @@ public class X3dOutput { ...@@ -160,10 +160,11 @@ public class X3dOutput {
Element el_appearance = x3dDoc.createElement("Appearance"); Element el_appearance = x3dDoc.createElement("Appearance");
el_shape.appendChild(el_appearance); el_shape.appendChild(el_appearance);
/*
Element el_material = x3dDoc.createElement("Material"); Element el_material = x3dDoc.createElement("Material");
el_appearance.appendChild(el_material); el_appearance.appendChild(el_material);
el_material.setAttribute("diffuseColor", "0.376471 0.5 0.376471"); el_material.setAttribute("diffuseColor", "0.376471 0.5 0.376471");
*/
Element el_imageTexture = x3dDoc.createElement("ImageTexture"); Element el_imageTexture = x3dDoc.createElement("ImageTexture");
el_imageTexture.setAttribute("url",url); el_imageTexture.setAttribute("url",url);
...@@ -182,8 +183,6 @@ public class X3dOutput { ...@@ -182,8 +183,6 @@ public class X3dOutput {
el_texCoordinate.setAttribute("point", stcoord); el_texCoordinate.setAttribute("point", stcoord);
el_IFC.appendChild(el_texCoordinate); el_IFC.appendChild(el_texCoordinate);
} }
......
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