Commit dd1befbb authored by Andrey Filippov's avatar Andrey Filippov

working on rig infinity calibration

parent c8fd13f4
import java.util.Properties;
/**
**
** BiQuadParameters - parameters defining Operation of a two quad camera rig
**
** Copyright (C) 2018 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** BiQuadParameters.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
public class BiQuadParameters {
public boolean rig_mode_debug = true;
public boolean use_poly = true;
public boolean use_xy_poly = true;
public double min_poly_strength = 0.2;
public double min_xy_poly_strength = 1.0; // never
public double inf_min_strength_main = 0.12;
public double inf_min_strength_aux = 0.12;
public double inf_min_strength_rig = 0.25;
public double inf_max_disp_main = 0.15;
public double inf_max_disp_aux = 0.15;
public double inf_max_disp_rig = 0.5; // maybe even higher (2.0) to lock to initially high mismatch
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addCheckbox ("Debug rig/bi-camera functionality ", this.rig_mode_debug,"Enable debugging of the methods related to dual camera rig");
gd.addCheckbox ("Use poly for main/aux/rig correlations (false - CM)", this.use_poly,"Use LMA/polynomial if correlation is strong enough");
gd.addCheckbox ("Use poly for rig X/Y mismatch measurements", this.use_xy_poly,"Use polynomial forX/Y offset measurements if correlation is strong enough");
gd.addNumericField("Use poly mode for disparity if strength is greater than", this.min_poly_strength, 3,6,"",
"Minimal correlation strength to use poly mode (below use CM)");
gd.addNumericField("Use poly mode for X/Y rig correction if strength is greater than", this.min_xy_poly_strength, 3,6,"",
"Minimal correlation strength to use poly mode (below use CM) for measureking X/Y offset at infinity");
gd.addNumericField("Minimal strength for main camera correlation to use for infinity rig adjustment", this.inf_min_strength_main, 3,6,"",
"Do not use tile for infinity adjustment if main correlation strength is less than");
gd.addNumericField("Minimal strength for aux camera correlation to use for infinity rig adjustment", this.inf_min_strength_aux, 3,6,"",
"Do not use tile for infinity adjustment if aux correlation strength is less than");
gd.addNumericField("Minimal strength for inter-camera correlation to use for infinity rig adjustment", this.inf_min_strength_rig, 3,6,"",
"Do not use tile for infinity adjustment if inter-camera correlation strength is less than");
gd.addNumericField("Maximal absolute value of main camera disparity to use for infinity rig adjustment", this.inf_max_disp_main, 3,6,"pix",
"Do not use tile for infinity adjustment if absolute value of the main camera disparity is too high");
gd.addNumericField("Maximal absolute value of aux camera disparity to use for infinity rig adjustment", this.inf_max_disp_aux, 3,6,"pix",
"Do not use tile for infinity adjustment if absolute value of the main camera disparity is too high");
gd.addNumericField("Maximal absolute value of inter-camera disparity to use for infinity rig adjustment", this.inf_max_disp_rig, 3,6,"pix",
"Do not use tile for infinity adjustment if absolute value of the inter-camera disparity is too high");
}
public void dialogAnswers(GenericJTabbedDialog gd) {
this.rig_mode_debug= gd.getNextBoolean();
this.use_poly= gd.getNextBoolean();
this.use_xy_poly= gd.getNextBoolean();
this.min_poly_strength= gd.getNextNumber();
this.min_xy_poly_strength= gd.getNextNumber();
this.inf_min_strength_main= gd.getNextNumber();
this.inf_min_strength_aux= gd.getNextNumber();
this.inf_min_strength_rig= gd.getNextNumber();
this.inf_max_disp_main= gd.getNextNumber();
this.inf_max_disp_aux= gd.getNextNumber();
this.inf_max_disp_rig= gd.getNextNumber();
}
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"rig_mode_debug", this.rig_mode_debug+"");
properties.setProperty(prefix+"use_poly", this.use_poly+"");
properties.setProperty(prefix+"use_xy_poly", this.use_xy_poly+"");
properties.setProperty(prefix+"min_poly_strength", this.min_poly_strength+"");
properties.setProperty(prefix+"min_xy_poly_strength", this.min_xy_poly_strength+"");
properties.setProperty(prefix+"inf_min_strength_main", this.inf_min_strength_main+"");
properties.setProperty(prefix+"inf_min_strength_aux", this.inf_min_strength_aux+"");
properties.setProperty(prefix+"inf_min_strength_rig", this.inf_min_strength_rig+"");
properties.setProperty(prefix+"inf_max_disp_main", this.inf_max_disp_main+"");
properties.setProperty(prefix+"inf_max_disp_aux", this.inf_max_disp_aux+"");
properties.setProperty(prefix+"inf_max_disp_rig", this.inf_max_disp_rig+"");
}
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"rig_mode_debug")!=null) this.rig_mode_debug=Boolean.parseBoolean(properties.getProperty(prefix+"rig_mode_debug"));
if (properties.getProperty(prefix+"use_poly")!=null) this.use_poly=Boolean.parseBoolean(properties.getProperty(prefix+"use_poly"));
if (properties.getProperty(prefix+"use_xy_poly")!=null) this.use_xy_poly=Boolean.parseBoolean(properties.getProperty(prefix+"use_xy_poly"));
if (properties.getProperty(prefix+"min_poly_strength")!=null) this.min_poly_strength=Double.parseDouble(properties.getProperty(prefix+"min_poly_strength"));
if (properties.getProperty(prefix+"min_xy_poly_strength")!=null) this.min_xy_poly_strength=Double.parseDouble(properties.getProperty(prefix+"min_xy_poly_strength"));
if (properties.getProperty(prefix+"inf_min_strength_main")!=null) this.inf_min_strength_main=Double.parseDouble(properties.getProperty(prefix+"inf_min_strength_main"));
if (properties.getProperty(prefix+"inf_min_strength_aux")!=null) this.inf_min_strength_aux=Double.parseDouble(properties.getProperty(prefix+"inf_min_strength_aux"));
if (properties.getProperty(prefix+"inf_min_strength_rig")!=null) this.inf_min_strength_rig=Double.parseDouble(properties.getProperty(prefix+"inf_min_strength_rig"));
if (properties.getProperty(prefix+"inf_max_disp_main")!=null) this.inf_max_disp_main=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_main"));
if (properties.getProperty(prefix+"inf_max_disp_aux")!=null) this.inf_max_disp_aux=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_aux"));
if (properties.getProperty(prefix+"inf_max_disp_rig")!=null) this.inf_max_disp_rig=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_rig"));
}
@Override
public BiQuadParameters clone() throws CloneNotSupportedException {
BiQuadParameters bqp = new BiQuadParameters();
bqp.rig_mode_debug= this.rig_mode_debug;
bqp.use_poly= this.use_poly;
bqp.use_xy_poly= this.use_xy_poly;
bqp.min_poly_strength = this.min_poly_strength;
bqp.min_xy_poly_strength = this.min_xy_poly_strength;
bqp.inf_min_strength_main = this.inf_min_strength_main;
bqp.inf_min_strength_aux = this.inf_min_strength_aux;
bqp.inf_min_strength_rig = this.inf_min_strength_rig;
bqp.inf_max_disp_main = this.inf_max_disp_main;
bqp.inf_max_disp_aux = this.inf_max_disp_aux;
bqp.inf_max_disp_rig = this.inf_max_disp_rig;
return bqp;
}
}
This diff is collapsed.
......@@ -3018,6 +3018,7 @@ public class EyesisCorrectionParameters {
public double [] vertical_xyz = {0.0,1.0,0.0}; // real world up unit vector in camera CS (x - right, y - up, z - to camera};
public ImageDttParameters img_dtt = new ImageDttParameters();
public BiQuadParameters rig = new BiQuadParameters();
public MeasuredLayersFilterParameters mlfp = new MeasuredLayersFilterParameters();
public HashMap<String,Double> z_corr_map = new HashMap<String,Double>();
......@@ -3661,6 +3662,7 @@ public class EyesisCorrectionParameters {
}
img_dtt.setProperties (prefix+"_img_dtt", properties);
mlfp.setProperties (prefix+"_mlfp", properties);
rig.setProperties (prefix+"_rig", properties);
}
public void getProperties(String prefix,Properties properties){
......@@ -4308,6 +4310,7 @@ public class EyesisCorrectionParameters {
}
img_dtt.getProperties (prefix+"_img_dtt", properties);
mlfp.getProperties (prefix+"_mlfp", properties);
rig.getProperties (prefix+"_rig", properties);
}
public boolean showJDialog() {
......@@ -4363,9 +4366,10 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Select all-pair correlation type to use 0 - CM, 1 - poly", this.corr_select, 0);
gd.addTab ("imageDtt", "Setup extra ImageDtt parameters - eventually all will be set that way");
// moved
this.img_dtt.dialogQuestions(gd);
gd.addTab ("Rig", "Parameters for the wide baseline rig with two quad cameras");
this.rig.dialogQuestions(gd);
gd.addTab ("vert/hor", "Enhance detection of horizontal/vertical features (when enh_ortho is enabled for tile");
gd.addMessage("--- Enhance detection of horizontal/vertical features (when enh_ortho is enabled for tile ---");
......@@ -5097,6 +5101,7 @@ public class EyesisCorrectionParameters {
this.img_dtt.dialogAnswers(gd);
this.rig.dialogAnswers(gd);
this.max_corr_double= gd.getNextBoolean();
this.corr_mode= (int) gd.getNextNumber();
......
......@@ -582,6 +582,7 @@ private Panel panel1,
addButton("CLT 2*4 images", panelClt4, color_conf_process);
addButton("CLT 2*4 images - 2", panelClt4, color_conf_process);
addButton("CLT 2*4 images - 3", panelClt4, color_conf_process);
addButton("Rig infinity calibration", panelClt4, color_conf_process);
addButton("AUX show fine", panelClt4, color_configure);
add(panelClt4);
......@@ -4464,6 +4465,12 @@ private Panel panel1,
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
getPairImages2(true);
return;
/* ======================================================================== */
} else if (label.equals("Rig infinity calibration")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
infinityRig();
return;
/* ======================================================================== */
} else if (label.equals("AUX show fine")) {
if (QUAD_CLT == null){
......@@ -4744,9 +4751,7 @@ private Panel panel1,
return true;
}
public boolean getPairImages2( boolean new_mode) {
public boolean prepareRigImages() {
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
QuadCLT.PREFIX,
......@@ -4849,6 +4854,14 @@ private Panel panel1,
if (TWO_QUAD_CLT == null) {
TWO_QUAD_CLT = new TwoQuadCLT();
}
return true;
}
public boolean getPairImages2( boolean new_mode) {
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
if (new_mode) {
if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Calculating combined correlations ++++++++++++++");
......@@ -4860,8 +4873,8 @@ private Panel panel1,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
CHANNEL_GAINS_PARAMETERS_AUX, //CorrectionColorProc.ColorGainsParameters channelGainParameters_aux,
// CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
// CHANNEL_GAINS_PARAMETERS_AUX, //CorrectionColorProc.ColorGainsParameters channelGainParameters_aux,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
......@@ -4901,11 +4914,40 @@ private Panel panel1,
true,
PROPERTIES);
}
return true;
}
public boolean infinityRig() {
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Processing Infinity rig calibration ++++++++++++++");
}
try {
TWO_QUAD_CLT.processInfinityRigs( // actually there is no sense to process multiple image sets. Combine with other processing?
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
return true;
}
public ImagePlus selectCLTImage() {
if (!CLT_PARAMETERS.showJDialog()) return null;
......
......@@ -223,6 +223,70 @@ public class GeometryCorrection {
return rot;
}
/**
* Get derivatives of the auxiliary camera rotation matrix, per axis (azimuth, tilt, roll, zoom)
* d/dx and d/dy should be normalized by z-component of the vector (not derivative)
* @return 2-d array array of derivatives matrices
*/
//TODO: UPDATE to include scales
public Matrix [] getRotDeriveMatrices()
{
Matrix [] rot_derivs = new Matrix [4]; // channel, azimuth-tilt-roll-zoom
double ca = Math.cos(aux_azimuth);
double sa = Math.sin(aux_azimuth);
double ct = Math.cos(aux_tilt);
double st = Math.sin(aux_tilt);
double zoom = (1.0 + aux_zoom);
double cr = Math.cos(aux_roll);
double sr = Math.sin(aux_roll);
double [][] a_az = { // inverted - OK
{ ca, 0.0, sa * ROT_AZ_SGN },
{ 0.0, 1.0, 0.0},
{ -sa* ROT_AZ_SGN, 0.0, ca}};
double [][] a_t = { // inverted - OK
{ 1.0, 0.0, 0.0},
{ 0.0, ct, st * ROT_TL_SGN},
{ 0.0, -st * ROT_TL_SGN, ct}};
double [][] a_r = { // inverted OK
{ cr, sr * ROT_RL_SGN, 0.0},
{ -sr * ROT_RL_SGN, cr, 0.0},
{ 0.0, 0.0, 1.0}};
double [][] a_daz = { // inverted - OK
{ -sa, 0.0, ca * ROT_AZ_SGN },
{ 0.0, 0.0, 0.0},
{ -ca* ROT_AZ_SGN, 0.0, -sa}};
double [][] a_dt = { // inverted - OK
{ 0.0, 0.0, 0.0},
{ 0.0, -st, ct * ROT_TL_SGN},
{ 0.0, -ct * ROT_TL_SGN, -st}};
double [][] a_dr = { // inverted OK
{ -sr * zoom, cr * zoom * ROT_RL_SGN, 0.0},
{ -cr * zoom *ROT_RL_SGN, -sr * zoom, 0.0},
{ 0.0, 0.0, 0.0}};
double [][] a_dzoom = { // inverted OK
{ cr, sr * ROT_RL_SGN, 0.0},
{ -sr * ROT_RL_SGN, cr, 0.0},
{ 0.0, 0.0, 0.0}};
// d/d_az
rot_derivs[0] = (new Matrix(a_r ).times(new Matrix(a_t ).times(new Matrix(a_daz))));
rot_derivs[1] = (new Matrix(a_r ).times(new Matrix(a_dt).times(new Matrix(a_az ))));
rot_derivs[2] = (new Matrix(a_dr).times(new Matrix(a_t ).times(new Matrix(a_az ))));
rot_derivs[3] = (new Matrix(a_dzoom).times(new Matrix(a_t ).times(new Matrix(a_az ))));
return rot_derivs;
}
public void setProperties(String parent_prefix,Properties properties){
String prefix = parent_prefix + RIG_PREFIX;
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
**
** -----------------------------------------------------------------------------**
**
** ImageDtt.java is free software: you can redistribute it and/or modify
** ImageDttParameters.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
......@@ -103,7 +103,7 @@ public class ImageDttParameters {
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addCheckbox ("Enable ImageDtt correlation debug layers", this.corr_mode_debug,
"false - return (old) per-coor correlations, true - replace them with more pairs correlation (new)");
"false - return (old) per-coord correlations, true - replace them with more pairs correlation (new)");
gd.addCheckbox ("Replace CM layer with mixed/new poly one", this.mix_corr_poly);
gd.addNumericField("Use poly mode if strength is greater than", this.min_poly_strength, 3,6,"", "AND condition");
gd.addNumericField("Maximal polynomial approximation half-width", this.max_poly_hwidth, 3,6,"pix", "Maximal polynomial approximation half-width (in both directions), Most now are ~2.0");
......
......@@ -76,6 +76,11 @@ public class QuadCLT {
EyesisCorrectionParameters.CLTParameters clt_parameters,
int threadsMax
){
setTiles(clt_parameters,
imp.getWidth()/clt_parameters.transform_size,
imp.getHeight()/clt_parameters.transform_size,
threadsMax);
/*
if (tp == null){
tp = new TileProcessor(imp.getWidth()/clt_parameters.transform_size,
imp.getHeight()/clt_parameters.transform_size,
......@@ -86,8 +91,29 @@ public class QuadCLT {
clt_parameters.max_overexposure, // double maxOverexposure,
threadsMax);
}
*/
}
public void setTiles (
EyesisCorrectionParameters.CLTParameters clt_parameters,
int tilesX,
int tilesY,
int threadsMax
){
if (tp == null){
tp = new TileProcessor(
tilesX,
tilesY,
clt_parameters.transform_size,
clt_parameters.stSize,
clt_parameters.corr_magic_scale,
clt_parameters.grow_disp_trust,
clt_parameters.max_overexposure, // double maxOverexposure,
threadsMax);
}
}
public QuadCLT(
String prefix,
Properties properties,
......
This diff is collapsed.
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