Commit 681a226e authored by Andrey Filippov's avatar Andrey Filippov

Improved ML output, testing batch execution

parent 77684393
...@@ -201,7 +201,10 @@ public class EyesisCorrectionParameters { ...@@ -201,7 +201,10 @@ public class EyesisCorrectionParameters {
public String x3dModelVersion="v01"; public String x3dModelVersion="v01";
public String jp4SubDir="jp4"; // FIXME: public String jp4SubDir="jp4"; // FIXME:
public String linkedModels=""; // linked models with reference scenes
public String x3dDirectory=""; public String x3dDirectory="";
public String videoDirectory=""; // combined (with MPEG) from multiple scene sequences video files
public String mlDirectory="ml"; public String mlDirectory="ml";
...@@ -308,6 +311,8 @@ public class EyesisCorrectionParameters { ...@@ -308,6 +311,8 @@ public class EyesisCorrectionParameters {
cp.referenceExposure= this.referenceExposure; cp.referenceExposure= this.referenceExposure;
cp.relativeExposure= this.relativeExposure; cp.relativeExposure= this.relativeExposure;
cp.swapSubchannels01= this.swapSubchannels01; cp.swapSubchannels01= this.swapSubchannels01;
cp.linkedModels= this.linkedModels;
cp.videoDirectory= this.videoDirectory;
cp.x3dDirectory= this.x3dDirectory; cp.x3dDirectory= this.x3dDirectory;
cp.mlDirectory= this.mlDirectory; cp.mlDirectory= this.mlDirectory;
cp.use_x3d_subdirs= this.use_x3d_subdirs; cp.use_x3d_subdirs= this.use_x3d_subdirs;
...@@ -514,6 +519,8 @@ public class EyesisCorrectionParameters { ...@@ -514,6 +519,8 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"cltKernelPrefix", this.cltKernelPrefix); properties.setProperty(prefix+"cltKernelPrefix", this.cltKernelPrefix);
properties.setProperty(prefix+"cltSuffix", this.cltSuffix); properties.setProperty(prefix+"cltSuffix", this.cltSuffix);
properties.setProperty(prefix+"linkedModels", this.linkedModels);
properties.setProperty(prefix+"videoDirectory", this.videoDirectory);
properties.setProperty(prefix+"x3dDirectory", this.x3dDirectory); properties.setProperty(prefix+"x3dDirectory", this.x3dDirectory);
properties.setProperty(prefix+"use_x3d_subdirs", this.use_x3d_subdirs+""); properties.setProperty(prefix+"use_x3d_subdirs", this.use_x3d_subdirs+"");
...@@ -701,6 +708,8 @@ public class EyesisCorrectionParameters { ...@@ -701,6 +708,8 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"cltKernelPrefix")!= null) this.cltKernelPrefix=properties.getProperty(prefix+"cltKernelPrefix"); if (properties.getProperty(prefix+"cltKernelPrefix")!= null) this.cltKernelPrefix=properties.getProperty(prefix+"cltKernelPrefix");
if (properties.getProperty(prefix+"cltSuffix")!= null) this.cltSuffix=properties.getProperty(prefix+"cltSuffix"); if (properties.getProperty(prefix+"cltSuffix")!= null) this.cltSuffix=properties.getProperty(prefix+"cltSuffix");
if (properties.getProperty(prefix+"linkedModels")!= null) this.linkedModels=properties.getProperty(prefix+"linkedModels");
if (properties.getProperty(prefix+"videoDirectory")!= null) this.videoDirectory=properties.getProperty(prefix+"videoDirectory");
if (properties.getProperty(prefix+"x3dDirectory")!= null) this.x3dDirectory=properties.getProperty(prefix+"x3dDirectory"); if (properties.getProperty(prefix+"x3dDirectory")!= null) this.x3dDirectory=properties.getProperty(prefix+"x3dDirectory");
if (properties.getProperty(prefix+"use_x3d_subdirs")!= null) this.use_x3d_subdirs=Boolean.parseBoolean(properties.getProperty(prefix+"use_x3d_subdirs")); if (properties.getProperty(prefix+"use_x3d_subdirs")!= null) this.use_x3d_subdirs=Boolean.parseBoolean(properties.getProperty(prefix+"use_x3d_subdirs"));
...@@ -870,8 +879,18 @@ public class EyesisCorrectionParameters { ...@@ -870,8 +879,18 @@ public class EyesisCorrectionParameters {
gd.addStringField ("x3d model version", this.x3dModelVersion, 20); // 10a gd.addStringField ("x3d model version", this.x3dModelVersion, 20); // 10a
gd.addStringField ("JP4 source image copy model subdirectory", this.jp4SubDir, 20); // 10b gd.addStringField ("JP4 source image copy model subdirectory", this.jp4SubDir, 20); // 10b
gd.addStringField ("Linked reference models", this.linkedModels, 60,
"Directory where links to reference models directories will be created.");
gd.addCheckbox ("Select linked reference models directory", false);
gd.addStringField ("Video directory", this.videoDirectory, 60,
"Directory to store combined video files.");
gd.addCheckbox ("Select video directory", false);
gd.addStringField ("x3d output directory", this.x3dDirectory, 60); gd.addStringField ("x3d output directory", this.x3dDirectory, 60);
gd.addCheckbox ("Select x3d output directory", false); gd.addCheckbox ("Select x3d output directory", false);
gd.addCheckbox ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs); gd.addCheckbox ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs);
gd.addStringField ("x3d subdirectory prefix", this.x3dSubdirPrefix, 10, gd.addStringField ("x3d subdirectory prefix", this.x3dSubdirPrefix, 10,
...@@ -994,6 +1013,8 @@ public class EyesisCorrectionParameters { ...@@ -994,6 +1013,8 @@ public class EyesisCorrectionParameters {
this.cltKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true); this.cltKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true);
this.x3dModelVersion= gd.getNextString(); // 10a this.x3dModelVersion= gd.getNextString(); // 10a
this.jp4SubDir= gd.getNextString(); // 10b this.jp4SubDir= gd.getNextString(); // 10b
this.linkedModels= gd.getNextString(); if (gd.getNextBoolean()) selectLinkedModelsDirectory(false, true);
this.videoDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectVideoDirectory(false, true);
this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true); this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true);
this.use_x3d_subdirs= gd.getNextBoolean(); this.use_x3d_subdirs= gd.getNextBoolean();
...@@ -1065,6 +1086,15 @@ public class EyesisCorrectionParameters { ...@@ -1065,6 +1086,15 @@ public class EyesisCorrectionParameters {
gd.addStringField ("x3d model version", this.x3dModelVersion, 60); // 10a gd.addStringField ("x3d model version", this.x3dModelVersion, 60); // 10a
gd.addStringField ("jp4 source copy subdirectory", this.jp4SubDir, 60); // 10b gd.addStringField ("jp4 source copy subdirectory", this.jp4SubDir, 60); // 10b
gd.addStringField ("Linked reference models", this.linkedModels, 60,
"Directory where links to reference models directories will be created.");
gd.addCheckbox ("Select linked reference models directory", false);
gd.addStringField ("Video directory", this.videoDirectory, 60,
"Directory to store combined video files.");
gd.addCheckbox ("Select video directory", false);
gd.addStringField ("x3d output directory", this.x3dDirectory, 60); // 8 gd.addStringField ("x3d output directory", this.x3dDirectory, 60); // 8
gd.addCheckbox ("Select x3d output (top model) directory", false); // 9 gd.addCheckbox ("Select x3d output (top model) directory", false); // 9
...@@ -1230,6 +1260,8 @@ public class EyesisCorrectionParameters { ...@@ -1230,6 +1260,8 @@ public class EyesisCorrectionParameters {
this.x3dModelVersion= gd.getNextString(); // 10a this.x3dModelVersion= gd.getNextString(); // 10a
this.jp4SubDir= gd.getNextString(); // 10b this.jp4SubDir= gd.getNextString(); // 10b
this.linkedModels= gd.getNextString(); if (gd.getNextBoolean()) selectLinkedModelsDirectory(false, true);
this.videoDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectVideoDirectory(false, true);
this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true); // 9 this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true); // 9
this.use_x3d_subdirs= gd.getNextBoolean(); // 10 this.use_x3d_subdirs= gd.getNextBoolean(); // 10
// this.sourcePrefix= gd.getNextString(); // 13 // this.sourcePrefix= gd.getNextString(); // 13
...@@ -2192,6 +2224,31 @@ public class EyesisCorrectionParameters { ...@@ -2192,6 +2224,31 @@ public class EyesisCorrectionParameters {
return dir; return dir;
} }
public String selectLinkedModelsDirectory(boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"linked models directory", // title
"Select linked models directory", // button
null, // filter
this.linkedModels); //this.sourceDirectory);
if (dir!=null) this.linkedModels=dir;
return dir;
}
public String selectVideoDirectory(boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"video directory", // title
"Select video directory", // button
null, // filter
this.videoDirectory); //this.sourceDirectory);
if (dir!=null) this.videoDirectory=dir;
return dir;
}
public String selectMlDirectory(String name, boolean smart, boolean newAllowed) { public String selectMlDirectory(String name, boolean smart, boolean newAllowed) {
if ((name != null) && (this.mlDirectory.length()>0) && (!this.mlDirectory.contains(Prefs.getFileSeparator()))) { if ((name != null) && (this.mlDirectory.length()>0) && (!this.mlDirectory.contains(Prefs.getFileSeparator()))) {
// relative to the X3D model version // relative to the X3D model version
...@@ -2218,7 +2275,6 @@ public class EyesisCorrectionParameters { ...@@ -2218,7 +2275,6 @@ public class EyesisCorrectionParameters {
// select qualified (by 'name' - quad timestamp) x3d subdirectory // select qualified (by 'name' - quad timestamp) x3d subdirectory
public String selectX3dDirectory(String name, String version, boolean smart, boolean newAllowed) { public String selectX3dDirectory(String name, String version, boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory( String dir= CalibrationFileManagement.selectDirectory(
smart, smart,
newAllowed, // save newAllowed, // save
......
...@@ -1118,14 +1118,17 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -1118,14 +1118,17 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
default: default:
LOG_LEVEL = "OFF"; LOG_LEVEL = "OFF";
} }
LOG_LEVEL = "ERROR"; // setting it here to shut up?
boolean LOG_LEVEL_SET = loci.common.DebugTools.enableLogging(LOG_LEVEL); boolean LOG_LEVEL_SET = loci.common.DebugTools.enableLogging(LOG_LEVEL);
if (!LOG_LEVEL_SET) { // only first time true if (!LOG_LEVEL_SET) { // only first time true
loci.common.DebugTools.setRootLevel(LOG_LEVEL); loci.common.DebugTools.setRootLevel(LOG_LEVEL);
} }
System.out.println("DEBUG_LEVEL = " + DEBUG_LEVEL + ", CLT_PARAMETERS.lwir.getDebugLevel() = " System.out.println("DEBUG_LEVEL = " + DEBUG_LEVEL + ", CLT_PARAMETERS.lwir.getDebugLevel() = "
+ CLT_PARAMETERS.lwir.getDebugLevel() + " LOG_LEVEL=" + LOG_LEVEL + "LOG_LEVEL_SET=" + CLT_PARAMETERS.lwir.getDebugLevel() + " LOG_LEVEL=" + LOG_LEVEL + " LOG_LEVEL_SET="
+ LOG_LEVEL_SET); + LOG_LEVEL_SET);
//https://www.javadoc.io/doc/org.openmicroscopy/ome-common/6.0.5/loci/common/DebugTools.html#enableLogging(java.lang.String)
// Temporary overwrite with public static boolean enableIJLogging​(boolean debug)
loci.common.DebugTools.enableIJLogging(false);
} }
/* ======================================================================== */ /* ======================================================================== */
......
...@@ -107,7 +107,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -107,7 +107,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.debug("ElphelTiffReader(), after super()"); LOGGER.info("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) {
...@@ -156,15 +156,15 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -156,15 +156,15 @@ public class ElphelJp4Reader extends ImageIOReader{
public void setId(String id) throws FormatException, IOException { // same as for tiff? public void setId(String id) throws FormatException, IOException { // same as for tiff?
image_bytes = null; image_bytes = null;
// buffered_data = null; // buffered_data = null;
LOGGER.debug("setId("+id+"). before super" ); LOGGER.info("setId("+id+"). before super" );
file_initialized = false; file_initialized = false;
mapped_externally = false; mapped_externally = false;
if (Location.getIdMap().containsKey(id)) { if (Location.getIdMap().containsKey(id)) {
LOGGER.debug("id '"+id+"' is already mapped" ); LOGGER.info("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.debug("Starting initFile() method, read file directly"); LOGGER.info("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
...@@ -177,7 +177,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -177,7 +177,7 @@ public class ElphelJp4Reader extends ImageIOReader{
// LOGGER.warn("Bad URL1: " + id); // will try direct file, not an error // LOGGER.warn("Bad URL1: " + id); // will try direct file, not an error
} }
if (url != null) { if (url != null) {
LOGGER.debug("Starting initFile() method, read "+ id +" to memory first"); LOGGER.info("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();
...@@ -194,44 +194,44 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -194,44 +194,44 @@ public class ElphelJp4Reader extends ImageIOReader{
content_fileName = "unknown." + suffix; content_fileName = "unknown." + suffix;
} }
// currentId = fileName; //??? // currentId = fileName; //???
// LOGGER.debug("Mime type = "+mime); // LOGGER.info("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.debug("Bytes read: "+ inBytes.length); LOGGER.info("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.debug("read file directly"); LOGGER.info("read file directly");
super.setId(id); super.setId(id);
} }
} }
//getReader //getReader
// super.setId(id); // super.setId(id);
LOGGER.debug("setId("+id+"). after super" ); LOGGER.info("setId("+id+"). after super" );
file_initialized = true; file_initialized = true;
} }
/* @see loci.formats.FormatReader#initFile(String) */ /* @see loci.formats.FormatReader#initFile(String) */
@Override @Override
protected void initFile(String id) throws FormatException, IOException { protected void initFile(String id) throws FormatException, IOException {
LOGGER.debug("initFile("+id+"), currentId="+currentId+", before super" ); LOGGER.info("initFile("+id+"), currentId="+currentId+", before super" );
try { try {
super.initFile(id); // fails class_not_found super.initFile(id); // fails class_not_found
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
throw new FormatException(e); throw new FormatException(e);
} }
LOGGER.debug("initFile("+id+"), currentId="+currentId+", after super" ); LOGGER.info("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.debug("Parsing JPEG EXIF data"); LOGGER.info("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
...@@ -295,7 +295,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -295,7 +295,7 @@ public class ElphelJp4Reader extends ImageIOReader{
} }
catch (ServiceException e) { catch (ServiceException e) {
LOGGER.debug("Could not parse EXIF data", e); LOGGER.info("Could not parse EXIF data", e);
} }
long [] maker_note = null; long [] maker_note = null;
double exposure = Double.NaN; double exposure = Double.NaN;
...@@ -324,14 +324,14 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -324,14 +324,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.debug("Created elphelMeta table, size="+property_table.size()); LOGGER.info("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.debug("initStandardMetadata() - got "+tags.length+" tags"); // LOGGER.info("initStandardMetadata() - got "+tags.length+" tags");
} }
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName);
} }
...@@ -343,9 +343,9 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -343,9 +343,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.debug("close("+fileOnly+") before super"); LOGGER.info("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.debug("close("+fileOnly+") after super"); LOGGER.info("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
...@@ -385,7 +385,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -385,7 +385,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.debug("openBytes() - before super()"); LOGGER.info("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);
...@@ -401,7 +401,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -401,7 +401,7 @@ public class ElphelJp4Reader extends ImageIOReader{
w); w);
dest += w; dest += w;
} }
LOGGER.debug("openBytes() - after super()"); LOGGER.info("openBytes() - after super()");
return buf; return buf;
} }
public void jp4Decode(int no) throws FormatException, IOException { public void jp4Decode(int no) throws FormatException, IOException {
...@@ -436,7 +436,7 @@ public class ElphelJp4Reader extends ImageIOReader{ ...@@ -436,7 +436,7 @@ public class ElphelJp4Reader extends ImageIOReader{
} else { } else {
image_bytes = ib; // temporary image_bytes = ib; // temporary
} }
LOGGER.debug("jp4Decode()"); LOGGER.info("jp4Decode()");
} }
} }
...@@ -40,6 +40,8 @@ import org.apache.commons.compress.utils.IOUtils; ...@@ -40,6 +40,8 @@ import org.apache.commons.compress.utils.IOUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
///import ch.qos.logback.classic.Level;
///import ch.qos.logback.classic.Logger;
import com.drew.imaging.ImageMetadataReader; import com.drew.imaging.ImageMetadataReader;
import com.drew.metadata.Metadata; import com.drew.metadata.Metadata;
...@@ -162,10 +164,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -162,10 +164,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
// mergeSubIFDs = true; // false; // mergeSubIFDs = true; // false;
// TODO: See if the selection is just between 2 readers (jp4 and tiff - just Elphel cameras), // TODO: See if the selection is just between 2 readers (jp4 and tiff - just Elphel cameras),
// or these readers are combined with all other readers in readers.txt // or these readers are combined with all other readers in readers.txt
//https://stackoverflow.com/questions/3837801/how-to-change-root-logging-level-programmatically-for-logback
// LOGGER.setLevel(Level.ERROR);
// Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
// root.setLevel(Level.ERROR);
suffixNecessary = true; // false suffixNecessary = true; // false
suffixSufficient = true; // false; suffixSufficient = true; // false;
/// mergeSubIFDs = true; // false; /// mergeSubIFDs = true; // false;
LOGGER.debug("ElphelTiffReader(), after supper(), mergeSubIFDs = true;"); LOGGER.info("ElphelTiffReader(), after supper(), mergeSubIFDs = true;");
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) {
...@@ -211,14 +217,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -211,14 +217,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
@Override @Override
public void setId(String id) throws FormatException, IOException { public void setId(String id) throws FormatException, IOException {
LOGGER.debug("setId("+id+"). before super" ); LOGGER.info("setId("+id+"). before super" );
file_initialized = false; file_initialized = false;
mapped_externally = false; mapped_externally = false;
if (Location.getIdMap().containsKey(id)) { if (Location.getIdMap().containsKey(id)) {
LOGGER.debug("id '"+id+"' is already mapped" ); LOGGER.info("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.debug("Starting setId() method, read file directly"); LOGGER.info("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
...@@ -244,7 +250,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -244,7 +250,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
} }
if (url != null) { if (url != null) {
LOGGER.debug("Starting initFile() method, read "+ id +" to memory first"); LOGGER.info("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();
...@@ -261,27 +267,27 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -261,27 +267,27 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
content_fileName = "unknown." + suffix; content_fileName = "unknown." + suffix;
} }
// currentId = fileName; //??? // currentId = fileName; //???
// LOGGER.debug("Mime type = "+mime); // LOGGER.info("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.debug("Bytes read: "+ inBytes.length); LOGGER.info("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.debug("read file directly"); LOGGER.info("read file directly");
super.setId(id); super.setId(id);
} }
} }
//getReader //getReader
// super.setId(id); // super.setId(id);
LOGGER.debug("setId("+id+"). after super" ); LOGGER.info("setId("+id+"). after super" );
file_initialized = true; file_initialized = true;
} }
...@@ -292,26 +298,26 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -292,26 +298,26 @@ 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.debug("Starting initFile() method"); LOGGER.info("Starting initFile() method");
super.initFile(id); super.initFile(id);
LOGGER.debug("Ending initFile() method"); LOGGER.info("Ending initFile() method");
} }
/* @see loci.formats.FormatReader#initFile(String) */ /* @see loci.formats.FormatReader#initFile(String) */
// copied from ElphelJp4Reader // copied from ElphelJp4Reader
@Override @Override
protected void initFile(String id) throws FormatException, IOException { protected void initFile(String id) throws FormatException, IOException {
LOGGER.debug("initFile("+id+"), currentId="+currentId+", before super" ); LOGGER.info("initFile("+id+"), currentId="+currentId+", before super" );
try { try {
super.initFile(id); // fails class_not_found super.initFile(id); // fails class_not_found
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
throw new FormatException(e); throw new FormatException(e);
} }
LOGGER.debug("initFile("+id+"), currentId="+currentId+", after super" ); LOGGER.info("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.debug("Parsing TIFF EXIF data"); LOGGER.info("Parsing TIFF 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
...@@ -378,7 +384,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -378,7 +384,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
} }
catch (ServiceException e) { catch (ServiceException e) {
LOGGER.debug("Could not parse EXIF data", e); LOGGER.info("Could not parse EXIF data", e);
} }
long [] maker_note = null; long [] maker_note = null;
double exposure = Double.NaN; double exposure = Double.NaN;
...@@ -409,14 +415,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -409,14 +415,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
int bytes_per_pixel = (bpp + 7) / 9; int bytes_per_pixel = (bpp + 7) / 9;
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.debug("Created elphelMeta table, size="+property_table.size()); LOGGER.info("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.debug("initStandardMetadata() - got "+tags.length+" tags"); // LOGGER.info("initStandardMetadata() - got "+tags.length+" tags");
} }
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName); addGlobalMeta(ELPHEL_PROPERTY_PREFIX+CONTENT_FILENAME,content_fileName);
} }
...@@ -436,9 +442,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -436,9 +442,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.debug("close("+fileOnly+") before super"); LOGGER.info("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.debug("close("+fileOnly+") after super"); LOGGER.info("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);
...@@ -463,10 +469,10 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -463,10 +469,10 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
/* Removed 08/03/2021 to match IP4 /* Removed 08/03/2021 to match IP4
@Override @Override
protected void initStandardMetadata() throws FormatException, IOException { protected void initStandardMetadata() throws FormatException, IOException {
LOGGER.debug("initStandardMetadata() - before super()"); LOGGER.info("initStandardMetadata() - before super()");
super.initStandardMetadata(); super.initStandardMetadata();
String comment = ifds.get(0).getComment(); // IMAGE_DESCRIPTION String comment = ifds.get(0).getComment(); // IMAGE_DESCRIPTION
LOGGER.debug("initStandardMetadata() - after super()"); LOGGER.info("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;
...@@ -505,14 +511,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -505,14 +511,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.debug("Created elphelMeta table, size="+property_table.size()); LOGGER.info("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.debug("initStandardMetadata() - got "+tags.length+" tags"); LOGGER.info("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
...@@ -549,9 +555,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader { ...@@ -549,9 +555,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.debug("openBytes() - before super()"); LOGGER.info("openBytes() - before super()");
super.openBytes(no, buf, x, y, w, h); super.openBytes(no, buf, x, y, w, h);
LOGGER.debug("openBytes() - after super()"); LOGGER.info("openBytes() - after super()");
return buf; return buf;
} }
......
...@@ -645,17 +645,17 @@ public class ImagejJp4Tiff { ...@@ -645,17 +645,17 @@ public class ImagejJp4Tiff {
} }
if (num_diff == 0) { if (num_diff == 0) {
System.out.println ("No discontinuities remain"); /// System.out.println ("No discontinuities remain");
return center; return center;
} }
System.out.println ("Discontinuities remain, will fix by clusters"); /// System.out.println ("Discontinuities remain, will fix by clusters");
boolean OK = fixByClusters( boolean OK = fixByClusters(
width, width,
height, height,
FIXCH6_BIT, // int bad_bit, FIXCH6_BIT, // int bad_bit,
idata, // int [] data) idata, // int [] data)
(dbg_img != null)); // boolean debug) (dbg_img != null)); // boolean debug)
System.out.println ("FixByClusters -> "+OK); /// System.out.println ("FixByClusters -> "+OK);
for (int i = 0; i < idata.length; i++) { for (int i = 0; i < idata.length; i++) {
pixels[i+640] = idata[i]; pixels[i+640] = idata[i];
} }
......
...@@ -801,7 +801,7 @@ public class GeometryCorrection { ...@@ -801,7 +801,7 @@ public class GeometryCorrection {
int [] full_par_index; int [] full_par_index;
public RigOffset () { public RigOffset () {
System.out.println("created RigOffset"); /// System.out.println("created RigOffset");
par_scales = new double [VECTOR_LENGTH]; par_scales = new double [VECTOR_LENGTH];
par_scales[AUX_AZIMUTH_INDEX] = 1000.0*focalLength/pixelSize; par_scales[AUX_AZIMUTH_INDEX] = 1000.0*focalLength/pixelSize;
par_scales[AUX_TILT_INDEX] = 1000.0*focalLength/pixelSize; par_scales[AUX_TILT_INDEX] = 1000.0*focalLength/pixelSize;
......
...@@ -2025,16 +2025,16 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2025,16 +2025,16 @@ public class QuadCLT extends QuadCLTCPU {
false, // final boolean updateStatus, false, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
if (debugLevel >-1) System.out.println("Processing set "+(nSet+1)+" (of "+set_channels.length+") finished at "+ if (debugLevel >-1) System.out.println("Processing set "+(nSet+1)+" (of "+set_channels.length+") finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory1="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (eyesisCorrections.stopRequested.get()>0) { if (eyesisCorrections.stopRequested.get()>0) {
System.out.println("User requested stop"); System.out.println("User requested stop");
System.out.println("Processing "+(nSet + 1)+" file sets (of "+set_channels.length+") finished at "+ System.out.println("Processing "+(nSet + 1)+" file sets (of "+set_channels.length+") finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory2="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return; return;
} }
} }
System.out.println("processCLTQuadCorrs(): processing "+getTotalFiles(set_channels)+" files ("+set_channels.length+" file sets) finished at "+ System.out.println("processCLTQuadCorrs(): processing "+getTotalFiles(set_channels)+" files ("+set_channels.length+" file sets) finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory3="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public static ImagePlus renderGPUFromDSI( public static ImagePlus renderGPUFromDSI(
......
...@@ -37,7 +37,7 @@ import com.elphel.imagej.common.PolynomialApproximation; ...@@ -37,7 +37,7 @@ import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
public class TileProcessor { public class TileProcessor {
public boolean run_garbage_collection=false;
public static String [] SCAN_TITLES4 = { public static String [] SCAN_TITLES4 = {
"tile_op", // 0 "tile_op", // 0
"final", // 1 - calculated, filtered, combined disparity "final", // 1 - calculated, filtered, combined disparity
...@@ -251,10 +251,11 @@ public class TileProcessor { ...@@ -251,10 +251,11 @@ public class TileProcessor {
rig_pre_poles_sel = null; rig_pre_poles_sel = null;
rig_post_poles_sel = null; rig_post_poles_sel = null;
clt_3d_passes_rig_size = 0; clt_3d_passes_rig_size = 0;
if (run_garbage_collection) {
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
runtime.gc(); runtime.gc();
System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")"); System.out.println("--- Free memory30="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
}
} }
public void saveCLTPasses(boolean rig){ public void saveCLTPasses(boolean rig){
...@@ -309,7 +310,7 @@ public class TileProcessor { ...@@ -309,7 +310,7 @@ public class TileProcessor {
} }
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
runtime.gc(); runtime.gc();
System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")"); System.out.println("--- Free memory31="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
} }
public void removeNonMeasurement(){ // executed during expansion (CLT 3D) public void removeNonMeasurement(){ // executed during expansion (CLT 3D)
......
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