Commit 6e5b9835 authored by Andrey Filippov's avatar Andrey Filippov

Working on target ranging

parent f0ca9c38
......@@ -86,10 +86,12 @@ public class CuasMotionLMA {
public static final int RSLT_SLOW = 41; // 1 - slow, 0 - fast
public static final int RSLT_WHEN = 42;
public static final int RSLT_FAIL = 43;
public static final int RSLT_DISPARITY = 44;
public static final int RSLT_DISPARITY=44;
public static final int RSLT_DISP_STR =45;
public static final int RSLT_RANGE = 46;
public static final int RSLT_LEN = RSLT_DISPARITY+1;
public static final int RSLT_LEN = RSLT_RANGE+1;
public static final String [] LMA_TITLES =
{"X-OFFS","Y-OFFS", "AMPLITUDE", "RADIUS","RAD_POS", "OVERSHOOT","OFFSET","RMSE","RMSE/A","MAX2A","ITERATIONS",
......@@ -105,7 +107,7 @@ public class CuasMotionLMA {
"*Q-AMPL","*Q-RMSE","*Q-RMSE/A","*Q-CENTER","*Q-MATCH","*Q-LENGTH","*QTRAVEL","*Q-SCORE",
"Stronger","Slow",
"WHEN", "FAILURE",
"Disparity"};
"Disparity","Strength","Range"};
public static final int FAIL_NONE = 0;
public static final int FAIL_MOTION = 1; // motion strength/fraction too low
......
......@@ -5030,15 +5030,15 @@ public class Correlation2d {
double [][] dispStr = lma.lmaDisparityStrength( //TODO: add parameter to filter out negative minimums ?
false, // boolean bypass_tests, // keep even weak for later analysis. Normally - only in test mode
imgdtt_params.lmas_min_amp, // minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
false, // boolean bypass_tests, // keep even weak for later analysis. Normally - only in test mode
imgdtt_params.lmas_min_amp, // minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
imgdtt_params.lmas_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lmas_min_max_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lmas_min_max_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lmas_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lmas_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset, // convert lma-generated strength to match previous ones - add to result
imgdtt_params.lma_str_offset, // convert lma-generated strength to match previous ones - add to result
imgdtt_params.lma_ac_offset, // Add to A, C coefficients for near-lines where A,C could become negative because of window
imgdtt_params.lma_relax_indiv_max// double lma_relax_indiv_max // double relax_indiv_max
);
......
......@@ -917,7 +917,7 @@ public class ImageDtt extends ImageDttCPU {
gpuQuad.setLpfCorr(// constants memory - same for all cameras
"LoG_corr", // String const_name, // "lpf_corr"
log_flat,
globalDebugLevel > -1);
globalDebugLevel > 0);
gpuQuad.setTasks( // copy tp_tasks to the GPU memory
tp_tasks, // TpTask [] tile_tasks,
......@@ -3081,6 +3081,8 @@ public class ImageDtt extends ImageDttCPU {
// final double [][] debug_lma = imgdtt_params.lmamask_dbg? (new double [6][tilesX*tilesY]):null;
final double [][] debug_lma = imgdtt_params.lmamask_dbg? (new double [debug_lma_titles.length][tilesX*tilesY]):null;
final boolean debug_print_targets = true;
if (debug_lma != null) {
for (int i = 0; i < debug_lma.length; i++) {
Arrays.fill(debug_lma[i], Double.NaN);
......@@ -3128,7 +3130,7 @@ public class ImageDtt extends ImageDttCPU {
}
if (globalDebugLevel > 1) {
if (globalDebugLevel > 2) {
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);
}
......@@ -3508,10 +3510,17 @@ public class ImageDtt extends ImageDttCPU {
imgdtt_params.lmas_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset, // convert lma-generated strength to match previous ones - add to result
dbg_dispStrs, // false // boolean dbg_mode
dbg_dispStrs || debug_print_targets, // false // boolean dbg_mode
imgdtt_params.lma_ac_offset, // Add to A, C coefficients for near-lines where A,C could become negative because of window
imgdtt_params.lma_relax_indiv_max// double lma_relax_indiv_max // double relax_indiv_max
);
if (debug_print_targets) {
String dbg_s = ""+tileX+":"+tileY+" ("+(tileX+tilesX*tileY)+")";
for (int i = 0; i < dispStrs[0][0].length; i++) {
dbg_s+=" "+dispStrs[0][0][i];
}
System.out.println(dbg_s);
}
disp_str_lma = new double [dispStrs.length][]; // order matching input ones
for (int nmax = 0;nmax < dispStrs.length; nmax++) {
if ((dispStrs[nmax] != null) && (dispStrs[nmax].length >0)) {
......
......@@ -92,27 +92,27 @@ public class ImageDttCPU {
// public static int FORCE_DISPARITY_BIT = 8; // move to parameters?
// static int QUAD = 4; // number of cameras in camera
static int GREEN_CHN = 2; // index of green channel
static int MONO_CHN = 0; /// 2; // index of channel used in monochrome mode
public static int GREEN_CHN = 2; // index of green channel
public static int MONO_CHN = 0; /// 2; // index of channel used in monochrome mode
static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho
public static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho
// Now DISPARITY_INDEX_CM may be POLY with backup from CM (for bad correlation)
static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction)
static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed
static int DISPARITY_INDEX_HOR_STRENGTH = 5; // strength for hor mode (emphasis on vertical lines)
static int DISPARITY_INDEX_VERT = 6; // disparity from correlation of the vertical pairs with center suppressed
static int DISPARITY_INDEX_VERT_STRENGTH = 7; // strength in vert mode (horizontal lines detection)
static int DISPARITY_INDEX_POLY = 8; // index of disparity value in disparity_map == 2 (0,2 or 4)
static int DISPARITY_STRENGTH_INDEX = 10; // index of strength data in disparity map ==6
static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6
public static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction)
public static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed
public static int DISPARITY_INDEX_HOR_STRENGTH = 5; // strength for hor mode (emphasis on vertical lines)
public static int DISPARITY_INDEX_VERT = 6; // disparity from correlation of the vertical pairs with center suppressed
public static int DISPARITY_INDEX_VERT_STRENGTH = 7; // strength in vert mode (horizontal lines detection)
public static int DISPARITY_INDEX_POLY = 8; // index of disparity value in disparity_map == 2 (0,2 or 4)
public static int DISPARITY_STRENGTH_INDEX = 10; // index of strength data in disparity map ==6
public static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6
// static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map
// static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels
static int OVEREXPOSED = 12; // index of overexposed fraction of all pixels
static int IMG_DIFF0_INDEX = 13; // index of noise- normalized image difference for port 0 in disparity map
public static int OVEREXPOSED = 12; // index of overexposed fraction of all pixels
public static int IMG_DIFF0_INDEX = 13; // index of noise- normalized image difference for port 0 in disparity map
// static int IMG_TONE_RGB = 17; // 12 entries of r0,r1,r2,r3,g0,g1,g2,g3,b0,b1,b2,b3
static int IMG_DIFFS = 16;
static int IMG_TONES_RGB = 17;
public static int IMG_DIFFS = 16;
public static int IMG_TONES_RGB = 17;
static boolean isCorrBit (int indx) {
return indx <= DISPARITY_STRENGTH_INDEX; // maybe use DISPARITY_VARIATIONS_INDEX?
......@@ -178,7 +178,7 @@ public class ImageDttCPU {
return getDisparityTitles(numSensors, false);
}
static String [] getDisparityTitles(int numSensors, boolean mono) {
public static String [] getDisparityTitles(int numSensors, boolean mono) {
// String [] disparity_titles0 = {
// "int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
// "poly_disp", "poly_y_disp", "strength_disp", "vary_disp","overexp"};
......@@ -200,7 +200,7 @@ public class ImageDttCPU {
String [] getDisparityTitles() {
public String [] getDisparityTitles() {
return getDisparityTitles(numSensors, isMonochrome());
}
......
......@@ -28,6 +28,18 @@ import java.util.Properties;
import com.elphel.imagej.common.GenericJTabbedDialog;
public class ImageDttParameters {
public static final int CORR_SEL_BIT_ALL = 0;
public static final int CORR_SEL_BIT_DIA = 1;
public static final int CORR_SEL_BIT_SQ = 2;
public static final int CORR_SEL_BIT_NEIB = 3;
public static final int CORR_SEL_BIT_HOR = 4;
public static final int CORR_SEL_BIT_VERT = 5;
public static final int CORR_SEL_BIT_LIMIT = 8;
public static final int CORR_SEL_BITS_LIMIT = 3;
// "ImageDtt" tab followed by others
public boolean gpu_mode_debug = true;
public boolean gpu_verify = false; // verify tasks/ input data
......@@ -131,12 +143,14 @@ public class ImageDttParameters {
public boolean mcorr_vert = true; // all vertical (2 pairs for quad, 8 - for lwir16)
public boolean mcorr_vert_multi = true; // all vertical
public int mcorr_limit_sensors = 0; // 0 - no limit, 1: binocular (12,4), 3 - quad (2,6,10,14), 4 -octal (0,2,4,6,8,10,12,14)
//final int corr_sel, // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
public int mcorr_sel_ly = 1; // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
public int mcorr_sel_ly_multi = 2+4+8; // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
public int mcorr_sel_lma = 1; // which pairs to use for LMA (1 - all)
public boolean mcorr_cons_all = true; // consolidate all available pairs
public boolean mcorr_cons_dia = true; // consolidate all having length of a diameter
......@@ -272,7 +286,7 @@ public class ImageDttParameters {
public double lma_ac_offset = 0.015; // add to a,c coefficients for near-lines where A,C could become negative because of window
public double lma_min_ac = 0.05; // minimal of a and C coefficients maximum (measures sharpest point/line)
public double lma_min_min_ac = 0.015; // minimal of a and C coefficients minimum (measures sharpest point)
public double lma_max_area = 30.0; //45.0; // maximal half-area (if > 0.0)
public double lma_max_area = 45.0; //45.0; // maximal half-area (if > 0.0)
public double lma_str_scale = 0.2665; // LWIR16: 0.2 convert lma-generated strength to match previous ones - scale
......@@ -396,6 +410,60 @@ public class ImageDttParameters {
}
public int corrSelEncode(ImageDttParameters img_dtt, int num_sensors) {
return corrSelEncode(
getMcorrAll (num_sensors), // boolean sel_all,
getMcorrDia (num_sensors), // boolean sel_dia,
getMcorrSq (num_sensors), // boolean sel_sq,
getMcorrNeib (num_sensors), // boolean sel_neib,
getMcorrHor (num_sensors), // boolean sel_hor,
getMcorrVert (num_sensors), // boolean sel_vert);
mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
public static int corrSelEncodeAll(int limit_sensors) { // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
return corrSelEncode(
true, // boolean sel_all,
false, // boolean sel_dia,
false, // boolean sel_sq,
false, // boolean sel_neib,
false, // boolean sel_hor,
false, // boolean sel_vert);
limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
public static int corrSelEncode(
boolean sel_all,
boolean sel_dia,
boolean sel_sq,
boolean sel_neib,
boolean sel_hor,
boolean sel_vert,
int limit_sensors) {
return (sel_all ? (1 << CORR_SEL_BIT_ALL): 0) |
(sel_dia ? (1 << CORR_SEL_BIT_DIA): 0) |
(sel_sq ? (1 << CORR_SEL_BIT_SQ): 0) |
(sel_neib ? (1 << CORR_SEL_BIT_NEIB): 0) |
(sel_hor ? (1 << CORR_SEL_BIT_HOR): 0) |
(sel_vert ? (1 << CORR_SEL_BIT_VERT): 0) |
((limit_sensors & ((1 << CORR_SEL_BITS_LIMIT) - 1)) << CORR_SEL_BIT_LIMIT);
}
public static boolean isCorrAll (int sel) { return ((sel >> CORR_SEL_BIT_ALL) & 1) != 0;}
public static boolean isCorrDia (int sel) { return ((sel >> CORR_SEL_BIT_DIA) & 1) != 0;}
public static boolean isCorrSq (int sel) { return ((sel >> CORR_SEL_BIT_SQ) & 1) != 0;}
public static boolean isCorrNeib(int sel) { return ((sel >> CORR_SEL_BIT_NEIB) & 1) != 0;}
public static boolean isCorrHor (int sel) { return ((sel >> CORR_SEL_BIT_HOR) & 1) != 0;}
public static boolean isCorrVert(int sel) { return ((sel >> CORR_SEL_BIT_VERT) & 1) != 0;}
public static int getSensorsLimit(int sel){ return ((sel >> CORR_SEL_BIT_LIMIT) & ((1 << CORR_SEL_BITS_LIMIT) - 1));}
// setCorrPairs(imp.cuas_mcorr_sel);
public void dialogQuestions(GenericJTabbedDialog gd) {
......@@ -601,6 +669,10 @@ public class ImageDttParameters {
" +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert");
gd.addNumericField ("Select correlation pairs for LY for multi cameras", this.mcorr_sel_ly_multi, 0, 3, "",
" +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert");
gd.addNumericField ("Select correlation pairs for LMA", this.mcorr_sel_lma, 0, 3, "",
"Will select from the processed pairs, so 1 will behave as before 09/2025. +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert");
gd.addCheckbox ("Combine all pairs", this.mcorr_cons_all,
"Combine all calculated correlation pairs");
......@@ -997,6 +1069,9 @@ public class ImageDttParameters {
this.mcorr_sel_ly= (int) gd.getNextNumber();
this.mcorr_sel_ly_multi=(int)gd.getNextNumber();
this.mcorr_sel_lma= (int) gd.getNextNumber();
this.mcorr_cons_all = gd.getNextBoolean();
this.mcorr_cons_dia = gd.getNextBoolean();
......@@ -1074,7 +1149,7 @@ public class ImageDttParameters {
this.lmas_min_amp_bg = gd.getNextNumber();
this.lmas_max_rel_rms = gd.getNextNumber();
this.lmas_min_strength = gd.getNextNumber();
this.lmas_min_max_ac = gd.getNextNumber();
this.lmas_min_max_ac = gd.getNextNumber();
this.lmas_min_min_ac = gd.getNextNumber();
this.lmas_max_area = gd.getNextNumber();
......@@ -1242,6 +1317,7 @@ public class ImageDttParameters {
properties.setProperty(prefix+"mcorr_sel_ly", this.mcorr_sel_ly +"");
properties.setProperty(prefix+"mcorr_sel_ly_multi", this.mcorr_sel_ly_multi +"");
properties.setProperty(prefix+"mcorr_sel_lma", this.mcorr_sel_lma +"");
properties.setProperty(prefix+"mcorr_cons_all", this.mcorr_cons_all +"");
properties.setProperty(prefix+"mcorr_cons_dia", this.mcorr_cons_dia +"");
......@@ -1490,6 +1566,7 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"mcorr_sel_ly")!=null) this.mcorr_sel_ly=Integer.parseInt(properties.getProperty(prefix+"mcorr_sel_ly"));
if (properties.getProperty(prefix+"mcorr_sel_ly_multi")!=null) this.mcorr_sel_ly_multi=Integer.parseInt(properties.getProperty(prefix+"mcorr_sel_ly_multi"));
if (properties.getProperty(prefix+"mcorr_sel_lma")!=null) this.mcorr_sel_lma=Integer.parseInt(properties.getProperty(prefix+"mcorr_sel_lma"));
if (properties.getProperty(prefix+"mcorr_cons_all")!=null) this.mcorr_cons_all=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_all"));
if (properties.getProperty(prefix+"mcorr_cons_dia")!=null) this.mcorr_cons_dia=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_dia"));
......@@ -1757,6 +1834,7 @@ public class ImageDttParameters {
idp.mcorr_sel_ly= this.mcorr_sel_ly;
idp.mcorr_sel_ly_multi= this.mcorr_sel_ly_multi;
idp.mcorr_sel_lma= this.mcorr_sel_lma;
idp.mcorr_cons_all= this.mcorr_cons_all;
idp.mcorr_cons_dia= this.mcorr_cons_dia;
......@@ -1893,4 +1971,19 @@ public class ImageDttParameters {
return idp;
}
public void updateFromCuas(IntersceneMatchParameters imp, int num_sens) {
setMcorr(num_sens, imp.cuas_mcorr_sel);
mcorr_sel_lma = imp.cuas_mcorr_sel_lma;
lma_max_rel_rms = imp.cuas_max_rel_rms;
lmas_max_rel_rms= imp.cuas_max_rel_rms;
lma_min_strength = imp.cuas_min_strength;
lmas_min_strength = imp.cuas_min_strength;
lma_ac_offset = imp.cuas_ac_offset;
lmas_min_max_ac = imp.cuas_min_max_ac;
lmas_min_min_ac = imp.cuas_min_min_ac;
}
}
......@@ -1682,6 +1682,7 @@ public class QuadCLT extends QuadCLTCPU {
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scene, //final QuadCLT scene,
ref_scene, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
null, // TpTask [][] tasks,
show_nan, // final boolean show_nan,
threadsMax, // int threadsMax,
debugLevel); // final int debugLevel)
......@@ -1739,6 +1740,7 @@ public class QuadCLT extends QuadCLTCPU {
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scene, //final QuadCLT scene,
ref_scene, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
null, // TpTask [][] tasks,
show_nan, // final boolean show_nan,
ImageDtt.THREADS_MAX, // threadsMax, // int threadsMax,
debugLevel); // final int debugLevel)
......@@ -1801,6 +1803,7 @@ public class QuadCLT extends QuadCLTCPU {
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scene, //final QuadCLT scene,
ref_scene, // final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
null, // TpTask [][] tasks,
show_nan, // final boolean show_nan,
threadsMax, // int threadsMax,
debugLevel); // final int debugLevel)
......@@ -1839,6 +1842,7 @@ public class QuadCLT extends QuadCLTCPU {
double [] scene_atr, // camera orientation relative to world frame
final QuadCLT scene,
final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
TpTask [][] tasks, // should be null or TpTask [2][] - will populate. tasks[1] may be returned as null
final boolean show_nan,
int threadsMax,
final int debugLevel){
......@@ -1957,6 +1961,17 @@ public class QuadCLT extends QuadCLTCPU {
null, // final boolean [] valid_tiles,
threadsMax); // final int threadsMax) // maximal number of threads to launch
}
if (tasks != null) {
tasks[0] = tp_tasks[0];
if (tasks.length > 1) {
if (tp_tasks.length > 1) {
tasks[1] = tp_tasks[1];
} else {
tasks[1] = null;
}
}
}
scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
ImageDtt image_dtt = new ImageDtt(
scene.getNumSensors(),
......
......@@ -6331,6 +6331,13 @@ public class QuadCLTCPU {
return image_data;
}
}
public double [][][] getOrigImageData(){ // does not reset new data
return image_data;
}
public double [][][] getAltImageData(){ // does not reset new data
return image_data_alt;
}
public void setImageData(double [][][] data) {
image_data = data;
......
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