Commit d786d9fe authored by Andrey Filippov's avatar Andrey Filippov

Added support of command interruption.

parent 00746159
......@@ -1520,14 +1520,18 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
String label = e.getActionCommand();
if (label.equals("Abort")) {
this.SYNC_COMMAND.stopRequested.set(1);
this.SYNC_COMMAND.confirm = true;
return;
} else if (label.equals("Stop")) {
this.SYNC_COMMAND.stopRequested.set(2);
this.SYNC_COMMAND.confirm = true;
return;
}
// System.out.println("actionPerformed: SwingUtilities.isEventDispatchThread()="+SwingUtilities.isEventDispatchThread());
// executed in EDT, so no need to synchronize additionally?
if (this.SYNC_COMMAND.isRunning) {
this.SYNC_COMMAND.interruptCommand();
/*
GenericDialog gd = new GenericDialog("Busy");
gd.addMessage("Command \"" + this.SYNC_COMMAND.buttonLabel + "\" is running. Ask it to stop "
+ ((this.SYNC_COMMAND.stopRequested.get() != 0) ? "(again!) " : "") + "(when possible)?");
......@@ -1536,6 +1540,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
if (gd.wasCanceled())
return;
this.SYNC_COMMAND.stopRequested.set(gd.wasOKed() ? 1 : 2);
*/
return;
}
synchronized (this.SYNC_COMMAND) {
......@@ -7742,7 +7747,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
CLT_PARAMETERS.setRGBParameters(RGB_PARAMETERS);
try {
TWO_QUAD_CLT.batchLwirRig(QUAD_CLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.batchLwirRig(
SYNC_COMMAND, // SyncCommand sync_command,
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
COLOR_PROC_PARAMETERS, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -7829,6 +7836,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.TestInterScene(
SYNC_COMMAND, // SyncCommand sync_command,
// use_aux, // boolean is_aux,
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
// QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
......@@ -7922,6 +7930,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
try {
TwoQuadCLT.buildSeriesTQ(
SYNC_COMMAND, // SyncCommand sync_command,
cuas_proc_mode, // int cuas_proc_mode, // 0 - old, 1 combine scene series
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
......@@ -8102,7 +8111,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.TestInterLMA(quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.TestInterLMA(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
......@@ -8187,7 +8198,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interPairsLMA(quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.interPairsLMA(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
......@@ -8271,7 +8284,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interSeriesLMA(quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.interSeriesLMA(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -8358,7 +8373,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.intersceneAccumulate(quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.intersceneAccumulate(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
......@@ -8442,6 +8459,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interIntraExportML(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
......@@ -8528,7 +8546,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
try {
if (batch_noise) {
TWO_QUAD_CLT.intersceneNoiseBatch(quadCLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.intersceneNoiseBatch(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
......@@ -8540,7 +8560,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
UPDATE_STATUS, // final boolean updateStatus,
DEBUG_LEVEL);
} else {
TWO_QUAD_CLT.intersceneNoise(quadCLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.intersceneNoise(
SYNC_COMMAND, // SyncCommand sync_command,
quadCLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
......
......@@ -2,8 +2,48 @@ package com.elphel.imagej.correction;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.common.GenericJTabbedDialog;
public class SyncCommand {
public static final int STOP_NO = 0;
public static final int STOP_ASAP = 1;
public static final int STOP_CONVENIENT = 2;
public boolean isRunning = false;
public AtomicInteger stopRequested = new AtomicInteger(0); // 0 - not requested, 1 - ASAP, 2 - gracefully
public String buttonLabel = "";
public boolean confirm = true;
public boolean interruptCommand() {
boolean asap = false;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Interrupt Command",600,300);
gd.addCheckbox ("Ask for confirmation", this.confirm,
"If checked, program will pause at a checkpoint allowing to cancel the stop request and continue.");
gd.addCheckbox ("ASAP", asap,
"Stop ASAP. If uncheked, stop at more convenient stage.");
gd.showDialog();
if (gd.wasCanceled())
return false;
this.confirm= gd.getNextBoolean();
this.stopRequested.set(gd.getNextBoolean() ? STOP_ASAP : STOP_CONVENIENT );
return true;
}
public boolean stopNow(boolean convenient) {
if (stopRequested.get()==STOP_NO){
return false;
}
//if (stopRequested.get() ==)
if (!convenient && (stopRequested.get()==STOP_CONVENIENT)) {
return false;
}
if (!confirm) {
return true;
}
GenericJTabbedDialog gd = new GenericJTabbedDialog("Stop requested, "+(convenient?"convenient point":"ASAP point"),600,300);
gd.addMessage ("OK to stop, Cancel to continue");
stopRequested.set(STOP_NO); // reset pending stop in any case.
gd.showDialog();
if (gd.wasCanceled())
return false;
return true;
}
}
\ No newline at end of file
......@@ -225,7 +225,8 @@ public class GroundPlane {
final int debugLevel) {
final boolean [] good_tiles = new boolean[ref_scene.getTilesX()*ref_scene.getTilesY()];
String dbg_title =ref_scene.getImageName()+"-ground_tilts";
// String dbg_title =ref_scene.getImageName()+"-ground_tilts";
String dbg_title ="-ground_tilts";
double [][] to_ground_xyzatr_frac= getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
......@@ -237,7 +238,6 @@ public class GroundPlane {
if (to_ground_xyzatr_frac == null) {
to_ground_xyzatr_frac = new double [][] {new double[3], new double[3], new double[1]};
}
// To get terrain disparity (until rotation is fixed) use "good_tiles" from getPlaneDualPassMetric and re-calculate ground disparity plane
double [][] to_ground_xyzatr = {to_ground_xyzatr_frac[0],to_ground_xyzatr_frac[1]};
......@@ -254,18 +254,6 @@ public class GroundPlane {
dbg_title+"-disp", // final String dbg_title,
debugLevel); // final int debugLevel)
/*
double [] disparity_plane = getDisparityPlaneDualPass( // returns to_ground_xyzatr (rotated around the ground point nadir of the drone)
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
ref_scene.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
gnd_disp, // final double [] gnd_disp, // if not null
dbg_title+"-disp", // final String dbg_title,
debugLevel); // final int debugLevel)
*/
return new GroundPlane(
to_ground_xyzatr, // double [][] to_ground_xyzatr,
disparity_plane, // double [] disparity_plane,
......@@ -274,8 +262,6 @@ public class GroundPlane {
ref_scene.getQEnu()); // double [] quat_enu) {
}
public static double [][] getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
final CLTParameters clt_parameters,
final QuadCLT ref_Clt,
......@@ -547,19 +533,43 @@ public class GroundPlane {
double [][] virtual_camera_from_camera = ErsCorrection.combineXYZATR(ground_xyzatr, virtual_camera_from_ground_xyz);
// FIXME: Next is correct (at least approximately, "-"/invert, order,), find out why
System.out.println("FIXME: Inverted X, Y, kept Z, and ATR. Find out why.");
// double [][] vcfs_test = {
// {-virtual_camera_from_camera[0][0], -virtual_camera_from_camera[0][1], virtual_camera_from_camera[0][2]},
// { virtual_camera_from_camera[1][0], virtual_camera_from_camera[1][1], virtual_camera_from_camera[1][2]}};
double [][] vcfs_test = {
{-virtual_camera_from_camera[0][0], -virtual_camera_from_camera[0][1], virtual_camera_from_camera[0][2]},
{ virtual_camera_from_camera[1][0], virtual_camera_from_camera[1][1], virtual_camera_from_camera[1][2]}};
{virtual_camera_from_camera[0][0], virtual_camera_from_camera[0][1], virtual_camera_from_camera[0][2]},
{ to_ground_xyzatr[1][0], to_ground_xyzatr[1][1], to_ground_xyzatr[1][2]}};
if ((dbg_title != null) || (gnd_disp != null)) {
// expand macrotiles results to match tiles
// rotate ref_disparity and show
/*
double [][] pXpYD_ground = OpticalFlow.transformToScenePxPyD(
null, // final Rectangle full_woi_in, // show larger than sensor WOI (or null) IN TILES
ref_disparity, // final double [] disparity_ref, // invalid tiles - NaN in disparity
vcfs_test, // virtual_camera_from_camera,// final double [][] scene_xyzatr, // camera center in world coordinates, camera orientation relative to world frame
ref_Clt); // final QuadCLT scene_QuadClt)
*/
double [][] fgnd_pXpYD = OpticalFlow.refDisparityFromGroundDisparity(
ref_disparity, // final double [] ground_disparity,
vcfs_test, // final double [][] ground_xyzatr,
ref_Clt); //final QuadCLT ref_scene)
double [][] pXpYD_ground = OpticalFlow.transformToScenePxPyD(
fgnd_pXpYD, // final double [][] reference_pXpYD,// invalid tiles - NaN in disparity. Should be no nulls, no NaN disparity
ground_xyzatr[0], // final double [] scene_xyz, // camera center in world (reference) coordinates
ground_xyzatr[1], // final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_Clt, // final QuadCLT reference_QuadClt) //
null); // final QuadCLT scene_QuadClt) //
/*
ref_pXpYD = OpticalFlow.transformToScenePxPyD(
fgnd_pXpYD, // final double [][] reference_pXpYD,// invalid tiles - NaN in disparity. Should be no nulls, no NaN disparity
ground_xyzatr[0], // final double [] scene_xyz, // camera center in world (reference) coordinates
ground_xyzatr[1], // final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene, // final QuadCLT reference_QuadClt) //
null); // final QuadCLT scene_QuadClt) //
*/
double [] gnd_disparity = (gnd_disp != null) ? gnd_disp.clone() : new double [ref_disparity.length];
Arrays.fill(gnd_disparity, Double.NaN);
for (int i = 0; i <ref_disparity.length; i++) {
......
......@@ -55,6 +55,7 @@ import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc;
import com.elphel.imagej.correction.SyncCommand;
import com.elphel.imagej.cuas.CorrectionFPN;
import com.elphel.imagej.cuas.Cuas;
import com.elphel.imagej.cuas.CuasCenterLma;
......@@ -172,11 +173,15 @@ public class OpticalFlow {
public double scale_no_lma_disparity = 1.0; // multiply strength were disparity_lma = NaN;
public long startTime; // start of batch processing
public SyncCommand sync_command = null;
public OpticalFlow (
SyncCommand sync_command,
int numSens,
double scale_no_lma_disparity,
int threadsMax, // maximal number of threads to launch
boolean updateStatus) {
this.sync_command = sync_command;
this.numSens = numSens;
// this.THREADS_MAX = threadsMax;
this.updateStatus = updateStatus;
......@@ -7505,53 +7510,6 @@ public class OpticalFlow {
if (clt_parameters.imp.fgnd_gen_tilted){
// No rotations orthogonal to ground, using tilted disparity
if (clt_parameters.imp.fgnd_gen_scan){
/*
for (double gnd_offset = clt_parameters.imp.fgnd_ct_low;
gnd_offset <= clt_parameters.imp.fgnd_ct_high;
gnd_offset+=clt_parameters.imp.fgnd_ct_step) {
String extra_suffix= "-GND";
if (gnd_offset >0) {
extra_suffix+="+";
}
extra_suffix+=String.format("%.3fm", gnd_offset);
GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
master_CLT, // final QuadCLT ref_Clt,
true, // final boolean tilted_plane,
gnd_offset, // final double offset,
test_bottom, // final double test_bottom,
debugLevel); // final int debugLevel)
combo_dsn_final =master_CLT.restoreComboDSI(true);
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
System.out.println ("No terrain data available");
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix_disp = master_CLT.getImageName()+"-TERRAIN-DISP"+extra_suffix;
ImagePlus imp_terrain_disp = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
false, // boolean um_mono,
null, // float [][] average_slice, // [channel][pixel]
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
false, // boolean toRGB,
null, // double [][] ground_xyzatr,
1, // int sensor_mask,
scenes_suffix_disp, // String suffix_in,
terrain_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // QuadCLT ref_scene, // int ref_index,
debugLevel); // int debugLevel) {
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_disp); // imp_scenes); // ImagePlus imp)
}
}
*/
ImagePlus imp_terrain_hyper_tilted = renderSceneSequenceHyper(
clt_parameters, // CLTParameters clt_parameters,
true, // boolean use_tilted_disparity, // tilted disparity: anisotropic distortions but full image fill
......@@ -7570,9 +7528,6 @@ public class OpticalFlow {
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_hyper_tilted); // imp_scenes); // ImagePlus imp)
}
} else {
GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
......@@ -7633,66 +7588,6 @@ public class OpticalFlow {
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_hyper); // imp_scenes); // ImagePlus imp)
}
/*
for (double gnd_offset = clt_parameters.imp.fgnd_ct_low;
gnd_offset <= clt_parameters.imp.fgnd_ct_high;
gnd_offset+=clt_parameters.imp.fgnd_ct_step) {
String extra_suffix= "-GND";
if (gnd_offset >0) {
extra_suffix+="+";
}
extra_suffix+=String.format("%.3fm", gnd_offset);
double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
master_CLT, // final QuadCLT ref_Clt,
false, // final boolean tilted_plane,
gnd_offset, // final double offset,
test_bottom, // final double test_bottom,
debugLevel); // final int debugLevel)
double [][] ignp = null;
if (gnp != null) {
ignp = ErsCorrection.invertXYZATR(gnp);
if (debugLevel > -3) {
System.out.println("Using airplane mode terrane as a single horizontal plane");
System.out.println("stereo_offset = ["+gnp[0][0]+", "+gnp[0][1]+", "+gnp[0][2]+"]");
System.out.println("stereo_atr = ["+gnp[1][0]+", "+gnp[1][1]+", "+gnp[1][2]+ "]");
// TODO add provisions to the non-flat terrain -modify terrain slice, keeping ground_normal_pose as a horizontal plane.
System.out.println("ignp[0] = ["+ignp[0][0]+", "+ignp[0][1]+", "+ignp[0][2]+"]");
System.out.println("ignp[1] = ["+ignp[1][0]+", "+ignp[1][1]+", "+ignp[1][2]+"]");
}
}
combo_dsn_final =master_CLT.restoreComboDSI(true);
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
System.out.println ("No terrain data available");
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix = master_CLT.getImageName()+"-TERRAIN"+extra_suffix; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
false, // boolean um_mono,
null, // float [][] average_slice, // [channel][pixel]
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
false, // boolean toRGB,
ignp, // double [][] ground_xyzatr,
1, // int sensor_mask,
scenes_suffix, // String suffix_in,
terrain_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // QuadCLT ref_scene, // int ref_index,
debugLevel); // int debugLevel) {
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain); // imp_scenes); // ImagePlus imp)
}
} // for (double gnd_offset
*/
} else { // if (clt_parameters.imp.fgnd_gen_scan){
double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
......@@ -9539,6 +9434,12 @@ public class OpticalFlow {
double [][] ref_pXpYD;
double [][] ref_pXpYD_or_null = null; // debugging cuas mode keeping old
if (ground_xyzatr != null) { // extract to method
// try replacement
double [][] fgnd_pXpYD =refDisparityFromGroundDisparity(
ref_disparity, // final double [] ground_disparity,
ground_xyzatr, // final double [][] ground_xyzatr,
ref_scene); // final QuadCLT ref_scene)
/*
final double [] ground_disparity = ref_disparity; // input
final int tilesX=ref_scene.getTilesX();
final int tilesY=ref_scene.getTilesY();
......@@ -9566,12 +9467,14 @@ public class OpticalFlow {
};
}
ImageDtt.startAndJoin(threads);
*/
ref_pXpYD = OpticalFlow.transformToScenePxPyD(
fgnd_pXpYD, // final double [][] reference_pXpYD,// invalid tiles - NaN in disparity. Should be no nulls, no NaN disparity
ground_xyzatr[0], // final double [] scene_xyz, // camera center in world (reference) coordinates
ground_xyzatr[1], // final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene, // final QuadCLT reference_QuadClt) //
null); // final QuadCLT scene_QuadClt) //
/*
double [] disp_dbg = new double[tiles];
Arrays.fill(disp_dbg, Double.NaN);
......@@ -9971,6 +9874,49 @@ public class OpticalFlow {
return imp_scenes;
}
public static double [][] refDisparityFromGroundDisparity(
final double [] ground_disparity,
final double [][] ground_xyzatr,
final QuadCLT ref_scene){
//final double [] ground_disparity = ref_disparity; // input
final int tilesX=ref_scene.getTilesX();
final int tilesY=ref_scene.getTilesY();
final int transform_size = ref_scene.getTileSize();
final int tiles = tilesX * tilesY;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final double [][] fgnd_pXpYD = new double [tiles][];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if (!Double.isNaN(ground_disparity[nTile])){
double disparity = ground_disparity[nTile];
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
double centerX = (tileX + 0.5) * transform_size; // - shiftX;
double centerY = (tileY + 0.5) * transform_size; // - shiftY;
if (disparity < 0) {
disparity = 1.0* disparity; // 0.0;
}
fgnd_pXpYD[nTile] = new double[] {centerX, centerY, disparity};
// fgnd_pXpYD[nTile] = new double[] {transform_size*tilesX-centerX, transform_size*tilesY-centerY, disparity};
}
}
};
}
ImageDtt.startAndJoin(threads);
return fgnd_pXpYD;
/*
double [][] ref_pXpYD = OpticalFlow.transformToScenePxPyD(
fgnd_pXpYD, // final double [][] reference_pXpYD,// invalid tiles - NaN in disparity. Should be no nulls, no NaN disparity
ground_xyzatr[0], // final double [] scene_xyz, // camera center in world (reference) coordinates
ground_xyzatr[1], // final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene, // final QuadCLT reference_QuadClt) //
null); // final QuadCLT scene_QuadClt) //
return ref_pXpYD;
*/
}
public static QuadCLT[] selectScenes(
QuadCLT[] quadCLTs,
......
......@@ -5437,6 +5437,8 @@ LogTee.clearSceneLog(); // stop per‑scene logging
} catch (IOException e) {
System.err.println("startLogging(): failed to start logging to "+x3d_path);
} // when you want to start per‑scene logging
System.out.println("\n***** STARTING LOGGING: "+
(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime())+" *****\n"));
}
public void stopLogging() {
......
......@@ -56,6 +56,7 @@ 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.CuasMultiSeries;
import com.elphel.imagej.gpu.ExportForGPUDevelopment;
import com.elphel.imagej.gpu.GPUTileProcessor;
......@@ -8016,6 +8017,7 @@ if (debugLevel > -100) return true; // temporarily !
}
public void TestInterScene(
SyncCommand sync_command,
QuadCLT quadCLT, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -8083,6 +8085,7 @@ if (debugLevel > -100) return true; // temporarily !
/// double k_prev = 0.75;
/// double corr_scale = 0.75;
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -8111,6 +8114,7 @@ if (debugLevel > -100) return true; // temporarily !
public void interPairsLMA(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -8167,6 +8171,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -8279,6 +8284,7 @@ if (debugLevel > -100) return true; // temporarily !
@Deprecated
public void TestInterLMA(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -8328,6 +8334,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -8345,6 +8352,7 @@ if (debugLevel > -100) return true; // temporarily !
@Deprecated
public void interSeriesLMA(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
int ref_index, // -1 - last
int ref_step,
......@@ -8393,6 +8401,7 @@ if (debugLevel > -100) return true; // temporarily !
for (int ri = ref_index; ri >= 0; ri -= ref_step) {
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -8432,6 +8441,7 @@ if (debugLevel > -100) return true; // temporarily !
* @throws Exception
*/
public static void buildSeriesTQ(
SyncCommand sync_command,
int cuas_proc_mode, // 0 - old, 1 combine scene series
QuadCLT quadCLT_main, // tiles should be set
int ref_index_unused, // -1 - last
......@@ -8468,6 +8478,7 @@ if (debugLevel > -100) return true; // temporarily !
}
long start_time_all = System.nanoTime();
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -8647,6 +8658,8 @@ if (debugLevel > -100) return true; // temporarily !
}
}
}
if (model_directory == null) {
if (initial_operation_mode == OpticalFlow.RESULTS_BUILD_SEQ_LY) {
System.out.println("\n ----- LY FIELD CALIBRATION SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+") IS FINISHED in "+
......@@ -8662,13 +8675,19 @@ if (debugLevel > -100) return true; // temporarily !
break;
}
ref_index = start_ref_pointers[0]; // continue from the same attached to the previous reference
// System.out.println("Continue from index "+ref_index);
// continue; // and go to the to next scene sequence from the list
}
boolean stop_now = sync_command.stopNow(false); // boolean convenient)
if ((model_directory == null) && !stop_now) {
System.out.println("Continue from index "+ref_index);
continue; // and go to the to next scene sequence from the list
}
initial_operation_mode = OpticalFlow.RESULTS_BUILD_SEQ_DEFAULT; // to prevent trying to get field_calibration for all but the first (latest in time) segment in a sequence
operation_mode = OpticalFlow.RESULTS_BUILD_SEQ_DEFAULT;
if ((start_ref_pointers[0]==0) && (start_ref_pointers[1]==0)) { // bail out for debug
if (stop_now || ((start_ref_pointers[0]==0) && (start_ref_pointers[1]==0))) { // bail out for debug
System.out.println("\n ----- PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+") ABORTED in "+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_seq),3)+" sec ("+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_all),3)+" sec from the overall start\n");
......@@ -8815,6 +8834,10 @@ if (debugLevel > -100) return true; // temporarily !
}
Files.createSymbolicLink(link.toPath(), pathRelative);
}
} // if ((map_gp != null) && !map_gp.isEmpty()) {
boolean stop_now = sync_command.stopNow(true); // boolean convenient)
if (stop_now) {
break; // will still generate videos
}
} // for (int nseq = 0; nseq < num_seq; nseq++) {
......@@ -8969,6 +8992,7 @@ if (debugLevel > -100) return true; // temporarily !
public void intersceneAccumulate(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -9012,6 +9036,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // int debugLevel)
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -9079,6 +9104,7 @@ if (debugLevel > -100) return true; // temporarily !
public void intersceneNoiseBatch(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -9397,6 +9423,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println ("\n\n\n");
if ((num_noise_variants <= 0) || ((noise_rnd == 0.0) && (noise_fpn == 0.0))) { // no need to generate multiple zero-noise
intersceneNoise(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
......@@ -9424,6 +9451,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println ("inter = "+inter);
System.out.println ("\n\n\n");
intersceneNoise(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
......@@ -9444,6 +9472,7 @@ if (debugLevel > -100) return true; // temporarily !
public void interIntraExportML(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
int ref_index, // = num_scenes - 1;
int ref_step,
......@@ -9498,6 +9527,7 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.inp.noise_debug_level); // debugLevel); // int debugLevel)
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -9558,6 +9588,7 @@ if (debugLevel > -100) return true; // temporarily !
public void intersceneNoise(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -9653,6 +9684,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
sync_command, // SyncCommand sync_command,
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
......@@ -12015,6 +12047,7 @@ if (debugLevel > -100) return true; // temporarily !
public void batchLwirRig(
SyncCommand sync_command,
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
CLTParameters clt_parameters,
......@@ -12746,7 +12779,9 @@ if (debugLevel > -100) return true; // temporarily !
int num_aux = (quadCLT_aux ==null)? 0 : quadCLT_aux.getTotalFiles(set_channels_aux);
// Process LWIR16 tasks applicable to scene series rather than individual scenes
if (quadCLT_main.correctionsParameters.clt_batch_pose_pairs_main) {
TestInterLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
TestInterLMA(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
......@@ -12762,7 +12797,9 @@ if (debugLevel > -100) return true; // temporarily !
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_last_main) {
interSeriesLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
interSeriesLMA(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12782,7 +12819,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_main) {
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_main -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_main;
interSeriesLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
interSeriesLMA(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12801,7 +12840,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_main) {
interIntraExportML(quadCLT_main, // QuadCLT quadCLT_main,
interIntraExportML(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12819,7 +12860,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_ml_all_main) {
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_main -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_main;
interIntraExportML(quadCLT_main, // QuadCLT quadCLT_main,
interIntraExportML(
sync_command, // SyncCommand sync_command,
quadCLT_main, // QuadCLT quadCLT_main,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12836,7 +12879,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_pose_pairs_aux) {
TestInterLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
TestInterLMA(
sync_command, // SyncCommand sync_command,
quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
colorProcParameters_aux, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
......@@ -12852,7 +12897,9 @@ if (debugLevel > -100) return true; // temporarily !
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_last_aux) {
interSeriesLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
interSeriesLMA(
sync_command, // SyncCommand sync_command,
quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12872,7 +12919,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_aux) {
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_aux -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_aux;
interSeriesLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
interSeriesLMA(
sync_command, // SyncCommand sync_command,
quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12890,7 +12939,9 @@ if (debugLevel > -100) return true; // temporarily !
}
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_aux) {
interIntraExportML(quadCLT_aux, // QuadCLT quadCLT_main,
interIntraExportML(
sync_command, // SyncCommand sync_command,
quadCLT_aux, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......@@ -12907,7 +12958,9 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_ml_all_aux) {
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_aux -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_aux;
interIntraExportML(quadCLT_aux, // QuadCLT quadCLT_main,
interIntraExportML(
sync_command, // SyncCommand sync_command,
quadCLT_aux, // QuadCLT quadCLT_main,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......
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