Commit b724a8ca authored by Andrey Filippov's avatar Andrey Filippov

Working on Cuas RT

parent 21b47b81
......@@ -38,6 +38,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.swing.JFileChooser;
......@@ -2033,6 +2035,65 @@ public class EyesisCorrectionParameters {
return;
}
public static String [] listModelNames(String [] source_tiff_paths) {
HashSet<String> models_set = new HashSet<String>();
for (String tiff_path: source_tiff_paths) {
models_set.add(Path.of(tiff_path).getParent().getFileName().toString());
}
List<String> models_list = new ArrayList<>(models_set);
Collections.sort(models_list);
return models_list.toArray(new String[0]);
}
public static String [] listExistingModelPaths(
String models_directory,
String version, // if null, will return top directories
String model_name_suffix,
String [] model_names) {
ArrayList<String> existing_list = new ArrayList<String>();
for (int i =0; i < model_names.length; i++) {
String model_name = model_names[i] + ((model_name_suffix != null)?model_name_suffix:"");
String model_path = (version != null)?
Paths.get(models_directory, model_name, version).toString():
Paths.get(models_directory, model_name).toString();
if ((new File(model_path)).exists()){
existing_list.add(model_path);
}
}
return existing_list.toArray(new String[0]);
}
public static String[] getFilesByExtensionAsArray(String dirPath, String suffix) {
Path path = Path.of(dirPath);
/*
// Open a stream of the directory contents
try (Stream<Path> stream = Files.list(path)) {
return stream
// 1. Filter out subdirectories
.filter(Files::isRegularFile)
// 2. Match the end of the filename (case-insensitive example)
.filter(p -> p.getFileName().toString().toLowerCase().endsWith(suffix.toLowerCase()))
// 3. Collect matching paths to a list
.collect(Collectors.toList()); // Use .collect(Collectors.toList()) if on Java 15 or below
}
*/
try (Stream<Path> stream = Files.list(path)) {
return stream
.filter(Files::isRegularFile)
// Convert Path object to String so the array holds Strings
.map(p -> p.toString())
.filter(s -> s.endsWith(suffix))
// Convert directly to String array (Works perfectly in Java 8 to 21+)
.toArray(String[]::new);
} catch (IOException | SecurityException e) {
// TODO Auto-generated catch block
return new String[0];
}
}
// .filter(s -> s.toLowerCase().endsWith(suffix.toLowerCase()))
// get list of source files in a directory
public String[] selectSourceFileInSet(String setdir, int debugLevel) {
int num_chn_main = numSubCameras;
......@@ -2670,6 +2731,12 @@ public class EyesisCorrectionParameters {
return dir;
}
public String getX3dDirectory() {
return x3dDirectory;
}
public String getX3dModelVersion() {
return x3dModelVersion;
}
public String selectX3dDirectory(boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
......
......@@ -22,6 +22,9 @@
**
*/
package com.elphel.imagej.common;
import java.awt.Font;
import javax.swing.UIManager;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -150,6 +153,11 @@ import ij.process.ImageProcessor;
}
public static ImagePlus showArraysHyperstack(double[][] pixels, int width, int height, int slices, String title, String [] titles, boolean show) {
// Explicitly push Java's fallback engine to use its universal "Dialog" family
// This forces Kubuntu to dynamically pull the missing arrow glyphs from Noto Sans Symbols
// Font linuxFallbackFont = new Font("Dialog", Font.PLAIN, 12);
// UIManager.put("Label.font", linuxFallbackFont);
// UIManager.put("TableHeader.font", linuxFallbackFont); // Fixes stack window header text
int i,j;
if (pixels==null) {
System.out.println("showDoubleFloatArrays.showArrays(): - pixel array is null");
......
......@@ -909,6 +909,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addJButton("Aux Build Series", jpanelLWIRWorld, color_stop);
addJButton("CUAS Combine", jpanelLWIRWorld, color_stop, "Combine previously processed CUAS series");
addJButton("CUAS Video", jpanelLWIRWorld, color_stop, "Combine previously rendered CUAS videos");
addJButton("CUAS RT", jpanelLWIRWorld, color_stop, "CUAS Real-time Tests");
addJButton("Build World", jpanelLWIRWorld, color_process);
addJButton("Test IMX5", jpanelLWIRWorld, color_process);
addJButton("Show mice", jpanelLWIRWorld, color_process);
......@@ -5551,6 +5552,14 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
2); // int cuas_proc_mode); // 0 - old, 1 combine scene series) {);
return;
/* ======================================================================== */
} else if (label.equals("CUAS RT")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
CLT_PARAMETERS.batch_run = true;
buildSeries(
true,
3); // int cuas_proc_mode); // 0 - old, 1 combine scene series) {);
return;
/* ======================================================================== */
} else if (label.equals("Aux Inter Test")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
CLT_PARAMETERS.batch_run = true;
......@@ -7650,7 +7659,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
public boolean buildSeries(
boolean use_aux,
int cuas_proc_mode) { // 0 - old, 1 combine scene series) {
int cuas_proc_mode) { // 0 - old, 1 combine scene series, 2 - combine video, 3 - RT tests) {
int lwir_level = CLT_PARAMETERS.lwir.getDebugLevel();
String slev = EyesisCorrections.stringLogLevel(lwir_level);
if (slev != null) {
......
......@@ -88,7 +88,6 @@ public class CuasMultiSeries {
QuadCLT quadCLT_main,
String path,
String version) {
// System.out.println ("CuasMultiSeries(): path="+path);
this.clt_parameters = clt_parameters;
double infinity = clt_parameters.imp.cuas_infinity;
File [] scene_dirs = (new File(path)).listFiles(); // may contain non-directories, will be filtered by filterScenes
......
......@@ -54,8 +54,7 @@ public class CuasRanging {
public static final String TARGET_GLOBALS_SUFFIX = "-TARGET_GLOBALS";
public static final String TARGET_STATS_SUFFIX = "-TARGETS"; // *.csv
final boolean realtime_mode;
final QuadCLT center_CLT;
private final QuadCLT center_CLT;
final QuadCLT [] scenes;
final double [][][] img_um;
final CLTParameters clt_parameters;
......@@ -66,11 +65,9 @@ public class CuasRanging {
public CuasRanging (
CLTParameters clt_parameters,
boolean realtime_mode,
QuadCLT center_CLT,
QuadCLT [] scenes,
int debugLevel) {
this.realtime_mode = realtime_mode;
this.clt_parameters = clt_parameters;
this.center_CLT = center_CLT;
this.scenes = scenes;
......@@ -78,8 +75,7 @@ public class CuasRanging {
}
public ImagePlus prepareFpixels(){
boolean save_linear_cuas = true;
double [][]combo_dsi = center_CLT.comboFromMain();
double [][]combo_dsi = getCenter_CLT().comboFromMain();
double [][] dls = {
combo_dsi[OpticalFlow.COMBO_DSN_INDX_DISP], // **** null on second scene sequence
combo_dsi[OpticalFlow.COMBO_DSN_INDX_LMA],
......@@ -89,7 +85,7 @@ public class CuasRanging {
true, // boolean use_conf, // use configuration parameters, false - use following
clt_parameters, // CLTParameters clt_parameters,
dls, // double [][] dls
center_CLT, // quadCLTs[ref_index], // QuadCLT scene,
getCenter_CLT(), // quadCLTs[ref_index], // QuadCLT scene,
debugLevel-1);
double [] disparity_fg = ds[0]; // combo_dsn_final[COMBO_DSN_INDX_DISP_FG];
double [] strength_fg = ds[1];
......@@ -117,8 +113,8 @@ public class CuasRanging {
ds_vantage, // final double [][] dsrbg_camera_in,
xyz_offset, // xyz_offset, // _inverse[0], // final double [] scene_xyz, // camera center in world coordinates
OpticalFlow.ZERO3, // _inverse[1], // final double [] scene_atr, // camera orientation relative to world frame
center_CLT, // quadCLTs[ref_index], // final QuadCLT scene_QuadClt,
center_CLT, // quadCLTs[ref_index], // final QuadCLT reference_QuadClt,
getCenter_CLT(), // quadCLTs[ref_index], // final QuadCLT scene_QuadClt,
getCenter_CLT(), // quadCLTs[ref_index], // final QuadCLT reference_QuadClt,
8); // iscale); // final int iscale);
if (dbg_vantage != null) {
for (int i = 0; i < 2; i++) {
......@@ -126,19 +122,19 @@ public class CuasRanging {
}
ShowDoubleFloatArrays.showArrays(
dbg_vantage,
center_CLT.getTileProcessor().getTilesX(),
center_CLT.getTileProcessor().getTilesY(),
getCenter_CLT().getTileProcessor().getTilesX(),
getCenter_CLT().getTileProcessor().getTilesY(),
true,
center_CLT.getImageName()+"-ds_vantage", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
getCenter_CLT().getImageName()+"-ds_vantage", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
new String[] {"disp0","lma0", "str0", "disp","str","virt_disp", "virt_str"});
}
float [] average_pixels = (float []) center_CLT.getCenterAverage().getProcessor().getPixels();
float [] average_pixels = (float []) getCenter_CLT().getCenterAverage().getProcessor().getPixels();
float [][] average_channels = new float [][] {average_pixels}; // for future color images
double [] cuas_atr = OpticalFlow.ZERO3;
String scenes_suffix = center_CLT.getImageName()+"-CUAS"; // "1747829900_781803-SEQ-FG-MONO-FPN";
String scenes_suffix = getCenter_CLT().getImageName()+"-CUAS"; // "1747829900_781803-SEQ-FG-MONO-FPN";
ImagePlus imp_targets= OpticalFlow.renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
true, // center_CLT.hasCenterClt(), // boolean mode_cuas,
......@@ -157,14 +153,9 @@ public class CuasRanging {
scenes_suffix, // String suffix,
ds_vantage[0], // selected_disparity, // double [] ref_disparity,
scenes, // QuadCLT [] quadCLTs,
center_CLT, // ref_index, // int ref_index,
getCenter_CLT(), // ref_index, // int ref_index,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
if (save_linear_cuas) {
center_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_targets); // imp_scenes); // ImagePlus imp)
}
return imp_targets;
}
......@@ -180,7 +171,6 @@ public class CuasRanging {
boolean mono_fixed = clt_parameters.imp.mono_fixed;
double mono_range = clt_parameters.imp.mono_range;
double rng_um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
/// boolean rng_um_twice = clt_parameters.imp.cuas_rng_um2;
double rng_radius0 = clt_parameters.imp.cuas_rng_radius0;
double rng_radius = clt_parameters.imp.cuas_rng_radius;
double rng_blur = clt_parameters.imp.cuas_rng_blur;
......@@ -199,102 +189,17 @@ public class CuasRanging {
boolean log_ranging = clt_parameters.imp.cuas_log_ranging; // true; // Log ranging iterations
boolean reuse_disparity = clt_parameters.imp.cuas_reuse_disparity;
boolean radar_mode = clt_parameters.imp.cuas_reuse_globals;
/// double rng_limit = clt_parameters.imp.cuas_rng_limit;
boolean generate_output = clt_parameters.imp.cuas_generate; // generate and save targets Tiff and/or video files
boolean generate_csv = clt_parameters.imp.cuas_generate_csv; // generate and save targets as csv file
boolean clean_video = clt_parameters.imp.cuas_clean_video; //true;// save video without any debug information for targets, output in TIFF files. False - same output for video and TIFFs
ImagePlus imp_targets = prepareFpixels();
double [][]combo_dsi = center_CLT.comboFromMain();
double [][] dls = {
combo_dsi[OpticalFlow.COMBO_DSN_INDX_DISP], // **** null on second scene sequence
combo_dsi[OpticalFlow.COMBO_DSN_INDX_LMA],
combo_dsi[OpticalFlow.COMBO_DSN_INDX_STRENGTH]
};
double [][] ds = OpticalFlow.conditionInitialDS(
true, // boolean use_conf, // use configuration parameters, false - use following
clt_parameters, // CLTParameters clt_parameters,
dls, // double [][] dls
center_CLT, // quadCLTs[ref_index], // QuadCLT scene,
debugLevel-1);
double [] disparity_fg = ds[0]; // combo_dsn_final[COMBO_DSN_INDX_DISP_FG];
double [] strength_fg = ds[1];
if (strength_fg != null) { // for FG/BG only, fixing for transformCameraVew()
for (int i = 0; i < disparity_fg.length; i++) {
if (!Double.isNaN(disparity_fg[i]) && (strength_fg[i] == 0)) strength_fg[i] = 0.01; // transformCameraVew ignores strength= 0
}
}
/*
double [] xyz_offset= {0,0,0};
double [][] ds_vantage = new double[][] {disparity_fg, strength_fg};
boolean debug_vantage = false;
double [][] dbg_vantage = debug_vantage ? (new double[7][]): null;
if (dbg_vantage != null) {
for (int i = 0; i < 3; i++) {
dbg_vantage[i] = dls[i].clone();
}
for (int i = 0; i < 2; i++) {
dbg_vantage[i+3] = ds_vantage[i].clone();
}
}
ds_vantage = OpticalFlow.transformCameraVew(
null, // (debug_ds_fg_virt?"transformCameraVew":null), // final String title,
ds_vantage, // final double [][] dsrbg_camera_in,
xyz_offset, // xyz_offset, // _inverse[0], // final double [] scene_xyz, // camera center in world coordinates
OpticalFlow.ZERO3, // _inverse[1], // final double [] scene_atr, // camera orientation relative to world frame
center_CLT, // quadCLTs[ref_index], // final QuadCLT scene_QuadClt,
center_CLT, // quadCLTs[ref_index], // final QuadCLT reference_QuadClt,
8); // iscale); // final int iscale);
if (dbg_vantage != null) {
for (int i = 0; i < 2; i++) {
dbg_vantage[i+5] = ds_vantage[i].clone();
}
ShowDoubleFloatArrays.showArrays(
dbg_vantage,
center_CLT.getTileProcessor().getTilesX(),
center_CLT.getTileProcessor().getTilesY(),
true,
center_CLT.getImageName()+"-ds_vantage", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
new String[] {"disp0","lma0", "str0", "disp","str","virt_disp", "virt_str"});
}
float [] average_pixels = (float []) center_CLT.getCenterAverage().getProcessor().getPixels();
float [][] average_channels = new float [][] {average_pixels}; // for future color images
double [] cuas_atr = OpticalFlow.ZERO3;
String scenes_suffix = center_CLT.getImageName()+"-CUAS"; // "1747829900_781803-SEQ-FG-MONO-FPN";
ImagePlus imp_targets= OpticalFlow.renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
true, // center_CLT.hasCenterClt(), // boolean mode_cuas,
false, // clt_parameters.imp.um_mono, // boolean um_mono,
clt_parameters.imp.calculate_average, // boolean insert_average, // then add new parameter, keep add average
null, // int [] average_range,
average_channels, // average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // fov_tiles, // Rectangle fov_tiles,
1, // mode3d, // int mode3d,
false, // toRGB, // boolean toRGB,
xyz_offset, // double [] stereo_offset, // offset reference camera {x,y,z}
cuas_atr, // double [] stereo_atr, // offset reference orientation (cuas)
1, // sensor_mask, // int sensor_mask,
scenes_suffix, // String suffix,
ds_vantage[0], // selected_disparity, // double [] ref_disparity,
scenes, // QuadCLT [] quadCLTs,
center_CLT, // ref_index, // int ref_index,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
if (save_linear_cuas) {
center_CLT.saveImagePlusInModelDirectory(
getCenter_CLT().saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_targets); // imp_scenes); // ImagePlus imp)
}
*/
ImagePlus imp_targets = prepareFpixels();
// always generating UM, even if not saving - needed for targets
String cuas_title = imp_targets.getTitle();
......@@ -310,12 +215,12 @@ public class CuasRanging {
um_sigma, // final double um_sigma,
um_weight); // final double um_weight)
if (save_um_cuas) {
center_CLT.saveImagePlusInModelDirectory(
getCenter_CLT().saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_targets); // imp_scenes); // ImagePlus imp)
}
boolean insert_average = (center_CLT.getCenterAverage() != null) || clt_parameters.imp.calculate_average;
boolean insert_average = (getCenter_CLT().getCenterAverage() != null) || clt_parameters.imp.calculate_average;
System.out.println("Will generate targets images/videos");
int first_corr = insert_average? 1:0; // skip average
int num_scenes = imp_targets.getStack().getSize()- first_corr; // includes average
......@@ -342,7 +247,7 @@ public class CuasRanging {
this.cuasMotion = new CuasMotion (
clt_parameters, // CLTParameters clt_parameters,
scene_titles, // String [] scene_titles,
center_CLT, // QuadCLT parentCLT,
getCenter_CLT(), // QuadCLT parentCLT,
fpixels_avg, // float [] fpixels_avg,
uasLogReader, // UasLogReader uasLogReader,
debugLevel); // int debugLevel)
......@@ -359,15 +264,15 @@ public class CuasRanging {
cuasMotion.getNoiseMap8(), // float[][] pixels,
cuasMotion.getTilesX(), // int width,
cuasMotion.getTilesY(), // int height,
center_CLT.getImageName()+"-NOISE-MAP8"); //String [] titles)
center_CLT.saveImagePlusInModelDirectory(imp_noise_map8); // ImagePlus imp)
getCenter_CLT().getImageName()+"-NOISE-MAP8"); //String [] titles)
getCenter_CLT().saveImagePlusInModelDirectory(imp_noise_map8); // ImagePlus imp)
ImagePlus imp_noise_neibs = ShowDoubleFloatArrays.makeArrays(
cuasMotion.getNoiseNeibs(), // float[][] pixels,
cuasMotion.getTilesX(), // int width,
cuasMotion.getTilesY(), // int height,
center_CLT.getImageName()+"-NOISE-NEIBS"); //String [] titles)
center_CLT.saveImagePlusInModelDirectory(imp_noise_neibs); // ImagePlus imp)
getCenter_CLT().getImageName()+"-NOISE-NEIBS"); //String [] titles)
getCenter_CLT().saveImagePlusInModelDirectory(imp_noise_neibs); // ImagePlus imp)
}
......@@ -386,9 +291,9 @@ public class CuasRanging {
// double [][] glob_stats = null;
if (radar_mode) {
double [][][] disparity_targets = null;
String disparity_path = center_CLT.getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_GLOBALS_SUFFIX); // may later be directly provided (e.g. select specific version)
String disparity_path = getCenter_CLT().getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_GLOBALS_SUFFIX); // may later be directly provided (e.g. select specific version)
if (disparity_path.indexOf(Prefs.getFileSeparator()) < 0) { // now always
String x3d_path = center_CLT.getX3dDirectory();
String x3d_path = getCenter_CLT().getX3dDirectory();
disparity_path = x3d_path + Prefs.getFileSeparator() + disparity_path+".tiff";
}
disparity_targets = CuasMotion.getTargetsFromHyperAugment(disparity_path);
......@@ -413,9 +318,9 @@ public class CuasRanging {
double [][][] disparity_targets = null;
if (reuse_disparity) {
// String disparity_path = model_prefix+TARGET_DISPARITIES_SUFFIX; // may later be directly provided (e.g. select specific version)
String disparity_path = center_CLT.getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_DISPARITIES_SUFFIX); // may later be directly provided (e.g. select specific version)
String disparity_path = getCenter_CLT().getImageName()+CuasMotion.getParametersSuffixRanging(clt_parameters,TARGET_DISPARITIES_SUFFIX); // may later be directly provided (e.g. select specific version)
if (disparity_path.indexOf(Prefs.getFileSeparator()) < 0) { // now always
String x3d_path = center_CLT.getX3dDirectory();
String x3d_path = getCenter_CLT().getX3dDirectory();
disparity_path = x3d_path + Prefs.getFileSeparator() + disparity_path+".tiff";
}
disparity_targets = CuasMotion.getTargetsFromHyperAugment(disparity_path);
......@@ -481,10 +386,10 @@ public class CuasRanging {
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),
getCenter_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)
getCenter_CLT().saveImagePlusInModelDirectory(imp_with_range); // ImagePlus imp)
}
} else if (recalc_target_id){// if (disparity_targets == null) { // at com.elphel.imagej.cuas.CuasMotion$46.run(CuasMotion.java:7269)
cuasMotion.recalcOmegas( // does not work -
......@@ -508,10 +413,10 @@ public class CuasRanging {
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),
getCenter_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)
getCenter_CLT().saveImagePlusInModelDirectory(imp_with_range); // ImagePlus imp)
}
if (generate_csv && (uasLogReader != null)) {
saveTargetStats(targets); // final double [][][] targets_single) {
......@@ -559,7 +464,7 @@ public class CuasRanging {
extended_targets, // final double [][][] targets5x5,
debugLevel); // final int debugLevel)
boolean show = false; // true;
int num_sens = center_CLT.getNumSensors();
int num_sens = getCenter_CLT().getNumSensors();
String [] sens_titles = new String[num_sens+1];
for (int i = 0; i < num_sens; i++) {
sens_titles[i] = "SENS-"+i;
......@@ -567,13 +472,13 @@ public class CuasRanging {
sens_titles[num_sens] = "COMBO";
ImagePlus imp_rendered = ShowDoubleFloatArrays.showArraysHyperstack(
rendered_keyframes, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-RENDERED_TARGETS-R"+rng_radius0+":"+rng_radius+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-RENDERED_TARGETS-R"+rng_radius0+":"+rng_radius+
"-B"+rng_blur+"-UM"+rng_um_sigma, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
sens_titles, // String [] titles, // all slices*frames titles or just slice titles or null
cuasMotion.getSliceTitles(), // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(imp_rendered); // ImagePlus imp)
getCenter_CLT().saveImagePlusInModelDirectory(imp_rendered); // ImagePlus imp)
}
return cuasMotion;
}
......@@ -585,7 +490,7 @@ public class CuasRanging {
final double min_disp_str = clt_parameters.imp.cuas_min_disp_str; // 0.4; // Minimal disparity strength to consider disparity valid
final double rng_limit = clt_parameters.imp.cuas_rng_limit; // 5000; // Maximal displayed distance to target
final double cuas_infinity = clt_parameters.imp.cuas_infinity;
final GeometryCorrection gc = center_CLT.getGeometryCorrection();
final GeometryCorrection gc = getCenter_CLT().getGeometryCorrection();
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
......@@ -698,14 +603,14 @@ public class CuasRanging {
/// boolean batch_run =clt_parameters.batch_run; // may be modified for debug
/// boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
final int tileSize = center_CLT.getTileSize();
final int tilesX = getCenter_CLT().getTilesX();
final int tilesY = getCenter_CLT().getTilesY();
final int tileSize = getCenter_CLT().getTileSize();
final int sensor_mask = -1; // all sensors
final int num_sens = center_CLT.getNumSensors();
final int num_sens = getCenter_CLT().getNumSensors();
final int width = tilesX * tileSize;
final int height = tilesY * tileSize;
ErsCorrection ers_reference = center_CLT.getErsCorrection();
ErsCorrection ers_reference = getCenter_CLT().getErsCorrection();
int num_used_sens = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) num_used_sens++;
int [] channels = new int [num_used_sens];
......@@ -730,14 +635,14 @@ public class CuasRanging {
continue;
}
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
getCenter_CLT().getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
getCenter_CLT().isAux(),
getCenter_CLT().isMonochrome(),
getCenter_CLT().isLwir(),
clt_parameters.getScaleStrength(getCenter_CLT().isAux()),
getCenter_CLT().getGPU());
prepareAltImages(
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
......@@ -753,7 +658,7 @@ public class CuasRanging {
if (mb_en && (dxyzatr_dt != null)) {
double [][] motion_blur = OpticalFlow.getMotionBlur(
center_CLT, // quadCLTs[ref_index], // QuadCLT ref_scene,
getCenter_CLT(), // quadCLTs[ref_index], // QuadCLT ref_scene,
scenes[nscene], // QuadCLT scene, // can be the same as ref_scene
ref_pXpYD5x5, // double [][] ref_pXpYD, // here it is scene, not reference!
scene_xyz, // double [] camera_xyz,
......@@ -778,7 +683,7 @@ public class CuasRanging {
scene_xyz, // final double [] scene_xyz, // camera center in world coordinates
scene_atr, // final double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], // final QuadCLT scene,
center_CLT, // quadCLTs[ref_index], // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // quadCLTs[ref_index], // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
false, // final boolean toRGB,
clt_parameters.imp.show_mono_nan,
debugLevel); // int debugLevel)
......@@ -798,7 +703,7 @@ public class CuasRanging {
scene_xyz, // final double [] scene_xyz, // camera center in world coordinates
scene_atr, // final double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], // final QuadCLT scene,
center_CLT, // quadCLTs[ref_index], // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // quadCLTs[ref_index], // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
false, // final boolean toRGB,
clt_parameters.imp.show_mono_nan,
debugLevel); // int debugLevel)
......@@ -861,8 +766,8 @@ public class CuasRanging {
if (log_ranging) {
String log_head = getRangingLogParameters();
log_head +="target\tnseq\tframe_center\tnrefine\ttileX\ttileY\ttile\tdisparity\tdisp_diff\thalf\tstrength\tlast_str\tmax_diff\n";
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_SUFFIX);
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_FULL_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_FULL_SUFFIX);
}
int target_id0 = 1;
int target_id1 = linked_targets.length;
......@@ -910,7 +815,7 @@ public class CuasRanging {
System.out.println("rangeTargets(): debug/change nseq_first="+nseq_first+", nseq_last="+nseq_last);
// for rng_vfy debugging
final int half_accum_range = cuasMotion.getSeqLength()/2;
final int num_sens = center_CLT.getNumSensors();
final int num_sens = getCenter_CLT().getNumSensors();
final int num_scenes = 2*half_accum_range+1;
final int num_scene_grp = (num_scenes + (rng_combine - 1)) / rng_combine;
// final double [][][] ranging_verify = (rng_vfy) ? (new double [num_scenes + 1][num_sens+1][]) : null;
......@@ -919,8 +824,8 @@ public class CuasRanging {
if (log_ranging) {
String log_head = getRangingLogParameters();
log_head +="target\tnseq\tframe_center\tnrefine\ttileX\ttileY\ttile\tdisparity\tdisp_diff\thalf\tstrength\tlast_str\tmax_diff\n";
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_SUFFIX);
center_CLT.appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_FULL_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(log_head, TARGET_RANGING_LOGS_FULL_SUFFIX);
}
for (int nseq = nseq_first; nseq <= nseq_last; nseq++) {
......@@ -1015,7 +920,7 @@ public class CuasRanging {
for (iseq = very_first_seq; (iseq < targets.length) && (linked_targets[target_id-1][iseq] != null); iseq++ );
int [] target_tiles_full = new int [iseq - very_first_seq];
for (int i = 0; i < target_tiles_full.length; i++) target_tiles_full[i] = linked_targets[target_id-1][very_first_seq+i][0];
final GeometryCorrection gc = center_CLT.getGeometryCorrection();
final GeometryCorrection gc = getCenter_CLT().getGeometryCorrection();
process_segments: {
double [] seg_rslt = null;
for (int seg_lev = 0; seg_lev < flw_levels; seg_lev++) {
......@@ -1119,7 +1024,7 @@ public class CuasRanging {
double cuas_initial_disparity=clt_parameters.imp.cuas_initial_disparity; // 1.0; // Start correlation with this disparity (in addition to infinity) after reset
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
final int tilesX = center_CLT.getTilesX();
final int tilesX = getCenter_CLT().getTilesX();
// final int tilesY = center_CLT.getTilesY();
// final int frame_center = cuasMotion.getFrameCenter(nseq); // for debug only
final boolean use_non_lma = false;
......@@ -1165,7 +1070,7 @@ public class CuasRanging {
target_id, // final int target_id,
nrefine, // final int nrefine,
false); // final boolean show)
center_CLT.saveImagePlusInModelDirectory(imp_vfy);
getCenter_CLT().saveImagePlusInModelDirectory(imp_vfy);
}
if (disparity_map == null) {
......@@ -1256,10 +1161,10 @@ public class CuasRanging {
}
if (sb != null) {
sb.append(sb_last);
center_CLT.appendStringInModelDirectory(sb.toString(), TARGET_RANGING_LOGS_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(sb.toString(), TARGET_RANGING_LOGS_SUFFIX);
}
if (sb_full != null) {
center_CLT.appendStringInModelDirectory(sb_full.toString(), TARGET_RANGING_LOGS_FULL_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(sb_full.toString(), TARGET_RANGING_LOGS_FULL_SUFFIX);
}
return new double [] {disparity, strength, disparity_diff};
}
......@@ -1283,8 +1188,8 @@ public class CuasRanging {
double cuas_initial_disparity=clt_parameters.imp.cuas_initial_disparity; // 1.0; // Start correlation with this disparity (in addition to infinity) after reset
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
final int tilesX = getCenter_CLT().getTilesX();
final int tilesY = getCenter_CLT().getTilesY();
final int frame_center = cuasMotion.getFrameCenter(nseq); // for debug only
final boolean use_non_lma = false;
......@@ -1311,7 +1216,7 @@ public class CuasRanging {
targets[dbg_nseq][dbg_ntile][CuasMotionLMA.RSLT_DISP_STR] = 0;
}
}
String dbg_title = center_CLT.getImageName()+
String dbg_title = getCenter_CLT().getImageName()+
"TARGETS-RESET-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1340,7 +1245,7 @@ public class CuasRanging {
null); // remain); // final int [] remain)
}
if (show_dbg) {
String dbg_title = center_CLT.getImageName()+
String dbg_title = getCenter_CLT().getImageName()+
"VAR_TARGETS-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1374,7 +1279,7 @@ public class CuasRanging {
frame_center-half_accum_range, // final int nscene0);
nrefine, // final int nrefine,
false); // final boolean show)
center_CLT.saveImagePlusInModelDirectory(imp_vfy);
getCenter_CLT().saveImagePlusInModelDirectory(imp_vfy);
}
if (show_disparity) {
......@@ -1383,12 +1288,12 @@ public class CuasRanging {
tilesX,
tilesY,
true,
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
getCenter_CLT().getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-accumulated_disparity_map_R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
ImageDtt.getDisparityTitles(center_CLT.getNumSensors(),center_CLT.isMonochrome()) // ImageDtt.DISPARITY_TITLES
ImageDtt.getDisparityTitles(getCenter_CLT().getNumSensors(),getCenter_CLT().isMonochrome()) // ImageDtt.DISPARITY_TITLES
);
}
if ((sb != null) || (sb_full != null)) {
......@@ -1473,10 +1378,10 @@ public class CuasRanging {
if (sb != null) {
sb.append(sb_last);
center_CLT.appendStringInModelDirectory(sb.toString(), TARGET_RANGING_LOGS_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(sb.toString(), TARGET_RANGING_LOGS_SUFFIX);
}
if (sb_full != null) {
center_CLT.appendStringInModelDirectory(sb_full.toString(), TARGET_RANGING_LOGS_FULL_SUFFIX);
getCenter_CLT().appendStringInModelDirectory(sb_full.toString(), TARGET_RANGING_LOGS_FULL_SUFFIX);
}
return;
}
......@@ -1567,8 +1472,8 @@ public class CuasRanging {
ImagePlus imp_vfy = ShowDoubleFloatArrays.showArraysHyperstack(
ranging_verify, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (nscene0 + half_accum_range)+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1667,8 +1572,8 @@ public class CuasRanging {
ImagePlus imp_vfy = ShowDoubleFloatArrays.showArraysHyperstack(
ranging_verify, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-ID"+ target_id+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1762,9 +1667,9 @@ public class CuasRanging {
final boolean mb_en = clt_parameters.imp.mb_en; // && (fov_tiles==null) && (mode3d > 0);
final double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
final double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(center_CLT.isMonochrome());
final double gpu_sigma_rb_corr = center_CLT.isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(center_CLT.isMonochrome());
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(getCenter_CLT().isMonochrome());
final double gpu_sigma_rb_corr = getCenter_CLT().isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(getCenter_CLT().isMonochrome());
final double radius = (nrefine == 0)? clt_parameters.imp.cuas_rng_radius0: clt_parameters.imp.cuas_rng_radius;
final int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
final int half_accum_range = cuasMotion.getSeqLength()/2;
......@@ -1817,8 +1722,8 @@ public class CuasRanging {
boolean show = false; // true;
ImagePlus imp_sensors_um =ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-SENSOR_FULL_IMAGES"+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-SENSOR_FULL_IMAGES"+
//"-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
//"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma
......@@ -1830,7 +1735,7 @@ public class CuasRanging {
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(
getCenter_CLT().saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_sensors_um); // imp_scenes); // ImagePlus imp)
}
......@@ -1842,10 +1747,10 @@ public class CuasRanging {
*/
/// boolean batch_run =clt_parameters.batch_run; // may be modified for debug
/// boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
final int tilesX = getCenter_CLT().getTilesX();
final int tilesY = getCenter_CLT().getTilesY();
final int sensor_mask = -1; // all sensors
final int num_sens = center_CLT.getNumSensors();
final int num_sens = getCenter_CLT().getNumSensors();
ImageDttParameters imgdtt_params = null;
try {
......@@ -1857,7 +1762,7 @@ public class CuasRanging {
imgdtt_params.updateFromCuas(clt_parameters.imp, num_sens);
final int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,num_sens);
ErsCorrection ers_reference = center_CLT.getErsCorrection();
ErsCorrection ers_reference = getCenter_CLT().getErsCorrection();
int num_used_sens = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) num_used_sens++;
int [] channels = new int [num_used_sens];
......@@ -1878,14 +1783,14 @@ public class CuasRanging {
final boolean no_map = false;
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
getCenter_CLT().getNumSensors(),
clt_parameters.transform_size,
imgdtt_params, // clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
getCenter_CLT().isAux(),
getCenter_CLT().isMonochrome(),
getCenter_CLT().isLwir(),
clt_parameters.getScaleStrength(getCenter_CLT().isAux()),
getCenter_CLT().getGPU());
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
final double[][] disparity_map = no_map ? null : new double [image_dtt.getDisparityTitles().length][];
......@@ -1966,7 +1871,7 @@ public class CuasRanging {
tp_tasks = new TpTask[(mb_en && (dxyzatr_dt != null)) ? 2 : 1][];
if (mb_en && (dxyzatr_dt != null)) {
double [][] motion_blur = OpticalFlow.getMotionBlur(
center_CLT, // quadCLTs[ref_index], // QuadCLT ref_scene,
getCenter_CLT(), // quadCLTs[ref_index], // QuadCLT ref_scene,
scenes[nscene], // QuadCLT scene, // can be the same as ref_scene
ref_pXpYD, // double [][] ref_pXpYD, // here it is scene, not reference!
scene_xyz, // double [] camera_xyz,
......@@ -1997,7 +1902,7 @@ public class CuasRanging {
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
......@@ -2023,7 +1928,7 @@ public class CuasRanging {
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
......@@ -2046,7 +1951,7 @@ public class CuasRanging {
if (ranging_verify[nscene] == null) {
ranging_verify[nscene]= new double [num_sens+1][];
}
double [][] scene_render = center_CLT.renderDoubleFromTDMono ( // [sensor][pixel]
double [][] scene_render = getCenter_CLT().renderDoubleFromTDMono ( // [sensor][pixel]
-1, // int sensor_mask,
null, // int [] wh, // may be null, or {width, height}
false); // boolean use_reference
......@@ -2130,7 +2035,7 @@ public class CuasRanging {
// The tp_tasks data should be decoded from GPU to get coordinates
tp_tasks_ref[0], // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
null, // final double [][] far_fgbg, // null, or [nTile]{disp(fg)-disp(bg), str(fg)-str(bg)} hints for LMA FG/BG split
center_CLT.getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
getCenter_CLT().getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
// next both can be nulls
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
// combo will be added as extra pair if mcorr_comb_width > 0 and clt_corr_out has a slot for it
......@@ -2184,7 +2089,7 @@ public class CuasRanging {
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
getCenter_CLT().getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-CORR-ACCUM_R"+clt_parameters.imp.cuas_rng_radius+
"-T"+ntile0+":"+nrefine+"-M"+mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
......@@ -2210,8 +2115,8 @@ public class CuasRanging {
//img_um_seq
ImagePlus imp_alt =ShowDoubleFloatArrays.showArraysHyperstack(
alt_images, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-SENSOR_ALT_IMAGES"+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-SENSOR_ALT_IMAGES"+
//"-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
//"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma
......@@ -2223,7 +2128,7 @@ public class CuasRanging {
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(
getCenter_CLT().saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_alt); // imp_scenes); // ImagePlus imp)
}
......@@ -2276,9 +2181,9 @@ public class CuasRanging {
final double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
final double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(center_CLT.isMonochrome());
final double gpu_sigma_rb_corr = center_CLT.isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(center_CLT.isMonochrome());
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(getCenter_CLT().isMonochrome());
final double gpu_sigma_rb_corr = getCenter_CLT().isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(getCenter_CLT().isMonochrome());
final double radius = (nrefine == 0)? clt_parameters.imp.cuas_rng_radius0: clt_parameters.imp.cuas_rng_radius;
final int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
......@@ -2304,10 +2209,10 @@ public class CuasRanging {
/// boolean batch_run =clt_parameters.batch_run; // may be modified for debug
/// boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
final int tilesX = getCenter_CLT().getTilesX();
final int tilesY = getCenter_CLT().getTilesY();
final int sensor_mask = -1; // all sensors
final int num_sens = center_CLT.getNumSensors();
final int num_sens = getCenter_CLT().getNumSensors();
ImageDttParameters imgdtt_params = null;
try {
......@@ -2334,8 +2239,8 @@ public class CuasRanging {
ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-img_um_seq-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-img_um_seq-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
true); // show); // boolean show)
......@@ -2343,7 +2248,7 @@ public class CuasRanging {
final int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,num_sens);
ErsCorrection ers_reference = center_CLT.getErsCorrection();
ErsCorrection ers_reference = getCenter_CLT().getErsCorrection();
int num_used_sens = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) num_used_sens++;
int [] channels = new int [num_used_sens];
......@@ -2364,14 +2269,14 @@ public class CuasRanging {
final boolean no_map = false;
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
getCenter_CLT().getNumSensors(),
clt_parameters.transform_size,
imgdtt_params, // clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
getCenter_CLT().isAux(),
getCenter_CLT().isMonochrome(),
getCenter_CLT().isLwir(),
clt_parameters.getScaleStrength(getCenter_CLT().isAux()),
getCenter_CLT().getGPU());
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
final double[][] disparity_map = no_map ? null : new double [image_dtt.getDisparityTitles().length][];
......@@ -2426,7 +2331,7 @@ public class CuasRanging {
tp_tasks = new TpTask[(mb_en && (dxyzatr_dt != null)) ? 2 : 1][];
if (mb_en && (dxyzatr_dt != null)) {
double [][] motion_blur = OpticalFlow.getMotionBlur(
center_CLT, // quadCLTs[ref_index], // QuadCLT ref_scene,
getCenter_CLT(), // quadCLTs[ref_index], // QuadCLT ref_scene,
scenes[nscene], // QuadCLT scene, // can be the same as ref_scene
ref_pXpYD, // double [][] ref_pXpYD, // here it is scene, not reference!
scene_xyz, // double [] camera_xyz,
......@@ -2458,7 +2363,7 @@ public class CuasRanging {
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
......@@ -2484,7 +2389,7 @@ public class CuasRanging {
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
tp_tasks, // TpTask [][] tasks,
false, // clt_parameters.imp.show_mono_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
......@@ -2500,7 +2405,7 @@ public class CuasRanging {
// correlate only after the last in group, others - just accumulate in TD
if (last_in_grp) {
if (ranging_verify != null) { // [2*half_accum_range +1 +1][num_sens+1][] // [num_pix])
double [][] scene_render = center_CLT.renderDoubleFromTDMono ( // [sensor][pixel]
double [][] scene_render = getCenter_CLT().renderDoubleFromTDMono ( // [sensor][pixel]
-1, // int sensor_mask,
null, // int [] wh, // may be null, or {width, height}
false); // boolean use_reference
......@@ -2589,16 +2494,16 @@ public class CuasRanging {
ShowDoubleFloatArrays.showArraysHyperstack(
alt_images, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-alt_images-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma+"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-alt_images-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma+"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-B"+clt_parameters.imp.cuas_rng_blur, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_alt_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
true); // show); // boolean show)
ShowDoubleFloatArrays.showArraysHyperstack(
orig_images, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-orig_images-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma+"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
getCenter_CLT().getWidth(), // int width,
getCenter_CLT().getImageName()+"-orig_images-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +um_sigma+"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-B"+clt_parameters.imp.cuas_rng_blur, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_alt_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
......@@ -2622,7 +2527,7 @@ public class CuasRanging {
// The tp_tasks data should be decoded from GPU to get coordinates
tp_tasks_ref[0], // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
null, // final double [][] far_fgbg, // null, or [nTile]{disp(fg)-disp(bg), str(fg)-str(bg)} hints for LMA FG/BG split
center_CLT.getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
getCenter_CLT().getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
// next both can be nulls
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
// combo will be added as extra pair if mcorr_comb_width > 0 and clt_corr_out has a slot for it
......@@ -2677,7 +2582,7 @@ public class CuasRanging {
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
getCenter_CLT().getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-CORR-ACCUM_R"+clt_parameters.imp.cuas_rng_radius+
"-F"+frame_center+":"+nrefine+"-M"+mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
......@@ -2701,13 +2606,13 @@ public class CuasRanging {
final double radius_blur = clt_parameters.imp.cuas_rng_blur;
final double alt_scale = clt_parameters.imp.cuas_rng_scale; // scale alt data to approximately match correlation values
final int tilesX = center_CLT.getTilesX();
final int tileSize = center_CLT.getTileSize();
final int tilesX = getCenter_CLT().getTilesX();
final int tileSize = getCenter_CLT().getTileSize();
final int width = tilesX * tileSize;
final int frame_center = cuasMotion.getFrameCenter(nseq);
// final int half_accum_range = cuasMotion.getSeqLength()/2;
ErsCorrection ers_reference = center_CLT.getErsCorrection();
final int num_sens = center_CLT.getNumSensors();
ErsCorrection ers_reference = getCenter_CLT().getErsCorrection();
final int num_sens = getCenter_CLT().getNumSensors();
final int nscene = frame_center + dseq;
final int iscene = dseq - first_offs; // starts from 0
......@@ -2728,7 +2633,7 @@ public class CuasRanging {
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], // final QuadCLT scene,
center_CLT, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
getCenter_CLT(), // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
debugLevel); // final int debugLevel);
double [][] masked = copyMaskedTargets ( // [sensor][pixel]
radius, // final double radius,
......@@ -2889,8 +2794,8 @@ public class CuasRanging {
// Update camera reference LLA from center_CLT.did_ins_2 if available.
// quadCLT_main (the ImageJ plugin template) has no IMS loaded, so the fix in
// TwoQuadCLT cannot set it there; center_CLT is the right source.
if (center_CLT != null && center_CLT.hasIns()) {
double [] cameraLla = center_CLT.getLla();
if (getCenter_CLT() != null && getCenter_CLT().hasIns()) {
double [] cameraLla = getCenter_CLT().getLla();
if (cameraLla != null && (cameraLla[0] != 0.0 || cameraLla[1] != 0.0)) {
uasLogReader.setCameraLLA(cameraLla);
System.out.println("addUasData(): camera LLA set from center_CLT did_ins_2: lat="+
......@@ -2972,7 +2877,7 @@ public class CuasRanging {
}
}
if (tsv != null) {
center_CLT.saveStringInModelDirectory(tsv.toString(), UAS_DATA_SUFFIX, false);
getCenter_CLT().saveStringInModelDirectory(tsv.toString(), UAS_DATA_SUFFIX, false);
}
}
......@@ -2985,7 +2890,7 @@ public class CuasRanging {
return;
}
final int tilesX = cuasMotion.getTilesX();
final GeometryCorrection gc = center_CLT.getGeometryCorrection();
final GeometryCorrection gc = getCenter_CLT().getGeometryCorrection();
final int tileSize = GPUTileProcessor.DTT_SIZE;
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
int flw_levels = clt_parameters.imp.cuas_flw_levels; // 1 - all, 2 - all and two halves, 3 - all, two halves and 4 quaters
......@@ -3020,7 +2925,7 @@ public class CuasRanging {
}
sb.append("\n"); // there will be 1 extra blank column
String [] slice_titles = cuasMotion.getSliceTitles(); // timestamps
ErsCorrection ersCorrection = center_CLT.getErsCorrection();
ErsCorrection ersCorrection = getCenter_CLT().getErsCorrection();
double velocity_scale = CuasMotion.getFrameVelocityScale(clt_parameters);
for (int nseq = 0; nseq < num_seq; nseq++) {
String timestamp = slice_titles[nseq];
......@@ -3089,9 +2994,13 @@ public class CuasRanging {
sb.append("\n"); // there will be 1 extra blank column
}
String suffix = CuasMotion.getParametersSuffixRslt(clt_parameters, TARGET_STATS_SUFFIX)+".csv";
center_CLT.saveStringInModelDirectory(sb.toString(), suffix, false);
getCenter_CLT().saveStringInModelDirectory(sb.toString(), suffix, false);
return;
}
public QuadCLT getCenter_CLT() {
return center_CLT;
}
}
package com.elphel.imagej.cuas.rt;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.EyesisCorrectionParameters.CorrectionParameters;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.cuas.CuasMotion;
import com.elphel.imagej.cuas.CuasRanging;
import com.elphel.imagej.ims.UasLogReader;
import com.elphel.imagej.tileprocessor.QuadCLT;
import com.elphel.imagej.tileprocessor.QuadCLTCPU;
import ij.ImagePlus;
import ij.ImageStack;
public class CuasDetectRT {
public static String SUFFIX_FPIXELS_TIFF = "-CUAS-MERGED-CUAS.tiff";
public static String SUFFIX_LOG = "-LoG";
public static String SUFFIX_CONV2D = "-CONV2D";
public static String SUFFIX_CONV3D3 = "-CONV3D3";
CuasRanging cuasRanging;
UasLogReader uasLogReader;
CLTParameters clt_parameters;
String model_directory;
// String [] model_names;
QuadCLT master_CLT;
String fpixels_file = null;
String base_name = null; // add suffix and
float [][] fpixels;
double [][] dpixels; // same as fpixels for faster calculations on 64-bit processors
int width;
int height;
String [] time_stamps;
double infinity;
public CuasDetectRT(
CLTParameters clt_parameters,
UasLogReader uasLogReader,
String model_directory,
int debugLevel) {
this.uasLogReader = uasLogReader;
this.clt_parameters = clt_parameters;
this.model_directory = model_directory;
this.infinity = clt_parameters.imp.cuas_infinity;
String [] fpixels_paths = CorrectionParameters.getFilesByExtensionAsArray(model_directory, SUFFIX_FPIXELS_TIFF);
if (fpixels_paths.length > 0) {
if (fpixels_paths.length > 1) {
System.out.println((fpixels_paths.length)+" files ending with \""+SUFFIX_FPIXELS_TIFF+"\" found in "+model_directory+", will use the first one.");
}
fpixels_file = fpixels_paths[0];
ImagePlus imp = new ImagePlus(fpixels_file);
width = imp.getWidth();
height = imp.getHeight();
if (width > 0) {
ImageStack stack = imp.getStack();
// Skip non-ts ("average") slices;
int first_slice = 1;
int num_slices = stack.getSize();
for (; !Character.isDigit(stack.getSliceLabel(first_slice).charAt(0)); first_slice++);
time_stamps = new String [num_slices - first_slice + 1];
fpixels = new float [time_stamps.length][width*height];
for (int i = 0; i < time_stamps.length; i++) {
time_stamps[i] = stack.getSliceLabel(first_slice + i);
fpixels[i] = (float[]) stack.getPixels (first_slice + i);
}
String fpixels_name = Path.of(fpixels_file).getFileName().toString();
base_name = fpixels_name.substring(0,fpixels_name.length() - SUFFIX_FPIXELS_TIFF.length());
} else {
System.out.println("Failed to read image data from "+fpixels_file);
fpixels_file = null;
fpixels = null;
}
} else {
System.out.println("No files ending with \""+SUFFIX_FPIXELS_TIFF+"\" found in "+model_directory);
fpixels_file = null;
fpixels = null;
}
if (fpixels != null) {
dpixels = new double [fpixels.length][width*height];
for (int i = 0; i < fpixels.length; i++) for (int pix = 0; pix < fpixels[i].length; pix++) {
dpixels[i][pix] = fpixels[i][pix];
}
} else {
dpixels = null;
}
return;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
String [] getTimeStamps() {
return time_stamps;
}
String [] getTimeStamps(int from_indx) {
String [] time_stamps_from = new String[time_stamps.length - from_indx];
System.arraycopy(time_stamps, from_indx, time_stamps_from, 0, time_stamps_from.length);
return time_stamps_from;
}
String [] getTimeStamps(int from_indx, int tdecimate) {
String [] time_stamps_decimated = new String[time_stamps.length / tdecimate];
for (int i = 0; i < time_stamps_decimated.length; i++) {
time_stamps_decimated[i] = time_stamps[(i+1)* tdecimate - 1];
}
return time_stamps_decimated;
}
public double [][] getDPpixels(){
return dpixels;
}
public float [][] getFPixels() {
return fpixels;
}
public String getBaseName() {
return base_name;
}
public String getModelDirectory() {
return model_directory;
}
public CuasMotion detectTargets(
CLTParameters clt_parameters,
boolean batch_mode,
int debugLevel) {
boolean save_linear_cuas = true;
int curt_pyramid = clt_parameters.imp.curt_pyramid;
double curt_psf_radius = clt_parameters.imp.curt_psf_radius;
double curt_n_sigma = clt_parameters.imp.curt_n_sigma;
double curt_rleak0 = clt_parameters.imp.curt_rleak0;
int curt_pix_decimate = clt_parameters.imp.curt_pix_decimate;
int curt_vel_decimate = clt_parameters.imp.curt_vel_decimate;
int curt_vel_radius = clt_parameters.imp.curt_vel_radius;
double[] curt_temp_weights = clt_parameters.imp.curt_temp_weights.clone();
// Initialize LoG and other kernel parameters, calculate LoG first, show results
int kernel3d3_rad = 1;
CuasRTUtils cuasRTUtils = new CuasRTUtils (
curt_psf_radius, // double psf_radius,
curt_n_sigma, // double n_sigma,
kernel3d3_rad, // int kernel3d3_rad,
curt_temp_weights, // double[] temporal_weights,
curt_pix_decimate, // int pixel_decimate,
curt_vel_decimate, // int velocity_decimate,
curt_vel_radius, // int velocity_radius,
getWidth (), // int width,
getHeight()); // int height)
// For testing, create whole arrays?
boolean save_LoG = debugLevel> -4;
boolean save_LoG_pixels = debugLevel> -4;
boolean save_3d3_pixels = debugLevel> -4;
if (save_LoG) {
String title_log = getBaseName()+SUFFIX_LOG+"-PSF"+cuasRTUtils.getPsfRadius()+"-KR"+cuasRTUtils.getKernel2dRadius();
ImagePlus imp_log = cuasRTUtils.showKernel2d(title_log);
QuadCLTCPU.saveImagePlusInDirectory(imp_log,getModelDirectory());
}
double [][] dpixels = getDPpixels();
double [][] dpixels_log = new double [dpixels.length][dpixels[0].length];
double [] kernel2d = cuasRTUtils.getKernel2d();
double alpha0 = 1.0 - clt_parameters.imp.curt_rleak0;
for (int nseq = 0; nseq < dpixels_log.length; nseq++) {
cuasRTUtils.convolve2DLReLU(
dpixels[nseq], // final double [] data,
kernel2d, // final double [] kernel, // square
dpixels_log[nseq], // double [] result_in,
alpha0); // final double alpha)
}
if (save_LoG_pixels) {
String title_conv2d = getBaseName()+SUFFIX_CONV2D+"-PSF"+cuasRTUtils.getPsfRadius()+
"-KR"+cuasRTUtils.getKernel2dRadius()+"-ALPHA0_"+alpha0;
ImagePlus imp_conv2d = ShowDoubleFloatArrays.makeArrays(
dpixels_log, // float[][] pixels,
getWidth(), // int width,
getHeight(), // int height,
title_conv2d,
getTimeStamps()); //String [] titles)
imp_conv2d.setDisplayRange(CuasRTUtils.IMP_MINMAX[0],CuasRTUtils.IMP_MINMAX[1]);
QuadCLTCPU.saveImagePlusInDirectory(imp_conv2d, getModelDirectory());
}
double w3d3_now = clt_parameters.imp.curt_3d3_wnow;
double w3d3_prev = clt_parameters.imp.curt_3d3_wprev;
double alpha1 = 1.0 - clt_parameters.imp.curt_rleak1;
int dim3d3 = (2*cuasRTUtils.get3d3Radius()+1);
// int size3x3 = dim3d3 * dim3d3;
double [][][] dpixels_3d3 = new double [dpixels.length-1][width*height][dim3d3 * dim3d3];
String title_conv3d3 = getBaseName()+SUFFIX_CONV3D3+"-PSF"+cuasRTUtils.getPsfRadius()+
"-KR"+cuasRTUtils.getKernel2dRadius()+"-ALPHA0_"+alpha0+"+N"+w3d3_now+":"+w3d3_prev+"-ALPHA1_"+alpha1;
// getTimeStamps(int from_indx)
int dbg_seq = 480;
for (int nseq = 1; nseq < dpixels_log.length; nseq++) {
int dbg_lev = (nseq == dbg_seq) ? 1 : -10;
cuasRTUtils.convolve3D3LReLU(
dpixels_log[nseq], // final double [] data,
dpixels_log[nseq-1], // final double [] data_prev,
dpixels_3d3[nseq-1], // double [][] result_in,
w3d3_now, // final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev, // final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
alpha1, // final double alpha) {
dbg_lev); // debugLevel); // final int debugLevel)
}
if (save_3d3_pixels) {
ImagePlus imp_3d3 = cuasRTUtils.render3d3Hyperstack(
dpixels_3d3, // double [][][] coarse_vel_seq, // [nser][npix][nvel]
getTimeStamps(1), // String [] scene_names,
title_conv3d3); // String title)
QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory());
}
// building pyramid
int pyramid_levels = clt_parameters.imp.curt_pyramid;
double [][][] dpixels_pyramid = new double [pyramid_levels][][];
String [][] ts_pyramid = new String [pyramid_levels][];
double [][][][] dpixels_3d3_pyramid = new double [pyramid_levels][][][];
ts_pyramid[0] = getTimeStamps(1);
dpixels_3d3_pyramid[0] = dpixels_3d3;
int center9 = 4;
for (int nlev = 0; nlev < pyramid_levels; nlev++) {
// copy centers
dpixels_pyramid[nlev] = new double [dpixels_3d3_pyramid[nlev].length][width*height];
for (int nseq = 0; nseq < dpixels_pyramid[nlev].length; nseq++) {
for (int npix = 0; npix < dpixels_pyramid[nlev][nseq].length; npix++) {
dpixels_pyramid[nlev][nseq][npix] = dpixels_3d3_pyramid[nlev][nseq][npix][center9];
}
}
if (save_LoG_pixels) {
String title_conv2d_lev = getBaseName()+SUFFIX_CONV2D+"-PSF"+cuasRTUtils.getPsfRadius()+
"-KR"+cuasRTUtils.getKernel2dRadius()+"-ALPHA0_"+alpha0+"-LEV"+nlev;
ImagePlus imp_conv2d = ShowDoubleFloatArrays.makeArrays(
dpixels_pyramid[nlev], // float[][] pixels,
getWidth(), // int width,
getHeight(), // int height,
title_conv2d_lev,
ts_pyramid[nlev]); //String [] titles)
imp_conv2d.setDisplayRange(CuasRTUtils.IMP_MINMAX[0],CuasRTUtils.IMP_MINMAX[1]);
QuadCLTCPU.saveImagePlusInDirectory(imp_conv2d, getModelDirectory());
}
// run next pyramid level (use half of the temporal slices)
if (nlev < (pyramid_levels -1)) {
int num_lev_scenes = (dpixels_pyramid[nlev].length)/2 -1;
dpixels_3d3_pyramid[nlev+1] = new double [num_lev_scenes][width*height][dim3d3 * dim3d3];
ts_pyramid[nlev+1] = new String[num_lev_scenes];
for (int nseq = 0; nseq < num_lev_scenes; nseq++) {
ts_pyramid[nlev+1][nseq] = ts_pyramid[nlev][2*(nseq + 1)];
cuasRTUtils.convolve3D3LReLU(
dpixels_pyramid[nlev][2*nseq+2], // final double [] data,
dpixels_pyramid[nlev][2*nseq], // final double [] data_prev,
dpixels_3d3_pyramid[nlev+1][nseq], // double [][] result_in,
w3d3_now, // final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev, // final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
alpha1, // final double alpha) {
debugLevel); // final int debugLevel)
}
if (save_3d3_pixels) {
ImagePlus imp_3d3 = cuasRTUtils.render3d3Hyperstack(
dpixels_3d3_pyramid[nlev+1], // double [][][] coarse_vel_seq, // [nser][npix][nvel]
ts_pyramid[nlev+1], // String [] scene_names,
title_conv3d3+"-LEV"+(nlev+1)); // String title)
QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory());
}
}
}
return null;
/*
CuasMotion cuasMotion = new CuasMotion (
clt_parameters, // CLTParameters clt_parameters,
getTimeStamps(), // String [] scene_titles,
cuasRanging.getCenter_CLT(), // QuadCLT parentCLT,
null, // fpixels_avg, // float [] fpixels_avg,
uasLogReader, // UasLogReader uasLogReader,
debugLevel); // int debugLevel)
return cuasMotion;
*/
}
}
/*
uasLogReader, // UasLogReader uasLogReader,
batch_mode); // boolean batch_mode)
*/
\ No newline at end of file
......@@ -11,7 +11,9 @@ import com.elphel.imagej.tileprocessor.TileNeibs;
import ij.ImagePlus;
public class CuasRTUtils {
final static double N_SIGMA = 4.0; // for LoG kernel size
public static double [] IMP_MINMAX= {-5,5}; //default range for
final double psf_radius;
final double n_sigma; // for LoG kernel size
final double [] kernel2d;
final private int kernel2d_rad;
// contains pixel indices, approximately in reverse bit order for multithreading efficiency
......@@ -47,7 +49,7 @@ public class CuasRTUtils {
// final private int tl_offset;
public CuasRTUtils (
double psf_radius,
// int kernel2d_rad,
double n_sigma,
int kernel3d3_rad,
double[] temporal_weights,
int pixel_decimate,
......@@ -55,10 +57,12 @@ public class CuasRTUtils {
int velocity_radius,
int width,
int height) {
this.psf_radius = psf_radius;
this.width = width;
this.height = height;
this.n_sigma = n_sigma;
// Setup 2D pre-filter kernel, based on LoG
kernel2d_rad = getRadiusLoGKernel(psf_radius,N_SIGMA);
kernel2d_rad = getRadiusLoGKernel(psf_radius,n_sigma);
kernel2d = getLoGKenel(psf_radius, kernel2d_rad);
int [][] indices = getIndices(
kernel2d_rad,
......@@ -101,6 +105,23 @@ public class CuasRTUtils {
indx_margins_5d = indices[2];
}
public double getPsfRadius() {
return psf_radius;
}
public int getKernel2dRadius() {
return kernel2d_rad;
}
public int get3d3Radius() {
return kernel3d3_rad;
}
public double [] getKernel2d() {
return kernel2d;
}
private void normalize1d(double [] data) {
double s = 0;
for (double d : data) s+= d;
......@@ -116,22 +137,27 @@ public class CuasRTUtils {
int height) {
int kernel_size = 2 * kernel_rad+1;
int [] i_all = new int [width*height];
int [] i_center = new int [(width-kernel_size)*(height-kernel_size)];
int [] i_margins = new int [i_all.length-i_center.length];
int cent_width = width-kernel_size+1;
int cent_height = height-kernel_size+1;
int cent_size = cent_width*cent_height;
int [] i_center = new int [cent_size];
int [] i_margins = new int [i_all.length - i_center.length];
int n;
for (n = 0; (1 << n) < i_all.length; n++);
int shft = 32-n;
int n_all = 1 << n;
// int mask = n_all-1;
int iall = 0, icent=0, imarg=0;
for (int i = 0; i < 1 << shft; i++) {
int ri = Integer.reverse(i)>>shft;
for (int i = 0; i < n_all; i++) {
int ri = Integer.reverse(i)>>>shft;
if (ri < i_all.length) {
int y = i/width;
int x = i%width;
i_all[iall++] = i;
int y = ri/width;
int x = ri%width;
i_all[iall++] = ri;
if ((x < kernel_rad) || (y < kernel_rad) || (x >= (width-kernel_rad)) || (y >= (height-kernel_rad))) {
i_margins[imarg++] = i;
i_margins[imarg++] = ri;
} else {
i_center[icent++] = i;
i_center[icent++] = ri;
}
}
}
......@@ -158,41 +184,6 @@ public class CuasRTUtils {
throw new IllegalArgumentException("Kernel length = "+kernel.length+" does not match kernel size (2*"+kernel2d_rad+"+1) * (2*"+kernel2d_rad+"+1) ="+(kernel_size * kernel_size));
}
}
/*
private void setupConvolve3d(
final double [] hist_weights, // same
final int decim_pix,
final int decim_vel,
final int rad_vel){
final int num_subpix = decim_pix * decim_pix;
final int num_layers = hist_weights.length;
final int num_src_vel = (2*this.kernel3d3_rad+1)*(2*this.kernel3d3_rad+1);
final int num_dst_vel = (2*rad_vel+1)*(2*rad_vel+1);
final double [][][][][] kern3d = new double [num_subpix][num_layers][][][];
for (int nsubpix_y = 0; nsubpix_y<decim_pix; nsubpix_y++) {
for (int nsubpix_x = 0; nsubpix_x<decim_pix; nsubpix_x++) {
int nsubpix = nsubpix_x + nsubpix_y * decim_pix;
for (int nlayer = 0; nlayer < num_layers; nlayer++) {
int pix_rng = 2 * nlayer; // from -pix_rng to +pix_rng+1 inclusive
int num_src_pix = 2 * pix_rng + 2;
kern3d[nsubpix][nlayer] = new double [num_src_pix * num_src_pix][num_src_vel][num_dst_vel];
// first calculate total energy, then how that apply this energy to specific velocity? how to mix mutual positions and
// source direction
// for nlayer > 0 use mutual position, for layer 0 use source direction
// Certain?
if (nlayer == 0) { // same layer - use source direction
} else { // one of the earliest layers - use mutual position
}
}
}
}
}
*/
public double [][][] convolve3d(
final double [][][] data, // outer index - historic layers, [0] - latest, second index - pixel, third - direction ([9])
double [][][] result_in){
......@@ -307,14 +298,17 @@ public class CuasRTUtils {
double [][] result_in,
final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
final double alpha) {
final double alpha,
final int debugLevel) {
final int kern_size_3d3 = 2 * kernel3d3_rad + 1;
final double [][] result = (result_in != null) ? result_in : new double [data.length][kern_size_3d3*kern_size_3d3];
int dbg_thresh = 10; // -4;
checkData(data);
checkData(data_prev);
checkData(result);
final int tl_offset = kernel3d3_rad * (width+1);
final int row_offset = width - (2*kernel3d3_rad +1);
final int dbg_pix = (debugLevel > dbg_thresh) ? (300+ 173*width):-1;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
// processing center area, no need to care about margins
......@@ -323,14 +317,18 @@ public class CuasRTUtils {
public void run() {
for (int nPix = ai.getAndIncrement(); nPix < indx_center_3d3.length; nPix = ai.getAndIncrement()) {
int ipix_dst = indx_center_3d3[nPix];
if (ipix_dst == dbg_pix) {
System.out.println("convolve3D3LReLU(): ipix_dst="+ipix_dst);
}
int ipix_prev = ipix_dst- tl_offset;
int ikern = kern_size_3d3*kern_size_3d3;
double v0 = w_now * data[ipix_dst]; // will ve added to all velocity outputs
for (int iy = 0; iy < kern_size_3d3; iy++) {
for (int ix = 0; ix < kern_size_3d3; ix++) {
double v = data[ipix_prev++] * w_prev * v0;
double v = data_prev[ipix_prev++] * w_prev + v0;
result[ipix_dst][--ikern] = Math.max(v, alpha * v);
}
ipix_prev += row_offset;
}
}
}
......@@ -346,7 +344,7 @@ public class CuasRTUtils {
for (int nPix = ai.getAndIncrement(); nPix < indx_margins_3d3.length; nPix = ai.getAndIncrement()) {
int ipix_dst = indx_margins_3d3[nPix];
int ikern = kern_size_3d3*kern_size_3d3;
double v0 = w_now * data[ipix_dst]; // will ve added to all velocity outputs
double v0 = w_now * data[ipix_dst]; // will be added to all velocity outputs
for (int iy = 0; iy < kern_size_3d3; iy++) {
int dy = iy-kernel3d3_rad;
for (int ix = 0; ix < kern_size_3d3; ix++) {
......@@ -354,7 +352,7 @@ public class CuasRTUtils {
int ipix_prev = tn.getNeibIndex(ipix_dst, dx, dy);
double v = v0;
if (ipix_prev >= 0) {
v += data[ipix_prev] * w_prev;
v += data_prev[ipix_prev] * w_prev;
}
result[ipix_dst][--ikern] = Math.max(v, alpha * v);
}
......@@ -498,6 +496,7 @@ public class CuasRTUtils {
2 * kernel2d_rad + 1,
2 * kernel2d_rad + 1,
title);
imp_kernel2d.setDisplayRange(IMP_MINMAX[0],IMP_MINMAX[1]);
return imp_kernel2d;
}
......@@ -534,8 +533,50 @@ public class CuasRTUtils {
return render_sliced;
}
public ImagePlus render3d3Hyperstack(
double [][][] coarse_vel_seq, // [nser][npix][nvel]
String [] scene_names,
String title) {
String [] arrows9 = get9Arrows();
double [][][] render_sliced = new double [arrows9.length][coarse_vel_seq.length][width * height];
for (double [][] slices:render_sliced) {
for (double [] slice:slices) {
Arrays.fill(slice, Double.NaN);
}
}
for (int nseq = 0; nseq < coarse_vel_seq.length; nseq++) {
for (int npix=0; npix < coarse_vel_seq[nseq].length; npix++) if (coarse_vel_seq[nseq][npix] !=null){
for (int s = 0; s < coarse_vel_seq[nseq][npix].length; s++) {
render_sliced[s][nseq][npix] = coarse_vel_seq[nseq][npix][s];
}
}
}
ImagePlus imp = ShowDoubleFloatArrays.showArraysHyperstack(
render_sliced, // double[][][] pixels,
width, // int width,
title, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
scene_names, // all slices*frames titles or just slice titles or null
arrows9, // String [] frame_titles, // frame titles or null
false); // boolean show)
imp.setDisplayRange(IMP_MINMAX[0],IMP_MINMAX[1]);
return imp;
}
public String [] get9Arrows() {
String [] arrows= {
"\u2191\u2190", // Up-Left
"\u2191", // Up
"\u2192\u2191", // Right-Up
"\u2190", // Left
"\u25E6", // Bullet
"\u2192", // Right
"\u2193\u2190", // Down-Left
"\u2193", // Down
"\u2192\u2193"}; // Right-Down
return arrows;
}
public String [] get9Arrows_diags() {
String [] arrows= {
"\u2196", // Left-Up
"\u2191", // Up
......@@ -544,8 +585,8 @@ public class CuasRTUtils {
"\u25E6", // Bullet
"\u2192", // Right
"\u2199", // Left-Down
"\u2198", // Right-Down
"\u2193"}; // Down
"\u2193", // Down
"\u2198"}; // Right-Down
return arrows;
}
......@@ -613,6 +654,7 @@ public class CuasRTUtils {
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
top_titles, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
false); // boolean show)
imp.setDisplayRange(IMP_MINMAX[0],IMP_MINMAX[1]);
return imp;
}
// Display convolution result [vout][2*width*2*height]. Or hyperstack with x and y sliders?
......@@ -664,6 +706,7 @@ public class CuasRTUtils {
scene_titles, // slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
v_titles, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
false); // boolean show)
imp.setDisplayRange(IMP_MINMAX[0],IMP_MINMAX[1]);
return imp;
}
......
......@@ -1121,8 +1121,22 @@ min_str_neib_fpn 0.35
public double cuas_max_disp_diff = 0.05; // Maximal disparity difference during last change to consider disparity valid
public double cuas_min_disp_str = 0.4; // Minimal disparity strength to consider disparity valid
public double cuas_rng_limit = 5000; // maximal displayed distance to target
// CUAS Reltime
public boolean curt_en = false; // enable airplane mode
// CUAS Realtime
public boolean curt_en = false; // enable cuas rt calculation
public int curt_pyramid = 7; // temporal pyramid levels
public double curt_psf_radius = 1.6; // sensor PSF radius for LoG pre-filter
public double curt_n_sigma = 4.0; // cutoff LoG kernel array, number of sigmas
public double curt_rleak0 = 0.1; // 1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the LoG prefilter
public double curt_3d3_wnow = 0.5; // Weight of the latest (now) temporal slice when creating coarse velocities
public double curt_3d3_wprev = 0.5; // Weight of the previous temporal slice when creating coarse velocities
public double curt_rleak1 = 0.1; // 1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the coarse velocity 3d convolution
public int curt_pix_decimate = 1; // decimate pixel resolution
public int curt_vel_decimate = 4; // decimate velocities
public int curt_vel_radius = 5; // velocities radius in decimated samples
public double[] curt_temp_weights = {1,1,1,1,1}; // historic weights for 5D convolution ([0] is the latest sample)
// Airplane mode
public boolean air_mode_en = false; // enable airplane mode
......@@ -3344,6 +3358,30 @@ min_str_neib_fpn 0.35
gd.addTab("CUAS RT", "CUAS Real Time");
gd.addCheckbox ("CUAS realtime enable", this.curt_en,
"Enable testing of the realtime CUAS detection.");
gd.addNumericField("Temporal pyramid levels", this.curt_pyramid, 0,3,"",
"Number of binary temporal pyramid levels.");
gd.addNumericField("Optical PSF radius", this.curt_psf_radius, 6,8,"pix",
"Sensor optical PSF radius for the LoG pre-filter.");
gd.addNumericField("N-sigmas for LoG cutoff", this.curt_n_sigma, 6,8,"x",
"Cutoff LoG kernel array, number of sigmas.");
gd.addNumericField("Reversed LReLU LoG leak", this.curt_rleak0, 6,8,"x",
"1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the LoG prefilter.");
gd.addNumericField("Coarse velocities weight now", this.curt_3d3_wnow, 6,8,"x",
"Weight of the latest (now) temporal slice when creating coarse velocities.");
gd.addNumericField("Coarse velocities weight previous", this.curt_3d3_wprev, 6,8,"x",
"Weight of the previous temporal slice when creating coarse velocities.");
gd.addNumericField("Reversed LReLU 3d3 leak", this.curt_rleak1, 6,8,"x",
" 1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the coarse velocity 3d convolution.");
gd.addNumericField("Pixel decimate", this.curt_pix_decimate, 0,3,"",
"Decimate pixels (increase resolution).");
gd.addNumericField("Velocity decimate", this.curt_vel_decimate, 0,3,"",
"Decimate velocities (increase velocity resolution).");
gd.addNumericField("Velocities radius", this.curt_vel_radius, 0,3,"",
"Velocities radius in decimated samples.");
gd.addStringField ("Historic weight for 5D convolution", IntersceneMatchParameters.doublesToString(curt_temp_weights), 80,
"Historic weights for 5D convolution ([0] is the latest sample). Will be normalized");
//
gd.addTab("Airplane","Airplane mode (fast forward movement, low vertical speed");
gd.addCheckbox ("Enable airplane mode", this.air_mode_en,
......@@ -4816,6 +4854,18 @@ min_str_neib_fpn 0.35
this.cuas_rng_limit = gd.getNextNumber();
this.curt_en = gd.getNextBoolean();
this.curt_pyramid = (int) gd.getNextNumber();
this.curt_psf_radius = gd.getNextNumber();
this.curt_n_sigma = gd.getNextNumber();
this.curt_rleak0 = gd.getNextNumber();
this.curt_3d3_wnow = gd.getNextNumber();
this.curt_3d3_wprev = gd.getNextNumber();
this.curt_rleak1 = gd.getNextNumber();
this.curt_pix_decimate = (int) gd.getNextNumber();
this.curt_vel_decimate = (int) gd.getNextNumber();
this.curt_vel_radius = (int) gd.getNextNumber();
this.curt_temp_weights = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 0);
this.air_mode_en = gd.getNextBoolean();
this.air_sync_ims = gd.getNextBoolean();
this.air_disp_corr = gd.getNextBoolean();
......@@ -6117,6 +6167,18 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_rng_limit", this.cuas_rng_limit+""); // double
properties.setProperty(prefix+"curt_en", this.curt_en+""); // boolean
properties.setProperty(prefix+"curt_pyramid", this.curt_pyramid+""); // int
properties.setProperty(prefix+"curt_psf_radius", this.curt_psf_radius+""); // double
properties.setProperty(prefix+"curt_n_sigma", this.curt_n_sigma+""); // double
properties.setProperty(prefix+"curt_rleak0", this.curt_rleak0+""); // double
properties.setProperty(prefix+"curt_3d3_wnow", this.curt_3d3_wnow+""); // double
properties.setProperty(prefix+"curt_3d3_wprev", this.curt_3d3_wprev+""); // double
properties.setProperty(prefix+"curt_rleak1", this.curt_rleak1+""); // double
properties.setProperty(prefix+"curt_pix_decimate", this.curt_pix_decimate+""); // int
properties.setProperty(prefix+"curt_vel_decimate", this.curt_vel_decimate+""); // int
properties.setProperty(prefix+"curt_vel_radius", this.curt_vel_radius+""); // int
properties.setProperty(prefix+"curt_temp_weights", IntersceneMatchParameters.doublesToString(this.curt_temp_weights));
properties.setProperty(prefix+"air_mode_en", this.air_mode_en+""); // boolean
properties.setProperty(prefix+"air_sync_ims", this.air_sync_ims+""); // boolean
properties.setProperty(prefix+"air_disp_corr", this.air_disp_corr+""); // boolean
......@@ -7401,6 +7463,21 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_rng_limit")!=null) this.cuas_rng_limit=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_limit"));
if (properties.getProperty(prefix+"curt_en")!=null) this.curt_en=Boolean.parseBoolean(properties.getProperty(prefix+"curt_en"));
if (properties.getProperty(prefix+"curt_pyramid")!=null) this.curt_pyramid=Integer.parseInt(properties.getProperty(prefix+"curt_pyramid"));
if (properties.getProperty(prefix+"curt_psf_radius")!=null) this.curt_psf_radius=Double.parseDouble(properties.getProperty(prefix+"curt_psf_radius"));
if (properties.getProperty(prefix+"curt_n_sigma")!=null) this.curt_n_sigma=Double.parseDouble(properties.getProperty(prefix+"curt_n_sigma"));
if (properties.getProperty(prefix+"curt_rleak0")!=null) this.curt_rleak0=Double.parseDouble(properties.getProperty(prefix+"curt_rleak0"));
if (properties.getProperty(prefix+"curt_3d3_wnow")!=null) this.curt_3d3_wnow=Double.parseDouble(properties.getProperty(prefix+"curt_3d3_wnow"));
if (properties.getProperty(prefix+"curt_3d3_wprev")!=null) this.curt_3d3_wprev=Double.parseDouble(properties.getProperty(prefix+"curt_3d3_wprev"));
if (properties.getProperty(prefix+"curt_rleak1")!=null) this.curt_rleak1=Double.parseDouble(properties.getProperty(prefix+"curt_rleak1"));
if (properties.getProperty(prefix+"curt_pix_decimate")!=null) this.curt_pix_decimate=Integer.parseInt(properties.getProperty(prefix+"curt_pix_decimate"));
if (properties.getProperty(prefix+"curt_vel_decimate")!=null) this.curt_vel_decimate=Integer.parseInt(properties.getProperty(prefix+"curt_vel_decimate"));
if (properties.getProperty(prefix+"curt_vel_radius")!=null) this.curt_vel_radius=Integer.parseInt(properties.getProperty(prefix+"curt_vel_radius"));
if (properties.getProperty(prefix+"curt_temp_weights")!=null) this.curt_temp_weights= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"curt_temp_weights"),0); // use 0
if (properties.getProperty(prefix+"air_mode_en")!=null) this.air_mode_en=Boolean.parseBoolean(properties.getProperty(prefix+"air_mode_en"));
if (properties.getProperty(prefix+"air_sync_ims")!=null) this.air_sync_ims=Boolean.parseBoolean(properties.getProperty(prefix+"air_sync_ims"));
if (properties.getProperty(prefix+"air_disp_corr")!=null) this.air_disp_corr=Boolean.parseBoolean(properties.getProperty(prefix+"air_disp_corr"));
......@@ -8666,6 +8743,18 @@ min_str_neib_fpn 0.35
imp.cuas_rng_limit = this.cuas_rng_limit;
imp.curt_en = this.curt_en;
imp.curt_pyramid = this.curt_pyramid;
imp.curt_psf_radius = this.curt_psf_radius;
imp.curt_n_sigma = this.curt_n_sigma;
imp.curt_rleak0 = this.curt_rleak0;
imp.curt_3d3_wnow = this.curt_3d3_wnow;
imp.curt_3d3_wprev = this.curt_3d3_wprev;
imp.curt_rleak1 = this.curt_rleak1;
imp.curt_pix_decimate = this.curt_pix_decimate;
imp.curt_vel_decimate = this.curt_vel_decimate;
imp.curt_vel_radius = this.curt_vel_radius;
imp.curt_temp_weights = this.curt_temp_weights.clone();
imp.air_mode_en = this.air_mode_en;
imp.air_sync_ims = this.air_sync_ims;
imp.air_disp_corr = this.air_disp_corr;
......
......@@ -62,6 +62,7 @@ import com.elphel.imagej.cuas.Cuas;
import com.elphel.imagej.cuas.CuasCenterLma;
import com.elphel.imagej.cuas.CuasMotion;
import com.elphel.imagej.cuas.CuasRanging;
import com.elphel.imagej.cuas.rt.CuasDetectRT;
import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.gpu.TpTask;
......@@ -7238,36 +7239,12 @@ java.lang.NullPointerException
// Moved to the very end, after 3D
// boolean test_vegetation = true;
if (master_CLT.hasCenterClt() && clt_parameters.imp.curt_en) { // cuas mode
if (debugLevel >-3) {
System.out.println("===== Running CUAS realtime testing. =====");
}
CuasRanging cuasRanging = new CuasRanging (
clt_parameters, // CLTParameters clt_parameters,
false, // boolean realtime_mode,
master_CLT, // QuadCLT center_CLT,
quadCLTs, // QuadCLT [] scenes,
debugLevel); // int debugLevel) {
CuasMotion cuasMotion = cuasRanging.detectTargets(
uasLogReader, // UasLogReader uasLogReader,
batch_mode); // boolean batch_mode)
if (cuasMotion == null) {
System.out.println("Failed target detection. Probably, radar mode was selected but target file does not exist (created with \"CUAS Combine\" command)");
} else {
if (debugLevel > -4) {
System.out.println("Target detection DONE");
}
}
}
if (master_CLT.hasCenterClt() && clt_parameters.imp.cuas_targets_en) { // cuas mode
if (debugLevel >-3) {
System.out.println("===== Running CUAS ranging. =====");
}
CuasRanging cuasRanging = new CuasRanging (
clt_parameters, // CLTParameters clt_parameters,
false, // boolean realtime_mode,
master_CLT, // QuadCLT center_CLT,
quadCLTs, // QuadCLT [] scenes,
debugLevel); // int debugLevel) {
......
......@@ -53,13 +53,16 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.ColorProcParameters;
import com.elphel.imagej.cameras.EyesisCorrectionParameters;
import com.elphel.imagej.cameras.EyesisCorrectionParameters.CorrectionParameters;
import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc;
import com.elphel.imagej.correction.EyesisCorrections;
import com.elphel.imagej.correction.SyncCommand;
import com.elphel.imagej.cuas.CuasMotion;
import com.elphel.imagej.cuas.CuasMultiSeries;
import com.elphel.imagej.cuas.rt.CuasDetectRT;
import com.elphel.imagej.gpu.ExportForGPUDevelopment;
import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
......@@ -8541,9 +8544,9 @@ if (debugLevel > -100) return true; // temporarily !
// has no IMS data loaded. setCameraLLA() is called in CuasRanging.addUasData()
// once center_CLT.did_ins_2 is available (from createCenterClt() or restoreCenterClt()).
}
String uas_sky_mask_path = quadCLT_main.correctionsParameters.getUasSkyMask();
switch (cuas_proc_mode) {
case 0 :
String uas_sky_mask_path = quadCLT_main.correctionsParameters.getUasSkyMask();
QuadCLT[] index_scenes = {null,null}; // [0] - first for this series, [1] - overall first
for (int nseq = 0; nseq < num_seq; nseq++) {
long start_time_seq = System.nanoTime();
......@@ -8595,19 +8598,6 @@ if (debugLevel > -100) return true; // temporarily !
Arrays.sort(scene_names);
}
/*
// Process UAS logs
UasLogReader uasLogReader = null;
String uas_log_path = quadCLT_main.correctionsParameters.getUasLogsPath();
System.out.println("Using UAS log file: "+uas_log_path);
if ((uas_log_path != null) && (uas_log_path.length() > 0)) {
uasLogReader = new UasLogReader(uas_log_path, quadCLT_main.correctionsParameters.cuasUasTimeStamp, null, quadCLT_main);
uasLogReader.setCameraATR(quadCLT_main.correctionsParameters.cuasCameraATR);
uasLogReader.setUASHomeNed(quadCLT_main.correctionsParameters.cuasSetHome? quadCLT_main.correctionsParameters.cuasUASHome : null);
}
*/
if (debugLevel > -4) {
System.out.println("cuas_centers="+((cuas_centers != null)?("[\""+cuas_centers[0]+"\",\""+cuas_centers[1]+"\"]"):"null"));
}
......@@ -9185,6 +9175,83 @@ if (debugLevel > -100) return true; // temporarily !
cuasMultiSeries.combineVideos();
}
break;
case 3:
{
System.out.println("Processing realtime tests");
SetChannels [] set_channels_main = quadCLT_main.setChannels(debugLevel);
String [] scene_names = null;
if (set_channels_main != null) {
scene_names = new String[ set_channels_main.length];
for (int i = 0; i < scene_names.length; i++) {
scene_names[i] = set_channels_main[i].name();
}
Arrays.sort(scene_names);
}
String model_suffix = "-CENTER";
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");
if (pathFirstLast != null) {
File [] scene_dirs = (new File(pathFirstLast[nseq].path)).listFiles(); // may contain non-directories, will be filtered by filterScenes
System.out.println("scene_dirs.length="+scene_dirs.length);
System.out.println("pathFirstLast[nseq].path="+pathFirstLast[nseq].path);
quadCLT_main.correctionsParameters.filterScenes(
scene_dirs, // File [] scene_dirs,
pathFirstLast[nseq].first, // int scene_first, // first scene to process
pathFirstLast[nseq].last); // int scene_last); // last scene to process (negative - add length
/*
if (pathFirstLast[nseq].movement_size < 0) {
clt_parameters.imp.mov_en = false;
if (debugLevel > -4) {
System.out.println("Disabling movement detection for this scene.");
}
} else {
clt_parameters.imp.mov_en = true;
clt_parameters.imp.mov_max_len = pathFirstLast[nseq].movement_size;
if (debugLevel > -4) {
System.out.println("Enabling movement detection for this scene with maximum cluster linear size of "+
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 [] model_names = CorrectionParameters.listModelNames( quadCLT_main.correctionsParameters.getSourcePaths());
// below is valid for CUAS
String models_directory = quadCLT_main.correctionsParameters.getX3dDirectory();
String model_version = quadCLT_main.correctionsParameters.getX3dModelVersion();
String [] model_paths = CorrectionParameters.listExistingModelPaths(
models_directory,
model_version,
model_suffix,
model_names);
if (model_paths.length > 0) {
for (int i = 0; i < model_paths.length; i++) {
System.out.println("Processing model directory: "+model_paths[i]);
// check if *-CUAS
CuasDetectRT cuasDetectRT = new CuasDetectRT(
clt_parameters, // CLTParameters clt_parameters,
uasLogReader, // UasLogReader uasLogReader,
model_paths[i], // String model_directory) {
debugLevel); // int debugLevel)
CuasMotion cuasMotion= cuasDetectRT.detectTargets(
clt_parameters, // CLTParameters clt_parameters,
(pathFirstLast != null), // boolean batch_mode,
debugLevel); // int debugLevel) {
}
} else {
System.out.println("No model paths match criteria");
}
}
System.out.println("nseq="+nseq);
}
}
break;
} // switch (cuas_proc_mode) {
System.out.println("\n\n\nPROCESSING OF "+num_seq+" SCENE SEQUENCES is FINISHED in "+
......
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