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

Simultaneous LWIR/VNIR acquisition: added configurable parameters

parent 3649ef29
......@@ -107,6 +107,17 @@
<resource>
<directory>${project.build.sourceDirectory}</directory>
</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>
<testResources>
<testResource>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -37,6 +37,7 @@ import java.util.Set;
import com.elphel.imagej.calibration.CalibrationFileManagement;
import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.lwir.LwirReaderParameters;
import com.elphel.imagej.tileprocessor.BiQuadParameters;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.ImageDttParameters;
......@@ -3252,6 +3253,8 @@ public class EyesisCorrectionParameters {
public BiQuadParameters rig = new BiQuadParameters();
public PoleProcessorParameters poles = new PoleProcessorParameters();
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> infinity_distace_map = new HashMap<String,Double>(); //new one
......@@ -3945,6 +3948,7 @@ public class EyesisCorrectionParameters {
mlfp.setProperties (prefix+"_mlfp", properties);
rig.setProperties (prefix+"_rig", properties);
poles.setProperties (prefix+"_poles", properties);
lwir.setProperties (prefix+"_lwir", properties);
}
public void setPropertiesInfinityDistance(String prefix,Properties properties){
......@@ -4653,6 +4657,7 @@ public class EyesisCorrectionParameters {
mlfp.getProperties (prefix+"_mlfp", properties);
rig.getProperties (prefix+"_rig", properties);
poles.getProperties (prefix+"_poles", properties);
lwir.getProperties (prefix+"_lwir", properties);
}
public boolean showJDialog() {
......@@ -5467,9 +5472,13 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Show 'flaps-dirs'", this.show_flaps_dirs);
gd.addCheckbox ("Show 'first_N_clusters'", this.show_first_clusters);
gd.addCheckbox ("Show planes", this.show_planes);
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]+"}");
gd.addTab ("LWIR", "parameters for LWIR/VNIR 8-camera rig");
this.lwir.dialogQuestions(gd);
// gd.buildDialog();
gd.showDialog();
// System.out.println("gd.wasCanceled="+gd.wasCanceled());
......@@ -6150,6 +6159,9 @@ public class EyesisCorrectionParameters {
this.show_flaps_dirs= gd.getNextBoolean();
this.show_first_clusters= gd.getNextBoolean();
this.show_planes= gd.getNextBoolean();
this.lwir.dialogAnswers(gd);
return true;
}
......
package com.elphel.imagej.tileprocessor;
package com.elphel.imagej.correction;
/**
** -----------------------------------------------------------------------------**
** Eyesis_Correction.java
......@@ -80,12 +80,6 @@ import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
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.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin;
......@@ -93,6 +87,11 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.readers.EyesisTiff;
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.IJ;
......@@ -675,6 +674,7 @@ private Panel panel1,
if (LWIR_MODE) {
panelLWIR = new Panel();
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);
add(panelLWIR);
}
......@@ -897,6 +897,9 @@ private Panel panel1,
if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
CLT_PARAMETERS.batch_run = false;
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")) {
showSplitBayerToStackDialog(SPLIT_PARAMETERS);
......@@ -4826,12 +4829,12 @@ private Panel panel1,
TENSORFLOW_INFER_MODEL.test_tensorflow(keep_empty);
return;
/* ======================================================================== */
} else if (label.equals("LWIR_ACQUIRE")) {
} else if (label.equals("LWIR_TEST")) {
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;
if (LWIR_READER == null) {
LWIR_READER = new LwirReader();
LWIR_READER = new LwirReader(CLT_PARAMETERS.lwir);
}
ImagePlus [][] imps = LWIR_READER.readAllMultiple(
10, // final int num_frames,
......@@ -4841,7 +4844,7 @@ private Panel panel1,
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)
if (imps_sync != null) {
ImagePlus [] imps_avg = LWIR_READER.averageMultiFrames(imps_sync);
......@@ -4849,6 +4852,20 @@ private Panel panel1,
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
// End of buttons code
......@@ -7675,6 +7692,7 @@ private Panel panel1,
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_AUX != null) QUAD_CLT_AUX.getProperties(QuadCLT.PREFIX_AUX);
}
/* ======================================================================== */
......
......@@ -1434,7 +1434,13 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
Class<?> clazz = JP46_Reader_camera.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
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", "/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
new ImageJ();
// run the plugin
......
This diff is collapsed.
......@@ -105,7 +105,7 @@ public class ElphelJp4Reader extends ImageIOReader{
// or these readers are combined with all other readers in readers.txt
suffixNecessary = true; // false
suffixSufficient = true; // false;
LOGGER.info("ElphelTiffReader(), after super()");
LOGGER.debug("ElphelTiffReader(), after super()");
if (REPLACEMENT_TAG_MAP == null) {
REPLACEMENT_TAG_MAP = new HashMap<String,String>();
for (String [] line: REPLACEMENT_TAGS) {
......@@ -162,7 +162,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.debug("id '"+id+"' is already mapped" );
content_fileName = id; // id; // maybe set to null to handle externally?
mapped_externally = true;
LOGGER.info("Starting initFile() method, read file directly");
LOGGER.debug("Starting initFile() method, read file directly");
super.setId(id);
} else {
// If URL, then read to memory, if normal file - use direct access
......@@ -175,7 +175,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.warn("Bad URL: " + id);
}
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
URLConnection connection = url.openConnection();
......@@ -192,20 +192,20 @@ public class ElphelJp4Reader extends ImageIOReader{
content_fileName = "unknown." + suffix;
}
// 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/2295221/java-net-url-read-stream-to-byte
InputStream is = url.openStream (); //
byte[] inBytes = IOUtils.toByteArray(is);
if (is != null) is.close();
LOGGER.info("Bytes read: "+ inBytes.length);
LOGGER.debug("Bytes read: "+ inBytes.length);
Location.mapFile(content_fileName, new ByteArrayHandle(inBytes));
// HashMap<String,Object> dbg_loc = Location.getIdMap();
super.setId(content_fileName);
} else { // read file normally
content_fileName = id;
LOGGER.info("read file directly");
LOGGER.debug("read file directly");
super.setId(id);
}
}
......@@ -229,7 +229,7 @@ public class ElphelJp4Reader extends ImageIOReader{
LOGGER.debug("initFile("+id+"), currentId="+currentId+", after super" );
// Below needs to be modified - EXIFService does not work with mapFile
MetadataStore store = makeFilterMetadata();
LOGGER.info("Parsing JPEG EXIF data");
LOGGER.debug("Parsing JPEG EXIF data");
HashMap<String, String> tags = null;
try {
// Reimplementing ExifServiceImpl as original does not have ExifIFD0Directory
......@@ -307,14 +307,14 @@ public class ElphelJp4Reader extends ImageIOReader{
int bytes_per_pixel = 1;
Hashtable<String, String> property_table = ElphelMeta.getMeta(
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()) {
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key));
}
MetadataLevel level = getMetadataOptions().getMetadataLevel();
if (level != MetadataLevel.MINIMUM) {
// 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);
......@@ -328,9 +328,9 @@ public class ElphelJp4Reader extends ImageIOReader{
// HashMap<String,Object> dbg_loc = Location.getIdMap();
String saveCurrentId = currentId;
currentId = null;
LOGGER.info("close("+fileOnly+") before super");
LOGGER.debug("close("+fileOnly+") before super");
super.close(fileOnly); // curerent_id == null only during actual close?
LOGGER.info("close("+fileOnly+") after super");
LOGGER.debug("close("+fileOnly+") after super");
currentId = saveCurrentId;
// if ((content_fileName != null) && file_initialized){
if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK
......@@ -370,7 +370,7 @@ public class ElphelJp4Reader extends ImageIOReader{
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
throws FormatException, IOException
{
LOGGER.info("openBytes() - before super()");
LOGGER.debug("openBytes() - before super()");
FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h);
if (image_bytes == null) {
jp4Decode(no);
......@@ -386,7 +386,7 @@ public class ElphelJp4Reader extends ImageIOReader{
w);
dest += w;
}
LOGGER.info("openBytes() - after super()");
LOGGER.debug("openBytes() - after super()");
return buf;
}
public void jp4Decode(int no) throws FormatException, IOException {
......@@ -421,7 +421,7 @@ public class ElphelJp4Reader extends ImageIOReader{
} else {
image_bytes = ib; // temporary
}
LOGGER.info("jp4Decode()");
LOGGER.debug("jp4Decode()");
}
}
......@@ -130,7 +130,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
suffixNecessary = true; // false
suffixSufficient = true; // false;
/// mergeSubIFDs = true; // false;
LOGGER.info("ElphelTiffReader(), after supper(), mergeSubIFDs = true;");
LOGGER.debug("ElphelTiffReader(), after supper(), mergeSubIFDs = true;");
}
// -- IFormatReader API methods --
......@@ -177,7 +177,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
LOGGER.debug("id '"+id+"' is already mapped" );
content_fileName = id; // id; // maybe set to null to handle externally?
mapped_externally = true;
LOGGER.info("Starting setId() method, read file directly");
LOGGER.debug("Starting setId() method, read file directly");
super.setId(id);
} else {
// If URL, then read to memory, if normal file - use direct access
......@@ -193,7 +193,7 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
LOGGER.warn("Bad URL: " + id);
}
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
URLConnection connection = url.openConnection();
......@@ -210,20 +210,20 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
content_fileName = "unknown." + suffix;
}
// 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/2295221/java-net-url-read-stream-to-byte
InputStream is = url.openStream (); //
byte[] inBytes = IOUtils.toByteArray(is);
if (is != null) is.close();
LOGGER.info("Bytes read: "+ inBytes.length);
LOGGER.debug("Bytes read: "+ inBytes.length);
Location.mapFile(content_fileName, new ByteArrayHandle(inBytes));
// HashMap<String,Object> dbg_loc = Location.getIdMap();
super.setId(content_fileName);
} else { // read file normally
content_fileName = id;
LOGGER.info("read file directly");
LOGGER.debug("read file directly");
super.setId(id);
}
}
......@@ -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
// with small set of services - only needed for Elphel
LOGGER.info("Starting initFile() method");
LOGGER.debug("Starting initFile() method");
super.initFile(id);
LOGGER.info("Ending initFile() method");
LOGGER.debug("Ending initFile() method");
}
......@@ -262,9 +262,9 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
/* @see loci.formats.IFormatReader#close(boolean) */
@Override
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?
LOGGER.info("close("+fileOnly+") after super");
LOGGER.debug("close("+fileOnly+") after super");
// if ((content_fileName != null) && file_initialized){
if (!mapped_externally && file_initialized){ // will try to unmap non-mapped file, OK
Location.mapFile(content_fileName, null);
......@@ -288,10 +288,10 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
/* @see BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
LOGGER.info("initStandardMetadata() - before super()");
LOGGER.debug("initStandardMetadata() - before super()");
super.initStandardMetadata();
String comment = ifds.get(0).getComment(); // IMAGE_DESCRIPTION
LOGGER.info("initStandardMetadata() - after super()");
LOGGER.debug("initStandardMetadata() - after super()");
long[] maker_note = null;
double exposure = Double.NaN;
String date_time = null;
......@@ -330,14 +330,14 @@ public class ElphelTiffReader extends TiffReader{ // BaseTiffReader {
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()) {
addGlobalMeta(ELPHEL_PROPERTY_PREFIX+key,property_table.get(key));
}
MetadataLevel level = getMetadataOptions().getMetadataLevel();
if (level != MetadataLevel.MINIMUM) {
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);
// convert MAKER_NOTE to the same text format as in com.drew.metadata
......@@ -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)
throws FormatException, IOException
{
LOGGER.info("openBytes() - before super()");
LOGGER.debug("openBytes() - before super()");
super.openBytes(no, buf, x, y, w, h);
LOGGER.info("openBytes() - after super()");
LOGGER.debug("openBytes() - after super()");
return buf;
}
......
......@@ -66,6 +66,7 @@ public class ImagejJp4Tiff {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassList.class);
private static final boolean BYPASS_SERVICES = false; // true;
private static final String SERVICES_PATH = "services.properties.forelphel";
private static final boolean KEEP_EXTENSION = false; // remove extension for ImagePlus title
// -- Fields --
......@@ -151,7 +152,7 @@ public class ImagejJp4Tiff {
if (url != null) {
LOGGER.error("Read "+ path_url +" to memory first");
URLConnection connection = url.openConnection();
// Wrong - waits forever
String content_disposition = connection.getHeaderField("Content-Disposition"); // reads file
// raw = "attachment; filename=abc.jpg"
if(content_disposition != null && content_disposition.indexOf("=") != -1) {
......@@ -217,6 +218,12 @@ public class ImagejJp4Tiff {
if (meta_hash.containsKey(imageNameKey)) {
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
// 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