Commit b106acf0 authored by Andrey Filippov's avatar Andrey Filippov

Converting 3D reconstruction program to support multiple camera

resolutions
parent 6b59db60
......@@ -2113,8 +2113,8 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
String [] extensions={".tif",".tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("grid",extensions,"Calibrated grid files");
MultipleExtensionsFileFilter gridFilter =
new MultipleExtensionsFileFilter("grid",extensions,"Calibrated grid files");
GenericDialog gd = new GenericDialog("Setup Goniometer/Camera Stations");
gd.addMessage("Setting up calibration that includes multiple camera tripod or goniometer positions.");
gd.addMessage("File selection dialog will open for each station separateley.");
......@@ -2623,7 +2623,7 @@ if (MORE_BUTTONS) {
return;
}
String [] extensions={".mask-tiff","-masks.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.mask-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.mask-tiff files");
String pathname=CalibrationFileManagement.selectFile(true,
"Save Sensor Masks file",
"Save",
......@@ -2645,7 +2645,7 @@ if (MORE_BUTTONS) {
DISTORTION_CALIBRATION_DATA.updateStatus=UPDATE_STATUS;
String [] extensions={".mask-tiff","-masks.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Sensor masks *.mask-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Sensor masks *.mask-tiff files");
String pathname=CalibrationFileManagement.selectFile(false,
"Restore Sensor Masks",
"Restore",
......@@ -2860,7 +2860,7 @@ if (MORE_BUTTONS) {
}
LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL;
String [] extensions={".calib-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String pathname=CalibrationFileManagement.selectFile(false,
"Restore distortion calibration for sensor",
"Restore",
......@@ -2975,7 +2975,7 @@ if (MORE_BUTTONS) {
}
LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL;
String [] extensions={".calib-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String pathname=CalibrationFileManagement.selectFile(true,
"Save distortion calibration for sensor (will add channel number when saving all)",
"Save",
......@@ -6648,7 +6648,7 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping((String)null,DEBUG_LEVEL); // ask for and load sensor calibration files
String [] extensions={".eqr-tiff",".eqrect-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files");
String pathname=CalibrationFileManagement.selectFile(true,
"Save equirectangular calibration file (will add channel number suffix)",
"Save",
......@@ -6838,8 +6838,8 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping(null,true,DEBUG_LEVEL);
String [] extensions={".tiff",".jpeg"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"channel images, may be scaled");
MultipleExtensionsFileFilter parFilter =
new MultipleExtensionsFileFilter("",extensions,"channel images, may be scaled");
String [] files=CalibrationFileManagement.selectFiles(false,
"Select channel images to warp to equirectangular",
"Select",
......@@ -6949,7 +6949,7 @@ if (MORE_BUTTONS) {
if (gd.wasCanceled()) return;
String resultPath=gd.getNextString();
if (gd.getNextBoolean() || (resultPath==null) || (resultPath.length()==0)){
CalibrationFileManagement.MultipleExtensionsFileFilter filter= new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"sensors map file ("+extList+")");
MultipleExtensionsFileFilter filter= new MultipleExtensionsFileFilter("",extensions,"sensors map file ("+extList+")");
resultPath=CalibrationFileManagement.selectFile(
false, // smart
true, // save
......@@ -9789,10 +9789,10 @@ if (MORE_BUTTONS) {
numStations= (int) gd.getNextNumber();
String [] grid_extensions={".tif",".tiff"};
String [] src_extensions={".tif",".tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("grid",grid_extensions,"Calibrated grid files");
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",src_extensions,"Source calibration images");
MultipleExtensionsFileFilter gridFilter =
new MultipleExtensionsFileFilter("grid",grid_extensions,"Calibrated grid files");
MultipleExtensionsFileFilter sourceFilter =
new MultipleExtensionsFileFilter("",src_extensions,"Source calibration images");
// CalibrationFileManagement.DirectoryContentsFilter gridDirFilter =
// new CalibrationFileManagement.DirectoryContentsFilter (gridFilter, min_files, 0, null);
......@@ -9801,7 +9801,7 @@ if (MORE_BUTTONS) {
String [] sourceStationDirs = new String [numStations]; // directories of the source files per station
for (int numStation=0;numStation<numStations;numStation++){
CalibrationFileManagement.DirectoryChoser dc = new CalibrationFileManagement.DirectoryChoser(
DirectoryChoser dc = new DirectoryChoser(
gridFilter,
min_files,
0,
......@@ -10496,7 +10496,7 @@ if (MORE_BUTTONS) {
public void viewCSVFile(){
String [] extensions={".csv","CSV"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"CSV table *.csv files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"CSV table *.csv files");
String pathname=CalibrationFileManagement.selectFile(
true, // smart,
false,
......@@ -15339,7 +15339,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
path= CalibrationFileManagement.selectFile(true, // save
"Save configuration selection", // title
"Select configuration file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns, (useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
new MultipleExtensionsFileFilter(patterns, (useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
directory); // may be ""
} else path+=patterns[0];
if (path==null) return;
......@@ -15392,7 +15392,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
path= CalibrationFileManagement.selectFile(false, // save
"Configuration file selection", // title
"Read configuration file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,(useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
new MultipleExtensionsFileFilter(patterns,(useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
directory); // may be ""
} else {
// do not add extension if it already exists
......@@ -2,7 +2,6 @@ package com.elphel.imagej.calibration;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import javax.swing.JFileChooser;
......@@ -204,148 +203,4 @@ public class CalibrationFileManagement {
}
}
}
/* ======================================================================== */
public static class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String prefix=""; // case sensitive
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefix= prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
}
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public static class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
}
package com.elphel.imagej.calibration;
import java.io.File;
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
\ No newline at end of file
......@@ -677,8 +677,8 @@ import ij.text.TextWindow;
public DistortionCalibrationData (
String [][] stationFilenames,
String [] source_dirs, // directories of the source files per station
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter,
MultipleExtensionsFileFilter gridFilter,
MultipleExtensionsFileFilter sourceFilter,
PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters,
LaserPointer laserPointers, // as a backup if data is not available in the file
......@@ -767,8 +767,8 @@ import ij.text.TextWindow;
public void setupDirDistortionCalibrationData (
String [][] stationFilenames, // per-station List of image set directories
String [] source_dirs, // directories of the source files per station
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter,
MultipleExtensionsFileFilter gridFilter,
MultipleExtensionsFileFilter sourceFilter,
PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters,
LaserPointer laserPointers, // as a backup if data is not available in the file
......@@ -789,8 +789,8 @@ import ij.text.TextWindow;
String dir, // grid image set directory that contains channel files (may be different timestamps)
String sdir, // source super directory that contains image set directories with files
int num_chn,
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter)
MultipleExtensionsFileFilter gridFilter,
MultipleExtensionsFileFilter sourceFilter)
{
this.station = station;
// this.dir = dir;
......@@ -2945,7 +2945,7 @@ import ij.text.TextWindow;
ImagePlus[] gridImages ){ // null - use specified files
setupIndices();
String [] extensions={".dcal-xml","-distcal.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
String pathname=CalibrationFileManagement.selectFile(
smart,
false,
......@@ -3149,7 +3149,7 @@ import ij.text.TextWindow;
}
public String selectAndSaveToXML(boolean smart, String defaultPath, String comment){
String [] extensions={".dcal-xml","-distcal.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
String pathname=CalibrationFileManagement.selectFile(
smart,
true,
......
......@@ -176,8 +176,8 @@ import ij.gui.GenericDialog;
defaultPaths[0]="";
}
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files");
MultipleExtensionsFileFilter sourceFilter =
new MultipleExtensionsFileFilter("",extensions,"Source files");
String [] sourceFiles=null;
if (allFiles){
File dir= new File (this.sourceDirectory);
......@@ -193,7 +193,7 @@ import ij.gui.GenericDialog;
sourceFiles = new String[fileList.length];
for (int i=0;i<sourceFiles.length;i++) sourceFiles[i]=fileList[i].getPath();
} else {
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files");
new MultipleExtensionsFileFilter("",extensions,"Source files");
sourceFiles=CalibrationFileManagement.selectFiles(false,
"Select Source files, saved as TIFF",
"Select",
......
......@@ -1164,7 +1164,7 @@ public class EyesisAberrations {
continue;
}
String [] extensions={filename}; // just this one file
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,filename);
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,filename);
String pathname=CalibrationFileManagement.selectFile(
false,
false,
......
......@@ -180,7 +180,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
DistortionCalibrationData distortionCalibrationData // per-image parameters
) {
String [] extensions={".stg-xml","-strategy.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
String pathname=CalibrationFileManagement.selectFile(
smart,
false,
......@@ -359,7 +359,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
boolean smart,
String defaultPath){
String [] extensions={".stg-xml","-strategy.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
if ((defaultPath==null) || (defaultPath.length()==0)){
defaultPath=this.pathName;
}
......
......@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
......@@ -5037,7 +5036,7 @@ public boolean LevenbergMarquardt(
boolean smart, // do not open dialog if default matches
String defaultPath){ // x,y,r
String [] extensions={".history-xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.history-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.history-xml files");
String pathname=CalibrationFileManagement.selectFile(
smart,
false,
......@@ -9589,7 +9588,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(true, // save
"Save Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,
new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter
directory); // may be ""
} else path+=patterns[0];
......@@ -9628,7 +9627,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(false, // save
"Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,
new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter
directory); // may be ""
} else {
......
package com.elphel.imagej.calibration;
import java.io.File;
import java.io.FilenameFilter;
import javax.swing.filechooser.FileFilter;
/* ======================================================================== */
public class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String [] prefixes= {""}; // case sensitive
// prefix/prefixeas can not be null - ambiguity
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefixes= new String[1];
this.prefixes[0] = prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] prefixes, String [] patterns,String description) {
this.prefixes= prefixes;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!testPrefix(name)) return false;
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!testPrefix(name)) return false;
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
private boolean testPrefix(String name) {
if ((prefixes == null) || (prefixes[0] == null)) return true;
for (String s : prefixes) {
if ((s == null) || name.startsWith(s)) {
return true;
}
}
return false; // prefix mismatch;
}
}
\ No newline at end of file
......@@ -290,7 +290,7 @@ import ij.io.Opener;
public String selectAndSave(boolean smart, String defaultPath){
String [] extensions={".grid-tiff","-grid.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Pattern grid *.grid-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Pattern grid *.grid-tiff files");
String pathname=CalibrationFileManagement.selectFile(
smart,
true,
......@@ -305,7 +305,7 @@ import ij.io.Opener;
public String selectAndRestore(boolean smart, String defaultPath, int numStations){
String [] extensions={".grid-tiff","-grid.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Pattern grid *.grid-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Pattern grid *.grid-tiff files");
String pathname=CalibrationFileManagement.selectFile(
smart,
false,
......
......@@ -84,7 +84,7 @@ public class PixelMapping {
String [] extensions={".calib-tiff"};
String [] defaultPaths=((defaultPath==null) || defaultPath.equals(""))?null:(new String[1]);
if (defaultPaths!=null) defaultPaths[0]=defaultPath;
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String [] calibFiles=CalibrationFileManagement.selectFiles(false,
"Select camera sub-modules calibration files",
"Select",
......@@ -157,13 +157,8 @@ public class PixelMapping {
if ((channel<0) || (channel>=this.sensors.length)) return -1;
return this.sensors[channel].getSubCamera();
}
/*
public int getSensorPort(int channel ){
if ((channel<0) || (channel>=this.sensors.length)) return -1;
return this.sensors[channel].getSensorPort();
}
*/
// Enumerated calibration file
public boolean isChannelAvailable(int channel){
return (this.sensors != null) && (channel>=0) && (channel<this.sensors.length) && (this.sensors[channel]!=null);
......@@ -171,25 +166,51 @@ public class PixelMapping {
// Updating for nc393. subCamera here is 0..9 for Eyesis4pi393 - 0-based index of the file, so it combines physical camera (separate IP)
// as stored in "subcamera" field of the calibration file and "sensor_port". sensor_port may start from non-0, so we need to count all combinations
//removeUnusedSensorData xshould be off!
//removeUnusedSensorData should be off!
public boolean subcamerasUsed() {
for (int i=0;i<this.sensors.length;i++) if ((this.sensors[i]!=null) && (this.sensors[i].subcamera >= 0)) {
return true;
}
return false;
}
// if subcameras are not used (-1), as in Quads, return {channel index} or null if alien file
public int [] getSensorWH(int chn) {
if ((sensors == null) || (chn < 0) || (chn >= sensors.length)) {
return null;
}
return sensors[chn].getSensorWH();
}
public int [] channelsForSubCamera(int subCamera){
if (subCamera < 0) {
return null;
}
if (this.sensors == null) return null;
if (this.debugLevel>1) {
System.out.print("channelsForSubCamera("+subCamera+"),this.sensors.length="+this.sensors.length+": ");
// } else if (this.debugLevel > -2) {
// System.out.print(".");
}
if (!subcamerasUsed()) {
for (int i=0;i<this.sensors.length;i++) if ((this.sensors[i]!=null) && (this.sensors[i].channel == subCamera)) {
int [] rslt = {i};
return rslt;
}
return null;
}
// ArrayList<ArrayList<ArrayList<Integer>>> camera_IPs = new ArrayList<ArrayList<ArrayList<Integer>>>();
// Eyesis version
ArrayList<Point> cam_port = new ArrayList<Point>();
for (int i=0;i<this.sensors.length;i++) if (this.sensors[i]!=null) {
Point cp = new Point(this.sensors[i].subcamera, this.sensors[i].sensor_port);
if (!cam_port.contains(cp)){
cam_port.add(cp);
}
// System.out.println("this.sensors["+i+"]!=null, this.sensors[i].subcamera="+this.sensors[i].subcamera+", this.sensors[i].sensor_port="+this.sensors[i].sensor_port);
}
Point [] cam_port_arr = cam_port.toArray(new Point[0]);
Arrays.sort(cam_port_arr, new Comparator<Point>() {
......@@ -210,7 +231,6 @@ public class PixelMapping {
} else if (this.debugLevel > -2) {
System.out.print(".");
}