Commit a12d2254 authored by Andrey Filippov's avatar Andrey Filippov

working snapshot

parent 971025da
...@@ -187,6 +187,10 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -187,6 +187,10 @@ public class ErsCorrection extends GeometryCorrection {
DP_DVX, DP_DVY, DP_DVZ, DP_DVX, DP_DVY, DP_DVZ,
DP_DSVAZ, DP_DSVTL, DP_DSVRL, DP_DSVAZ, DP_DSVTL, DP_DSVRL,
DP_DSVX, DP_DSVY, DP_DSVZ}; DP_DSVX, DP_DSVY, DP_DSVZ};
public static final int [] DP_XYZR_INDICES = {DP_DSX,DP_DSY,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};
public static final RotationConvention ROT_CONV = RotationConvention.FRAME_TRANSFORM; public static final RotationConvention ROT_CONV = RotationConvention.FRAME_TRANSFORM;
static final double THRESHOLD = 1E-10; static final double THRESHOLD = 1E-10;
static final double LINE_ERR = 0.001; // line accuracy for ERS when converting from world to pixels. static final double LINE_ERR = 0.001; // line accuracy for ERS when converting from world to pixels.
...@@ -223,8 +227,29 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -223,8 +227,29 @@ public class ErsCorrection extends GeometryCorrection {
if (d > 0) return 1.0/ERS_MIN_DISPARITY; if (d > 0) return 1.0/ERS_MIN_DISPARITY;
return -1.0/ERS_MIN_DISPARITY; return -1.0/ERS_MIN_DISPARITY;
} }
public static final int [] DP_XYZR_INDICES = {DP_DSX,DP_DSY,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};
*/ */
public static boolean [] getParamSelect(
boolean use_AT,
boolean use_ERS) {
boolean [] param_select = new boolean[DP_NUM_PARS];
for (int i:DP_XYZR_INDICES) param_select[i] = true;
if (use_AT) for (int i:DP_AT_INDICES) param_select[i] = true;
if (use_ERS) for (int i:DP_ATT_ERS_INDICES) param_select[i] = true;
return param_select;
}
public static double [] getParamRegWeights(
double reg_weight,
boolean use_AT) {
double [] reg_weights = new double[DP_NUM_PARS];
reg_weights[DP_DSX] = reg_weight;
reg_weights[DP_DSY] = reg_weight;
return reg_weights;
}
public void setPose( public void setPose(
double [] camera_xyz, double [] camera_xyz,
double [] camera_atr) { double [] camera_atr) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4712,11 +4712,16 @@ public class OpticalFlow { ...@@ -4712,11 +4712,16 @@ public class OpticalFlow {
int test_ers0 = clt_parameters.imp.test_ers0; // try adjusting a pair of scenes with ERS. Reference scene index int test_ers0 = clt_parameters.imp.test_ers0; // try adjusting a pair of scenes with ERS. Reference scene index
int test_ers1 = clt_parameters.imp.test_ers1; // try adjusting a pair of scenes with ERS. Other scene index int test_ers1 = clt_parameters.imp.test_ers1; // try adjusting a pair of scenes with ERS. Other scene index
test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0); test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0);
boolean use_combo_relaible = clt_parameters.imp.use_combo_relaible; boolean use_combo_relaible = clt_parameters.imp.use_combo_reliable;
boolean ref_need_lma = clt_parameters.imp.ref_need_lma; boolean ref_need_lma = clt_parameters.imp.ref_need_lma;
boolean ref_need_lma_combo = clt_parameters.imp.ref_need_lma_combo; boolean ref_need_lma_combo = clt_parameters.imp.ref_need_lma_combo;
double min_ref_str = clt_parameters.imp.min_ref_str; double min_ref_str = clt_parameters.imp.min_ref_str;
boolean sfm_filter = clt_parameters.imp.sfm_filter; //true; // use SfM filtering if available
double sfm_minmax = clt_parameters.imp.sfm_minmax; //10.0; // minimal value of the SfM gain maximum to consider available
double sfm_fracmax = clt_parameters.imp.sfm_fracmax; // 0.75; // minimal fraction of the SfM maximal gain
double sfm_fracall = clt_parameters.imp.sfm_fracall; // 0.3; // minimal relative area of the SfM-enabled tiles (do not apply filter if less)
double min_ref_frac= clt_parameters.imp.min_ref_frac; double min_ref_frac= clt_parameters.imp.min_ref_frac;
double [] ref_blue_sky = null; // turn off "lma" in the ML output double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options if (reuse_video) { // disable all other options
...@@ -5234,8 +5239,12 @@ public class OpticalFlow { ...@@ -5234,8 +5239,12 @@ public class OpticalFlow {
min_ref_frac, // double min_ref_frac, min_ref_frac, // double min_ref_frac,
ref_need_lma, // boolean needs_lma); ref_need_lma, // boolean needs_lma);
ref_need_lma_combo, // boolean needs_lma); ref_need_lma_combo, // boolean needs_lma);
reduced_strength); // if not null will return >0 if had to reduce strength (no change if did not reduce) sfm_filter, // boolean sfm_filter, // use SfM filtering if available
sfm_minmax, // double sfm_minmax, // minimal value of the SfM gain maximum to consider available
sfm_fracmax, // double sfm_fracmax,// minimal fraction of the SfM maximal gain
sfm_fracall, // double sfm_fracall,// minimal relative area of the SfM-enabled tiles (do not apply filter if less)
reduced_strength, // if not null will return >0 if had to reduce strength (no change if did not reduce)
debugLevel); // int debugLevel)
if (show_reliable_ref) { if (show_reliable_ref) {
double [] dbg_img = new double [reliable_ref.length]; double [] dbg_img = new double [reliable_ref.length];
for (int i = 0; i < dbg_img.length; i++) { for (int i = 0; i < dbg_img.length; i++) {
......
...@@ -356,7 +356,7 @@ public class QuadCLTCPU { ...@@ -356,7 +356,7 @@ public class QuadCLTCPU {
double [] ims_ortho = clt_parameters.imp.ims_ortho; double [] ims_ortho = clt_parameters.imp.ims_ortho;
double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians
double [][][] scenes_xyzatr = new double [quadCLTs.length][][]; double [][][] scenes_xyzatr = new double [quadCLTs.length][][];
// scenes_xyzatr[ref_index] = new double[2][3]; // all zeros // scenes_xyzatr[ref_index] = new double[2][3]; // all zeros
Did_ins_2 d2_ref = did_ins_2; Did_ins_2 d2_ref = did_ins_2;
// apply correction to orientation - better not to prevent extra loops. // apply correction to orientation - better not to prevent extra loops.
...@@ -485,11 +485,11 @@ public class QuadCLTCPU { ...@@ -485,11 +485,11 @@ public class QuadCLTCPU {
} }
} }
return fl; return fl;
// if ((fl[0] >= 0) && (fl[1] >= 0)) { // if ((fl[0] >= 0) && (fl[1] >= 0)) {
// return fl; // return fl;
// } else { // } else {
// return null; // return null;
// } // }
} }
/** /**
...@@ -989,7 +989,7 @@ public class QuadCLTCPU { ...@@ -989,7 +989,7 @@ public class QuadCLTCPU {
d2.getQEnu(), d2.getQEnu(),
ims_mount_atr, ims_mount_atr,
ims_ortho); ims_ortho);
// //
double [] quat_corr = getQuatCorr(); double [] quat_corr = getQuatCorr();
if (apply_quat_corr && (quat_corr != null)) { if (apply_quat_corr && (quat_corr != null)) {
cam_quat_enu=Imx5.applyQuaternionToQuaternion(quat_corr, cam_quat_enu, false); cam_quat_enu=Imx5.applyQuaternionToQuaternion(quat_corr, cam_quat_enu, false);
...@@ -1030,7 +1030,7 @@ public class QuadCLTCPU { ...@@ -1030,7 +1030,7 @@ public class QuadCLTCPU {
xy_range, // double [][] xy_range, // should be double[2][]; meters xy_range, // double [][] xy_range, // should be double[2][]; meters
debug_level); // int debug_level) debug_level); // int debug_level)
// camera position and orientation relative to the same lat/long on the ground below it // camera position and orientation relative to the same lat/long on the ground below it
// double [][] scene_abs_xyzatr_enu = new double [][] {new double[] {0,0,-agl}, scene_abs_atr_enu}; // double [][] scene_abs_xyzatr_enu = new double [][] {new double[] {0,0,-agl}, scene_abs_atr_enu};
double [][] scene_abs_xyzatr_enu = new double [][] {new double[] {0,0,use_parallel_proj?0:-agl}, scene_abs_atr_enu}; double [][] scene_abs_xyzatr_enu = new double [][] {new double[] {0,0,use_parallel_proj?0:-agl}, scene_abs_atr_enu};
// double [][] ground_xyzatr = new double [][] { // double [][] ground_xyzatr = new double [][] {
// {0, 0, z_tilts[0]}, // {0, 0, z_tilts[0]},
...@@ -1102,7 +1102,7 @@ public class QuadCLTCPU { ...@@ -1102,7 +1102,7 @@ public class QuadCLTCPU {
double hist_rlow = 0.5; double hist_rlow = 0.5;
double hist_rhigh = 2.0; double hist_rhigh = 2.0;
int min_good = 20; //number of good tiles int min_good = 20; //number of good tiles
// double rel_hight = 0.2; // when calculating scale, ignore objects far from plane // double rel_hight = 0.2; // when calculating scale, ignore objects far from plane
int num_bins = 1000; int num_bins = 1000;
double sw=0, swd=0; double sw=0, swd=0;
boolean [] good_tiles = new boolean[ref_disparity.length]; boolean [] good_tiles = new boolean[ref_disparity.length];
...@@ -1176,8 +1176,8 @@ public class QuadCLTCPU { ...@@ -1176,8 +1176,8 @@ public class QuadCLTCPU {
return Double.NaN; return Double.NaN;
} }
// double dl = discard_low * sw; // double dl = discard_low * sw;
// double dh = discard_high * sw; // double dh = discard_high * sw;
double dl = discard_high * sw; double dl = discard_high * sw;
double dh = discard_low * sw; double dh = discard_low * sw;
double sh = 0.0; double sh = 0.0;
...@@ -1234,7 +1234,7 @@ public class QuadCLTCPU { ...@@ -1234,7 +1234,7 @@ public class QuadCLTCPU {
public double [][] getDLS(){ // get disparity, disparity_lma, strength, sfm_gain public double [][] getDLS(){ // get disparity, disparity_lma, strength, sfm_gain
if (dsi == null) { if (dsi == null) {
// System.out.println("dsi== null, use spawnQuadCLT(), restoreFromModel(), ... to set it"); // System.out.println("dsi== null, use spawnQuadCLT(), restoreFromModel(), ... to set it");
return null; return null;
} }
double [][] dls = new double[4][]; double [][] dls = new double[4][];
...@@ -1294,7 +1294,7 @@ public class QuadCLTCPU { ...@@ -1294,7 +1294,7 @@ public class QuadCLTCPU {
this.new_image_data = qParent.new_image_data; this.new_image_data = qParent.new_image_data;
if (qParent.saturation_imp != null) this.saturation_imp = qParent.saturation_imp.clone(); // each camera will be re-written, not just modified, so shallow copy if (qParent.saturation_imp != null) this.saturation_imp = qParent.saturation_imp.clone(); // each camera will be re-written, not just modified, so shallow copy
this.is_aux = qParent.is_aux; this.is_aux = qParent.is_aux;
// this.is_mono = qParent.is_mono; // this.is_mono = qParent.is_mono;
this.photometric_scene = qParent.photometric_scene; this.photometric_scene = qParent.photometric_scene;
this.lwir_offsets = ErsCorrection.clone1d(qParent.lwir_offsets); this.lwir_offsets = ErsCorrection.clone1d(qParent.lwir_offsets);
...@@ -1404,7 +1404,7 @@ public class QuadCLTCPU { ...@@ -1404,7 +1404,7 @@ public class QuadCLTCPU {
public static double getTimeStamp(String ts) { public static double getTimeStamp(String ts) {
String sts = ts.replace("_", "."); String sts = ts.replace("_", ".");
// Matcher m = Pattern.compile("\\d").matcher(sts); // Matcher m = Pattern.compile("\\d").matcher(sts);
Matcher m = Pattern.compile("\\d{5,10}\\.\\d{6}").matcher(sts); Matcher m = Pattern.compile("\\d{5,10}\\.\\d{6}").matcher(sts);
// //
if(m.find()) { if(m.find()) {
...@@ -1556,10 +1556,10 @@ public class QuadCLTCPU { ...@@ -1556,10 +1556,10 @@ public class QuadCLTCPU {
int height = strength.length/width; int height = strength.length/width;
int dbg_tile = -1150; int dbg_tile = -1150;
// int sky_bottleneck = 5; // shrink full selection, then re-expand from seed to disable // int sky_bottleneck = 5; // shrink full selection, then re-expand from seed to disable
// small (narrow) leaks (or just disable leaks near margins)? // small (narrow) leaks (or just disable leaks near margins)?
// int shrink_for_temp = 10; // int shrink_for_temp = 10;
// double sky_temp_override = -300; // really cold average seed - ignore lowest_sky_row filter // double sky_temp_override = -300; // really cold average seed - ignore lowest_sky_row filter
double [] temp_scales = null; double [] temp_scales = null;
boolean failure = false; boolean failure = false;
double temp_cold = Double.NaN; double temp_cold = Double.NaN;
...@@ -2130,7 +2130,7 @@ public class QuadCLTCPU { ...@@ -2130,7 +2130,7 @@ public class QuadCLTCPU {
} }
// @Deprecated // @Deprecated
public void setBlueSky (boolean [] blue_sky) { public void setBlueSky (boolean [] blue_sky) {
double [] double_blue_sky = new double [blue_sky.length]; double [] double_blue_sky = new double [blue_sky.length];
for (int i = 0; i < blue_sky.length; i++) { for (int i = 0; i < blue_sky.length; i++) {
...@@ -2214,7 +2214,7 @@ public class QuadCLTCPU { ...@@ -2214,7 +2214,7 @@ public class QuadCLTCPU {
QuadCLT dbg_scene, // use to save debug images if not null QuadCLT dbg_scene, // use to save debug images if not null
int debugLevel) { int debugLevel) {
int width = tp.getTilesX(); int width = tp.getTilesX();
// this.blue_sky = getBlueSky ( // this.blue_sky = getBlueSky (
setBlueSky(getBlueSky ( setBlueSky(getBlueSky (
max_disparity, max_disparity,
max_disparity_strength, max_disparity_strength,
...@@ -2403,23 +2403,27 @@ public class QuadCLTCPU { ...@@ -2403,23 +2403,27 @@ public class QuadCLTCPU {
dsi, dsi,
silent); silent);
} }
//min_ref_frac //min_ref_frac
public boolean [] getReliableTiles( public boolean [] getReliableTiles(
boolean use_combo, boolean use_combo,
double min_strength, double min_strength,
double min_ref_frac, double min_ref_frac,
boolean needs_lma, boolean needs_lma,
boolean needs_lma_combo, boolean needs_lma_combo,
double [] reduced_strength // if not null will return >0 if had to reduce strength (no change if did not reduce) boolean sfm_filter,
double sfm_minmax,
double sfm_fracmax,
double sfm_fracall,
double [] reduced_strength, // if not null will return >0 if had to reduce strength (no change if did not reduce)
int debugLevel
) { ) {
int NUM_BINS = 1024; int NUM_BINS = 1024;
// 10.15.2023 - was error here, readComboDSI (silent) returns combo_dsi, not converted to this.dsi format; // 10.15.2023 - was error here, readComboDSI (silent) returns combo_dsi, not converted to this.dsi format;
// double [][] main_dsi = use_combo? readComboDSI (silent): readDsiMain(); // double [][] main_dsi = use_combo? readComboDSI (silent): readDsiMain();
double [][] main_dsi = null; double [][] main_dsi = null;
boolean silent = false; boolean silent = false;
if (use_combo) { if (use_combo) {
readComboDSI (silent); readComboDSI (silent);
main_dsi = this.dsi;
needs_lma = needs_lma_combo; needs_lma = needs_lma_combo;
} else { } else {
main_dsi = readDsiMain(); main_dsi = readDsiMain();
...@@ -2427,6 +2431,7 @@ public class QuadCLTCPU { ...@@ -2427,6 +2431,7 @@ public class QuadCLTCPU {
if (main_dsi == null) { if (main_dsi == null) {
return null; return null;
} }
double [] disparity_lma = main_dsi[isAux()?TwoQuadCLT.DSI_DISPARITY_AUX_LMA:TwoQuadCLT.DSI_DISPARITY_MAIN_LMA]; double [] disparity_lma = main_dsi[isAux()?TwoQuadCLT.DSI_DISPARITY_AUX_LMA:TwoQuadCLT.DSI_DISPARITY_MAIN_LMA];
double [] strength = main_dsi[isAux()?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN]; double [] strength = main_dsi[isAux()?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN];
double [] sfm_gain = main_dsi[isAux()?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN]; double [] sfm_gain = main_dsi[isAux()?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN];
...@@ -2449,22 +2454,34 @@ public class QuadCLTCPU { ...@@ -2449,22 +2454,34 @@ public class QuadCLTCPU {
} }
} }
} }
if (sfm_gain != null) { if (sfm_filter && (sfm_gain != null)) {
double sfm_max = 0.0;
for (int i = 0; i < reliable.length; i++) {
if (sfm_gain[i] > sfm_max) sfm_max = sfm_gain[i];
}
if (sfm_max > sfm_minmax) {
double sfm_thresh = sfm_max * sfm_fracmax;
boolean [] sfm_good = new boolean [reliable.length];
int num_sfm_gain = 0; int num_sfm_gain = 0;
for (int i = 0; i < reliable.length; i++) { for (int i = 0; i < reliable.length; i++) {
if (sfm_gain[i] >0) { if (sfm_gain[i] >= sfm_thresh) {
sfm_good[i] = true;
num_sfm_gain++; num_sfm_gain++;
} }
} }
if (num_sfm_gain > min_reliable) { if (num_sfm_gain > (sfm_fracall * reliable.length)) {
if (debugLevel > -3) {
System.out.println("getReliableTiles(): Using SfM filter");
}
for (int i = 0; i < reliable.length; i++) { for (int i = 0; i < reliable.length; i++) {
if (sfm_gain[i] <= 0){ if (!sfm_good[i]) { // sfm_gain[i] <= 0){
reliable[i] = false; reliable[i] = false;
strength[i] = 0.0; strength[i] = 0.0;
} }
} }
} }
} }
}
int num_reliable = 0; int num_reliable = 0;
for (boolean b: reliable) if (b) num_reliable++; for (boolean b: reliable) if (b) num_reliable++;
if (num_reliable < min_reliable) { // not enough, select best tiles, ignoring LMA if (num_reliable < min_reliable) { // not enough, select best tiles, ignoring LMA
...@@ -2697,7 +2714,7 @@ public class QuadCLTCPU { ...@@ -2697,7 +2714,7 @@ public class QuadCLTCPU {
// Moving here form QC: // Moving here form QC:
public double [][] getDSRBG (){ public double [][] getDSRBG (){
return dsrbg; return dsrbg;
} }
......
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