Commit b771650e authored by Andrey Filippov's avatar Andrey Filippov

testing/bug fixing

parent 046d8eb3
......@@ -4,4 +4,5 @@
/target/
*.backup
NC393I
attic
\ No newline at end of file
attic
*.log
\ No newline at end of file
......@@ -53,11 +53,11 @@ public class AlignmentCorrection {
}
public double [][][] infinityCorrection(
final double min_strength_in,
final double max_diff,
final int max_iterations,
final double max_coeff_diff,
final double far_pull, // = 0.2; // 1; // 0.5;
final double min_strength_in,
final double max_diff,
final int max_iterations,
final double max_coeff_diff,
final double far_pull, // = 0.2; // 1; // 0.5;
final double strength_pow,
final int smplSide, // = 2; // Sample size (side of a square)
final int smplNum, // = 3; // Number after removing worst (should be >1)
......
......@@ -27,9 +27,11 @@ import java.awt.Rectangle;
import java.util.concurrent.atomic.AtomicInteger;
public class CLTPass3d{
public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX]
public int [][] tile_op; // what was done in the current pass
public double [][] disparity_map = null; // add 4 layers - worst difference for the port
public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX]
public int [][] tile_op; // what was done in the current pass
private double [][] disparity_sav; // saved disaprity
private int [][] tile_op_sav; // saved tile_op
public double [][] disparity_map = null; // add 4 layers - worst difference for the port
double [] calc_disparity = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
// using horizontal features and corr_magic_scale
// used directly in TileProcessor.compositeScan()
......@@ -55,7 +57,7 @@ public class CLTPass3d{
public boolean is_combo = false;
public boolean is_measured = false;
public String texture = null; // relative (to x3d) path
public Rectangle bounds;
public Rectangle texture_bounds;
public int dbg_index;
public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY
......@@ -133,6 +135,9 @@ public class CLTPass3d{
return "null-texture-name";
}
}
// Will not work if texture is disabled
public void updateSelection(){ // add updating border tiles?
int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY();
......@@ -149,7 +154,11 @@ public class CLTPass3d{
selected[ty * tilesX + tx] = false; // may be omitted
}
}
bounds = new Rectangle(minX, minY, maxX - minX +1, maxY - minY +1 );
texture_bounds = new Rectangle(minX, minY, maxX - minX +1, maxY - minY +1 );
}
public Rectangle getTextureBounds(){
return texture_bounds;
}
public boolean isProcessed(){
......@@ -219,7 +228,11 @@ public class CLTPass3d{
public void setSelected (boolean [] selected) {
this.selected = selected;
}
public void setBorderTiles (boolean [] border_tiles) {
this.border_tiles = border_tiles;
}
public void fixNaNDisparity()
{
fixNaNDisparity(
......@@ -648,6 +661,65 @@ public class CLTPass3d{
return measured;
}
public void saveTileOpDisparity()
{
disparity_sav =disparity.clone();
for (int i = 0; i < disparity.length; i++ ) if (disparity[i]!= null) disparity_sav[i] = disparity[i].clone();
tile_op_sav =tile_op.clone();
for (int i = 0; i < tile_op.length; i++ ) if (tile_op[i]!= null) tile_op_sav[i] = tile_op[i].clone();
}
public void restoreTileOpDisparity()
{
disparity = disparity_sav;
tile_op = tile_op_sav;
}
public void restoreKeepTileOpDisparity()
{
restoreTileOpDisparity();
saveTileOpDisparity();
}
public int setTileOpDisparity(
boolean [] selection,
double [] disparity)
{
int op = ImageDtt.setImgMask(0, 0xf);
op = ImageDtt.setPairMask(op,0xf);
op = ImageDtt.setForcedDisparity(op,true);
return setTileOpDisparity(
op, // int tile_op,
selection, // boolean [] selection,
disparity); // double [] disparity)
}
public int setTileOpDisparity(
int tile_op,
boolean [] selection,
double [] disparity)
{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
this.disparity = new double [tilesY][tilesX];
this.tile_op = new int [tilesY][tilesX];
int num_op_tiles = 0;
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
if (this.selected[indx]) {
this.disparity[ty][tx] = disparity[indx];
this.tile_op[ty][tx] = tile_op;
num_op_tiles ++;
} else {
this.disparity[ty][tx] = 0.0;
this.tile_op[ty][tx] = 0;
}
}
return num_op_tiles;
}
public double [] getSecondMaxDiff (
final boolean averaged)
......
This diff is collapsed.
......@@ -1002,7 +1002,8 @@ public class ImageDtt {
final int transform_size,
final int window_type,
final double [][] shiftXY, // [port]{shiftX,shiftY}
final double [][][] fine_corr, // quadratic cofficients for fine correction (or null)
final double disparity_corr, // disparity at infinity
final double [][][] fine_corr, // quadratic coefficients for fine correction (or null)
final double corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
final double shiftX, // shift image horizontally (positive - right) - just for testing
final double shiftY, // shift image vertically (positive - down)
......@@ -1030,6 +1031,9 @@ public class ImageDtt {
final int corr_size = transform_size * 2 -1;
final int [][] transpose_indices = new int [corr_size*(corr_size-1)/2][2];
int indx = 0;
if (disparity_corr != 0.0){
System.out.println(String.format("Using manual infinity disparity correction of %8.5f pixels",disparity_corr));
}
for (int i =0; i < corr_size-1; i++){
for (int j = i+1; j < corr_size; j++){
transpose_indices[indx ][0] = i * corr_size + j;
......@@ -1183,7 +1187,7 @@ public class ImageDtt {
double [][] centersXY = geometryCorrection.getPortsCoordinates(
centerX,
centerY,
disparity_array[tileY][tileX]);
disparity_array[tileY][tileX] + disparity_corr);
if ((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)) {
for (int i = 0; i < quad; i++) {
System.out.println("clt_aberrations_quad_corr(): color="+chn+", tileX="+tileX+", tileY="+tileY+
......
......@@ -2674,33 +2674,33 @@ public class LinkPlanes {
System.out.println("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs:");
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs weighted: ");
for (int i = 0; i < costs[0].length;i++) {
if ( costs[0] != null) for (int i = 0; i < costs[0].length;i++) {
System.out.print(costs[0][i]+" ");
}
System.out.println();
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs equalized: ");
for (int i = 0; i < costs[1].length;i++) {
if ( costs[1] != null) for (int i = 0; i < costs[1].length;i++) {
System.out.print(costs[1][i]+" ");
}
System.out.println();
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs weighted, 1-st star, 2-nd measured: ");
for (int i = 0; i < costs[2].length;i++) {
if ( costs[2] != null) for (int i = 0; i < costs[2].length;i++) {
System.out.print(costs[2][i]+" ");
}
System.out.println();
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs equalized, 1-st star, 2-nd measured: ");
for (int i = 0; i < costs[3].length;i++) {
if ( costs[3] != null) for (int i = 0; i < costs[3].length;i++) {
System.out.print(costs[3][i]+" ");
}
System.out.println();
System.out.println();
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs weighted, 1-st measured, 2-nd star: ");
for (int i = 0; i < costs[4].length;i++) {
if ( costs[4] != null) for (int i = 0; i < costs[4].length;i++) {
System.out.print(costs[4][i]+" ");
}
System.out.println();
System.out.print("costSameTileConnections(): nsTile="+nsTile0+":"+np1+":"+np2+" costs equalized, 1-st measured, 2-nd star: ");
for (int i = 0; i < costs[5].length;i++) {
if ( costs[5] != null) for (int i = 0; i < costs[5].length;i++) {
System.out.print(costs[5][i]+" ");
}
System.out.println();
......
......@@ -584,7 +584,7 @@ public class MeasuredLayers {
* @return double [2][4*superTileSize] {disparity[4*superTileSize], strength [4*superTileSize]}
*/
public double[][] getDisparityStrength (
public double[][] getDisparityStrengthML (
int num_layer,
int stX,
int stY,
......@@ -638,7 +638,7 @@ public class MeasuredLayers {
* @return double {disparity[tilesX * tilesY], strength[tilesX * tilesY]}
*/
public double[][] getDisparityStrength (
public double[][] getDisparityStrengthML (
int num_layer,
double strength_floor,
double strength_pow)
......@@ -750,7 +750,7 @@ public class MeasuredLayers {
for (int dx = 0; dx < st2; dx ++){
int indx = dy * st2 + dx;
if (indx == dbg_tile){
System.out.println("getDisparityStrength(): stX="+stX+" stY="+stY+" dx="+dx+" dy="+dy);
System.out.println("getDisparityStrengthML(): stX="+stX+" stY="+stY+" dx="+dx+" dy="+dy);
}
if (((sel_in == null) || sel_in[indx])){
int num_in_sample = 0;
......@@ -796,7 +796,7 @@ public class MeasuredLayers {
}
}
if (iworst < 0){
System.out.println("**** this is a BUG in getDisparityStrength() ****");
System.out.println("**** this is a BUG in getDisparityStrengthML() ****");
break;
}
// remove worst sample
......@@ -820,7 +820,7 @@ public class MeasuredLayers {
}
} else {
num_in_sample = 0;
System.out.println("**** this is a BUG in getDisparityStrength(), shoud not happen ? ****");
System.out.println("**** this is a BUG in getDisparityStrengthML(), shoud not happen ? ****");
}
}
}
......@@ -884,7 +884,7 @@ public class MeasuredLayers {
}
// testing - redirecting all existing requests to this one with floating planes
public double[][] getDisparityStrength (
public double[][] getDisparityStrengthMLTilted (
int num_layer,
int stX,
int stY,
......@@ -895,13 +895,14 @@ public class MeasuredLayers {
int smplNum, // = 3; // Number after removing worst (should be >1)
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, //
double damp_tilt, //
boolean null_if_none,
int debugLevel)
{
boolean use_new = true; // false;
if (use_new) {
return getDisparityStrength (
return getDisparityStrengthMLTilted (
num_layer, // int num_layer,
stX, // int stX,
stY, // int stY,
......@@ -915,6 +916,7 @@ public class MeasuredLayers {
smplWnd, // boolean smplWnd, //
2.0, // double max_abs_tilt, // = 2.0; // pix per tile
0.2, // double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
damp_tilt, // double damp_tilt, //
null_if_none, // boolean null_if_none,
debugLevel); // int debugLevel)
} else {
......@@ -938,7 +940,7 @@ public class MeasuredLayers {
}
}
public double[][] getDisparityStrength (
public double[][] getDisparityStrengthMLTilted (
int num_layer,
int stX,
int stY,
......@@ -954,6 +956,7 @@ public class MeasuredLayers {
boolean smplWnd, //
double max_abs_tilt, // = 2.0; // pix per tile
double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
double damp_tilt, //
boolean null_if_none,
int debugLevel)
{
......@@ -961,6 +964,8 @@ public class MeasuredLayers {
if ((layers[num_layer] == null) && null_if_none){
return null;
}
final double [] damping = {damp_tilt, damp_tilt, 0.0}; // 0.0 will be applied to average value, tilt_cost - to both tilts
int st2 = 2 * superTileSize;
int st_half = superTileSize/2;
double [][] ds = new double [2][st2*st2];
......@@ -1015,7 +1020,7 @@ public class MeasuredLayers {
for (int dx = 0; dx < st2; dx ++){
int indx = dy * st2 + dx;
if (indx == dbg_tile){
System.out.println("getDisparityStrength(): stX="+stX+" stY="+stY+" dx="+dx+" dy="+dy);
System.out.println("getDisparityStrengthML(): stX="+stX+" stY="+stY+" dx="+dx+" dy="+dy);
}
if (((sel_in == null) || sel_in[indx])){
int num_in_sample = 0;
......@@ -1044,7 +1049,7 @@ public class MeasuredLayers {
{
boolean en_tilt = (atiltXY == null);
if (en_tilt) { // make sure there are enough samples and not all of them are on the same line
if (!notColinear(smpl_sel,smplSide)){
if ((damp_tilt == 0.0) && !notColinear(smpl_sel,smplSide)){
en_tilt = false;
}
}
......@@ -1077,12 +1082,13 @@ public class MeasuredLayers {
double[][] approx2d = pa.quadraticApproximation(
mdata,
true, // boolean forceLinear, // use linear approximation
damping, // double [] damping,
thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
thresholdQuad, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
debugLevel);
if (approx2d == null){
if (debugLevel > -1){
System.out.println("getDisparityStrength(): can not find linear approximation");
System.out.println("getDisparityStrengthML(): can not find linear approximation");
}
break sample_loop;
}
......@@ -1142,7 +1148,7 @@ public class MeasuredLayers {
double d2 = smpl_d[indxs] - smpl_p[indxs];
d2 *=d2;
if (d2 > dworst2) {
if (notColinearWithout (
if ((damp_tilt !=0.0) || notColinearWithout (
indxs, // int indx,
smpl_sel, // boolean [] sel,
smplSide)) { // int side))
......@@ -1153,7 +1159,7 @@ public class MeasuredLayers {
}
if (iworst < 0){
if (debugLevel > 0) {
System.out.println("**** this may be BUG in getDisparityStrength() can not find the worst sample - all tiles fit perfectly ****");
System.out.println("**** this may be BUG in getDisparityStrengthML() can not find the worst sample - all tiles fit perfectly ****");
}
// this can happen if some samples are the same and all the pixels fit exactly - use all of them
break;
......@@ -1228,7 +1234,7 @@ public class MeasuredLayers {
}
}
if (iworst < 0){
System.out.println("**** this is a BUG in getDisparityStrength() ****");
System.out.println("**** this is a BUG in getDisparityStrengthML() ****");
break;
}
// remove worst sample
......@@ -1252,7 +1258,7 @@ public class MeasuredLayers {
}
} else {
num_in_sample = 0;
System.out.println("**** this is a BUG in getDisparityStrength(), shoud not happen ? ****");
System.out.println("**** this is a BUG in getDisparityStrengthML(), shoud not happen ? ****");
}
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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