Commit 5e90425c authored by Andrey Filippov's avatar Andrey Filippov

Grid matching for secondary (LWIR) sensors

parent 726f3d95
......@@ -1520,9 +1520,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
for (;(endIndex<enabled.length) && !allImages && !enabled[endIndex];endIndex++); // advance over disabled images
GenericDialog gd=new GenericDialog("Select images "+startIndex+"..."+(endIndex-1));
for (int i=startIndex;i<endIndex;i++) if (allImages || enabled[i]){
gd.addCheckbox (i+" - "+(this.distortionCalibrationData.gIP[i].enabled?"":"(disabled) ")+
gd.addCheckbox (i+ " ("+this.distortionCalibrationData.gIP[i].getSetNumber()+
"."+this.distortionCalibrationData.gIP[i].getChannel()+")"+
" - "+(this.distortionCalibrationData.gIP[i].enabled?"":"(disabled) ")+
IJ.d2s(this.distortionCalibrationData.gIP[i].timestamp,6)+
": "+this.distortionCalibrationData.gIP[i].channel+
" matched "+this.distortionCalibrationData.gIP[i].matchedPointers+" pointers"+
", hinted state: "+((hintedMatch[i]<0)?"undefined":((hintedMatch[i]==0)?"failed":((hintedMatch[i]==1)?"orientation":"orientation and translation"))),
selection[i]);
......@@ -1852,7 +1853,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
// gd.addCheckbox("Select images with estimated orientation", selectEstimated);
// gd.addCheckbox("Select new enabled images", selectNewEnabled);
if (this.distortionCalibrationData.hasSmallSensors()) {
gd.addMessage("=== Filter selection by High/Low resolution sensors (such as VNIR/LWIR)");
gd.addMessage("=== Filter selection by High/Low resolution sensors (such as EO/LWIR)");
gd.addCheckbox("Select high-res sensors", true);
gd.addCheckbox("Select low-res sensors", true);
}
......@@ -1977,7 +1978,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
* @param useParameters Select parameters for this series
* @param askNextSeries Ask for next series number
* @param zeroAndOther use 2 channels 0 and "other", propagate settings for channel 1 to all the rest
* For low/high res (LWIR/VNIR) - use first /other for each class
* For low/high res (LWIR/EO) - use first /other for each class
* @return -2 - cancel, -1, done, otherwise - number of step to edit
*/
......@@ -2055,7 +2056,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
// sub(other): their group number - no, 0 - later add this.definedModesAll.length to master subcamera
// not zeroAndOther:
// non-sub - -1:
// sub(>0): subCam-1 (previous index) - will suggest any with smaller index - may be useless with lwir < vnir indices
// sub(>0): subCam-1 (previous index) - will suggest any with smaller index - may be useless with lwir < eo indices
// int subMaxNum = (this.distortionCalibrationData.isSubcameraParameter(parIndex) && (subCam > 0)) ? (zeroAndOther? 0 : (subCam-1)):-1;
int subMaxNum = -1;
if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters
......@@ -2120,7 +2121,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
* @param useParameters Select parameters for this series
* @param askNextSeries Ask for next series number
* @param zeroAndOther use 2 channels 0 and "other", propagate settings for channel 1 to all the rest
* Updated for more groups (up to 4 in LWIR/VNIR) - use 1 channel for each group, propagate to the rest of the group
* Updated for more groups (up to 4 in LWIR/EO) - use 1 channel for each group, propagate to the rest of the group
* @return -2 - cancel, -1, done, otherwise - number of step to edit
*/
public int selectStrategyStep(
......@@ -2187,7 +2188,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
for (int i=0;i<this.distortionCalibrationData.eyesisCameraParameters.numStations;i++) gd.addCheckbox("Station "+i, constrainByStation[i]);
}
if (this.distortionCalibrationData.hasSmallSensors()) {
gd.addMessage("Constrain (select/remove all) by High/Low resolution sensors (such as VNIR/LWIR)");
gd.addMessage("Constrain (select/remove all) by High/Low resolution sensors (such as EO/LWIR)");
gd.addCheckbox("Select high-res sensors", true);
gd.addCheckbox("Select low-res sensors", true);
}
......@@ -2272,7 +2273,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
// sub(other): their group number - no, 0
// not zeroAndOther:
// non-sub - -1:
// sub(>0): subCam-1 (previous index) - will suggest any with smaller index - may be useless with lwir < vnir indices
// sub(>0): subCam-1 (previous index) - will suggest any with smaller index - may be useless with lwir < eo indices
// int subMaxNum = (this.distortionCalibrationData.isSubcameraParameter(parIndex) && (subCam > 0)) ? (zeroAndOther? 0 : (subCam-1)):-1;
int subMaxNum = -1;
if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters
......
......@@ -989,7 +989,9 @@ horizontal axis:
// TODO: Set initial values for the goniometer angles from the sensor
// (channel) number, average them if there are several in the list
lensDistortions.LevenbergMarquardt(false); // skip dialog
lensDistortions.LevenbergMarquardt(
false, // skip dialog
false); // new: dry_run use it here?
if (debug_level > 0)
System.out.println("Finished LMA at "
+ IJ.d2s(0.000000001 * (System.nanoTime() - startTime), 3));
......
......@@ -5,9 +5,9 @@ import java.util.Properties;
import com.elphel.imagej.cameras.EyesisSubCameraParameters;
import com.elphel.imagej.common.WindowTools;
import Jama.Matrix;
import ij.IJ;
import ij.gui.GenericDialog;
import Jama.Matrix;
//import EyesisCameraParameters;
//import Distortions.EyesisSubCameraParameters;
......@@ -97,24 +97,25 @@ import Jama.Matrix;
}
}
public LensDistortionParameters(
// LensDistortionParameters lensDistortionParameters,
boolean isTripod,
boolean cartesian,
double pixelSize,
double distortionRadius,
double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
double [] parVect,
boolean [] mask, // calculate only selected derivatives (all parVect values are still
int debugLevel
// boolean calculateDerivatives // calculate this.interParameterDerivatives -derivatives array (false - just this.values)
){
this.debugLevel=debugLevel;
lensCalcInterParamers( // changed name to move calcInterParamers method from enclosing class
this,
isTripod,
cartesian,
pixelSize,
distortionRadius,
interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
parVect,
mask // calculate only selected derivatives (all parVect values are still
// boolean calculateDerivatives // calculate this.interParameterDerivatives -derivatives array (false - just this.values)
);
}
......@@ -197,6 +198,7 @@ import Jama.Matrix;
null // r_od,
);
}
@Override
public LensDistortionParameters clone() {
return new LensDistortionParameters(
this.focalLength,
......@@ -1861,6 +1863,8 @@ dPXmmc/dphi=
LensDistortionParameters lensDistortionParameters,
boolean isTripod,
boolean cartesian,
double pixelSize,
double distortionRadius,
double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
double [] parVect,
boolean [] mask // calculate only selected derivatives (all parVect values are still
......@@ -2056,6 +2060,10 @@ dPXmmc/dphi=
// System.out.println("interParameterDerivatives[0]="+sprintfArray(interParameterDerivatives[0]));
}
double [] extrinsicParams=parametersFromMAMB(MA,MB); // all after 6 are 0;
lensDistortionParameters.pixelSize = pixelSize;
lensDistortionParameters.distortionRadius = distortionRadius;
lensDistortionParameters.distance=extrinsicParams[2];
lensDistortionParameters.x0=extrinsicParams[0];
lensDistortionParameters.y0=extrinsicParams[1];
......@@ -2087,21 +2095,8 @@ dPXmmc/dphi=
lensDistortionParameters.r_od[i][0]=parVect[index++];
lensDistortionParameters.r_od[i][1]=parVect[index++];
}
/*
for (double [] row :lensDistortionParameters.r_xy){
row[0]=parVect[index++];
row[1]=parVect[index++];
}
for (double [] row :lensDistortionParameters.r_od){
row[0]=parVect[index++];
row[1]=parVect[index++];
}
*/
///
// public double [][] r_xy=null; // only 6, as for the first term delta x, delta y ==0
// public double [][] r_od=null; // ortho
lensDistortionParameters.recalcCommons(); // uncliding lensDistortionParameters.r_xyod
lensDistortionParameters.recalcCommons(); // uncluding lensDistortionParameters.r_xyod
if (this.debugLevel>2){
......@@ -2816,4 +2811,3 @@ dPXmmc/dphi=
public int getNumInputs(){return numInputs;}
public int getNumOutputs(){return numOutputs;}
}
\ No newline at end of file
......@@ -5476,7 +5476,7 @@ public class EyesisCorrectionParameters {
gd.addMessage ("Unity up vector in camera coordinate system (x - right, y - up, z - to camera): {"+
this.vertical_xyz[0]+","+this.vertical_xyz[1]+","+this.vertical_xyz[2]+"}");
gd.addTab ("LWIR", "parameters for LWIR/VNIR 8-camera rig");
gd.addTab ("LWIR", "parameters for LWIR/EO 8-camera rig");
this.lwir.dialogQuestions(gd);
// gd.buildDialog();
......
......@@ -362,4 +362,12 @@ import java.util.Properties;
updateCartesian();
this.cartesian = cartesian;
}
public double getPixelSize() {
return this.pixelSize;
}
public double getDistortionRadius() {
return this.distortionRadius;
}
}
......@@ -496,12 +496,12 @@ public class LwirReader {
if (lrp.lwir_ffc) {
calibrate(lrp); // seems to work. test calibration duration and if any images are sent during calibration
}
int num_frames = lrp.avg_number + lrp.vnir_lag + 2 * lrp.max_frame_diff;
int num_frames = lrp.avg_number + lrp.eo_lag + 2 * lrp.max_frame_diff;
ImagePlus [][] imps = readAllMultiple(
num_frames,
// lrp.lwir_telemetry,
false, // final boolean show,
lrp.vnir_scale);
lrp.eo_scale);
if (imps == null) {
LOGGER.error("acquire(): failed to acquire images");
return null;
......@@ -521,9 +521,9 @@ public class LwirReader {
LOGGER.warn(String.format("LWIR channel %d time from FFC: %.3f", chn, after_ffc[chn]));
}
int [] lags = new int [lrp.lwir_channels.length + lrp.vnir_channels.length];
int [] lags = new int [lrp.lwir_channels.length + lrp.eo_channels.length];
for (int i = 0; i < lags.length; i++) {
lags[i] = (i >= lrp.lwir_channels.length) ? lrp.vnir_lag : 0;
lags[i] = (i >= lrp.lwir_channels.length) ? lrp.eo_lag : 0;
}
ImagePlus [][] imps_sync = matchSets(
imps,
......@@ -605,10 +605,10 @@ public class LwirReader {
public boolean programLWIRCamera(LwirReaderParameters lrp) {
int lwir_master_port = 0;
int vnir_master_port = 0;
int eo_master_port = 0;
int num_lwir = lrp.lwir_channels.length;
int num_vnir = lrp.vnir_channels.length;
final String [] urls = new String [num_lwir + num_vnir];
int num_eo = lrp.eo_channels.length;
final String [] urls = new String [num_lwir + num_eo];
for (int chn:lrp.lwir_channels) {
urls[chn] = "http://"+lrp.lwir_ip+"/parsedit.php?immediate&sensor_port="+chn+
"&BITS=16"+
......@@ -623,21 +623,21 @@ public class LwirReader {
"&XMIT_TIMESTAMP=1*0";
}
}
for (int chn:lrp.vnir_channels) {
for (int chn:lrp.eo_channels) {
int minExposure=10; // usec
int maxExposure=1000000; //usec
int minGain=(int) (0x10000*1.0);
int maxGain=(int) (0x10000*15.75);
int minScale=0;
int maxScale=(int) (0x10000*4.0);
int exposure= (int) (Math.round(1000*lrp.vnir_exposure_ms * lrp.vnir_exp_corr[chn]));
int autoExposureMax= (int) (Math.round(1000*lrp.vnir_max_autoexp_ms));
int gain= (int) (Math.round(0x10000*lrp.vnir_gain_g));
int rScale= (int) (Math.round(0x10000*lrp.vnir_gain_rg*lrp.vnir_gcorr_rbgb[3*chn+0]));
int bScale= (int) (Math.round(0x10000*lrp.vnir_gain_bg*lrp.vnir_gcorr_rbgb[3*chn+1]));
int gScale= (int) (Math.round(0x10000* lrp.vnir_gcorr_rbgb[3*chn+2]));
int autoExp= lrp.vnir_autoexp?1:0;
int autoWB= lrp.vnir_whitebal?1:0;
int exposure= (int) (Math.round(1000*lrp.eo_exposure_ms * lrp.eo_exp_corr[chn]));
int autoExposureMax= (int) (Math.round(1000*lrp.eo_max_autoexp_ms));
int gain= (int) (Math.round(0x10000*lrp.eo_gain_g));
int rScale= (int) (Math.round(0x10000*lrp.eo_gain_rg*lrp.eo_gcorr_rbgb[3*chn+0]));
int bScale= (int) (Math.round(0x10000*lrp.eo_gain_bg*lrp.eo_gcorr_rbgb[3*chn+1]));
int gScale= (int) (Math.round(0x10000* lrp.eo_gcorr_rbgb[3*chn+2]));
int autoExp= lrp.eo_autoexp?1:0;
int autoWB= lrp.eo_whitebal?1:0;
if (exposure<minExposure) exposure=minExposure; else if (exposure>maxExposure) exposure=maxExposure;
if (autoExposureMax<minExposure) autoExposureMax=minExposure; else if (autoExposureMax>maxExposure) autoExposureMax=maxExposure;
if (gain<minGain) gain= minGain ; else if (gain> maxGain) gain= maxGain;
......@@ -645,9 +645,9 @@ public class LwirReader {
if (bScale<minScale) bScale= minScale ; else if (bScale> maxScale) bScale= maxScale;
if (gScale<minScale) gScale= minScale ; else if (gScale> maxScale) gScale= maxScale;
urls[num_lwir+chn] = "http://"+lrp.vnir_ip+"/parsedit.php?immediate&sensor_port="+chn+
urls[num_lwir+chn] = "http://"+lrp.eo_ip+"/parsedit.php?immediate&sensor_port="+chn+
"&COLOR="+COLOR_JP4+ // "*1"+ // JP4 always
"&QUALITY="+lrp.vnir_quality+ // "*0"+
"&QUALITY="+lrp.eo_quality+ // "*0"+
"&EXPOS="+exposure+ // "*0"+
"&AUTOEXP_EXP_MAX="+autoExposureMax+//"*0"+
"&AUTOEXP_ON="+autoExp+//"*0"+
......@@ -659,7 +659,7 @@ public class LwirReader {
"&DAEMON_EN_TEMPERATURE=1";//"*0";
if (chn == vnir_master_port) {
if (chn == eo_master_port) {
urls[num_lwir+chn] += "&TRIG=4*0"+
"&TRIG_CONDITION=611669*0"+ // external input
"&TRIG_BITLENGTH=31*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