Commit 58750471 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Implementing/testing interscene accumulation

parent 605aa42c
Loading
Loading
Loading
Loading
+199 −94
Original line number Diff line number Diff line
@@ -712,9 +712,13 @@ private Panel panel1,
			addButton("Inter Test",                 panelClt5, color_stop);
			addButton("Aux Inter Test",             panelClt5, color_stop);
			addButton("Inter Pairs",                panelClt5, color_process);
			addButton("Aux Inter Pairs",            panelClt5, color_process);
			addButton("Inter LMA",                  panelClt5, color_stop);
			addButton("Aux Inter LMA",              panelClt5, color_stop);
			addButton("Inter Series",               panelClt5, color_process);
			addButton("Aux Inter Series",           panelClt5, color_process);
			addButton("Inter Accumulate",           panelClt5, color_process);
			addButton("Aux Inter Accumulate",       panelClt5, color_process);
			addButton("Inter Noise",                panelClt5, color_process);
			addButton("Inter Debug Noise",          panelClt5, color_report);
			addButton("Noise Stats",                panelClt5, color_process);
@@ -5156,22 +5160,42 @@ private Panel panel1,
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        interPairsLMA();
        interPairsLMA(false);
    	return;
/* ======================================================================== */
    } else if (label.equals("Aux Inter Pairs")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        interPairsLMA(true);
    	return;
/* ======================================================================== */
    } else if (label.equals("Inter Series")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        interSeriesLMA();
        interSeriesLMA(false);
    	return;
/* ======================================================================== */
    } else if (label.equals("Aux Inter Series")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        interSeriesLMA(true);
    	return;
/* ======================================================================== */
    } else if (label.equals("Inter Accumulate")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        intersceneAccumulate();
        intersceneAccumulate(false);
    	return;
/* ======================================================================== */
    } else if (label.equals("Aux Inter Accumulate")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        intersceneAccumulate(true);
    	return;
/* ======================================================================== */
@@ -5217,10 +5241,15 @@ private Panel panel1,
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        testInterLMA();
        testInterLMA(false);
    	return;
/* ======================================================================== */
    } else if (label.equals("Aux Inter LMA")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        CLT_PARAMETERS.batch_run = true;
        testInterLMA(true);
    	return;
    	
    	
/* ======================================================================== */
    } else if (label.equals("CLT rig edit")) {
        DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
@@ -6653,6 +6682,7 @@ private Panel panel1,
						return false;
					} //final int        debugLevel);
					QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
				}
			} else {
				if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
					try {
@@ -6669,7 +6699,7 @@ private Panel panel1,
					QUAD_CLT.setGPU(GPU_QUAD);
				}
			}
			}
		}
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
@@ -6707,7 +6737,7 @@ private Panel panel1,
	}
	
	public boolean testInterLMA() {
	public boolean testInterLMA(boolean use_aux) {
		long startTime=System.nanoTime();
		// load needed sensor and kernels files
		if (!prepareRigImages()) return false;
@@ -6729,6 +6759,22 @@ private Panel panel1,
					return false;
				} //final int        debugLevel);
			}
			if (use_aux) {
				if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
					try {
						GPU_QUAD_AUX =  new GpuQuad(//
								GPU_TILE_PROCESSOR, QUAD_CLT_AUX,
								4,
								3);
					} catch (Exception e) {
						System.out.println("Failed to initialize GpuQuad class");
						// TODO Auto-generated catch block
						e.printStackTrace();
						return false;
					} //final int        debugLevel);
					QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
				}
			} else {
				if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
					try {
						GPU_QUAD = new GpuQuad(
@@ -6744,15 +6790,17 @@ private Panel panel1,
					QUAD_CLT.setGPU(GPU_QUAD);
				}
			}
		
		}
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		try {
			TWO_QUAD_CLT.TestInterLMA(
					QUAD_CLT, // QuadCLT quadCLT_main,
					quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
//					QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
					CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
					DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters     debayerParameters,
					COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
//					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters     channelGainParameters,
					RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters             rgbParameters,
					EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
@@ -6779,7 +6827,7 @@ private Panel panel1,
	}
	
	
	public boolean interPairsLMA() {
	public boolean interPairsLMA(boolean use_aux) {
		long startTime=System.nanoTime();
		// load needed sensor and kernels files
		if (!prepareRigImages()) return false;
@@ -6801,6 +6849,22 @@ private Panel panel1,
					return false;
				} //final int        debugLevel);
			}
			if (use_aux) {
				if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
					try {
						GPU_QUAD_AUX =  new GpuQuad(//
								GPU_TILE_PROCESSOR, QUAD_CLT_AUX,
								4,
								3);
					} catch (Exception e) {
						System.out.println("Failed to initialize GpuQuad class");
						// TODO Auto-generated catch block
						e.printStackTrace();
						return false;
					} //final int        debugLevel);
					QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
				}
			} else {
				if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
					try {
						GPU_QUAD = new GpuQuad(
@@ -6815,16 +6879,20 @@ private Panel panel1,
					} //final int        debugLevel);
					QUAD_CLT.setGPU(GPU_QUAD);
				}
		}
			}
		}
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		try {
			TWO_QUAD_CLT.interPairsLMA(
					QUAD_CLT, // QuadCLT quadCLT_main,
					quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
//					QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
					CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
					DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters     debayerParameters,
					COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
//					COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
//					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters     channelGainParameters,
					RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters             rgbParameters,
					EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
@@ -6851,7 +6919,7 @@ private Panel panel1,
	}
	
	
	public boolean interSeriesLMA() {
	public boolean interSeriesLMA(boolean use_aux) {
		long startTime=System.nanoTime();
		// load needed sensor and kernels files
		if (!prepareRigImages()) return false;
@@ -6873,6 +6941,22 @@ private Panel panel1,
					return false;
				} //final int        debugLevel);
			}
			if (use_aux) {
				if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
					try {
						GPU_QUAD_AUX =  new GpuQuad(//
								GPU_TILE_PROCESSOR, QUAD_CLT_AUX,
								4,
								3);
					} catch (Exception e) {
						System.out.println("Failed to initialize GpuQuad class");
						// TODO Auto-generated catch block
						e.printStackTrace();
						return false;
					} //final int        debugLevel);
					QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
				}
			} else {
				if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
					try {
						GPU_QUAD = new GpuQuad(
@@ -6888,15 +6972,17 @@ private Panel panel1,
					QUAD_CLT.setGPU(GPU_QUAD);
				}
			}
		
		}
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		try {
			TWO_QUAD_CLT.interSeriesLMA(
					QUAD_CLT, // QuadCLT quadCLT_main,
					quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
//					QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
					CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
					DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters     debayerParameters,
					COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
//					COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
					CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters     channelGainParameters,
					RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters             rgbParameters,
					EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
@@ -6922,7 +7008,7 @@ private Panel panel1,
		return true;
	}
	
	public boolean intersceneAccumulate() {
	public boolean intersceneAccumulate(boolean use_aux) {
		long startTime=System.nanoTime();
		// load needed sensor and kernels files
		if (!prepareRigImages()) return false;
@@ -6944,6 +7030,22 @@ private Panel panel1,
					return false;
				} //final int        debugLevel);
			}
			if (use_aux) {
				if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
					try {
						GPU_QUAD_AUX =  new GpuQuad(//
								GPU_TILE_PROCESSOR, QUAD_CLT_AUX,
								4,
								3);
					} catch (Exception e) {
						System.out.println("Failed to initialize GpuQuad class");
						// TODO Auto-generated catch block
						e.printStackTrace();
						return false;
					} //final int        debugLevel);
					QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
				}
			} else {
				if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
					try {
						GPU_QUAD = new GpuQuad(
@@ -6958,14 +7060,17 @@ private Panel panel1,
					} //final int        debugLevel);
					QUAD_CLT.setGPU(GPU_QUAD);
				}
		}
			}
		}
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		try {
			TWO_QUAD_CLT.intersceneAccumulate(
					QUAD_CLT, // QuadCLT quadCLT_main,
					quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
					CLT_PARAMETERS,  // EyesisCorrectionParameters.DCTParameters           dct_parameters,
					DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters     debayerParameters,
					COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters     channelGainParameters,
					RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters             rgbParameters,
					EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
+8 −3
Original line number Diff line number Diff line
@@ -2305,7 +2305,11 @@ public class GpuQuad{ // quad camera description
		final double [] max_py = new double[num_cams] ;
		for (int i = 0; i < num_cams; i++) {
			min_py [i] = margin + geometryCorrection.getWOITops()[i];
			max_py [i] = geometryCorrection.getWOITops()[i] + geometryCorrection.getCameraHeights()[i] - 1 - margin;
			// camera_heights array is only set during conditionImageSet(), not called by the intersceneAccumulate()
			// That was correct, as all scenes should be conditioned
//			max_py [i] = geometryCorrection.getWOITops()[i] + geometryCorrection.getCameraHeights()[i] - 1 - margin;
			max_py [i] = geometryCorrection.getSensorWH()[1] - 1 - margin;
			//.getSensorWH()[0]
		}
		if (valid_tiles!=null) {
			Arrays.fill(valid_tiles, false);
@@ -2334,17 +2338,18 @@ public class GpuQuad{ // quad camera description
						tp_task.task = task_code;
						double disparity = pXpYD[nTile][2] + disparity_corr;
						tp_task.target_disparity = (float) disparity; // will it be used?
						double [][] disp_dist_main = new double[quad_main][]; // used to correct 3D correlations (not yet used here)
						double [][] disp_dist = new double[quad_main][]; // used to correct 3D correlations (not yet used here)
						double [][] centersXY_main = geometryCorrection.getPortsCoordinatesAndDerivatives(
								geometryCorrection, //			GeometryCorrection gc_main,
								false,          // boolean use_rig_offsets,
								corr_rots, // Matrix []   rots,
								null,           //  Matrix [][] deriv_rots,
								null,           // double [][] pXYderiv, // if not null, should be double[8][]
								disp_dist_main,       // used to correct 3D correlations
								disp_dist,       // used to correct 3D correlations
								pXpYD[nTile][0],
								pXpYD[nTile][1],
								disparity); //  + disparity_corr);
						tp_task.setDispDist(disp_dist);
						tp_task.xy = new float [centersXY_main.length][2];
						boolean bad_margins = false;
						for (int i = 0; i < centersXY_main.length; i++) {
+31 −1
Original line number Diff line number Diff line
@@ -54,6 +54,18 @@ public class TpTask {
	public float [][] getDispDist(){
		return disp_dist;
	}
	public void setDispDist(float [][] disp_dist){
		this.disp_dist = disp_dist;
	}
	public void setDispDist(double [][] disp_dist){
		this.disp_dist = new float [disp_dist.length][disp_dist[0].length];
		for (int i = 0; i < disp_dist.length; i++) {
			for (int j = 0; j < disp_dist[0].length; j++) {
				this.disp_dist[i][j] = (float) disp_dist[i][j];		
			}
		}
	}

	public double [][] getDoubleDispDist(){
		if (disp_dist == null) { // can it happen?
			return null;
@@ -66,10 +78,11 @@ public class TpTask {
		}
		return ddisp_dist;
	}
	
	@Deprecated
	public float [][] getXY(boolean use_aux){
		return use_aux? xy_aux : xy;
	}
	@Deprecated
	public double [][] getDoubleXY(boolean use_aux){
		float [][] fXY = getXY(use_aux);
		if (fXY == null) {
@@ -84,6 +97,23 @@ public class TpTask {
		return dXY;
	}

	public float [][] getXY(){
		return  xy;
	}
	public double [][] getDoubleXY(){
		float [][] fXY = getXY();
		if (fXY == null) {
			return null;
		}
		double [][] dXY = new double [fXY.length][fXY[0].length];
		for (int nsens = 0; nsens < fXY.length; nsens++) {
			for (int i = 0; i < fXY[nsens].length; i++) {
				dXY[nsens][i] = fXY[nsens][i]; 
			}
		}
		return dXY;
	}
	
	
	
	public int getTileY(){
+1 −1
Original line number Diff line number Diff line
@@ -2024,7 +2024,7 @@ public class Corr2dLMA {
			double      lambda,
			double [][] jt){
		int num_pars = jt.length;
		int nup_points = jt[0].length;
		int nup_points = (num_pars > 0)? jt[0].length : 0;
		double [][] wjtjl = new double [num_pars][num_pars];
		for (int i = 0; i < num_pars; i++) {
			for (int j = i; j < num_pars; j++) {
+5 −1
Original line number Diff line number Diff line
@@ -274,6 +274,10 @@ public class Correlation2d {
    	return pair_start_end.length;
    }
    
    public static int getNumPairs(int numSensors) {
     return  numSensors * (numSensors-1) /2;
    }
    
    public void setCorrPairs(boolean [] sel) { // these pairs will be correlated
    	corr_pairs = sel.clone();
    }
@@ -782,7 +786,7 @@ public class Correlation2d {
				true,                            // boolean normalize,
				true,                            // boolean notch,
				wndx_scale);                     // double  scale);
    	int num_pairs = numSensors * (numSensors-1) /2;
    	int num_pairs = getNumPairs(numSensors);//  numSensors * (numSensors-1) /2;
    	pair_start_end = new int [num_pairs][2];
    	pair_orient =    new int [num_pairs][num_pairs];
    	pair_length =    new int [num_pairs];
Loading