Commit d0c338fe authored by Andrey Filippov's avatar Andrey Filippov

Starting cuas series combining

parent 0ce393c1
......@@ -7893,6 +7893,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
try {
TwoQuadCLT.buildSeriesTQ(
0, // int cuas_proc_mode, // 0 - old, 1 combine scene series
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
......
......@@ -1825,7 +1825,7 @@ public class CuasMotion {
for (int i = 0; i < CuasMotionLMA.LMA_TITLES.length; i++) {
frame_titles[i] = CuasMotionLMA.LMA_TITLES[i];
}
frame_titles[CuasMotionLMA.LMA_TITLES.length] = "Targets";
frame_titles[CuasMotionLMA.LMA_TITLES.length] = CuasMotionLMA.EXTRA_SLICE_DISCARD_ON_LOAD; // "Targets"; // will be discarded
double [][][] img_data = new double [num_fields+1][num_scenes][num_tiles];
for (int nscene = 0; nscene < num_scenes; nscene++) {
for (int nfield = 0; nfield < img_data.length; nfield++) {
......@@ -1837,6 +1837,7 @@ public class CuasMotion {
for (int nfield = 0; nfield < num_fields; nfield++) {
img_data[nfield][nscene][ntile] = target[nfield];
}
// dangerous - saves and then loads (on reuse)
img_data[num_fields][nscene][ntile] = ((target[CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE) &&
Double.isNaN(target[CuasMotionLMA.RSLT_STRONGER]))? 1:0;
}
......@@ -1913,7 +1914,8 @@ public class CuasMotion {
return vf;
}
public static double [][][] getTargetsFromHyperAugment(String path){ // add empty fields to the end of each target if shorter than CuasMotionLMA.RSLT_LEN
public static double [][][] getTargetsFromHyperAugment(
String path){ // add empty fields to the end of each target if shorter than CuasMotionLMA.RSLT_LEN
int [] wh = new int [2];
String [][] pvf_top_titles = new String[1][];
String [][] pvf_titles = new String[1][];
......@@ -1926,6 +1928,11 @@ public class CuasMotion {
return null;
}
int num_fields = targets_file.length;
// fix - discarding last slice if it is called CuasMotionLMA.EXTRA_SLICE_DISCARD_ON_LOAD ("Targets")
if (pvf_top_titles[0][pvf_top_titles[0].length-1].equals(CuasMotionLMA.EXTRA_SLICE_DISCARD_ON_LOAD)) {
System.out.println("getTargetsFromHyperAugment(): removing last slice called "+ pvf_top_titles[0][pvf_top_titles[0].length-1]);
num_fields--;
}
int num_fields_augmented = Math.max(num_fields, CuasMotionLMA.RSLT_LEN);
int num_seq = targets_file[0].length;
int num_tiles = targets_file[0][0].length;
......@@ -3167,7 +3174,7 @@ public class CuasMotion {
* @param mask_blur mask transition width
* @param round false - square (no blur), true - round
* @param target_keyframes accumulated target images (centered to the tiles if center is true)
* @param vector_field [scene][tile][] first two elements - targets vX, vY in pixels per frame. Empty are nulls, same velocities for 5x5
* @param target_sequence [scene][tile][] first two elements - targets vX, vY in pixels per frame. Empty are nulls, same velocities for 5x5
* @param target_positions [scene][tile][] target positions of the targets relative to the tile center
* @param background static scenes to be overlaid by the targets
* @param frame0 frame number of the background corresponding to the first keyframe
......
......@@ -93,7 +93,13 @@ public class CuasMotionLMA {
public static final int RSLT_GDISP_DIFF= 51;
public static final int RSLT_GDISP_STR = 52;
public static final int RSLT_GRANGE = 53;
public static final int RSLT_LEN = RSLT_GRANGE+1;
public static final int RSLT_FL_PX = 54; // flight log px
public static final int RSLT_FL_PY = 55; // flight log py
public static final int RSLT_FL_DISP = 56; // flight log true disparity
public static final int RSLT_FL_RANGE = 57; // flight log range (meters)
public static final int RSLT_INFINITY = 58; // disparity at infinity used for range calculation
public static final int RSLT_LEN = RSLT_INFINITY + 1;
public static final String [] LMA_TITLES =
{"X-OFFS","Y-OFFS", "AMPLITUDE", "RADIUS","RAD_POS", "OVERSHOOT","OFFSET","RMSE","RMSE/A","MAX2A","ITERATIONS",
......@@ -110,8 +116,9 @@ public class CuasMotionLMA {
"Stronger","Slow",
"WHEN", "FAILURE",
"Disparity","Disparity-Diff","Strength","Range","Global-index",
"segment-length","segment-disparity","segment_disp-diff", "segment-strength", "segment-range"};
"segment-length","segment-disparity","segment_disp-diff", "segment-strength", "segment-range",
"FLOG-px","FLOG-pY","FLOG-DISP","FLOG-range","infinity"};
public static final String EXTRA_SLICE_DISCARD_ON_LOAD = "Targets";
public static final int FAIL_NONE = 0;
public static final int FAIL_MOTION = 1; // motion strength/fraction too low
public static final int FAIL_NO_MAX = 2; // no suitable local maximum
......@@ -133,6 +140,7 @@ public class CuasMotionLMA {
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 CENTERED_NO = 0;
public static final int CENTERED_YES = 1;
......
......@@ -238,7 +238,8 @@ public class CuasRanging {
System.out.println("processMovingTargetsMulti(): re-using target disparities from "+disparity_path);
}
}
if ((disparity_targets == null) || rng_glob) { // for now - always recalculate if
// if ((disparity_targets == null) || rng_glob) { // for now - always recalculate if
if (disparity_targets == null) {
if (debugLevel > -4) {
System.out.println("detectTargets(): Generating target disparities");
}
......@@ -264,14 +265,6 @@ 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);
if (rng_glob) {
// glob_stats =
......@@ -290,24 +283,36 @@ public class CuasRanging {
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 (!generate_csv) { // if csv is generated, data will be saved later
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,
center_CLT.getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_DISPARITIES_SUFFIX),
!batch_mode, // boolean show,
cuasMotion.getTilesX()); // int tilesX) {
center_CLT.saveImagePlusInModelDirectory(imp_with_range); // ImagePlus imp)
}
}
}
// calculate range from disparity
getRangeFromDisparity(targets);
{ // always save after calculating ranges and adding UAS data. Later may be moved to after rangeTargets() above, only when calculated
getRangeFromDisparity(targets); // adds RSLT_INFINITY field
// generate results video (move from earlier)
addUasData(targets); // add flight log data to the nearest tiles, either existing or new
// re-saving data with flight log (ground truth) additions
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
center_CLT.getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_DISPARITIES_SUFFIX),
!batch_mode, // boolean show,
cuasMotion.getTilesX()); // int tilesX) {
center_CLT.saveImagePlusInModelDirectory(imp_with_range); // ImagePlus imp)
}
if (generate_csv) {
saveTargetStats(targets); // final double [][][] targets_single) {
}
if (generate_output) {
cuasMotion.generateExtractFilterMovingTargets( // move parameters to clt_parameters
false, // final boolean video_pass, // if clt_parameters.cuas_clean_video=true, video_pass=0 - output TIFFS, but no video. If video_pass==1 - only video with no debug
......@@ -380,6 +385,7 @@ public class CuasRanging {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < targets.length; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < targets[nSeq].length; ntile++) if (targets[nSeq][ntile] != null){
targets[nSeq][ntile][CuasMotionLMA.RSLT_INFINITY] = cuas_infinity;
if (!Double.isNaN(targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY]) && (targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY] != 0.0)) {
double disparity = targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY] - cuas_infinity; // corrected disparity
double disparity_diff = targets[nSeq][ntile][CuasMotionLMA.RSLT_DISP_DIFF];
......@@ -2636,6 +2642,38 @@ public class CuasRanging {
return masked_img;
}
public void addUasData(
final double [][][] targets_single) {
int num_seq = targets_single.length;
UasLogReader uasLogReader = cuasMotion.getUasLogReader();
String [] slice_titles = cuasMotion.getSliceTitles(); // timestamps
int tilesX = cuasMotion.getTilesX();
int tilesY = targets_single[0].length / tilesX;
for (int nseq = 0; nseq < num_seq; nseq++) {
String timestamp = slice_titles[nseq];
double [] uas_pXpYDRange = uasLogReader.getUasPxPyDRange(timestamp); // px, py, d- cuas_infinity (true disparity), range
if (uas_pXpYDRange != null) {
double px = uas_pXpYDRange[0];
double py = uas_pXpYDRange[1];
double disparity = uas_pXpYDRange[2]; // true disparity, w/o infinity offset
double range = uas_pXpYDRange[3];
int tileX = (int) (px/GPUTileProcessor.DTT_SIZE);
int tileY = (int) (py/GPUTileProcessor.DTT_SIZE);
if ((tileX>=0) && (tileY>=0) && (tileX < tilesX) && (tileY < tilesY)) {
int ntile = tileX + tileY * tilesX;
if (targets_single[nseq][ntile] == null) {
targets_single[nseq][ntile] = CuasMotionLMA.getEmpty(); // all fields NaN
targets_single[nseq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_FL_ONLY; // should be enough not to treat as a target
}
double [] tile = targets_single[nseq][ntile];
tile[CuasMotionLMA.RSLT_FL_PX] = px;
tile[CuasMotionLMA.RSLT_FL_PY] = py;
tile[CuasMotionLMA.RSLT_FL_DISP] = disparity;
tile[CuasMotionLMA.RSLT_FL_RANGE] = range;
}
}
}
}
// relies on calcMatchingTargetsLengths(.., true,...) called from recalcOmegas() to set [RSLT_GLOBAL]
public void saveTargetStats(
......@@ -2680,7 +2718,7 @@ public class CuasRanging {
String timestamp = slice_titles[nseq];
sb.append(nseq+"\t"+timestamp+"\t");
// get azimuth, elevation, target disparity from the log plus infinity, log range
double [] uas_pXpYDRange = uasLogReader.getUasPxPyDRange(timestamp); // px, py, d, range + cuas_infinity
double [] uas_pXpYDRange = uasLogReader.getUasPxPyDRange(timestamp); // px, py, d- cuas_infinity (true disparity), range
double [][] az_el_oaz_oel= CuasMotion.getPixToAzElev(
clt_parameters, // CLTParameters clt_parameters,
uas_pXpYDRange[0], // double target_x,
......
......@@ -8561,6 +8561,7 @@ if (debugLevel > -100) return true; // temporarily !
* @throws Exception
*/
public static void buildSeriesTQ(
int cuas_proc_mode, // 0 - old, 1 combine scene series
QuadCLT quadCLT_main, // tiles should be set
int ref_index_unused, // -1 - last
int ref_step_unused, // not used here
......
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