Commit 66cd4b7e authored by Andrey Filippov's avatar Andrey Filippov

Simultaneous LWIR/VNIR acquisition: added configurable parameters

parent 3649ef29
...@@ -107,6 +107,17 @@ ...@@ -107,6 +107,17 @@
<resource> <resource>
<directory>${project.build.sourceDirectory}</directory> <directory>${project.build.sourceDirectory}</directory>
</resource> </resource>
<!-- trying to copy deep classes to top for the imageJ to see as plugins-->
<!--
<resource>
<filtering>true</filtering>
<directory>${basedir}/target/classes/com/elphel/imagej/jp4</directory>
<targetPath>${basedir}/target/classes</targetPath>
<includes>
<include>JP46_Reader_camera.class</include>
</includes>
</resource>
-->
</resources> </resources>
<testResources> <testResources>
<testResource> <testResource>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -37,6 +37,7 @@ import java.util.Set; ...@@ -37,6 +37,7 @@ import java.util.Set;
import com.elphel.imagej.calibration.CalibrationFileManagement; import com.elphel.imagej.calibration.CalibrationFileManagement;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.WindowTools; import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.lwir.LwirReaderParameters;
import com.elphel.imagej.tileprocessor.BiQuadParameters; import com.elphel.imagej.tileprocessor.BiQuadParameters;
import com.elphel.imagej.tileprocessor.ImageDtt; import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.ImageDttParameters; import com.elphel.imagej.tileprocessor.ImageDttParameters;
...@@ -3252,6 +3253,8 @@ public class EyesisCorrectionParameters { ...@@ -3252,6 +3253,8 @@ public class EyesisCorrectionParameters {
public BiQuadParameters rig = new BiQuadParameters(); public BiQuadParameters rig = new BiQuadParameters();
public PoleProcessorParameters poles = new PoleProcessorParameters(); public PoleProcessorParameters poles = new PoleProcessorParameters();
public MeasuredLayersFilterParameters mlfp = new MeasuredLayersFilterParameters(); public MeasuredLayersFilterParameters mlfp = new MeasuredLayersFilterParameters();
public LwirReaderParameters lwir = new LwirReaderParameters();
public HashMap<String,Double> z_corr_map = new HashMap<String,Double>(); //old one public HashMap<String,Double> z_corr_map = new HashMap<String,Double>(); //old one
public HashMap<String,Double> infinity_distace_map = new HashMap<String,Double>(); //new one public HashMap<String,Double> infinity_distace_map = new HashMap<String,Double>(); //new one
...@@ -3945,6 +3948,7 @@ public class EyesisCorrectionParameters { ...@@ -3945,6 +3948,7 @@ public class EyesisCorrectionParameters {
mlfp.setProperties (prefix+"_mlfp", properties); mlfp.setProperties (prefix+"_mlfp", properties);
rig.setProperties (prefix+"_rig", properties); rig.setProperties (prefix+"_rig", properties);
poles.setProperties (prefix+"_poles", properties); poles.setProperties (prefix+"_poles", properties);
lwir.setProperties (prefix+"_lwir", properties);
} }
public void setPropertiesInfinityDistance(String prefix,Properties properties){ public void setPropertiesInfinityDistance(String prefix,Properties properties){
...@@ -4653,6 +4657,7 @@ public class EyesisCorrectionParameters { ...@@ -4653,6 +4657,7 @@ public class EyesisCorrectionParameters {
mlfp.getProperties (prefix+"_mlfp", properties); mlfp.getProperties (prefix+"_mlfp", properties);
rig.getProperties (prefix+"_rig", properties); rig.getProperties (prefix+"_rig", properties);
poles.getProperties (prefix+"_poles", properties); poles.getProperties (prefix+"_poles", properties);
lwir.getProperties (prefix+"_lwir", properties);
} }
public boolean showJDialog() { public boolean showJDialog() {
...@@ -5467,9 +5472,13 @@ public class EyesisCorrectionParameters { ...@@ -5467,9 +5472,13 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Show 'flaps-dirs'", this.show_flaps_dirs); gd.addCheckbox ("Show 'flaps-dirs'", this.show_flaps_dirs);
gd.addCheckbox ("Show 'first_N_clusters'", this.show_first_clusters); gd.addCheckbox ("Show 'first_N_clusters'", this.show_first_clusters);
gd.addCheckbox ("Show planes", this.show_planes); gd.addCheckbox ("Show planes", this.show_planes);
gd.addMessage ("Unity up vector in camera coordinate system (x - right, y - up, z - to camera): {"+ 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]+"}"); this.vertical_xyz[0]+","+this.vertical_xyz[1]+","+this.vertical_xyz[2]+"}");
gd.addTab ("LWIR", "parameters for LWIR/VNIR 8-camera rig");
this.lwir.dialogQuestions(gd);
// gd.buildDialog(); // gd.buildDialog();
gd.showDialog(); gd.showDialog();
// System.out.println("gd.wasCanceled="+gd.wasCanceled()); // System.out.println("gd.wasCanceled="+gd.wasCanceled());
...@@ -6150,6 +6159,9 @@ public class EyesisCorrectionParameters { ...@@ -6150,6 +6159,9 @@ public class EyesisCorrectionParameters {
this.show_flaps_dirs= gd.getNextBoolean(); this.show_flaps_dirs= gd.getNextBoolean();
this.show_first_clusters= gd.getNextBoolean(); this.show_first_clusters= gd.getNextBoolean();
this.show_planes= gd.getNextBoolean(); this.show_planes= gd.getNextBoolean();
this.lwir.dialogAnswers(gd);
return true; return true;
} }
......
package com.elphel.imagej.tileprocessor; package com.elphel.imagej.correction;
/** /**
** -----------------------------------------------------------------------------** ** -----------------------------------------------------------------------------**
** Eyesis_Correction.java ** Eyesis_Correction.java
...@@ -80,12 +80,6 @@ import com.elphel.imagej.common.DoubleGaussianBlur; ...@@ -80,12 +80,6 @@ import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
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.correction.BlueLeak;
import com.elphel.imagej.correction.CorrectionColorProc;
import com.elphel.imagej.correction.EyesisCorrections;
import com.elphel.imagej.correction.EyesisDCT;
import com.elphel.imagej.correction.PostProcessing;
import com.elphel.imagej.correction.CorrectionColorProc.ColorGainsParameters;
import com.elphel.imagej.dct.FactorConvKernel; import com.elphel.imagej.dct.FactorConvKernel;
import com.elphel.imagej.gpu.GPUTileProcessor; import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin; import com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin;
...@@ -93,6 +87,11 @@ import com.elphel.imagej.jp4.JP46_Reader_camera; ...@@ -93,6 +87,11 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReader; import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.readers.EyesisTiff; import com.elphel.imagej.readers.EyesisTiff;
import com.elphel.imagej.tensorflow.TensorflowInferModel; import com.elphel.imagej.tensorflow.TensorflowInferModel;
import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.MLStats;
import com.elphel.imagej.tileprocessor.QuadCLT;
import com.elphel.imagej.tileprocessor.TwoQuadCLT;
import ij.CompositeImage; import ij.CompositeImage;
import ij.IJ; import ij.IJ;
...@@ -675,6 +674,7 @@ private Panel panel1, ...@@ -675,6 +674,7 @@ private Panel panel1,
if (LWIR_MODE) { if (LWIR_MODE) {
panelLWIR = new Panel(); panelLWIR = new Panel();
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_TEST", panelLWIR, color_conf_process);
addButton("LWIR_ACQUIRE", panelLWIR, color_conf_process); addButton("LWIR_ACQUIRE", panelLWIR, color_conf_process);
add(panelLWIR); add(panelLWIR);
} }
...@@ -897,6 +897,9 @@ private Panel panel1, ...@@ -897,6 +897,9 @@ private Panel panel1,
if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")"); if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
CLT_PARAMETERS.batch_run = false; CLT_PARAMETERS.batch_run = false;
if (label==null) return; if (label==null) return;
System.out.println("DEBUG_LEVEL = "+DEBUG_LEVEL+", MASTER_DEBUG_LEVEL = "+MASTER_DEBUG_LEVEL);
loci.common.DebugTools.enableLogging((MASTER_DEBUG_LEVEL > 1)?"DEBUG":((MASTER_DEBUG_LEVEL > 0)?"INFO":"ERROR")); // INFO"); // ERROR");
/* ======================================================================== */ /* ======================================================================== */
if (label.equals("Configure spilt")) { if (label.equals("Configure spilt")) {
showSplitBayerToStackDialog(SPLIT_PARAMETERS); showSplitBayerToStackDialog(SPLIT_PARAMETERS);
...@@ -4826,12 +4829,12 @@ private Panel panel1, ...@@ -4826,12 +4829,12 @@ private Panel panel1,
TENSORFLOW_INFER_MODEL.test_tensorflow(keep_empty); TENSORFLOW_INFER_MODEL.test_tensorflow(keep_empty);
return; return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("LWIR_ACQUIRE")) { } else if (label.equals("LWIR_TEST")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
loci.common.DebugTools.enableLogging((DEBUG_LEVEL > 1)?"DEBUG":((DEBUG_LEVEL > 0)?"INFO":"ERROR")); // INFO"); // ERROR"); // loci.common.DebugTools.enableLogging((DEBUG_LEVEL > 1)?"DEBUG":((DEBUG_LEVEL > 0)?"INFO":"ERROR")); // INFO"); // ERROR");
// public static LwirReader LWIR_READER = null; // public static LwirReader LWIR_READER = null;
if (LWIR_READER == null) { if (LWIR_READER == null) {
LWIR_READER = new LwirReader(); LWIR_READER = new LwirReader(CLT_PARAMETERS.lwir);
} }
ImagePlus [][] imps = LWIR_READER.readAllMultiple( ImagePlus [][] imps = LWIR_READER.readAllMultiple(
10, // final int num_frames, 10, // final int num_frames,
...@@ -4841,7 +4844,7 @@ private Panel panel1, ...@@ -4841,7 +4844,7 @@ private Panel panel1,
imp.show(); imp.show();
} }
System.out.println("LWIR_ACQUIRE: got "+imps.length+" image sets"); System.out.println("LWIR_TEST: got "+imps.length+" image sets");
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);
...@@ -4849,6 +4852,20 @@ private Panel panel1, ...@@ -4849,6 +4852,20 @@ private Panel panel1,
imp.show(); imp.show();
} }
} }
/* ======================================================================== */
} else if (label.equals("LWIR_ACQUIRE")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
// loci.common.DebugTools.enableLogging((DEBUG_LEVEL > 1)?"DEBUG":((DEBUG_LEVEL > 0)?"INFO":"ERROR")); // INFO"); // ERROR");
// public static LwirReader LWIR_READER = null;
if (LWIR_READER == null) {
LWIR_READER = new LwirReader(CLT_PARAMETERS.lwir);
}
ImagePlus [] imps = LWIR_READER.acquire();
if (imps != null) {
for (ImagePlus imp: imps) {
imp.show();
}
}
//JTabbedTest //JTabbedTest
// End of buttons code // End of buttons code
...@@ -7675,6 +7692,7 @@ private Panel panel1, ...@@ -7675,6 +7692,7 @@ private Panel panel1,
PSF_SUBPIXEL_SHOULD_BE_4=Integer.parseInt(properties.getProperty("PSF_SUBPIXEL_SHOULD_BE_4")); PSF_SUBPIXEL_SHOULD_BE_4=Integer.parseInt(properties.getProperty("PSF_SUBPIXEL_SHOULD_BE_4"));
if (QUAD_CLT != null) QUAD_CLT.getProperties(QuadCLT.PREFIX); if (QUAD_CLT != null) QUAD_CLT.getProperties(QuadCLT.PREFIX);
if (QUAD_CLT_AUX != null) QUAD_CLT_AUX.getProperties(QuadCLT.PREFIX_AUX); if (QUAD_CLT_AUX != null) QUAD_CLT_AUX.getProperties(QuadCLT.PREFIX_AUX);
} }
/* ======================================================================== */ /* ======================================================================== */
......
...@@ -1434,7 +1434,13 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970 ...@@ -1434,7 +1434,13 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
Class<?> clazz = JP46_Reader_camera.class; Class<?> clazz = JP46_Reader_camera.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString(); String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6); String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
System.out.println(System.getProperty("plugins.dir"));
System.setProperty("plugins.dir", pluginsDir); System.setProperty("plugins.dir", pluginsDir);
// System.setProperty("plugins.dir", "/data_ssd/imagej-elphel/ijplugins");
// System.setProperty("plugins.dir", "/data_ssd/imagej-elphel/target/classes/com/elphel/imagej/jp4/");
System.out.println(System.getProperty("plugins.dir"));
// start ImageJ // start ImageJ
new ImageJ(); new ImageJ();
// run the plugin // run the plugin
......
This diff is collapsed.
...@@ -105,7 +105,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -105,7 +105,7 @@ public class ElphelJp4Reader extends ImageIOReader{
// or these readers are combined with all other readers in readers.txt // or these readers are combined with all other readers in readers.txt
suffixNecessary = true; // false suffixNecessary = true; // false
suffixSufficient = true; // false; suffixSufficient = true; // false;
LOGGER.info("ElphelTiffReader(), after super()"); LOGGER.debug("ElphelTiffReader(), after super()");
if (REPLACEMENT_TAG_MAP == null) { if (REPLACEMENT_TAG_MAP == null) {
REPLACEMENT_TAG_MAP = new HashMap<String,String>(); REPLACEMENT_TAG_MAP = new HashMap<String,String>();
for (String [] line: REPLACEMENT_TAGS) { for (String [] line: REPLACEMENT_TAGS) {
...@@ -162,7 +162,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -162,7 +162,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.debug("id '"+id+"' is already mapped" ); LOGGER.debug("id '"+id+"' is already mapped" );
content_fileName = id; // id; // maybe set to null to handle externally? content_fileName = id; // id; // maybe set to null to handle externally?
mapped_externally = true; mapped_externally = true;
LOGGER.info("Starting initFile() method, read file directly"); LOGGER.debug("Starting initFile() method, read file directly");
super.setId(id); super.setId(id);
} else { } else {
// If URL, then read to memory, if normal file - use direct access // If URL, then read to memory, if normal file - use direct access
...@@ -175,7 +175,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -175,7 +175,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.warn("Bad URL: " + id); LOGGER.warn("Bad URL: " + id);
} }
if (url != null) { if (url != null) {
LOGGER.info("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
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
...@@ -192,20 +192,20 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -192,20 +192,20 @@ public class ElphelJp4Reader extends ImageIOReader{
content_fileName = "unknown." + suffix; content_fileName = "unknown." + suffix;
} }
// currentId = fileName; //??? // currentId = fileName; //???
// LOGGER.info("Mime type = "+mime); // LOGGER.debug("Mime type = "+mime);
// https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests // https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
//https://stackoverflow.com/questions/2295221/java-net-url-read-stream-to-byte //https://stackoverflow.com/questions/2295221/java-net-url-read-stream-to-byte
InputStream is = url.openStream (); // InputStream is = url.openStream (); //
byte[] inBytes = IOUtils.toByteArray(is); byte[] inBytes = IOUtils.toByteArray(is);
if (is != null) is.close(); if (is != null) is.close();
LOGGER.info("Bytes read: "+ inBytes.length); LOGGER.debug("Bytes read: "+ inBytes.length);
Location.mapFile(content_fileName, new ByteArrayHandle(inBytes)); Location.mapFile(content_fileName, new ByteArrayHandle(inBytes));
// HashMap<String,Object> dbg_loc = Location.getIdMap(); // HashMap<String,Object> dbg_loc = Location.getIdMap();
super.setId(content_fileName); super.setId(content_fileName);
} else { // read file normally } else { // read file normally
content_fileName = id; content_fileName = id;
LOGGER.info("read file directly"); LOGGER.debug("read file directly");
super.setId(id); super.setId(id);
} }
} }
...@@ -229,7 +229,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -229,7 +229,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.debug("initFile("+id+"), currentId="+currentId+", after super" ); LOGGER.debug("initFile("+id+"), currentId="+currentId+", after super" );
// Below needs to be modified - EXIFService does not work with mapFile // Below needs to be modified - EXIFService does not work with mapFile
MetadataStore store = makeFilterMetadata(); MetadataStore store = makeFilterMetadata();
LOGGER.info("Parsing JPEG EXIF data"); LOGGER.debug("Parsing JPEG EXIF data");
HashMap<String, String> tags = null; HashMap<String, String> tags = null;
try { try {
// Reimplementing ExifServiceImpl as original does not have ExifIFD0Directory // Reimplementing ExifServiceImpl as original does not have ExifIFD0Directory
...@@ -307,14 +307,14 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -307,14 +307,14 @@ public class ElphelJp4Reader extends ImageIOReader{
int bytes_per_pixel = 1; int bytes_per_pixel = 1;
Hashtable<String, String> property_table = ElphelMeta.getMeta( Hashtable<String, String> property_table = ElphelMeta.getMeta(
null, maker_note, exposure, date_time, bytes_per_pixel, true ); null, maker_note, exposure, date_time, bytes_per_pixel, true );
LOGGER.info("Created elphelMeta table, size="+property_table.size()); LOGGER.debug("Created elphelMeta table, size="+property_table.size());
for (String key:property_table.keySet()) { for (String key:property_table.keySet()) {
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key)); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key));
} }
MetadataLevel level = getMetadataOptions().getMetadataLevel(); MetadataLevel level = getMetadataOptions().getMetadataLevel();
if (level != MetadataLevel.MINIMUM) { if (level != MetadataLevel.MINIMUM) {
// Integer[] tags = ifds.get(0).keySet().toArray(new Integer[0]); // Integer[] tags = ifds.get(0).keySet().toArray(new Integer[0]);
// LOGGER.info("initStandardMetadata() - got "+tags.length+" tags"); // LOGGER.debug("initStandardMetadata() - got "+tags.length+" tags");
} }
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName);
...@@ -328,9 +328,9 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -328,9 +328,9 @@ public class ElphelJp4Reader extends ImageIOReader{
// HashMap<String,Object> dbg_loc = Location.getIdMap(); // HashMap<String,Object> dbg_loc = Location.getIdMap();
String saveCurrentId = currentId; String saveCurrentId = currentId;
currentId = null; currentId = null;
LOGGER.info("close("+fileOnly+") before super"); LOGGER.debug("close("+fileOnly+") before super");
super.close(fileOnly); // curerent_id == null only during actual close? super.close(fileOnly); // curerent_id == null only during actual close?
LOGGER.info("close("+fileOnly+") after super"); LOGGER.debug("close("+fileOnly+") after super");
currentId = saveCurrentId; currentId = saveCurrentId;
// if ((content_fileName != null) && file_initialized){ // if ((content_fileName != null) && file_initialized){
if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK
...@@ -370,7 +370,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -370,7 +370,7 @@ public class ElphelJp4Reader extends ImageIOReader{
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
throws FormatException, IOException throws FormatException, IOException
{ {
LOGGER.info("openBytes() - before super()"); LOGGER.debug("openBytes() - before super()");
FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h);
if (image_bytes == null) { if (image_bytes == null) {
jp4Decode(no); jp4Decode(no);
...@@ -386,7 +386,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -386,7 +386,7 @@ public class ElphelJp4Reader extends ImageIOReader{
w); w);
dest += w; dest += w;
} }
LOGGER.info("openBytes() - after super()"); LOGGER.debug("openBytes() - after super()");
return buf; return buf;
} }
public void jp4Decode(int no) throws FormatException, IOException { public void jp4Decode(int no) throws FormatException, IOException {
...@@ -421,7 +421,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -421,7 +421,7 @@ public class ElphelJp4Reader extends ImageIOReader{
} else { } else {
image_bytes = ib; // temporary image_bytes = ib; // temporary
} }
LOGGER.info("jp4Decode()"); LOGGER.debug("jp4Decode()");
} }
} }
...@@ -130,7 +130,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -130,7 +130,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
suffixNecessary = true; // false suffixNecessary = true; // false
suffixSufficient = true; // false; suffixSufficient = true; // false;
/// mergeSubIFDs = true; // false; /// mergeSubIFDs = true; // false;
LOGGER.info("ElphelTiffReader(), after supper(), mergeSubIFDs = true;"); LOGGER.debug("ElphelTiffReader(), after supper(), mergeSubIFDs = true;");
} }
// -- IFormatReader API methods -- // -- IFormatReader API methods --
...@@ -177,7 +177,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -177,7 +177,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
LOGGER.debug("id '"+id+"' is already mapped" ); LOGGER.debug("id '"+id+"' is already mapped" );
content_fileName = id; // id; // maybe set to null to handle externally? content_fileName = id; // id; // maybe set to null to handle externally?
mapped_externally = true; mapped_externally = true;
LOGGER.info("Starting setId() method, read file directly"); LOGGER.debug("Starting setId() method, read file directly");
super.setId(id); super.setId(id);
} else { } else {
// If URL, then read to memory, if normal file - use direct access // If URL, then read to memory, if normal file - use direct access
...@@ -193,7 +193,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -193,7 +193,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
LOGGER.warn("Bad URL: " + id); LOGGER.warn("Bad URL: " + id);
} }
if (url != null) { if (url != null) {
LOGGER.info("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
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
...@@ -210,20 +210,20 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -210,20 +210,20 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
content_fileName = "unknown." + suffix; content_fileName = "unknown." + suffix;
} }
// currentId = fileName; //??? // currentId = fileName; //???
// LOGGER.info("Mime type = "+mime); // LOGGER.debug("Mime type = "+mime);
// https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests // https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
//https://stackoverflow.com/questions/2295221/java-net-url-read-stream-to-byte //https://stackoverflow.com/questions/2295221/java-net-url-read-stream-to-byte
InputStream is = url.openStream (); // InputStream is = url.openStream (); //
byte[] inBytes = IOUtils.toByteArray(is); byte[] inBytes = IOUtils.toByteArray(is);
if (is != null) is.close(); if (is != null) is.close();
LOGGER.info("Bytes read: "+ inBytes.length); LOGGER.debug("Bytes read: "+ inBytes.length);
Location.mapFile(content_fileName, new ByteArrayHandle(inBytes)); Location.mapFile(content_fileName, new ByteArrayHandle(inBytes));
// HashMap<String,Object> dbg_loc = Location.getIdMap(); // HashMap<String,Object> dbg_loc = Location.getIdMap();
super.setId(content_fileName); super.setId(content_fileName);
} else { // read file normally } else { // read file normally
content_fileName = id; content_fileName = id;
LOGGER.info("read file directly"); LOGGER.debug("read file directly");
super.setId(id); super.setId(id);
} }
} }
...@@ -241,9 +241,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -241,9 +241,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
{ {
// Trying ServiceFactory before it is going to be initialized, so static defaultFactory will be initialized // Trying ServiceFactory before it is going to be initialized, so static defaultFactory will be initialized
// with small set of services - only needed for Elphel // with small set of services - only needed for Elphel
LOGGER.info("Starting initFile() method"); LOGGER.debug("Starting initFile() method");
super.initFile(id); super.initFile(id);
LOGGER.info("Ending initFile() method"); LOGGER.debug("Ending initFile() method");
} }
...@@ -262,9 +262,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -262,9 +262,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
/* @see loci.formats.IFormatReader#close(boolean) */ /* @see loci.formats.IFormatReader#close(boolean) */
@Override @Override
public void close(boolean fileOnly) throws IOException { public void close(boolean fileOnly) throws IOException {
LOGGER.info("close("+fileOnly+") before super"); LOGGER.debug("close("+fileOnly+") before super");
super.close(fileOnly); // curerent_id == null only during actual close? super.close(fileOnly); // curerent_id == null only during actual close?
LOGGER.info("close("+fileOnly+") after super"); LOGGER.debug("close("+fileOnly+") after super");
// if ((content_fileName != null) && file_initialized){ // if ((content_fileName != null) && file_initialized){
if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK
Location.mapFile(content_fileName, null); Location.mapFile(content_fileName, null);
...@@ -288,10 +288,10 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -288,10 +288,10 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
/* @see BaseTiffReader#initStandardMetadata() */ /* @see BaseTiffReader#initStandardMetadata() */
@Override @Override
protected void initStandardMetadata() throws FormatException, IOException { protected void initStandardMetadata() throws FormatException, IOException {
LOGGER.info("initStandardMetadata() - before super()"); LOGGER.debug("initStandardMetadata() - before super()");
super.initStandardMetadata(); super.initStandardMetadata();
String comment = ifds.get(0).getComment(); // IMAGE_DESCRIPTION String comment = ifds.get(0).getComment(); // IMAGE_DESCRIPTION
LOGGER.info("initStandardMetadata() - after super()"); LOGGER.debug("initStandardMetadata() - after super()");
long[] maker_note = null; long[] maker_note = null;
double exposure = Double.NaN; double exposure = Double.NaN;
String date_time = null; String date_time = null;
...@@ -330,14 +330,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -330,14 +330,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
null, maker_note, exposure, date_time, bytes_per_pixel, true ); null, maker_note, exposure, date_time, bytes_per_pixel, true );
LOGGER.info("Created elphelMeta table, size="+property_table.size()); LOGGER.debug("Created elphelMeta table, size="+property_table.size());
for (String key:property_table.keySet()) { for (String key:property_table.keySet()) {
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key)); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key));
} }
MetadataLevel level = getMetadataOptions().getMetadataLevel(); MetadataLevel level = getMetadataOptions().getMetadataLevel();
if (level != MetadataLevel.MINIMUM) { if (level != MetadataLevel.MINIMUM) {
Integer[] tags = ifds.get(0).keySet().toArray(new Integer[0]); Integer[] tags = ifds.get(0).keySet().toArray(new Integer[0]);
LOGGER.info("initStandardMetadata() - got "+tags.length+" tags"); LOGGER.debug("initStandardMetadata() - got "+tags.length+" tags");
} }
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName);
// convert MAKER_NOTE to the same text format as in com.drew.metadata // convert MAKER_NOTE to the same text format as in com.drew.metadata
...@@ -410,9 +410,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -410,9 +410,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
throws FormatException, IOException throws FormatException, IOException
{ {
LOGGER.info("openBytes() - before super()"); LOGGER.debug("openBytes() - before super()");
super.openBytes(no, buf, x, y, w, h); super.openBytes(no, buf, x, y, w, h);
LOGGER.info("openBytes() - after super()"); LOGGER.debug("openBytes() - after super()");
return buf; return buf;
} }
......
...@@ -66,6 +66,7 @@ public class ImagejJp4Tiff { ...@@ -66,6 +66,7 @@ public class ImagejJp4Tiff {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassList.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassList.class);
private static final boolean BYPASS_SERVICES = false; // true; private static final boolean BYPASS_SERVICES = false; // true;
private static final String SERVICES_PATH = "services.properties.forelphel"; private static final String SERVICES_PATH = "services.properties.forelphel";
private static final boolean KEEP_EXTENSION = false; // remove extension for ImagePlus title
// -- Fields -- // -- Fields --
...@@ -151,7 +152,7 @@ public class ImagejJp4Tiff { ...@@ -151,7 +152,7 @@ public class ImagejJp4Tiff {
if (url != null) { if (url != null) {
LOGGER.error("Read "+ path_url +" to memory first"); LOGGER.error("Read "+ path_url +" to memory first");
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
// Wrong - waits forever
String content_disposition = connection.getHeaderField("Content-Disposition"); // reads file String content_disposition = connection.getHeaderField("Content-Disposition"); // reads file
// raw = "attachment; filename=abc.jpg" // raw = "attachment; filename=abc.jpg"
if(content_disposition != null && content_disposition.indexOf("=") != -1) { if(content_disposition != null && content_disposition.indexOf("=") != -1) {
...@@ -217,6 +218,12 @@ public class ImagejJp4Tiff { ...@@ -217,6 +218,12 @@ public class ImagejJp4Tiff {
if (meta_hash.containsKey(imageNameKey)) { if (meta_hash.containsKey(imageNameKey)) {
imageName = meta_hash.get(imageNameKey).toString(); imageName = meta_hash.get(imageNameKey).toString();
} }
if (!KEEP_EXTENSION) {
int dot_indx = imageName.lastIndexOf(".");
if (dot_indx >= 0) {
imageName = imageName.substring(0, dot_indx);
}
}
imp = new ImagePlus(imageName, ip); // original jp46 reader had full path as title imp = new ImagePlus(imageName, ip); // original jp46 reader had full path as title
// first - save all as properties, later - only ELPHEL_* // first - save all as properties, later - only ELPHEL_*
......
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