Commit 816eae59 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Testing multiscene LY derivatives

parent 9ec32785
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -115,7 +115,7 @@ public class Corr2dLMA {
	private double [][]       last_jt =         null;
	private double [][]       last_jt =         null;


	private int               ddisp_index;   // =  G0_INDEX +    NUM_PAIRS; // disparity offset per camera (at least 1 should be disabled)
	private int               ddisp_index;   // =  G0_INDEX +    NUM_PAIRS; // disparity offset per camera (at least 1 should be disabled)
	private int               ndisp_index;   //  =  ddisp_index + NUM_CAMS;  // disparity offset per camera - none should be disable
	private int               ndisp_index;   //  =  ddisp_index + NUM_CAMS;  // disparity offset per camera - none should be disabled
	private int               num_all_pars;  //  = ndisp_index+ NUM_CAMS; // maximal number of parameters
	private int               num_all_pars;  //  = ndisp_index+ NUM_CAMS; // maximal number of parameters
	private final int []      used_cams_map; //  =  new int[NUM_CAMS]; // for each camera index return used index ???
	private final int []      used_cams_map; //  =  new int[NUM_CAMS]; // for each camera index return used index ???


@@ -1507,7 +1507,8 @@ public class Corr2dLMA {
								if (par_map[ndisp_index + f] >= 0) jt[par_map[ndisp_index + f]][ns] = 0.0;
								if (par_map[ndisp_index + f] >= 0) jt[par_map[ndisp_index + f]][ns] = 0.0;
							}
							}
						}
						}
						double [] dd_deriv = new double[3]; // derivatives by dependent dd_pre_lars, dd_last and nd_last (calculated on demand) with sign according to first/second in a pair
						double [] dd_deriv = new double[3]; // derivatives by dependent dd_pre_last (0), dd_last (1) and nd_last (1)
						                                    // (calculated on demand) with sign according to first/second in a pair
						if ((fs[0] == pre_last_cam)) {
						if ((fs[0] == pre_last_cam)) {
							dd_deriv[0] =   2 * WGp * lim_negative * 
							dd_deriv[0] =   2 * WGp * lim_negative * 
									(       (A * xmxp + B * ymyp) * m_disp[s.tile][pre_last_cam].get(0, 0)+
									(       (A * xmxp + B * ymyp) * m_disp[s.tile][pre_last_cam].get(0, 0)+
@@ -1551,7 +1552,6 @@ public class Corr2dLMA {
											(B * xmxp + C * ymyp) * m_disp[s.tile][fs[0]].get(1, 1));
											(B * xmxp + C * ymyp) * m_disp[s.tile][fs[0]].get(1, 1));
						}
						}
						if (par_map[ndisp_index + fs[1]] >= 0) {
						if (par_map[ndisp_index + fs[1]] >= 0) {

							jt[par_map[ndisp_index + fs[1]]][ns] -= 2 * WGp * lim_negative *
							jt[par_map[ndisp_index + fs[1]]][ns] -= 2 * WGp * lim_negative *
									(       (A * xmxp + B * ymyp) * m_disp[s.tile][fs[1]].get(0, 1)+
									(       (A * xmxp + B * ymyp) * m_disp[s.tile][fs[1]].get(0, 1)+
											(B * xmxp + C * ymyp) * m_disp[s.tile][fs[1]].get(1, 1));
											(B * xmxp + C * ymyp) * m_disp[s.tile][fs[1]].get(1, 1));
+2 −2
Original line number Original line Diff line number Diff line
@@ -245,7 +245,7 @@ public class ExtrinsicAdjustment {
			double min_strength) {
			double min_strength) {
		if (ref_data == null) ref_data = data;
		if (ref_data == null) ref_data = data;
		double [] avg = new double [indx_length];
		double [] avg = new double [indx_length];
		double [] weights = new double [data.length];
		double [] weights = new double [data.length]; // nullp
		double sw = 0;
		double sw = 0;
		for (int cluster = 0; cluster < weights.length; cluster++) if ((ref_data[cluster] != null) && (data[cluster] != null) && !Double.isNaN (ref_data[cluster][INDX_STRENGTH])){
		for (int cluster = 0; cluster < weights.length; cluster++) if ((ref_data[cluster] != null) && (data[cluster] != null) && !Double.isNaN (ref_data[cluster][INDX_STRENGTH])){
			double w = ref_data[cluster][INDX_STRENGTH] - min_strength;
			double w = ref_data[cluster][INDX_STRENGTH] - min_strength;
@@ -279,7 +279,7 @@ public class ExtrinsicAdjustment {
		String dfmt =  "%"+format[0]+"."+format[1]+"f,";
		String dfmt =  "%"+format[0]+"."+format[1]+"f,";
		String dfmta = "%"+format[0]+"."+(2*format[1])+"f";
		String dfmta = "%"+format[0]+"."+(2*format[1])+"f";
		String hfmt =  "%"+(format[0]/2)+"d%"+(format[0]-format[0]/2)+"s,";
		String hfmt =  "%"+(format[0]/2)+"d%"+(format[0]-format[0]/2)+"s,";
		double [] avg =  weightedLY (data, ref_data, min_strength);
		double [] avg =  weightedLY (data, ref_data, min_strength); //nullp
		String s = "";
		String s = "";
		double avg_dd = 0.0, avg_nd = 0.0, avg_x = 0.0, avg_y = 0.0;
		double avg_dd = 0.0, avg_nd = 0.0, avg_x = 0.0, avg_y = 0.0;
		for (int p = 0; p < num_sensors; p++) avg_dd += avg[indx_dd0 + p]/ num_sensors;
		for (int p = 0; p < num_sensors; p++) avg_dd += avg[indx_dd0 + p]/ num_sensors;
+448 −42

File changed.

Preview size limit exceeded, changes collapsed.

+48 −28
Original line number Original line Diff line number Diff line
@@ -11152,19 +11152,7 @@ if (debugLevel > -100) return true; // temporarily !
		boolean lma_only = true; // use clt_parameters
		boolean lma_only = true; // use clt_parameters
		double        dbg_disparity_offset = 0.0; // 0.1
		double        dbg_disparity_offset = 0.0; // 0.1
		double        inf_disp_ref =   0.0;
		double        inf_disp_ref =   0.0;
/*		
		double        far_inf =       -0.5; //
		double        near_inf =       0.5; //
		double        far_fract =      0.05; //
		double        inf_range_offs = 0.05; // 
		double        inf_range =      0.15; // 
		double        min_inf_str =    0.2;  //
		double        min_fg_str =     0.4;  //
// non-infinity parameters		
		int           clust_size =     4;
		double        scene_range =   10.0;    // disparity range for non-infinity in the same cluster 
		int           min_num_inf =   10;      // Minimal number of tiles (in all scenes total) in an infinity cluster
*/
		int last_scene_index = quadCLTs.length-1;
		int last_scene_index = quadCLTs.length-1;
		QuadCLT last_scene = quadCLTs[last_scene_index];
		QuadCLT last_scene = quadCLTs[last_scene_index];
        String composite_suffix =    "-INTER-INTRA-LMA";
        String composite_suffix =    "-INTER-INTRA-LMA";
@@ -11193,7 +11181,7 @@ if (debugLevel > -100) return true; // temporarily !
//		int []     num_tiles =    new int [clusters]; // may be null;; // null;
//		int []     num_tiles =    new int [clusters]; // may be null;; // null;
//		boolean [] inf_cluster  = new boolean [clusters]; // null;		
//		boolean [] inf_cluster  = new boolean [clusters]; // null;		
		
		
		boolean       debug      = debugLevel > -3; 
		boolean       debug      = debugLevel > -2; 
		
		
		if (proc_infinity) {
		if (proc_infinity) {
			double [] inf_avg = new double[1];
			double [] inf_avg = new double[1];
@@ -11263,14 +11251,11 @@ if (debugLevel > -100) return true; // temporarily !
			}
			}
		}
		}
		
		int [][] num_tiles2 = new int[2][];
		int [][] num_tiles2 = new int[2][];
		double [][][] target_disparities = new double [2][][]; 
		double [][][] target_disparities = new double [2][][]; 
		double [][][] lazy_eye_data = 	MultisceneLY.getLYDataInfNoinf(
		double [][][] lazy_eye_data = 	MultisceneLY.getLYDataInfNoinf(
				clt_parameters,       // final CLTParameters  clt_parameters,
				clt_parameters,       // final CLTParameters  clt_parameters,
				clt_parameters.lyms_clust_size,           // final int            clust_size,
				clt_parameters.lyms_inf_range,            // final double         inf_range,         // full range centered at inf_disp_ref to be used as infinity
				clt_parameters.lyms_scene_range,          // final double         scene_range,       // disparity range for non-infinity in the same cluster
				clt_parameters.lyms_min_num_inf,          // final int            min_num_inf,       // Minimal number of tiles (in all scenes total) in an infinity cluster
				quadCLTs,             // final QuadCLT []     scenes,            // ordered by increasing timestamps
				quadCLTs,             // final QuadCLT []     scenes,            // ordered by increasing timestamps
				valid_tile,           // final boolean [][]   valid_tile,        // tile with lma and single correlation maximum
				valid_tile,           // final boolean [][]   valid_tile,        // tile with lma and single correlation maximum
				inf_disp_ref,         // final double         inf_disp_ref,      // average disparity at infinity for ref scene // is_scene_infinity
				inf_disp_ref,         // final double         inf_disp_ref,      // average disparity at infinity for ref scene // is_scene_infinity
@@ -11278,11 +11263,33 @@ if (debugLevel > -100) return true; // temporarily !
				target_disparities,   // final double[][]     target_disparities,
				target_disparities,   // final double[][]     target_disparities,
				dbg_disparity_offset, // final double         dbg_disparity_offset,
				dbg_disparity_offset, // final double         dbg_disparity_offset,
				num_tiles2,           // final int [][]       in_num_tiles,     // null or number of tiles per cluster to multiply strength
				num_tiles2,           // final int [][]       in_num_tiles,     // null or number of tiles per cluster to multiply strength
				null,                 // final CorrVector     corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
				threadsMax,           // final int            threadsMax,
				threadsMax,           // final int            threadsMax,
				debugLevel);          // final int            debug_level);
				debugLevel);          // final int            debug_level);
		
		
	    boolean                 use_tarz = false; // true; //false;
	    double                  delta = 0.001; // 0.01;
	    
		MultisceneLY.debugLYDerivatives(
				clt_parameters, // final CLTParameters     clt_parameters,
				quadCLTs,             // final QuadCLT []        scenes,            // ordered by increasing timestamps
				lazy_eye_data,        // double [][][]           lazy_eye_data2, // inf, no_inf
				valid_tile,           // final boolean [][]      valid_tile,        // tile with lma and single correlation maximum
				inf_disp_ref,         // final double            inf_disp_ref,      // average disparity at infinity for ref scene // is_scene_infinity
				is_scene_infinity,    //final boolean [][]      is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
				false,                // boolean                 update_disparity, // re-measure disparity before measuring LY
				threadsMax,           // final int               threadsMax,  // maximal number of threads to launch
				true,                 // final boolean           updateStatus,
				delta,                // double                  delta,
				use_tarz,             // boolean                 use_tarz,  // derivatives by tarz, not symmetrical vectors
				debugLevel); // final int               debugLevel);
		if (debugLevel > -200) {
			return;
		}
		
		
		// debug images
		// debug images
		if (debugLevel > -3) {
		if (debugLevel > -2) {
			double [][] dbg_numCorrMax = new double[numCorrMax.length][];
			double [][] dbg_numCorrMax = new double[numCorrMax.length][];
			for (int i = 0; i < dbg_numCorrMax.length; i++) {
			for (int i = 0; i < dbg_numCorrMax.length; i++) {
				dbg_numCorrMax[i] = new double[numCorrMax[i].length];
				dbg_numCorrMax[i] = new double[numCorrMax[i].length];
@@ -11311,11 +11318,17 @@ if (debugLevel > -100) return true; // temporarily !
					"clusters_num_inf_boinf",
					"clusters_num_inf_boinf",
					new String[] {"inf tiles", "noinf tiles"});
					new String[] {"inf tiles", "noinf tiles"});
		
		}
			if (lazy_eye_data != null) {
			if (lazy_eye_data != null) {
				ExtrinsicAdjustment ea_dbg = new ExtrinsicAdjustment (
				multisceneLY.processLYdata(
						clt_parameters,     // final CLTParameters  clt_parameters,
						quadCLTs,           // final QuadCLT []     scenes,        // ordered by increasing timestamps
						lazy_eye_data,      // final double [][][]  lazy_eye_data,
						debugLevel);        // final int            debugLevel 
				/*
				ExtrinsicAdjustment ea = new ExtrinsicAdjustment (
						last_scene.getErsCorrection(),  // GeometryCorrection gc,
						last_scene.getErsCorrection(),  // GeometryCorrection gc,
						clt_parameters.tileStep, // int         clusterSize,
						clt_parameters.lyms_clust_size, // int         clusterSize,
						clustersX,                      // int         clustersX,
						clustersX,                      // int         clustersX,
						clustersY);                     // int         clustersY)
						clustersY);                     // int         clustersY)
				double [][][] dbg_cluster = new double [lazy_eye_data.length][ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors())][clustersY * clustersX];
				double [][][] dbg_cluster = new double [lazy_eye_data.length][ExtrinsicAdjustment.get_INDX_LENGTH(last_scene.getNumSensors())][clustersY * clustersX];
@@ -11338,11 +11351,18 @@ if (debugLevel > -100) return true; // temporarily !
							clustersY,
							clustersY,
							true,
							true,
							last_scene.getImageName()+"-lazy_eye_data-"+m,
							last_scene.getImageName()+"-lazy_eye_data-"+m,
							ea_dbg.data_titles); //  ExtrinsicAdjustment.DATA_TITLES);
							ea.data_titles); //  ExtrinsicAdjustment.DATA_TITLES);
				}
				}
				}
				*/
// Testing next step				
				
				
				
				
				
			
		}
		}
		if (debugLevel > -3) {
		if (debugLevel > -2) {
			System.out.println("adjustLYSeries() Done");
			System.out.println("adjustLYSeries() Done");
		}
		}