Commit 3c58184f authored by Andrey Filippov's avatar Andrey Filippov

generating range-balanced PNG files for preview videos

parent 3735bd46
...@@ -1192,7 +1192,7 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener { ...@@ -1192,7 +1192,7 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
try { try {
url = new URL(cameraurl); url = new URL(cameraurl);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
System.out.println("Bad URL: " + cameraurl); System.out.println("Bad URL5: " + cameraurl);
return null; return null;
} }
......
...@@ -1072,6 +1072,9 @@ if (MORE_BUTTONS) { ...@@ -1072,6 +1072,9 @@ if (MORE_BUTTONS) {
addButton("Illustrations Configure", panelIllustrations,color_configure); addButton("Illustrations Configure", panelIllustrations,color_configure);
addButton("Remove bad grids", panelIllustrations,color_stop); addButton("Remove bad grids", panelIllustrations,color_stop);
addButton("Illustrations", panelIllustrations,color_bundle); addButton("Illustrations", panelIllustrations,color_bundle);
addButton("Illustrate Kernels", panelIllustrations,color_process);
addButton("Illustrate Footage", panelIllustrations,color_process);
add(panelIllustrations); add(panelIllustrations);
...@@ -8867,6 +8870,10 @@ if (MORE_BUTTONS) { ...@@ -8867,6 +8870,10 @@ if (MORE_BUTTONS) {
/* ======================================================================== */ /* ======================================================================== */
if (label.equals("Select Channels")) { if (label.equals("Select Channels")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (LENS_DISTORTIONS == null) {
LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
}
ABERRATIONS_PARAMETERS.selectChannelsToProcess("Select channels to process",LENS_DISTORTIONS); //LENS_DISTORTIONS==null OK ABERRATIONS_PARAMETERS.selectChannelsToProcess("Select channels to process",LENS_DISTORTIONS); //LENS_DISTORTIONS==null OK
return; return;
} }
...@@ -9432,6 +9439,7 @@ if (MORE_BUTTONS) { ...@@ -9432,6 +9439,7 @@ if (MORE_BUTTONS) {
if (CALIBRATION_ILLUSTRATION == null) { if (CALIBRATION_ILLUSTRATION == null) {
CALIBRATION_ILLUSTRATION = new CalibrationIllustration( CALIBRATION_ILLUSTRATION = new CalibrationIllustration(
LWIR_PARAMETERS, // LwirReaderParameters lwirReaderParameters,
CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters, CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters,
EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations, EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations,
LENS_DISTORTIONS, // Distortions distortions, LENS_DISTORTIONS, // Distortions distortions,
...@@ -9442,6 +9450,114 @@ if (MORE_BUTTONS) { ...@@ -9442,6 +9450,114 @@ if (MORE_BUTTONS) {
return; return;
} }
/* ======================================================================== */ /* ======================================================================== */
if (label.equals("Illustrate Footage")) {
// if (LENS_DISTORTIONS==null) {
// IJ.showMessage("LENS_DISTORTION is not set"); // to use all grids imported
// return;
// }
// EYESIS_ABERRATIONS.setDistortions(LENS_DISTORTIONS);
if (EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory.length()>0){
File dFile=new File(EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory);
if (!dFile.isDirectory() && !dFile.mkdirs()) {
String msg="Failed to create directory "+EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory;
IJ.showMessage("Warning",msg);
System.out.println("Warning: "+msg);
EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory=""; // start over with selecting directory
}
}
String configPath=EYESIS_ABERRATIONS.aberrationParameters.selectIllustrationsDirectory(
true,
EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory,
true);
if (configPath==null){
String msg="No illustrations directory selected, command aborted";
System.out.println("Warning: "+msg);
IJ.showMessage("Warning",msg);
return;
}
configPath+=Prefs.getFileSeparator()+"config-illustrations";
try {
saveTimestampedProperties(
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
} catch (Exception e){
String msg="Failed to save configuration to "+configPath+", command aborted";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
return;
}
if (CALIBRATION_ILLUSTRATION == null) { //LWIR_PARAMETERS
CALIBRATION_ILLUSTRATION = new CalibrationIllustration(
LWIR_PARAMETERS, // LwirReaderParameters lwirReaderParameters,
CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters,
EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations,
LENS_DISTORTIONS, // Distortions distortions,
SYNC_COMMAND.stopRequested, // AtomicInteger stopRequested,
MASTER_DEBUG_LEVEL); // int debug_level);
}
CALIBRATION_ILLUSTRATION.convertCapturedFiles();
return;
}
//
/* ======================================================================== */
if (label.equals("Illustrate Kernels")) {
if (EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory.length()>0){
File dFile=new File(EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory);
if (!dFile.isDirectory() && !dFile.mkdirs()) {
String msg="Failed to create directory "+EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory;
IJ.showMessage("Warning",msg);
System.out.println("Warning: "+msg);
EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory=""; // start over with selecting directory
}
}
String configPath=EYESIS_ABERRATIONS.aberrationParameters.selectIllustrationsDirectory(
true,
EYESIS_ABERRATIONS.aberrationParameters.illustrationsDirectory,
true);
if (configPath==null){
String msg="No illustrations directory selected, command aborted";
System.out.println("Warning: "+msg);
IJ.showMessage("Warning",msg);
return;
}
configPath+=Prefs.getFileSeparator()+"config-illustrations";
try {
saveTimestampedProperties(
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
} catch (Exception e){
String msg="Failed to save configuration to "+configPath+", command aborted";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
return;
}
if (CALIBRATION_ILLUSTRATION == null) {
CALIBRATION_ILLUSTRATION = new CalibrationIllustration(
LWIR_PARAMETERS, // LwirReaderParameters lwirReaderParameters,
CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters,
EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations,
LENS_DISTORTIONS, // Distortions distortions,
SYNC_COMMAND.stopRequested, // AtomicInteger stopRequested,
MASTER_DEBUG_LEVEL); // int debug_level);
}
CALIBRATION_ILLUSTRATION.convertKernels(
INVERSE.dSize, // int dsize, // direct kernel size
INVERSE.rSize // int rsize // inverse kernel size
);
return;
}
/* ======================================================================== */
if (label.equals("Remove bad grids")) { if (label.equals("Remove bad grids")) {
if (LENS_DISTORTIONS==null) { if (LENS_DISTORTIONS==null) {
IJ.showMessage("LENS_DISTORTION is not set"); // to use all grids imported IJ.showMessage("LENS_DISTORTION is not set"); // to use all grids imported
...@@ -9451,6 +9567,7 @@ if (MORE_BUTTONS) { ...@@ -9451,6 +9567,7 @@ if (MORE_BUTTONS) {
if (CALIBRATION_ILLUSTRATION == null) { if (CALIBRATION_ILLUSTRATION == null) {
CALIBRATION_ILLUSTRATION = new CalibrationIllustration( CALIBRATION_ILLUSTRATION = new CalibrationIllustration(
LWIR_PARAMETERS, // LwirReaderParameters lwirReaderParameters,
CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters, CALIBRATION_ILLUSTRATION_PARAMETERS, // CalibrationIllustrationParameters illustrationParameters,
EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations, EYESIS_ABERRATIONS, // EyesisAberrations eyesisAberrations,
LENS_DISTORTIONS, // Distortions distortions, LENS_DISTORTIONS, // Distortions distortions,
...@@ -10401,8 +10518,8 @@ if (MORE_BUTTONS) { ...@@ -10401,8 +10518,8 @@ if (MORE_BUTTONS) {
some_type[0] = false; some_type[0] = false;
some_type[1] = false; some_type[1] = false;
} }
if (allornone_eo) some_type[0] = all_type[0]; if (allornone_eo) some_type[0] &= all_type[0];
if (allornone_lwir) some_type[1] = all_type[1]; if (allornone_lwir) some_type[1] &= all_type[1];
if (some_type[0] || some_type[1]) { if (some_type[0] || some_type[1]) {
for (int i = 0; i < avail_chn.length; i++) { for (int i = 0; i < avail_chn.length; i++) {
...@@ -957,9 +957,20 @@ import ij.text.TextWindow; ...@@ -957,9 +957,20 @@ import ij.text.TextWindow;
(path.charAt(indexLastDash)!='_') && (path.charAt(indexLastDash)!='_') &&
(path.charAt(indexLastDash)!='-')) indexLastDash--; (path.charAt(indexLastDash)!='-')) indexLastDash--;
return Integer.parseInt(path.substring(indexLastDash+1,indexSuffix)); return Integer.parseInt(path.substring(indexLastDash+1,indexSuffix));
} }
/*
public static double getTimestampFromPath(String path) {
if (path == null) return Double.NaN;
int i1=path.indexOf('-',path.lastIndexOf(Prefs.getFileSeparator()));
int i2=path.indexOf('-',i1+1);
int i3=path.indexOf('.',i2+1);
// Extract timestamp from the filename
if ((i1<0) || (i2<0)) {
return Double.NaN;
}
return Double.parseDouble(path.substring(i1+1,i2).replace('_','.'));
}
*/
private boolean invertColor(int chn) { private boolean invertColor(int chn) {
//TODO: Add looking at the image property to find out if inversion is already contained in the grid files //TODO: Add looking at the image property to find out if inversion is already contained in the grid files
return eyesisCameraParameters.isLWIR(chn); return eyesisCameraParameters.isLWIR(chn);
......
...@@ -2290,7 +2290,7 @@ public class EyesisAberrations { ...@@ -2290,7 +2290,7 @@ public class EyesisAberrations {
final int masterDebugLevel, // get rid of it? // ** NEW final int masterDebugLevel, // get rid of it? // ** NEW
final int globalDebugLevel,// ** NEW final int globalDebugLevel,// ** NEW
final int debug_level){// debug level used inside loops final int debug_level){// debug level used inside loops
boolean is_lwir = ((lwirReaderParameters != null) && lwirReaderParameters.is_LWIR(imp_sel)); boolean is_lwir = ((lwirReaderParameters != null) && LwirReaderParameters.is_LWIR(imp_sel));
boolean is_mono = false; boolean is_mono = false;
try { try {
is_mono = Boolean.parseBoolean((String) imp_sel.getProperty("MONOCHROME")); is_mono = Boolean.parseBoolean((String) imp_sel.getProperty("MONOCHROME"));
...@@ -4785,6 +4785,7 @@ public class EyesisAberrations { ...@@ -4785,6 +4785,7 @@ public class EyesisAberrations {
public String sourceDirectory=""; public String sourceDirectory="";
public String partialKernelDirectory=""; public String partialKernelDirectory="";
public String illustrationsDirectory=""; public String illustrationsDirectory="";
public String capturedDirectory = "";
public String psfKernelDirectory=""; public String psfKernelDirectory="";
public String aberrationsKernelDirectory=""; public String aberrationsKernelDirectory="";
public String calibrationDirectory=""; public String calibrationDirectory="";
...@@ -4823,10 +4824,10 @@ public class EyesisAberrations { ...@@ -4823,10 +4824,10 @@ public class EyesisAberrations {
properties.setProperty(prefix+"sourceDirectory",this.sourceDirectory); properties.setProperty(prefix+"sourceDirectory",this.sourceDirectory);
properties.setProperty(prefix+"partialKernelDirectory",this.partialKernelDirectory); properties.setProperty(prefix+"partialKernelDirectory",this.partialKernelDirectory);
properties.setProperty(prefix+"illustrationsDirectory",this.illustrationsDirectory); properties.setProperty(prefix+"illustrationsDirectory",this.illustrationsDirectory);
properties.setProperty(prefix+"capturedDirectory", this.capturedDirectory);
properties.setProperty(prefix+"psfKernelDirectory",this.psfKernelDirectory); properties.setProperty(prefix+"psfKernelDirectory",this.psfKernelDirectory);
properties.setProperty(prefix+"aberrationsKernelDirectory",this.aberrationsKernelDirectory); properties.setProperty(prefix+"aberrationsKernelDirectory",this.aberrationsKernelDirectory);
properties.setProperty(prefix+"calibrationDirectory",this.calibrationDirectory); properties.setProperty(prefix+"calibrationDirectory",this.calibrationDirectory);
properties.setProperty(prefix+"autoRestore",this.autoRestore+""); properties.setProperty(prefix+"autoRestore",this.autoRestore+"");
properties.setProperty(prefix+"calibrationPath",this.calibrationPath); properties.setProperty(prefix+"calibrationPath",this.calibrationPath);
properties.setProperty(prefix+"strategyPath",this.strategyPath); properties.setProperty(prefix+"strategyPath",this.strategyPath);
...@@ -4869,6 +4870,7 @@ public class EyesisAberrations { ...@@ -4869,6 +4870,7 @@ public class EyesisAberrations {
if (properties.getProperty(prefix+"sourceDirectory")!=null) this.sourceDirectory=properties.getProperty(prefix+"sourceDirectory"); if (properties.getProperty(prefix+"sourceDirectory")!=null) this.sourceDirectory=properties.getProperty(prefix+"sourceDirectory");
if (properties.getProperty(prefix+"partialKernelDirectory")!=null) this.partialKernelDirectory=properties.getProperty(prefix+"partialKernelDirectory"); if (properties.getProperty(prefix+"partialKernelDirectory")!=null) this.partialKernelDirectory=properties.getProperty(prefix+"partialKernelDirectory");
if (properties.getProperty(prefix+"illustrationsDirectory")!=null) this.illustrationsDirectory=properties.getProperty(prefix+"illustrationsDirectory"); if (properties.getProperty(prefix+"illustrationsDirectory")!=null) this.illustrationsDirectory=properties.getProperty(prefix+"illustrationsDirectory");
if (properties.getProperty(prefix+"capturedDirectory")!=null) this.capturedDirectory=properties.getProperty(prefix+"capturedDirectory");
if (properties.getProperty(prefix+"psfKernelDirectory")!=null) this.psfKernelDirectory=properties.getProperty(prefix+"psfKernelDirectory"); if (properties.getProperty(prefix+"psfKernelDirectory")!=null) this.psfKernelDirectory=properties.getProperty(prefix+"psfKernelDirectory");
if (properties.getProperty(prefix+"aberrationsKernelDirectory")!=null) this.aberrationsKernelDirectory=properties.getProperty(prefix+"aberrationsKernelDirectory"); if (properties.getProperty(prefix+"aberrationsKernelDirectory")!=null) this.aberrationsKernelDirectory=properties.getProperty(prefix+"aberrationsKernelDirectory");
if (properties.getProperty(prefix+"calibrationDirectory")!=null) this.calibrationDirectory=properties.getProperty(prefix+"calibrationDirectory"); if (properties.getProperty(prefix+"calibrationDirectory")!=null) this.calibrationDirectory=properties.getProperty(prefix+"calibrationDirectory");
...@@ -5023,6 +5025,8 @@ public class EyesisAberrations { ...@@ -5023,6 +5025,8 @@ public class EyesisAberrations {
gd.addCheckbox("Select partial kernels directory", false); gd.addCheckbox("Select partial kernels directory", false);
gd.addStringField("Illustrations directory", this.illustrationsDirectory, 60); gd.addStringField("Illustrations directory", this.illustrationsDirectory, 60);
gd.addCheckbox("Select illustrations directory", false); gd.addCheckbox("Select illustrations directory", false);
gd.addStringField("Captured images directory", this.capturedDirectory, 60);
gd.addCheckbox("Select captured images directory", false);
gd.addStringField("Combined kernels directory", this.psfKernelDirectory, 60); gd.addStringField("Combined kernels directory", this.psfKernelDirectory, 60);
gd.addCheckbox("Select combined kernsls directory", false); gd.addCheckbox("Select combined kernsls directory", false);
gd.addStringField("Aberrations kernels directory", this.aberrationsKernelDirectory, 60); gd.addStringField("Aberrations kernels directory", this.aberrationsKernelDirectory, 60);
...@@ -5078,6 +5082,8 @@ public class EyesisAberrations { ...@@ -5078,6 +5082,8 @@ public class EyesisAberrations {
if (gd.getNextBoolean()) selectPartialKernelDirectory(false, this.partialKernelDirectory, false); if (gd.getNextBoolean()) selectPartialKernelDirectory(false, this.partialKernelDirectory, false);
this.illustrationsDirectory=gd.getNextString(); this.illustrationsDirectory=gd.getNextString();
if (gd.getNextBoolean()) selectIllustrationsDirectory(false, this.illustrationsDirectory, false); if (gd.getNextBoolean()) selectIllustrationsDirectory(false, this.illustrationsDirectory, false);
this.capturedDirectory=gd.getNextString();
if (gd.getNextBoolean()) selectCapturedDirectory(false, this.capturedDirectory, false);
this.psfKernelDirectory=gd.getNextString(); this.psfKernelDirectory=gd.getNextString();
if (gd.getNextBoolean()) selectPSFKernelDirectory(false, this.psfKernelDirectory, false); if (gd.getNextBoolean()) selectPSFKernelDirectory(false, this.psfKernelDirectory, false);
this.aberrationsKernelDirectory=gd.getNextString(); this.aberrationsKernelDirectory=gd.getNextString();
...@@ -5152,6 +5158,18 @@ public class EyesisAberrations { ...@@ -5152,6 +5158,18 @@ public class EyesisAberrations {
if (dir!=null) this.illustrationsDirectory=dir; if (dir!=null) this.illustrationsDirectory=dir;
return dir; return dir;
} }
public String selectCapturedDirectory(boolean smart, String defaultPath, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"Captured images directory", // title
"Select captured images directory", // button
null, // filter
defaultPath); //this.sourceDirectory);
if (dir!=null) this.capturedDirectory=dir;
return dir;
}
public String selectPSFKernelDirectory(boolean smart, String defaultPath, boolean newAllowed) { public String selectPSFKernelDirectory(boolean smart, String defaultPath, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory( String dir= CalibrationFileManagement.selectDirectory(
......
...@@ -325,6 +325,10 @@ public class GenericJTabbedDialog implements ActionListener { ...@@ -325,6 +325,10 @@ public class GenericJTabbedDialog implements ActionListener {
} else if (e.getActionCommand().equals("OK")) { } else if (e.getActionCommand().equals("OK")) {
result = e.getActionCommand(); result = e.getActionCommand();
jd.dispose(); jd.dispose();
// Added 07/18/2021 - button names starting with "_" exit from dialog
} else if ((e.getActionCommand().length()>0) && (e.getActionCommand().charAt(0) == '_')){
result = e.getActionCommand().substring(1);
jd.dispose();
} }
} }
...@@ -332,6 +336,9 @@ public class GenericJTabbedDialog implements ActionListener { ...@@ -332,6 +336,9 @@ public class GenericJTabbedDialog implements ActionListener {
public boolean wasCanceled() { public boolean wasCanceled() {
return (result == null) || (result.equals("Cancel")); return (result == null) || (result.equals("Cancel"));
} }
public boolean wasOKed() {
return result.equals("OK");
}
private boolean skipComments ( private boolean skipComments (
boolean incTab) { // increment tab if nothing left in this one (false - keep read_component equal to tab's components length boolean incTab) { // increment tab if nothing left in this one (false - keep read_component equal to tab's components length
......
...@@ -2721,7 +2721,8 @@ public class EyesisCorrections { ...@@ -2721,7 +2721,8 @@ public class EyesisCorrections {
if (debugLevel > 0) System.out.println("Saving RGBA result to "+path+".png"); if (debugLevel > 0) System.out.println("Saving RGBA result to "+path+".png");
(new EyesisTiff()).savePNG_ARGB32( (new EyesisTiff()).savePNG_ARGB32(
imp, imp,
path +".png" path +".png",
debugLevel
); );
} else { } else {
......
...@@ -1157,7 +1157,7 @@ public class JP46_Reader_camera implements PlugIn, ActionListener { ...@@ -1157,7 +1157,7 @@ public class JP46_Reader_camera implements PlugIn, ActionListener {
try { try {
url = new URL(cameraurl); url = new URL(cameraurl);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
System.out.println("Bad URL: " + cameraurl); System.out.println("Bad URL4: " + cameraurl);
return null; return null;
} }
......
...@@ -1096,6 +1096,9 @@ public class Lwir16Reader { ...@@ -1096,6 +1096,9 @@ public class Lwir16Reader {
set_dir.mkdirs(); // including parent set_dir.mkdirs(); // including parent
LOGGER.warn("Saving image set to: "+set_dir.getAbsolutePath()); LOGGER.warn("Saving image set to: "+set_dir.getAbsolutePath());
for (ImagePlus imp:imgs) { for (ImagePlus imp:imgs) {
if (imp==null) { // channel was not selected?
continue;
}
String fname = imp.getTitle(); String fname = imp.getTitle();
// fname = fname.substring(0, fname.lastIndexOf('_')) + ".tiff"; // remove _average // fname = fname.substring(0, fname.lastIndexOf('_')) + ".tiff"; // remove _average
// fname = fname.substring(0, fname.lastIndexOf('.')) + ".tiff"; // remove _average // fname = fname.substring(0, fname.lastIndexOf('.')) + ".tiff"; // remove _average
...@@ -1199,9 +1202,18 @@ public class Lwir16Reader { ...@@ -1199,9 +1202,18 @@ public class Lwir16Reader {
public boolean programLWIRCamera(LwirReaderParameters lrp) {
return programLWIRCamera(lrp, 0);
}
/**
* Program all 5 cameras for calibration mode
* @param lrp LWIR Reader parameters
* @param compressor_run 0 - exit with compressors stopped, 2 - keep compressors running
* @return true if OK, false otherwise
*/
public boolean programLWIRCamera(LwirReaderParameters lrp) { public boolean programLWIRCamera(LwirReaderParameters lrp, int compressor_run) {
String [] all_IPs = lrp.getAllIPs(); String [] all_IPs = lrp.getAllIPs();
String [] lwir_IPs = lrp.getLwirIPs(); String [] lwir_IPs = lrp.getLwirIPs();
String eo_ip = lrp.getEOIP(); String eo_ip = lrp.getEOIP();
...@@ -1228,12 +1240,13 @@ public class Lwir16Reader { ...@@ -1228,12 +1240,13 @@ public class Lwir16Reader {
"&XMIT_TIMESTAMP=1"; "&XMIT_TIMESTAMP=1";
} }
for (int i = 0; i < lwir_IPs.length; i++) { // Alpply to only 4 lwir cameras, port 0 (some to all ports) for (int i = 0; i < lwir_IPs.length; i++) { // Apply to only 4 lwir cameras, port 0 (some to all ports)
urls[i] += "&TRIG_DELAY="+lrp.lwir_trig_dly+"&*TRIG_DELAY=15"+ // apply to all ports urls[i] += "&TRIG_DELAY="+lrp.lwir_trig_dly+"&*TRIG_DELAY=15"+ // apply to all ports
"&BITS=16&*BITS=15"+ "&BITS=16&*BITS=15"+
"&COLOR="+COLOR_RAW +"&*COLOR=15"+ "&COLOR="+COLOR_RAW +"&*COLOR=15"+
"&WOI_HEIGHT="+(LWIR_HEIGHT + (lrp.lwir_telemetry?LWIR_TELEMETRY_LINES:0))+"&*WOI_HEIGHT=15"+ "&WOI_HEIGHT="+(LWIR_HEIGHT + (lrp.lwir_telemetry?LWIR_TELEMETRY_LINES:0))+"&*WOI_HEIGHT=15"+
"&"+REG_FFC_FRAMES+"="+lrp.getFFCFrames() +"&*"+REG_FFC_FRAMES+"=15"; // apply to all channels "&"+REG_FFC_FRAMES+"="+lrp.getFFCFrames() +"&*"+REG_FFC_FRAMES+"=15"; // apply to all channels
urls[i] += "&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15"; // turn compressor and keep fort at least one frame after TRIG=4
} }
for (int chn:lrp.eo_channels) { // add color settings to all EO channels for (int chn:lrp.eo_channels) { // add color settings to all EO channels
...@@ -1276,6 +1289,9 @@ public class Lwir16Reader { ...@@ -1276,6 +1289,9 @@ public class Lwir16Reader {
"&WOI_TOP=0"+ "&WOI_TOP=0"+
"&WOI_WIDTH=2592"+ "&WOI_WIDTH=2592"+
"&WOI_HEIGHT=1936"; "&WOI_HEIGHT=1936";
if (chn == 0) {
urls[all_IPs.length-1] += "&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15"; // turn compressor and keep fort at least one frame after TRIG=4
}
} }
} }
// run all programming not including TRIG=4 // run all programming not including TRIG=4
...@@ -1303,7 +1319,8 @@ public class Lwir16Reader { ...@@ -1303,7 +1319,8 @@ public class Lwir16Reader {
// set external trigger mode for all LWIR and EO cameras // set external trigger mode for all LWIR and EO cameras
urls = new String[all_IPs.length]; urls = new String[all_IPs.length];
for (int i = 0; i < urls.length; i++) { for (int i = 0; i < urls.length; i++) {
urls[i] = "http://"+all_IPs[i]+"/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15"; urls[i] = "http://"+all_IPs[i]+"/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15"+
"&COMPRESSOR_RUN=" + compressor_run +"*5&*COMPRESSOR_RUN=15"; // delay turning off COMPRESSOR_RUN
} }
docs = collectXmlResponses(urls); docs = collectXmlResponses(urls);
......
...@@ -44,6 +44,9 @@ public class LwirReaderParameters { ...@@ -44,6 +44,9 @@ public class LwirReaderParameters {
public final static int [] FFC_GROUPS= {1,2,4}; public final static int [] FFC_GROUPS= {1,2,4};
public static final String [] SENSOR_TYPES = {"EO","LWIR"}; public static final String [] SENSOR_TYPES = {"EO","LWIR"};
public static final String SENSOR_TYPE = "SENSOR_TYPE"; public static final String SENSOR_TYPE = "SENSOR_TYPE";
public final static int TYPE_EO= 0;
public final static int TYPE_LWIR= 1;
protected static int MAX_LWIR_WIDTH = 1024; // protected static int MAX_LWIR_WIDTH = 1024; //
private boolean parameters_updated = false; private boolean parameters_updated = false;
...@@ -168,7 +171,7 @@ public class LwirReaderParameters { ...@@ -168,7 +171,7 @@ public class LwirReaderParameters {
public int [] getTypeMap() { // eo - 0, lwir - 1 public int [] getTypeMap() { // eo - 0, lwir - 1
int [] types = new int [getNumChannels()]; int [] types = new int [getNumChannels()];
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
types[i] = (i >= getEoChn0())? 0 : 1; types[i] = (i >= getEoChn0())? TYPE_EO : TYPE_LWIR;
} }
return types; return types;
} }
...@@ -195,7 +198,7 @@ public class LwirReaderParameters { ...@@ -195,7 +198,7 @@ public class LwirReaderParameters {
if (imp.getProperty(SENSOR_TYPE)!=null) { if (imp.getProperty(SENSOR_TYPE)!=null) {
return (is_LWIR((String) imp.getProperty(SENSOR_TYPE)))? 1:0; return (is_LWIR((String) imp.getProperty(SENSOR_TYPE)))? 1:0;
} }
return is_LWIR(imp.getWidth())? 1 : 0; return is_LWIR(imp.getWidth())? TYPE_LWIR : TYPE_EO;
} }
......
...@@ -172,7 +172,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -172,7 +172,7 @@ public class ElphelJp4Reader extends ImageIOReader{
try { try {
url = new URL(id); url = new URL(id);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
LOGGER.warn("Bad URL: " + id); LOGGER.warn("Bad URL1: " + id);
} }
if (url != null) { if (url != null) {
LOGGER.debug("Starting initFile() method, read "+ id +" to memory first"); LOGGER.debug("Starting initFile() method, read "+ id +" to memory first");
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
** **
*/ */
package com.elphel.imagej.readers; package com.elphel.imagej.readers;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
...@@ -187,11 +188,21 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -187,11 +188,21 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
url = null; url = null;
// String mime = null; // use to select jp4/tiff later? Or to check it is correct // String mime = null; // use to select jp4/tiff later? Or to check it is correct
content_fileName = null; content_fileName = null;
boolean bad_file = false;
try { try {
url = new URL(id); File test_file = new File(id);
} catch (MalformedURLException e) { test_file.getCanonicalPath();
LOGGER.warn("Bad URL: " + id); } catch (IOException e) {
bad_file = true;
} }
if (bad_file) {
try {
url = new URL(id);
} catch (MalformedURLException e) {
LOGGER.warn("Bad URL2: " + id);
}
}
if (url != null) { if (url != null) {
LOGGER.debug("Starting initFile() method, read "+ id +" to memory first"); LOGGER.debug("Starting initFile() method, read "+ id +" to memory first");
//https://www.rgagnon.com/javadetails/java-0487.html //https://www.rgagnon.com/javadetails/java-0487.html
......
...@@ -258,10 +258,24 @@ the type of pixel data in this file getPixelType() ...@@ -258,10 +258,24 @@ the type of pixel data in this file getPixelType()
ImagePlus imp, ImagePlus imp,
String path String path
){ ){
savePNG_ARGB32(
imp,
path,
1 // will print - for cdompatibility with older code
);
}
public void savePNG_ARGB32(
ImagePlus imp,
String path,
int debug_level
){
int width = imp.getWidth(); int width = imp.getWidth();
int height = imp.getHeight(); int height = imp.getHeight();
int [] pixels = (int []) imp.getProcessor().getPixels(); int [] pixels = (int []) imp.getProcessor().getPixels();
System.out.println("savePNG_ARGB32("+path+"): width="+width+", height="+height+" length="+pixels.length); if (debug_level > 0) {
System.out.println("savePNG_ARGB32("+path+"): width="+width+", height="+height+" length="+pixels.length);
}
DataBufferInt buffer = new DataBufferInt(pixels, pixels.length); DataBufferInt buffer = new DataBufferInt(pixels, pixels.length);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
*/ */
package com.elphel.imagej.readers; package com.elphel.imagej.readers;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
...@@ -141,13 +142,26 @@ public class ImagejJp4Tiff { ...@@ -141,13 +142,26 @@ public class ImagejJp4Tiff {
public ImagePlus readTiffJp4(String path_url, boolean scale, String std ) throws IOException, FormatException { // std - include non-elphel properties with prefix std public ImagePlus readTiffJp4(String path_url, boolean scale, String std ) throws IOException, FormatException { // std - include non-elphel properties with prefix std
// determine if it is a file or URL and read url to memory // determine if it is a file or URL and read url to memory
// If URL, then read to memory, if normal file - use direct access // If URL, then read to memory, if normal file - use direct access
if (path_url == null) {
LOGGER.warn("readTiffJp4(): null path_url");
return null;
}
url = null; url = null;
// String mime = null; // use to select jp4/tiff later? Or to check it is correct // String mime = null; // use to select jp4/tiff later? Or to check it is correct
content_fileName = null; content_fileName = null;
boolean bad_file = false;
try { try {
url = new URL(path_url); File test_file = new File(path_url); // null
} catch (MalformedURLException e) { test_file.getCanonicalPath();
LOGGER.warn("Bad URL: " + path_url); } catch (IOException e) {
bad_file = true;
}
if (bad_file) {
try {
url = new URL(path_url);
} catch (MalformedURLException e) {
LOGGER.warn("Bad URL3: " + path_url);
}
} }
//https://stackoverflow.com/questions/39086500/read-http-response-header-and-body-from-one-http-request-in-java //https://stackoverflow.com/questions/39086500/read-http-response-header-and-body-from-one-http-request-in-java
if (url != null) { if (url != null) {
......
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