Commit 9a4d969e authored by Andrey Filippov's avatar Andrey Filippov

Profiling and convenience features

parent 5961834e
...@@ -1761,104 +1761,6 @@ public class CuasMotion { ...@@ -1761,104 +1761,6 @@ public class CuasMotion {
return target_sequence_multi; return target_sequence_multi;
} }
// By Claude on 05/07/2026: pre-populate target_sequence_multi with FAIL_PENDING sentinels from motion_sequence.
// Each sentinel is a clone of the motion entry with RSLT_FAIL=FAIL_PENDING, RSLT_CENTERED=CENTERED_NO,
// RSLT_QSCORE initialized from RSLT_MSCORE. Preserves VX/VY/X/Y and all other motion fields.
@Deprecated
public static void initFromMotionSequence(
final double [][][] motion_sequence,
final double [][][][] target_sequence_multi) {
final int num_seq = motion_sequence.length;
final int num_tiles = motion_sequence[0].length;
for (int nSeq = 0; nSeq < num_seq; nSeq++) {
for (int ntile = 0; ntile < num_tiles; ntile++) {
if (motion_sequence[nSeq][ntile] != null && target_sequence_multi[nSeq][ntile] == null) {
double [] sentinel = motion_sequence[nSeq][ntile].clone();
sentinel[CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_PENDING;
sentinel[CuasMotionLMA.RSLT_CENTERED] = CuasMotionLMA.CENTERED_NO;
sentinel[CuasMotionLMA.RSLT_QSCORE] = motion_sequence[nSeq][ntile][CuasMotionLMA.RSLT_MSCORE];
target_sequence_multi[nSeq][ntile] = new double [][] {sentinel};
}
}
}
}
// By Claude on 05/07/2026: after each getEffectiveStrengthMV call, keep RSLT_QSCORE in FAIL_PENDING sentinels
// current with the freshly computed RSLT_MSCORE so filter5 ranks by up-to-date motion confidence.
@Deprecated
public static void syncMotionScoreToSentinels(
final double [][][] motion_sequence,
final double [][][][] target_sequence_multi) {
final int num_seq = motion_sequence.length;
final int num_tiles = motion_sequence[0].length;
for (int nSeq = 0; nSeq < num_seq; nSeq++) {
for (int ntile = 0; ntile < num_tiles; ntile++) {
double [] mv = motion_sequence[nSeq][ntile];
if (mv != null && target_sequence_multi[nSeq][ntile] != null) {
for (double [] entry : target_sequence_multi[nSeq][ntile]) {
if ((entry != null) &&
((entry[CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING) &&
( entry[CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO))) {
// copy all other
/// entry[CuasMotionLMA.RSLT_QSCORE] = mv[CuasMotionLMA.RSLT_MSCORE]; Why was that needed?
// Make a mrthod to copy all motion-related parameters
entry[CuasMotionLMA.RSLT_VX] = mv[CuasMotionLMA.RSLT_VX];
entry[CuasMotionLMA.RSLT_VY] = mv[CuasMotionLMA.RSLT_VY];
entry[CuasMotionLMA.RSLT_VSTR] = mv[CuasMotionLMA.RSLT_VSTR];
entry[CuasMotionLMA.RSLT_VFRAC] = mv[CuasMotionLMA.RSLT_VFRAC];
entry[CuasMotionLMA.RSLT_VBOOST] = mv[CuasMotionLMA.RSLT_VBOOST];
entry[CuasMotionLMA.RSLT_VCORR] = mv[CuasMotionLMA.RSLT_VCORR];
}
}
}
}
}
}
// fills out additional fields in target_coords
@Deprecated
public static double [][] getEffectiveStrengthMV( // calculate tiles effective strength by the motion vectors. Combine with the target LMA?
final double [][][] targets_sequence,
int niter, // save iteration number on failure if >=
final int tilesX,
final double min_score_mv,
double speed_min,
double speed_pref,
double speed_boost ){
final int num_seq = targets_sequence.length;
final int num_tiles = targets_sequence[0].length;
final double [][] effective_strength = new double [num_seq][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() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
double [][] targets = targets_sequence[nSeq];
for (int ntile = 0; ntile < num_tiles; ntile++) {
if (targets[ntile] != null) {
double es = getEffectiveStrengthMV(
targets[ntile], // double [] target,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost); //double speed_boost)
targets[ntile][CuasMotionLMA.RSLT_MSCORE] = es;
effective_strength[nSeq][ntile] = es;
if ((niter >= 0) && !(es >= min_score_mv)) {
targets[ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_MOTION;
targets[ntile][CuasMotionLMA.RSLT_WHEN] = niter;
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return effective_strength;
}
/** /**
* When used, each tile has a single target * When used, each tile has a single target
...@@ -2366,6 +2268,11 @@ public class CuasMotion { ...@@ -2366,6 +2268,11 @@ public class CuasMotion {
final Thread[] threads = ImageDtt.newThreadArray(); final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
final boolean show_dbg = (dbg_nseq >= 0 || dbg_tile >= 0) && debugLevel >= 0; final boolean show_dbg = (dbg_nseq >= 0 || dbg_tile >= 0) && debugLevel >= 0;
// By Claude on 05/24/2026: profiling accumulators
long t_clear = 0, t_mask = 0, t_corr = 0, t_pd = 0;
int prof_nseq = 0, prof_targets = 0;
long t_corr_sparse = 0, t_corr_dense = 0; // sparse: <10 targets, dense: >=10
int prof_nseq_sparse = 0, prof_nseq_dense = 0;
// Collect per-nseq correlation for end-of-method CORR2D stack // Collect per-nseq correlation for end-of-method CORR2D stack
final double[][][] corr2d_ref = show_dbg ? new double[targets_nonoverlap.length][][] : null; final double[][][] corr2d_ref = show_dbg ? new double[targets_nonoverlap.length][][] : null;
final String[] scene_titles_all = cuasMotion.getSceneTitles(); final String[] scene_titles_all = cuasMotion.getSceneTitles();
...@@ -2394,7 +2301,9 @@ public class CuasMotion { ...@@ -2394,7 +2301,9 @@ public class CuasMotion {
if (fmin_alloc > fmax_alloc) continue; // no valid pairs in range if (fmin_alloc > fmax_alloc) continue; // no valid pairs in range
// Clear staging frames for this scan position // Clear staging frames for this scan position
long t0 = System.nanoTime(); // By Claude on 05/24/2026
for (int f = fmin_alloc; f <= fmax_alloc; f++) Arrays.fill(fpixels_masked[f], 0.0f); for (int f = fmin_alloc; f <= fmax_alloc; f++) Arrays.fill(fpixels_masked[f], 0.0f);
long t1 = System.nanoTime(); // By Claude on 05/24/2026
// Pre-extract tile center/velocity for thread-safe parallel access // Pre-extract tile center/velocity for thread-safe parallel access
final int ntiles = targets_nonoverlap[nseq].length; final int ntiles = targets_nonoverlap[nseq].length;
...@@ -2413,6 +2322,9 @@ public class CuasMotion { ...@@ -2413,6 +2322,9 @@ public class CuasMotion {
tvy[ntile] = target[CuasMotionLMA.RSLT_VY]; tvy[ntile] = target[CuasMotionLMA.RSLT_VY];
} }
// By Claude on 05/24/2026: count valid targets for profiling
int nseq_targets = 0;
for (int ntile = 0; ntile < ntiles; ntile++) if (tile_valid[ntile]) nseq_targets++;
// Parallel over frames: each thread applies all tile masks to one frame // Parallel over frames: each thread applies all tile masks to one frame
final int fmin_f = fmin_alloc; final int fmin_f = fmin_alloc;
final int frange = fmax_alloc - fmin_f + 1; final int frange = fmax_alloc - fmin_f + 1;
...@@ -2449,6 +2361,7 @@ public class CuasMotion { ...@@ -2449,6 +2361,7 @@ public class CuasMotion {
}; };
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
long t2 = System.nanoTime(); // By Claude on 05/24/2026
// Debug: show full fmin..fmax masked frame stack for dbg_nseq // Debug: show full fmin..fmax masked frame stack for dbg_nseq
if ((nseq == dbg_nseq) && (debugLevel >= 0)) { // && (dbg_iter_index<= max_index_dbg)) { if ((nseq == dbg_nseq) && (debugLevel >= 0)) { // && (dbg_iter_index<= max_index_dbg)) {
...@@ -2478,6 +2391,7 @@ public class CuasMotion { ...@@ -2478,6 +2391,7 @@ public class CuasMotion {
"refineMotionVectors-boost"+recalc_mv_boost+"-nseq" + nseq+"-niter"+dbg_iter_index+dbg_suffix, stack_titles); "refineMotionVectors-boost"+recalc_mv_boost+"-nseq" + nseq+"-niter"+dbg_iter_index+dbg_suffix, stack_titles);
} }
long t3 = System.nanoTime(); // By Claude on 05/24/2026
TDCorrTile[] tdCorrTiles = cuasMotion.correlatePairs( // By Claude on 05/06/2026 TDCorrTile[] tdCorrTiles = cuasMotion.correlatePairs( // By Claude on 05/06/2026
clt_parameters, // CLTParameters clt_parameters clt_parameters, // CLTParameters clt_parameters
fpixels_masked, // float [][] fpixels fpixels_masked, // float [][] fpixels
...@@ -2493,6 +2407,7 @@ public class CuasMotion { ...@@ -2493,6 +2407,7 @@ public class CuasMotion {
null, // String dbg_suffix null, // String dbg_suffix
debugLevel); debugLevel);
long t4 = System.nanoTime(); // By Claude on 05/24/2026
double scale_fat_zero = 1.0 / recalc_mv_boost; double scale_fat_zero = 1.0 / recalc_mv_boost;
double[][] corr_tiles_pd = cuasMotion.convertTDtoPD( double[][] corr_tiles_pd = cuasMotion.convertTDtoPD(
tdCorrTiles, tdCorrTiles,
...@@ -2513,6 +2428,7 @@ public class CuasMotion { ...@@ -2513,6 +2428,7 @@ public class CuasMotion {
true); true);
long t5 = System.nanoTime(); // By Claude on 05/24/2026
// Add differential MV to targets_nonoverlap in-place // Add differential MV to targets_nonoverlap in-place
for (int ntile = 0; ntile < targets_nonoverlap[nseq].length; ntile++) { for (int ntile = 0; ntile < targets_nonoverlap[nseq].length; ntile++) {
double[] target = targets_nonoverlap[nseq][ntile]; double[] target = targets_nonoverlap[nseq][ntile];
...@@ -2539,6 +2455,30 @@ public class CuasMotion { ...@@ -2539,6 +2455,30 @@ public class CuasMotion {
// set RSLT_WHEN - will be set in public static int addNewResults() // set RSLT_WHEN - will be set in public static int addNewResults()
} }
} }
// By Claude on 05/24/2026: accumulate profiling times
t_clear += t1 - t0;
t_mask += t2 - t1;
t_corr += t4 - t3;
t_pd += t5 - t4;
prof_nseq++;
prof_targets += nseq_targets;
if (nseq_targets < 10) { t_corr_sparse += t4 - t3; prof_nseq_sparse++; }
else { t_corr_dense += t4 - t3; prof_nseq_dense++; }
}
// By Claude on 05/24/2026: profiling summary
if (prof_nseq > 0) {
double ms = 1e-6;
System.out.printf("refineMotionVectors() profiling (%d nseq, %d total targets, avg %.1f/iter, boost=%.1f):%n",
prof_nseq, prof_targets, (double)prof_targets/prof_nseq, recalc_mv_boost);
System.out.printf(" clear (Arrays.fill) : %8.1f ms total, %6.3f ms/iter%n", t_clear*ms, t_clear*ms/prof_nseq);
System.out.printf(" mask (startAndJoin) : %8.1f ms total, %6.3f ms/iter%n", t_mask *ms, t_mask *ms/prof_nseq);
System.out.printf(" corr (correlatePairs) total : %8.1f ms total, %6.3f ms/iter%n", t_corr *ms, t_corr *ms/prof_nseq);
if (prof_nseq_sparse > 0) System.out.printf(" corr sparse (<10 targ, %3d iters): %8.1f ms, %6.3f ms/iter%n",
prof_nseq_sparse, t_corr_sparse*ms, t_corr_sparse*ms/prof_nseq_sparse);
if (prof_nseq_dense > 0) System.out.printf(" corr dense (>=10 targ, %3d iters): %8.1f ms, %6.3f ms/iter%n",
prof_nseq_dense, t_corr_dense *ms, t_corr_dense *ms/prof_nseq_dense);
System.out.printf(" pd (convertTD+getMismatch) : %8.1f ms total, %6.3f ms/iter%n", t_pd*ms, t_pd*ms/prof_nseq);
System.out.printf(" total accounted : %8.1f ms%n", (t_clear+t_mask+t_corr+t_pd)*ms);
} }
// Debug: CORR2D overview — one slice per keyframe, same layout as *CORR2D.tiff // Debug: CORR2D overview — one slice per keyframe, same layout as *CORR2D.tiff
if (show_dbg && (corr2d_ref != null)) { // && (dbg_iter_index<= max_index_dbg)) { if (show_dbg && (corr2d_ref != null)) { // && (dbg_iter_index<= max_index_dbg)) {
...@@ -6761,6 +6701,85 @@ public class CuasMotion { ...@@ -6761,6 +6701,85 @@ public class CuasMotion {
return; return;
} }
/**
* Fail early after phase 1 to increase performance
* Use the following procedure to select values:
* 1) Relax them and run the program
* 2) Analyze RSLT_PHASE1_* parameters of the survived targets at the last stage (currently, *-CENT.tiff)
* 3) Set the threshold values somewhat lower.
* Each threshold below, if set
* @param target_multi target data to be modified [nseq][ntile][ntarget][nparam]
* @param niter current iteration number, will be applied to [RSLT_WHEN]
* @param min_mscore minimal value for [RSLT_MSCORE]
* @param min_vstr minimal value for [RSLT_VSTR]
* @param min_score minimal value for [RSLT_QSCORE]
* @param min_amp minimal value for [RSLT_A]
* @return int [] : total number of failures and for each of the 4 input parameters (same target may fail by several parameters
*/
public static int [] earlyFail( // Fail after Phase 1
final double [][][][] target_multi,
final int niter,
final double min_mscore,
final double min_vstr,
final double min_score,
final double min_amp) {
final int num_seq = target_multi.length;
final int num_tiles = target_multi[0].length;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger afail = new AtomicInteger(0);
final AtomicInteger amscore = new AtomicInteger(0);
final AtomicInteger avstr = new AtomicInteger(0);
final AtomicInteger ascore = new AtomicInteger(0);
final AtomicInteger aamp = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < num_tiles; ntile++) {
double [][] targets = target_multi[nSeq][ntile];
if (targets != null){
for (int ntarg = 0; ntarg <targets.length; ntarg++) if (targets[ntarg] != null){
if (Double.isNaN(targets[ntarg][CuasMotionLMA.RSLT_FAIL]) || (targets[ntarg][CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE)) {
int fail_type = 0;
if (!Double.isNaN(min_mscore) && !(targets[ntarg][CuasMotionLMA.RSLT_MSCORE] >= min_mscore)) {
if (fail_type == 0) fail_type = CuasMotionLMA.FAIL_MOTION;
amscore.getAndIncrement();
}
if (!Double.isNaN(min_vstr) && !(targets[ntarg][CuasMotionLMA.RSLT_VSTR] >= min_vstr)) {
if (fail_type == 0) fail_type = CuasMotionLMA.FAIL_MOTION;
avstr.getAndIncrement();
}
if (!Double.isNaN(min_score) && !(targets[ntarg][CuasMotionLMA.RSLT_QSCORE] >= min_score)) {
if (fail_type == 0) fail_type = CuasMotionLMA.FAIL_Q_LOW;
ascore.getAndIncrement();
}
if (!Double.isNaN(min_amp) && !(targets[ntarg][CuasMotionLMA.RSLT_A] >= min_amp)) {
if (fail_type == 0) fail_type = CuasMotionLMA.FAIL_A_LOW;
aamp.getAndIncrement();
}
if (fail_type != 0) {
targets[ntarg][CuasMotionLMA.RSLT_FAIL] = fail_type;
targets[ntarg][CuasMotionLMA.RSLT_WHEN] = niter;
afail.getAndIncrement();
}
}
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return new int [] {
afail.get(),
amscore.get(),
avstr.get(),
ascore.get(),
aamp.get()};
}
...@@ -8020,6 +8039,13 @@ public class CuasMotion { ...@@ -8020,6 +8039,13 @@ public class CuasMotion {
boolean accum_boosted = clt_parameters.imp.cuas_accum_boosted;// By AF on 05/12/2026 boolean accum_boosted = clt_parameters.imp.cuas_accum_boosted;// By AF on 05/12/2026
// at least one of accum_boosted, accum_base should be used, normally both // at least one of accum_boosted, accum_base should be used, normally both
boolean accum_base = clt_parameters.imp.cuas_accum_base || !accum_boosted; // By AF on 05/12/2026 boolean accum_base = clt_parameters.imp.cuas_accum_base || !accum_boosted; // By AF on 05/12/2026
boolean early_en = clt_parameters.imp.cuas_early_en; // Apply early fail filter after phase 1
double early_mscore = clt_parameters.imp.cuas_early_mscore; // Minimal motion score (RSLT_MSCORE)
double early_vstr = clt_parameters.imp.cuas_early_vstr; // Minimal MV confidence (RSLT_VSTR)
double early_score = clt_parameters.imp.cuas_early_score; // Minimal score (RSLT_QSCORE)
double early_amp = clt_parameters.imp.cuas_early_amp; // Minimal amplitude (RSLT_A)
for (int i = 0; i < target_frac.length; i++) { for (int i = 0; i < target_frac.length; i++) {
if (clt_parameters.imp.cuas_target_frac[i].length >= 2) { if (clt_parameters.imp.cuas_target_frac[i].length >= 2) {
target_frac[i][0] = clt_parameters.imp.cuas_target_frac[i][0]; target_frac[i][0] = clt_parameters.imp.cuas_target_frac[i][0];
...@@ -8531,6 +8557,28 @@ public class CuasMotion { ...@@ -8531,6 +8557,28 @@ public class CuasMotion {
score_coeff, // final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A) score_coeff, // final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A)
slow_score, // final double slow_score, // multiply total score for targets detected in slow target mode slow_score, // final double slow_score, // multiply total score for targets detected in slow target mode
cuasMotion.tilesX); // final int tilesX, cuasMotion.tilesX); // final int tilesX,
if (early_en) {
int [] early_fail = earlyFail( // Fail after Phase 1
target_sequence_multi, // final double [][][][] target_multi,
niter, // final int niter,
early_mscore, // final double min_mscore,
early_vstr, // final double min_vstr,
early_score, // final double min_score,
early_amp); // final double min_amp);
if (debugLevel > -4) {
System.out.println("Early failed:");
System.out.println(String.format(" total: %5d", early_fail[0]));
System.out.println(String.format(" mscore: %5d (<%f)", early_fail[1],early_mscore));
System.out.println(String.format(" vstr: %5d (<%f)", early_fail[2],early_vstr));
System.out.println(String.format(" score: %5d (<%f)", early_fail[3],early_score));
System.out.println(String.format(" amplitude: %5d (<%f)", early_fail[4],early_amp));
}
} else {
if (debugLevel > -4) {
System.out.println("Early fail DISABLED.");
}
}
sortMultiTargets( sortMultiTargets(
target_sequence_multi, // final double [][][][] target_multi, target_sequence_multi, // final double [][][][] target_multi,
true); // final boolean trim_nulls) { // trim null targets true); // final boolean trim_nulls) { // trim null targets
...@@ -10624,6 +10672,9 @@ public class CuasMotion { ...@@ -10624,6 +10672,9 @@ public class CuasMotion {
false, // boolean slow_mode, false, // boolean slow_mode,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
double [][][][] targets_good_multi = targets_fast; double [][][][] targets_good_multi = targets_fast;
/* /*
* Before running with slow_en== true, verify temporal (scene) offset between slow and fast mode. * Before running with slow_en== true, verify temporal (scene) offset between slow and fast mode.
......
...@@ -160,28 +160,29 @@ public class CuasMotionLMA { ...@@ -160,28 +160,29 @@ public class CuasMotionLMA {
public static final String EXTRA_SLICE_DISCARD_ON_LOAD = "Targets"; public static final String EXTRA_SLICE_DISCARD_ON_LOAD = "Targets";
public static final int FAIL_PENDING = -1; // By Claude on 05/07/2026: motion sentinel — tile tracked but not yet processed by LMA public static final int FAIL_PENDING = -1; // By Claude on 05/07/2026: motion sentinel — tile tracked but not yet processed by LMA
public static final int FAIL_NONE = 0; public static final int FAIL_NONE = 0;
public static final int FAIL_MOTION = 1; // motion strength/fraction too low public static final int FAIL_MOTION = 1; // motion strength/fraction too low, also - motion score too low
public static final int FAIL_NO_MAX = 2; // no suitable local maximum public static final int FAIL_NO_MAX = 2; // no suitable local maximum
public static final int FAIL_CENT_STR = 3; // centroid amplitude is too low public static final int FAIL_CENT_STR = 3; // centroid amplitude is too low
public static final int FAIL_CENT_FRAC = 4; // centroid fraction (energy in the peak fraction of all) is too low public static final int FAIL_CENT_FRAC = 4; // centroid fraction (energy in the peak fraction of all) is too low
public static final int FAIL_LMA = 5; // LMA fail to converge public static final int FAIL_LMA = 5; // LMA fail to converge
public static final int FAIL_A_PRE = 6; // amplitude is too low at preliminary filter (just after LMA) public static final int FAIL_A_PRE = 6; // amplitude is too low at preliminary filter (just after LMA)
public static final int FAIL_A_LOW = 7; // amplitude is too low public static final int FAIL_A_LOW = 7; // amplitude is too low
public static final int FAIL_ACENT = 8; // ratio of maximal pixel to amplitude is too low public static final int FAIL_Q_LOW = 8; // score too low
public static final int FAIL_RMSE = 9; // RMSE is too high public static final int FAIL_ACENT = 9; // ratio of maximal pixel to amplitude is too low
public static final int FAIL_RMSE_R = 10; // BOTH RMSE is not sufficient and RMSE/A is too high public static final int FAIL_RMSE = 10; // RMSE is too high
public static final int FAIL_R0_HIGH = 11; // Full radius (including negative overshoot) is too high public static final int FAIL_RMSE_R = 11; // BOTH RMSE is not sufficient and RMSE/A is too high
public static final int FAIL_R1_LOW = 12; // Inner (positive) peak radius is too low public static final int FAIL_R0_HIGH = 12; // Full radius (including negative overshoot) is too high
public static final int FAIL_K_LOW = 13; // Overshoot is too low (not used, it can be down to 0) public static final int FAIL_R1_LOW = 13; // Inner (positive) peak radius is too low
public static final int FAIL_K_HIGH = 14; // Overshoot is too high public static final int FAIL_K_LOW = 14; // Overshoot is too low (not used, it can be down to 0)
public static final int FAIL_FAR = 15; // Peak is too far from the center public static final int FAIL_K_HIGH = 15; // Overshoot is too high
public static final int FAIL_VCORR = 16; // MV refinement (fine pass) resulted in a too high correction (not yet checked) public static final int FAIL_FAR = 16; // Peak is too far from the center
public static final int FAIL_HORIZON = 17; // Peak is below horizon public static final int FAIL_VCORR = 17; // MV refinement (fine pass) resulted in a too high correction (not yet checked)
public static final int FAIL_MISMATCH = 18; // Mismatch on both ends is too high public static final int FAIL_HORIZON = 18; // Peak is below horizon
public static final int FAIL_NEIGHBOR = 19; // failed because some neighbor is stronger public static final int FAIL_MISMATCH = 19; // Mismatch on both ends is too high
public static final int FAIL_DUPLICATE= 20; // coordinate are (almost) the same as those of a stronger tile public static final int FAIL_NEIGHBOR = 20; // failed because some neighbor is stronger
public static final int FAIL_USED= 21; // non-centered used to generate centered, remove this public static final int FAIL_DUPLICATE= 21; // coordinate are (almost) the same as those of a stronger tile
public static final int FAIL_FL_ONLY= 22; // Flight log data only, no target detected here public static final int FAIL_USED= 22; // non-centered used to generate centered, remove this
public static final int FAIL_FL_ONLY= 23; // Flight log data only, no target detected here
public static final int CENTERED_NO = 0; public static final int CENTERED_NO = 0;
public static final int CENTERED_YES = 1; public static final int CENTERED_YES = 1;
......
...@@ -823,9 +823,15 @@ min_str_neib_fpn 0.35 ...@@ -823,9 +823,15 @@ min_str_neib_fpn 0.35
public int cuas_num_cycles = 25; // number of cycles of testing and removing bad targets // will get out earlier public int cuas_num_cycles = 25; // number of cycles of testing and removing bad targets // will get out earlier
public int cuas_trim_first = 5; // Trim targets after first (non-centered) pass (if > 0) public int cuas_trim_first = 5; // Trim targets after first (non-centered) pass (if > 0)
public boolean cuas_early_en = true; // Apply early fail filter after phase 1
public double cuas_early_mscore = 0.0015;// Minimal motion score (RSLT_MSCORE)
public double cuas_early_vstr = 0.007; // Minimal MV confidence (RSLT_VSTR)
public double cuas_early_score = 0.32; // Minimal score (RSLT_QSCORE)
public double cuas_early_amp = 0.35; // Minimal amplitude (RSLT_A)
// Recalculate Motion Vectors before centered \"tracking camera\" // Recalculate Motion Vectors before centered \"tracking camera\"
public boolean cuas_recalc_mv = true; // Recalculate motion vectors before centered targets accumulation by masking far-from target areas // public boolean cuas_recalc_mv = true; // Recalculate motion vectors before centered targets accumulation by masking far-from target areas
public int cuas_recalc_mv_num = 2; // Number of recalculations of the motion vectors before centered targets accumulation by masking far-from target areas public int cuas_recalc_mv_num = 2; // Number of recalculations of the motion vectors before centered targets accumulation by masking far-from target areas
public double cuas_recalc_mv_boost = 4.0; // Scale default number of correlation pairs for motion vectors calculation public double cuas_recalc_mv_boost = 4.0; // Scale default number of correlation pairs for motion vectors calculation
public double cuas_recalc_mv_corr = 4.0; // Scale corr_offset for refinement pass (will use (int)Math.round() public double cuas_recalc_mv_corr = 4.0; // Scale corr_offset for refinement pass (will use (int)Math.round()
...@@ -908,7 +914,8 @@ min_str_neib_fpn 0.35 ...@@ -908,7 +914,8 @@ min_str_neib_fpn 0.35
public boolean cuas_slow_en = true; // enable slow (almost static) target detection // verify temporal offset with fast public boolean cuas_slow_en = true; // enable slow (almost static) target detection // verify temporal offset with fast
public double cuas_slow_ra = 50.0; // running averaging for slow targets public double cuas_slow_ra = 50.0; // running averaging for slow targets
public double cuas_slow_score = 1.0; // scale scores for slow target mode public double cuas_slow_score = 1.0; // scale scores for slow target mode
public double cuas_score_mv = 0.0; // minimal score for the motion vectors //70: Phase1-mscore Rectangle(51, 38, 10, 1) scenes:[0, 235] min = 0.001979102846235037, max = 0.1058499738574028
public double cuas_score_mv = 0.0015; // minimal score for the motion vectors
public double cuas_score_lma = 1.6; // minimal score for the target LMA public double cuas_score_lma = 1.6; // minimal score for the target LMA
public double cuas_factor_lim = 5.0; // limit each individual score factor public double cuas_factor_lim = 5.0; // limit each individual score factor
public double cuas_factor_pow = 1.0; // raise score factor to this power before combining public double cuas_factor_pow = 1.0; // raise score factor to this power before combining
...@@ -2771,9 +2778,19 @@ min_str_neib_fpn 0.35 ...@@ -2771,9 +2778,19 @@ min_str_neib_fpn 0.35
gd.addNumericField("Trim targets after non-centered pass", this.cuas_trim_first, 0,3,"", gd.addNumericField("Trim targets after non-centered pass", this.cuas_trim_first, 0,3,"",
"Trim targets after first (non-centered) pass (if > 0)."); "Trim targets after first (non-centered) pass (if > 0).");
gd.addMessage("=== Early Fail Filters (after phase 1) ===");
gd.addCheckbox ("Apply early fail filters", this.cuas_early_en,
"Reduce number of target candidates after phase 1.");
gd.addNumericField("Motion score (RSLT_MSCORE)", this.cuas_early_mscore, 5,8,"",
"Minimal motion score (RSLT_MSCORE).");
gd.addNumericField("Motion confidence (RSLT_VSTR)", this.cuas_early_vstr, 5,8,"",
"Minimal MV confidence (RSLT_VSTR).");
gd.addNumericField("Score (RSLT_QSCORE)", this.cuas_early_score, 5,8,"",
"Minimal score (RSLT_QSCORE).");
gd.addNumericField("Amplitude (RSLT_A)", this.cuas_early_amp, 5,8,"",
"Minimal amplitude (RSLT_A).");
gd.addMessage("=== Recalculate Motion Vectors before centered \"tracking camera\" ==="); gd.addMessage("=== Recalculate Motion Vectors before centered \"tracking camera\" ===");
// gd.addCheckbox ("Refine motion vectors", this.cuas_recalc_mv,
// "Recalculate motion vectors before centered targets accumulation by masking far-from target areas.");
gd.addNumericField("Refine morion vector passes", this.cuas_recalc_mv_num, 0,3,"", gd.addNumericField("Refine morion vector passes", this.cuas_recalc_mv_num, 0,3,"",
"Number of MV refinement passes: 0 - no refinement, 1 - coarse, 2 coarse+fine."); "Number of MV refinement passes: 0 - no refinement, 1 - coarse, 2 coarse+fine.");
gd.addNumericField("Boost number of correlation pairs", this.cuas_recalc_mv_boost, 5,8,"x", gd.addNumericField("Boost number of correlation pairs", this.cuas_recalc_mv_boost, 5,8,"x",
...@@ -2915,6 +2932,9 @@ min_str_neib_fpn 0.35 ...@@ -2915,6 +2932,9 @@ min_str_neib_fpn 0.35
"Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0)."); "Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0).");
gd.addNumericField("Minimal max pixel to amplitude ratio", this.cuas_lma_a2a, 5,8,"", gd.addNumericField("Minimal max pixel to amplitude ratio", this.cuas_lma_a2a, 5,8,"",
"Minimal ratio of the maximal pixel near fitted maximum to the LMA amplitude."); "Minimal ratio of the maximal pixel near fitted maximum to the LMA amplitude.");
gd.addMessage("=== Reuse already calculated targets ===");
gd.addMessage("=== Slow targets detection ==="); gd.addMessage("=== Slow targets detection ===");
gd.addCheckbox ("Enable slow targets detection", this.cuas_slow_en, gd.addCheckbox ("Enable slow targets detection", this.cuas_slow_en,
...@@ -4453,8 +4473,13 @@ min_str_neib_fpn 0.35 ...@@ -4453,8 +4473,13 @@ min_str_neib_fpn 0.35
this.cuas_fin_range = (int) gd.getNextNumber(); this.cuas_fin_range = (int) gd.getNextNumber();
this.cuas_num_cycles = (int) gd.getNextNumber(); this.cuas_num_cycles = (int) gd.getNextNumber();
this.cuas_trim_first = (int) gd.getNextNumber(); this.cuas_trim_first = (int) gd.getNextNumber();
this.cuas_early_en = gd.getNextBoolean();
this.cuas_early_mscore = gd.getNextNumber();
this.cuas_early_vstr = gd.getNextNumber();
this.cuas_early_score = gd.getNextNumber();
this.cuas_early_amp = gd.getNextNumber();
// this.cuas_recalc_mv = gd.getNextBoolean();
this.cuas_recalc_mv_num = (int) gd.getNextNumber(); this.cuas_recalc_mv_num = (int) gd.getNextNumber();
this.cuas_recalc_mv_boost = gd.getNextNumber(); this.cuas_recalc_mv_boost = gd.getNextNumber();
this.cuas_recalc_mv_corr = gd.getNextNumber(); this.cuas_recalc_mv_corr = gd.getNextNumber();
...@@ -5777,6 +5802,12 @@ min_str_neib_fpn 0.35 ...@@ -5777,6 +5802,12 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_num_cycles", this.cuas_num_cycles+""); // int properties.setProperty(prefix+"cuas_num_cycles", this.cuas_num_cycles+""); // int
properties.setProperty(prefix+"cuas_trim_first", this.cuas_trim_first+""); // int properties.setProperty(prefix+"cuas_trim_first", this.cuas_trim_first+""); // int
properties.setProperty(prefix+"cuas_early_en", this.cuas_early_en+""); // boolean
properties.setProperty(prefix+"cuas_early_mscore", this.cuas_early_mscore+""); // double
properties.setProperty(prefix+"cuas_early_vstr", this.cuas_early_vstr+""); // double
properties.setProperty(prefix+"cuas_early_score", this.cuas_early_score+""); // double
properties.setProperty(prefix+"cuas_early_amp", this.cuas_early_amp+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_num", this.cuas_recalc_mv_num+""); // int properties.setProperty(prefix+"cuas_recalc_mv_num", this.cuas_recalc_mv_num+""); // int
properties.setProperty(prefix+"cuas_recalc_mv_boost", this.cuas_recalc_mv_boost+"");// double properties.setProperty(prefix+"cuas_recalc_mv_boost", this.cuas_recalc_mv_boost+"");// double
properties.setProperty(prefix+"cuas_recalc_mv_corr", this.cuas_recalc_mv_corr+""); // double properties.setProperty(prefix+"cuas_recalc_mv_corr", this.cuas_recalc_mv_corr+""); // double
...@@ -7033,7 +7064,13 @@ min_str_neib_fpn 0.35 ...@@ -7033,7 +7064,13 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_fin_range")!=null) this.cuas_fin_range=Integer.parseInt(properties.getProperty(prefix+"cuas_fin_range")); if (properties.getProperty(prefix+"cuas_fin_range")!=null) this.cuas_fin_range=Integer.parseInt(properties.getProperty(prefix+"cuas_fin_range"));
if (properties.getProperty(prefix+"cuas_num_cycles")!=null) this.cuas_num_cycles=Integer.parseInt(properties.getProperty(prefix+"cuas_num_cycles")); if (properties.getProperty(prefix+"cuas_num_cycles")!=null) this.cuas_num_cycles=Integer.parseInt(properties.getProperty(prefix+"cuas_num_cycles"));
if (properties.getProperty(prefix+"cuas_trim_first")!=null) this.cuas_trim_first=Integer.parseInt(properties.getProperty(prefix+"cuas_trim_first")); if (properties.getProperty(prefix+"cuas_trim_first")!=null) this.cuas_trim_first=Integer.parseInt(properties.getProperty(prefix+"cuas_trim_first"));
if (properties.getProperty(prefix+"cuas_early_en")!=null) this.cuas_early_en=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_early_en"));
if (properties.getProperty(prefix+"cuas_early_mscore")!=null) this.cuas_early_mscore=Double.parseDouble(properties.getProperty(prefix+"cuas_early_mscore"));
if (properties.getProperty(prefix+"cuas_early_vstr")!=null) this.cuas_early_vstr=Double.parseDouble(properties.getProperty(prefix+"cuas_early_vstr"));
if (properties.getProperty(prefix+"cuas_early_score")!=null) this.cuas_early_score=Double.parseDouble(properties.getProperty(prefix+"cuas_early_score"));
if (properties.getProperty(prefix+"cuas_early_amp")!=null) this.cuas_early_amp=Double.parseDouble(properties.getProperty(prefix+"cuas_early_amp"));
if (properties.getProperty(prefix+"cuas_recalc_mv_num")!=null) this.cuas_recalc_mv_num=Integer.parseInt(properties.getProperty(prefix+"cuas_recalc_mv_num")); if (properties.getProperty(prefix+"cuas_recalc_mv_num")!=null) this.cuas_recalc_mv_num=Integer.parseInt(properties.getProperty(prefix+"cuas_recalc_mv_num"));
if (properties.getProperty(prefix+"cuas_recalc_mv_boost")!=null) this.cuas_recalc_mv_boost=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_boost")); if (properties.getProperty(prefix+"cuas_recalc_mv_boost")!=null) this.cuas_recalc_mv_boost=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_boost"));
if (properties.getProperty(prefix+"cuas_recalc_mv_corr")!=null) this.cuas_recalc_mv_corr=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_corr")); if (properties.getProperty(prefix+"cuas_recalc_mv_corr")!=null) this.cuas_recalc_mv_corr=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_corr"));
...@@ -8307,6 +8344,12 @@ min_str_neib_fpn 0.35 ...@@ -8307,6 +8344,12 @@ min_str_neib_fpn 0.35
imp.cuas_fin_range = this.cuas_fin_range; imp.cuas_fin_range = this.cuas_fin_range;
imp.cuas_num_cycles = this.cuas_num_cycles; imp.cuas_num_cycles = this.cuas_num_cycles;
imp.cuas_trim_first = this.cuas_trim_first; imp.cuas_trim_first = this.cuas_trim_first;
imp.cuas_early_en = this.cuas_early_en;
imp.cuas_early_mscore = this.cuas_early_mscore;
imp.cuas_early_vstr = this.cuas_early_vstr;
imp.cuas_early_score = this.cuas_early_score;
imp.cuas_early_amp = this.cuas_early_amp;
imp.cuas_recalc_mv_num = this.cuas_recalc_mv_num; imp.cuas_recalc_mv_num = this.cuas_recalc_mv_num;
imp.cuas_recalc_mv_boost = this.cuas_recalc_mv_boost; imp.cuas_recalc_mv_boost = this.cuas_recalc_mv_boost;
......
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