Commit d7636cec authored by Andrey Filippov's avatar Andrey Filippov

CUAS first tests

parent 6381665c
......@@ -1280,6 +1280,17 @@ public class CLTParameters {
return lwir? fom_cdiff_lwir : fom_cdiff_rgb;
}
public boolean getErsForw() {
return ly_ers_forw && !imp.lock_position;
}
public boolean getErsSide() {
return ly_ers_side && !imp.lock_position;
}
public boolean getErsVert() {
return ly_ers_vert && !imp.lock_position;
}
public CLTParameters(){}
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"transform_size", this.transform_size+"");
......
......@@ -85,6 +85,7 @@ import javax.imageio.plugins.tiff.TIFFDirectory;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import org.json.JSONException;
import org.w3c.dom.Node;
import com.elphel.imagej.calibration.CalibrationFileManagement;
......@@ -109,6 +110,7 @@ import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin;
import com.elphel.imagej.ims.EventLogger;
import com.elphel.imagej.ims.UasLogReader;
//import com.elphel.imagej.ims.Imx5;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReader;
......@@ -870,6 +872,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Generate LWIR target", panelOrange, color_process);
// addButton("Test LDLT Cholesky", panelOrange, color_process);
addButton("Test LLT Cholesky", panelOrange, color_process);
addButton("UAS log", panelOrange, color_process);
plugInFrame.add(panelOrange);
}
plugInFrame.pack();
......@@ -5828,9 +5831,33 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return;
}
CholeskyBlockTest.testCholesky(imp_sel); // ImagePlus imp.);
} else if (label.equals("UAS log")) {
testUasLog();
}
//
}
public static boolean testUasLog() {
String uas_path= "/home/elphel/lwir16-proc/eagle_mountain/flight-logs/01-05-2025210705.json";
GenericJTabbedDialog gd = new GenericJTabbedDialog("UAS Log");
gd.addStringField("File path of the UAS log", uas_path, 100,
"Provide full path to the UAS JSON flight log");
gd.showDialog();
if (gd.wasCanceled())
return false;
uas_path = gd.getNextString();
try {
UasLogReader uasLogReader = new UasLogReader(uas_path);
} catch (JSONException e) {
System.out.println("Error reading/parsing "+uas_path);
System.out.println();
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
return true;
}
//
public boolean debugInitOneScene() {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
......
......@@ -103,7 +103,7 @@ public class Did_gps_pos {
public boolean isDidSane() { // add more!
if ( (lla[0] <-90) || (lla[0] > 90) || // latitude
(lla[1] <-90) || (lla[1] > 90) || // longitude
(lla[1] <-180) || (lla[1] > 180) || // longitude
(lla[2] <-10) || (lla[1] > 20000)) { // altitude
System.out.println("isDidSane(): bad lla=["+
lla[0]+", "+lla[1]+", "+lla[2]+"], timeOfWeekMs="+timeOfWeekMs);
......
......@@ -9,6 +9,8 @@ import com.elphel.imagej.tileprocessor.IntersceneMatchParameters;
public abstract class Did_ins <T extends Did_ins <T>>{
final static LocalDateTime DT_01_06_1980 = LocalDateTime.of(1980,1,6,0,0);
final static int WEEK_SECONDS = 7 * 24 * 3600;
public boolean good = true;
/** GPS number of weeks since January 6th, 1980 */
public int week; // uint32_t
/** GPS time of week (since Sunday morning) in seconds */
......@@ -67,6 +69,9 @@ public abstract class Did_ins <T extends Did_ins <T>>{
public boolean isDidSane() {
if (!good) { // BufferUnderflowException when creating
return false;
}
if ((week < MIN_WEEK) || (week > MAX_WEEK)) {
System.out.println("isDidSane(): bad week = "+week+
" - should be in range ["+MIN_WEEK+","+MAX_WEEK+"]");
......@@ -91,9 +96,9 @@ public abstract class Did_ins <T extends Did_ins <T>>{
(insStatus ^ eInsStatusFlags_data) & eInsStatusFlags_mask));
return false;
}
if ( (lla[0] <-90) || (lla[0] > 90) || // latitude
(lla[1] <-90) || (lla[1] > 90) || // longitude
(lla[2] <-10) || (lla[1] > 20000)) { // altitude
if ( (lla[0] <-90) || (lla[0] > 90) || // latitude
(lla[1] <-180) || (lla[1] > 180) || // longitude
(lla[2] <-10) || (lla[1] > 20000)) { // altitude
System.out.println("isDidSane(): bad lla=["+
lla[0]+", "+lla[1]+", "+lla[2]+"], timeOfWeek="+timeOfWeek);
return false;
......
package com.elphel.imagej.ims;
import java.nio.BufferUnderflowException;
//import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
......@@ -38,15 +39,21 @@ public class Did_ins_1 extends Did_ins <Did_ins_1>{
}
public Did_ins_1 (ByteBuffer bb) {
bb.order(ByteOrder.LITTLE_ENDIAN);
week= bb.getInt();
timeOfWeek=bb.getDouble();
insStatus= bb.getInt();
hdwStatus= bb.getInt();
theta[0]= bb.getFloat(); theta[1] = bb.getFloat(); theta[2]= bb.getFloat();
uvw[0]= bb.getFloat(); uvw[1] = bb.getFloat(); uvw[2]= bb.getFloat();
lla[0]= bb.getDouble(); lla[1] = bb.getDouble(); lla[2]= bb.getDouble();
ned[0]= bb.getFloat(); ned[1] = bb.getFloat(); ned[2]= bb.getFloat();
bb.order(ByteOrder.LITTLE_ENDIAN);
try {
week= bb.getInt();
timeOfWeek=bb.getDouble();
insStatus= bb.getInt();
hdwStatus= bb.getInt();
theta[0]= bb.getFloat(); theta[1] = bb.getFloat(); theta[2]= bb.getFloat();
uvw[0]= bb.getFloat(); uvw[1] = bb.getFloat(); uvw[2]= bb.getFloat();
lla[0]= bb.getDouble(); lla[1] = bb.getDouble(); lla[2]= bb.getDouble();
ned[0]= bb.getFloat(); ned[1] = bb.getFloat(); ned[2]= bb.getFloat();
} catch (BufferUnderflowException e) {
// TODO Auto-generated catch block
good = false;
return; // e.printStackTrace();
}
}
public Did_ins_1() {}
public Did_ins_1(String prefix, Properties properties) {
......
package com.elphel.imagej.ims;
import java.nio.BufferUnderflowException;
//import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
......@@ -28,14 +29,20 @@ public class Did_ins_2 extends Did_ins <Did_ins_2>{
// public double [] lla = new double [3];
public Did_ins_2 (ByteBuffer bb) {
bb.order(ByteOrder.LITTLE_ENDIAN);
week= bb.getInt();
timeOfWeek=bb.getDouble();
insStatus= bb.getInt();
hdwStatus= bb.getInt();
qn2b[0]= bb.getFloat(); qn2b[1] = bb.getFloat(); qn2b[2]= bb.getFloat(); qn2b[3]= bb.getFloat();
uvw[0]= bb.getFloat(); uvw[1] = bb.getFloat(); uvw[2]= bb.getFloat();
lla[0]= bb.getDouble(); lla[1] = bb.getDouble(); lla[2]= bb.getDouble();
bb.order(ByteOrder.LITTLE_ENDIAN);
try {
week= bb.getInt();
timeOfWeek=bb.getDouble();
insStatus= bb.getInt();
hdwStatus= bb.getInt();
qn2b[0]= bb.getFloat(); qn2b[1] = bb.getFloat(); qn2b[2]= bb.getFloat(); qn2b[3]= bb.getFloat();
uvw[0]= bb.getFloat(); uvw[1] = bb.getFloat(); uvw[2]= bb.getFloat();
lla[0]= bb.getDouble(); lla[1] = bb.getDouble(); lla[2]= bb.getDouble();
} catch (BufferUnderflowException e) {
// TODO Auto-generated catch block
good = false;
return; // e.printStackTrace();
}
}
public Did_ins_2() {}
public Did_ins_2(String prefix, Properties properties) {
......
......@@ -248,7 +248,7 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
if (debugLevel > -1) {
System.out.println("calibrateFromDidIns(true)");
}
calibrateFromDidIns(true, debugLevel);
calibrateFromDidIns(true, debugLevel); // error
// Timing calibration with local logging of GPS 1pps events (with IMX-5 it is REC_TYPE_ODO)
// Only fractional seconds can be calibrated, the record appears 0.1 sec after the event, local
......@@ -385,6 +385,12 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
int [] full_type = getFullType(bb, nrec);
if ((full_type != null) && (full_type[0] == type_imx5) && (full_type[1] == did_ins_type)) {
double ts_master = getMasterTS(bb, nrec);
/*
if (nrec==58364) {
System.out.println("nrec="+nrec+", type_ins_2="+type_ins_2); //*****
System.out.println();
}
*/
byte [] payload = getDidPayload(
null, // next_fileinfo, // may be null if payload does not extend beyond single record
nrec);
......@@ -394,8 +400,9 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
}
ByteBuffer bb_payload = ByteBuffer.wrap(payload);
bb_payload.order(ByteOrder.LITTLE_ENDIAN);
// Did_ins did_ins = null;
@SuppressWarnings("rawtypes")
Did_ins did_ins = type_ins_2 ? (new Did_ins_2(bb_payload)) : (new Did_ins_1(bb_payload));
Did_ins did_ins = type_ins_2 ? (new Did_ins_2(bb_payload)) : (new Did_ins_1(bb_payload)); // error
if (!did_ins.isDidSane()) {
continue;
}
......@@ -1345,6 +1352,14 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
}
@Override
public int compareTo(EventLoggerFileInfo arg0) {
if ((gnss_start != null) && (gnss_start[0] > 0) && (arg0.gnss_start != null) && (arg0.gnss_start[0] > 0)) {
int c = Integer.compare(gnss_start[0],arg0.gnss_start[0]);
if (c == 0) {
c = Integer.compare(gnss_start[1],arg0.gnss_start[1]);
}
return c;
}
// compare by GNSS time if available for both, by timestamps if not available
return Double.compare(ts_master_start,arg0.ts_master_start) ;
}
......
package com.elphel.imagej.ims;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
//import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
//import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
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);
*/
} 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;
/*
"flight_logging_keys": [
"timestamp",
"gps_lat",
"gps_lon",
"gps_altitude",
"speed_vx",
"speed_vy",
"zSpeed",
"dronePitch",
"droneRoll",
"droneYaw",
"mLeftHorizontal",
"mLeftVertical",
"mRightHorizontal",
"mRightVertical",
"batteryCapacityPercentage",
"phoneHeading",
"currentJourney",
"distanceFromHome",
"battery_voltage",
"currentElectricity",
"currentCurrent",
"visionWarning",
"visionExtWarning",
"visionErrorCode",
"radarInfoTimeStamp",
"frontRadarInfo",
"rearRadarInfo",
"leftRadarInfo",
"rightRadarInfo",
"topRadarInfo",
"bottomRadarInfo",
"alertArry",
"remoteLatitude",
"remoteLongitude",
"flightMode",
"gimbalPitch",
"gimbalRoll",
"gimbalYaw",
"gpsSignalLevel",
"rcRSSI",
"rcModeState",
"rcPowerState",
"rcTakeOffState",
"rcHomeState",
"rcHoverState",
"cameraMode",
"mMode",
"timeLeft",
"homeLatitude",
"homeLongitude",
"satelliteCount",
"designedVolume",
"fullChargeVolume",
"batteryTemperature",
"remainPowerPercent",
"numberOfDischarge",
"cellCount",
"maxFlightAltitude",
"voltageOfCells",
"goHomeAltitude",
"beginnerModeEnable",
"lowBatteryWarningThreshold",
"seriousBatteryWarningThreshold",
"maxFlightRadius",
"maxFlightHorizontalSpeed",
"obstacleAvoidanceEnable",
"radarEnable",
"gearMode",
"backTime",
"imageName",
"imagePath"
],
*/
}
}
......@@ -2909,7 +2909,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
};
}
ImageDtt.startAndJoin(threads);
imp.setTitle(removeKnownExtension(imp.getTitle())+String.format("-UM%.1f_%.2f",um_sigma,um_weight));
imp.setTitle(removeKnownExtension(imp.getTitle())+String.format("-UM%.1f_%.3f",um_sigma,um_weight));
return imp;
}
......
......@@ -97,11 +97,13 @@ public class ImagejJp4Tiff {
// private static final int FIXCH6_MAXVAL = 23367; // higher - subtract 4096, <19271 -add 4096
private static final int FIXCH6_EXPECTED = 21319; // expected value
private static final String FIXCH6_EARLIEST = "2021-12-01 00:00:00.000";
private static final String FIXCH6_LATEST = "2024-12-01 00:00:00.000";
// private static final String FIXCH6_LATEST = "2024-12-01 00:00:00.000";
private static final String FIXCH6_LATEST = "2030-12-01 00:00:00.000";
private static final String FIXCH5_SERIAL = "00:0E:64:10:C4:35";
// private static final String FIXCH5_EARLIEST = "2023-11-02 00:00:00.000";
private static final String FIXCH5_EARLIEST = "2023-10-01 00:00:00.000";
private static final String FIXCH5_LATEST = "2024-12-01 00:00:00.000";
// private static final String FIXCH5_LATEST = "2024-12-01 00:00:00.000";
private static final String FIXCH5_LATEST = "2030-12-01 00:00:00.000";
private static final int FIXCH5_CHANNEL = 1;
// -- Fields --
......
......@@ -538,7 +538,7 @@ public class Correlation2d {
public void normalizeAccumulatedPairs(
public static void normalizeAccumulatedPairs(
double [] accum_tile,
double sumw) {
if ((accum_tile != null) && (sumw > 0)) {
......@@ -5971,27 +5971,35 @@ public class Correlation2d {
for (int np = 0; np < corrs.length; np++) if ((xy_offsets[np] != null) && (corrs[np] != null)) {
int ix0 = (int) Math.floor(xy_offsets[np][0]);
int iy0 = (int) Math.floor(xy_offsets[np][1]);
for (int dy = 0; dy < 2; dy++) {
int iy = iy0 + dy;
int y0 = (iy > 0) ? 0 : -iy;
int y1 = (iy > 0) ? (corr_size - iy) : corr_size;
double ky = (dy > 0)? (xy_offsets[np][1] - iy0) : (iy0 + 1 - xy_offsets[np][1]);
for (int dx = 0; dx < 2; dx++) {
int ix = ix0 + dx;
int x0 = (ix > 0) ? 0 : -ix;
int x1 = (ix > 0) ? (corr_size - ix) : corr_size;
double kx = (dx > 0)? (xy_offsets[np][0] - ix0) : (ix0 + 1 - xy_offsets[np][0]);
double k = ky*kx;
int dsrc = iy * corr_size + ix;
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
int idst = y * corr_size + x;
int isrc = idst + dsrc;
corr_weights[idst] += k;
corr_shape[idst] += corrs[np][isrc] * k;
}
}
}
// skip crazy offsets
if ((ix0 < corr_size) && (iy0 < corr_size) && (ix0 > -corr_size) && (iy0 > -corr_size)) {
for (int dy = 0; dy < 2; dy++) {
int iy = iy0 + dy;
int y0 = (iy > 0) ? 0 : -iy;
int y1 = (iy > 0) ? (corr_size - iy) : corr_size;
double ky = (dy > 0)? (xy_offsets[np][1] - iy0) : (iy0 + 1 - xy_offsets[np][1]);
for (int dx = 0; dx < 2; dx++) {
int ix = ix0 + dx;
int x0 = (ix > 0) ? 0 : -ix;
int x1 = (ix > 0) ? (corr_size - ix) : corr_size;
double kx = (dx > 0)? (xy_offsets[np][0] - ix0) : (ix0 + 1 - xy_offsets[np][0]);
double k = ky*kx;
int dsrc = iy * corr_size + ix;
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
int idst = y * corr_size + x;
int isrc = idst + dsrc;
if ((idst >=0) && (idst < corr_shape.length) && (isrc >= 0) && (isrc < corrs[np].length)) { // 05.04.2025 got crazy xy_offsets
corr_weights[idst] += k;
corr_shape[idst] += corrs[np][isrc] * k;
}
}
}
}
}
} else {
System.out.println("getCorrShape(): Skip crazy offsets for np="+np+
",x/y="+xy_offsets[np][0]+"/"+xy_offsets[np][1]);
}
}
for (int i = 0; i < corr_shape.length; i++) if (corr_weights[i] > 0.0) {
......@@ -6018,28 +6026,37 @@ public class Correlation2d {
shifted_shapes[np] = new double [corr_len];
int ix0 = (int) Math.floor(-xy_offsets[np][0]);
int iy0 = (int) Math.floor(-xy_offsets[np][1]);
for (int dy = 0; dy < 2; dy++) {
int iy = iy0 + dy;
int y0 = (iy > 0) ? 0 : -iy;
int y1 = (iy > 0) ? (corr_size - iy) : corr_size;
double ky = (dy > 0)? (-xy_offsets[np][1] - iy0) : (iy0 + 1 + xy_offsets[np][1]);
for (int dx = 0; dx < 2; dx++) {
int ix = ix0 + dx;
int x0 = (ix > 0) ? 0 : -ix;
int x1 = (ix > 0) ? (corr_size - ix) : corr_size;
double kx = (dx > 0)? (-xy_offsets[np][0] - ix0) : (ix0 + 1 + xy_offsets[np][0]);
double k = ky*kx;
int dsrc = iy * corr_size + ix;
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
int idst = y * corr_size + x;
int isrc = idst + dsrc;
corr_weights[idst] += k;
shifted_shapes[np][idst] += corrs_shape[isrc] *k;
}
}
}
// skip crazy offsets
if ((ix0 < corr_size) && (iy0 < corr_size) && (ix0 > -corr_size) && (iy0 > -corr_size)) {
for (int dy = 0; dy < 2; dy++) {
int iy = iy0 + dy;
int y0 = (iy > 0) ? 0 : -iy;
int y1 = (iy > 0) ? (corr_size - iy) : corr_size;
double ky = (dy > 0)? (-xy_offsets[np][1] - iy0) : (iy0 + 1 + xy_offsets[np][1]);
for (int dx = 0; dx < 2; dx++) {
int ix = ix0 + dx;
int x0 = (ix > 0) ? 0 : -ix;
int x1 = (ix > 0) ? (corr_size - ix) : corr_size;
double kx = (dx > 0)? (-xy_offsets[np][0] - ix0) : (ix0 + 1 + xy_offsets[np][0]);
double k = ky*kx;
int dsrc = iy * corr_size + ix;
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
int idst = y * corr_size + x;
int isrc = idst + dsrc;
if ((idst >=0) && (idst < corr_weights.length) && (isrc >= 0) && (isrc < corrs_shape.length)) { // 05.04.2025 got crazy xy_offsets
corr_weights[idst] += k;
shifted_shapes[np][idst] += corrs_shape[isrc] *k;
}
}
}
}
}
} else {
System.out.println("applyCorrShape(): Skip crazy offsets for np="+np+
",x/y="+xy_offsets[np][0]+"/"+xy_offsets[np][1]);
}
for (int i = 0; i < corr_len; i++) if (corr_weights[i] > 0) {
shifted_shapes[np][i] /= corr_weights[i];
}
......
......@@ -188,6 +188,8 @@ public class ErsCorrection extends GeometryCorrection {
DP_DSVAZ, DP_DSVTL, DP_DSVRL,
DP_DSVX, DP_DSVY, DP_DSVZ};
public static final int [] DP_XY_INDICES = {DP_DSX,DP_DSY};
public static final int [] DP_XYZ_INDICES = {DP_DSX,DP_DSY,DP_DSZ};
public static final int [] DP_ZR_INDICES = {DP_DSZ,DP_DSRL};
public static final int [] DP_AT_INDICES = {DP_DSAZ,DP_DSTL};
public static final int [] DP_ATT_ERS_INDICES = {DP_DSVAZ,DP_DSVTL};
......
......@@ -230,7 +230,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1) {
System.out.println("clt_aberrations_quad_corr(): width="+width+" height="+height+" transform_size="+transform_size+
System.out.println("1.clt_aberrations_quad_corr(): width="+width+" height="+height+" transform_size="+transform_size+
" debug_tileX="+debug_tileX+" debug_tileY="+debug_tileY+" globalDebugLevel="+globalDebugLevel);
}
......@@ -2927,13 +2927,16 @@ public class ImageDtt extends ImageDttCPU {
final String debug_suffix,
final int globalDebugLevel)
{
final boolean debug_stuck = false; // true;
final double disparity_scale = 1.0/Math.sqrt(2); // combo pixels -> disparity pixels
final boolean diameters_combo = (imgdtt_params.mcorr_dual_fract > 0.0); // add diameters-only combo after all-combo
if (this.gpuQuad == null) {
System.out.println("clt_aberrations_quad_corr_GPU(): this.gpuQuad is null, bailing out");
return;
}
if (debug_stuck) {
System.out.println("clt_process_tl_correlations(): START, run_lma="+run_lma);
}
final double [][] debug_offsets = new double[getNumSensors()][2];
for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
......@@ -3005,7 +3008,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1) {
System.out.println("clt_aberrations_quad_corr(): width="+width+" height="+height+" transform_size="+transform_size+
System.out.println("2.clt_aberrations_quad_corr(): width="+width+" height="+height+" transform_size="+transform_size+
" debug_tileX="+debug_tileX+" debug_tileY="+debug_tileY+" globalDebugLevel="+globalDebugLevel);
}
......@@ -3035,7 +3038,10 @@ public class ImageDtt extends ImageDttCPU {
fcorr_weights, // fcorr_weights, // float [] fcorr_weights, // null or one per correlation tile (num_corr_tiles) to divide fat zero2
gpu_corr_rad); // int corr_radius
final float [][] fcorr2D = gpuQuad.getCorr2D(gpu_corr_rad); // int corr_rad);
if (debug_stuck) {
System.out.println("clt_process_tl_correlations(): corr_indices.length="+corr_indices.length);
}
if (corr_indices.length > 0) {
final int corr_length = fcorr2D[0].length;// all correlation tiles have the same size
......@@ -3113,7 +3119,9 @@ public class ImageDtt extends ImageDttCPU {
Arrays.fill(disparity_map[indx], Double.NaN);
}
}
if (debug_stuck) {
System.out.println("clt_process_tl_correlations(): START MULTI");
}
final Thread[] threads = newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
......@@ -3238,12 +3246,12 @@ public class ImageDtt extends ImageDttCPU {
}
}
correlation2d.normalizeAccumulatedPairs(
Correlation2d.normalizeAccumulatedPairs(
corr_combo_tile,
sumw);
corrs[correlation2d.getNumPairs()] = corr_combo_tile;
if (corr_dia_tile != null) {
correlation2d.normalizeAccumulatedPairs(
Correlation2d.normalizeAccumulatedPairs(
corr_dia_tile,
sumw_dia);
corrs[correlation2d.getNumPairs()+1] = corr_dia_tile;
......@@ -3596,7 +3604,7 @@ public class ImageDtt extends ImageDttCPU {
}
};
}
startAndJoin(threads);
startAndJoin(threads); // getting stuck
if (debug_lma != null) {
String suffix = (debug_suffix == null)?"":debug_suffix;
if (imgdtt_params.bimax_dual_LMA) {
......@@ -3634,6 +3642,9 @@ public class ImageDtt extends ImageDttCPU {
}
}
if (debug_stuck) {
System.out.println("clt_process_tl_correlations(): DONE");
}
return;
}
......
......@@ -211,7 +211,7 @@ public class ImageDttParameters {
public double lmas_poly_str_min = 0.05; // ignore tiles with poly strength (scaled) below
public boolean lmas_poly_continue = true; // use center if polynomial argmax fails
public boolean lmas_LY_single = true; // Adjust LY when performing single-tile LMA
public boolean lmas_LY_single = true; // Adjust LY when performing single-tile LMA
public boolean lmas_LY_single_LY = false; // Adjust LY when performing single-tile LMA before LY
public double lmas_lambda_initial = 0.03; //
......
package com.elphel.imagej.tileprocessor;
import java.awt.Rectangle;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -258,7 +257,7 @@ public class MultisceneLY {
scenes[nscene].getErsCorrection().setErsDt(
scene_ers_xyz_dt, // double [] ers_xyz_dt,
scene_ers_atr_dt); // double [] ers_atr_dt)(ers_scene_original_xyz_dt);
//setupERS() will be inside transformToScenePxPyD()
//setupERS() will be inside transformToScenePxPyD() // null pointer in the next
scenes_pXpYD[nscene] = OpticalFlow.transformToScenePxPyD( // will be null for disparity == NaN, total size - tilesX*tilesY
null, // final Rectangle [] extra_woi, // show larger than sensor WOI (or null)
disparity_ref, // final double [] disparity_ref, // invalid tiles - NaN in disparity (maybe it should not be masked by margins?)
......@@ -1024,14 +1023,14 @@ public class MultisceneLY {
// Does not use disparity_map[DISPARITY_STRENGTH_INDEX]
image_dtt.clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
fcorr_td_acc, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
fcorr_td_acc, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
num_acc, // float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] (or null)
null, // dcorr_weight, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough)
null, // dcorr_weight, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough)
clt_parameters.gpu_corr_scale, // final double gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values
clt_parameters.getGpuFatZero(last_scene.isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
image_dtt.transform_size - 1, // final int gpu_corr_rad, // = transform_size - 1 ?
// The tp_tasks data should be decoded from GPU to get coordinates
tp_tasks_combo, // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
tp_tasks_combo, // 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 [tilesY][tilesX]{disp(fg)-disp(bg), str(fg)-str(bg)} hints for LMA FG/BG split
last_scene.getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
// next both can be nulls
......@@ -1044,7 +1043,7 @@ public class MultisceneLY {
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
ddnd, // [tilesY][tilesX][num_sensors][2] data for LY. Should be either null or [tilesY][tilesX][][]. disparity_map should be non-null
clt_parameters.correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
clt_parameters.imp.run_ly_lma, // correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
// define combining of all 2D correlation pairs for CM (LMA does not use them)
clt_parameters.img_dtt.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
clt_parameters.img_dtt.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
......
......@@ -2645,44 +2645,46 @@ public class QuadCLTCPU {
}
}
}
boolean [] good_tiles = new boolean [disparity.length];
for (int i = 0; i < disparity.length; i++) {
good_tiles[i] = !Double.isNaN(disparity[i]);
}
if (sigma > 0) {
boolean [] good_tiles = new boolean [disparity.length];
for (int i = 0; i < disparity.length; i++) {
good_tiles[i] = !Double.isNaN(disparity[i]);
}
double scale_sigma = 5.0; // non-NaN - 5 pixels from original NaN for each sigma
int grow = 2* Math.min((int) Math.ceil(sigma * scale_sigma), tilesX);
disparity = TileProcessor.fillNaNs(
disparity, // final double [] data,
null, // final boolean [] prohibit,
tilesX, // int width,
// CAREFUL ! Remaining NaN is grown by unsharp mask filter ************* !
grow, // 100, // 2*width, // 16, // final int grow,
0.7, // double diagonal_weight, // relative to ortho
100, // int num_passes,
0.03); // final double max_rchange, // = 0.01 - does not need to be accurate
(new DoubleGaussianBlur()).blurDouble(
disparity, //
tilesX,
disparity.length/tilesX,
sigma, // double sigmaX,
sigma, // double sigmaY,
0.01); // double accuracy)
if (max_diff > 0) {
for (int i = 0; i < disparity.length; i++) if (good_tiles[i]){
if (Math.abs(disparity[i] - disparity_in[i]) > max_diff) {
good_tiles[i] = false;
double scale_sigma = 5.0; // non-NaN - 5 pixels from original NaN for each sigma
int grow = 2* Math.min((int) Math.ceil(sigma * scale_sigma), tilesX);
disparity = TileProcessor.fillNaNs(
disparity, // final double [] data,
null, // final boolean [] prohibit,
tilesX, // int width,
// CAREFUL ! Remaining NaN is grown by unsharp mask filter ************* !
grow, // 100, // 2*width, // 16, // final int grow,
0.7, // double diagonal_weight, // relative to ortho
100, // int num_passes,
0.03); // final double max_rchange, // = 0.01 - does not need to be accurate
(new DoubleGaussianBlur()).blurDouble(
disparity, //
tilesX,
disparity.length/tilesX,
sigma, // double sigmaX,
sigma, // double sigmaY,
0.01); // double accuracy)
if (max_diff > 0) {
for (int i = 0; i < disparity.length; i++) if (good_tiles[i]){
if (Math.abs(disparity[i] - disparity_in[i]) > max_diff) {
good_tiles[i] = false;
}
}
}
if (apply_nan) {
for (int i = 0; i < disparity.length; i++) if (!good_tiles[i]){
disparity[i] = Double.NaN;
}
}
}
if (apply_nan) {
for (int i = 0; i < disparity.length; i++) if (!good_tiles[i]){
disparity[i] = Double.NaN;
}
}
if (reliable_ref != null) {
System.arraycopy(good_tiles, 0, reliable_ref, 0, disparity.length);
if (reliable_ref != null) {
System.arraycopy(good_tiles, 0, reliable_ref, 0, disparity.length);
}
}
return disparity;
}
......@@ -3905,6 +3907,8 @@ public class QuadCLTCPU {
needs_lma = needs_lma_combo;
} else {
main_dsi = readDsiMain();
// this.dsi = readDsiMain(); // this.dsiis used in getBooleanBlueSky()
// main_dsi = this.dsi;
}
if (main_dsi == null) {
return null;
......@@ -3962,6 +3966,10 @@ public class QuadCLTCPU {
}
int num_reliable = 0;
for (boolean b: reliable) if (b) num_reliable++;
if (debugLevel > -3) {
System.out.println("getReliableTiles(): num_reliable="+num_reliable);
}
if (num_reliable < min_reliable) { // not enough, select best tiles, ignoring LMA
double max_str = 0;
for (double s:strength) if ((s > max_str) )max_str= s; // NaN OK
......@@ -3993,6 +4001,9 @@ public class QuadCLTCPU {
if (reduced_strength != null) {
reduced_strength[0] = threshold;
}
if (debugLevel > -3) {
System.out.println("getReliableTiles(): updated num_reliable="+num_reliable);
}
}
return reliable;
}
......@@ -4726,6 +4737,7 @@ public class QuadCLTCPU {
String ims_path,
boolean create,
int debugLevel) {
int debug_threshold = 0; // use -3 for verbose
if (ims_path == null) {
String model_dir = correctionsParameters.selectX3dDirectory(
image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
......@@ -4785,7 +4797,7 @@ public class QuadCLTCPU {
did_gps2_pos = new Did_gps_pos("did_gps2_pos-", ims_properties);
did_gps1_ubx_pos = new Did_gps_pos("did_gps1_ubx_pos-", ims_properties);
ims_last_path = ims_path;
if (debugLevel> -3) {
if (debugLevel > debug_threshold) {
System.out.println("IMS parameters are restored from "+ims_path);
}
return true;
......@@ -9924,9 +9936,9 @@ public class QuadCLTCPU {
clt_parameters.ly_com_roll, //boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength, //boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
clt_parameters.getErsForw(), // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.getErsSide(), // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.getErsVert(), // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
......@@ -13885,9 +13897,9 @@ public class QuadCLTCPU {
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength , // boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
clt_parameters.getErsForw(), // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.getErsSide(), // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.getErsVert(), // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
......@@ -18122,7 +18134,7 @@ public class QuadCLTCPU {
/// }
}
for (String fname:path_list) {
System.out.println("writeKml(): "+fname);
if (debugLevel > -1) System.out.println("writeKml(): "+fname);
if (setGpsLla(fname)) {
break;
}
......
......@@ -2678,7 +2678,7 @@ public class TexturedModel {
final boolean tex_um_fixed = clt_parameters.tex_um_fixed; // imp.mono_fixed; // true; // normalize to fixed range when converting to 8 bits
final double tex_um_range = clt_parameters.tex_um_range; // imp.mono_range; // 500.0; // monochrome full-scale range (+/- half)
final boolean gsmth_enable = clt_parameters.gsmth_enable ; // true; // ;
final boolean gsmth_enable = clt_parameters.gsmth_enable && !clt_parameters.imp.lock_position; // true; // ;
final boolean gsmth_sfm_gnd = clt_parameters.gsmth_sfm_gnd ; // true; // ;
final boolean gsmth_sfm_deviate = clt_parameters.gsmth_sfm_deviate ; // true; // ;
final double gsmth_sfm_gain = clt_parameters.gsmth_sfm_gain; // 10.0; // minimal SfM gain to enable deviations from the smooth level
......@@ -2695,7 +2695,7 @@ public class TexturedModel {
final boolean flat_border = clt_parameters.imp.terr_flat_brd; // when filling NaN, replace NaN border tiles with flat ground
final int expand_above = clt_parameters.imp.terr_expand; // 4; // 2;
final boolean save_terrain = clt_parameters.imp.terr_save & terrain_mode; // save debug data in model directory
final boolean lock_position = clt_parameters.imp.lock_position; // do not rectify, just generate intermediate
// final int ref_index = scenes.length - 1;
final QuadCLT ref_scene = scenes[ref_index];
......@@ -3168,6 +3168,9 @@ public class TexturedModel {
if (updateStatus) IJ.showProgress((nscan+1.0)/num_scans);
}
}
if (lock_position && clt_parameters.tex_save_interm_textures) {
System.out.println("CUAS mode, intermediate texture saved, exiting");
}
if (ct_scans != null) {
if (ct_disparity != null) {
String [] titles = new String[ct_disparity.length];
......@@ -8387,24 +8390,24 @@ public class TexturedModel {
debugLevel); // int debugLevel)
}
if (save_interm_textures) {
String suffix = (terrain_mode?"-TERR":"")+"-combined_textures";
if (!batch_run && (debugLevel > -1)) {
ShowDoubleFloatArrays.showArrays(
dbg_textures,
tilesX * transform_size,
tilesY * transform_size,
true,
ref_scene.getImageName()+suffix,
dbg_titles);
}
ref_scene.saveDoubleArrayInModelDirectory(
suffix, // String suffix,
null, // String [] labels, // or null
dbg_textures, // double [][] data,
tilesX * transform_size, // int width, // int tilesX,
tilesY * transform_size); // int height, // int tilesY,
}
if (save_interm_textures) {
String suffix = (terrain_mode?"-TERR":"")+"-combined_textures";
if (!batch_run && (debugLevel > -1)) {
ShowDoubleFloatArrays.showArrays(
dbg_textures,
tilesX * transform_size,
tilesY * transform_size,
true,
ref_scene.getImageName()+suffix,
dbg_titles);
}
ref_scene.saveDoubleArrayInModelDirectory(
suffix, // String suffix,
null, // String [] labels, // or null
dbg_textures, // double [][] data,
tilesX * transform_size, // int width, // int tilesX,
tilesY * transform_size); // int height, // int tilesY,
}
}
return faded_textures;
}
......
......@@ -11722,9 +11722,9 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength , // boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
clt_parameters.getErsForw(), // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.getErsSide(), // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.getErsVert(), // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
......
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