Commit 770a8d96 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

batch mode for multiple image sets

parent f5a43005
Loading
Loading
Loading
Loading
+94 −19
Original line number Diff line number Diff line
@@ -110,6 +110,19 @@ public class EyesisCorrectionParameters {
    	public String cltKernelDirectory="";
    	public String cltKernelPrefix="clt-";
    	public String cltSuffix=".clt-tiff";
  		public boolean use_x3d_subdirs =  true;
  		
  		// CLT 3d batch parameters
  		
  		public boolean clt_batch_4img =       true;  // Create a set of 4 images, usually for disparity = 0
  		public boolean clt_batch_extrinsic =  false; // Calibrate extrinsic parameters for each set
  		public boolean clt_batch_poly =       false; // Calculate fine polynomial correction for each set
  		public boolean clt_batch_explore =    true;  // 1-st step of 3d reconstruction - explore disparities for each tile
  		public boolean clt_batch_surf =       true;  // Create super-tile 2.5d surfaces
  		public boolean clt_batch_assign =     true;  // Assign tiles to surfaces
  		public boolean clt_batch_gen3d =      true;  // Generate 3d output: x3d and/or obj+mtl
  		


    	public String x3dDirectory="";   	
    	
@@ -200,7 +213,15 @@ public class EyesisCorrectionParameters {
    		properties.setProperty(prefix+"cltSuffix",             this.cltSuffix);

    		properties.setProperty(prefix+"x3dDirectory",          this.x3dDirectory);
    		properties.setProperty(prefix+"use_x3d_subdirs",       this.use_x3d_subdirs+"");

    		properties.setProperty(prefix+"clt_batch_4img",        this.clt_batch_4img+"");
    		properties.setProperty(prefix+"clt_batch_extrinsic",   this.clt_batch_extrinsic+"");
    		properties.setProperty(prefix+"clt_batch_poly",        this.clt_batch_poly+"");
    		properties.setProperty(prefix+"clt_batch_explore",     this.clt_batch_explore+"");
    		properties.setProperty(prefix+"clt_batch_surf",        this.clt_batch_surf+"");
    		properties.setProperty(prefix+"clt_batch_assign",      this.clt_batch_assign+"");
    		properties.setProperty(prefix+"clt_batch_gen3d",       this.clt_batch_gen3d+"");
    	}

    	public void getProperties(String prefix,Properties properties){
@@ -294,6 +315,15 @@ public class EyesisCorrectionParameters {
  		    
			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((String) properties.getProperty(prefix+"use_x3d_subdirs"));
			
			if (properties.getProperty(prefix+"clt_batch_4img")!= null)      this.clt_batch_4img=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_4img"));
			if (properties.getProperty(prefix+"clt_batch_extrinsic")!= null) this.clt_batch_extrinsic=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_extrinsic"));
			if (properties.getProperty(prefix+"clt_batch_poly")!= null)      this.clt_batch_poly=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_poly"));
			if (properties.getProperty(prefix+"clt_batch_explore")!= null)   this.clt_batch_explore=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_explore"));
			if (properties.getProperty(prefix+"clt_batch_surf")!= null)      this.clt_batch_surf=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_surf"));
			if (properties.getProperty(prefix+"clt_batch_assign")!= null)    this.clt_batch_assign=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_assign"));
			if (properties.getProperty(prefix+"clt_batch_gen3d")!= null)     this.clt_batch_gen3d=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_gen3d"));
    	}

    	public boolean showDialog(String title) { 
@@ -365,6 +395,7 @@ public class EyesisCorrectionParameters {
    		
    		gd.addStringField ("x3d output directory",                             this.x3dDirectory, 60);
    		gd.addCheckbox    ("Select x3d output directory",                      false);
    		gd.addCheckbox    ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs);

    		gd.addStringField("Equirectangular maps directory (may be empty)",     this.equirectangularDirectory, 60);
    		gd.addCheckbox("Select equirectangular maps directory",                false);
@@ -450,6 +481,7 @@ public class EyesisCorrectionParameters {
    		this.dctKernelDirectory=     gd.getNextString(); if (gd.getNextBoolean()) selectDCTKernelDirectory(false, true);
    		this.cltKernelDirectory=     gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true);
    		this.x3dDirectory=           gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true);
    		this.use_x3d_subdirs=        gd.getNextBoolean();
    		this.equirectangularDirectory=  gd.getNextString(); if (gd.getNextBoolean()) selectEquirectangularDirectory(false, false); 
    		this.resultsDirectory=       gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true); 
    		this.sourcePrefix=           gd.getNextString();
@@ -488,20 +520,29 @@ public class EyesisCorrectionParameters {
    		gd.addStringField ("x3d output directory",                             this.x3dDirectory, 60);       // 8
    		gd.addCheckbox    ("Select x3d output directory",                      false);                       // 9

    		gd.addStringField("Results directory",                                 this.resultsDirectory, 60);   // 10
    		gd.addCheckbox("Select results directory",                             false);                       // 11
    		gd.addCheckbox    ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs); //10
    		
    		gd.addStringField("Results directory",                                 this.resultsDirectory, 60);   // 11
    		gd.addCheckbox("Select results directory",                             false);                       // 12
    		
    		gd.addStringField("Source files prefix",                               this.sourcePrefix, 60);       // 12
    		gd.addStringField("Source files suffix",                               this.sourceSuffix, 60);       // 13
    		gd.addNumericField("First subcamera (in the source filename)",         this.firstSubCamera, 0);      // 14
    		gd.addStringField("Source files prefix",                               this.sourcePrefix, 60);       // 13
    		gd.addStringField("Source files suffix",                               this.sourceSuffix, 60);       // 14
    		gd.addNumericField("First subcamera (in the source filename)",         this.firstSubCamera, 0);      // 15
    		
    		gd.addStringField("Sensor files prefix",                               this.sensorPrefix, 40);       // 15       
    		gd.addStringField("Sensor files suffix",                               this.sensorSuffix, 40);       // 16
    		gd.addStringField("Sensor files prefix",                               this.sensorPrefix, 40);       // 16       
    		gd.addStringField("Sensor files suffix",                               this.sensorSuffix, 40);       // 17
    		
    		gd.addStringField("CLT kernel files  prefix",                          this.cltKernelPrefix, 40);    // 17
    		gd.addStringField("CLT symmetical kernel files",                       this.cltSuffix, 40);          // 18
    		gd.addStringField("CLT kernel files  prefix",                          this.cltKernelPrefix, 40);    // 18
    		gd.addStringField("CLT symmetical kernel files",                       this.cltSuffix, 40);          // 19
    		
    		gd.addMessage("============ batch parameters ============");
    		gd.addCheckbox    ("Create a set of 4 images, usually for disparity = 0",                this.clt_batch_4img);      // 20
    		gd.addCheckbox    ("Calibrate extrinsic parameters for each set",                        this.clt_batch_extrinsic); // 21
    		gd.addCheckbox    ("Calculate fine polynomial correction for each set",                  this.clt_batch_poly);      // 22
    		gd.addCheckbox    ("1-st step of 3d reconstruction - explore disparities for each tile", this.clt_batch_explore);   // 23
    		gd.addCheckbox    ("Create super-tile 2.5d surfaces",                                    this.clt_batch_surf);      // 24
    		gd.addCheckbox    ("Assign tiles to surfaces",                                           this.clt_batch_assign);    // 25
    		gd.addCheckbox    ("Generate 3d output: x3d and/or obj+mtl",                             this.clt_batch_gen3d);     // 26
    		
    		
    		WindowTools.addScrollBars(gd);
@@ -516,14 +557,23 @@ public class EyesisCorrectionParameters {
    		this.sensorDirectory=        gd.getNextString(); if (gd.getNextBoolean()) selectSensorDirectory(false, false);   // 5 
    		this.cltKernelDirectory=     gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true); // 7
    		this.x3dDirectory=           gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true);       // 9
    		this.resultsDirectory=       gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true);   // 11
    		this.sourcePrefix=           gd.getNextString();  // 12
    		this.sourceSuffix=           gd.getNextString();  // 13
    		this.firstSubCamera=   (int) gd.getNextNumber();  // 14
    		this.sensorPrefix=           gd.getNextString();  // 15
    		this.sensorSuffix=           gd.getNextString();  // 16
    		this.cltKernelPrefix=        gd.getNextString();  // 17
    		this.cltSuffix=              gd.getNextString();  // 18
    		this.use_x3d_subdirs=        gd.getNextBoolean(); // 10
    		this.resultsDirectory=       gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true);   // 12
    		this.sourcePrefix=           gd.getNextString();  // 13
    		this.sourceSuffix=           gd.getNextString();  // 14
    		this.firstSubCamera=   (int) gd.getNextNumber();  // 15
    		this.sensorPrefix=           gd.getNextString();  // 16
    		this.sensorSuffix=           gd.getNextString();  // 17
    		this.cltKernelPrefix=        gd.getNextString();  // 18
    		this.cltSuffix=              gd.getNextString();  // 19

    		this.clt_batch_4img=         gd.getNextBoolean(); // 20
    		this.clt_batch_extrinsic=    gd.getNextBoolean(); // 21
    		this.clt_batch_poly=         gd.getNextBoolean(); // 22
    		this.clt_batch_explore=      gd.getNextBoolean(); // 23
    		this.clt_batch_surf=         gd.getNextBoolean(); // 24
    		this.clt_batch_assign=       gd.getNextBoolean(); // 25
    		this.clt_batch_gen3d=        gd.getNextBoolean(); // 26
    		return true;
    	}
    	
@@ -1061,6 +1111,31 @@ public class EyesisCorrectionParameters {
    		return dir;
    	}

    	// select qualified (by 'name' - quad timestamp) x3d subdirectory
    	public String selectX3dDirectory(String name, boolean smart, boolean newAllowed) {
    		
    		String dir= CalibrationFileManagement.selectDirectory(
    				smart,
    				newAllowed, // save  
    				"x3d output directory", // title
    				"Select x3d output directory", // button
    				null, // filter
    				this.x3dDirectory); //this.sourceDirectory);
    		if (dir!=null) {
    			this.x3dDirectory=dir;
    			if (this.use_x3d_subdirs &&(name != null) && !name.equals("")) {
    			dir= CalibrationFileManagement.selectDirectory(
        				smart,
        				newAllowed, // save  
        				"x3d output sub-directory", // title
        				"Select x3d output sub-directory", // button
        				null, // filter
        				this.x3dDirectory + Prefs.getFileSeparator()+name); //this.sourceDirectory);
    			}
    		}
    		return dir;
    	}
    	
    	public String selectEquirectangularDirectory(boolean smart, boolean newAllowed) {
    		String dir= CalibrationFileManagement.selectDirectory(
    				smart,
+96 −14
Original line number Diff line number Diff line
@@ -544,7 +544,7 @@ private Panel panel1,
			panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
			addButton("Setup CLT Batch parameters", panelClt3, color_configure);
			addButton("Setup CLT parameters",       panelClt3, color_configure);
			addButton("CLT Batch process",          panelClt3, color_process);
			addButton("CLT batch process",          panelClt3, color_process);
			add(panelClt3);
		}
		pack();
@@ -4937,22 +4937,13 @@ private Panel panel1,
    			return;
    		}
    	}      
/*
	  public boolean output3d(
			  EyesisCorrectionParameters.CLTParameters           clt_parameters,
			  EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
			  EyesisCorrectionParameters.RGBParameters             rgbParameters,
			  final int        threadsMax,  // maximal number of threads to launch                         
			  final boolean    updateStatus,
			  final int        debugLevel)

 */
        boolean OK = QUAD_CLT.output3d(
        		CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
        		COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
        		RGB_PARAMETERS,  // EyesisCorrectionParameters.RGBParameters             rgbParameters,
        		THREADS_MAX,     // final int          threadsMax,  // maximal number of threads to launch                         
        		UPDATE_STATUS,   // final boolean    updateStatus,
        		false,           // final boolean    batch_mode,
        		DEBUG_LEVEL); //final int        debugLevel);
        if (!OK) {
        	String msg="Image data not initialized, run 'CLT 3D' command first";
@@ -4970,7 +4961,98 @@ private Panel panel1,
        }
        
*/
    } else if (label.equals("CLT batch process")) {
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
        			PROPERTIES,
        			EYESIS_CORRECTIONS,
        			CORRECTION_PARAMETERS);
        	if (DEBUG_LEVEL > 0){
        		System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
        	}
        }
    	String configPath=null;
    	if (EYESIS_CORRECTIONS.correctionsParameters.saveSettings) {
    		configPath=EYESIS_CORRECTIONS.correctionsParameters.selectResultsDirectory(
    				true,
    				true);
    		if (configPath==null){
    			String msg="No results directory selected, command aborted";
    			System.out.println("Warning: "+msg);
    			IJ.showMessage("Warning",msg);
    			return;
    		}
    		configPath+=Prefs.getFileSeparator()+"autoconfig"+Prefs.getFileSeparator()+"autoconfig";
    		try {
    			saveTimestampedProperties(
    					configPath,      // full path or null
    					null, // use as default directory if path==null 
    					true,
    					PROPERTIES);

    		} catch (Exception e){
    			String msg="Failed to save configuration to "+configPath+", command aborted";
    			System.out.println("Error: "+msg);
    			IJ.showMessage("Error",msg);
    			return;
    		}
    	}      
        
        EYESIS_CORRECTIONS.initSensorFiles(DEBUG_LEVEL);
        int numChannels=EYESIS_CORRECTIONS.getNumChannels();
        NONLIN_PARAMETERS.modifyNumChannels(numChannels);
        CHANNEL_GAINS_PARAMETERS.modifyNumChannels(numChannels);

        if (!QUAD_CLT.CLTKernelsAvailable()){
        	if (DEBUG_LEVEL > 0){
        		System.out.println("Reading CLT kernels");
        	}
        	QUAD_CLT.readCLTKernels(
            		CLT_PARAMETERS,
                    THREADS_MAX,
                    UPDATE_STATUS, // update status info
            		DEBUG_LEVEL);

            if (DEBUG_LEVEL > 1){
            	QUAD_CLT.showCLTKernels(
            			THREADS_MAX,
            			UPDATE_STATUS, // update status info
            			DEBUG_LEVEL);
        	}
        }

        if (!QUAD_CLT.geometryCorrectionAvailable()){
        	if (DEBUG_LEVEL > 0){
        		System.out.println("Calculating geometryCorrection");
        	}
        	if (!QUAD_CLT.initGeometryCorrection(DEBUG_LEVEL+2)){
        		return;
        	}
        }
        
///========================================        
        QUAD_CLT.batchCLT3d(
        		CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
        		DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters     debayerParameters,
        		NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters       nonlinParameters,
        		COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
        		CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters     channelGainParameters,
        		RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters             rgbParameters,
        		EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
        		CONVOLVE_FFT_SIZE, //int          convolveFFTSize, // 128 - fft size, kernel size should be size/2
        		THREADS_MAX, //final int          threadsMax,  // maximal number of threads to launch                         
        		UPDATE_STATUS, //final boolean    updateStatus,
        		DEBUG_LEVEL); //final int        debugLevel);
        
        if (configPath!=null) {
        	saveTimestampedProperties( // save config again
        			configPath,      // full path or null
        			null, // use as default directory if path==null 
        			true,
        			PROPERTIES);
        }
        return;
        
        
+1 −1
Original line number Diff line number Diff line
@@ -1042,7 +1042,7 @@ public class ImageDtt {
		final int corr_size = transform_size * 2 -1;
		final int [][] transpose_indices = new int [corr_size*(corr_size-1)/2][2];
		int indx = 0;
		if (disparity_corr != 0.0){
		if ((globalDebugLevel > -1) && (disparity_corr != 0.0)){
			System.out.println(String.format("Using manual infinity disparity correction of %8.5f pixels",disparity_corr));
		}
		for (int i =0; i < corr_size-1; i++){