Commit ac185fe7 authored by Andrey Filippov's avatar Andrey Filippov

refactoring, combining with the GPU

parent 4a49fd62
......@@ -4906,7 +4906,7 @@ private Panel panel1,
importAux();
return;
/* ======================================================================== */
} else if (label.equals("CLT 2*4 images")) {
} else if (label.equals("CLT 2*4 images")) { // never used
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
getPairImages();
......@@ -5416,7 +5416,7 @@ private Panel panel1,
return true;
}
public boolean getPairImages() {
public boolean getPairImages() { // Never Used
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
QuadCLT.PREFIX,
......@@ -5810,10 +5810,7 @@ private Panel panel1,
if (GPU_QUAD == null) {
try {
GPU_QUAD = GPU_TILE_PROCESSOR. new GpuQuad(
2592,
1936,
164, // final int kernels_hor,
123, // final int kernels_vert,
QUAD_CLT,
4,
3);
} catch (Exception e) {
......@@ -5822,6 +5819,7 @@ private Panel panel1,
e.printStackTrace();
return false;
} //final int debugLevel);
QUAD_CLT.setGPU(GPU_QUAD);
}
// For now keep GPU_QUAD_AUX==null
......@@ -6266,6 +6264,8 @@ private Panel panel1,
public boolean batchLwir() {
long startTime=System.nanoTime();
// load needed sensor and kernels files
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
......@@ -6278,8 +6278,52 @@ private Panel panel1,
/// if (COLOR_PROC_PARAMETERS_AUX == null) {
/// COLOR_PROC_PARAMETERS_AUX = COLOR_PROC_PARAMETERS.clone();
/// }
if (CLT_PARAMETERS.useGPU()) { // only init GPU instances if it is used
if (GPU_TILE_PROCESSOR == null) {
try {
GPU_TILE_PROCESSOR = new GPUTileProcessor(CORRECTION_PARAMETERS.tile_processor_gpu);
} catch (Exception e) {
System.out.println("Failed to initialize GPU class");
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} //final int debugLevel);
}
if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
try {
GPU_QUAD = GPU_TILE_PROCESSOR.new GpuQuad(
QUAD_CLT,
4,
3);
} catch (Exception e) {
System.out.println("Failed to initialize GpuQuad class");
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} //final int debugLevel);
QUAD_CLT.setGPU(GPU_QUAD);
}
if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
try {
GPU_QUAD_AUX = GPU_TILE_PROCESSOR. new GpuQuad(//
QUAD_CLT_AUX,
4,
3);
} catch (Exception e) {
System.out.println("Failed to initialize GpuQuad class");
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} //final int debugLevel);
QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
}
}
try {
TWO_QUAD_CLT.batchLwirRig(
// GPU_QUAD, // GPUTileProcessor.GpuQuad gpuQuad_main, // may be null if GPU for MAIN is not use3d
// GPU_QUAD_AUX, // GPUTileProcessor.GpuQuad gpuQuad_aux, // may be null if GPU for AUX is not use3d
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......
......@@ -48,7 +48,8 @@ public class AlignmentCorrection {
static final int INDEX_14_DISPARITY = 0;
static final double DISP_SCALE = 2.0;
QuadCLT qc;
QuadCLT qc_gpu; // maybe will be used later?
QuadCLTCPU qc;
public class Sample{
public int series;
......@@ -265,9 +266,12 @@ public class AlignmentCorrection {
}
//System.arraycopy(dpixels, (tileY*width+tileX)*dct_size + i*width, tile_in, i*n2, n2);
AlignmentCorrection (QuadCLT qc){
AlignmentCorrection (QuadCLTCPU qc){
this.qc = qc;
}
AlignmentCorrection (QuadCLT qc){
this.qc_gpu = qc;
}
public double [][][] infinityCorrection(
final boolean use_poly,
......
......@@ -2364,7 +2364,6 @@ public class ImageDtt {
final double [][][][] clt_corr_combo, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [type][tilesY][tilesX] should be set by caller
// types: 0 - selected correlation (product+offset), 1 - sum
final double [][][][][] clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [tilesY][tilesX] should be set by caller
// When clt_mismatch is non-zero, no far objects extraction will be attempted
......@@ -2374,7 +2373,6 @@ public class ImageDtt {
final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
// last 2 - contrast, avg/ "geometric average)
final double [][][][] texture_tiles, // [tilesY][tilesX]["RGBA".length()][]; null - will skip images combining
final int width,
final double corr_fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
final boolean corr_sym,
......@@ -3230,7 +3228,7 @@ public class ImageDtt {
disparity_map[DISPARITY_INDEX_POLY] [tIndex] = lma_disparity_strength[0];
// if enabled overwrite - replace DISPARITY_INDEX_CM and DISPARITY_STRENGTH_INDEX
if (imgdtt_params.mix_corr_poly) {
if (imgdtt_params.mix_corr_poly) { //true
disp_str[0] = lma_disparity_strength[0];
disp_str[1] = lma_disparity_strength[1];
disparity_map[DISPARITY_INDEX_CM] [tIndex] = disp_str[0];
......
......@@ -30,14 +30,14 @@ import com.elphel.imagej.common.GenericJTabbedDialog;
public class ImageDttParameters {
public boolean corr_mode_debug = true;
public boolean mix_corr_poly = true;
public double min_poly_strength = 0.2;
public double min_poly_strength = 0.2; /// 0.1
public double max_poly_hwidth = 2.5; // Maximal polynomial approximation half-width (in both directions)
public double poly_corr_scale = 2.0; // Shift value if correlation maximum is wide in X than in Y to detect near objects (negative - far ones)
public double poly_corr_scale = 2.0; /// 0.0 // Shift value if correlation maximum is wide in X than in Y to detect near objects (negative - far ones)
public double poly_pwr = 1.0;
public double poly_vasw_pwr = 2.0; // raise value to this power and apply as weight (0 - disable)
public double corr_magic_scale_cm = 1.0; //0.85; // reported correlation offset vs. actual one (not yet understood)
public double corr_magic_scale_poly = 1.0; // 0.95; // reported correlation offset vs. actual one (not yet understood)
public double corr_magic_scale_cm = 1.0; /// 1.0 //0.85; // reported correlation offset vs. actual one (not yet understood)
public double corr_magic_scale_poly = 1.0; /// 1.0 // 0.95; // reported correlation offset vs. actual one (not yet understood)
public int ortho_height = 7; // height of non-zero weights for hor/vert correlation to compensate borders
public double ortho_eff_height = 2.58; // effective correlation stripe height to match strengths
......@@ -50,7 +50,7 @@ public class ImageDttParameters {
private double enhortho_scale = 0.0; // 0.2; // multiply center correlation pixels (inside enhortho_width)
private double enhortho_scale_aux = 0.0; // 0.2; // multiply center correlation pixels (inside enhortho_width)
public boolean ly_poly = false; // Use polynomial when measuring mismatch (false - use center of mass)
public double ly_crazy_poly = 1.0; // Maximal allowed mismatch difference calculated as polynomial maximum
public double ly_crazy_poly = 1.0; ///2.0 // Maximal allowed mismatch difference calculated as polynomial maximum
public boolean ly_poly_backup = true; // Use CM offset measuremets if poly failed
public boolean fo_correct = true; // correct far objects by comparing orthogonal correlations
......@@ -111,7 +111,7 @@ public class ImageDttParameters {
public double lmas_lambda_initial = 0.03; //
public double lmas_rms_diff = 0.0003; //
public int lmas_num_iter = 20; //
public int lmas_num_iter = 20; ///10
// Filtering and strength calculation
public double lmas_max_rel_rms = 0.3; // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
public double lmas_min_strength = 0.7; // minimal composite strength (sqrt(average amp squared over absolute RMS)
......@@ -141,8 +141,8 @@ public class ImageDttParameters {
public double lma_half_width = 2.0; //
public double lma_cost_wy = 0.0; // cost of parallel-to-disparity correction
public double lma_cost_wxy = 0.0; // cost of ortho-to-disparity correction
public double lma_cost_wy = 0.0; /// 0.00050 // cost of parallel-to-disparity correction
public double lma_cost_wxy = 0.0; /// 0.00100 // cost of ortho-to-disparity correction
public double lma_lambda_initial = 0.03; //
public double lma_lambda_scale_good = 0.5; //
......
This diff is collapsed.
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