Commit e24b8d2f authored by Andrey Filippov's avatar Andrey Filippov

Started conversion from quad-camera configuration

parent 3c58184f
......@@ -70,6 +70,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.tileprocessor.CorrVector;
import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.GeometryCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
......@@ -93,6 +94,7 @@ import jcuda.nvrtc.JNvrtc;
import jcuda.nvrtc.nvrtcProgram;
public class GPUTileProcessor {
static int CORR_VECTOR_MAX_LENGTH =19; // TODO: update to fit for 16-sensor
String LIBRARY_PATH = "/usr/local/cuda/targets/x86_64-linux/lib/libcudadevrt.a"; // linux
static String GPU_RESOURCE_DIR = "kernels";
static String [] GPU_KERNEL_FILES = {"dtt8x8.cuh","TileProcessor.cuh"};
......@@ -799,7 +801,9 @@ public class GPUTileProcessor {
cuMemAlloc(gpu_geometry_correction, GeometryCorrection.arrayLength(num_cams) * Sizeof.FLOAT);
cuMemAlloc(gpu_rByRDist, RBYRDIST_LEN * Sizeof.FLOAT);
cuMemAlloc(gpu_rot_deriv, 5*num_cams*3*3 * Sizeof.FLOAT);
cuMemAlloc(gpu_correction_vector, GeometryCorrection.CorrVector.LENGTH * Sizeof.FLOAT);
// cuMemAlloc(gpu_correction_vector, CorrVector.LENGTH * Sizeof.FLOAT);
cuMemAlloc(gpu_correction_vector, CORR_VECTOR_MAX_LENGTH * Sizeof.FLOAT); // update CORR_VECTOR_LENGTH to fit
// Set task array
cuMemAlloc(gpu_tasks, tilesX * tilesY * TPTASK_SIZE * Sizeof.FLOAT);
......@@ -947,7 +951,7 @@ public class GPUTileProcessor {
* Copy extrinsic correction vector to the GPU memory
* @param cv correction vector
*/
public void setExtrinsicsVector(GeometryCorrection.CorrVector cv) {
public void setExtrinsicsVector(CorrVector cv) {
double [] dcv = cv.toFullRollArray();
float [] fcv = new float [dcv.length];
for (int i = 0; i < dcv.length; i++) {
......
......@@ -172,7 +172,7 @@ public class ElphelJp4Reader extends ImageIOReader{
try {
url = new URL(id);
} catch (MalformedURLException e) {
LOGGER.warn("Bad URL1: " + id);
// LOGGER.warn("Bad URL1: " + id); // will try direct file, not an error
}
if (url != null) {
LOGGER.debug("Starting initFile() method, read "+ id +" to memory first");
......
......@@ -30,7 +30,7 @@ import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
//import GeometryCorrection.CorrVector;
//import CorrVector;
import Jama.Matrix;
import ij.ImagePlus;
import ij.ImageStack;
......@@ -2363,7 +2363,7 @@ B = |+dy0 -dy1 -2*dy3 |
int solveCorr_debug = ((clt_parameters.lym_iter == 1) && (clt_parameters.ly_par_sel != 0))? 2 : debugLevel;
GeometryCorrection.CorrVector corr_vector = solveCorr (
CorrVector corr_vector = solveCorr (
clt_parameters.lylw_inf_en, // boolean use_disparity, // if true will ignore disparity data even if available (was false)
clt_parameters.lylw_aztilt_en,// boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.lylw_diff_roll_en,// boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
......@@ -2373,7 +2373,7 @@ B = |+dy0 -dy1 -2*dy3 |
clt_parameters.lylw_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
qc.geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
// 2); // debugLevel); // 2); // 1); // int debugLevel)
solveCorr_debug); // debugLevel); // 2); // 1); // int debugLevel)
......@@ -2926,7 +2926,7 @@ B = |+dy0 -dy1 -2*dy3 |
double [] old_new_rms = new double[1];
boolean apply_extrinsic = true;
int solveCorr_debug = ((clt_parameters.lym_iter == 1) && (clt_parameters.ly_par_sel != 0))? 2 : debugLevel;
GeometryCorrection.CorrVector corr_vector = solveCorr (
CorrVector corr_vector = solveCorr (
clt_parameters.lylw_inf_en, // boolean use_disparity, // if true will ignore disparity data even if available (was false)
clt_parameters.lylw_aztilt_en,// boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.lylw_diff_roll_en,// boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
......@@ -2937,7 +2937,7 @@ B = |+dy0 -dy1 -2*dy3 |
mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
/// geometryCorrection_main, // GeometryCorrection geometryCorrection_main, // if is aux camera using main cameras' coordinates. Disparity is still in aux camera pixels
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
qc.geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
// 2); // debugLevel); // 2); // 1); // int debugLevel)
solveCorr_debug); // debugLevel); // 2); // 1); // int debugLevel)
......@@ -3063,7 +3063,7 @@ B = |+dy0 -dy1 -2*dy3 |
boolean [] par_mask,
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
int debugLevel)
{
boolean dbg_images = debugLevel>1;
......@@ -3214,7 +3214,7 @@ B = |+dy0 -dy1 -2*dy3 |
boolean [] par_mask,
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
int debugLevel)
{
int num_pars = 0;
......@@ -3227,8 +3227,8 @@ B = |+dy0 -dy1 -2*dy3 |
double [] sym_par_m = sym_par_0.clone();
sym_par_p[sym_par] += 0.5 * delta;
sym_par_m[sym_par] -= 0.5 * delta;
GeometryCorrection.CorrVector corr_p = geometryCorrection.getCorrVector(sym_par_p, par_mask);
GeometryCorrection.CorrVector corr_m = geometryCorrection.getCorrVector(sym_par_m, par_mask);
CorrVector corr_p = geometryCorrection.getCorrVector(sym_par_p, par_mask);
CorrVector corr_m = geometryCorrection.getCorrVector(sym_par_m, par_mask);
double [] mv_p = debug_mv_from_sym(
mismatch_list,
geometryCorrection,
......@@ -3261,7 +3261,7 @@ B = |+dy0 -dy1 -2*dy3 |
// boolean [] par_mask,
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
int debugLevel)
{
double [][] dMismatch_dXY = (new Mismatch()).get_dMismatch_dXY(); // just a static array
......@@ -3463,7 +3463,7 @@ B = |+dy0 -dy1 -2*dy3 |
return w;
}
public GeometryCorrection.CorrVector solveCorr (
public CorrVector solveCorr (
boolean use_disparity, // adjust disparity-related extrinsics
boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
......@@ -3474,7 +3474,7 @@ B = |+dy0 -dy1 -2*dy3 |
int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
double [] old_new_rms, // should be double[2]
int debugLevel)
{
......@@ -3502,7 +3502,7 @@ B = |+dy0 -dy1 -2*dy3 |
par_mask, // boolean [] par_mask,
mismatch_list, // ArrayList<Mismatch> mismatch_list,
geometryCorrection, // GeometryCorrection geometryCorrection,
corr_vector, // GeometryCorrection.CorrVector corr_vector)
corr_vector, // CorrVector corr_vector)
debugLevel); // int debugLevel)
// debugLevel = 2;
......@@ -3558,7 +3558,7 @@ B = |+dy0 -dy1 -2*dy3 |
par_mask, // boolean [] par_mask,
mismatch_list, // ArrayList<Mismatch> mismatch_list,
geometryCorrection, // GeometryCorrection geometryCorrection,
corr_vector, // GeometryCorrection.CorrVector corr_vector)
corr_vector, // CorrVector corr_vector)
debugLevel); // int debugLevel)
dbg_xy = doubleNaN(dbg_titles_xy.length, dbg_length); // jacobian dmv/dsym
......@@ -3630,7 +3630,7 @@ B = |+dy0 -dy1 -2*dy3 |
}
//if (par_mask[0]) drslt[0] *= -1.0; //FIXME: Find actual bug, sym[0] corrects in opposite way
GeometryCorrection.CorrVector rslt = geometryCorrection.getCorrVector(drslt, par_mask);
CorrVector rslt = geometryCorrection.getCorrVector(drslt, par_mask);
if (debugLevel > -3){ // change to >0) {
System.out.println("solveCorr() rslt (increment):");
System.out.println(rslt.toString());
......
This diff is collapsed.
......@@ -668,7 +668,9 @@ public class ErsCorrection extends GeometryCorrection {
XYZ_he = gc.XYZ_he; // all cameras coordinates transformed to eliminate heading and elevation (rolls preserved)
XYZ_her = gc.XYZ_her; // = null; // XYZ of the lenses in a corrected CCS (adjusted for to elevation, heading, common_roll)
rXY = gc.rXY; // = null; // XY pairs of the in a normal plane, relative to disparityRadius
rXY_ideal = gc.rXY_ideal; // = {{-0.5, -0.5}, {0.5,-0.5}, {-0.5, 0.5}, {0.5,0.5}};
// rXY_ideal = gc.rXY_ideal; // = {{-0.5, -0.5}, {0.5,-0.5}, {-0.5, 0.5}, {0.5,0.5}};
set_rXY_ideal(gc.get_rXY_ideal()); //)
cameraRadius = gc.cameraRadius; // =0; // average distance from the "mass center" of the sensors to the sensors
disparityRadius = gc.disparityRadius; // 150.0; // distance between cameras to normalize disparity units to. sqrt(2)*disparityRadius for quad camera (~=150mm)?
rByRDist = gc.rByRDist; // =null;
......@@ -689,7 +691,8 @@ public class ErsCorrection extends GeometryCorrection {
XYZ_he = clone2d(XYZ_he);
XYZ_her = clone2d(XYZ_her);
rXY = clone2d(rXY);
rXY_ideal = clone2d(rXY_ideal);
// rXY_ideal = clone2d(rXY_ideal);
set_rXY_ideal(clone2d(gc.get_rXY_ideal())); //)
rByRDist = clone1d(rByRDist); // probably it is not needed
extrinsic_corr = extrinsic_corr.clone();
if (rigOffset!=null) rigOffset = rigOffset.clone();
......
......@@ -67,7 +67,7 @@ public class ExtrinsicAdjustment {
private boolean [] force_disparity = null; // boolean [] force_disparity, // same dimension as dsdn, true if disparity should be controlled
private double pure_weight; // weight of samples only
// private double [] values;
private GeometryCorrection.CorrVector corr_vector = null;
private CorrVector corr_vector = null;
private boolean [] par_mask = null;
private boolean use_rig_offsets = false;
private double [][] measured_dsxy = null;
......@@ -217,7 +217,7 @@ public class ExtrinsicAdjustment {
titles);
}
public GeometryCorrection.CorrVector solveCorr (
public CorrVector solveCorr (
double marg_fract, // part of half-width, and half-height to reduce weights
boolean use_disparity, // adjust disparity-related extrinsics
double inf_min_disparity, // minimal disparity for infinity (from average, possibly tilted)
......@@ -256,7 +256,7 @@ public class ExtrinsicAdjustment {
double [][] measured_dsxy_in, //
boolean [] force_disparity_in, // boolean [] force_disparity,
boolean use_main, // corr_rots_aux != null;
GeometryCorrection.CorrVector corr_vector_meas,
CorrVector corr_vector_meas,
double [] old_new_rms, // should be double[2]
int debugLevel)
{
......@@ -456,7 +456,7 @@ public class ExtrinsicAdjustment {
private double [][] getXYNondistorted(
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
boolean set_dydisp){
int clusters =clustersX * clustersY;
Matrix [] corr_rots = corr_vector.getRotMatrices(); // get array of per-sensor rotation matrices
......@@ -1347,7 +1347,7 @@ public class ExtrinsicAdjustment {
}
private double [] getFx(
GeometryCorrection.CorrVector corr_vector)
CorrVector corr_vector)
{
int clusters = clustersX * clustersY;
Matrix [] corr_rots = corr_vector.getRotMatrices(); // get array of per-sensor rotation matrices
......@@ -1383,7 +1383,7 @@ public class ExtrinsicAdjustment {
}
private double [][] getJacobianTransposed(
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
double delta){
int clusters = clustersX * clustersY;
int num_pars = getNumPars();
......@@ -1392,9 +1392,9 @@ public class ExtrinsicAdjustment {
for (int par = 0; par < num_pars; par++) {
double [] pars = new double[num_pars];
pars[par] = delta;
GeometryCorrection.CorrVector corr_delta = geometryCorrection.getCorrVector(pars, par_mask);
GeometryCorrection.CorrVector corr_vectorp = corr_vector.clone();
GeometryCorrection.CorrVector corr_vectorm = corr_vector.clone();
CorrVector corr_delta = geometryCorrection.getCorrVector(pars, par_mask);
CorrVector corr_vectorp = corr_vector.clone();
CorrVector corr_vectorm = corr_vector.clone();
corr_vectorp.incrementVector(corr_delta, 0.5);
corr_vectorm.incrementVector(corr_delta, -0.5);
double [] fx_p = getFx(corr_vectorp);
......@@ -1440,7 +1440,7 @@ public class ExtrinsicAdjustment {
private double dbgJacobians(
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
double delta,
boolean graphic) {
// delta *= 0.1;
......@@ -1609,7 +1609,7 @@ public class ExtrinsicAdjustment {
double max_reasonable = 100.0;
double [][] ers_tilt_az = getMovingObjects( // will output null if ERS tilt or roll are disabled
corr_vector, // GeometryCorrection.CorrVector corr_vector,
corr_vector, // CorrVector corr_vector,
null ); // double [] fx
boolean [] moving_maybe = null;
if (ers_tilt_az != null) {
......@@ -1716,11 +1716,11 @@ public class ExtrinsicAdjustment {
private double [][] getMovingObjects(
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
double [] fx // or null;
) {
int ers_tilt_index = getParIndex(GeometryCorrection.CorrVector.IMU_INDEX);
int ers_azimuth_index = getParIndex(GeometryCorrection.CorrVector.IMU_INDEX + 1);
int ers_tilt_index = getParIndex(corr_vector. getIMUIndex());
int ers_azimuth_index = getParIndex(corr_vector. getIMUIndex() + 1);
if ((ers_tilt_index < 0) || (ers_azimuth_index < 0)) {
return null;
}
......@@ -1965,7 +1965,7 @@ public class ExtrinsicAdjustment {
private void dbgXY(
GeometryCorrection.CorrVector corr_vector,
CorrVector corr_vector,
String title) {
int gap = 10; //pix
int clusters = clustersX * clustersY;
......@@ -2019,7 +2019,7 @@ public class ExtrinsicAdjustment {
private double [][] getJacobianTransposed(
GeometryCorrection.CorrVector corr_vector)
CorrVector corr_vector)
{
if (dbg_delta > 0.0) {
return getJacobianTransposed(corr_vector, dbg_delta); // running LMA with delta
......@@ -2195,7 +2195,7 @@ public class ExtrinsicAdjustment {
// TODO: Restore/implement
if (debug_level > 3) {
dbgJacobians(
corr_vector, // GeometryCorrection.CorrVector corr_vector,
corr_vector, // CorrVector corr_vector,
1E-5, // double delta,
true); //boolean graphic)
}
......@@ -2251,9 +2251,9 @@ public class ExtrinsicAdjustment {
}
double [] delta = mdelta.getColumnPackedCopy();
GeometryCorrection.CorrVector corr_delta = geometryCorrection.getCorrVector(delta, par_mask);
CorrVector corr_delta = geometryCorrection.getCorrVector(delta, par_mask);
GeometryCorrection.CorrVector new_vector = this.corr_vector.clone();
CorrVector new_vector = this.corr_vector.clone();
double scale = 1.0;
new_vector.incrementVector(corr_delta, scale); // ok = false if there are nay NaN-s
......@@ -2294,7 +2294,7 @@ public class ExtrinsicAdjustment {
this.last_rms = getWYmFxRms(this.last_ymfx); // modifies this.last_ymfx
if (debug_level > 2) {
dbgJacobians(
corr_vector, // GeometryCorrection.CorrVector corr_vector,
corr_vector, // CorrVector corr_vector,
1E-5, // double delta,
true); //boolean graphic)
}
......
......@@ -543,8 +543,8 @@ public class MLStats {
null // EyesisCorrectionParameters.CorrectionParameters correctionsParameters
);
System.out.println(indx+": model:"+model+", version:"+version+", name: "+name);
GeometryCorrection.CorrVector cvm = qcm.geometryCorrection.getCorrVector();
GeometryCorrection.CorrVector cva = qca.geometryCorrection.getCorrVector();
CorrVector cvm = qcm.geometryCorrection.getCorrVector();
CorrVector cva = qca.geometryCorrection.getCorrVector();
*/
indx++;
}
......@@ -616,9 +616,15 @@ public class MLStats {
String fmt = "\t"+(inPixels ? "%8.4f":(inMrad?"%8.4f":"%8.2f"));
String fmt_angle = "\t%8.3f";
String fmt_len = "\t%8.3f";
int num_sym = showZooms? GeometryCorrection.CorrVector.IMU_INDEX:GeometryCorrection.CorrVector.ZOOM_INDEX; // update
if (showERS) num_sym = GeometryCorrection.CorrVector.LENGTH;
// int num_sym = showZooms? CorrVector.IMU_INDEX:CorrVector.ZOOM_INDEX; // update
// if (showERS) num_sym = CorrVector.LENGTH;
int num_chn_m = eyesis_corrections_main.getNumChannels();
int num_chn_a = eyesis_corrections_aux.getNumChannels();
int num_sym_m = showZooms? CorrVector.getIMUIndex(num_chn_m):CorrVector.getZoomIndex(num_chn_m);
if (showERS) num_sym_m = CorrVector.getLength(num_chn_m);
int num_sym_a = showZooms? CorrVector.getIMUIndex(num_chn_a):CorrVector.getZoomIndex(num_chn_a);
if (showERS) num_sym_a = CorrVector.getLength(num_chn_a);
//eyesis_corrections_main
class ModVerString{
String model;
String version;
......@@ -658,10 +664,10 @@ public class MLStats {
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
for (int i = 0; i < num_sym_m; i++) {
header+=String.format("\tsym%02d-m", i);
}
num_col+=num_sym;
num_col+=num_sym_m;
}
if (showAux) {
......@@ -682,10 +688,10 @@ public class MLStats {
num_col+=6;
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
for (int i = 0; i < num_sym_a; i++) {
header+=String.format("\tsym%02d-a", i);
}
num_col+=num_sym;
num_col+=num_sym_a;
}
}
if (showRigATR) {
......@@ -753,8 +759,19 @@ public class MLStats {
null // EyesisCorrectionParameters.CorrectionParameters correctionsParameters
);
System.out.println(indx+": model:"+model+", version:"+version+", name: "+name);
GeometryCorrection.CorrVector cvm = qcm.geometryCorrection.getCorrVector();
GeometryCorrection.CorrVector cva = qca.geometryCorrection.getCorrVector();
CorrVector cvm = qcm.geometryCorrection.getCorrVector();
CorrVector cva = qca.geometryCorrection.getCorrVector();
int cvm_azimuth_index = cvm.getAzimuthIndex();
int cva_azimuth_index = cva.getAzimuthIndex();
int cvm_tilt_index = cvm.getTiltIndex();
int cva_tilt_index = cva.getTiltIndex();
int cvm_roll_index = cvm.getRollIndex();
int cva_roll_index = cva.getRollIndex();
int cvm_zoom_index = cvm.getZoomIndex();
int cva_zoom_index = cva.getZoomIndex();
int cvm_imu_index = cvm.getIMUIndex();
int cva_imu_index = cva.getIMUIndex();
// double [] vect_main = qcm.geometryCorrection.getCorrVector().toArray();
StringBuffer sb = new StringBuffer();
int ncol = 0;
......@@ -764,7 +781,7 @@ public class MLStats {
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.AZIMUTH_INDEX, inPixels);
v[i] = scale * cvm.getExtrinsicParameterValue(i+cvm_azimuth_index, inPixels); // CorrVector.AZIMUTH_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // azimuths
......@@ -775,7 +792,7 @@ public class MLStats {
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.TILT_INDEX, inPixels);
v[i] = scale * cvm.getExtrinsicParameterValue(i+cvm_tilt_index, inPixels); // CorrVector.TILT_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // tilts
......@@ -786,7 +803,7 @@ public class MLStats {
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ROLL_INDEX, inPixels);
v[i] = scale * cvm.getExtrinsicParameterValue(i+cvm_roll_index, inPixels); // CorrVector.ROLL_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // rolls
......@@ -799,7 +816,7 @@ public class MLStats {
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ZOOM_INDEX, inPixels);
v[i] = scale * cvm.getExtrinsicParameterValue(i+cvm_zoom_index, inPixels); // CorrVector.ZOOM_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // zooms
......@@ -812,7 +829,7 @@ public class MLStats {
if (showERS) { // main camera
double [] v = new double[6];
for (int i = 0; i < v.length ; i++) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.IMU_INDEX, inPixels);
v[i] = scale * cvm.getExtrinsicParameterValue(i+cvm_imu_index, inPixels); // CorrVector.IMU_INDEX, inPixels);
sb.append(String.format(fmt,v[i])); // zooms
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
......@@ -821,7 +838,7 @@ public class MLStats {
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
for (int i = 0; i < num_sym_m; i++) {
double v = scale * cvm.getExtrinsicSymParameterValue(i, inPixels);
sb.append(String.format(fmt,v)); // sym parameters
fmts [ncol] = fmt;
......@@ -835,7 +852,7 @@ public class MLStats {
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.AZIMUTH_INDEX, inPixels);
v[i] = scale * cva.getExtrinsicParameterValue(i+cva_azimuth_index, inPixels); // CorrVector.AZIMUTH_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // azimuths
......@@ -846,7 +863,7 @@ public class MLStats {
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.TILT_INDEX, inPixels);
v[i] = scale * cva.getExtrinsicParameterValue(i+cva_tilt_index, inPixels); // CorrVector.TILT_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // tilts
......@@ -857,7 +874,7 @@ public class MLStats {
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ROLL_INDEX, inPixels);
v[i] = scale * cva.getExtrinsicParameterValue(i+cva_roll_index, inPixels); // CorrVector.ROLL_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // rolls
......@@ -870,7 +887,7 @@ public class MLStats {
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ZOOM_INDEX, inPixels);
v[i] = scale * cva.getExtrinsicParameterValue(i+cva_zoom_index, inPixels); // CorrVector.ZOOM_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // zooms
......@@ -882,7 +899,7 @@ public class MLStats {
if (showERS) { // main camera
double [] v = new double[6];
for (int i = 0; i < v.length ; i++) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.IMU_INDEX, inPixels);
v[i] = scale * cva.getExtrinsicParameterValue(i+cva_imu_index, inPixels); // CorrVector.IMU_INDEX, inPixels);
sb.append(String.format(fmt,v[i])); // zooms
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
......@@ -891,7 +908,7 @@ public class MLStats {
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
for (int i = 0; i < num_sym_a; i++) {
double v = scale * cva.getExtrinsicSymParameterValue(i, inPixels);
sb.append(String.format(fmt,v)); // sym parameters
fmts [ncol] = fmt;
......
......@@ -58,7 +58,7 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc;
import com.elphel.imagej.correction.EyesisCorrections;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.tileprocessor.GeometryCorrection.CorrVector;
import com.elphel.imagej.tileprocessor.CorrVector;
import com.elphel.imagej.x3d.export.WavefrontExport;
import com.elphel.imagej.x3d.export.X3dOutput;
......@@ -615,7 +615,7 @@ public class QuadCLTCPU {
this.correctionsParameters = correctionsParameters;
this.properties = properties;
is_aux = prefix.equals(PREFIX_AUX);
getProperties(prefix);
getProperties(prefix); // failed with aux
}
public static Properties loadProperties(
......@@ -857,8 +857,9 @@ public class QuadCLTCPU {
geometryCorrection.pixelSize = sensors[0].pixelSize;
geometryCorrection.distortionRadius = sensors[0].distortionRadius;
for (int i = CorrVector.LENGTH_ANGLES; i < CorrVector.LENGTH; i++){
}
// What was that below? Started smth?
// for (int i = CorrVector.LENGTH_ANGLES; i < CorrVector.LENGTH; i++){
// }
// set common distportion parameters
geometryCorrection.setDistortion(
f_avg, // sensors[0].focalLength,
......@@ -923,13 +924,16 @@ public class QuadCLTCPU {
// calcualte reverse distortion as a table to be linear interpolated (now cubic!)
geometryCorrection.calcReverseDistortionTable();
if (numSensors == 4){
// if (numSensors == 4){
geometryCorrection.adustSquare();
System.out.println("Adjusted camera to orient X Y along the sides of a square");
System.out.println("Adjusted camera to orient X Y along the sides of a square (now univerasal), numSensors = "+numSensors);
/*
} else {
System.out.println("============= Cannot adustSquare() as it requires exactly 4 sensors, "+numSensors+" provided ==========");
return false; // not used in lwir
System.out.println("Keeping as it was");
// return false; // not used in lwir
}
*/
// Print parameters
if (debugLevel > 0){
geometryCorrection.listGeometryCorrection(debugLevel > 1);
......@@ -5264,7 +5268,7 @@ public class QuadCLTCPU {
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
double inf_min_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_min_narrow :clt_parameters.ly_inf_min_broad;
double inf_max_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_max_narrow :clt_parameters.ly_inf_max_broad;
GeometryCorrection.CorrVector corr_vector = ea.solveCorr (
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
......@@ -5307,7 +5311,7 @@ public class QuadCLTCPU {
dsxy, // double [][] measured_dsxy,
null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel)
......@@ -5316,7 +5320,7 @@ public class QuadCLTCPU {
System.out.println(geometryCorrection.getCorrVector().toString());
}
if (corr_vector != null) {
GeometryCorrection.CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
if (debugLevel > -2){
System.out.println("New extrinsic corrections:");
System.out.println(corr_vector.toString());
......@@ -6337,16 +6341,22 @@ public class QuadCLTCPU {
*/
public void resetExtrinsicCorr( // not used in lwir
public void resetExtrinsicCorr( // not used in lwir // only manual commands
CLTParameters clt_parameters)
{
if (extrinsic_vect != null) {
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 0] = 0.0;
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 1] = 0.0;
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 2] = 0.0;
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 3] = 0.0;
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 4] = 0.0;
extrinsic_vect [GeometryCorrection.CorrVector.IMU_INDEX + 5] = 0.0;
for (int i = 0; i < extrinsic_vect.length; i++) {
extrinsic_vect [i] = 0.0;
}
/*
int imu_index = extrinsic_vect.getIMUIndex();
extrinsic_vect [CorrVector.IMU_INDEX + 0] = 0.0;
extrinsic_vect [CorrVector.IMU_INDEX + 1] = 0.0;
extrinsic_vect [CorrVector.IMU_INDEX + 2] = 0.0;
extrinsic_vect [CorrVector.IMU_INDEX + 3] = 0.0;
extrinsic_vect [CorrVector.IMU_INDEX + 4] = 0.0;
extrinsic_vect [CorrVector.IMU_INDEX + 5] = 0.0;
*/
}
if (geometryCorrection != null){
geometryCorrection.resetCorrVectorERS();
......@@ -8406,7 +8416,7 @@ public class QuadCLTCPU {
debugLevel); // final int debugLevel)
}
GeometryCorrection.CorrVector corr_vector = ea.solveCorr (
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
......@@ -8450,7 +8460,7 @@ public class QuadCLTCPU {
scan.getLazyEyeData(), // dsxy, // double [][] measured_dsxy,
scan.getLazyEyeForceDisparity(), // null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel) >=2 to show images
......@@ -8459,7 +8469,7 @@ public class QuadCLTCPU {
System.out.println(geometryCorrection.getCorrVector().toString());
}
if (corr_vector != null) {
GeometryCorrection.CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
comp_diff = diff_corr.getNorm();
if (debugLevel > -2){
......@@ -12377,7 +12387,7 @@ public class QuadCLTCPU {
boolean debug_img = false;
int debugLevelInner = -5;
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
GeometryCorrection.CorrVector corr_vector = geometryCorrection.getCorrVector().clone();
CorrVector corr_vector = geometryCorrection.getCorrVector().clone();
double [] curr_corr_arr = corr_vector.toArray();
int clusters = ea.clustersX * ea.clustersY;
int num_ly = ExtrinsicAdjustment.INDX_LENGTH; // scan.getLazyEyeData().length;
......@@ -12407,8 +12417,8 @@ public class QuadCLTCPU {
// perform asymmetric delta
double [] par_inc = new double [num_pars];
par_inc[npar] = delta * parameter_scales[npar];
GeometryCorrection.CorrVector corr_delta = geometryCorrection.getCorrVector(par_inc,null); // , par_mask); all parameters
GeometryCorrection.CorrVector corr_vectorp = corr_vector.clone();
CorrVector corr_delta = geometryCorrection.getCorrVector(par_inc,null); // , par_mask); all parameters
CorrVector corr_vectorp = corr_vector.clone();
corr_vectorp.incrementVector(corr_delta, 1.0); // 0.5 for p/m
geometryCorrection.setCorrVector(corr_vectorp) ;
double rdelta = 1.0/ par_inc[npar];
......
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