Commit c682d587 authored by Andrey Filippov's avatar Andrey Filippov

Tested non-overlapped texture tiles

parent 14e9c7f5
...@@ -72,6 +72,7 @@ import jcuda.nvrtc.JNvrtc; ...@@ -72,6 +72,7 @@ import jcuda.nvrtc.JNvrtc;
import jcuda.nvrtc.nvrtcProgram; import jcuda.nvrtc.nvrtcProgram;
public class GPUTileProcessor { public class GPUTileProcessor {
public static boolean USE_DS_DP = false; // Use Dynamic Shared memory with Dynamic Parallelism (not implemented)
String LIBRARY_PATH = "/usr/local/cuda/targets/x86_64-linux/lib/libcudadevrt.a"; // linux String LIBRARY_PATH = "/usr/local/cuda/targets/x86_64-linux/lib/libcudadevrt.a"; // linux
static String GPU_RESOURCE_DIR = "kernels"; static String GPU_RESOURCE_DIR = "kernels";
static String [] GPU_KERNEL_FILES = {"dtt8x8.cuh","TileProcessor.cuh"}; static String [] GPU_KERNEL_FILES = {"dtt8x8.cuh","TileProcessor.cuh"};
......
...@@ -387,8 +387,9 @@ public class ImageDtt extends ImageDttCPU { ...@@ -387,8 +387,9 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ? diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ?
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages) min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
false, // boolean calc_textures, false, // boolean calc_textures,
true); // boolean calc_extra) true, // boolean calc_extra
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
float [][] extra = gpuQuad.getExtra(); // now 4*numSensors float [][] extra = gpuQuad.getExtra(); // now 4*numSensors
// int num_cams = gpuQuad.getNumCams(); // int num_cams = gpuQuad.getNumCams();
int num_cams = getNumSensors(); int num_cams = getNumSensors();
...@@ -438,7 +439,8 @@ public class ImageDtt extends ImageDttCPU { ...@@ -438,7 +439,8 @@ public class ImageDtt extends ImageDttCPU {
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages) min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
true, // boolean calc_textures, true, // boolean calc_textures,
false); // boolean calc_extra) false, // boolean calc_extra
false); // boolean linescan_order)
int [] texture_indices = gpuQuad.getTextureIndices(); int [] texture_indices = gpuQuad.getTextureIndices();
int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate
...@@ -1251,8 +1253,9 @@ public class ImageDtt extends ImageDttCPU { ...@@ -1251,8 +1253,9 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ? diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ?
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages) min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
false, // boolean calc_textures, false, // boolean calc_textures,
true); // boolean calc_extra) true, // boolean calc_extra
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
float [][] extra = gpuQuad.getExtra(); float [][] extra = gpuQuad.getExtra();
// int num_cams = gpuQuad.getNumCams(); // int num_cams = gpuQuad.getNumCams();
int num_cams = getNumSensors(); int num_cams = getNumSensors();
...@@ -1291,7 +1294,8 @@ public class ImageDtt extends ImageDttCPU { ...@@ -1291,7 +1294,8 @@ public class ImageDtt extends ImageDttCPU {
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages) min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
true, // boolean calc_textures, true, // boolean calc_textures,
false); // boolean calc_extra) false, // boolean calc_extra
false); // boolean linescan_order)
int [] texture_indices = gpuQuad.getTextureIndices(); int [] texture_indices = gpuQuad.getTextureIndices();
int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate
......
...@@ -2409,10 +2409,167 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2409,10 +2409,167 @@ public class QuadCLT extends QuadCLTCPU {
//,new String[] {"R","B","G","A"} //,new String[] {"R","B","G","A"}
); );
}
boolean try_lores = true;
if (try_lores) {
//Generate non-overlapping (16x16) texture tiles, prepare
double [] col_weights = new double[3];
if (isMonochrome()) {
col_weights[0] = 1.0;
col_weights[1] = 0.0;
col_weights[2] = 0.0;// green color/mono
} else {
col_weights[2] = 1.0/(1.0 + clt_parameters.corr_red + clt_parameters.corr_blue); // green color
col_weights[0] = clt_parameters.corr_red * col_weights[2];
col_weights[1] = clt_parameters.corr_blue * col_weights[2];
}
gpuQuad.execTextures(
col_weights, // double [] color_weights,
isLwir(), // boolean is_lwir,
clt_parameters.min_shot, // double min_shot, // 10.0
clt_parameters.scale_shot, // double scale_shot, // 3.0
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove,
false, // boolean calc_textures,
true, // boolean calc_extra
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
float [][] extra = gpuQuad.getExtra(); // now 4*numSensors
int num_cams = getNumSensors();
(new ShowDoubleFloatArrays()).showArrays( // show slices RBGA (colors - 256, A - 1.0)
extra,
gpuQuad.img_width / GPUTileProcessor.DTT_SIZE,
gpuQuad.img_height / GPUTileProcessor.DTT_SIZE,
true,
getImageName()+"-LOW-RES"
//,new String[] {"R","B","G","A"}
);
/*
for (int ncam = 0; ncam < num_cams; ncam++) {
int indx = ncam + IMG_DIFF0_INDEX;
// if ((disparity_modes & (1 << indx)) != 0){
if (needImgDiffs(disparity_modes)){
disparity_map[indx] = new double [extra[ncam].length];
for (int i = 0; i < extra[ncam].length; i++) {
disparity_map[indx][i] = extra[ncam][i];
}
}
}
*/
for (int nc = 00; nc < (extra.length - num_cams); nc++) {
int sindx = nc + num_cams;
/*
int indx = nc + IMG_TONE_RGB;
if ((disparity_modes & (1 << indx)) != 0){
disparity_map[indx] = new double [extra[sindx].length];
for (int i = 0; i < extra[sindx].length; i++) {
disparity_map[indx][i] = extra[sindx][i];
}
}
*/
/*
int indx = nc + getImgToneRGB(); // IMG_TONE_RGB;
// if ((disparity_modes & (1 << indx)) != 0){
if (needTonesRGB(disparity_modes)){
disparity_map[indx] = new double [extra[sindx].length];
for (int i = 0; i < extra[sindx].length; i++) {
disparity_map[indx][i] = extra[sindx][i];
}
}
*/
}
boolean try_textures = true;
if (try_textures) {
//Generate non-overlapping (16x16) texture tiles, prepare
gpuQuad.execTextures(
col_weights, // double [] color_weights,
isLwir(), // boolean is_lwir,
clt_parameters.min_shot, // double min_shot, // 10.0
clt_parameters.scale_shot, // double scale_shot, // 3.0
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove,
true, // boolean calc_textures,
false, // boolean calc_extra
false); // boolean linescan_order)
int [] texture_indices = gpuQuad.getTextureIndices();
int numcol = isMonochrome()? 1 : 3;
int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate
float [] flat_textures = gpuQuad.getFlatTextures( // fatal error has been detected by the Java Runtime Environment:
texture_indices.length,
numcol, // int num_colors,
false); // clt_parameters.keep_weights); // boolean keep_weights);
int tilesX = gpuQuad.img_width / GPUTileProcessor.DTT_SIZE;
int tilesY = gpuQuad.img_height / GPUTileProcessor.DTT_SIZE;
double [][][][] texture_tiles = new double [tilesY][tilesX][][];
gpuQuad.doubleTextures(
new Rectangle(0, 0, tilesX, tilesY), // Rectangle woi,
texture_tiles, // double [][][][] texture_tiles, // null or [tilesY][tilesX]
texture_indices, // int [] indices,
flat_textures, // float [][][] ftextures,
tilesX, // int full_width,
isMonochrome()? 2: 4, // rbga only /int num_slices
num_src_slices // int num_src_slices
);
int num_out_slices = 0;
for (int nt = 0; nt < tilesY * tilesX; nt++) {
if (texture_tiles[nt / tilesX][nt % tilesX] != null) {
num_out_slices = texture_tiles[nt / tilesX][nt % tilesX].length;
break;
}
}
if (num_out_slices > 0) {
int ssize = 2*GPUTileProcessor.DTT_SIZE;
int width = tilesX * ssize;
int height = tilesY * ssize;
double [][] dbg_nonoverlap = new double[num_out_slices][width * height];
for (int slice = 0; slice < num_out_slices; slice++) {
Arrays.fill(dbg_nonoverlap[slice], Double.NaN);
}
for (int ty = 0; ty < tilesY; ty++) {
for (int tx = 0; tx < tilesX; tx++) {
if (texture_tiles[ty][tx] != null) {
for (int slice = 0; slice < num_out_slices; slice++) {
for (int row = 0; row < ssize; row++) {
System.arraycopy(
texture_tiles[ty][tx][slice],
row * ssize,
dbg_nonoverlap[slice],
(ty * ssize + row) * width + (tx * ssize),
ssize);
}
}
}
}
}
(new ShowDoubleFloatArrays()).showArrays( // show slices RBGA (colors - 256, A - 1.0)
dbg_nonoverlap,
width,
height,
true,
getImageName()+"-textures"
);
}
System.out.println("try_textures DONE");
}
} }
// try low-res and non-overlap textures
/** /**
if (colorProcParameters.isLwir() && colorProcParameters.lwir_autorange) { if (colorProcParameters.isLwir() && colorProcParameters.lwir_autorange) {
double rel_low = colorProcParameters.lwir_low; double rel_low = colorProcParameters.lwir_low;
...@@ -2700,7 +2857,9 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2700,7 +2857,9 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages) clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average clt_parameters.dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
calc_textures, // boolean calc_textures, calc_textures, // boolean calc_textures,
calc_extra); // boolean calc_extra) calc_extra, // boolean calc_extra)
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
long endTextures = System.nanoTime(); long endTextures = System.nanoTime();
// run texturesRBGA // run texturesRBGA
......
...@@ -2791,7 +2791,9 @@ __global__ void convert_correct_tiles( ...@@ -2791,7 +2791,9 @@ __global__ void convert_correct_tiles(
* @param dust_remove do not reduce average weight when only one image differs much from the average (true) * @param dust_remove do not reduce average weight when only one image differs much from the average (true)
* @param texture_stride output stride in floats (now 256*4 = 1024) * @param texture_stride output stride in floats (now 256*4 = 1024)
* @param gpu_texture_tiles output array (number of colors +1 + ?)*16*16 rgba texture tiles) float values. Will not be calculated if null * @param gpu_texture_tiles output array (number of colors +1 + ?)*16*16 rgba texture tiles) float values. Will not be calculated if null
* @param inescan_order 0 low-res tiles have tghe same order, as gpu_texture_indices, 1 - in linescan order
* @param gpu_diff_rgb_combo low-resolution output, with per-camera mismatch an each color average. Will not be calculated if null * @param gpu_diff_rgb_combo low-resolution output, with per-camera mismatch an each color average. Will not be calculated if null
* @param num_tilesx number of tiles in a row
*/ */
extern "C" __global__ void textures_nonoverlap( extern "C" __global__ void textures_nonoverlap(
int num_cams, // number of cameras int num_cams, // number of cameras
...@@ -2812,6 +2814,7 @@ extern "C" __global__ void textures_nonoverlap( ...@@ -2812,6 +2814,7 @@ extern "C" __global__ void textures_nonoverlap(
// combining both non-overlap and overlap (each calculated if pointer is not null ) // combining both non-overlap and overlap (each calculated if pointer is not null )
size_t texture_stride, // in floats (now 256*4 = 1024) size_t texture_stride, // in floats (now 256*4 = 1024)
float * gpu_texture_tiles, // (number of colors +1 + ?)*16*16 rgba texture tiles float * gpu_texture_tiles, // (number of colors +1 + ?)*16*16 rgba texture tiles
int linescan_order, // 0 low-res tiles have tghe same order, as gpu_texture_indices, 1 - in linescan order
float * gpu_diff_rgb_combo, // diff[num_cams], R[num_cams], B[num_cams],G[num_cams] float * gpu_diff_rgb_combo, // diff[num_cams], R[num_cams], B[num_cams],G[num_cams]
int num_tilesx) int num_tilesx)
// num_tilesx in the end - worked, after num_tiles - did not compile with JIT in Eclipse // num_tilesx in the end - worked, after num_tiles - did not compile with JIT in Eclipse
...@@ -2875,8 +2878,8 @@ extern "C" __global__ void textures_nonoverlap( ...@@ -2875,8 +2878,8 @@ extern "C" __global__ void textures_nonoverlap(
0, // size_t texture_rbg_stride, // in floats 0, // size_t texture_rbg_stride, // in floats
(float *) 0, // float * gpu_texture_rbg, // (number of colors +1 + ?)*16*16 rgba texture tiles (float *) 0, // float * gpu_texture_rbg, // (number of colors +1 + ?)*16*16 rgba texture tiles
texture_stride, // size_t texture_stride, // in floats (now 256*4 = 1024) texture_stride, // size_t texture_stride, // in floats (now 256*4 = 1024)
gpu_texture_tiles, //(float *)0);// float * gpu_texture_tiles); // (number of colors +1 + ?)*16*16 rgba texture tiles gpu_texture_tiles, // (float *)0);// float * gpu_texture_tiles); // (number of colors +1 + ?)*16*16 rgba texture tiles
1, // int linescan_order, // if !=0 then output gpu_diff_rgb_combo in linescan order, else - in gpu_texture_indices order linescan_order, // int linescan_order, // if !=0 then output gpu_diff_rgb_combo in linescan order, else - in gpu_texture_indices order
gpu_diff_rgb_combo, //); // float * gpu_diff_rgb_combo) // diff[num_cams], R[num_cams], B[num_cams],G[num_cams] gpu_diff_rgb_combo, //); // float * gpu_diff_rgb_combo) // diff[num_cams], R[num_cams], B[num_cams],G[num_cams]
num_tilesx); num_tilesx);
} }
......
...@@ -127,6 +127,7 @@ extern "C" __global__ void textures_nonoverlap( ...@@ -127,6 +127,7 @@ extern "C" __global__ void textures_nonoverlap(
// combining both non-overlap and overlap (each calculated if pointer is not null ) // combining both non-overlap and overlap (each calculated if pointer is not null )
size_t texture_stride, // in floats (now 256*4 = 1024) // may be 0 if not needed size_t texture_stride, // in floats (now 256*4 = 1024) // may be 0 if not needed
float * gpu_texture_tiles, // (number of colors +1 + ?)*16*16 rgba texture tiles // may be 0 if not needed float * gpu_texture_tiles, // (number of colors +1 + ?)*16*16 rgba texture tiles // may be 0 if not needed
int linescan_order, // 0 low-res tiles have tghe same order, as gpu_texture_indices, 1 - in linescan order
float * gpu_diff_rgb_combo, //); // diff[NUM_CAMS], R[NUM_CAMS], B[NUM_CAMS],G[NUM_CAMS] // may be 0 if not needed float * gpu_diff_rgb_combo, //); // diff[NUM_CAMS], R[NUM_CAMS], B[NUM_CAMS],G[NUM_CAMS] // may be 0 if not needed
int num_tilesx); int num_tilesx);
......
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