Commit dfc47feb authored by Mikhail Karpenko's avatar Mikhail Karpenko

Add extra sensors processing to lens center measurement

parent 63e87e10
......@@ -3761,24 +3761,30 @@ if (MORE_BUTTONS) {
POWER_CONTROL.lightsOnWithDelay();
long startTime=System.nanoTime();
FOCUS_MEASUREMENT_PARAMETERS.sensorTemperature=CAMERAS.getSensorTemperature(0,FOCUS_MEASUREMENT_PARAMETERS.EEPROM_channel);
imp_sel= CAMERAS.acquireSingleImage (
ImagePlus [] imp_set_ref = CAMERAS.acquireSeveralImages (
true, //boolean useLasers,
UPDATE_STATUS);
if (imp_sel==null){
if (imp_set_ref==null){
IJ.showMessage("Error","Failed to get camera image\nProcess canceled");
return;
}
if (FOCUS_MEASUREMENT_PARAMETERS.showAcquiredImages){
imp_sel.show();
imp_sel.updateAndDraw();
}
ImagePlus [] imp_set = new ImagePlus[imp_set_ref.length];
imp_set = imp_set_ref.clone();
if (LENS_DISTORTION_PARAMETERS==null){
IJ.showMessage("LENS_DISTORTION_PARAMETERS is not set");
return;
}
MatchSimulatedPattern [] matchSimulatedPatternSet = new MatchSimulatedPattern[imp_set.length];
ImagePlus [] imp_calibrated = new ImagePlus[imp_set.length];
double headPointersTilt=Double.NaN;
// measure rotation from the optical head lasers
if (findCenter &&FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){
for (int imgCounter = 0; imgCounter < imp_set.length; imgCounter++) {
if (FOCUS_MEASUREMENT_PARAMETERS.showAcquiredImages){
imp_set[imgCounter].show();
imp_set[imgCounter].updateAndDraw();
}
// measure rotation from the optical head lasers for the first image only
if (imgCounter == 0 && findCenter &&FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){
ImagePlus imp_headLasers= CAMERAS.acquireSingleImage (
UV_LED_LASERS,
UPDATE_STATUS);
......@@ -3811,23 +3817,23 @@ if (MORE_BUTTONS) {
if (DEBUG_LEVEL>0) System.out.println("Image acquisition (@"+FOCUS_MEASUREMENT_PARAMETERS.sensorTemperature+"C) done at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
// reset matchSimulatedPattern, so it will start from scratch
matchSimulatedPattern= new MatchSimulatedPattern(DISTORTION.FFTSize); // new instance, all reset
matchSimulatedPatternSet[imgCounter] = new MatchSimulatedPattern(DISTORTION.FFTSize); // new instance, all reset
// next 2 lines are not needed for the new instance, but can be used alternatively if keeipg it
matchSimulatedPattern.invalidateFlatFieldForGrid(); //Reset Flat Field calibration - different image.
matchSimulatedPattern.invalidateFocusMask();
matchSimulatedPatternSet[imgCounter].invalidateFlatFieldForGrid(); //Reset Flat Field calibration - different image.
matchSimulatedPatternSet[imgCounter].invalidateFocusMask();
if (matchSimulatedPattern.getPointersXY(imp_sel,LASER_POINTERS.laserUVMap.length)==null) { // no pointers in this image
IJ.showMessage("Error","No laser pointers detected - they are needed for absolute grid positioning\nProcess canceled");
if (matchSimulatedPatternSet[imgCounter].getPointersXY(imp_set[imgCounter],LASER_POINTERS.laserUVMap.length)==null) { // no pointers in this image
IJ.showMessage("Error","No laser pointers detected for image #" + imgCounter + " - they are needed for absolute grid positioning\nProcess canceled");
return;
}
matchSimulatedPattern.debugLevel=DEBUG_LEVEL;
matchSimulatedPatternSet[imgCounter].debugLevel=DEBUG_LEVEL;
int numAbsolutePoints=LENS_ADJUSTMENT.updateFocusGrid(
LENS_DISTORTION_PARAMETERS.px0, // pixel coordinate of the the optical center
LENS_DISTORTION_PARAMETERS.py0, // pixel coordinate of the the optical center
imp_sel,
matchSimulatedPattern,
imp_set[imgCounter],
matchSimulatedPatternSet[imgCounter],
DISTORTION,
FOCUS_MEASUREMENT_PARAMETERS,
PATTERN_DETECT,
......@@ -3837,7 +3843,7 @@ if (MORE_BUTTONS) {
COMPONENTS.equalizeGreens,
THREADS_MAX,
UPDATE_STATUS,
// DEBUG_LEVEL);
// DEBUG_LEVEL);
DISTORTION.loop_debug_level);
if (numAbsolutePoints<=0) { // no pointers in this image
String msg="No laser pointers matched - they are needed for absolute grid positioning\nProcess canceled";
......@@ -3846,7 +3852,8 @@ if (MORE_BUTTONS) {
return;
}
if (DEBUG_LEVEL>0) System.out.println("Matched "+numAbsolutePoints+" laser pointers, grid generated at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
ImagePlus [] imp_calibrated={matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,"grid-",numAbsolutePoints)};
imp_calibrated[imgCounter] = matchSimulatedPatternSet[imgCounter].getCalibratedPatternAsImage(imp_set[imgCounter],"grid-",numAbsolutePoints);
}
if (FOCUS_MEASUREMENT_PARAMETERS.showAcquiredImages) imp_calibrated[0].show(); // DISTORTION_PROCESS_CONFIGURATION.showGridImages
if (findCenter){
// Read required calibration files
......@@ -1761,6 +1761,16 @@ public class CalibrationHardwareInterface {
this.lastTimestamp=(String) this.images[0].getProperty("timestamp");
return this.images[0];
}
public ImagePlus [] acquireSeveralImages (boolean useLasers, boolean updateStatus){
getImages(
null, // UVLEDLasers
selectAllSubcameras(),
(useLasers?selectAllSubcameras():null),
true,
this.debugLevel>1); // reset and trigger
this.lastTimestamp=(String) this.images[0].getProperty("timestamp");
return this.images;
}
public ImagePlus acquireSingleImage (UVLEDandLasers uvLEDLasers, boolean updateStatus){
getImages(
......
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