Commit 46612695 authored by Andrey Filippov's avatar Andrey Filippov

GPU code debugging, fixed right/bottom on dewarped images, tested

textures with LWIR
parent 78a62e6f
......@@ -127,7 +127,7 @@ public class CLTParameters {
public double min_shot = 10.0; // Do not adjust for shot noise if lower than
public double scale_shot = 3.0; // scale when dividing by sqrt
public double diff_sigma = 5.0; // RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
public double diff_sigma = 5.0; // RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image) (1.5 for RGB, 10 for LWIR?)
public double diff_threshold = 1.5; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
public boolean diff_gauss = true; // when averaging images, use Gaussian around average as weight (false - sharp all/nothing)
public double min_agree = 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
......
......@@ -88,6 +88,16 @@ public class GPUTileProcessor {
static String GPU_SET_TILES_OFFSETS = "get_tiles_offsets"; // calculate pixel offsets and disparity distortions
static String GPU_CALCULATE_TILES_OFFSETS = "calculate_tiles_offsets"; // calculate pixel offsets and disparity distortions
static String GPU_CALC_REVERSE_DISTORTION = "calcReverseDistortionTable"; // calculate reverse radial distortion table from gpu_geometry_correction
// Kernels to use w/o Dynamic Parallelism
static String GPU_CLEAR_TEXTURE_LIST_NAME = "clear_texture_list";
static String GPU_MARK_TEXTURE_LIST_NAME = "mark_texture_tiles";
static String GPU_MARK_TEXTURE_NEIGHBOR_NAME = "mark_texture_neighbor_tiles";
static String GPU_GEN_TEXTURE_LIST_NAME = "gen_texture_list";
static String GPU_CLEAR_TEXTURE_RBGA_NAME = "clear_texture_rbga";
static String GPU_TEXTURES_ACCUMULATE_NAME = "textures_accumulate";
static String GPU_CREATE_NONOVERLAP_LIST_NAME ="create_nonoverlap_list";
// pass some defines to gpu source code with #ifdef JCUDA
public static int DTT_SIZE_LOG2 = 3;
......@@ -153,9 +163,18 @@ public class GPUTileProcessor {
CUfunction GPU_TEXTURES_kernel = null; // "textures_nonoverlap"
CUfunction GPU_RBGA_kernel = null; // "generate_RBGA"
CUfunction GPU_ROT_DERIV_kernel = null; // "calc_rot_deriv"
// private CUfunction GPU_SET_TILES_OFFSETS_kernel = null; // "get_tiles_offsets"
CUfunction GPU_CALCULATE_TILES_OFFSETS_kernel = null; // "calculate_tiles_offsets"
CUfunction GPU_CALC_REVERSE_DISTORTION_kernel = null; // "calcReverseDistortionTable"
// Kernels to use w/o Dynamic Parallelism
CUfunction GPU_CLEAR_TEXTURE_LIST_kernel = null; // "clear_texture_list"
CUfunction GPU_MARK_TEXTURE_LIST_kernel = null; // "mark_texture_tiles"
CUfunction GPU_MARK_TEXTURE_NEIGHBOR_kernel = null; // "mark_texture_neighbor_tiles"
CUfunction GPU_GEN_TEXTURE_LIST_kernel = null; // "gen_texture_list"
CUfunction GPU_CLEAR_TEXTURE_RBGA_kernel = null; // "clear_texture_rbga"
CUfunction GPU_TEXTURES_ACCUMULATE_kernel = null; // "textures_accumulate"
CUfunction GPU_CREATE_NONOVERLAP_LIST_kernel = null; // "create_nonoverlap_list"
CUmodule module; // to access constants memory
// private
......@@ -295,9 +314,16 @@ public class GPUTileProcessor {
GPU_TEXTURES_NAME,
GPU_RBGA_NAME,
GPU_ROT_DERIV,
// GPU_SET_TILES_OFFSETS,
GPU_CALCULATE_TILES_OFFSETS,
GPU_CALC_REVERSE_DISTORTION
GPU_CALC_REVERSE_DISTORTION,
// Kernels to use w/o Dynamic Parallelism
GPU_CLEAR_TEXTURE_LIST_NAME,
GPU_MARK_TEXTURE_LIST_NAME,
GPU_MARK_TEXTURE_NEIGHBOR_NAME,
GPU_GEN_TEXTURE_LIST_NAME,
GPU_CLEAR_TEXTURE_RBGA_NAME,
GPU_TEXTURES_ACCUMULATE_NAME,
GPU_CREATE_NONOVERLAP_LIST_NAME
};
CUfunction[] functions = createFunctions(kernelSources,
func_names,
......@@ -311,9 +337,17 @@ public class GPUTileProcessor {
GPU_TEXTURES_kernel= functions[5];
GPU_RBGA_kernel= functions[6];
GPU_ROT_DERIV_kernel = functions[7];
// GPU_SET_TILES_OFFSETS_kernel = functions[8];
GPU_CALCULATE_TILES_OFFSETS_kernel = functions[8];
GPU_CALC_REVERSE_DISTORTION_kernel = functions[9];
// Kernels to use w/o Dynamic Parallelism
GPU_CLEAR_TEXTURE_LIST_kernel = functions[10];
GPU_MARK_TEXTURE_LIST_kernel = functions[11];
GPU_MARK_TEXTURE_NEIGHBOR_kernel = functions[12];
GPU_GEN_TEXTURE_LIST_kernel = functions[13];
GPU_CLEAR_TEXTURE_RBGA_kernel = functions[14];
GPU_TEXTURES_ACCUMULATE_kernel = functions[15];
GPU_CREATE_NONOVERLAP_LIST_kernel = functions[16];
System.out.println("GPU kernel functions initialized");
System.out.println(GPU_CONVERT_DIRECT_kernel.toString());
......@@ -324,10 +358,16 @@ public class GPUTileProcessor {
System.out.println(GPU_TEXTURES_kernel.toString());
System.out.println(GPU_RBGA_kernel.toString());
System.out.println(GPU_ROT_DERIV_kernel.toString());
// System.out.println(GPU_SET_TILES_OFFSETS_kernel.toString());
System.out.println(GPU_CALCULATE_TILES_OFFSETS_kernel.toString());
System.out.println(GPU_CALC_REVERSE_DISTORTION_kernel.toString());
// Kernels to use w/o Dynamic Parallelism
System.out.println(GPU_CLEAR_TEXTURE_LIST_kernel.toString());
System.out.println(GPU_MARK_TEXTURE_LIST_kernel.toString());
System.out.println(GPU_MARK_TEXTURE_NEIGHBOR_kernel.toString());
System.out.println(GPU_GEN_TEXTURE_LIST_kernel.toString());
System.out.println(GPU_CLEAR_TEXTURE_RBGA_kernel.toString());
System.out.println(GPU_TEXTURES_ACCUMULATE_kernel.toString());
System.out.println(GPU_CREATE_NONOVERLAP_LIST_kernel.toString());
// GPU data structures are now initialized through GpuQuad instances
}
......@@ -475,6 +515,7 @@ public class GPUTileProcessor {
for (int i = 0; i < kernelNames.length; i++) {
// Find the function in the source by name, get its pointer
functions[i] = new CUfunction();
System.out.println("Looking for GPU kernel ["+i+"]: "+kernelNames[i]);
cuModuleGetFunction(functions[i] , module, kernelNames[i]);
}
return functions;
......
......@@ -45,6 +45,7 @@ public class TpTask {
*/
public TpTask(int num_sensors, float [] flt, int task_indx, boolean use_aux)
{
this.num_sensors = num_sensors; // will not be encoded
int indx = task_indx * getSize(num_sensors);
task = Float.floatToIntBits(flt[indx++]); // 0
int txy = Float.floatToIntBits(flt[indx++]); // 1
......
......@@ -2364,7 +2364,55 @@ public class QuadCLT extends QuadCLTCPU {
debugLevel);
}
// try textures here
boolean show_textures_rgba = clt_parameters.show_rgba_color;
if (show_textures_rgba) {
float [][] texture_img = new float [isMonochrome()?2:4][];
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];
}
Rectangle woi = new Rectangle(); // will be filled out to match actual available image
gpuQuad.execRBGA(
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,
float [][] rbga = gpuQuad.getRBGA(
(isMonochrome() ? 1 : 3), // int num_colors,
woi);
for (int ncol = 0; ncol < texture_img.length; ncol++) if (ncol < rbga.length) {
texture_img[ncol] = rbga[ncol];
}
// first try just multi-layer, then with palette
(new ShowDoubleFloatArrays()).showArrays( // show slices RBGA (colors - 256, A - 1.0)
rbga,
woi.width,
woi.height,
true,
getImageName()+"-RGBA-STACK-D"+clt_parameters.disparity+
":"+clt_parameters.gpu_woi_tx+":"+clt_parameters.gpu_woi_ty+
":"+clt_parameters.gpu_woi_twidth+":"+clt_parameters.gpu_woi_theight+
":"+(clt_parameters.gpu_woi_round?"C":"R")
//,new String[] {"R","B","G","A"}
);
}
/**
if (colorProcParameters.isLwir() && colorProcParameters.lwir_autorange) {
double rel_low = colorProcParameters.lwir_low;
......
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