Commit d74fb32e authored by Andrey Filippov's avatar Andrey Filippov

Generating files to feed to ML

parent c682d587
...@@ -745,6 +745,7 @@ private Panel panel1, ...@@ -745,6 +745,7 @@ private Panel panel1,
addButton("Batch Noise Aux", panelClt5aux, color_report); addButton("Batch Noise Aux", panelClt5aux, color_report);
addButton("Noise Stats Aux", panelClt5aux, color_process); addButton("Noise Stats Aux", panelClt5aux, color_process);
addButton("Colorize Depth", panelClt5aux, color_process); addButton("Colorize Depth", panelClt5aux, color_process);
addButton("Inter Intra ML", panelClt5aux, color_report);
plugInFrame.add(panelClt5aux); plugInFrame.add(panelClt5aux);
} }
...@@ -5325,6 +5326,13 @@ private Panel panel1, ...@@ -5325,6 +5326,13 @@ private Panel panel1,
CLT_PARAMETERS.batch_run = true; CLT_PARAMETERS.batch_run = true;
intersceneNoise(true, false, false); // boolean bayer_artifacts_debug); intersceneNoise(true, false, false); // boolean bayer_artifacts_debug);
return; return;
/* ======================================================================== */
} else if (label.equals("Inter Intra ML")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
inter_intra_export(true);
return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Batch Noise Aux")) { } else if (label.equals("Batch Noise Aux")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
...@@ -7210,11 +7218,10 @@ private Panel panel1, ...@@ -7210,11 +7218,10 @@ private Panel panel1,
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true; return true;
} }
public boolean intersceneNoise( public boolean inter_intra_export(
boolean use_aux, boolean use_aux) {
boolean batch_noise,
boolean bayer_artifacts_debug) {
long startTime=System.nanoTime(); long startTime=System.nanoTime();
// load needed sensor and kernels files // load needed sensor and kernels files
if (!prepareRigImages()) return false; if (!prepareRigImages()) return false;
...@@ -7224,7 +7231,6 @@ private Panel panel1, ...@@ -7224,7 +7231,6 @@ private Panel panel1,
if (DEBUG_LEVEL > -2){ if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Testing Interscene processing ++++++++++++++"); System.out.println("++++++++++++++ Testing Interscene processing ++++++++++++++");
} }
/*
if (CLT_PARAMETERS.useGPU()) { // only init GPU instances if it is used if (CLT_PARAMETERS.useGPU()) { // only init GPU instances if it is used
if (GPU_TILE_PROCESSOR == null) { if (GPU_TILE_PROCESSOR == null) {
try { try {
...@@ -7236,22 +7242,81 @@ private Panel panel1, ...@@ -7236,22 +7242,81 @@ private Panel panel1,
return false; return false;
} //final int debugLevel); } //final int debugLevel);
} }
if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed if (use_aux) {
try { if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is needed
GPU_QUAD = new GpuQuad( try {
GPU_TILE_PROCESSOR, QUAD_CLT, GPU_QUAD_AUX = new GpuQuad(//
4, GPU_TILE_PROCESSOR, QUAD_CLT_AUX);
3); } catch (Exception e) {
} catch (Exception e) { System.out.println("Failed to initialize GpuQuad class");
System.out.println("Failed to initialize GpuQuad class"); // TODO Auto-generated catch block
// TODO Auto-generated catch block e.printStackTrace();
e.printStackTrace(); return false;
return false; } //final int debugLevel);
} //final int debugLevel); QUAD_CLT_AUX.setGPU(GPU_QUAD_AUX);
QUAD_CLT.setGPU(GPU_QUAD); }
} else {
if (CLT_PARAMETERS.useGPU(false) && (QUAD_CLT != null) && (GPU_QUAD == null)) { // if GPU main is needed
try {
GPU_QUAD = new GpuQuad(
GPU_TILE_PROCESSOR, QUAD_CLT);
} 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);
}
} }
} }
*/ QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interIntraExportML(
quadCLT, // QuadCLT quadCLT_main,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, // EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
PROPERTIES, // Properties properties,
THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, // final boolean updateStatus,
DEBUG_LEVEL);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
System.out.println("batchRig(): Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec, --- Free memory="+
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
}
public boolean intersceneNoise(
boolean use_aux,
boolean batch_noise,
boolean bayer_artifacts_debug) {
long startTime=System.nanoTime();
// load needed sensor and kernels files
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
setAllProperties(PROPERTIES); // batchRig may save properties with the model. Extrinsics will be updated, others should be set here
if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Testing Interscene processing ++++++++++++++");
}
if (CLT_PARAMETERS.useGPU()) { // only init GPU instances if it is used if (CLT_PARAMETERS.useGPU()) { // only init GPU instances if it is used
if (GPU_TILE_PROCESSOR == null) { if (GPU_TILE_PROCESSOR == null) {
try { try {
......
...@@ -139,7 +139,7 @@ public class GPUTileProcessor { ...@@ -139,7 +139,7 @@ public class GPUTileProcessor {
public static int TASK_TEXTURE_W_BIT = 3; // Texture with West neighbor public static int TASK_TEXTURE_W_BIT = 3; // Texture with West neighbor
// public static int TASK_TEXTURE_BIT = 3; // bit to request texture calculation int task field of struct tp_task // public static int TASK_TEXTURE_BIT = 3; // bit to request texture calculation int task field of struct tp_task
public static int LIST_TEXTURE_BIT = 7; // bit to request texture calculation public static int LIST_TEXTURE_BIT = 7; // bit to request texture calculation
public static int CORR_OUT_RAD = 4; // output radius of the correlations (implemented) // public static int CORR_OUT_RAD = 4; // output radius of the correlations (implemented)
public static double FAT_ZERO_WEIGHT = 0.0001; // add to port weights to avoid nan public static double FAT_ZERO_WEIGHT = 0.0001; // add to port weights to avoid nan
public static int THREADS_DYNAMIC_BITS = 5; // treads in block for CDP creation of the texture list public static int THREADS_DYNAMIC_BITS = 5; // treads in block for CDP creation of the texture list
...@@ -225,7 +225,7 @@ public class GPUTileProcessor { ...@@ -225,7 +225,7 @@ public class GPUTileProcessor {
"#define TASK_TEXTURE_S_BIT " + TASK_TEXTURE_S_BIT+"\n"+ "#define TASK_TEXTURE_S_BIT " + TASK_TEXTURE_S_BIT+"\n"+
"#define TASK_TEXTURE_W_BIT " + TASK_TEXTURE_W_BIT+"\n"+ "#define TASK_TEXTURE_W_BIT " + TASK_TEXTURE_W_BIT+"\n"+
"#define LIST_TEXTURE_BIT " + LIST_TEXTURE_BIT+"\n"+ "#define LIST_TEXTURE_BIT " + LIST_TEXTURE_BIT+"\n"+
"#define CORR_OUT_RAD " + CORR_OUT_RAD+"\n" + // "#define CORR_OUT_RAD " + CORR_OUT_RAD+"\n" +
"#define FAT_ZERO_WEIGHT " + FAT_ZERO_WEIGHT+"\n"+ "#define FAT_ZERO_WEIGHT " + FAT_ZERO_WEIGHT+"\n"+
"#define THREADS_DYNAMIC_BITS " + THREADS_DYNAMIC_BITS+"\n"+ "#define THREADS_DYNAMIC_BITS " + THREADS_DYNAMIC_BITS+"\n"+
"#define RBYRDIST_LEN " + RBYRDIST_LEN+"\n"+ "#define RBYRDIST_LEN " + RBYRDIST_LEN+"\n"+
......
...@@ -101,6 +101,17 @@ public class Correlation2d { ...@@ -101,6 +101,17 @@ public class Correlation2d {
img_dtt.getMcorrVert (num_sensors), // boolean sel_vert); img_dtt.getMcorrVert (num_sensors), // boolean sel_vert);
img_dtt.mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14) img_dtt.mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
} }
public static int corrSelEncodeAll(int limit_sensors) { // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
return corrSelEncode(
true, // boolean sel_all,
false, // boolean sel_dia,
false, // boolean sel_sq,
false, // boolean sel_neib,
false, // boolean sel_hor,
false, // boolean sel_vert);
limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
// configuration for 8-lens and 4-lens cameras. 8-lens has baseline = 1 for 1..4 and 1/2 for 4..7 // configuration for 8-lens and 4-lens cameras. 8-lens has baseline = 1 for 1..4 and 1/2 for 4..7
...@@ -332,7 +343,26 @@ public class Correlation2d { ...@@ -332,7 +343,26 @@ public class Correlation2d {
return numSensors * (numSensors-1) /2; return numSensors * (numSensors-1) /2;
} }
public void setCorrPairs(int mcorr_sel) { public static boolean [] boolCorrPairs(int mcorr_sel, int numSensors) {
Correlation2d c2d = new Correlation2d(
numSensors, // other parameters do not matter
8,
true,
false);
return c2d.setCorrPairs(mcorr_sel);
}
public static int [] intCorrPairs(int mcorr_sel, int numSensors, int num_out) {
boolean [] boolCorrPairs = boolCorrPairs(mcorr_sel, numSensors);
int [] int_pairs = new int [num_out]; // normally 4
for (int i = 0; i < boolCorrPairs.length; i++) if (boolCorrPairs[i]){
int_pairs[i >> 5] |= 1 << (i & 31);
}
return int_pairs;
}
public boolean[] setCorrPairs(int mcorr_sel) {
boolean [] corr_calculate = null; boolean [] corr_calculate = null;
if (isCorrAll (mcorr_sel)) corr_calculate = selectAll(); if (isCorrAll (mcorr_sel)) corr_calculate = selectAll();
if (isCorrDia (mcorr_sel)) corr_calculate = selectDiameters (corr_calculate); if (isCorrDia (mcorr_sel)) corr_calculate = selectDiameters (corr_calculate);
...@@ -362,6 +392,7 @@ public class Correlation2d { ...@@ -362,6 +392,7 @@ public class Correlation2d {
//*********************************** limit pairs //*********************************** limit pairs
} }
setCorrPairs(corr_calculate); setCorrPairs(corr_calculate);
return corr_calculate;
} }
......
...@@ -2248,6 +2248,75 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2248,6 +2248,75 @@ public class QuadCLT extends QuadCLTCPU {
gpuQuad.execConvertDirect(); gpuQuad.execConvertDirect();
boolean test_execCorr2D = false; // true;
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
if (test_execCorr2D) {
int [] i_mcorr_sel = Correlation2d.intCorrPairs(
mcorr_sel,
getNumSensors(),
4); // int num_out); should be 4 int
gpuQuad.setCorrMask(i_mcorr_sel);
double fat_zero = 30.0; // 2000.0; // 30.00;
int gpu_corr_rad = 7;
int corr_size = 2* gpu_corr_rad + 1;
final int numcol = isMonochrome()?1:3;
final double [] col_weights= new double [numcol]; // colors are RBG
if (isMonochrome()) {
col_weights[0] = 1.00; // Was 0 ! 0;
} 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];
}
//Generate 2D phase correlations from the CLT representation
// Try to zero out memory before calculating?
gpuQuad.eraseGpuCorrs(); // no-diff
gpuQuad.execCorr2D(
gpuQuad.getCorrMask(), // boolean [] pair_select,
col_weights, // double [] scales,
fat_zero, // double fat_zero);
gpu_corr_rad); // int corr_radius
// Should be done before execCorr2D_TD as corr_indices are shared to save memory
int [] corr_indices = gpuQuad.getCorrIndices();
// the following is not yet shared
float [][] corr2D = gpuQuad.getCorr2D(
gpu_corr_rad); // int corr_rad);
final int tilesX=gpuQuad.getTilesX(); // width/transform_size;
final int tilesY=gpuQuad.getTilesY(); // final int tilesY=height/transform_size;
int num_tiles = tilesX * tilesY;
int sq = 16;
int num_pairs = gpuQuad.getNumUsedPairs();
float [][] corr_img = new float [num_pairs][tilesY * sq * tilesX * sq];
for (int pair = 0; pair < num_pairs; pair++) {
Arrays.fill(corr_img[pair], Float.NaN);
}
for (int ict = 0; ict < corr_indices.length; ict++){
// int ct = cpu_corr_indices[ict];
int ctt = ( corr_indices[ict] >> GPUTileProcessor.CORR_NTILE_SHIFT);
int cpair = corr_indices[ict] & ((1 << GPUTileProcessor.CORR_NTILE_SHIFT) - 1);
int ty = ctt / tilesX;
int tx = ctt % tilesX;
int dst_offs0 = (ty * sq * tilesX * sq) + (tx * sq);
for (int iy = 0; iy < corr_size; iy++){
int dst_offs = dst_offs0 + iy * (tilesX * sq);
System.arraycopy(corr2D[ict], iy * corr_size, corr_img[cpair], dst_offs, corr_size);
}
}
(new ShowDoubleFloatArrays()).showArrays( // out of boundary 15
corr_img,
tilesX * sq,
tilesY * sq,
true,
"test-corr1");
}
gpuQuad.execImcltRbgAll(is_mono); gpuQuad.execImcltRbgAll(is_mono);
// get data back from GPU // get data back from GPU
...@@ -2408,7 +2477,33 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2408,7 +2477,33 @@ public class QuadCLT extends QuadCLTCPU {
":"+(clt_parameters.gpu_woi_round?"C":"R") ":"+(clt_parameters.gpu_woi_round?"C":"R")
//,new String[] {"R","B","G","A"} //,new String[] {"R","B","G","A"}
); );
float [][] rgb_text; // = new float [(isMonochrome() ? 1 : 3)][]; // {rbga[0],rbga[1],rbga[2]};
float [][] rgba_text; // = new float [(isMonochrome() ? 2 : 4)][]; // {rbga[0],rbga[1],rbga[2],rbga[3]};
if (isMonochrome()) {
rgb_text = new float [][]{rbga[0]};
rgba_text = new float [][]{rbga[0]};
} else {
rgb_text = new float [][]{rbga[0],rbga[2],rbga[1]};
rgba_text = new float [][]{rbga[0],rbga[2],rbga[1],rbga[3]};
}
//isAux()
ImagePlus imp_rgba = linearStackToColor(
clt_parameters,
colorProcParameters,
rgbParameters,
getImageName()+"-texture", // String name,
"-D"+clt_parameters.disparity+"-"+(isAux()?"AUX":"MAIN")+ "GPU", //String suffix, // such as disparity=...
toRGB,
!correctionsParameters.jpeg, // boolean bpp16, // 16-bit per channel color mode for result
false, // true, // boolean saveShowIntermediate, // save/show if set globally
false, // true, // boolean saveShowFinal, // save/show result (color image?)
((clt_parameters.alpha1 > 0)? rgba_text: rgb_text),
woi.width, // clt_parameters.gpu_woi_twidth * image_dtt.transform_size, // tilesX * image_dtt.transform_size,
woi.height, // clt_parameters.gpu_woi_theight *image_dtt.transform_size, // tilesY * image_dtt.transform_size,
1.0, // double scaleExposure, // is it needed?
debugLevel );
imp_rgba.getProcessor().resetMinAndMax();
imp_rgba.show();
} }
boolean try_lores = true; boolean try_lores = true;
if (try_lores) { if (try_lores) {
...@@ -2824,11 +2919,15 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2824,11 +2919,15 @@ public class QuadCLT extends QuadCLTCPU {
float [][] corr2D = quadCLT_main.getGPU().getCorr2D( float [][] corr2D = quadCLT_main.getGPU().getCorr2D(
clt_parameters.gpu_corr_rad); // int corr_rad); clt_parameters.gpu_corr_rad); // int corr_rad);
// calculate correlations, keep TD // calculate correlations, keep TD
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,quadCLT_main.getNumSensors());
int [] i_mcorr_sel = Correlation2d.intCorrPairs(
mcorr_sel,
quadCLT_main.getNumSensors(),
4); // int num_out); should be 4 int
quadCLT_main.getGPU().execCorr2D_TD( quadCLT_main.getGPU().execCorr2D_TD(
scales);// double [] scales, scales,i_mcorr_sel);// double [] scales,
quadCLT_main.getGPU().execCorr2D_combine( // calculate cross pairs quadCLT_main.getGPU().execCorr2D_combine( // calculate cross pairs
true, // boolean init_corr, // initialize output tiles (false - add to current) true, // boolean init_corr, // initialize output tiles (false - add to current)
...@@ -2838,9 +2937,8 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -2838,9 +2937,8 @@ public class QuadCLT extends QuadCLTCPU {
quadCLT_main.getGPU().execCorr2D_normalize( quadCLT_main.getGPU().execCorr2D_normalize(
true, // boolean combo, // normalize combo correlations (false - per-pair ones) true, // boolean combo, // normalize combo correlations (false - per-pair ones)
fat_zero, // double fat_zero); fat_zero, // double fat_zero);
null, // float [] fcorr_weights, // null or one per correlation tile (num_corr_tiles) to divide fat zero2
clt_parameters.gpu_corr_rad); // int corr_radius clt_parameters.gpu_corr_rad); // int corr_radius
// run textures // run textures
long startTextures = System.nanoTime(); // System.nanoTime(); long startTextures = System.nanoTime(); // System.nanoTime();
boolean calc_textures = clt_parameters.gpu_show_jtextures; // true; boolean calc_textures = clt_parameters.gpu_show_jtextures; // true;
...@@ -3010,6 +3108,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -3010,6 +3108,7 @@ public class QuadCLT extends QuadCLTCPU {
quadCLT_main.getGPU().execCorr2D_normalize( quadCLT_main.getGPU().execCorr2D_normalize(
true, // boolean combo, // normalize combo correlations (false - per-pair ones) true, // boolean combo, // normalize combo correlations (false - per-pair ones)
fat_zero, // double fat_zero); fat_zero, // double fat_zero);
null, // float [] fcorr_weights, // null or one per correlation tile (num_corr_tiles) to divide fat zero2
clt_parameters.gpu_corr_rad); // int corr_radius clt_parameters.gpu_corr_rad); // int corr_radius
int [] corr_cross_indices = quadCLT_main.getGPU().getCorrComboIndices(); // get quad int [] corr_cross_indices = quadCLT_main.getGPU().getCorrComboIndices(); // get quad
...@@ -4113,6 +4212,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -4113,6 +4212,7 @@ public class QuadCLT extends QuadCLTCPU {
gpuQuad); gpuQuad);
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
TpTask[] tp_tasks = gpuQuad.setInterTasks( TpTask[] tp_tasks = gpuQuad.setInterTasks(
false, // final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
pXpYD, // final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls) pXpYD, // final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
geometryCorrection, // final GeometryCorrection geometryCorrection, geometryCorrection, // final GeometryCorrection geometryCorrection,
disparity_corr, // final double disparity_corr, disparity_corr, // final double disparity_corr,
...@@ -5010,20 +5110,14 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -5010,20 +5110,14 @@ public class QuadCLT extends QuadCLTCPU {
public void setPassAvgRBGA( // get image from a single pass, return relative path for x3d // USED in lwir public void setPassAvgRBGA( // get image from a single pass, return relative path for x3d // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
// int scanIndex,
CLTPass3d scan, CLTPass3d scan,
int threadsMax, // maximal number of threads to launch int threadsMax, // maximal number of threads to launch
boolean updateStatus, boolean updateStatus,
int debugLevel) int debugLevel)
{ {
if ((gpuQuad != null) && (isAux()?clt_parameters.gpu_use_aux : clt_parameters.gpu_use_main)) { if ((gpuQuad != null) && (isAux()?clt_parameters.gpu_use_aux : clt_parameters.gpu_use_main)) {
// CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
// final int tilesX = tp.getTilesX();
// final int tilesY = tp.getTilesY();
final int tilesX = scan.getTileProcessor().getTilesX(); final int tilesX = scan.getTileProcessor().getTilesX();
final int tilesY = scan.getTileProcessor().getTilesY(); final int tilesY = scan.getTileProcessor().getTilesY();
double [] disparity = scan.getDisparity(); double [] disparity = scan.getDisparity();
double [] strength = scan.getStrength(); double [] strength = scan.getStrength();
boolean [] selection = null; // scan.getSelected(); boolean [] selection = null; // scan.getSelected();
...@@ -5043,7 +5137,6 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -5043,7 +5137,6 @@ public class QuadCLT extends QuadCLTCPU {
scan.getDisparity()); // double [] disparity) scan.getDisparity()); // double [] disparity)
} }
scan.texture_tiles = getTextureTilesGPU( // returns texture tiles, as with CPU scan.texture_tiles = getTextureTilesGPU( // returns texture tiles, as with CPU
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
scan.tile_op, // int [][] tile_op, scan.tile_op, // int [][] tile_op,
...@@ -5764,4 +5857,26 @@ if (debugLevel < -100) { ...@@ -5764,4 +5857,26 @@ if (debugLevel < -100) {
} }
} }
public QuadCLT spawnQuadCLT(
String set_name,
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, //
int threadsMax,
int debugLevel)
{
QuadCLT quadCLT = new QuadCLT(this, set_name); //null
quadCLT.restoreFromModel(
clt_parameters,
colorProcParameters,
null, // double [] noise_sigma_level,
-1, // noise_variant, // <0 - no-variants, compatible with old code
null, // final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
threadsMax,
debugLevel);
return quadCLT;
}
} }
...@@ -272,28 +272,6 @@ public class QuadCLTCPU { ...@@ -272,28 +272,6 @@ public class QuadCLTCPU {
return quadCLT; return quadCLT;
} }
/*
public QuadCLT spawnQuadCLT(
String set_name,
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, //
int threadsMax,
int debugLevel)
{
QuadCLT quadCLT = new QuadCLT(this, set_name); //null
quadCLT.restoreFromModel(
clt_parameters,
colorProcParameters,
null, // double [] noise_sigma_level,
threadsMax,
debugLevel);
return quadCLT;
}
*/
public QuadCLTCPU spawnQuadCLT( public QuadCLTCPU spawnQuadCLT(
String set_name, String set_name,
...@@ -505,7 +483,7 @@ public class QuadCLTCPU { ...@@ -505,7 +483,7 @@ public class QuadCLTCPU {
public double [][] getDSRBG (){ public double [][] getDSRBG (){
return dsrbg; return dsrbg;
} }
public String [] getDSRGGTiltes() { public String [] getDSRGGTitles() {
return isMonochrome()? return isMonochrome()?
// (new String[]{"disparity","strength", "disparity_lma","Y"}): // (new String[]{"disparity","strength", "disparity_lma","Y"}):
// (new String[]{"disparity","strength", "disparity_lma","R","B","G"}); // (new String[]{"disparity","strength", "disparity_lma","R","B","G"});
...@@ -561,7 +539,7 @@ public class QuadCLTCPU { ...@@ -561,7 +539,7 @@ public class QuadCLTCPU {
disparity, disparity,
strength, strength,
// disparity_lma, // disparity_lma,
rbg[2]}; ((rbg.length>2)?rbg[2]:rbg[0])}; // [2] - for old compatibility, [0] - new (2021)
} else { } else {
this.dsrbg = new double[][] { this.dsrbg = new double[][] {
disparity, disparity,
...@@ -571,7 +549,7 @@ public class QuadCLTCPU { ...@@ -571,7 +549,7 @@ public class QuadCLTCPU {
} }
if (debugLevel > 1) { // -2) { if (debugLevel > 1) { // -2) {
String title = image_name+"-DSRBG"; String title = image_name+"-DSRBG";
String [] titles = getDSRGGTiltes(); String [] titles = getDSRGGTitles();
(new ShowDoubleFloatArrays()).showArrays( (new ShowDoubleFloatArrays()).showArrays(
this.dsrbg, this.dsrbg,
tp.getTilesX(), tp.getTilesX(),
...@@ -611,7 +589,7 @@ public class QuadCLTCPU { ...@@ -611,7 +589,7 @@ public class QuadCLTCPU {
// will work only with GPU // will work only with GPU
// reset bayer source, geometry correction/vector // reset bayer source, geometry correction/vector
//this.new_image_data = true; //this.new_image_data = true;
QuadCLT savedQuadClt = saveQuadClt(); QuadCLT savedQuadClt = saveQuadClt(); // does nothing with CPU
/* /*
QuadCLT savedQuadClt = gpuQuad.getQuadCLT(); QuadCLT savedQuadClt = gpuQuad.getQuadCLT();
if (savedQuadClt != this) { if (savedQuadClt != this) {
...@@ -628,8 +606,8 @@ public class QuadCLTCPU { ...@@ -628,8 +606,8 @@ public class QuadCLTCPU {
debugLevel); debugLevel);
double [][] rgba = scan.getTilesRBGA(); double [][] rgba = scan.getTilesRBGA();
if (debugLevel > -1) { // -2) { if (debugLevel > -1) { // -2) {
String title = image_name+"-RBGA"; String title = image_name+"-RBGA"; // max A = 0.00297 with LWIR
String [] titles = {"R","B","G","A"}; String [] titles = isMonochrome()? (new String [] {"Y","A"}):(new String []{"R","B","G","A"});
(new ShowDoubleFloatArrays()).showArrays( (new ShowDoubleFloatArrays()).showArrays(
rgba, rgba,
tp.getTilesX(), tp.getTilesX(),
...@@ -13890,7 +13868,7 @@ public class QuadCLTCPU { ...@@ -13890,7 +13868,7 @@ public class QuadCLTCPU {
} }
} }
} }
scan.setTilesRBGA(tileTones); scan.setTilesRBGA(tileTones); // Alpha is very low, ~1/400
if (debugLevel>10) { if (debugLevel>10) {
(new ShowDoubleFloatArrays()).showArrays( (new ShowDoubleFloatArrays()).showArrays(
tileTones, tileTones,
......
...@@ -6140,54 +6140,6 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -6140,54 +6140,6 @@ if (debugLevel > -100) return true; // temporarily !
// special treatment - make 2 bytes of one disparity value // special treatment - make 2 bytes of one disparity value
for (int tileY = 0; tileY < tilesY; tileY++) { for (int tileY = 0; tileY < tilesY; tileY++) {
for (int tileX = 0; tileX < tilesX; tileX++) { for (int tileX = 0; tileX < tilesX; tileX++) {
/*
double target_disparity = corr2d.restoreMlTilePixel(
tileX, // int tileX,
tileY, // int tileY,
ml_hwidth, // int ml_hwidth,
ml_data, // double [][] ml_data,
ImageDtt.ML_OTHER_INDEX, // int ml_layer,
ImageDtt.ML_OTHER_TARGET , // int ml_index,
tilesX); // int tilesX);
double gtruth_disparity = corr2d.restoreMlTilePixel(
tileX, // int tileX,
tileY, // int tileY,
ml_hwidth, // int ml_hwidth,
ml_data, // double [][] ml_data,
ImageDtt.ML_OTHER_INDEX, // int ml_layer,
ImageDtt.ML_OTHER_GTRUTH , // int ml_index,
tilesX); // int tilesX);
double gtruth_strength = corr2d.restoreMlTilePixel(
tileX, // int tileX,
tileY, // int tileY,
ml_hwidth, // int ml_hwidth,
ml_data, // double [][] ml_data,
ImageDtt.ML_OTHER_INDEX, // int ml_layer,
ImageDtt.ML_OTHER_GTRUTH_STRENGTH , // int ml_index,
tilesX); // int tilesX);
// converting disparity to 9.7 ( 1/128 pixel step, +/-256 pixels disparity range), 0x8000 - zero disparity
// converting strength to 2 bytes 0.16 fixed point
int itd = (int) Math.round(128 * target_disparity) + 0x8000;
int [] itarget_disparity = {itd >> 8, itd & 0xff};
int igt = (int) Math.round(128 * gtruth_disparity) + 0x8000;
int [] igtruth_disparity = {igt >> 8, igt & 0xff};
int igs = (int) Math.round(0x10000 * gtruth_strength);
int [] igtruth_strength = {igs >> 8, igs & 0xff};
for (int nb = 0; nb<2; nb++) {
if (!Double.isNaN(target_disparity)) {
int indx = corr2d.getMlTilePixelIndex(tileX,tileY, ml_hwidth, ImageDtt.ML_OTHER_TARGET + nb, tilesX);
iml_data[nl][indx] = (byte) itarget_disparity[nb];
}
if (!Double.isNaN(gtruth_disparity)) {
int indx = corr2d.getMlTilePixelIndex(tileX,tileY, ml_hwidth, ImageDtt.ML_OTHER_GTRUTH + nb, tilesX);
iml_data[nl][indx] = (byte) igtruth_disparity[nb];
}
if (gtruth_strength > 0.0) {
int indx = corr2d.getMlTilePixelIndex(tileX,tileY, ml_hwidth, ImageDtt.ML_OTHER_GTRUTH_STRENGTH + nb, tilesX);
iml_data[nl][indx] = (byte) igtruth_strength[nb];
}
}
*/
for (int data:signed_data) if (aux_mode || (data <= ImageDtt.ML_OTHER_GTRUTH_STRENGTH)) { for (int data:signed_data) if (aux_mode || (data <= ImageDtt.ML_OTHER_GTRUTH_STRENGTH)) {
double d = corr2d.restoreMlTilePixel( double d = corr2d.restoreMlTilePixel(
tileX, // int tileX, tileX, // int tileX,
...@@ -8986,6 +8938,121 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8986,6 +8938,121 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
public void interIntraExportML(
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
Properties properties,
// boolean bayer_artifacts_debug,
// int noise_variant, // <0 - no-variants, compatible with old code
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) throws Exception
{
// TODO:remove
boolean bayer_artifacts_debug = false;
int noise_variant = -1; // <0 - no-variants, compatible with old code
NoiseParameters noise_sigma_level = null;
if ((clt_parameters.inp.noise.scale_random >= 0.0) || (clt_parameters.inp.noise.scale_fpn >= 0.0)) {// <0 - will generate no-noise data
if (quadCLT_main.getNumSensors() == 16) {
switch (clt_parameters.img_dtt.mcorr_limit_sensors) {
case 0:
clt_parameters.inp.noise.used_sensors = 16;
break;
case 1:
clt_parameters.inp.noise.used_sensors = 2;
break;
case 2:
clt_parameters.inp.noise.used_sensors = 4;
break;
case 3:
clt_parameters.inp.noise.used_sensors = 8;
break;
}
System.out.println ("Using "+clt_parameters.inp.noise.used_sensors+" of "+quadCLT_main.getNumSensors()+" sensors.");
}
noise_sigma_level = clt_parameters.inp.noise.clone();
}
boolean ref_only = clt_parameters.inp.ref_only; // true; // process only reference frame (false - inter-scene)
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) {
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
}
// final boolean batch_mode = clt_parameters.batch_run;
this.startTime=System.nanoTime();
String [] sourceFiles0=quadCLT_main.correctionsParameters.getSourcePaths();
QuadCLT.SetChannels [] set_channels_main = quadCLT_main.setChannels(debugLevel);
if ((set_channels_main == null) || (set_channels_main.length==0)) {
System.out.println("No files to process (of "+sourceFiles0.length+")");
return;
}
QuadCLT.SetChannels [] set_channels=quadCLT_main.setChannels(debugLevel); // TODO: use just the last one (to need this is no time)
QuadCLT ref_quadCLT = quadCLT_main.spawnQuadCLT(
set_channels[set_channels.length-1].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
clt_parameters.inp.noise_debug_level); // debugLevel);
// temporarily fix wrong sign:
// ErsCorrection ers = (ErsCorrection) (ref_quadCLT.getGeometryCorrection());
ref_quadCLT.setDSRBG( // runs GPU to calculate average R,B,G
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
clt_parameters.inp.noise_debug_level); // debugLevel); // int debugLevel)
// if (debugLevel > -1000) return; // TODO: Remove
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus);
ErsCorrection ers_reference = ref_quadCLT.getErsCorrection();
String [] sts = ref_only ? (new String [0]) : ers_reference.getScenes();
// get list of all other scenes
int num_scenes = sts.length + 1;
int indx_ref = num_scenes - 1;
QuadCLT [] scenes = new QuadCLT [num_scenes];
scenes[indx_ref] = ref_quadCLT;
for (int i = 0; i < sts.length; i++) {
scenes[i] = ref_quadCLT.spawnQuadCLT( // spawnQuadCLT(
sts[i],
clt_parameters,
colorProcParameters, //
threadsMax,
-1); // debug_level);
scenes[i].setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
-1); // debug_level); // int debugLevel)
}
opticalFlow.intersceneExport(
clt_parameters, // CLTParameters clt_parameters,
ers_reference, // ErsCorrection ers_reference,
scenes, // QuadCLT [] scenes,
indx_ref, // int indx_ref,
colorProcParameters, // ColorProcParameters colorProcParameters,
ref_quadCLT, // QuadCLT ref_scene, // ordered by increasing timestamps
clt_parameters.inp.noise_debug_level // clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
);
System.out.println("End of intersceneNoise()");
}
public void intersceneNoise( public void intersceneNoise(
QuadCLT quadCLT_main, // tiles should be set QuadCLT quadCLT_main, // tiles should be set
......
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