Commit 7364fa88 authored by Andrey Filippov's avatar Andrey Filippov

debugging/untested

parent 69e30a31
......@@ -2662,7 +2662,7 @@ public class CuasMotion {
* @param targets - targets for a single keyframe
* @return
*/
public double [][][] targetPxPyD(
public double [][][] targetPxPyD_old(
final double [][] targets) {
final int half_accum_range = getSeqLength()/2;
final int num_tiles = tilesX * tilesY;
......@@ -2702,6 +2702,84 @@ public class CuasMotion {
return pXpYDs;
}
public double [][][] targetPxPyD( // original
final double [][] targets) {
final int half_accum_range = getSeqLength()/2;
final int num_tiles = tilesX * tilesY;
final int tileSize = GPUTileProcessor.DTT_SIZE;
final double [][][] pXpYDs = new double [2* half_accum_range +1][num_tiles][];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] pXpYD = new double [3];
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (targets[nTile] != null) {
double [] target = targets[nTile];
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
double xc = tileSize * tileX + tileSize/2;
double yc = tileSize * tileY + tileSize/2;
double xtk = xc + target[CuasMotionLMA.RSLT_X];
double ytk = yc + target[CuasMotionLMA.RSLT_Y];
double vx = target[CuasMotionLMA.RSLT_VX]/corr_offset;
double vy = target[CuasMotionLMA.RSLT_VY]/corr_offset;
double disp = target[CuasMotionLMA.RSLT_DISPARITY];
if (Double.isNaN(disp)) {
disp = 0.0;
}
pXpYD[2] = disp;
for (int dseq = -half_accum_range; dseq <= half_accum_range; dseq++) {
pXpYD[0] = xtk + vx * dseq;
pXpYD[1] = ytk + vy * dseq;
pXpYDs[dseq + half_accum_range][nTile] = pXpYD.clone();
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return pXpYDs;
}
public double [][][] targetPxPyDSingleTile(
final double [][] targets,
final int ntile,
final double disparity,
final int first_offs,
final int last_offs) {
final int num_tiles = tilesX * tilesY;
final int tileSize = GPUTileProcessor.DTT_SIZE;
final double [][][] pXpYDs = new double [last_offs-first_offs +1][num_tiles][];
final double [] pXpYD = new double [3];
double [] target = targets[ntile];
if (target != null) {
int tileY = ntile / tilesX;
int tileX = ntile % tilesX;
double xc = tileSize * tileX + tileSize/2;
double yc = tileSize * tileY + tileSize/2;
double xtk = xc + target[CuasMotionLMA.RSLT_X];
double ytk = yc + target[CuasMotionLMA.RSLT_Y];
double vx = target[CuasMotionLMA.RSLT_VX]/corr_offset;
double vy = target[CuasMotionLMA.RSLT_VY]/corr_offset;
double disp = disparity; // target[CuasMotionLMA.RSLT_DISPARITY];
if (Double.isNaN(disp)) {
disp = 0.0;
}
pXpYD[2] = disp;
for (int dseq = first_offs; dseq <= last_offs; dseq++) {
pXpYD[0] = xtk + vx * dseq;
pXpYD[1] = ytk + vy * dseq;
pXpYDs[dseq - first_offs][ntile] = pXpYD.clone();
}
} else {
System.out.println ("targetPxPyDSingleTile(): BUG targets["+ntile+"] == null");
}
return pXpYDs;
}
public ImagePlus showPxPyDs(
double [][][] pXpYDs,
int nseq, // center
......
......@@ -1008,6 +1008,7 @@ public class ImageDtt extends ImageDttCPU {
}
// // FIXME: will not work with combining pairs !!!
// final int num_pairs = Correlation2d.getNumPairs(numSensors);
return;
}
/**
......@@ -3527,8 +3528,8 @@ public class ImageDtt extends ImageDttCPU {
dbg_s+="\n";
}
dbg_s += " image_dtt "+tileX+":"+tileY+" ("+(tileX+tilesX*tileY)+") <"+nmax+"> ";
for (int i = 0; i < dispStrs[0][0].length; i++) {
dbg_s+=" "+dispStrs[0][0][i];
for (int i = 0; i < dispStrs[nmax][0].length; i++) {
dbg_s+=" "+dispStrs[nmax][0][i];
}
}
System.out.println(dbg_s);
......
......@@ -900,7 +900,9 @@ min_str_neib_fpn 0.35
public double cuas_initial_disparity = 1.0; // Start correlation with this disparity (in addition to infinity) after reset
public double cuas_infinity = 0.63; // disparity at infinity for targets
public boolean cuas_rng_img = false; // Generate/save per-sensor target images
public boolean cuas_rng_img = false; // Generate/save per-sensor target images
public boolean cuas_rng_glob= true; // Generate/save integrated target disparities (one per target) TODO: add first/second half
public int cuas_glob_ends = 0; // 0 - same as internal, 1 - cosine extended ends, 2 - rectangular extended ends // make a parameter
public boolean cuas_rng_disp= true; // Generate/save target disparities
public boolean cuas_rng_vfy= false; // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
......@@ -2627,7 +2629,7 @@ min_str_neib_fpn 0.35
"Image pixel Y corresponding to the known elevation.");
gd.addNumericField("Known pixel azimuth", this.cuas_az0, 5,8,"degree",
"Azimuth corresponding to the known pixel X.");
gd.addNumericField("Known pixel azimuth", this.cuas_el0, 5,8,"degree",
gd.addNumericField("Known pixel elevation", this.cuas_el0, 5,8,"degree",
"Elevation corresponding to the known pixel Y.");
gd.addCheckbox ("Show target disparity", this.cuas_show_disp,
"Show disparity before infinity correction (not in clean mode).");
......@@ -2703,6 +2705,10 @@ min_str_neib_fpn 0.35
gd.addCheckbox ("Generate/save per-sensor target images", this.cuas_rng_img,
"Generate/save per-sensor images using same data as for ranging.");
gd.addCheckbox("Generate/save target integrated disparities",this.cuas_rng_glob,
"Generate/save integrated target disparities (one per target), average for all scenes.");
gd.addNumericField("Ends integration mode", this.cuas_glob_ends, 0,3,"",
"0 - same as internal, 1 - cosine extended ends, 2 - rectangular extended ends.");
gd.addCheckbox ("Generate/save target disparities", this.cuas_rng_disp,
"Measure per-target, per key-frame disparity and save it in target structures.");
gd.addCheckbox ("Ranging verification images", this.cuas_rng_vfy,
......@@ -3903,6 +3909,8 @@ min_str_neib_fpn 0.35
this.cuas_infinity = gd.getNextNumber();
this.cuas_rng_img = gd.getNextBoolean();
this.cuas_rng_glob = gd.getNextBoolean();
this.cuas_glob_ends = (int) gd.getNextNumber();
this.cuas_rng_disp = gd.getNextBoolean();
this.cuas_rng_vfy = gd.getNextBoolean();
this.cuas_rng_niterate = (int) gd.getNextNumber();
......@@ -4988,6 +4996,8 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_infinity", this.cuas_infinity+""); // double
properties.setProperty(prefix+"cuas_rng_img", this.cuas_rng_img+""); // boolean
properties.setProperty(prefix+"cuas_rng_glob", this.cuas_rng_glob+""); // boolean
properties.setProperty(prefix+"cuas_glob_ends", this.cuas_glob_ends+""); // int
properties.setProperty(prefix+"cuas_rng_disp", this.cuas_rng_disp+""); // boolean
properties.setProperty(prefix+"cuas_rng_vfy", this.cuas_rng_vfy+""); // boolean
properties.setProperty(prefix+"cuas_rng_niterate", this.cuas_rng_niterate+""); // int
......@@ -6050,6 +6060,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_infinity")!=null) this.cuas_infinity=Double.parseDouble(properties.getProperty(prefix+"cuas_infinity"));
if (properties.getProperty(prefix+"cuas_rng_img")!=null) this.cuas_rng_img=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_rng_img"));
if (properties.getProperty(prefix+"cuas_rng_glob")!=null) this.cuas_rng_glob=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_rng_glob"));
if (properties.getProperty(prefix+"cuas_glob_ends")!=null) this.cuas_glob_ends=Integer.parseInt(properties.getProperty(prefix+"cuas_glob_ends"));
if (properties.getProperty(prefix+"cuas_rng_disp")!=null) this.cuas_rng_disp=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_rng_disp"));
if (properties.getProperty(prefix+"cuas_rng_vfy")!=null) this.cuas_rng_vfy=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_rng_vfy"));
if (properties.getProperty(prefix+"cuas_rng_niterate")!=null) this.cuas_rng_niterate=Integer.parseInt(properties.getProperty(prefix+"cuas_rng_niterate"));
......@@ -7099,10 +7111,12 @@ min_str_neib_fpn 0.35
imp.cuas_infinity = this.cuas_infinity;
imp.cuas_rng_img = this.cuas_rng_img;
imp.cuas_rng_glob = this.cuas_rng_glob;
imp.cuas_rng_niterate = this.cuas_rng_niterate;
imp.cuas_rng_disp = this.cuas_rng_disp;
imp.cuas_rng_vfy = this.cuas_rng_vfy;
imp.cuas_rng_niterate = this.cuas_rng_niterate;
imp.cuas_glob_ends = this.cuas_glob_ends;
imp.cuas_rng_diff = this.cuas_rng_diff;
imp.cuas_debug = this.cuas_debug;
......
......@@ -14305,6 +14305,47 @@ public class OpticalFlow {
ImageDtt.startAndJoin(threads);
}
public static void accumulateCorrelations(
double weight,
float [] num_acc, // number of accumulated tiles [pair]
float [][] fcorr_td, // [pair][256] sparse transform domain representation of corr pairs
float [][] fcorr_td_acc // [pair][256] sparse transform domain representation of corr pairs // should not be null, same length as fcorr_td
) {
int tX=-1;
for (int ity = 0; ity < fcorr_td.length; ity++) if (fcorr_td[ity] != null){
tX = fcorr_td[ity].length;
break;
}
final int tilesY = fcorr_td.length;
final int tilesX = tX;
final int tiles = tilesY * tilesX;
if (fcorr_td != null) {
/*
if (fcorr_td_acc == null) {
fcorr_td_acc = new float [fcorr_td.length][];
}
*/
for (int pair = 0; pair < fcorr_td.length; pair++) if (fcorr_td [pair] != null){
if (fcorr_td_acc[pair] == null) {
fcorr_td_acc[pair] = fcorr_td[pair].clone();
} else {
for (int i = 0; i < fcorr_td[pair].length; i++) {
fcorr_td_acc[pair][i] += fcorr_td[pair][i];
}
}
num_acc[pair] += weight;
}
}
return;
}
public static void accumulateCorrelations( // normalize
final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
final double [][][][][] dcorr_td_acc) { // [pair][tilesY][tilesX][4][64] sparse transform domain representation of corr pairs
......
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