Commit 520cb0d7 authored by Andrey Filippov's avatar Andrey Filippov

Adding more control and multi-pass refineMotionVectors()

parent 4adfcfa1
......@@ -83,58 +83,58 @@ public class CuasMotionLMA {
public static final int RSLT_VSTR = 19;
public static final int RSLT_VFRAC = 20;
public static final int RSLT_VBOOST = 21; // motion vector was calculated with boosted number of accumulated scene pairs (based scaled this)
public static final int RSLT_BX = 22;
public static final int RSLT_BY = 23; // RSLT_BX+1;
public static final int RSLT_AX = 24; // RSLT_BX+2;
public static final int RSLT_AY = 25; // RSLT_BX+3;
public static final int RSLT_MISMATCH_BEFORE = 26;
public static final int RSLT_MISMATCH_AFTER = 27; // RSLT_MISMATCH_BEFORE+1;
public static final int RSLT_MISMATCH_DIRS= 28;
public static final int RSLT_MATCH_LENGTH= 29; // is one less than the total length (0 - isolated)
public static final int RSLT_BEFORE_LENGTH= 30; // just for debug
public static final int RSLT_AFTER_LENGTH= 31; // just for debug
public static final int RSLT_SEQ_TRAVEL= 32;
public static final int RSLT_MSCORE = 33;
public static final int RSLT_QA = 34;
public static final int RSLT_QRMS = 35;
public static final int RSLT_QRMS_A = 36;
public static final int RSLT_QCENTER = 37;
public static final int RSLT_QMATCH = 38;
public static final int RSLT_QMATCH_LEN= 39;
public static final int RSLT_QTRAVEL= 40;
public static final int RSLT_QSCORE = 41;
public static final int RSLT_STRONGER = 42; // index of stronger neighbor (may be more)
public static final int RSLT_SLOW = 43; // 1 - slow, 0 - fast
public static final int RSLT_WHEN = 44;
public static final int RSLT_FAIL = 45;
public static final int RSLT_DISPARITY= 46; // disparity from single keyframe sequences
public static final int RSLT_DISP_DIFF= 47; // disparity difference between what?
public static final int RSLT_DISP_STR = 48; // disparity strength
public static final int RSLT_RANGE = 49; // range (meters) found from RSLT_DISPARITY, modified by RSLT_INFINITY
public static final int RSLT_GLOBAL = 50; // local target ID (1-based)
public static final int RSLT_GLENGTH = 51; // length (symmetrical around this one) for which disparity and range are provided
public static final int RSLT_GDISPARITY= 52; // disparity from accumulation of the range (RSLT_GLENGTH)
public static final int RSLT_GDISP_DIFF= 53; // disparity difference for a range
public static final int RSLT_GDISP_STR = 54; // disparity strength for a range
public static final int RSLT_GRANGE = 55; // global range - calculated for long sequences (and its fractions)
public static final int RSLT_FL_PX = 56; // flight log px
public static final int RSLT_FL_PY = 57; // flight log py
public static final int RSLT_FL_DISP = 58; // flight log true disparity
public static final int RSLT_FL_RANGE = 59; // flight log range (meters)
public static final int RSLT_INFINITY = 60; // disparity at infinity used for range calculation
public static final int RSLT_TARGET_ID = 61; // unique target id for the whole sequence of segments. 1 is reserved for the UAS
public static final int RSLT_VEL_AWAY = 62; // axial velocity (positive - away), range derivative (m/s), calculated from the difference to the previous/next series range
public static final int RSLT_VEL_RIGHT = 63; // lateral velocity, right ( calculated from angular and RSLT_GRANGE
public static final int RSLT_VEL_UP = 64; // lateral velocity, up ( calculated from angular and RSLT_GRANGE
public static final int RSLT_RANGE_LIN = 65; // range linear interpolated using previous/next series if the same target is present there
public static final int RSLT_VCORR = 22; // Last correction of VX, VY during refine (large correction means failed correction)
public static final int RSLT_BX = 23;
public static final int RSLT_BY = 24; // RSLT_BX+1;
public static final int RSLT_AX = 25; // RSLT_BX+2;
public static final int RSLT_AY = 26; // RSLT_BX+3;
public static final int RSLT_MISMATCH_BEFORE = 27;
public static final int RSLT_MISMATCH_AFTER = 28; // RSLT_MISMATCH_BEFORE+1;
public static final int RSLT_MISMATCH_DIRS= 29;
public static final int RSLT_MATCH_LENGTH= 30; // is one less than the total length (0 - isolated)
public static final int RSLT_BEFORE_LENGTH= 31; // just for debug
public static final int RSLT_AFTER_LENGTH= 32; // just for debug
public static final int RSLT_SEQ_TRAVEL= 33;
public static final int RSLT_MSCORE = 34;
public static final int RSLT_QA = 35;
public static final int RSLT_QRMS = 36;
public static final int RSLT_QRMS_A = 37;
public static final int RSLT_QCENTER = 38;
public static final int RSLT_QMATCH = 39;
public static final int RSLT_QMATCH_LEN= 40;
public static final int RSLT_QTRAVEL= 41;
public static final int RSLT_QSCORE = 42;
public static final int RSLT_STRONGER = 43; // index of stronger neighbor (may be more)
public static final int RSLT_SLOW = 44; // 1 - slow, 0 - fast
public static final int RSLT_WHEN = 45;
public static final int RSLT_FAIL = 46;
public static final int RSLT_DISPARITY= 47; // disparity from single keyframe sequences
public static final int RSLT_DISP_DIFF= 48; // disparity difference between what?
public static final int RSLT_DISP_STR = 49; // disparity strength
public static final int RSLT_RANGE = 50; // range (meters) found from RSLT_DISPARITY, modified by RSLT_INFINITY
public static final int RSLT_GLOBAL = 51; // local target ID (1-based)
public static final int RSLT_GLENGTH = 52; // length (symmetrical around this one) for which disparity and range are provided
public static final int RSLT_GDISPARITY= 53; // disparity from accumulation of the range (RSLT_GLENGTH)
public static final int RSLT_GDISP_DIFF= 54; // disparity difference for a range
public static final int RSLT_GDISP_STR = 55; // disparity strength for a range
public static final int RSLT_GRANGE = 56; // global range - calculated for long sequences (and its fractions)
public static final int RSLT_FL_PX = 57; // flight log px
public static final int RSLT_FL_PY = 58; // flight log py
public static final int RSLT_FL_DISP = 59; // flight log true disparity
public static final int RSLT_FL_RANGE = 60; // flight log range (meters)
public static final int RSLT_INFINITY = 61; // disparity at infinity used for range calculation
public static final int RSLT_TARGET_ID = 62; // unique target id for the whole sequence of segments. 1 is reserved for the UAS
public static final int RSLT_VEL_AWAY = 63; // axial velocity (positive - away), range derivative (m/s), calculated from the difference to the previous/next series range
public static final int RSLT_VEL_RIGHT = 64; // lateral velocity, right ( calculated from angular and RSLT_GRANGE
public static final int RSLT_VEL_UP = 65; // lateral velocity, up ( calculated from angular and RSLT_GRANGE
public static final int RSLT_RANGE_LIN = 66; // range linear interpolated using previous/next series if the same target is present there
public static final int RSLT_LEN = RSLT_RANGE_LIN + 1;
public static final String [] LMA_TITLES =
{"X-OFFS","Y-OFFS", "AMPLITUDE", "RADIUS","RAD_POS", "OVERSHOOT","OFFSET","RMSE","RMSE/A","MAX2A","ITERATIONS",
"CENTERED", "EXP-BOOST",
"Centr-X","Centr-Y","Centr-max","Centr-frac",
"Vx", "Vy", "V-conf","V-frac", "V-boost",// from motion vectors
"Vx", "Vy", "V-conf","V-frac", "V-boost","V-corr",// from motion vectors
"X-before", "Y-before","X-after","Y-after", // from getHalfBeforeAfterPixXY()
"ERR-BEFORE", "ERR-AFTER", "BA-DIRS", // before dir + 16*after dir
"Match-length",
......@@ -166,12 +166,13 @@ public class CuasMotionLMA {
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_K_HIGH = 14; // Overshoot is too high
public static final int FAIL_FAR = 15; // Peak is too far from the center
public static final int FAIL_HORIZON = 16; // Peak is below horizon
public static final int FAIL_MISMATCH = 17; // Mismatch on both ends is too high
public static final int FAIL_NEIGHBOR = 18; // failed because some neighbor is stronger
public static final int FAIL_DUPLICATE= 19; // coordinate are (almost) the same as those of a stronger tile
public static final int FAIL_USED= 20; // non-centered used to generate centered, remove this
public static final int FAIL_FL_ONLY= 21; // Flight log data only, no target detected here
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_HORIZON = 17; // Peak is below horizon
public static final int FAIL_MISMATCH = 18; // Mismatch on both ends is too high
public static final int FAIL_NEIGHBOR = 19; // failed because some neighbor is stronger
public static final int FAIL_DUPLICATE= 20; // coordinate are (almost) the same as those of a stronger tile
public static final int FAIL_USED= 21; // non-centered used to generate centered, remove this
public static final int FAIL_FL_ONLY= 22; // Flight log data only, no target detected here
public static final int CENTERED_NO = 0;
public static final int CENTERED_YES = 1;
......
......@@ -819,9 +819,14 @@ min_str_neib_fpn 0.35
// 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 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_r0 = 2.0; // Masking window parameters: for r <= r0, w = 1.0
public double cuas_recalc_mv_r1 = 6.0; // Masking window parameters: for r >= r1, w = 0.0, r0<r<r1: w = 0.5*(cos(PI*(r-r0)/(r1-r0))+1)
public double cuas_recalc_mv_corr = 4.0; // Scale corr_offset for refinement pass (will use (int)Math.round()
public double cuas_recalc_mv_r0 = 2.0; // Masking window parameters: for r <= r0, w = 1.0, first (coarse) pass
public double cuas_recalc_mv_r1 = 6.0; // Masking window parameters: for r >= r1, w = 0.0, r0<r<r1: w = 0.5*(cos(PI*(r-r0)/(r1-r0))+1), first (coarse) pass
public double cuas_recalc_mv_r0f = 1.5; // Masking window parameters: for r <= r0, w = 1.0, second (narrow) pass
public double cuas_recalc_mv_r1f = 4.0; // Masking window parameters: for r >= r1, w = 0.0, r0<r<r1: w = 0.5*(cos(PI*(r-r0)/(r1-r0))+1), second (narrow) pass
public double cuas_recalc_mv_max2 = 0.2; // Maximal Vx,Vy corection for the fine pass (only if cuas_recalc_mv_num >= 2)
public int cuas_mul_samples = 3; // multiply number of samples in slow mode
public int cuas_mul_offset = 5; // multiply correlation offset in slow mode
......@@ -2749,14 +2754,24 @@ min_str_neib_fpn 0.35
"Number of cycles of testing and removing bad targets from compoetition with weaker neighbors.");
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.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,"",
"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",
"Scale default number of correlation pairs for motion vectors calculation.");
gd.addNumericField("Center selection window R0 (inner)", this.cuas_recalc_mv_r0, 5,8,"pix",
"Masking window parameters: for r <= r0, w = 1.0");
gd.addNumericField("Center selection window R1 (outer)", this.cuas_recalc_mv_r1, 5,8,"pix",
gd.addNumericField("Scale correlation offset", this.cuas_recalc_mv_corr, 5,8,"x",
"Scale default default correlation offset for motion vectors calculation (will be limited so full offset does not exceed span).");
gd.addNumericField("Center selection window R0 (inner), coarse", this.cuas_recalc_mv_r0, 5,8,"pix",
"Masking window parameters: for r <= r0, w = 1.0 for the first (coarse) pass");
gd.addNumericField("Center selection window R1 (outer), coarse", this.cuas_recalc_mv_r1, 5,8,"pix",
"Masking window parameters: for r >= r1, w = 0.0, r0<r<r1: w = 0.5*(cos(PI*(r-r0)/(r1-r0))+1) for the first (coarse) pass.");
gd.addNumericField("Center selection window R0 (inner), coarse", this.cuas_recalc_mv_r0f, 5,8,"pix",
"Masking window parameters: for r <= r0, w = 1.0 for the second (fine) pass");
gd.addNumericField("Center selection window R1 (outer), coarse", this.cuas_recalc_mv_r1f, 5,8,"pix",
"Masking window parameters: for r >= r1, w = 0.0, r0<r<r1: w = 0.5*(cos(PI*(r-r0)/(r1-r0))+1).");
gd.addNumericField("Verify maximal Vx,Vy fine correction", this.cuas_recalc_mv_max2, 5,8,"",
"Fail if fine Vx,Vy corection for the fine pass (only if cuas_recalc_mv_num >= 2) exceeds this.");
gd.addMessage("=== Scale correlation parameters while detecting slow targets ===");
gd.addNumericField("Scale number of correlation samples", this.cuas_mul_samples, 0,3,"",
......@@ -4417,10 +4432,15 @@ min_str_neib_fpn 0.35
this.cuas_fin_range = (int) gd.getNextNumber();
this.cuas_num_cycles = (int) gd.getNextNumber();
this.cuas_recalc_mv = gd.getNextBoolean();
// this.cuas_recalc_mv = gd.getNextBoolean();
this.cuas_recalc_mv_num = (int) gd.getNextNumber();
this.cuas_recalc_mv_boost = gd.getNextNumber();
this.cuas_recalc_mv_corr = gd.getNextNumber();
this.cuas_recalc_mv_r0 = gd.getNextNumber();
this.cuas_recalc_mv_r1 = gd.getNextNumber();
this.cuas_recalc_mv_r0f = gd.getNextNumber();
this.cuas_recalc_mv_r1f = gd.getNextNumber();
this.cuas_recalc_mv_max2 = gd.getNextNumber();
this.cuas_mul_samples = (int) gd.getNextNumber();
this.cuas_mul_offset = (int) gd.getNextNumber();
......@@ -5731,10 +5751,15 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_fin_range", this.cuas_fin_range+""); // int
properties.setProperty(prefix+"cuas_num_cycles", this.cuas_num_cycles+""); // int
properties.setProperty(prefix+"cuas_recalc_mv", this.cuas_recalc_mv+""); // boolean
// properties.setProperty(prefix+"cuas_recalc_mv", this.cuas_recalc_mv+""); // boolean
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_corr", this.cuas_recalc_mv_corr+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_r0", this.cuas_recalc_mv_r0+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_r1", this.cuas_recalc_mv_r1+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_r0f", this.cuas_recalc_mv_r0f+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_r1f", this.cuas_recalc_mv_r1f+""); // double
properties.setProperty(prefix+"cuas_recalc_mv_max2", this.cuas_recalc_mv_max2+""); // double
properties.setProperty(prefix+"cuas_mul_samples", this.cuas_mul_samples+""); // int
properties.setProperty(prefix+"cuas_mul_offset", this.cuas_mul_offset+""); // int
......@@ -6980,10 +7005,15 @@ 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_num_cycles")!=null) this.cuas_num_cycles=Integer.parseInt(properties.getProperty(prefix+"cuas_num_cycles"));
if (properties.getProperty(prefix+"cuas_recalc_mv")!=null) this.cuas_recalc_mv=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_recalc_mv"));
// if (properties.getProperty(prefix+"cuas_recalc_mv")!=null) this.cuas_recalc_mv=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_recalc_mv"));
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_corr")!=null) this.cuas_recalc_mv_corr=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_corr"));
if (properties.getProperty(prefix+"cuas_recalc_mv_r0")!=null) this.cuas_recalc_mv_r0=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_r0"));
if (properties.getProperty(prefix+"cuas_recalc_mv_r1")!=null) this.cuas_recalc_mv_r1=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_r1"));
if (properties.getProperty(prefix+"cuas_recalc_mv_r0f")!=null) this.cuas_recalc_mv_r0f=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_r0f"));
if (properties.getProperty(prefix+"cuas_recalc_mv_r1f")!=null) this.cuas_recalc_mv_r1f=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_r1f"));
if (properties.getProperty(prefix+"cuas_recalc_mv_max2")!=null) this.cuas_recalc_mv_max2=Double.parseDouble(properties.getProperty(prefix+"cuas_recalc_mv_max2"));
if (properties.getProperty(prefix+"cuas_mul_samples")!=null) this.cuas_mul_samples=Integer.parseInt(properties.getProperty(prefix+"cuas_mul_samples"));
if (properties.getProperty(prefix+"cuas_mul_offset")!=null) this.cuas_mul_offset=Integer.parseInt(properties.getProperty(prefix+"cuas_mul_offset"));
......@@ -8246,10 +8276,15 @@ min_str_neib_fpn 0.35
imp.cuas_fin_range = this.cuas_fin_range;
imp.cuas_num_cycles = this.cuas_num_cycles;
imp.cuas_recalc_mv = this.cuas_recalc_mv;
// imp.cuas_recalc_mv = this.cuas_recalc_mv;
imp.cuas_recalc_mv_num = this.cuas_recalc_mv_num;
imp.cuas_recalc_mv_boost = this.cuas_recalc_mv_boost;
imp.cuas_recalc_mv_corr = this.cuas_recalc_mv_corr;
imp.cuas_recalc_mv_r0 = this.cuas_recalc_mv_r0;
imp.cuas_recalc_mv_r1 = this.cuas_recalc_mv_r1;
imp.cuas_recalc_mv_r0f = this.cuas_recalc_mv_r0f;
imp.cuas_recalc_mv_r1f = this.cuas_recalc_mv_r1f;
imp.cuas_recalc_mv_max2 = this.cuas_recalc_mv_max2;
imp.cuas_mul_samples = this.cuas_mul_samples;
imp.cuas_mul_offset = this.cuas_mul_offset;
......
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