Commit 016b8b7c authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Acquiring images sets with LWIR16

parent 57a60fb7
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,14 @@
        <description>A Maven project implementing imagej-elphel plugin</description>
        <description>A Maven project implementing imagej-elphel plugin</description>


        <dependencies>
        <dependencies>
			<!--  ssh support - see https://www.baeldung.com/java-ssh-connection -->
			<!-- https://mvnrepository.com/artifact/org.apache.sshd/sshd-core -->
			<dependency>
			    <groupId>org.apache.sshd</groupId>
			    <artifactId>sshd-core</artifactId>
			    <version>2.6.0</version>
			</dependency>
       
            <dependency>
            <dependency>
                <groupId>net.imagej</groupId>
                <groupId>net.imagej</groupId>
                <artifactId>ij</artifactId>
                <artifactId>ij</artifactId>
+132 −42
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.Lwir16Reader;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.lwir.LwirReaderParameters;
import com.elphel.imagej.lwir.LwirReaderParameters;
import com.elphel.imagej.readers.EyesisTiff;
import com.elphel.imagej.readers.EyesisTiff;
@@ -108,6 +109,7 @@ public class Aberration_Calibration extends PlugInFrame implements ActionListene
	private Panel panelGoniometer;
	private Panel panelGoniometer;
	private Panel panelPixelMapping, panelStereo,panelStereo1;
	private Panel panelPixelMapping, panelStereo,panelStereo1;
	private Panel panelLWIR;
	private Panel panelLWIR;
	private Panel panelLWIR16;
	private ShowDoubleFloatArrays SDFA_INSTANCE; // just for debugging?
	private ShowDoubleFloatArrays SDFA_INSTANCE; // just for debugging?
	JP46_Reader_camera JP4_INSTANCE;
	JP46_Reader_camera JP4_INSTANCE;
@@ -289,6 +291,7 @@ public class Aberration_Calibration extends PlugInFrame implements ActionListene
	);
	);
    public static LwirReader       LWIR_READER = null;
    public static LwirReader       LWIR_READER = null;
    public static Lwir16Reader     LWIR16_READER = null;
	public static ProcessCalibrationFilesParameters PROCESS_PARAMETERS = new ProcessCalibrationFilesParameters(
	public static ProcessCalibrationFilesParameters PROCESS_PARAMETERS = new ProcessCalibrationFilesParameters(
@@ -652,8 +655,6 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
	public static LwirReaderParameters   LWIR_PARAMETERS =   new LwirReaderParameters();
	public static LwirReaderParameters   LWIR_PARAMETERS =   new LwirReaderParameters();
//	new CalibrationHardwareInterface.LaserPointers();
//	new CalibrationHardwareInterface.LaserPointers();
	public class SyncCommand{
	public class SyncCommand{
	    public boolean isRunning=      false;
	    public boolean isRunning=      false;
@@ -1030,6 +1031,11 @@ if (MORE_BUTTONS) {
		panelLWIR.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
		panelLWIR.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
		addButton("LWIR Configure",             panelLWIR,color_configure);
		addButton("LWIR Configure",             panelLWIR,color_configure);
		addButton("LWIR_TEST",                  panelLWIR, color_conf_process);
		addButton("LWIR_TEST",                  panelLWIR, color_conf_process);
		addButton("CMPRS_STOP",                 panelLWIR, color_stop);
		addButton("CMPRS_START",                panelLWIR, color_process);
		addButton("LWIR_FFC",                   panelLWIR, color_conf_process);
		addButton("RST BUFs",                   panelLWIR, color_stop);
		
		addButton("LWIR_ACQUIRE",               panelLWIR, color_conf_process);
		addButton("LWIR_ACQUIRE",               panelLWIR, color_conf_process);
		addButton("Configure Goniometer",       panelLWIR,color_configure);
		addButton("Configure Goniometer",       panelLWIR,color_configure);
		addButton("Goniometer Move",            panelLWIR,color_debug);
		addButton("Goniometer Move",            panelLWIR,color_debug);
@@ -1041,8 +1047,8 @@ if (MORE_BUTTONS) {
		addButton("EO Offsets",                 panelLWIR,color_process);
		addButton("EO Offsets",                 panelLWIR,color_process);
		addButton("LWIR to EO",                 panelLWIR,color_process);
		addButton("LWIR to EO",                 panelLWIR,color_process);
		addButton("Manual hint",                panelLWIR,color_configure);
		addButton("Manual hint",                panelLWIR,color_configure);
		add(panelLWIR);
		add(panelLWIR);
		
		pack();
		pack();
		GUI.center(this);
		GUI.center(this);
		setVisible(true);
		setVisible(true);
@@ -9284,25 +9290,90 @@ if (MORE_BUTTONS) {
			LWIR_PARAMETERS.showJDialog();
			LWIR_PARAMETERS.showJDialog();
			return;
			return;
		}
		}
//startStopCompressor(LwirReaderParameters lrp, boolean start, double delay)
		//condProgramLWIRCamera()
/* ======================================================================== */
		if (label.equals("CMPRS_START") || label.equals("CMPRS_STOP")) {
			boolean start = label.equals("CMPRS_START");
			if (LWIR_PARAMETERS.isLwir16()) {
				if (LWIR16_READER == null) {
					LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
				}
				LWIR16_READER.condProgramLWIRCamera();
				double delay = 3.0;
				LWIR16_READER.startStopCompressor(LWIR_PARAMETERS, start, delay);
			}
			return;
		}
/* ======================================================================== */
		if (label.equals("LWIR_FFC")) {
			if (LWIR_PARAMETERS.isLwir16()) {
				if (LWIR16_READER == null) {
					LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
				}
				LWIR16_READER.condProgramLWIRCamera();
				int skip_frames = 0; // 300; // 5 second to come to the camera, remove later
				if (skip_frames > 0) {
					LWIR16_READER.skipMasterFrames(new String[] {LWIR_PARAMETERS.getLwirIP(0)},  skip_frames);
				}
				LWIR16_READER.runFFC(LWIR_PARAMETERS);
			}
			return;
		}
/* ======================================================================== */
		if (label.equals("RST BUFs")) {
			if (LWIR_PARAMETERS.isLwir16()) {
				if (LWIR16_READER == null) {
					LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
				}
				LWIR16_READER.condProgramLWIRCamera();
				LWIR16_READER.resetFrameBuffers(LWIR_PARAMETERS);
			}
			return;
		}
/* ======================================================================== */
/* ======================================================================== */
//
		if (label.equals("LWIR_TEST")) {
		if (label.equals("LWIR_TEST")) {
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			//   public static LwirReader       LWIR_READER = null;
			//   public static LwirReader       LWIR_READER = null;
			ImagePlus [][] imps;
			if (LWIR_PARAMETERS.isLwir16()) {
				if (LWIR16_READER == null) {
					LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
				}
				LWIR16_READER.programLWIRCamera(LWIR_PARAMETERS);
				if (DEBUG_LEVEL <1000) {
					return;
				}
				imps = LWIR16_READER.readAllMultiple(
					LWIR_PARAMETERS.getNumFrames(), // 10, // final int     num_frames,
					//    			true, // use LWIR telemetry
					true, // final boolean show,
					false); // true); // final boolean scale)
			} else {
				if (LWIR_READER == null) {
				if (LWIR_READER == null) {
					LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
					LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
				}
				}
			ImagePlus [][] imps = LWIR_READER.readAllMultiple(
				imps = LWIR_READER.readAllMultiple(
						LWIR_PARAMETERS.getNumFrames(), // 10, // final int     num_frames,
						LWIR_PARAMETERS.getNumFrames(), // 10, // final int     num_frames,
						//    			true, // use LWIR telemetry
						//    			true, // use LWIR telemetry
						true, // final boolean show,
						true, // final boolean show,
						false); // true); // final boolean scale)
						false); // true); // final boolean scale)
			}
			for (ImagePlus imp: imps[0]) {
			for (ImagePlus imp: imps[0]) {
				imp.show();
				imp.show();
			}
			}
			System.out.println("LWIR_TEST: got "+imps.length+" image sets");
			System.out.println("LWIR_TEST: got "+imps.length+" image sets");
			if (LWIR_PARAMETERS.isLwir16()) {
				// will probably not needed for Bosons
				ImagePlus [][] imps_sync =  LWIR16_READER.matchSets(imps, 0.001, 3); // double max_mismatch)
				if (imps_sync != null) {
					ImagePlus [] imps_avg = LWIR16_READER.averageMultiFrames(imps_sync);
					for (ImagePlus imp: imps_avg) {
						imp.show();
					}
				}
			} else {
				ImagePlus [][] imps_sync =  LWIR_READER.matchSets(imps, 0.001, 3); // double max_mismatch)
				ImagePlus [][] imps_sync =  LWIR_READER.matchSets(imps, 0.001, 3); // double max_mismatch)
				if (imps_sync != null) {
				if (imps_sync != null) {
					ImagePlus [] imps_avg = LWIR_READER.averageMultiFrames(imps_sync);
					ImagePlus [] imps_avg = LWIR_READER.averageMultiFrames(imps_sync);
@@ -9310,48 +9381,68 @@ if (MORE_BUTTONS) {
						imp.show();
						imp.show();
					}
					}
				}
				}
			}
			return;
			return;
		}
		}
/* ======================================================================== */
/* ======================================================================== */
    if (label.equals("LWIR_ACQUIRE")) {
    if (label.equals("LWIR_ACQUIRE")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
		//   public static LwirReader       LWIR_READER = null;
		ImagePlus [][] imps;
		if (LWIR_PARAMETERS.isLwir16()) {
			if (LWIR16_READER == null) {
				LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
			}
//          ImagePlus [] imps =
			LWIR16_READER.acquire(DISTORTION_PROCESS_CONFIGURATION.sourceDirectory); // directory to save
//          ImagePlus [] imps = LWIR_READER.acquire("attic/lwir_test_images"); // directory to save
		} else {
			if (LWIR_READER == null) {
			if (LWIR_READER == null) {
				LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
				LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
			}
			}
//          ImagePlus [] imps =
//          ImagePlus [] imps =
			LWIR_READER.acquire(DISTORTION_PROCESS_CONFIGURATION.sourceDirectory); // directory to save
			LWIR_READER.acquire(DISTORTION_PROCESS_CONFIGURATION.sourceDirectory); // directory to save
//          ImagePlus [] imps = LWIR_READER.acquire("attic/lwir_test_images"); // directory to save
//          ImagePlus [] imps = LWIR_READER.acquire("attic/lwir_test_images"); // directory to save
		}
		return;
		return;
	}
	}
    /* ======================================================================== */
    /* ======================================================================== */
	if       (label.equals("LWIR Goniometer")) {
	if       (label.equals("LWIR Goniometer")) {
		DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
		DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
		if ((GONIOMETER==null) || (LWIR_PARAMETERS.isLwir16()?(GONIOMETER.lwir16Reader ==  null):(GONIOMETER.lwirReader ==  null))) {
//		CAMERAS.setNumberOfThreads(THREADS_MAX);
			if (LWIR_PARAMETERS.isLwir16()) {
//		CAMERAS.debugLevel=DEBUG_LEVEL;
				if (LWIR16_READER == null) {
					LWIR16_READER =  new Lwir16Reader(LWIR_PARAMETERS);
		if ((GONIOMETER==null) || (GONIOMETER.lwirReader ==  null)) {
				}
				GONIOMETER= new Goniometer(
						LWIR16_READER,
						DISTORTION, //MatchSimulatedPattern.DistortionParameters distortion,
						PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
						EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters,
						LASER_POINTERS, // MatchSimulatedPattern.LaserPointer laserPointers
						SIMUL,                       //SimulationPattern.SimulParameters  simulParametersDefault,
						GONIOMETER_PARAMETERS, //LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
						DISTORTION_PROCESS_CONFIGURATION);
			} else {
				if (LWIR_READER == null) {
				if (LWIR_READER == null) {
					LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
					LWIR_READER =  new LwirReader(LWIR_PARAMETERS);
				}
				}
				GONIOMETER= new Goniometer(
				GONIOMETER= new Goniometer(
						LWIR_READER,
						LWIR_READER,
//					CAMERAS, // CalibrationHardwareInterface.CamerasInterface cameras,
						DISTORTION, //MatchSimulatedPattern.DistortionParameters distortion,
						DISTORTION, //MatchSimulatedPattern.DistortionParameters distortion,
						PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
						PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
						EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters,
						EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters,
						LASER_POINTERS, // MatchSimulatedPattern.LaserPointer laserPointers
						LASER_POINTERS, // MatchSimulatedPattern.LaserPointer laserPointers
						SIMUL,                       //SimulationPattern.SimulParameters  simulParametersDefault,
						SIMUL,                       //SimulationPattern.SimulParameters  simulParametersDefault,
						GONIOMETER_PARAMETERS, //LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
						GONIOMETER_PARAMETERS, //LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
					DISTORTION_PROCESS_CONFIGURATION
						DISTORTION_PROCESS_CONFIGURATION);
			);
			}
			if (DEBUG_LEVEL>1){
			if (DEBUG_LEVEL>1){
				System.out.println("Initiaslizing Goniometer class");
				System.out.println("Initialized Goniometer class for "+LWIR_PARAMETERS.getCameraName());
			}
			}
		} else if (DEBUG_LEVEL>1){
		} else if (DEBUG_LEVEL>1){
			System.out.println("GONIOMETER was initialized");
			System.out.println("GONIOMETER was initialized for "+LWIR_PARAMETERS.getCameraName());
		}
		}
		// calculate angular size of the target as visible from the camera
		// calculate angular size of the target as visible from the camera
@@ -9437,7 +9528,6 @@ if (MORE_BUTTONS) {
	}
	}
	
	
/* ======================================================================== */
/* ======================================================================== */
		IJ.showMessage("Not yet implemented");
		IJ.showMessage("Not yet implemented");
		DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
		DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
		return;
		return;
+29 −1
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.elphel.imagej.calibration.hardware.GoniometerMotors;
import com.elphel.imagej.cameras.EyesisCameraParameters;
import com.elphel.imagej.cameras.EyesisCameraParameters;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.lwir.Lwir16Reader;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.lwir.LwirReader;


import ij.IJ;
import ij.IJ;
@@ -54,6 +55,7 @@ horizontal axis:
																				// debugging
																				// debugging
	public CamerasInterface cameras = null;
	public CamerasInterface cameras = null;
	public LwirReader   lwirReader = null;
	public LwirReader   lwirReader = null;
	public Lwir16Reader lwir16Reader = null;
	// public CalibrationHardwareInterface.LaserPointers lasers = null;
	// public CalibrationHardwareInterface.LaserPointers lasers = null;
	// public static CalibrationHardwareInterface.FocusingMotors motorsS=null;
	// public static CalibrationHardwareInterface.FocusingMotors motorsS=null;
	// public DistortionProcessConfiguration
	// public DistortionProcessConfiguration
@@ -123,6 +125,28 @@ horizontal axis:
		this.distortionProcessConfiguration=distortionProcessConfiguration;
		this.distortionProcessConfiguration=distortionProcessConfiguration;
	}
	}


	public Goniometer(
			Lwir16Reader lwir16Reader,
//			CalibrationHardwareInterface.CamerasInterface cameras,
			MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
			MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
			EyesisCameraParameters eyesisCameraParameters,
			LaserPointer laserPointers,
			SimulationPattern.SimulParameters simulParametersDefault,
			Goniometer.GoniometerParameters goniometerParameters,
			DistortionProcessConfiguration distortionProcessConfiguration
			) {
		this.lwir16Reader= lwir16Reader;
//		this.cameras = cameras;
		this.distortionParametersDefault = distortionParametersDefault;
//		this.distortion = distortion;
		this.patternDetectParameters=patternDetectParameters;
		this.eyesisCameraParameters = eyesisCameraParameters;
		this.laserPointers = laserPointers;
		this.simulParametersDefault=simulParametersDefault;
		this.goniometerParameters=goniometerParameters;
		this.distortionProcessConfiguration=distortionProcessConfiguration;
	}






@@ -459,6 +483,10 @@ horizontal axis:
					this.lwirReader.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions()); // Used target, not current to prevent minor variations
					this.lwirReader.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions()); // Used target, not current to prevent minor variations
					this.lwirReader.reportTiming=debugTiming;
					this.lwirReader.reportTiming=debugTiming;
					this.lwirReader.acquire(this.distortionProcessConfiguration.sourceDirectory); // true - use lasers, updateStatus - make false?
					this.lwirReader.acquire(this.distortionProcessConfiguration.sourceDirectory); // true - use lasers, updateStatus - make false?
				} else if (lwir16Reader != null) {
					this.lwir16Reader.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions()); // Used target, not current to prevent minor variations
					this.lwir16Reader.reportTiming=debugTiming;
					this.lwir16Reader.acquire(this.distortionProcessConfiguration.sourceDirectory); // true - use lasers, updateStatus - make false?
				} else {
				} else {
					System.out.println("Neignter traditional camera/rig, no LWIR rig are initialized, dry run");
					System.out.println("Neignter traditional camera/rig, no LWIR rig are initialized, dry run");
				}
				}
+3 −1
Original line number Original line Diff line number Diff line
@@ -4793,7 +4793,7 @@ public class MatchSimulatedPattern {
																											// process
																											// process
			final double[] bPattern, final double[] windowFunction, final double[] windowFunctionCorr,
			final double[] bPattern, final double[] windowFunction, final double[] windowFunctionCorr,
			final double[] windowFunctionCorr2, final double[] windowFunctionCorr4, final double[][] locsNeib, // which
			final double[] windowFunctionCorr2, final double[] windowFunctionCorr4, final double[][] locsNeib, // which
																												// neibors
																												// neighbors
																												// to
																												// to
																												// try
																												// try
																												// (here
																												// (here
@@ -6919,6 +6919,8 @@ public class MatchSimulatedPattern {
				noMessageBoxes);
				noMessageBoxes);
	}
	}
	
	
	// ====== end of calculateDistortions()
	// ====== end of calculateDistortions()
	// ==============================================
	// ==============================================
	/**
	/**
+2 −2
Original line number Original line Diff line number Diff line
@@ -318,7 +318,7 @@ public class GenericJTabbedDialog implements ActionListener {


    @Override
    @Override
	public void actionPerformed(ActionEvent e) {
	public void actionPerformed(ActionEvent e) {
    	System.out.println(e.getActionCommand());
//    	System.out.println(e.getActionCommand());
    	if (e.getActionCommand().equals("Cancel")) {
    	if (e.getActionCommand().equals("Cancel")) {
    		result = e.getActionCommand();
    		result = e.getActionCommand();
    		jd.dispose();
    		jd.dispose();
@@ -409,7 +409,7 @@ public class GenericJTabbedDialog implements ActionListener {
    	}
    	}




    	System.out.println(combo.getSelectedItem());
//    	System.out.println(combo.getSelectedItem());
//    	for (int i = 0; i < selectedItem.length; i++){
//    	for (int i = 0; i < selectedItem.length; i++){
 //   	    System.out.println(String.format("item %s = %s", i, selectedItem[i]));
 //   	    System.out.println(String.format("item %s = %s", i, selectedItem[i]));
  //  	}
  //  	}
Loading