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 { ...@@ -91,20 +91,23 @@ public class CuasMotionLMA {
"WHEN", "FAILURE"}; "WHEN", "FAILURE"};
public static final int FAIL_NONE = 0; 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_MOTION = 1; // motion strength/fraction 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_NO_MAX = 2; // no suitable local maximum
public static final int FAIL_LMA = 3; // LMA fail to converge public static final int FAIL_CENT_STR = 3; // centroid amplitude is too low
public static final int FAIL_A_LOW = 4; // 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_ACENT = 5; // ratio of maximal pixel to amplitude is too low public static final int FAIL_LMA = 5; // LMA fail to converge
public static final int FAIL_RMSE = 6; // RMSE is too high public static final int FAIL_A_LOW = 6; // amplitude is too low
public static final int FAIL_RMSE_R = 7; // BOTH RMSE is not sufficient and RMSE/A is too high public static final int FAIL_ACENT = 7; // ratio of maximal pixel to amplitude is too low
public static final int FAIL_R0_HIGH = 8; // Full radius (including negative overshoot) is too high public static final int FAIL_RMSE = 8; // RMSE is too high
public static final int FAIL_R1_LOW = 9; // Inner (positive) peak radius is too low public static final int FAIL_RMSE_R = 9; // BOTH RMSE is not sufficient and RMSE/A is too high
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_R0_HIGH = 10; // Full radius (including negative overshoot) is too high
public static final int FAIL_K_HIGH = 11; // Overshoot is too high public static final int FAIL_R1_LOW = 11; // Inner (positive) peak radius is too low
public static final int FAIL_FAR = 12; // Peak is too far from the center 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_HORIZON = 13; // Peak is below horizon public static final int FAIL_K_HIGH = 13; // Overshoot is too high
public static final int FAIL_MISMATCH = 14; // Mismatch on both ends 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 int width;
private double [][] window; private double [][] window;
......
...@@ -4728,6 +4728,7 @@ public class GpuQuad{ // quad camera description ...@@ -4728,6 +4728,7 @@ public class GpuQuad{ // quad camera description
* @param offset_scale multiply all vectors by this value when calculating pixel offsets * @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 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_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). * @param image_width image width in tiles (80 for 640-wide images).
* @return condensed array of TpTask * @return condensed array of TpTask
*/ */
...@@ -4736,6 +4737,7 @@ public class GpuQuad{ // quad camera description ...@@ -4736,6 +4737,7 @@ public class GpuQuad{ // quad camera description
final double offset_scale, final double offset_scale,
final double magnitude_scale, final double magnitude_scale,
final int index_vx, final int index_vx,
final int index_xc,
final int tilesX) { final int tilesX) {
final float fmagnitude_scale = (magnitude_scale==0)? 1.0f : ((float) -magnitude_scale); final float fmagnitude_scale = (magnitude_scale==0)? 1.0f : ((float) -magnitude_scale);
final int tiles = targets_array.length; final int tiles = targets_array.length;
...@@ -4754,6 +4756,10 @@ public class GpuQuad{ // quad camera description ...@@ -4754,6 +4756,10 @@ public class GpuQuad{ // quad camera description
int tileX = nTile % tilesX;; int tileX = nTile % tilesX;;
double dx = targets_array[nTile][index_vx + 0]*offset_scale; double dx = targets_array[nTile][index_vx + 0]*offset_scale;
double dy = targets_array[nTile][index_vx + 1]*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 double [] cxy0 = { // uniform coordinates for the center scene
(tileX + 0.5) * GPUTileProcessor.DTT_SIZE, (tileX + 0.5) * GPUTileProcessor.DTT_SIZE,
(tileY + 0.5) * GPUTileProcessor.DTT_SIZE}; (tileY + 0.5) * GPUTileProcessor.DTT_SIZE};
......
...@@ -2572,7 +2572,8 @@ public class Correlation2d { ...@@ -2572,7 +2572,8 @@ public class Correlation2d {
System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1] +" ("+rslt[2]+"), frac = " + rslt[3]); 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])) { 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; return rslt;
} else { } else {
...@@ -2581,7 +2582,8 @@ public class Correlation2d { ...@@ -2581,7 +2582,8 @@ public class Correlation2d {
System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1] +" ("+rslt[2]+")"); System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1] +" ("+rslt[2]+")");
} }
if (Double.isNaN(rslt[0]) || Double.isNaN(rslt[1]) || Double.isNaN(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; return rslt;
} }
......
...@@ -4851,22 +4851,15 @@ public class OpticalFlow { ...@@ -4851,22 +4851,15 @@ public class OpticalFlow {
double min_ref_frac= clt_parameters.imp.min_ref_frac; double min_ref_frac= clt_parameters.imp.min_ref_frac;
boolean cuas_subtract_fpn = clt_parameters.imp.cuas_subtract_fpn; 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_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_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_step_debug = clt_parameters.imp.cuas_step_debug;
boolean cuas_reset_first= clt_parameters.imp.cuas_reset_first && first_in_series; 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 boolean combine_clt = clt_parameters.imp.cuas_rotation; // (cuas_atr[0] != 0) || (cuas_atr[1] != 0) || (cuas_atr[2] != 0);
/// double cuas_invert_tolerance = clt_parameters.imp.cuas_invert_tolerance;// 0.001 Finish enhancing when last change was lower than boolean update_existing = clt_parameters.imp.cuas_update_existing; // re-create center_CLT if it exists (FIXME: accumulates errors - need fixing)
/// int cuas_invert_gap2 = clt_parameters.imp.cuas_invert_gap2; // 10 Maximal dual gap size for inversion (depends on scanning radius in tiles)
double [] ref_blue_sky = null; // turn off "lma" in the ML output double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options if (reuse_video) { // disable all other options
...@@ -5252,7 +5245,7 @@ public class OpticalFlow { ...@@ -5252,7 +5245,7 @@ public class OpticalFlow {
// use master_clt? - where to look for stage. in CUAS mode build directory name and look there // use master_clt? - where to look for stage. in CUAS mode build directory name and look there
if (center_CLT != null) { if (center_CLT != null) {
if (center_CLT.getNumOrient() == 0) { 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."); System.out.println("center_CLT exists, but does not have egomotion data. Forcing its calculation.");
} }
force_initial_orientations = true; force_initial_orientations = true;
...@@ -5480,7 +5473,7 @@ public class OpticalFlow { ...@@ -5480,7 +5473,7 @@ public class OpticalFlow {
if (combo_dsn_final == null) { if (combo_dsn_final == null) {
combo_dsn_final =quadCLTs[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky 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); System.out.println("Creating center_CLT from the reference one (ref_index="+ref_index);
} }
center_CLT = Cuas.createCenterClt( // assuming cuas_rotation is true center_CLT = Cuas.createCenterClt( // assuming cuas_rotation is true
...@@ -5493,7 +5486,7 @@ public class OpticalFlow { ...@@ -5493,7 +5486,7 @@ public class OpticalFlow {
sensor_mask_clt, // int sensor_mask, // -1 - all; sensor_mask_clt, // int sensor_mask, // -1 - all;
true, // boolean // new_average, true, // boolean // new_average,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
if (debugLevel > -3) { if (debugLevel > -4) {
System.out.println("Cuas.createCenterClt() done, center_CLT="+((center_CLT==null)? "null":center_CLT.toString())); System.out.println("Cuas.createCenterClt() done, center_CLT="+((center_CLT==null)? "null":center_CLT.toString()));
} }
} }
...@@ -6040,7 +6033,6 @@ public class OpticalFlow { ...@@ -6040,7 +6033,6 @@ public class OpticalFlow {
System.out.println ("Omegas ATR: "+center_ATR[2][0]+", "+center_ATR[2][1]+", "+center_ATR[2][2]); 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 // TODO: Refine center_CLT if it exists, not create
...@@ -6071,13 +6063,13 @@ public class OpticalFlow { ...@@ -6071,13 +6063,13 @@ public class OpticalFlow {
if (cuas_centers != null) { if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath(); cuas_centers[1] = center_CLT.getImagePath();
} }
if (debugLevel > -3) { if (debugLevel > -4) {
System.out.println("Created/saved center CLT "+center_CLT.getImagePath()); System.out.println("Created/saved center CLT "+center_CLT.getImagePath());
} }
dbg_created=true; dbg_created=true;
} else { } else if (update_existing) {
if (debugLevel > -3) { if (debugLevel > -4) {
System.out.println("Updating CLT"); System.out.println("Updating existing CLT (FIXME: accumulates errors - needs fixing)");
} }
boolean condition_dsi = true; boolean condition_dsi = true;
if (combo_dsn_final == null) { if (combo_dsn_final == null) {
...@@ -6096,12 +6088,15 @@ public class OpticalFlow { ...@@ -6096,12 +6088,15 @@ public class OpticalFlow {
if (cuas_centers != null) { if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath(); cuas_centers[1] = center_CLT.getImagePath();
} }
if (debugLevel > -3) { if (debugLevel > -4) {
System.out.println("Updated/saved center CLT "+center_CLT.getImagePath()); 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(); // setCenterAverage();
ImagePlus imp_center_clt= center_CLT.showCenterClt( ImagePlus imp_center_clt= center_CLT.showCenterClt(
null, // float [][] fclt, // may be null null, // float [][] fclt, // may be null
...@@ -7287,7 +7282,8 @@ public class OpticalFlow { ...@@ -7287,7 +7282,8 @@ public class OpticalFlow {
String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths; String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths;
boolean bkp_use_set_dirs = quadCLT_main.correctionsParameters.use_set_dirs; 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_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_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0};
double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0}; double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0};
...@@ -7301,7 +7297,6 @@ public class OpticalFlow { ...@@ -7301,7 +7297,6 @@ public class OpticalFlow {
} }
quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels; quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels;
quadCLT_main.correctionsParameters.linkedCenters = bkp_linkedCenters; quadCLT_main.correctionsParameters.linkedCenters = bkp_linkedCenters;
/// quadCLT_main.correctionsParameters.cuasSeed = bkp_cuasSeed;
quadCLT_main.correctionsParameters.cuasSeedDir = bkp_cuasSeedDir; quadCLT_main.correctionsParameters.cuasSeedDir = bkp_cuasSeedDir;
quadCLT_main.correctionsParameters.videoDirectory = bkp_videoDirectory; quadCLT_main.correctionsParameters.videoDirectory = bkp_videoDirectory;
quadCLT_main.correctionsParameters.x3dDirectory = bkp_x3dDirectory; quadCLT_main.correctionsParameters.x3dDirectory = bkp_x3dDirectory;
...@@ -7315,6 +7310,7 @@ public class OpticalFlow { ...@@ -7315,6 +7310,7 @@ public class OpticalFlow {
quadCLT_main.correctionsParameters.cuasCameraATR = bkp_cuasCameraATR; quadCLT_main.correctionsParameters.cuasCameraATR = bkp_cuasCameraATR;
quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome; quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome;
quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome; quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome;
quadCLT_main.correctionsParameters.cuasSkyMask = bkp_cuasSkyMask;
System.out.println("buildSeries(): DONE"); // System.out.println("buildSeries(): DONE"); //
// String top_dir0=quadCLTs[ref_index].getX3dTopDirectory(); // String top_dir0=quadCLTs[ref_index].getX3dTopDirectory();
......
...@@ -8645,6 +8645,9 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8645,6 +8645,9 @@ if (debugLevel > -100) return true; // temporarily !
cuas_centers = new String [] {quadCLT_main.correctionsParameters.getCuasDir(),""}; 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++) { for (int nseq = 0; nseq < num_seq; nseq++) {
long start_time_seq = System.nanoTime(); long start_time_seq = System.nanoTime();
System.out.println("\nSTARTED PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+")\n"); System.out.println("\nSTARTED PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+")\n");
...@@ -8668,6 +8671,10 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8668,6 +8671,10 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.imp.mov_max_len+" tiles."); 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][]; String [][] video_list = new String[1][];
...@@ -8676,9 +8683,6 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8676,9 +8683,6 @@ if (debugLevel > -100) return true; // temporarily !
int [] start_ref_pointers = new int[2]; //{earlist, reference} - reference may be center int [] start_ref_pointers = new int[2]; //{earlist, reference} - reference may be center
boolean first_in_series = true; boolean first_in_series = true;
// Process UAS logs // Process UAS logs
// quadCLT_main.correctionsParameters.cuasUasLogs, // String cuasUasLogs,
// quadCLT_main.correctionsParameters.cuasUasTimeStamp, // double cuasUasTimeStamp,
// quadCLT_main.correctionsParameters.cuasCameraATR, // double [] cuasCameraATR,
UasLogReader uasLogReader = null; UasLogReader uasLogReader = null;
String uas_log_path = quadCLT_main.correctionsParameters.getUasLogsPath(); String uas_log_path = quadCLT_main.correctionsParameters.getUasLogsPath();
if ((uas_log_path != null) && (uas_log_path.length() > 0)) { if ((uas_log_path != null) && (uas_log_path.length() > 0)) {
...@@ -8686,6 +8690,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8686,6 +8690,8 @@ if (debugLevel > -100) return true; // temporarily !
uasLogReader.setCameraATR(quadCLT_main.correctionsParameters.cuasCameraATR); uasLogReader.setCameraATR(quadCLT_main.correctionsParameters.cuasCameraATR);
uasLogReader.setUASHomeNed(quadCLT_main.correctionsParameters.cuasSetHome? quadCLT_main.correctionsParameters.cuasUASHome : null); uasLogReader.setUASHomeNed(quadCLT_main.correctionsParameters.cuasSetHome? quadCLT_main.correctionsParameters.cuasUASHome : null);
} }
while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) { while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) {
String model_directory = opticalFlow.buildSeries( String model_directory = opticalFlow.buildSeries(
(pathFirstLast != null), //boolean batch_mode, (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