Commit 196c2875 authored by Andrey Filippov's avatar Andrey Filippov

Adding UAS logs processing

parent 90e3e80a
......@@ -46,6 +46,7 @@ import com.elphel.imagej.calibration.DirectoryChoser;
import com.elphel.imagej.calibration.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.tileprocessor.IntersceneMatchParameters;
import ij.IJ;
import ij.Prefs;
......@@ -62,7 +63,8 @@ public class EyesisCorrectionParameters {
"videoDirectory", // 4
"x3dDirectory", // 5
"resultsDirectory", // 6
"cuasSeed"}; // 7
"cuasSeed", // 7
"uasLogs"}; // 8
public static final String AUX_PREFIX = "AUX-";
public boolean swapSubchannels01= true; // false; // (false: 0-1-2, true - 1-0-2)
public boolean split= true;
......@@ -111,8 +113,9 @@ public class EyesisCorrectionParameters {
public boolean useSourceList= false;
public String cuasSeedDir= "";
public boolean useCuasSeedDir= false;
public String cuasUasLogs = ""; // json file path containing UAS logs
public double cuasUasTimeStamp = 0.0; // timestamp corresponding to the UAS time 0.0
public double [] cuasCameraATR = {0, 0, 0};
// public String sourceImsDirectory= ""; // source IMS log files
public String imsRootDirectory= ""; // source IMS log files
......@@ -300,6 +303,10 @@ public class EyesisCorrectionParameters {
cp.cuasSeedDir= this.cuasSeedDir;
cp.useCuasSeedDir= this.useCuasSeedDir;
cp.cuasUasLogs = this.cuasUasLogs;
cp.cuasUasTimeStamp = this.cuasUasTimeStamp;
cp.cuasCameraATR = this.cuasCameraATR.clone();
/// cp.sourceImsDirectory= this.sourceImsDirectory;
cp.imsRootDirectory = this.imsRootDirectory;
......@@ -504,6 +511,8 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"cuasSeedDir", this.cuasSeedDir);
properties.setProperty(prefix+"useCuasSeedDir", this.useCuasSeedDir+"");
properties.setProperty(prefix+"cuasUasTimeStamp", this.cuasUasTimeStamp+"");
properties.setProperty(prefix+"cuasCameraATR", IntersceneMatchParameters.doublesToString(this.cuasCameraATR));
/// properties.setProperty(prefix+"sourceImsDirectory",this.sourceImsDirectory);
......@@ -707,8 +716,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"cuasSeedDir")!= null) this.cuasSeedDir=properties.getProperty(prefix+"cuasSeedDir");
if (properties.getProperty(prefix+"useCuasSeedDir")!=null) this.useCuasSeedDir=Boolean.parseBoolean(properties.getProperty(prefix+"useCuasSeedDir")); // save 32-bit tiff also if the end result is 8 or 16 bit
if (properties.getProperty(prefix+"cuasUasLogs")!= null) this.cuasUasLogs=properties.getProperty(prefix+"cuasUasLogs");
if (properties.getProperty(prefix+"cuasUasTimeStamp")!=null)this.cuasUasTimeStamp=Double.parseDouble(properties.getProperty(prefix+"cuasUasTimeStamp")); // save 32-bit tiff also if the end result is 8 or 16 bit
if (properties.getProperty(prefix+"cuasCameraATR")!=null) this.cuasCameraATR= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"cuasCameraATR"),this.cuasCameraATR);
/// if (properties.getProperty(prefix+"sourceImsDirectory")!= null) this.sourceImsDirectory=properties.getProperty(prefix+"sourceImsDirectory");
if (properties.getProperty(prefix+"imsRootDirectory")!= null) this.imsRootDirectory =properties.getProperty(prefix+"imsRootDirectory");
if (properties.getProperty(prefix+"imsDataSubdirectory")!= null) this.imsDataSubdirectory =properties.getProperty(prefix+"imsDataSubdirectory");
......@@ -941,6 +951,11 @@ public class EyesisCorrectionParameters {
gd.addStringField ("CUAS seed directory", this.cuasSeedDir, 80);
gd.addCheckbox ("Use CUAS seed", this.useCuasSeedDir);
gd.addStringField ("UAS log file", this.cuasUasLogs, 80);
gd.addNumericField("UAS log start timestamp", this.cuasUasTimeStamp, 0);
gd.addStringField ("Camera ATR in world coordinates", IntersceneMatchParameters.doublesToString(this.cuasCameraATR), 80);
gd.addStringField ("Sensor calibration directory", this.sensorDirectory, 80);
gd.addCheckbox ("Select sensor calibration directory", false);
......@@ -1093,6 +1108,9 @@ public class EyesisCorrectionParameters {
this.sourceSequencesList= gd.getNextString(); if (gd.getNextBoolean()) selectSourceSequencesList(false, false);
this.useSourceList = gd.getNextBoolean();
this.cuasSeedDir= gd.getNextString();
this.cuasUasLogs = gd.getNextString();
this.cuasUasTimeStamp = gd.getNextNumber();
this.cuasCameraATR = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), cuasCameraATR);
this.sensorDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSensorDirectory(false, false);
this.sharpKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSharpKernelDirectory(false, false);
this.smoothKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSmoothKernelDirectory(false, true);
......@@ -1183,7 +1201,11 @@ public class EyesisCorrectionParameters {
gd.addStringField ("CUAS seed directory", this.cuasSeedDir, 80);
gd.addCheckbox ("Use CUAS seed", this.useCuasSeedDir);
gd.addStringField ("UAS log file", this.cuasUasLogs, 80);
gd.addNumericField("UAS log start timestamp", this.cuasUasTimeStamp, 0);
gd.addStringField ("Camera ATR in world coordinates", IntersceneMatchParameters.doublesToString(this.cuasCameraATR), 80);
gd.addStringField ("x3d model version", this.x3dModelVersion, 80); // 10a
gd.addStringField ("jp4 source copy subdirectory", this.jp4SubDir, 80); // 10b
......@@ -1372,6 +1394,11 @@ public class EyesisCorrectionParameters {
this.cuasSeedDir= gd.getNextString();
this.useCuasSeedDir = gd.getNextBoolean();
this.cuasUasLogs = gd.getNextString();
this.cuasUasTimeStamp = gd.getNextNumber();
this.cuasCameraATR = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), cuasCameraATR);
this.x3dModelVersion= gd.getNextString(); // 10a
this.jp4SubDir= gd.getNextString(); // 10b
this.linkedModels= gd.getNextString(); if (gd.getNextBoolean()) selectLinkedModelsDirectory(false, true);
......@@ -1661,7 +1688,9 @@ public class EyesisCorrectionParameters {
System.out.println("First line: "+lines.get(0)+"\n");
Path base_path = seq_path.getParent();
// first - scan all file and set sourceDirectory, x3dDirectory, linkedModels,videoDirectory,resultsDirectory
HashMap<String,String> dir_map = new HashMap<String,String>();
HashMap<String,String> dir_map = new HashMap<String,String>();
HashMap<String,ArrayList<String>> extra_map = new HashMap<String,ArrayList<String>>();
for (String line:lines){
if (line.split("#").length > 0) {
String[] tokens = line.split("#")[0].trim().split("[\\s,;=]+");
......@@ -1674,6 +1703,13 @@ public class EyesisCorrectionParameters {
for (String dir_name:KEY_DIRS) if (dir_name.equals(tokens[1])) {
dir_map.put(dir_name,tokens[2]);
System.out.println("Parsed SET: "+tokens[1]+" in line: "+line);
if (tokens.length > 3) {
ArrayList<String> extras = new ArrayList<String>();
for (int i= 3; i < tokens.length; i++) {
extras.add(tokens[i]);
}
extra_map.put(dir_name, extras);
}
break parse_set;
}
System.out.println("*********** Unknown SET: "+tokens[1]+" in line: "+line);
......@@ -1717,8 +1753,10 @@ public class EyesisCorrectionParameters {
if (dir_map.get(KEY_DIRS[i]).length() > 0){
Path dir_path=base_path.resolve(Paths.get(dir_map.get(KEY_DIRS[i])));
File dir_file = new File(dir_path.toString());
if (!dir_file.exists()) {
dir_file.mkdirs();
if (i != 8) { // cuasUasLogs is a file, not directory
if (!dir_file.exists()) {
dir_file.mkdirs();
}
}
dir_string = dir_path.toString();
}
......@@ -1748,6 +1786,23 @@ public class EyesisCorrectionParameters {
System.out.println("this.cuasSeedDir=" + this.cuasSeedDir);
useCuasSeedDir = true;
break;
case 8: // cuasSeed
this.cuasUasLogs = dir_string; // dir_path.toString();
System.out.println("this.cuasUasLogs=" + this.cuasUasLogs);
ArrayList<String> uas_pars = extra_map.get("uasLogs");
if (uas_pars != null) {
for (int n = 0; n < uas_pars.size(); n++) {
double d = Double.parseDouble(uas_pars.get(n));
switch (n) {
case 0: cuasUasTimeStamp = d; break;
case 1:
case 2:
case 3:
cuasCameraATR[n-1] = d;
}
}
}
break;
}
}
}
......@@ -2390,7 +2445,22 @@ public class EyesisCorrectionParameters {
return this.cuasSeedDir + Prefs.getFileSeparator();
}
public String getUasLogsPath() {
if (this.cuasUasLogs == null) { // Keep it?
return null;
}
if (this.cuasUasLogs.length() == 0) {
return "";
}
if (!this.cuasUasLogs.endsWith(".json")) {
this.cuasUasLogs = this.cuasUasLogs+".json";
}
return this.cuasUasLogs;
}
public double getUasLogsTimeStamp() {
return this.cuasUasTimeStamp;
}
public String selectSourceSequencesList(boolean smart, boolean newAllowed) { // normally newAllowed=false
......
......@@ -6321,8 +6321,61 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
if (gd.wasCanceled())
return false;
uas_path = gd.getNextString();
{
setAllProperties(PROPERTIES); // batchRig may save properties with the model. Extrinsics will be updated,
if (GPU_TILE_PROCESSOR == null) {
try {
GPU_TILE_PROCESSOR = new GPUTileProcessor(CORRECTION_PARAMETERS.tile_processor_gpu);
} catch (Exception e) {
System.out.println("Failed to initialize GPU class");
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} // final int debugLevel);
}
EYESIS_CORRECTIONS_AUX.initSensorFiles(DEBUG_LEVEL);
if (!QUAD_CLT_AUX.CLTKernelsAvailable()) {
if (DEBUG_LEVEL > 0) {
System.out.println("Reading AUX CLT kernels");
}
QUAD_CLT_AUX.readCLTKernels(CLT_PARAMETERS, THREADS_MAX, UPDATE_STATUS, // update status info
DEBUG_LEVEL);
if (DEBUG_LEVEL > 1) {
QUAD_CLT_AUX.showCLTKernels(THREADS_MAX, UPDATE_STATUS, // update status info
DEBUG_LEVEL);
}
}
if (!QUAD_CLT_AUX.geometryCorrectionAvailable()) {
if (DEBUG_LEVEL > 0) {
System.out.println("Calculating geometryCorrection");
}
if (!QUAD_CLT_AUX.initGeometryCorrection(DEBUG_LEVEL + 2)) {
return false;
}
}
if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is
// needed
try {
GPU_QUAD_AUX = new GpuQuad(//
GPU_TILE_PROCESSOR, QUAD_CLT_AUX, CLT_PARAMETERS.gpu_debug_level);
} catch (Exception e) {
System.out.println("Failed to initialize GpuQuad class");
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} // final int debugLevel);
QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
}
}
try {
UasLogReader uasLogReader = new UasLogReader(uas_path);
// UasLogReader uasLogReader = new UasLogReader(uas_path);
UasLogReader.testUasLogReader(uas_path,QUAD_CLT_AUX);
} catch (JSONException e) {
System.out.println("Error reading/parsing "+uas_path);
System.out.println();
......
......@@ -21,6 +21,7 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.gpu.TpTask;
import com.elphel.imagej.ims.UasLogReader;
import com.elphel.imagej.tileprocessor.Correlation2d;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.IntersceneMatchParameters;
......@@ -78,7 +79,7 @@ public class CuasMotion {
{"Circle21x21.png", "Circle43x43_2px.png"}, // friend
{"diamond21x17.png", "diamond43x35_2px.png"} // foe
};
public static String ICON_BLUE = "Circle63x63blue.png";
private final GPUTileProcessor gpuTileProcessor;
private CLTParameters clt_parameters=null;
......@@ -765,6 +766,7 @@ public class CuasMotion {
vf_sequence, // final double [][][] vf_sequence, // center tiles (not extended), null /non-null only
// frame0, // final int frame0, // for vector_field[0] // source scene corresponding to the first sequence
cuasMotion, // final CuasMotion cuasMotion,
null, // UasLogReader uasLogReader,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
slice_titles, // String [] slice_titles,
debugLevel); // final int debugLevel)
......@@ -776,9 +778,9 @@ public class CuasMotion {
batch_mode, // final boolean batch_mode,
parentCLT, // QuadCLT parentCLT, //
fpixels, // final float [][] fpixels,
null, // String [] scene_titles, // recreate slice_titles from scene titles?
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
debugLevel); // final int debugLevel)
continue;
} // while (true) {
......@@ -3099,10 +3101,25 @@ public class CuasMotion {
final int frame0,
final int frame_step,
final int width_src,
String title,
String [] titles,
final String title,
final String [] titles,
String diamond_path,
final UasLogReader uasLogReader,
final int debugLevel) {
String uas_log_path = null;
boolean annotate_uas = clt_parameters.imp.cuas_annotate_uas && (uasLogReader != null);
if (annotate_uas) {
String resource_name = ICON_BLUE;
URL resourceUrl = CuasMotion.class.getClassLoader().getResource("graphics/"+resource_name);
Path resourcePath = null;
try {
resourcePath = Paths.get(resourceUrl.toURI());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uas_log_path = resourcePath.toString();
}
if (diamond_path == null) {
String resource_name = TARGET_ICONS[target_type][scale2x? 1 : 0];
URL resourceUrl = CuasMotion.class.getClassLoader().getResource("graphics/"+resource_name);
......@@ -3137,10 +3154,9 @@ public class CuasMotion {
// TODO Auto-generated catch block
e1.printStackTrace();
}
final int diamond_width = diamond_cp.getWidth();
final int diamond_height = diamond_cp.getHeight();
final int [] diamond_pixels = ((int []) diamond_cp.getPixels());
final int [][] diamond_rgba = new int [diamond_pixels.length][4];
......@@ -3150,6 +3166,28 @@ public class CuasMotion {
}
}
ColorProcessor uaslog_cp = null;
if (uas_log_path != null) {
try {
uaslog_cp = new ColorProcessor(ImageIO.read(new File(diamond_path)));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
final int uaslog_width = (uaslog_cp != null) ? uaslog_cp.getWidth() : 0;
final int uaslog_height = (uaslog_cp != null) ? uaslog_cp.getHeight() : 0;
final int [] uaslog_pixels = (uaslog_cp != null) ? ((int []) uaslog_cp.getPixels()) : null;
final int [][] uaslog_rgba = (uaslog_cp != null) ? (new int [uaslog_pixels.length][4]) : null;
if (uaslog_cp != null) {
for (int i = 0; i < uaslog_rgba.length; i++) {
for (int s = 0; s <4; s++) {
uaslog_rgba[i][s] = (uaslog_pixels[i] >> (8 * s)) & 0xff;
}
}
}
final int num_scenes = fpixels.length;
final int num_pixels = fpixels[0].length;
final int num_seq = targets60hz.length;
......@@ -3270,6 +3308,45 @@ public class CuasMotion {
for (int dscene = half_step0; dscene < half_step1; dscene ++) {
int nscene = frame_center + dscene;
if ((nscene >=0) && (nscene < num_scenes)) {
if (uaslog_rgba != null) { // draw uas from log
// get drone pixel coordinates
double [] uas_pXpYD = uasLogReader.getUasPxPyD(titles[nscene]);
int xc = (int) Math.round(scale * uas_pXpYD[0]);
int yc = (int) Math.round(scale * uas_pXpYD[1]);
int xl = xc - uaslog_width/2;
int yt = yc - uaslog_height/2;
for (int y = 0; y < uaslog_height; y++) {
int py = yt + y;
if ((py >= 0) && (py < height)) {
for (int x = 0; x< uaslog_width; x++) {
int px = xl +x;
int dpix = x + y * uaslog_width;
int ipix = px + py*width;
if ((px >=0) && (px < width)) {
int alpha = uaslog_rgba[dpix][3];
if (alpha > 0) { // alpha
int dp = uaslog_pixels[x + y * uaslog_width];
if (alpha == 255) {
ipixels[nscene][ipix] = dp;
} else {
double k = alpha/255.0;
int img_pix = ipixels[nscene][ipix];
int new_pix = 0xff000000;
for (int c = 0; c < 3; c++) {
int rgb = (img_pix >> (8 * c)) & 0xff;
rgb = (int) Math.round((1-k)*rgb + k* uaslog_rgba[dpix][c]);
if (rgb > 255) rgb = 255;
new_pix |= (rgb << (8*c));
}
ipixels[nscene][ipix] = new_pix;
}
}
}
}
}
}
}
double [][] targets = targets60hz[nscene];
if (targets != null) { // TODO: find why
for (int ntarget = 0; ntarget < targets.length; ntarget++) {
......@@ -3496,6 +3573,7 @@ public class CuasMotion {
final boolean batch_mode,
QuadCLT parentCLT, //
final float [][] fpixels,
UasLogReader uasLogReader,
String [] scene_titles, // recreate slice_titles from scene titles?
final int debugLevel) {
......@@ -3549,6 +3627,7 @@ public class CuasMotion {
targets_nonconflict, // final double [][][] vf_sequence, // center tiles (not extended), null /non-null only
// frame0, // final int frame0, // for vector_field[0] // source scene corresponding to the first sequence
cuasMotion, // final CuasMotion cuasMotion,
uasLogReader, // UasLogReader uasLogReader,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
slice_titles, // String [] slice_titles,
debugLevel); // final int debugLevel)
......@@ -4511,7 +4590,8 @@ public class CuasMotion {
QuadCLT parentCLT, //
final float [][] fpixels,
double [][][] target_sequence, //
final CuasMotion cuasMotion,
CuasMotion cuasMotion,
UasLogReader uasLogReader,
String [] scene_titles, // recreate slice_titles from scene titles?
String [] slice_titles,
final int debugLevel) {
......@@ -4747,6 +4827,7 @@ public class CuasMotion {
model_prefix+"-RGB"+ra_bg_suffix, // String title,
scene_titles, // String [] titles,
null, // diamond_path, // //String diamond_path, null - use resources
uasLogReader, // UasLogReader uasLogReader,
debugLevel); // final int debugLevel) {
// save tiff in model directory
if (imp_color != null) {
......
......@@ -3,6 +3,9 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.elphel.imagej.tileprocessor.ErsCorrection;
import com.elphel.imagej.tileprocessor.QuadCLT;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
......@@ -11,92 +14,312 @@ import java.nio.file.Files;
//import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
public class UasLogReader {
public UasLogReader(String filePath) throws JSONException {
String [] filed_to_print = {
"timestamp",
"distanceFromHome",
"gps_lat",
"gps_lon",
"gps_altitude",
"homeLatitude",
"homeLongitude"};
StringBuffer sb = new StringBuffer();
sb.append(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime())+"\n");
try {
String jsonString = new String(Files.readAllBytes(Paths.get(filePath)));
JSONObject logData = new JSONObject(jsonString);
/*
647.8000000000103,
40.36068344116211,
-112.02062225341797,
*
String fancy_data = logData.toString(4);
try {
Path path = Paths.get(filePath+".txt");
Files.write(path, fancy_data.getBytes(StandardCharsets.UTF_8));
System.out.println("String successfully written to file: " + path);
} catch (IOException e) {
System.err.println("An error occurred while writing to the file: " + e.getMessage());
}
*/
JSONArray flight_logging_items = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_items");
JSONArray flight_logging_keys = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_keys");
// String [] log_keys = new String [flight_logging_keys.length()];
HashMap<String, Integer> log_indices = new HashMap<String, Integer>();
for (int i = 0; i < flight_logging_keys.length(); i++) {
log_indices.put(flight_logging_keys.getString(i), i);
}
int [] indices = new int[filed_to_print.length];
for (int i = 0; i < filed_to_print.length; i++) {
indices[i] = log_indices.get(filed_to_print[i]);
}
sb.append("index\t");
for (int i = 0; i < filed_to_print.length; i++) {
sb.append(filed_to_print[i]);
sb.append((i < (filed_to_print.length - 1))?"\t":"\n");
}
for (int indx = 0; indx < flight_logging_items.length(); indx++) {
sb.append(indx+"\t");
JSONArray log_line =flight_logging_items.getJSONArray(indx);
for (int i = 0; i < filed_to_print.length; i++) {
sb.append(log_line.get(indices[i]));
sb.append((i < (filed_to_print.length - 1))?"\t":"\n");
}
}
// System.out.println("flight_logging_keys.length()="+flight_logging_keys.length());
// JSONObject logData_exchange = (JSONObject) logData.getJSONObject("exchange");
// Accessing data
// String droneId = logData.getString("droneId");
/*
double latitude = logData.getJSONObject("location").getDouble("latitude");
double longitude = logData.getJSONObject("location").getDouble("longitude");
// System.out.println("Drone ID: " + droneId);
System.out.println("Latitude: " + latitude);
System.out.println("Longitude: " + longitude);
// just for testing
public static double [] CAMERA_LLA = {40.36068739259896, -112.02054681495696, 1507.4378478095987};
UasLogRecord[] rec_arr;
double start_timestamp;
double uas_home_alt = 0; // relative to the camera
double [] camera_lla = CAMERA_LLA.clone();
double [] camera_ATR = new double[3];
QuadCLT parentCLT = null; // for geometic parameters
public void setCameraLLA(double [] camera_lla){
if (camera_lla != null) {
this.camera_lla = camera_lla.clone();
}
}
public void setCameraATR(double [] atr) {
if (atr != null) {
this.camera_ATR = atr.clone();
}
}
public double [] getCameraATR() {
return this.camera_ATR;
}
public double getStartTimestamp() {
return start_timestamp;
}
public void setStartTimestamp(double timestamp) {
this.start_timestamp = timestamp;
}
public UasLogReader(
String filePath,
double timestamp,
double [] camera_lla,
QuadCLT parentCLT) throws JSONException {
this.parentCLT = parentCLT;
setCameraLLA(camera_lla);
setStartTimestamp(timestamp);
// StringBuffer sb = new StringBuffer();
// sb.append(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime())+"\n");
// UasLogRecord[] rec_arr = null;
JSONObject logData = null;
JSONArray flight_logging_items = null;
JSONArray flight_logging_keys = null;
HashMap<String, Integer> log_indices = null;
try {
String jsonString = new String(Files.readAllBytes(Paths.get(filePath)));
logData = new JSONObject(jsonString);
flight_logging_items = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_items");
flight_logging_keys = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_keys");
log_indices = new HashMap<String, Integer>();
} catch (IOException e) {
System.err.println("Error reading file: " + e.getMessage());
}
if (log_indices == null) {
return;
}
for (int i = 0; i < flight_logging_keys.length(); i++) {
log_indices.put(flight_logging_keys.getString(i), i);
}
int [] indices = new int[UasLogRecord.FIELDS_USED.length];
for (int i = 0; i < UasLogRecord.FIELDS_USED.length; i++) {
indices[i] = log_indices.get(UasLogRecord.FIELDS_USED[i]);
}
ArrayList<UasLogRecord> uas_log_list = new ArrayList<UasLogRecord>();
double[] rec = new double [indices.length];
for (int indx = 0; indx < flight_logging_items.length(); indx++) {
JSONArray log_line =flight_logging_items.getJSONArray(indx);
for (int i = 0; i < UasLogRecord.FIELDS_USED.length; i++) {
Object obj = log_line.get(indices[i]);
if ((obj instanceof Integer) && (((Integer) obj) == -1)) {
rec[i] = Double.NaN;
} else {
rec[i] = Double.parseDouble(log_line.get(indices[i]).toString());
}
}
try {
uas_log_list.add(new UasLogRecord(rec));
} catch (IllegalArgumentException e) {
System.err.println("Skipping undefined timestamp");
}
}
rec_arr = UasLogRecord.getArray(
uas_log_list); // ArrayList<UasLogRecord> rec_list)
UasLogRecord.fillUndefined(rec_arr);
System.out.println(rec_arr.length+" items");
return;
}
public UasLogRecord interpolate(double timestamp) { // relative
return UasLogRecord.interpolate(
this.rec_arr,
timestamp-start_timestamp);
}
public double [] getNED(double timestamp) {
UasLogRecord uas_loc = interpolate(timestamp);
double [] camera_lla0 = {camera_lla[0], camera_lla[1], -uas_home_alt};
double [] uas_lla = {uas_loc.gps_lat, uas_loc.gps_long, uas_loc.gps_alt};
return Imx5.nedFromLla (
uas_lla, // double [] lla,
camera_lla0); // double [] lla_ref)
}
/*
>>> NED = [-1757.6742631032464, -581.1933833090495, -60.759999999999785]
>>> az=math.atan2(NED[1],NED[0])
>>> az
-2.822249609529323
>>> 180/math.pi*az
-161.70299135847475
*/
public static double degToRad(double a) {
return a/180.0*Math.PI;
}
public static double radToDeg(double a) {
return a*180.0/Math.PI;
}
public void testOrient(double [] camera_atr, double ts, QuadCLT parentCLT) {
setCameraATR(camera_atr);
double [] ned = getNED(ts);
System.out.println(String.format("north = %f, east = %f, down = %f @ time = %f s", ned[0], ned[1], ned[2],ts));
double [] wxyz = {-ned[1], -ned[2], -ned[0]}; // right - positive X, up -positive Y, away - negative Z
double uas_az = Math.atan2(wxyz[0], -wxyz[2]);
double uas_tl = Math.atan2(wxyz[1], -wxyz[2]);
System.out.println(String.format("uas world az = %fdeg, tl = %fdeg)", radToDeg(uas_az),radToDeg(uas_tl)));
System.out.println(String.format("world x = %f, y = %f, z = %f)", wxyz[0], wxyz[1], wxyz[2]));
double [] atr = getCameraATR();
double [] iatr = ErsCorrection.invertXYZATR(
new double[3], //double [] source_xyz,
atr)[1]; // double [] source_atr)[1];
double [] camera_xyz0 = ErsCorrection.applyXYZATR(
new double [3], // double [] reference_xyz,
atr, // double [] reference_atr,
wxyz); // double [] scene_xyz)
/*
double [] camera_xyz1 = ErsCorrection.applyXYZATR(
wxyz, // double [] reference_xyz,
atr, // double [] reference_atr,
new double [3]); // double [] scene_xyz)
double [] camera_xyz2 = ErsCorrection.applyXYZATR(
new double [3], // double [] reference_xyz,
iatr, // double [] reference_atr,
wxyz); // double [] scene_xyz)
double [] camera_xyz3 = ErsCorrection.applyXYZATR(
wxyz, // double [] reference_xyz,
iatr, // double [] reference_atr,
new double [3]); // double [] scene_xyz)
*/
} catch (IOException e) {
System.err.println("Error reading file: " + e.getMessage());
}
System.out.println(String.format("camera0 x = %f, y = %f, z = %f)", camera_xyz0[0], camera_xyz0[1], camera_xyz0[2]));
/*
System.out.println(String.format("camera1 x = %f, y = %f, z = %f)", camera_xyz1[0], camera_xyz1[1], camera_xyz1[2]));
System.out.println(String.format("camera2 x = %f, y = %f, z = %f)", camera_xyz2[0], camera_xyz2[1], camera_xyz2[2]));
System.out.println(String.format("camera3 x = %f, y = %f, z = %f)", camera_xyz3[0], camera_xyz3[1], camera_xyz3[2]));
*/
double [] wxyz4 = {wxyz[0],wxyz[1],wxyz[2], 1.0}; // 0.0 for infinity
boolean correctDistortions = true;
ErsCorrection ec = parentCLT.getErsCorrection();
double [] pXpYD = ec.getImageCoordinatesERS(
wxyz4, // double [] xyzw,
correctDistortions, // boolean correctDistortions, // correct distortion (will need corrected background too !)
new double[3], // double [] camera_xyz, // camera center in world coordinates
atr); // double [] camera_atr); // camera orientation relative to world frame
System.out.println(String.format("pXpYD= [%f, %f,%f]", pXpYD[0], pXpYD[1], pXpYD[2]));
return;
}
public double [] getUasPxPyD (
String stimestamp) {
double timestamp = Double.parseDouble(stimestamp.replace("_", "."));
return getUasPxPyD(timestamp);
}
public double [] getUasPxPyD (
double timestamp) {
if (parentCLT == null) {
return null;
}
double [] ned = getNED(timestamp);
double [] wxyz4 = {-ned[1], -ned[2], -ned[0], 1.0}; // 0.0 for infinity
double [] atr = getCameraATR();
boolean correctDistortions = true;
ErsCorrection ec = parentCLT.getErsCorrection();
double [] pXpYD = ec.getImageCoordinatesERS(
wxyz4, // double [] xyzw,
correctDistortions, // boolean correctDistortions, // correct distortion (will need corrected background too !)
new double[3], // double [] camera_xyz, // camera center in world coordinates
atr); // double [] camera_atr); // camera orientation relative to world frame
return pXpYD;
}
public static void testUasLogReader(
String filePath,
QuadCLT parentCLT
) throws JSONException {
// just for now
UasLogReader uasLogReader = new UasLogReader(filePath, 0, null, parentCLT);
double [] camera_atr = {degToRad(-161),degToRad(16),0};
double ts = 135.0;
uasLogReader.testOrient(camera_atr,ts, parentCLT);
/*
String [] field_to_print = {
"timestamp",
"distanceFromHome",
"gps_lat",
"gps_lon",
"gps_altitude",
"homeLatitude",
"homeLongitude"};
*/
StringBuffer sb = new StringBuffer();
sb.append(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime())+"\n");
try {
String jsonString = new String(Files.readAllBytes(Paths.get(filePath)));
JSONObject logData = new JSONObject(jsonString);
/*
647.8000000000103,
40.36068344116211,
-112.02062225341797,
*
String fancy_data = logData.toString(4);
try {
Path path = Paths.get(filePath+".txt");
Files.write(path, fancy_data.getBytes(StandardCharsets.UTF_8));
System.out.println("String successfully written to file: " + path);
} catch (IOException e) {
System.err.println("An error occurred while writing to the file: " + e.getMessage());
}
*/
JSONArray flight_logging_items = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_items");
JSONArray flight_logging_keys = logData.getJSONObject("exchange").getJSONObject("message").getJSONObject("flight_logging").getJSONArray("flight_logging_keys");
// String [] log_keys = new String [flight_logging_keys.length()];
HashMap<String, Integer> log_indices = new HashMap<String, Integer>();
for (int i = 0; i < flight_logging_keys.length(); i++) {
log_indices.put(flight_logging_keys.getString(i), i);
}
int [] indices = new int[UasLogRecord.FIELDS_USED.length];
for (int i = 0; i < UasLogRecord.FIELDS_USED.length; i++) {
indices[i] = log_indices.get(UasLogRecord.FIELDS_USED[i]);
}
sb.append("index\t");
for (int i = 0; i < UasLogRecord.FIELDS_USED.length; i++) {
sb.append(UasLogRecord.FIELDS_USED[i]);
sb.append((i < (UasLogRecord.FIELDS_USED.length - 1))?"\t":"\n");
}
for (int indx = 0; indx < flight_logging_items.length(); indx++) {
sb.append(indx+"\t");
JSONArray log_line =flight_logging_items.getJSONArray(indx);
for (int i = 0; i < UasLogRecord.FIELDS_USED.length; i++) {
sb.append(log_line.get(indices[i]));
sb.append((i < (UasLogRecord.FIELDS_USED.length - 1))?"\t":"\n");
}
}
} catch (IOException e) {
System.err.println("Error reading file: " + e.getMessage());
}
try {
BufferedWriter out = new BufferedWriter(
new FileWriter(filePath+".csv", true));
out.write(sb.toString());
out.close();
// return; // true;
} catch (IOException e) {
// Display message when exception occurs
System.out.println("exception occurred" + e);
return; // false;
}
return;
/*
} catch (IOException e) {
// Display message when exception occurs
System.out.println("exception occurred" + e);
return; // false;
}
return;
/*
"flight_logging_keys": [
"timestamp",
"gps_lat",
......@@ -171,7 +394,10 @@ public class UasLogReader {
"imagePath"
],
*/
*/
}
}
package com.elphel.imagej.ims;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
public class UasLogRecord {
public static String [] FIELDS_USED = {
"timestamp",
"distanceFromHome",
"gps_lat",
"gps_lon",
"gps_altitude",
"homeLatitude",
"homeLongitude"};
public double timestamp; // should be first in array
public double distance;
public double gps_lat;
public double gps_long;
public double gps_alt; // relative to home
public double home_lat;
public double home_long;
public UasLogRecord(
double [] data) {
setData(data);
}
public void setData (
double [] data) throws IllegalArgumentException{
int n = 0;
this.timestamp = data[n++];
this.distance = data[n++];
this.gps_lat = data[n++];
this.gps_long = data[n++];
this.gps_alt = data[n++]; // relative to home
this.home_lat = data[n++];
this.home_long = data[n++];
if (Double.isNaN(this.timestamp)) {
throw new IllegalArgumentException ("UasLogRecord).timestamp has to be defined");
}
}
public void copyOverNaN(double [] data) {
double [] arr = toArray();
copyOverNaN(arr, data);
for (int i = 0; i < arr.length; i++) {
if (Double.isNaN(arr[i])) {
arr[i] = data[i];
}
}
setData(arr);
}
public static void copyOverNaN(double [] dst, double [] src) {
for (int i = 0; i < dst.length; i++) {
if (Double.isNaN(dst[i])) {
dst[i] = src[i];
}
}
}
public double [] toArray() {
double [] val = new double[FIELDS_USED.length];
int n = 0;
val[n++] = this.timestamp;
val[n++] = this.distance;
val[n++] = this.gps_lat;
val[n++] = this.gps_long;
val[n++] = this.gps_alt;
val[n++] = this.home_lat;
val[n++] = this.home_long;
return val;
}
public UasLogRecord(
double timestamp,
double distance,
double gps_lat,
double gps_long,
double gps_alt, // relative to home
double home_lat,
double home_long) {
this.timestamp = timestamp;
this.distance = distance;
this.gps_lat = gps_lat;
this.gps_long = gps_long;
this.gps_alt = gps_alt; // relative to home
this.home_lat = home_lat;
this.home_long = home_long;
}
public boolean hasUndefined() {
return hasUndefined(toArray());
}
public static boolean hasUndefined(double [] arr) {
for (double v: arr) if (Double.isNaN(v)) return true;
return false;
}
public static UasLogRecord[] getArray(
ArrayList<UasLogRecord> rec_list) {
UasLogRecord [] rec_array = rec_list.toArray(new UasLogRecord[0]);
Arrays.sort(rec_array, new Comparator<UasLogRecord>() { // decreasing weight
@Override
public int compare(UasLogRecord lhs, UasLogRecord rhs) {
return (rhs.timestamp > lhs.timestamp) ? -1 : (rhs.timestamp < lhs.timestamp) ? 1 : 0;
}
});
return rec_array;
}
public String toString() {
return String.format("timestamp=%f, distance=%f, gps_lat=%f, gps_lon=%f, alt=%f, home_lat=%f, home_lon=%f",
timestamp, distance, gps_lat, gps_long, gps_alt, home_lat, home_long);
}
public UasLogRecord clone() {
return new UasLogRecord (toArray());
}
public static UasLogRecord interpolate(
UasLogRecord[] rec_arr,
double timestamp) {
int last = rec_arr.length-1;
double ts0 = rec_arr[0].timestamp;
double ts1 = rec_arr[last].timestamp;
if (timestamp <= ts0) {
return rec_arr[0];
} else if ( timestamp >= last) {
return rec_arr[last];
} else {
// assuming timestamps are uniform, but not requiring that
int indx = (int) Math.round((timestamp-ts0)/(ts1-ts0));
while ((indx < (last-1)) && (rec_arr[indx+1].timestamp < timestamp)) indx++; // next record timestamp > requested
while ((indx >=0) && (rec_arr[indx].timestamp > timestamp)) indx--; // this record timestamp <= requested
double k = (timestamp-rec_arr[indx].timestamp) / (rec_arr[indx+1].timestamp-rec_arr[indx].timestamp);
double [] arr0 = rec_arr[indx].toArray();
double [] arr1 = rec_arr[indx+1].toArray();
double [] arr = new double [arr0.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = arr0[i] + k * (arr1[i] - arr0[i]);
}
return new UasLogRecord(arr);
}
}
public static boolean fillUndefined(UasLogRecord[] rec_arr) {
// UasLogRecord rec0=rec_arr[0].clone();
// fill initial NaNs to the first record
if (rec_arr[0].hasUndefined()) {
double [] arr0 = rec_arr[0].toArray();
fill_0: {
for (int i = 0; i < rec_arr.length; i++) {
if (!hasUndefined(arr0)) {
break fill_0;
}
double [] v1= rec_arr[i].toArray();
copyOverNaN(arr0, v1);
}
System.out.println("Still first undefined: "+(new UasLogRecord(arr0).toString()));
return false;
}
rec_arr[0].setData(arr0);
}
// fill last
int last = rec_arr.length-1;
if (rec_arr[last].hasUndefined()) {
double [] arr_last = rec_arr[last].toArray();
fill_0: {
for (int i = last; i >= 0; i--) {
if (!hasUndefined(arr_last)) {
break fill_0;
}
double [] v1= rec_arr[i].toArray();
copyOverNaN(arr_last, v1);
}
System.out.println("Still last undefined: "+(new UasLogRecord(arr_last).toString()));
return false;
}
rec_arr[last].setData(arr_last);
}
// interpolate assuming timestamp is always known
// first and last element should never be NaN here
double [][] all_arr = new double [rec_arr.length][];
for (int i = 0; i < all_arr.length; i++) {
all_arr[i] = rec_arr[i].toArray();
}
int num_fields = all_arr[0].length;
for (int nfield = 1; nfield < num_fields; nfield++) { // 0 is the timestamp
for (int tail = 0; tail <= last; tail++) {
for (; (tail < last) && !Double.isNaN(all_arr[tail][nfield]); tail++);
if (tail < last) {
tail--;
// tail is the last non-NaN here
int head = tail+2;
for (; (head <= last) && Double.isNaN(all_arr[head][nfield]); head++);
// head is the first non-NaN after NaN
double time_span = all_arr[head][0] - all_arr[tail][0];
double value_span = all_arr[head][nfield] - all_arr[tail][nfield];
double tail_val = all_arr[tail][nfield];
for (int i = tail+1; i < head; i++) {
double since_tail = all_arr[i][0] - all_arr[tail][0];
all_arr[i][nfield] = tail_val + value_span*since_tail/time_span;
}
tail = head; // will be added 1
}
}
}
for (int i = 0; i < all_arr.length; i++) {
rec_arr[i].setData(all_arr[i]);
}
return true;
}
}
......@@ -1998,6 +1998,20 @@ public class ErsCorrection extends GeometryCorrection {
return new double[][] {xyz,angles};
}
public double [] getImageCoordinatesERS(
double [] xyzw,
boolean correctDistortions, // correct distortion (will need corrected background too !)
double [] camera_xyz, // camera center in world coordinates
double [] camera_atr) { // camera orientation relative to world frame
return getImageCoordinatesERS(
xyzw, // double [] xyzw,// double [] xyzw,
correctDistortions, // boolean correctDistortions, // correct distortion (will need corrected background too !)
camera_xyz, // double [] camera_xyz, // camera center in world coordinates
camera_atr, //double [] camera_atr, // camera orientation relative to world frame
LINE_ERR); // double line_err); // threshold error in scan lines (1.0)
}
public double [] getImageCoordinatesERS(
......
......@@ -800,6 +800,7 @@ min_str_neib_fpn 0.35
public boolean cuas_save_video = true; // save color rendered images (same as videos)
public boolean cuas_annotate = true; // save color rendered images (same as videos)
public boolean cuas_annotate_uas = true; // indicate uas from log if available
public Color cuas_text_color = new Color (0, 255, 255);// 220);
public String cuas_font_name = "Monospaced";
public int cuas_font_size = 7; // before scaling
......@@ -2411,7 +2412,9 @@ min_str_neib_fpn 0.35
gd.addMessage("=== Target Annotation ===");
gd.addCheckbox ("Annotate targets", this.cuas_annotate,
"Add textual annptations to the target icons.");
"Add textual annotations to the target icons.");
gd.addCheckbox ("Show UAS from flighgt log", this.cuas_annotate,
"Indicate UAS position from the UAS flight log, if available.");
{
String scolor = String.format("%08x", getLongColor(this.cuas_text_color));
gd.addStringField ("Tast color",scolor, 8, "Any invalid hex number disables annotation");
......@@ -3479,6 +3482,7 @@ min_str_neib_fpn 0.35
this.cuas_save_video = gd.getNextBoolean();
this.cuas_annotate = gd.getNextBoolean();
this.cuas_annotate_uas = gd.getNextBoolean();
{
String scolor = gd.getNextString();
long lcolor = -1;
......@@ -4467,6 +4471,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_annotate", this.cuas_annotate+""); // boolean
properties.setProperty(prefix+"cuas_annotate_uas", this.cuas_annotate_uas+""); // boolean
{
long lcolor_annotate = (cuas_text_color == null) ? 0xCCFF00 : getLongColor(this.cuas_text_color);
properties.setProperty(prefix+"cuas_text_color", lcolor_annotate+"");
......@@ -5421,6 +5426,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_save_video")!=null) this.cuas_save_video=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_save_video"));
if (properties.getProperty(prefix+"cuas_annotate")!=null) this.cuas_annotate=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_annotate"));
if (properties.getProperty(prefix+"cuas_annotate_uas")!=null) this.cuas_annotate_uas=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_annotate_uas"));
if (properties.getProperty(prefix+"cuas_text_color")!=null) {
long lcolor_annotate = Long.parseLong(properties.getProperty(prefix+"cuas_text_color"));
if (lcolor_annotate < 0) this.cuas_text_color = setLongColor(0xCCFF00);
......@@ -6374,8 +6380,8 @@ min_str_neib_fpn 0.35
imp.cuas_save_color = this.cuas_save_color;
imp.cuas_save_video = this.cuas_save_video;
imp.cuas_annotate = this.cuas_annotate;
imp.cuas_annotate_uas = this.cuas_annotate_uas;
imp.cuas_text_color= this.cuas_text_color;
imp.cuas_font_name = this.cuas_font_name;
......
......@@ -64,6 +64,7 @@ import com.elphel.imagej.ims.Did_ins_1;
import com.elphel.imagej.ims.Did_ins_2;
import com.elphel.imagej.ims.Did_pimu;
import com.elphel.imagej.ims.Imx5;
import com.elphel.imagej.ims.UasLogReader;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.tileprocessor.sfm.StructureFromMotion;
import com.elphel.imagej.vegetation.VegetationModel;
......@@ -4715,7 +4716,8 @@ public class OpticalFlow {
int [] start_ref_pointers, // [0] - earliest valid scene, [1] ref_index
// each element is 0 for non-stereo and full width for stereo
String [] cuas_centers, // [0] - cumulative input, [1] - cumulative output
// processing UAS logs
UasLogReader uasLogReader,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) throws Exception
......@@ -6458,9 +6460,10 @@ public class OpticalFlow {
master_CLT.processMovingTargets(
clt_parameters, // CLTParameters clt_parameters,
batch_mode, // final boolean batch_mode,
fpixels, // final float [][] fpixels,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
debugLevel); // final int debugLevel)
fpixels, // final float [][] fpixels,
uasLogReader, // UasLogReader uasLogReader,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
debugLevel); // final int debugLevel)
}
}
}
......@@ -7279,6 +7282,13 @@ public class OpticalFlow {
String bkp_sourceDirectory = quadCLT_main.correctionsParameters.sourceDirectory;
String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths;
boolean bkp_use_set_dirs = quadCLT_main.correctionsParameters.use_set_dirs;
String bkp_cuasUasLogs = quadCLT_main.correctionsParameters.cuasUasLogs; // json file path containing UAS logs
double bkp_cuasUasTimeStamp = quadCLT_main.correctionsParameters.cuasUasTimeStamp; // 0.0; // timestamp corresponding to the UAS time 0.0
double [] bkp_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0};
master_CLT.saveConfInModelDirectory(); // save all (global) configurations in model/version directory
if (master_CLT != quadCLTs[ref_index]) {
quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
......@@ -7294,6 +7304,9 @@ public class OpticalFlow {
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourcePaths = bkp_sourcePaths;
quadCLT_main.correctionsParameters.use_set_dirs = bkp_use_set_dirs;
quadCLT_main.correctionsParameters.cuasUasLogs = bkp_cuasUasLogs;
quadCLT_main.correctionsParameters.cuasUasTimeStamp = bkp_cuasUasTimeStamp;
quadCLT_main.correctionsParameters.cuasCameraATR = bkp_cuasCameraATR;
System.out.println("buildSeries(): DONE"); //
// String top_dir0=quadCLTs[ref_index].getX3dTopDirectory();
......
......@@ -54,6 +54,7 @@ import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.gpu.TpTask;
//import com.elphel.imagej.tileprocessor.SetChannels;
import com.elphel.imagej.ims.UasLogReader;
import ij.IJ;
import ij.ImagePlus;
......@@ -5878,6 +5879,7 @@ if (debugLevel < -100) {
CLTParameters clt_parameters,
final boolean batch_mode,
final float [][] fpixels,
UasLogReader uasLogReader,
String [] scene_titles, // recreate slice_titles from scene titles?
final int debugLevel) {
CuasMotion.processMovingTargets(
......@@ -5885,6 +5887,7 @@ if (debugLevel < -100) {
batch_mode, // final boolean batch_mode,
this, // QuadCLT parentCLT, //
fpixels, // final float [][] fpixels,
uasLogReader, // UasLogReader uasLogReader,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
debugLevel); // final int debugLevel)
}
......
......@@ -57,6 +57,7 @@ import com.elphel.imagej.correction.EyesisCorrections;
import com.elphel.imagej.gpu.ExportForGPUDevelopment;
import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.ims.UasLogReader;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import ij.IJ;
......@@ -8674,6 +8675,16 @@ if (debugLevel > -100) return true; // temporarily !
int ref_index = -1; // -1 - last
int [] start_ref_pointers = new int[2]; //{earlist, reference} - reference may be center
boolean first_in_series = true;
// Process UAS logs
// quadCLT_main.correctionsParameters.cuasUasLogs, // String cuasUasLogs,
// quadCLT_main.correctionsParameters.cuasUasTimeStamp, // double cuasUasTimeStamp,
// quadCLT_main.correctionsParameters.cuasCameraATR, // double [] cuasCameraATR,
UasLogReader uasLogReader = null;
String uas_log_path = quadCLT_main.correctionsParameters.getUasLogsPath();
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);
}
while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) {
String model_directory = opticalFlow.buildSeries(
(pathFirstLast != null), //boolean batch_mode,
......@@ -8692,6 +8703,8 @@ if (debugLevel > -100) return true; // temporarily !
widths_list,
start_ref_pointers, // int [] start_ref_pointers,
cuas_centers, // String [] cuas_centers, // [0] - cumulative input, [1] - cumulative output
// processing UAS logs
uasLogReader, // UasLogReader uasLogReader,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel+2); // final int debugLevel)
......
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