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
......
......@@ -63,6 +63,7 @@ public class CuasRanging {
double rng_blur = clt_parameters.imp.cuas_rng_blur;
boolean rng_img = clt_parameters.imp.cuas_rng_img;
boolean rng_glob = clt_parameters.imp.cuas_rng_glob;
boolean rng_disp = clt_parameters.imp.cuas_rng_disp;
boolean rng_vfy = clt_parameters.imp.cuas_rng_vfy; // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
boolean reset_disparity = clt_parameters.imp.cuas_reset_disparity;
......@@ -215,8 +216,9 @@ public class CuasRanging {
double[][][] targets = cuasMotion.getTargets();
String model_prefix = center_CLT.getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,null);
if (rng_disp) {
double [][] glob_stats = null;
if (rng_disp || rng_glob) {
double [][][] disparity_targets = null;
if (reuse_disparity) {
String disparity_path = model_prefix+TARGET_DISPARITIES_SUFFIX; // may later be directly provided (e.g. select specific version)
......@@ -232,7 +234,7 @@ public class CuasRanging {
System.out.println("processMovingTargetsMulti(): re-using target disparities from "+disparity_path);
}
}
if (disparity_targets == null) {
if ((disparity_targets == null) || rng_glob) { // for now - always recalculate if
if (debugLevel > -4) {
System.out.println("detectTargets(): Generating target disparities");
}
......@@ -258,20 +260,38 @@ public class CuasRanging {
System.out.println ("Skipping omegas recalculation omegas.");
}
}
/*
public double [][] rangeSingleTargets(
final double [][][] targets, // centers
final boolean log_ranging,
final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data) NOT implemented
final int debugLevel) {
*/
// String model_prefix = center_CLT.getImageName()+CuasMotion.getParametersSuffix(clt_parameters,null);
rangeTargets(
targets, //final double [][][] targets, // centers
// rng_combine, // final int rng_combine,
log_ranging, // final boolean log_ranging,
rng_vfy, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
ImagePlus imp_new_scores = CuasMotion.showTargetSequence(
if (rng_glob) {
glob_stats = rangeSingleTargets(
targets, //final double [][][] targets, // centers
log_ranging, // final boolean log_ranging,
rng_vfy, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
}
if (disparity_targets == null) { // recalculate if was not read
rangeTargets(
targets, //final double [][][] targets, // centers
// rng_combine, // final int rng_combine,
log_ranging, // final boolean log_ranging,
rng_vfy, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
}
ImagePlus imp_with_range = CuasMotion.showTargetSequence(
targets, // double [][][] vector_fields_sequence,
cuasMotion.getSliceTitles(), // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+TARGET_DISPARITIES_SUFFIX, // "-TARGET_DISPARITIES",// String title,
!batch_mode, // boolean show,
cuasMotion.getTilesX()); // int tilesX) {
center_CLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
center_CLT.saveImagePlusInModelDirectory(imp_with_range); // ImagePlus imp)
}
}
// calculate range from disparity
......@@ -500,15 +520,16 @@ public class CuasRanging {
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
prepareAltImages(
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius0, // final double radius,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius0, // final double radius,
nseq, // final int nseq,
half_accum_range, // final int first_offs,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
if (mb_en && (dxyzatr_dt != null)) {
......@@ -607,6 +628,65 @@ public class CuasRanging {
return rendered;
}
public double [][] rangeSingleTargets(
final double [][][] targets, // centers
final boolean log_ranging,
final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data) NOT implemented
final int debugLevel) {
int [][][] linked_targets = CuasMotion.getLinkedTargets(targets);
double [][] target_glob_stats = new double [linked_targets.length][];
int show_mode = clt_parameters.imp.cuas_dbg_show_mode; // 2; // 7; // 0; // 4; // 0; //3; +1 - disparity, +2 - corr
// int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
float [][][] accum_2d_corr = null;
// for rng_vfy debugging
/// final int half_accum_range = cuasMotion.getSeqLength()/2;
/// final int num_sens = center_CLT.getNumSensors();
/// final int num_scenes = 2*half_accum_range+1;
/// final int num_scene_grp = (num_scenes + (rng_combine - 1)) / rng_combine;
final double [][][] ranging_verify = null; // (rng_vfy) ? (new double [num_scene_grp + 1][num_sens + 1][]) : null;
if (log_ranging) {
String log_head = getRangingLogParameters();
log_head +="target\tnseq\tframe_center\tnrefine\ttileX\ttileY\ttile\tdisparity\tdisp_diff\tstrength\tlast_str\tmax_diff\n";
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_SUFFIX);
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_FULL_SUFFIX);
}
int target_id0 = 1;
int target_id1 = target_glob_stats.length;
System.out.println ("rangeSingleTargets(): Processing target_id from "+target_id0+" to "+target_id1+" (inclusive)"); // for debugging
for (int target_id = target_id0; target_id <= target_id1; target_id++) {
double [] target_stats = rangeSingleTarget( // return {disparity, strength, last disparity difference}
targets, // final double [][][] targets, // centers
linked_targets, // final int [][][] linked_targets,
target_id, // final int target_id, // target number, starting with 1
log_ranging, // final boolean log_ranging,
accum_2d_corr, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
show_mode, // final int show_mode, //+1 - disparity, +2 - correlations +4 - debug single run
ranging_verify, // final double [][][] ranging_verify,
debugLevel) ; // final int debugLevel) ;
target_glob_stats[target_id-1] = target_stats;
}
/*
for (int nseq = nseq_first; nseq <= nseq_last; nseq++) {
int show_mode1 = show_mode & ((nseq == nseq_first)? 7 : 3);
double [][][] ranging_verify_use = (nseq == nseq_first) ? ranging_verify : null ;
rangeTargets(
targets, // final double [][][] targets, // centers
log_ranging, // final boolean log_ranging,
accum_2d_corr, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
nseq, // final int nseq,
show_mode1, // final int show_mode, //+1 - disparity, +2 - correlations
ranging_verify_use, // final double [][][] ranging_verify,
debugLevel); // final int debugLevel)
}
*/
return target_glob_stats;
}
public void rangeTargets(
final double [][][] targets, // centers
......@@ -696,6 +776,154 @@ public class CuasRanging {
return sb.toString();
}
public double[] rangeSingleTarget( // return {disparity, strength, last disparity difference}
final double [][][] targets, // centers
final int [][][] linked_targets,
final int target_id, // target number, starting with 1
final boolean log_ranging,
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
// final int nseq,
final int show_mode, //+1 - disparity, +2 - correlations +4 - debug single run
final double [][][] ranging_verify,
final int debugLevel) {
final int end_mode = clt_parameters.imp.cuas_glob_ends; // 1; // 0 - same as internal, 1 - cosine extended ends, 2 - rectangular extended ends // make a parameter
final boolean first_last_extra = (end_mode > 0);
final boolean smooth_ends = (end_mode == 1);
// extract target from the first to the last defined sequence number
int first_seq = -1;
for (int i = 0; i < targets.length; i++) {
if (linked_targets[target_id-1][i] != null) {
first_seq = i;
break;
}
}
if (first_seq < 0) {
System.out.println("rangeSingleTarget(): target "+target_id+" is undefined");
return null;
}
int iseq;
for (iseq = first_seq; (iseq < targets.length) && (linked_targets[target_id-1][iseq] != null); iseq++ );
int [] target_tiles = new int [iseq - first_seq];
for (int i = 0; i < target_tiles.length; i++) target_tiles[i] = linked_targets[target_id-1][first_seq+i][0];
boolean show_disparity= (show_mode & 1) != 0;
boolean show_corr= (show_mode & 2) != 0;
boolean show_debug_single = (show_mode & 4) != 0;
final int rng_niterate = clt_parameters.imp.cuas_rng_niterate;
final double rng_diff = clt_parameters.imp.cuas_rng_diff;
double cuas_initial_disparity=clt_parameters.imp.cuas_initial_disparity; // 1.0; // Start correlation with this disparity (in addition to infinity) after reset
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
// final int frame_center = cuasMotion.getFrameCenter(nseq); // for debug only
final boolean use_non_lma = false;
// TODO: move to parameters!
final double worsen_str = 0.3; // 9; // do not update if new strength is below worsen_str * old_str
// Show disparity_map;
StringBuffer sb = null;
StringBuffer sb_full = null;
StringBuffer sb_last = null;
if (log_ranging) {
sb = new StringBuffer();
sb_full = new StringBuffer();
}
int refine_vfy = 0; // on which refine step to generate verify images
// debugging
final boolean center_only = debugLevel < 1000; // > 1000; // < 1000;
boolean show_dbg = false; // true;
double disparity = cuas_initial_disparity + cuas_infinity; // 0;
double strength = 0;
double disparity_diff = Double.NaN;
int ref_tile = target_tiles[0]; // moving targets will have accumulated correlations in this tile
int ref_tileX = ref_tile % tilesX;
int ref_tileY = ref_tile / tilesX;
for (int nrefine = 0; nrefine < rng_niterate; nrefine++) {
double [][] disparity_map = refineSingleTargetDisparity(
targets, // final double [][][] targets, // centers
accum_2d_corr, //final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
first_seq, // final int first_seq,
target_tiles, // final int [] target_tiles,
disparity, // final double disparity0,
nrefine, // final int nrefine, // number of the refine to select radius (larger first time)
first_last_extra, // final boolean first_last_extra,
smooth_ends, // final boolean smooth_ends,
show_corr, // final boolean show_corr,
debugLevel); // final int debugLevel)
if (disparity_map == null) {
System.out.println("rangeTargets()): disparity_map==null on nrefine="+nrefine);
break;
}
double disp_diff = disparity_map[ImageDtt.DISPARITY_INDEX_POLY][ref_tile]; // null
double str = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1][ref_tile];
if (Double.isNaN(disp_diff)) {
if (use_non_lma) {
disp_diff = disparity_map[ImageDtt.DISPARITY_INDEX_CM][ref_tile];
str = disparity_map[ImageDtt.DISPARITY_INDEX_CM+1][ref_tile];
}
if (Double.isNaN(disp_diff)) {
System.out.println ("rangeSingleTarget(): Failed to range target #"+target_id+" for sequence "+ first_seq+" ("+ref_tileX+":"+ref_tileY+").");
return null;
}
}
boolean improved = false;
if ((str > 0) && !((worsen_str * strength) > str)) {
disparity += disp_diff;
disparity_diff = disp_diff;
strength = str;
improved = true;
}
double abs_diff = Math.abs(disp_diff);
if ((sb != null) || (sb_full != null)) {
sb_last = new StringBuffer();
}
if (sb_last != null) {
sb_last.append(target_id+"\t"+first_seq+"\t"+target_tiles.length+"\t"+nrefine+"\t"+ref_tileX+"\t"+ref_tileY+"\t"+ref_tile+"\t"+
disparity+"\t"+
disp_diff+"\t"+
strength+"\t"+
str+"\t"+
abs_diff+"\n");
}
if (debugLevel > -4) {
System.out.println(String.format("rangeSingleTarget(), target=%2d, first_seq=%3d (%3d), nrefine=%2d, %3d:%3d (%4d), disparity=%7.4f (%7.4f), strength=%7.5f (%7.5f) abs_diff=%7.5f",
target_id, first_seq,target_tiles.length,nrefine,ref_tileX,ref_tileY,ref_tile,
disparity,
disp_diff,strength,str,abs_diff));
}
if (sb_full != null) {
sb_full.append(sb_last);
// sb_full.append("\n");
}
if (!improved) {
System.out.println ("rangeSingleTarget(): No improvement for target #"+target_id+" for sequence "+ first_seq+" ("+ref_tileX+":"+ref_tileY+").");
break;
}
if (abs_diff <= rng_diff) {
break;
}
} // for (int nrefine = 0; nrefine < rng_niterate; nrefine++) {
// if never was set - make it NaN
if (strength <= 0) { // never was set
disparity = Double.NaN;
strength = 0;
}
if (sb != null) {
sb.append(sb_last);
center_CLT.appendStringInModelDirectory(sb.toString(), TARGET_RANGING_LOGS_SUFFIX);
}
if (sb_full != null) {
center_CLT.appendStringInModelDirectory(sb_full.toString(), TARGET_RANGING_LOGS_FULL_SUFFIX);
}
return new double [] {disparity, strength, disparity_diff};
}
public void rangeTargets(
......@@ -1050,6 +1278,406 @@ public class CuasRanging {
}
/**
* Calculate disparity for a sequence of keyframes following a single target that may change tiles along the way
* @param targets targets array with a single target per tile and marked target numbers in CuasMotionLMA.RSLT_GLOBAL field
* @param first_seq first sequence (key frame) number (0<= first_seq < targets.length)
* @param target_tiles array of target indices for consecutive key frames
* @param disparity0 initial disparity to be refined
* @param nrefine number of refine cycle (0-th uses larger radius)
* @param first_last_extra add longer scene sequence before the first and after the last keyframe (same as fo per-keyframe ranging, apply windowing)
* @param debugLevel debug level
* @return disparity map (only one tile will be used - the first one with the selected target
*/
public double [][] refineSingleTargetDisparity(
final double [][][] targets, // centers
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
final int first_seq,
final int [] target_tiles,
final double disparity0,
final int nrefine, // number of the refine to select radius (larger first time)
final boolean first_last_extra,
final boolean smooth_ends,
final boolean show_corr,
final int debugLevel){
// final boolean show_corr = true;
// final boolean first_last_extra = true; // use longer sequences for the first/last keyframe
// final int num_tiles = targets[0].length;
// final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma; // only for file names
final double rng_fz = clt_parameters.imp.cuas_rng_fz;
final boolean mb_en = clt_parameters.imp.mb_en; // && (fov_tiles==null) && (mode3d > 0);
final double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
final double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(center_CLT.isMonochrome());
final double gpu_sigma_rb_corr = center_CLT.isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(center_CLT.isMonochrome());
final double radius = (nrefine == 0)? clt_parameters.imp.cuas_rng_radius0: clt_parameters.imp.cuas_rng_radius;
final int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
final int half_accum_range = cuasMotion.getSeqLength()/2;
boolean clean_up = true; // remove unneded data
boolean erase_source = true; // check everything works
final int frame_center0 = cuasMotion.getFrameCenter(first_seq);
final int frame_step = cuasMotion.getCorrInc(); // 20
final int hframe_step = frame_step/2;
final int start_scene = frame_center0 - (first_last_extra ? half_accum_range: hframe_step);
final int num_seq = target_tiles.length;
final int num_scenes = first_last_extra ? ((num_seq -1) * frame_step + 2* half_accum_range + 1) : (num_seq * frame_step);
final double [] window_nnorm = new double [num_scenes];
Arrays.fill(window_nnorm, 1.0);
if (first_last_extra ) {
final double [] window1= cuasMotion.getSegmentWindow( // normalized, sum == 1.0
smooth_ends, // boolean smooth)
false); // boolean normalize) // not normalized, values up to 1.0
for (int i = 0; i <= half_accum_range; i++) {
window_nnorm[i] = window1[i];
window_nnorm[num_scenes - 1 - i] = window1[i];
}
}
double sum_wnd = 0;
for (int i = 0; i < window_nnorm.length; i++) {
sum_wnd+=window_nnorm[i];
}
final double [][][] img_um_seq = getUMSequence(
start_scene, // final int start_scene,
num_scenes, // final int num_scenes,
clean_up, // final boolean clean_up, // remove unneded data
erase_source, // final boolean erase_source, // erase source images (will not clean up this.img_um)
debugLevel); // final int debugLevel)
/*
double [][][] pXpYDs = cuasMotion.targetPxPyD(
targets[nseq]); // final double [][] targets)
*/
/// boolean batch_run =clt_parameters.batch_run; // may be modified for debug
/// boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
final int sensor_mask = -1; // all sensors
final int num_sens = center_CLT.getNumSensors();
ImageDttParameters imgdtt_params = null;
try {
imgdtt_params = clt_parameters.img_dtt.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgdtt_params.updateFromCuas(clt_parameters.imp, num_sens);
final int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,num_sens);
ErsCorrection ers_reference = center_CLT.getErsCorrection();
int num_used_sens = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) num_used_sens++;
int [] channels = new int [num_used_sens];
int nch = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) channels[nch++] = i;
// from OF13477: public static double[][] correlateInterscene(
final int num_pairs = Correlation2d.getNumPairs(num_sens);
final float [][][][] fcorr_td_acc = new float [tilesY][tilesX][][];
final float [][][] accum_weights = new float [tilesY][tilesX][num_pairs];
final boolean show_2d_corr = false;
boolean show_accumulated_correlations = show_2d_corr || debugLevel > -5;
// boolean show_reference_correlations = show_2d_corr || debugLevel > -5;
// final float [][][] fclt_corr = ((accum_2d_corr != null) || show_accumulated_correlations || show_reference_correlations) ?
final float [][][] fclt_corr = ((accum_2d_corr != null) || show_accumulated_correlations) ?
(new float [tilesX * tilesY][][]) : null;
final boolean use_rms = true; // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023) (from OF11168: boolean use_rms = true; )
final boolean no_map = false;
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
clt_parameters.transform_size,
imgdtt_params, // clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
final double[][] disparity_map = no_map ? null : new double [image_dtt.getDisparityTitles().length][];
TpTask[][] tp_tasks = null; // will contain last tp_tasks
TpTask[][] tp_tasks_ref = null; // copy from the first segment dseq==0
int ntile0 = target_tiles[0];
int tileX0 = ntile0 % tilesX;
int tileY0 = ntile0 / tilesX;
// initialize fclt and normalize window
for (int rnseq = 0; rnseq < num_seq; rnseq++) { // relative sequence number, starting from 0
int nseq = first_seq + rnseq; // absolute sequence number
int frame_center = cuasMotion.getFrameCenter(nseq);
int first_offs = ((rnseq==0) && first_last_extra)? -half_accum_range : -hframe_step;
int last_offs = ((rnseq==(num_seq - 1)) && first_last_extra)? half_accum_range : (frame_step - hframe_step);
// int rscene0 = frame_center + first_offs; // negative offset
// int rscene1 = frame_center + last_offs; // positive offset
int ntile = target_tiles[rnseq];
int tileX = ntile % tilesX;
int tileY = ntile / tilesX;
double [][][] pXpYDs = cuasMotion.targetPxPyDSingleTile(
targets[nseq], // final double [][] targets,
ntile, // final int ntile,
disparity0, // final double disparity,
first_offs, // final int first_offs,
last_offs); // final int last_offs) {
// split segment by integration groups
double wgrp = 0;
for (int dseq = first_offs; dseq <= last_offs; dseq++) {
// final int iscene = dseq + half_accum_range; // 0, 1,..., 2* half_accum_range.
final int iscene = dseq - first_offs; // starting from 0;
final double [][] ref_pXpYD = pXpYDs[iscene]; // center target
final int nscene = frame_center + dseq; // absolute scene number
final int iscene_grp = iscene / rng_combine;
final boolean first_in_grp = (iscene % rng_combine) == 0;
final boolean last_in_grp = (((iscene + 1) % rng_combine) == 0) || (dseq == last_offs);
if (first_in_grp) {
wgrp = 0;
}
wgrp += window_nnorm[iscene];
final int sm = -1; // merge_all? -1: sensor_mask;
final double [][] dxyzatr_dt = (mb_en ? new double[][] { // for all, including ref
scenes[nscene].getErsCorrection().getErsXYZ_dt(),
scenes[nscene].getErsCorrection().getErsATR_dt()} : null);
final String ts = scenes[nscene].getImageName();
final double [] scene_xyz = ers_reference.getSceneXYZ(ts);
final double [] scene_atr = ers_reference.getSceneATR(ts);
if ((scene_atr==null) || (scene_xyz == null)) { // should not happen
System.out.println("renderKeyFrame() BUG1");
continue;
}
prepareAltImages(
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
first_offs, // final int first_offs,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
tp_tasks = new TpTask[(mb_en && (dxyzatr_dt != null)) ? 2 : 1][];
if (mb_en && (dxyzatr_dt != null)) {
double [][] motion_blur = OpticalFlow.getMotionBlur(
center_CLT, // quadCLTs[ref_index], // QuadCLT ref_scene,
scenes[nscene], // QuadCLT scene, // can be the same as ref_scene
ref_pXpYD, // double [][] ref_pXpYD, // here it is scene, not reference!
scene_xyz, // double [] camera_xyz,
scene_atr, // double [] camera_atr,
dxyzatr_dt[0], // double [] camera_xyz_dt,
dxyzatr_dt[1], // double [] camera_atr_dt,
0, // int shrink_gaps, // will gaps, but not more that grow by this
debugLevel); // int debug_level)
// TODO: Add target movement (recalculate velocities)
QuadCLT.preRenderGPUFromDSI(
!first_in_grp, // final boolean accumulate,
window_nnorm[iscene],// final double global_scale, // <=1.0
sm, // final int sensor_mask,
false, // final boolean merge_channels,
0, // final int discard_border,
0, // final double max_fold,
0, // final int min_in_row_col, // Minimal number of defined tiles in a row/column
null, // final Rectangle full_woi_in, // show larger than sensor WOI in tiles (or null)
clt_parameters, // CLTParameters clt_parameters,
null, // double [] disparity_ref,
// only center tiles here!
ref_pXpYD, // double [][] ref_pXpYD, // alternative to disparity_ref when reference is not uniform
// motion blur compensation
mb_tau, // double mb_tau, // 0.008; // time constant, sec
mb_max_gain, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
motion_blur, // double [][] mb_vectors, // now [2][ntiles];
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
debugLevel); // final int debugLevel)
} else {
QuadCLT.preRenderGPUFromDSI(
!first_in_grp, // final boolean accumulate,
window_nnorm[iscene], // final double global_scale, // <=1.0
sm, // final int sensor_mask,
false, // final boolean merge_channels,
0, // final int discard_border,
0, // final double max_fold,
0, // final int min_in_row_col, // Minimal number of defined tiles in a row/column
null, // final Rectangle full_woi_in, // show larger than sensor WOI in tiles (or null)
clt_parameters, // CLTParameters clt_parameters,
null, // double [] disparity_ref,
// only center tiles here!
ref_pXpYD, // double [][] ref_pXpYD, // alternative to disparity_ref when reference is not uniform
// motion blur compensation
0.0, // double mb_tau, // 0.008; // time constant, sec
0.0, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
null, // double [][] mb_vectors, // now [2][ntiles];
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
debugLevel); // final int debugLevel)
}
// copy center tasks from the first series to the reference
if ((rnseq == 0) && (dseq == 0)) {
tp_tasks_ref = tp_tasks; // for the middle frame
for (int i = 0; i < tp_tasks.length; i++) { // here just one
tp_tasks_ref[i] = tp_tasks[i].clone();
}
}
// correlate only after the last in group, others - just accumulate in TD
if (last_in_grp) {
/*
if (ranging_verify != null) { // [2*half_accum_range +1 +1][num_sens+1][] // [num_pix])
double [][] scene_render = center_CLT.renderDoubleFromTDMono ( // [sensor][pixel]
-1, // int sensor_mask,
null, // int [] wh, // may be null, or {width, height}
false); // boolean use_reference
for (int nsens = 0; nsens < scene_render.length; nsens++) {
ranging_verify[iscene_grp][nsens] = scene_render[nsens];
}
}
*/
float [][][][] fcorr_td = new float[tilesY][tilesX][][];
image_dtt.quadCorrTD(
imgdtt_params, // clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
tp_tasks[0], // *** will be updated inside from GPU-calculated geometry
fcorr_td, // fcorrs_td[nscene], // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs
clt_parameters.gpu_sigma_r, // 0.9, 1.1
clt_parameters.gpu_sigma_b, // 0.9, 1.1
clt_parameters.gpu_sigma_g, // 0.6, 0.7
clt_parameters.gpu_sigma_m, // = 0.4; // 0.7;
gpu_sigma_rb_corr, // final double gpu_sigma_rb_corr, // = 0.5; // apply LPF after accumulating R and B correlation before G, monochrome ? 1.0 : gpu_sigma_rb_corr;
gpu_sigma_corr, // = 0.9;gpu_sigma_corr_m
gpu_sigma_log_corr, // final double gpu_sigma_log_corr, // hpf to reduce dynamic range for correlations
clt_parameters.corr_red, // +used
clt_parameters.corr_blue, // +used
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
ImageDtt.THREADS_MAX, // maximal number of threads to launch
debugLevel);
if (image_dtt.getGPU().getGpu_debug_level() > -1) {
System.out.println("==ooo=after image_dtt.quadCorrTD()");
}
// Verify tasks are now updated
/*
OpticalFlow.accumulateCorrelations(
// window_full[iscene] * (2 * half_accum_range + 1), // final double weight, // keep same sum as before
wgrp, // window_grp[iscene_grp], // final double weight, // keep same sum as before
accum_weights, // final int [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
*/
if (fcorr_td[tileY][tileX] != null) {
if (fcorr_td_acc[tileY0][tileX0] == null) {
fcorr_td_acc[tileY0][tileX0] = new float [fcorr_td[tileY][tileX].length][];
}
OpticalFlow.accumulateCorrelations(
wgrp, // double weight,
accum_weights[tileY0][tileX0], // float [] num_acc, // number of accumulated tiles [pair]
fcorr_td[tileY][tileX], // float [][] fcorr_td, // [pair][256] sparse transform domain representation of corr pairs
fcorr_td_acc[tileY0][tileX0]); // float [][] fcorr_td_acc // [pair][256] sparse transform domain representation of corr pairs // should not be null, same length as fcorr_td
}
if (image_dtt.getGPU().getGpu_debug_level() > -1) {
System.out.println("==ooo=accumulateCorrelations()");
}
} // if (last_in_grp) {
} // for (int dseq = first_offs; dseq <= last_offs; dseq++) {
} // for (int nseq = 0; nseq < num_seq; nseq++) {
// Normalize accumulated correlations
OpticalFlow.accumulateCorrelationsAcOnly(
accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks_ref[0].length][][]):null;
image_dtt.clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
imgdtt_params, // clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
fcorr_td_acc, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
accum_weights, // float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] (or null)
null, // dcorr_weight, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough)
clt_parameters.gpu_corr_scale, // final double gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values
// clt_parameters.getGpuFatZero(center_CLT.isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
rng_fz, // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
image_dtt.transform_size - 1, // final int gpu_corr_rad, // = transform_size - 1 ?
// The tp_tasks data should be decoded from GPU to get coordinates
tp_tasks_ref[0], // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
null, // final double [][] far_fgbg, // null, or [nTile]{disp(fg)-disp(bg), str(fg)-str(bg)} hints for LMA FG/BG split
center_CLT.getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
// next both can be nulls
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
// combo will be added as extra pair if mcorr_comb_width > 0 and clt_corr_out has a slot for it
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
use_rms, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
clt_parameters.correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
// define combining of all 2D correlation pairs for CM (LMA does not use them)
imgdtt_params.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
imgdtt_params.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
imgdtt_params.mcorr_comb_offset,//final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
imgdtt_params.mcorr_comb_disp, //final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.clt_window, // final int window_type, // GPU: will not be used
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
ImageDtt.THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
"accumulated", // final String debug_suffix,
debugLevel + 0); // 2); // -1 ); // final int globalDebugLevel)
ImageDtt.convertFcltCorr(
dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null
if (show_corr || (accum_2d_corr != null)){ // -1
float [][] accum_2d_img = ImageDtt.corr_partial_dbg( // not used in lwir
fclt_corr, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
tp_tasks_ref[0], // final TpTask [] tp_tasks, //
tilesX, //final int tilesX,
tilesY, //final int tilesX,
2*image_dtt.transform_size - 1, // final int corr_size,
1000, // will be limited by available layersfinal int layers0,
clt_parameters.corr_border_contrast, // final double border_contrast,
ImageDtt.THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel)
String [] titles = new String [accum_2d_img.length]; // dcorr_tiles[0].length];
int ind_length = image_dtt.getCorrelation2d().getCorrTitles().length;
System.arraycopy(image_dtt.getCorrelation2d().getCorrTitles(), 0, titles, 0, ind_length);
String [] combos= {"combo-all", "combo-diameters"};
for (int i = ind_length; i < titles.length; i++) {
titles[i] = combos[i-ind_length]; // "combo-"+(i - ind_length);
}
if ((accum_2d_corr != null)) {
accum_2d_corr[0] = accum_2d_img;
}
if (show_accumulated_correlations) {
ShowDoubleFloatArrays.showArrays( // out of boundary 15
accum_2d_img,
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-CORR-ACCUM_R"+clt_parameters.imp.cuas_rng_radius+
"-T"+ntile0+":"+nrefine+"-M"+mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
titles); // image_dtt.getCorrelation2d().getCorrTitles()); //CORR_TITLES);
}
}
return disparity_map; // disparity_map
}
public double [][] refineTargetDisparity( // returns disparity_map
final double [][][] targets, // centers
......@@ -1061,11 +1689,7 @@ public class CuasRanging {
final boolean show_debug_single,
final int debugLevel) {
// final boolean um_en = clt_parameters.imp.cuas_rng_um;
// final boolean um_all = clt_parameters.imp.cuas_rng_um_all;
final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
// final boolean um_twice = clt_parameters.imp.cuas_rng_um2;
// final double um_weight = clt_parameters.imp.cuas_rng_um_weight;
final double rng_fz = clt_parameters.imp.cuas_rng_fz;
final boolean mb_en = clt_parameters.imp.mb_en; // && (fov_tiles==null) && (mode3d > 0);
final double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
......@@ -1080,12 +1704,6 @@ public class CuasRanging {
final int frame_center = cuasMotion.getFrameCenter(nseq);
final int half_accum_range = cuasMotion.getSeqLength()/2;
// final boolean unsharped
// final double [] window_full= cuasMotion.getSegmentWindow(
// true, // boolean smooth)
// true); // boolean normalize)
//radius_blur
final int start_scene = frame_center - half_accum_range;
final int num_scenes = 2*half_accum_range + 1;
boolean clean_up = true; // remove unneded data
......@@ -1123,19 +1741,7 @@ public class CuasRanging {
boolean show_um = show_debug_single; // (show_corr & 4) != 0; // true; // false; // true;
if (show_um) {
/*
String title_pXpYDs = center_CLT.getImageName()+
"-pXpYDs-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
"-"+clt_parameters.imp.cuas_mcorr_sel_lma;
cuasMotion.showPxPyDs(
pXpYDs, // double [][][] pXpYDs,
nseq, // int nseq, // center
title_pXpYDs, // String title,
true); // boolean show)
*/
String [] titles_sensors = new String[img_um_seq[0].length];
String [] titles_scenes = new String[num_scenes];
for (int i = 0; i < titles_sensors.length; i++) {
......@@ -1224,16 +1830,16 @@ public class CuasRanging {
continue;
}
prepareAltImages(
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
half_accum_range, // final int first_offs,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
tp_tasks = new TpTask[(mb_en && (dxyzatr_dt != null)) ? 2 : 1][];
......@@ -1419,7 +2025,7 @@ public class CuasRanging {
}
// Normalize accumulated correlations
OpticalFlow.accumulateCorrelationsAcOnly(
OpticalFlow.accumulateCorrelationsAcOnly(
accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks_ref[0].length][][]):null;
......@@ -1507,7 +2113,8 @@ public class CuasRanging {
final double [] scene_xyz,
final double [] scene_atr,
final double radius,
final int nseq,
final int first_offs,
final int nseq, // absolute sequence number (to calculate center frame
final int dseq,
final int debugLevel) {
final double radius_blur = clt_parameters.imp.cuas_rng_blur;
......
......@@ -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