Commit fb528d3a authored by Andrey Filippov's avatar Andrey Filippov

improving target detection

parent 99bfce50
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -91,20 +91,23 @@ public class CuasMotionLMA {
"WHEN", "FAILURE"};
public static final int FAIL_NONE = 0;
public static final int FAIL_CENT_STR = 1; // centroid amplitude is too low
public static final int FAIL_CENT_FRAC = 2; // Centroid fraction (energy in the peak fraction of all) is too low
public static final int FAIL_LMA = 3; // LMA fail to converge
public static final int FAIL_A_LOW = 4; // amplitude is too low
public static final int FAIL_ACENT = 5; // ratio of maximal pixel to amplitude is too low
public static final int FAIL_RMSE = 6; // RMSE is too high
public static final int FAIL_RMSE_R = 7; // BOTH RMSE is not sufficient and RMSE/A is too high
public static final int FAIL_R0_HIGH = 8; // Full radius (including negative overshoot) is too high
public static final int FAIL_R1_LOW = 9; // Inner (positive) peak radius is too low
public static final int FAIL_K_LOW = 10; // Overshoot is too low (not used, it can be down to 0)
public static final int FAIL_K_HIGH = 11; // Overshoot is too high
public static final int FAIL_FAR = 12; // Peak is too far from the center
public static final int FAIL_HORIZON = 13; // Peak is below horizon
public static final int FAIL_MISMATCH = 14; // Mismatch on both ends is too high
public static final int FAIL_MOTION = 1; // motion strength/fraction too low
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_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_A_LOW = 6; // amplitude is too low
public static final int FAIL_ACENT = 7; // ratio of maximal pixel to amplitude is too low
public static final int FAIL_RMSE = 8; // RMSE is too high
public static final int FAIL_RMSE_R = 9; // BOTH RMSE is not sufficient and RMSE/A is too high
public static final int FAIL_R0_HIGH = 10; // Full radius (including negative overshoot) is too high
public static final int FAIL_R1_LOW = 11; // Inner (positive) peak radius is too low
public static final int FAIL_K_LOW = 12; // Overshoot is too low (not used, it can be down to 0)
public static final int FAIL_K_HIGH = 13; // Overshoot is too high
public static final int FAIL_FAR = 14; // Peak is too far from the center
public static final int FAIL_HORIZON = 15; // Peak is below horizon
public static final int FAIL_MISMATCH = 16; // Mismatch on both ends is too high
public static final int FAIL_NEIGHBOR = 17; // failed because some neighbor is stronger
private int width;
private double [][] window;
......
......@@ -4728,6 +4728,7 @@ public class GpuQuad{ // quad camera description
* @param offset_scale multiply all vectors by this value when calculating pixel offsets
* @param magnitude_scale Scale data for accumulation (here positive, will be negated). If 0 - will use scale=1.0 (no accumulation)
* @param index_vx - index of vx in the targets_array[tile] array
* @param index_xc - index of xc in the targets_array[tile] array to center target or <0 to render as is
* @param image_width image width in tiles (80 for 640-wide images).
* @return condensed array of TpTask
*/
......@@ -4736,6 +4737,7 @@ public class GpuQuad{ // quad camera description
final double offset_scale,
final double magnitude_scale,
final int index_vx,
final int index_xc,
final int tilesX) {
final float fmagnitude_scale = (magnitude_scale==0)? 1.0f : ((float) -magnitude_scale);
final int tiles = targets_array.length;
......@@ -4754,6 +4756,10 @@ public class GpuQuad{ // quad camera description
int tileX = nTile % tilesX;;
double dx = targets_array[nTile][index_vx + 0]*offset_scale;
double dy = targets_array[nTile][index_vx + 1]*offset_scale;
if ((index_xc >= 0) && !Double.isNaN( targets_array[nTile][index_xc])) {
dx += targets_array[nTile][index_xc + 0];
dy += targets_array[nTile][index_xc + 1];
}
double [] cxy0 = { // uniform coordinates for the center scene
(tileX + 0.5) * GPUTileProcessor.DTT_SIZE,
(tileY + 0.5) * GPUTileProcessor.DTT_SIZE};
......
......@@ -2572,7 +2572,8 @@ public class Correlation2d {
System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1] +" ("+rslt[2]+"), frac = " + rslt[3]);
}
if (Double.isNaN(rslt[0]) || Double.isNaN(rslt[1]) || Double.isNaN(rslt[2])) {
System.out.println("getMaxXYCm():NaN");
// System.out.println("getMaxXYCm():NaN");
return null;
}
return rslt;
} else {
......@@ -2581,7 +2582,8 @@ public class Correlation2d {
System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1] +" ("+rslt[2]+")");
}
if (Double.isNaN(rslt[0]) || Double.isNaN(rslt[1]) || Double.isNaN(rslt[2])) {
System.out.println("getMaxXYCm():NaN");
// System.out.println("getMaxXYCm():NaN");
return null;
}
return rslt;
}
......
......@@ -4851,22 +4851,15 @@ public class OpticalFlow {
double min_ref_frac= clt_parameters.imp.min_ref_frac;
boolean cuas_subtract_fpn = clt_parameters.imp.cuas_subtract_fpn;
/// boolean cuas_calc_fpn = clt_parameters.imp.cuas_calc_fpn;
/// double cuas_rot_period = clt_parameters.imp.cuas_rot_period;
boolean cuas_subtract_rowcol=clt_parameters.imp.cuas_subtract_rowcol;// Subtract row/column noise
/// boolean cuas_calc_rowcol= clt_parameters.imp.cuas_calc_rowcol; // Recalculate+save row/column noise, if false - try to read saved one first
/// double cuas_um_sigma = clt_parameters.imp.cuas_um_sigma; // Apply Unsharp Mask filter sigma when calculating row/column noise
/// double cuas_max_abs_rowcol= clt_parameters.imp.cuas_max_abs_rowcol; // consider pixels with abs(UM difference) does not exceed this value
/// double cuas_outliers_rowcol=clt_parameters.imp.cuas_outliers_rowcol;// scale weight of the outliers with high difference (to prevent undefined values
boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
boolean cuas_step_debug = clt_parameters.imp.cuas_step_debug;
boolean cuas_reset_first= clt_parameters.imp.cuas_reset_first && first_in_series;
/// int cuas_invert_margins = clt_parameters.imp.cuas_invert_margins; // 1 Expand image each side when inverting tasks
/// int cuas_invert_iters = clt_parameters.imp.cuas_invert_iters; // 4 Enhance inversion iterations
/// double cuas_invert_tolerance = clt_parameters.imp.cuas_invert_tolerance;// 0.001 Finish enhancing when last change was lower than
/// int cuas_invert_gap2 = clt_parameters.imp.cuas_invert_gap2; // 10 Maximal dual gap size for inversion (depends on scanning radius in tiles)
boolean combine_clt = clt_parameters.imp.cuas_rotation; // (cuas_atr[0] != 0) || (cuas_atr[1] != 0) || (cuas_atr[2] != 0);
boolean update_existing = clt_parameters.imp.cuas_update_existing; // re-create center_CLT if it exists (FIXME: accumulates errors - need fixing)
double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options
......@@ -5252,7 +5245,7 @@ public class OpticalFlow {
// use master_clt? - where to look for stage. in CUAS mode build directory name and look there
if (center_CLT != null) {
if (center_CLT.getNumOrient() == 0) {
if (debugLevel >-3) {
if (debugLevel >-4) {
System.out.println("center_CLT exists, but does not have egomotion data. Forcing its calculation.");
}
force_initial_orientations = true;
......@@ -5480,7 +5473,7 @@ public class OpticalFlow {
if (combo_dsn_final == null) {
combo_dsn_final =quadCLTs[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
}
if (debugLevel > -3) {
if (debugLevel > -4) {
System.out.println("Creating center_CLT from the reference one (ref_index="+ref_index);
}
center_CLT = Cuas.createCenterClt( // assuming cuas_rotation is true
......@@ -5493,7 +5486,7 @@ public class OpticalFlow {
sensor_mask_clt, // int sensor_mask, // -1 - all;
true, // boolean // new_average,
debugLevel); // int debugLevel)
if (debugLevel > -3) {
if (debugLevel > -4) {
System.out.println("Cuas.createCenterClt() done, center_CLT="+((center_CLT==null)? "null":center_CLT.toString()));
}
}
......@@ -6040,7 +6033,6 @@ public class OpticalFlow {
System.out.println ("Omegas ATR: "+center_ATR[2][0]+", "+center_ATR[2][1]+", "+center_ATR[2][2]);
}
boolean combine_clt = clt_parameters.imp.cuas_rotation; // (cuas_atr[0] != 0) || (cuas_atr[1] != 0) || (cuas_atr[2] != 0);
// TODO: Refine center_CLT if it exists, not create
......@@ -6071,13 +6063,13 @@ public class OpticalFlow {
if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath();
}
if (debugLevel > -3) {
if (debugLevel > -4) {
System.out.println("Created/saved center CLT "+center_CLT.getImagePath());
}
dbg_created=true;
} else {
if (debugLevel > -3) {
System.out.println("Updating CLT");
} else if (update_existing) {
if (debugLevel > -4) {
System.out.println("Updating existing CLT (FIXME: accumulates errors - needs fixing)");
}
boolean condition_dsi = true;
if (combo_dsn_final == null) {
......@@ -6096,12 +6088,15 @@ public class OpticalFlow {
if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath();
}
if (debugLevel > -3) {
if (debugLevel > -4) {
System.out.println("Updated/saved center CLT "+center_CLT.getImagePath());
}
} else {
if (debugLevel > -4) {
System.out.println("Spipping update of center CLT (it is reaed from "+center_CLT.getImagePath()+").");
}
}
// setCenterAverage();
ImagePlus imp_center_clt= center_CLT.showCenterClt(
null, // float [][] fclt, // may be null
......@@ -7287,7 +7282,8 @@ public class OpticalFlow {
String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths;
boolean bkp_use_set_dirs = quadCLT_main.correctionsParameters.use_set_dirs;
String bkp_cuasUasLogs = quadCLT_main.correctionsParameters.cuasUasLogs; // json file path containing UAS logs
String bkp_cuasUasLogs = quadCLT_main.correctionsParameters.cuasSkyMask; // TIFF image 640x512 where 1.0 - sky, 0.0 - ground, blurred with GB (now sigma==2.0)
String bkp_cuasSkyMask = quadCLT_main.correctionsParameters.cuasUasLogs; // json file path containing UAS logs
double bkp_cuasUasTimeStamp = quadCLT_main.correctionsParameters.cuasUasTimeStamp; // 0.0; // timestamp corresponding to the UAS time 0.0
double [] bkp_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0};
double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0};
......@@ -7299,22 +7295,22 @@ public class OpticalFlow {
if (master_CLT != quadCLTs[ref_index]) {
quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
}
quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels;
quadCLT_main.correctionsParameters.linkedCenters = bkp_linkedCenters;
/// quadCLT_main.correctionsParameters.cuasSeed = bkp_cuasSeed;
quadCLT_main.correctionsParameters.cuasSeedDir = bkp_cuasSeedDir;
quadCLT_main.correctionsParameters.videoDirectory = bkp_videoDirectory;
quadCLT_main.correctionsParameters.x3dDirectory = bkp_x3dDirectory;
quadCLT_main.correctionsParameters.mlDirectory = bkp_mlDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourcePaths = bkp_sourcePaths;
quadCLT_main.correctionsParameters.use_set_dirs = bkp_use_set_dirs;
quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels;
quadCLT_main.correctionsParameters.linkedCenters = bkp_linkedCenters;
quadCLT_main.correctionsParameters.cuasSeedDir = bkp_cuasSeedDir;
quadCLT_main.correctionsParameters.videoDirectory = bkp_videoDirectory;
quadCLT_main.correctionsParameters.x3dDirectory = bkp_x3dDirectory;
quadCLT_main.correctionsParameters.mlDirectory = bkp_mlDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourcePaths = bkp_sourcePaths;
quadCLT_main.correctionsParameters.use_set_dirs = bkp_use_set_dirs;
quadCLT_main.correctionsParameters.cuasUasLogs = bkp_cuasUasLogs;
quadCLT_main.correctionsParameters.cuasUasTimeStamp = bkp_cuasUasTimeStamp;
quadCLT_main.correctionsParameters.cuasCameraATR = bkp_cuasCameraATR;
quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome;
quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome;
quadCLT_main.correctionsParameters.cuasSkyMask = bkp_cuasSkyMask;
System.out.println("buildSeries(): DONE"); //
// String top_dir0=quadCLTs[ref_index].getX3dTopDirectory();
......
......@@ -8645,6 +8645,9 @@ if (debugLevel > -100) return true; // temporarily !
cuas_centers = new String [] {quadCLT_main.correctionsParameters.getCuasDir(),""};
}
*/
String uas_sky_mask_path = quadCLT_main.correctionsParameters.getUasSkyMask();
for (int nseq = 0; nseq < num_seq; nseq++) {
long start_time_seq = System.nanoTime();
System.out.println("\nSTARTED PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+")\n");
......@@ -8668,6 +8671,10 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.imp.mov_max_len+" tiles.");
}
}
clt_parameters.imp.cuas_sky_path = uas_sky_mask_path;
if (clt_parameters.imp.cuas_sky_path != null) {
clt_parameters.imp.cuas_sky_offset = new double[] {pathFirstLast[nseq].mask_x,pathFirstLast[nseq].mask_y};
}
}
String [][] video_list = new String[1][];
......@@ -8676,9 +8683,6 @@ if (debugLevel > -100) return true; // temporarily !
int [] start_ref_pointers = new int[2]; //{earlist, reference} - reference may be center
boolean first_in_series = true;
// Process UAS logs
// quadCLT_main.correctionsParameters.cuasUasLogs, // String cuasUasLogs,
// quadCLT_main.correctionsParameters.cuasUasTimeStamp, // double cuasUasTimeStamp,
// quadCLT_main.correctionsParameters.cuasCameraATR, // double [] cuasCameraATR,
UasLogReader uasLogReader = null;
String uas_log_path = quadCLT_main.correctionsParameters.getUasLogsPath();
if ((uas_log_path != null) && (uas_log_path.length() > 0)) {
......@@ -8686,6 +8690,8 @@ if (debugLevel > -100) return true; // temporarily !
uasLogReader.setCameraATR(quadCLT_main.correctionsParameters.cuasCameraATR);
uasLogReader.setUASHomeNed(quadCLT_main.correctionsParameters.cuasSetHome? quadCLT_main.correctionsParameters.cuasUASHome : null);
}
while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) {
String model_directory = opticalFlow.buildSeries(
(pathFirstLast != null), //boolean batch_mode,
......
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