Commit 5defee61 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

debugging

parent aac34c6a
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -2242,7 +2242,7 @@ public class CuasMotion {
			int                 corr_offset,        // inter-frame distance for correlation pairs
			int                 dbg_iter_index,     // to generate different image names for different iteration to simplify "save as" images
			int                 debugLevel) {

		final int max_index_dbg = 10; // show images for the first iterations only
		final int tileSize = GPUTileProcessor.DTT_SIZE;   // 8 pixels
		final int tilesX   = cuasMotion.tilesX;
		final int width    = cuasMotion.gpu_max_width;
@@ -2258,8 +2258,8 @@ public class CuasMotion {
		final int corr_pairs_ref = (int) Math.round(2 * half_accum_range * recalc_mv_boost);

		// Hard-coded debug selectors: set >= 0 to enable per-scan/per-tile visualisation
		final int dbg_nseq = 157; // -(116); // 57; // 20; // -1;
		final int dbg_tile = 55+38*80; // -(17 + 33*80); // 48+32*80; // 50+38*80; // -1;
		final int dbg_nseq = 41; // 157; // -(116); // 57; // 20; // -1;
		final int dbg_tile = 50+38*80; // 55+38*80; // -(17 + 33*80); // 48+32*80; // 50+38*80; // -1;

		// Pre-compute integer-pixel raised-cosine mask kernel once (shared across all nseq)
		final int r1i = (int) Math.ceil(recalc_mv_r1);
@@ -2275,7 +2275,7 @@ public class CuasMotion {
				mask_kernel[(dy + r1i) * mside + (dx + r1i)] = w;
			}
		}
		if ((dbg_nseq >= 0 || dbg_tile >= 0) && debugLevel >= 0) {
		if ((dbg_nseq >= 0 || dbg_tile >= 0) && (debugLevel >= 0) && (dbg_iter_index<= max_index_dbg)) {
			ShowDoubleFloatArrays.showArrays(mask_kernel.clone(), mside, mside,
					"refineMotionVectors-mask-r0_" + recalc_mv_r0 + "-r1_" + recalc_mv_r1+"-niter"+dbg_iter_index);
		}
@@ -2370,7 +2370,7 @@ public class CuasMotion {
			ImageDtt.startAndJoin(threads);

			// Debug: show full fmin..fmax masked frame stack for dbg_nseq
			if (nseq == dbg_nseq && debugLevel >= 0) {
			if ((nseq == dbg_nseq) && (debugLevel >= 0) && (dbg_iter_index<= max_index_dbg)) {
				int fcount = fmax_alloc - fmin_alloc + 1;
				float[][] stack_slices = new float[fcount][];
				String[] stack_titles = new String[fcount];
@@ -2383,7 +2383,7 @@ public class CuasMotion {
				ShowDoubleFloatArrays.showArrays(stack_slices, width, height, true,
						"refineMotionVectors-masked-nseq" + nseq+"-niter"+dbg_iter_index, stack_titles);
			}
			if (nseq == dbg_nseq && debugLevel >= 0) {
			if ((nseq == dbg_nseq) && (debugLevel >= 0) && (dbg_iter_index<= max_index_dbg)) {
				int fcount = fmax_alloc - fmin_alloc + 1;
				float[][] stack_slices = new float[fcount][];
				String[] stack_titles = new String[fcount];
@@ -2436,10 +2436,12 @@ public class CuasMotion {
				if (target == null || Double.isNaN(target[CuasMotionLMA.RSLT_X])) continue;
				if (vector_field[ntile] == null) continue;
				if (ntile == dbg_tile && debugLevel >= 0) {
					System.out.printf("refineMotionVectors(): nseq=%d ntile=%d  before: VX=%.4f VY=%.4f  delta: dVX=%.4f dVY=%.4f%n",
					System.out.printf("refineMotionVectors(): nseq=%3d ntile=%4d  before: VX=%9.4f VY=%9.4f  delta: dVX=%8.4f dVY=%8.4f% after: VX1=%9.4f VY1=%9.4f%",
							nseq, ntile,
							target[CuasMotionLMA.RSLT_VX], target[CuasMotionLMA.RSLT_VY],
							vector_field[ntile][INDX_VX],   vector_field[ntile][INDX_VY]);
							vector_field[ntile][INDX_VX],   vector_field[ntile][INDX_VY],
							target[CuasMotionLMA.RSLT_VX] + vector_field[ntile][INDX_VX],
							target[CuasMotionLMA.RSLT_VY] + vector_field[ntile][INDX_VY]);
				}
				target[CuasMotionLMA.RSLT_VX] += vector_field[ntile][INDX_VX];
				target[CuasMotionLMA.RSLT_VY] += vector_field[ntile][INDX_VY];
+19 −3
Original line number Diff line number Diff line
@@ -803,8 +803,10 @@ min_str_neib_fpn 0.35
    public int      cuas_temporal_um =    100;    // temporal "unsharp mask" - subtract running
    public double   cuas_tum_threshold =  5.0;    // if >0, remove outliers from the running average and recalculate RA
    
    public int      cuas_precorr_ra =     10;     // rolling average before correlation
    public int      cuas_precorr_ra =     4;      // running average before correlation
    public int      cuas_corr_step =      2;      // correlation step when using rolling average
    public int      cuas_accum_ra =       2;      // running average before shifted target accumulation
    public int      cuas_accum_step =     2;      // accumulation step when using rolling average
    public boolean  cuas_half_step =     true;    // half step (=cuas_corr_offset/2) when scanning for motion
    public int      cuas_max_range =       2;     // how far to extend local max: 1 3x3 neighbors, 2 - 5x5 neighbs
@@ -2716,9 +2718,14 @@ min_str_neib_fpn 0.35
				"Remove outlier pixels that differ from the running average by more than this (to later re-calculate running average excluding those pixels.");
		gd.addNumericField("Pre-correlation running average",        this.cuas_precorr_ra, 0,3,"scenes",
				"Smoothing input data by running average before correlation for motion vectors calculations. Target extraction wil still use individual scenes.");
				"LPF input data by running average before correlation for motion vectors calculations. Target extraction wil still use individual scenes.");
		gd.addNumericField("Correlation step after RA",              this.cuas_corr_step, 0,3,"scenes",
				"Decimate correlations after running average");
		gd.addNumericField("Pre target accumulation running average",this.cuas_accum_ra, 0,3,"scenes",
				"LPF input data by running average before target accumulation to avoid potential prsision loss for long series.");
		gd.addNumericField("Averaging step after RA",                this.cuas_accum_step, 0,3,"scenes",
				"Step in averaging of the shifted targets when using input LPF");
		
		gd.addCheckbox    ("Half scan step",                         this.cuas_half_step,
				"Reduce step for motion detection = offset/2, if false = offset.");
		gd.addNumericField("Local max range",                        this.cuas_max_range, 0,3,"",
@@ -4383,6 +4390,8 @@ min_str_neib_fpn 0.35
		
		this.cuas_precorr_ra =    (int) gd.getNextNumber();
		this.cuas_corr_step =     (int) gd.getNextNumber();
		this.cuas_accum_ra =      (int) gd.getNextNumber();
		this.cuas_accum_step =    (int) gd.getNextNumber();
		
		this.cuas_half_step =           gd.getNextBoolean();
		this.cuas_max_range =     (int) gd.getNextNumber();
@@ -5690,6 +5699,8 @@ min_str_neib_fpn 0.35
		
		properties.setProperty(prefix+"cuas_precorr_ra",      this.cuas_precorr_ra+"");     // int
		properties.setProperty(prefix+"cuas_corr_step",       this.cuas_corr_step+"");      // int
		properties.setProperty(prefix+"cuas_accum_ra",        this.cuas_accum_ra+"");       // int
		properties.setProperty(prefix+"cuas_accum_step",      this.cuas_accum_step+"");     // int
		
        properties.setProperty(prefix+"cuas_half_step",       this.cuas_half_step+"");      // boolean
		properties.setProperty(prefix+"cuas_max_range",       this.cuas_max_range+"");      // int
@@ -6932,6 +6943,8 @@ min_str_neib_fpn 0.35
		
		if (properties.getProperty(prefix+"cuas_precorr_ra")!=null)      this.cuas_precorr_ra=Integer.parseInt(properties.getProperty(prefix+"cuas_precorr_ra"));
		if (properties.getProperty(prefix+"cuas_corr_step")!=null)       this.cuas_corr_step=Integer.parseInt(properties.getProperty(prefix+"cuas_corr_step"));
		if (properties.getProperty(prefix+"cuas_accum_ra")!=null)        this.cuas_accum_ra=Integer.parseInt(properties.getProperty(prefix+"cuas_accum_ra"));
		if (properties.getProperty(prefix+"cuas_accum_step")!=null)      this.cuas_accum_step=Integer.parseInt(properties.getProperty(prefix+"cuas_accum_step"));
		
		if (properties.getProperty(prefix+"cuas_half_step")!=null)       this.cuas_half_step=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_half_step"));
		if (properties.getProperty(prefix+"cuas_max_range")!=null)       this.cuas_max_range=Integer.parseInt(properties.getProperty(prefix+"cuas_max_range"));
@@ -8191,6 +8204,9 @@ min_str_neib_fpn 0.35
		
		imp.cuas_precorr_ra =       this.cuas_precorr_ra;
		imp.cuas_corr_step =        this.cuas_corr_step;
		imp.cuas_accum_ra =         this.cuas_accum_ra;
		imp.cuas_accum_step =       this.cuas_accum_step;
		
		imp.cuas_half_step =        this.cuas_half_step;
		imp.cuas_max_range =        this.cuas_max_range;
		imp.cuas_fin_range =        this.cuas_fin_range;