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

updated GPU code

parent 15cff9c7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7053,7 +7053,7 @@ private Panel panel1,
			}
			dpixels[i] = d;
		}
		if (disparity_max > 0) {
		if (log_mode && (disparity_max > 0)) {
			mn = 0.0;
			double d = disparity_max;
			if (d < 0.0) { //
+0 −55
Original line number Diff line number Diff line
@@ -1019,24 +1019,9 @@ public class CLTPass3d{
				double     step_threshold,
				double     min_disparity,
				double     max_disparity,
//				double     strength_floor,
//				double     strength_pow,
				double     stBlurSigma,
				boolean    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
				MeasuredLayersFilterParameters mlfp,
//				int        smplSide, //        = 2;      // Sample size (side of a square)
//				int        smplNum, //         = 3;      // Number after removing worst
//				double     smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//				boolean    smplWnd,  // use window functions for the samples

//				double     max_abs_tilt,  //  2.0;   // pix per tile
//				double     max_rel_tilt,  //  0.2;   // (pix / disparity) per tile
//				double     damp_tilt,     //  0.001; // Damp tilt to handle insufficient  (co-linear)data
//				double     min_tilt_disp, //  4.0;   // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//				double     transition,    //  1.0;   // Mode transition range (between tilted and maximal disparity)
//				int        far_mode,      //  1;     // Far objects filtering mode (0 - off, 1 - power of disparity)
//				double     far_power,     //  3.0;   // Raise disparity to this power before averaging for far objects

				int        measSel)
		{
			this.superTiles = new SuperTiles(
@@ -1046,23 +1031,9 @@ public class CLTPass3d{
					step_threshold,
					min_disparity,
					max_disparity,
//					strength_floor,
//					strength_pow,
					stBlurSigma,
					smplMode, //        = true;   // Use sample mode (false - regular tile mode)
					mlfp,
//					smplSide, //        = 2;      // Sample size (side of a square)
//					smplNum, //         = 3;      // Number after removing worst
//					smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//					smplWnd,           // final boolean    smplWnd,  // use window functions for the samples
//					max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//					max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//					damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//					min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//					transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//					far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//					far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
//					true,          // boolean    null_if_none,
					measSel);
			return this.superTiles;
		}
@@ -1072,19 +1043,6 @@ public class CLTPass3d{

				boolean    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
				MeasuredLayersFilterParameters mlfp,
//				int        smplSide, //        = 2;      // Sample size (side of a square)
//				int        smplNum,  //         = 3;      // Number after removing worst
//				double     smplRms,  //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//				boolean    smplWnd,  // use window functions for the samples

//	  			double     max_abs_tilt,  //  2.0;   // pix per tile
//				double     max_rel_tilt,  //  0.2;   // (pix / disparity) per tile
//				double     damp_tilt,     //  0.001; // Damp tilt to handle insufficient  (co-linear)data
//				double     min_tilt_disp, //  4.0;   // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//				double     transition,    //  1.0;   // Mode transition range (between tilted and maximal disparity)
//				int        far_mode,      //  1;     // Far objects filtering mode (0 - off, 1 - power of disparity)
//				double     far_power,     //  3.0;   // Raise disparity to this power before averaging for far objects

				int        measSel)
		{
			if (this.superTiles == null){
@@ -1096,19 +1054,6 @@ public class CLTPass3d{

					smplMode, //        = true;   // Use sample mode (false - regular tile mode)
					mlfp,
//					smplSide, //        = 2;      // Sample size (side of a square)
//					smplNum,  //         = 3;      // Number after removing worst
//					smplRms,  //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//					smplWnd,  // use window functions for the samples

//					max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//					max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//					damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//					min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//					transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//					far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//					far_power,     //    1.0; // Raise disparity to this power before averaging for far objects

					measSel);
		}

+0 −45
Original line number Diff line number Diff line
@@ -104,24 +104,6 @@ public class SuperTiles{
			double                  stBlurSigma,
			boolean                 smplMode, //        = true;   // Use sample mode (false - regular tile mode)
			MeasuredLayersFilterParameters  mlfp,

//			double                  strength_floor,
//			double                  strength_pow,
//			boolean                 smplMode, //        = true;   // Use sample mode (false - regular tile mode)
//			int                     smplSide, //        = 2;      // Sample size (side of a square)
//			int                     smplNum, //         = 3;      // Number after removing worst
//			double                  smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//			boolean                 smplWnd,  // use window functions for the samples

//  			double     max_abs_tilt,  //  2.0;   // pix per tile
//			double     max_rel_tilt,  //  0.2;   // (pix / disparity) per tile
//			double     damp_tilt,     //  0.001; // Damp tilt to handle insufficient  (co-linear)data
//			double     min_tilt_disp, //  4.0;   // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//			double     transition,    //  1.0;   // Mode transition range (between tilted and maximal disparity)
//			int        far_mode,      //  1;     // Far objects filtering mode (0 - off, 1 - power of disparity)
//			double     far_power,     //  3.0;   // Raise disparity to this power before averaging for far objects
//			boolean    null_if_none,

			int                     measSel)
	{
		this.cltPass3d =           cltPass3d;
@@ -135,21 +117,6 @@ public class SuperTiles{
		this.smplMode        = smplMode;   // Use sample mode (false - regular tile mode)
		this.mlfp = mlfp.clone();

//		this.strength_floor = strength_floor;
//		this.strength_pow =   strength_pow;
//		this.smplSide        = smplSide;   // Sample size (side of a square)
//		this.smplNum         = smplNum;    // Number after removing worst
//		this.smplRms         = smplRms;    // Maximal RMS of the remaining tiles in a sample
//		this.max_abs_tilt =  max_abs_tilt;
//		this.max_rel_tilt =  max_rel_tilt;
//		this.damp_tilt =     damp_tilt;
//		this.min_tilt_disp = min_tilt_disp;
//		this.transition =    transition;
//		this.far_mode =      far_mode;
//		this.far_power =     far_power;
//		this.smplWnd         = smplWnd;    // Use window functions for the samples


		this.measSel =        measSel;
		this.step_threshold_near = this.step_threshold_far * step_near / this.step_far ;
		this.bin_far =             this.step_threshold_far / this.step_far;
@@ -197,18 +164,6 @@ public class SuperTiles{
				null,       // boolean [][] tile_sel, // null  or per-measurement layer, per-tile selection. For each layer null - do not use, {} - use all
				smplMode,   // final boolean    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
				mlfp,
//				smplSide,   // final int        smplSide, //        = 2;      // Sample size (side of a square)
//				smplNum,    // final int        smplNum,  //         = 3;      // Number after removing worst
//				smplRms,    // final double     smplRms,  //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
//				smplWnd,    // final boolean    smplWnd,  // use window functions for the samples

//				max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//				max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//				damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//				min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//				transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//				far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//				far_power,     //    1.0; // Raise disparity to this power before averaging for far objects

				measSel);   // calculate and blur supertiles (for all, not just selected?)
		if (tileProcessor.globalDebugLevel > 0){
+4 −91
Original line number Diff line number Diff line
@@ -6796,22 +6796,9 @@ ImageDtt.startAndJoin(threads);
					clt_parameters.stStepThreshold,  // double     step_threshold,
					clt_parameters.stMinDisparity,   // double     min_disparity,
					clt_parameters.grow_disp_max,   // double     max_disparity,
//					clt_parameters.stFloor,          // double     strength_floor,
//					clt_parameters.stPow,            // double     strength_pow,
					0.0, // NO BLUR double     stBlurSigma)
					false, //clt_parameters.stSmplMode,  // Use sample mode (false - regular tile mode)
					clt_parameters.mlfp,         // Filter parameters
//					clt_parameters.stSmplSide,  // Sample size (side of a square)
//					clt_parameters.stSmplNum,   // Number after removing worst
//					clt_parameters.stSmplRms,   // Maximal RMS of the remaining tiles in a sample
//					clt_parameters.stSmplWnd,   // boolean                 smplWnd,  // use window functions for the samples
//					clt_parameters.fs_max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//					clt_parameters.fs_max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//					clt_parameters.fs_damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//					clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//					clt_parameters.fs_transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//					clt_parameters.fs_far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//					clt_parameters.fs_far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
					clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
			dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram();
			scan_prev.setSuperTiles(
@@ -6820,22 +6807,9 @@ ImageDtt.startAndJoin(threads);
					clt_parameters.stStepThreshold,  // double     step_threshold,
					clt_parameters.stMinDisparity,   // double     min_disparity,
					clt_parameters.grow_disp_max,   // double     max_disparity,
//					clt_parameters.stFloor,          // double     strength_floor,
//					clt_parameters.stPow,            // double     strength_pow,
					0.0, // NO BLUR double     stBlurSigma)
					clt_parameters.stSmplMode,  // Use sample mode (false - regular tile mode)
					clt_parameters.mlfp,         // Filter parameters
//					clt_parameters.stSmplSide,  // Sample size (side of a square)
//					clt_parameters.stSmplNum,   // Number after removing worst
//					clt_parameters.stSmplRms,   // Maximal RMS of the remaining tiles in a sample
//					clt_parameters.stSmplWnd,   // boolean                 smplWnd,  // use window functions for the samples
//					clt_parameters.fs_max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//					clt_parameters.fs_max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//					clt_parameters.fs_damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//					clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//					clt_parameters.fs_transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//					clt_parameters.fs_far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//					clt_parameters.fs_far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
					clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
			dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram();
		}
@@ -6847,22 +6821,9 @@ ImageDtt.startAndJoin(threads);
				clt_parameters.stStepThreshold,  // double     step_threshold,
				clt_parameters.stMinDisparity,   // double     min_disparity,
				clt_parameters.grow_disp_max,   // double     max_disparity,
//				clt_parameters.stFloor,          // double     strength_floor,
//				clt_parameters.stPow,            // double     strength_pow,
				clt_parameters.stSigma,          // with blur double     stBlurSigma)
				false, //clt_parameters.stSmplMode,  // Use sample mode (false - regular tile mode)
				clt_parameters.mlfp,         // Filter parameters
//				clt_parameters.stSmplSide,  // Sample size (side of a square)
//				clt_parameters.stSmplNum,   // Number after removing worst
//				clt_parameters.stSmplRms,   // Maximal RMS of the remaining tiles in a sample
//				clt_parameters.stSmplWnd,   // boolean                 smplWnd,  // use window functions for the samples
//				clt_parameters.fs_max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//				clt_parameters.fs_max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//				clt_parameters.fs_damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//				clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//				clt_parameters.fs_transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//				clt_parameters.fs_far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//				clt_parameters.fs_far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
				clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
		if (show_st) { // otherwise only blured version is needed
			dbg_hist[2] = scan_prev.getSuperTiles().showDisparityHistogram();
@@ -6884,22 +6845,9 @@ ImageDtt.startAndJoin(threads);
					clt_parameters.stStepThreshold,  // double     step_threshold,
					clt_parameters.stMinDisparity,   // double     min_disparity,
					clt_parameters.grow_disp_max,   // double     max_disparity,
//					clt_parameters.stFloor,          // double     strength_floor,
//					clt_parameters.stPow,            // double     strength_pow,
					0.0, // NO BLUR double     stBlurSigma)
					clt_parameters.stSmplMode,  // Use sample mode (false - regular tile mode)
					clt_parameters.mlfp,         // Filter parameters
//					clt_parameters.stSmplSide,  // Sample size (side of a square)
//					clt_parameters.stSmplNum,   // Number after removing worst
//					clt_parameters.stSmplRms,   // Maximal RMS of the remaining tiles in a sample
//					clt_parameters.stSmplWnd,   // boolean                 smplWnd,  // use window functions for the samples
//					clt_parameters.fs_max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
//					clt_parameters.fs_max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
//					clt_parameters.fs_damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
//					clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
//					clt_parameters.fs_transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
//					clt_parameters.fs_far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
//					clt_parameters.fs_far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
					clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
		}

@@ -7063,22 +7011,6 @@ ImageDtt.startAndJoin(threads);
				debugLevel,                  // final int        debugLevel)
				clt_parameters.tileX,
				clt_parameters.tileY);
/*
		if (clt_parameters.plSplitApply) {
			while (true) {
				int num_added = 0;
				num_added += st.fillSquares();
				if (debugLevel > -1) {
					System.out.println("after fillSquares() added "+num_added);
				}
				num_added += st.cutCorners();
				if (debugLevel > -1) {
					System.out.println("after plCutCorners() added (cumulative) "+num_added);
				}
				if (num_added == 0) break;
			}
		}
*/
		double [][][]  dispStrength = st.getDisparityStrengths(
				clt_parameters.stMeasSel); // int        stMeasSel) //            = 1;      // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert)
		boolean [][] tileSel =  st.getMeasurementSelections(
@@ -7199,25 +7131,6 @@ ImageDtt.startAndJoin(threads);
					clt_parameters.tileY);
		} // if (clt_parameters.plSplitApply)

/*
		while (true) {
			int num_added = 0;
			if (clt_parameters.plFillSquares){
				num_added += st.fillSquares();
			}
			if (debugLevel > -1) {
				System.out.println("after fillSquares() added "+num_added);
			}
			if (clt_parameters.plCutCorners){
				num_added += st.cutCorners();
			}
			if (debugLevel > -1) {
				System.out.println("after plCutCorners() added (cumulative) "+num_added);
			}
			if (num_added == 0) break;
		}

*/

		int max_num_tries = 20;
		if (clt_parameters.plIterations > 0) {
+28 −1
Original line number Diff line number Diff line
@@ -403,6 +403,16 @@ __constant__ float lpf_corr[64]={ // modify if needed
				0.02728573f, 0.02374977f, 0.01799322f, 0.01186582f, 0.00681327f, 0.00341565f, 0.00153247f, 0.00074451f
		};

__constant__ float LoG_corr[64]={ // modify if needed high-pass filter before correlation to fit into float range
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
				1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f
		};

__constant__ int pairs[6][2]={
		{0, 1},
@@ -1086,6 +1096,22 @@ extern "C" __global__ void correlate2D_inner(
		float * clt_tile1i = clt_tile1 + threadIdx.x;
		float * clt_tile2i = clt_tile2 + threadIdx.x;
#pragma unroll
#define USE_LOG
#ifdef 	USE_LOG
		// Apply high-pass filter to correlation inputs to reduce dynamic range before multiplication
		for (int q = 0; q < 4; q++){
    		float *log = LoG_corr + threadIdx.x;
			for (int i = 0; i < DTT_SIZE; i++){ // copy 32 rows (4 quadrants of 8 rows)
				*clt_tile1i= (*gpu_tile1) * (*log);
				*clt_tile2i= (*gpu_tile2) * (*log);
				clt_tile1i += DTT_SIZE1;
				clt_tile2i += DTT_SIZE1;
				gpu_tile1 += DTT_SIZE;
				gpu_tile2 += DTT_SIZE;
				log +=       DTT_SIZE;
			}
		}
#else
		for (int i = 0; i < DTT_SIZE4; i++){ // copy 32 rows (4 quadrants of 8 rows)
			*clt_tile1i= *gpu_tile1;
			*clt_tile2i= *gpu_tile2;
@@ -1094,6 +1120,7 @@ extern "C" __global__ void correlate2D_inner(
			gpu_tile1 += DTT_SIZE;
			gpu_tile2 += DTT_SIZE;
    	}
#endif //USE_LOG
		__syncthreads();
#ifdef DBG_TILE
#ifdef DEBUG6
Loading