Commit 8623329f authored by Andrey Filippov's avatar Andrey Filippov

started TD neighbors

parent aec8ae98
...@@ -507,7 +507,7 @@ public class GpuQuad{ // quad camera description ...@@ -507,7 +507,7 @@ public class GpuQuad{ // quad camera description
public int getSensorWidth() {return this.img_width;} public int getSensorWidth() {return this.img_width;}
public int getSensorHeight() {return this.img_height;} public int getSensorHeight() {return this.img_height;}
public int getDttSize() {return GPUTileProcessor.DTT_SIZE;} public static int getDttSize() {return GPUTileProcessor.DTT_SIZE;}
// public int getNumCams() {return GPUTileProcessor.NUM_CAMS;} // public int getNumCams() {return GPUTileProcessor.NUM_CAMS;}
public int getSensorMaskInter() {return sensor_mask_inter;} public int getSensorMaskInter() {return sensor_mask_inter;}
public void setSensorMaskInter(int mask) { public void setSensorMaskInter(int mask) {
...@@ -2718,7 +2718,6 @@ public class GpuQuad{ // quad camera description ...@@ -2718,7 +2718,6 @@ public class GpuQuad{ // quad camera description
public int getNumPairs() {return num_all_pairs;} public int getNumPairs() {return num_all_pairs;}
//
/** /**
* Generating correlation sequence by CPU to correlate all tiles provided in linescan order. * Generating correlation sequence by CPU to correlate all tiles provided in linescan order.
* Additionally, if both (num_acc != null) and (pfcorr_weights !=null), pfcorr_weights[0] * Additionally, if both (num_acc != null) and (pfcorr_weights !=null), pfcorr_weights[0]
...@@ -2817,10 +2816,10 @@ public class GpuQuad{ // quad camera description ...@@ -2817,10 +2816,10 @@ public class GpuQuad{ // quad camera description
int ty = tp_tasks[ntile].ty; int ty = tp_tasks[ntile].ty;
int tx = tp_tasks[ntile].tx; int tx = tp_tasks[ntile].tx;
for (int ipair = 0; ipair < num_pairs; ipair++) { for (int ipair = 0; ipair < num_pairs; ipair++) {
int pair = inter_mode?getSensInter(ipair): getCorrPair(ipair); int pair = inter_mode?getSensInter(ipair): getCorrPair(ipair); // 0xff for accumulated
int corr_pair = ntile * num_pairs + ipair; int corr_pair = ntile * num_pairs + ipair;
// Below was an error (not visible if all selected, using index of the pair, not an absolute pair ) // Below was an error (not visible if all selected, using index of the pair, not an absolute pair )
indices[corr_pair]= // ntile * num_pairs + pair] = indices[corr_pair]= // ntile * num_pairs + pair] = // low 8 bits - pair, 0xff for sum of all channels
((ty * tilesX + tx) << GPUTileProcessor.CORR_NTILE_SHIFT) + ((ty * tilesX + tx) << GPUTileProcessor.CORR_NTILE_SHIFT) +
(pair & ((1 << GPUTileProcessor.CORR_NTILE_SHIFT) -1) ); (pair & ((1 << GPUTileProcessor.CORR_NTILE_SHIFT) -1) );
if (fcorr_weights != null) { if (fcorr_weights != null) {
...@@ -2994,9 +2993,44 @@ public class GpuQuad{ // quad camera description ...@@ -2994,9 +2993,44 @@ public class GpuQuad{ // quad camera description
return corr_tiles; return corr_tiles;
} }
/**
* Read GPU correlation data to the sparse array [tilesY][tilesX][] for a single correlation pair (usually a combo one)
* @param inter true for interscene correlations, false - for the intrascene ones
* @param pair correlation pair index to read
* @return an array of transform-domain correlations mapped to tiles [tilesY][tilesX]. Each tile data is either null
* or [4*64] float array
*/
public float [][][] getCorrTilesLayerTD(
boolean inter,
int pair) {
int tilesX = img_width / GPUTileProcessor.DTT_SIZE;
int tilesY = img_height / GPUTileProcessor.DTT_SIZE;
int num_pairs = inter? (getNumCamsInter() + 1 + 0): getNumUsedPairs();// Number of used pairs num_pairs = num_pairs_in;
final int corr_size_td = 4 * GPUTileProcessor.DTT_SIZE * GPUTileProcessor.DTT_SIZE;
int [] indices = getCorrIndices(); // also sets num_corr_tiles
float [] fdata = getCorrTdData();
int num_tiles = num_corr_tiles / num_pairs;
float [][][] corr_tiles = new float [tilesY][tilesX][];
for (int nt = 0; nt < num_tiles; nt++ ) {
int nTile = (indices[nt * num_pairs] >> GPUTileProcessor.CORR_NTILE_SHIFT);
int ty = nTile / tilesX;
int tx = nTile % tilesX;
corr_tiles[ty][tx] = new float [corr_size_td];
System.arraycopy(
fdata,
(nt * num_pairs + pair) * corr_size_td,
corr_tiles[ty][tx],
0,
corr_size_td);
}
return corr_tiles;
}
public int [] setCorrTilesComboTd( public int [] setCorrTilesComboTd( // not used?
final float [][][] corr_tiles, // [tileY][tileX][4*64] final float [][][] corr_tiles, // [tileY][tileX][4*64]
int ipair) // just to set in the index low bits int ipair) // just to set in the index low bits
{ {
...@@ -3025,7 +3059,7 @@ public class GpuQuad{ // quad camera description ...@@ -3025,7 +3059,7 @@ public class GpuQuad{ // quad camera description
return indices_trim; return indices_trim;
} }
public float [][][] getCorrTilesComboTd() // [tileY][tileX][4*64] , read all available pairs public float [][][] getCorrTilesComboTd() // [tileY][tileX][4*64] , read all available pairs // not used?
{ {
int tilesX = img_width / GPUTileProcessor.DTT_SIZE; int tilesX = img_width / GPUTileProcessor.DTT_SIZE;
int tilesY = img_height / GPUTileProcessor.DTT_SIZE; int tilesY = img_height / GPUTileProcessor.DTT_SIZE;
......
...@@ -44,6 +44,7 @@ import Jama.Matrix; ...@@ -44,6 +44,7 @@ import Jama.Matrix;
import ij.ImageStack; import ij.ImageStack;
public class ImageDttCPU { public class ImageDttCPU {
static final int THREADS_MAX = 100;
static boolean FPGA_COMPARE_DATA= false; // true; // false; // static boolean FPGA_COMPARE_DATA= false; // true; // false; //
static int FPGA_SHIFT_BITS = 7; // number of bits for fractional pixel shift static int FPGA_SHIFT_BITS = 7; // number of bits for fractional pixel shift
static int FPGA_PIXEL_BITS = 15; // bits to represent pixel data (positive) static int FPGA_PIXEL_BITS = 15; // bits to represent pixel data (positive)
......
...@@ -12998,6 +12998,9 @@ public class OpticalFlow { ...@@ -12998,6 +12998,9 @@ public class OpticalFlow {
scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
float [][][][] fcorr_td = null; // no accumulation, use data in GPU float [][][][] fcorr_td = null; // no accumulation, use data in GPU
// Generate 2D phase correlations from the CLT representation
// generates sum of the per-channel correlations as the last slot.
// updates gpuQuad.gpu_corr_indices, gpuQuad.gpu_corrs_td and some other
if (mb_en && (mb_vectors!=null)) { if (mb_en && (mb_vectors!=null)) {
image_dtt.interCorrTDMotionBlur( image_dtt.interCorrTDMotionBlur(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
...@@ -13158,10 +13161,12 @@ public class OpticalFlow { ...@@ -13158,10 +13161,12 @@ public class OpticalFlow {
double scale_neibs_td = use_neibs? clt_parameters.imp.scale_neibs_td : 0; // scale threshold for the transform-domain average maximums double scale_neibs_td = use_neibs? clt_parameters.imp.scale_neibs_td : 0; // scale threshold for the transform-domain average maximums
double scale_avg_weight = clt_parameters.imp.scale_avg_weight; // reduce influence of the averaged correlations compared to the single-tile ones double scale_avg_weight = clt_parameters.imp.scale_avg_weight; // reduce influence of the averaged correlations compared to the single-tile ones
int [] corr_indices_dbg = show_2d_correlations? image_dtt.getGPU().getCorrIndices() : null;
coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
// only used here to keep extra array element for disparity difference // only used here to keep extra array element for disparity difference
use3D, // boolean use3D, // generate disparity difference use3D, // boolean use3D, // generate disparity difference
use_neibs, // boolean use_neibs,
fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
null, // float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] (or null). Can be inner null if not used in tp_tasks null, // float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] (or null). Can be inner null if not used in tp_tasks
null, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough) null, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough)
...@@ -13307,9 +13312,12 @@ public class OpticalFlow { ...@@ -13307,9 +13312,12 @@ public class OpticalFlow {
float [][][] fclt_corr1 = ImageDtt.convertFcltCorr( // partial length, matching corr_indices = gpuQuad.getCorrIndices(); // also sets num_corr_tiles float [][][] fclt_corr1 = ImageDtt.convertFcltCorr( // partial length, matching corr_indices = gpuQuad.getCorrIndices(); // also sets num_corr_tiles
dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null
if (use_neibs) {
}
float [][] dbg_corr_rslt_partial = ImageDtt.corr_partial_dbg( // not used in lwir float [][] dbg_corr_rslt_partial = ImageDtt.corr_partial_dbg( // not used in lwir
fclt_corr1, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate fclt_corr1, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
image_dtt.getGPU().getCorrIndices(), // tp_tasks, // final TpTask [] tp_tasks, // corr_indices_dbg, // image_dtt.getGPU().getCorrIndices(), // tp_tasks, // final TpTask [] tp_tasks, //
tilesX, //final int tilesX, tilesX, //final int tilesX,
tilesY, //final int tilesX, tilesY, //final int tilesX,
2*image_dtt.transform_size - 1, // final int corr_size, 2*image_dtt.transform_size - 1, // final int corr_size,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment