...
 
Commits (4)
......@@ -119,6 +119,21 @@
<version>1.7.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-numbers-quaternion -->
<!--
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-numbers-quaternion</artifactId>
<version>1.0-beta1</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
<build>
......
......@@ -88,6 +88,7 @@ import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.readers.EyesisTiff;
import com.elphel.imagej.tensorflow.TensorflowInferModel;
import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.ErsCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.MLStats;
import com.elphel.imagej.tileprocessor.QuadCLT;
......@@ -631,6 +632,7 @@ private Panel panel1,
addButton("CLT disparity scan", panelClt2, color_conf_process);
addButton("CLT reset fine corr", panelClt2, color_stop);
addButton("CLT reset extrinsic corr", panelClt2, color_stop);
addButton("ERS reset", panelClt2, color_stop);
addButton("CLT show geometry", panelClt2, color_configure);
addButton("CLT show fine corr", panelClt2, color_report);
addButton("CLT apply fine corr", panelClt2, color_process);
......@@ -711,11 +713,14 @@ private Panel panel1,
addButton("LWIR_TEST", panelClt_GPU, color_conf_process);
addButton("LWIR_ACQUIRE", panelClt_GPU, color_conf_process);
addButton("ERS reset", panelClt2, color_stop);
addButton("IMU main", panelClt_GPU, color_conf_process);
addButton("ERS main", panelClt_GPU, color_process);
addButton("IMU aux", panelClt_GPU, color_conf_process_aux);
addButton("ERS aux", panelClt_GPU, color_process_aux);
addButton("Rotations_test", panelClt_GPU, color_stop);
plugInFrame.add(panelClt_GPU);
}
if (LWIR_MODE) {
......@@ -4559,6 +4564,21 @@ private Panel panel1,
}
QUAD_CLT.resetExtrinsicCorr(CLT_PARAMETERS);
return;
} else if (label.equals("ERS reset")) {
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
QuadCLT.PREFIX,
PROPERTIES,
EYESIS_CORRECTIONS,
CORRECTION_PARAMETERS);
if (DEBUG_LEVEL > 0){
System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
}
}
QUAD_CLT.resetExtrinsicCorr(CLT_PARAMETERS);
return;
} else if (label.equals("CLT show geometry")) {
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
......@@ -4993,6 +5013,9 @@ private Panel panel1,
} else if (label.equals("LIST extrinsics")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (EYESIS_CORRECTIONS_AUX == null) {
EYESIS_CORRECTIONS_AUX = new EyesisCorrections(SYNC_COMMAND.stopRequested,CORRECTION_PARAMETERS.getAux());
}
listExtrinsics();
return;
/* ======================================================================== */
......@@ -5173,7 +5196,9 @@ private Panel panel1,
/// imp.show();
/// }
}
/* ======================================================================== */
} else if (label.equals("Rotations_test")) {
ErsCorrection.test_rotations();
//JTabbedTest
// End of buttons code
}
......@@ -6514,7 +6539,10 @@ private Panel panel1,
if (dir!=null) {
System.out.println("top directory = "+dir);
}
return MLStats.listExtrinsics(dir); // , mask);
return MLStats.listExtrinsics(
dir, // ); // , mask);
EYESIS_CORRECTIONS,
EYESIS_CORRECTIONS_AUX);
}
public boolean mlRecalc() {
......
......@@ -106,6 +106,7 @@ public class GPUTileProcessor {
static String GPU_RBGA_NAME = "generate_RBGA"; // name in C code
static String GPU_ROT_DERIV = "calc_rot_deriv"; // calculate rotation matrices and derivatives
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
// pass some defines to gpu source code with #ifdef JCUDA
......@@ -168,7 +169,8 @@ public class GPUTileProcessor {
private CUfunction GPU_TEXTURES_kernel = null;
private CUfunction GPU_RBGA_kernel = null;
private CUfunction GPU_ROT_DERIV_kernel = null;
private CUfunction GPU_SET_TILES_OFFSETS_kernel = null;
// private CUfunction GPU_SET_TILES_OFFSETS_kernel = null;
private CUfunction GPU_CALCULATE_TILES_OFFSETS_kernel = null;
private CUfunction GPU_CALC_REVERSE_DISTORTION_kernel = null;
CUmodule module; // to access constants memory
......@@ -393,7 +395,8 @@ public class GPUTileProcessor {
GPU_TEXTURES_NAME,
GPU_RBGA_NAME,
GPU_ROT_DERIV,
GPU_SET_TILES_OFFSETS,
// GPU_SET_TILES_OFFSETS,
GPU_CALCULATE_TILES_OFFSETS,
GPU_CALC_REVERSE_DISTORTION
};
CUfunction[] functions = createFunctions(kernelSources,
......@@ -408,7 +411,8 @@ 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_SET_TILES_OFFSETS_kernel = functions[8];
GPU_CALCULATE_TILES_OFFSETS_kernel = functions[8];
GPU_CALC_REVERSE_DISTORTION_kernel = functions[9];
System.out.println("GPU kernel functions initialized");
......@@ -420,7 +424,8 @@ 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_SET_TILES_OFFSETS_kernel.toString());
System.out.println(GPU_CALCULATE_TILES_OFFSETS_kernel.toString());
System.out.println(GPU_CALC_REVERSE_DISTORTION_kernel.toString());
// GPU data structures are now initialized through GpuQuad instances
......@@ -1603,7 +1608,8 @@ public class GPUTileProcessor {
/**
* Calculate tiles offsets (before each direct conversion run)
*/
public void execSetTilesOffsets() {
/*
public void execSetTilesOffsetsOld() {
execCalcReverseDistortions(); // will check if it is needed first
execRotDerivs(); // will check if it is needed first
if (GPU_SET_TILES_OFFSETS_kernel == null)
......@@ -1612,7 +1618,7 @@ public class GPUTileProcessor {
return;
}
// kernel parameters: pointer to pointers
int [] GridFullWarps = {(num_task_tiles + TILES_PER_BLOCK_GEOM - 1)/TILES_PER_BLOCK_GEOM, 1, 1}; // round up
int [] GridFullWarps = {(num_task_tiles + 2 * TILES_PER_BLOCK_GEOM - 1)/TILES_PER_BLOCK_GEOM, 1, 1}; // round up
int [] ThreadsFullWarps = {num_cams, TILES_PER_BLOCK_GEOM, 1}; // 4,8,1
Pointer kernelParameters = Pointer.to(
Pointer.to(gpu_tasks), // struct tp_task * gpu_tasks,
......@@ -1632,6 +1638,35 @@ public class GPUTileProcessor {
System.out.println("======execSetTilesOffsets()");
}
}
*/
public void execSetTilesOffsets() {
execCalcReverseDistortions(); // will check if it is needed first
execRotDerivs(); // will check if it is needed first
if (GPU_CALCULATE_TILES_OFFSETS_kernel == null)
{
IJ.showMessage("Error", "No GPU kernel: GPU_CALCULATE_TILES_OFFSETS_kernel");
return;
}
int [] GridFullWarps = {1, 1, 1};
int [] ThreadsFullWarps = {1, 1, 1}; // 4,8,1
Pointer kernelParameters = Pointer.to(
Pointer.to(gpu_tasks), // struct tp_task * gpu_tasks,
Pointer.to(new int[] { num_task_tiles }),// int num_tiles, // number of tiles in task list
Pointer.to(gpu_geometry_correction), // struct gc * gpu_geometry_correction,
Pointer.to(gpu_correction_vector), // struct corr_vector * gpu_correction_vector,
Pointer.to(gpu_rByRDist), // float * gpu_rByRDist) // length should match RBYRDIST_LEN
Pointer.to(gpu_rot_deriv)); // trot_deriv * gpu_rot_deriv);
cuCtxSynchronize();
cuLaunchKernel(GPU_CALCULATE_TILES_OFFSETS_kernel,
GridFullWarps[0], GridFullWarps[1], GridFullWarps[2], // Grid dimension
ThreadsFullWarps[0], ThreadsFullWarps[1],ThreadsFullWarps[2],// Block dimension
0, null, // Shared memory size and stream (shared - only dynamic, static is in code)
kernelParameters, null); // Kernel- and extra parameters
cuCtxSynchronize(); // remove later
if (gpu_debug_level > -1) {
System.out.println("======execSetTilesOffsets(), num_task_tiles="+num_task_tiles);
}
}
/**
* Direct CLT conversion and aberration correction
......
......@@ -1460,10 +1460,12 @@ public class Corr2dLMA {
return rslt;
}
public double [][] lmaDisparityStrength(
public double [][] lmaDisparityStrength1( // restored from git
double lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
double lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
double lma_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
double lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
double lma_max_area, // maximal half-area (if > 0.0)
double lma_str_scale, // convert lma-generated strength to match previous ones - scale
double lma_str_offset // convert lma-generated strength to match previous ones - add to result
......@@ -1506,6 +1508,179 @@ public class Corr2dLMA {
return ds;
}
public double [][] lmaDisparityStrength(
double lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
double lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
double lma_min_max_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
double lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
double lma_max_area, // maximal half-area (if > 0.0)
double lma_str_scale, // convert lma-generated strength to match previous ones - scale
double lma_str_offset // convert lma-generated strength to match previous ones - add to result
){
double [][] ds = new double[numTiles][2];
double [] rms = getRmsTile();
double [][] maxmin_amp = getMaxMinAmpTile();
double [][] abc = getABCTile();
for (int tile = 0; tile < numTiles; tile++) {
ds[tile][0] = Double.NaN;
if (Double.isNaN(maxmin_amp[tile][0])) {
continue;
}
double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
double rrms = rms[tile]/avg;
if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac)
// || (Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)
) {
continue;
}
if (lma_max_area > 0) {
if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
// double area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
double area = 1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
if (area > lma_max_area) {
continue; // too wide maximum
}
} else {
continue; // not a maximum
}
}
double strength = Math.sqrt(avg/rrms);
double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
continue;
}
strength = Math.sqrt(strength * Math.sqrt(abc[tile][0] * abc[tile][2])); // / area ); // new strength
ds[tile][0] = disparity;
ds[tile][1] = (strength * lma_str_scale) + lma_str_offset;
}
return ds;
}
public double [][] lmaDisparityStrengthLY(
double lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
double lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
double lma_min_max_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
double lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
double lma_max_area, // maximal half-area (if > 0.0)
double lma_str_scale, // convert lma-generated strength to match previous ones - scale
double lma_str_offset // convert lma-generated strength to match previous ones - add to result
){
double [][] ds = new double[numTiles][2];
double [] rms = getRmsTile();
double [][] maxmin_amp = getMaxMinAmpTile();
double [][] abc = getABCTile();
for (int tile = 0; tile < numTiles; tile++) {
ds[tile][0] = Double.NaN;
if (Double.isNaN(maxmin_amp[tile][0])) {
continue;
}
double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
double rrms = rms[tile]/avg;
if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac) ||
(Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)) {
continue;
}
if (lma_max_area > 0) {
if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
// double area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
double area = 1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
if (area > lma_max_area) {
continue; // too wide maximum
}
} else {
continue; // not a maximum
}
}
double strength = Math.sqrt(avg/rrms);
double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
continue;
}
strength = Math.sqrt(strength * Math.sqrt(abc[tile][0] * abc[tile][2])); // / area ); // new strength
ds[tile][0] = disparity;
ds[tile][1] = (strength * lma_str_scale) + lma_str_offset;
}
return ds;
}
public double [][] lmaGetExtendedStats(
double lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
double lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
double lma_min_max_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
double lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
double lma_max_area, // maximal half-area (if > 0.0)
double lma_str_scale, // convert lma-generated strength to match previous ones - scale
double lma_str_offset // convert lma-generated strength to match previous ones - add to result
){
// double [][] ds = new double[numTiles][2];
double [][] ext_stats = new double[numTiles][11];
double [] rms = getRmsTile();
double [][] maxmin_amp = getMaxMinAmpTile();
double [][] abc = getABCTile();
for (int tile = 0; tile < numTiles; tile++) {
if (Double.isNaN(maxmin_amp[tile][0])) {
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 1;
}
ext_stats[tile][0] = maxmin_amp[tile][0];
double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
double rrms = rms[tile]/avg;
ext_stats[tile][1] = avg;
ext_stats[tile][2] = rrms; // -lma_max_rel_rms;
// ext_stats[tile][3] = Math.max(abc[tile][0], abc[tile][2])-lma_min_ac;
if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac) ||
(Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)) {
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 2;
// continue;
}
double area = Double.NaN;
double area_old = Double.NaN;
if (lma_max_area > 0) {
ext_stats[tile][5] = abc[tile][0];
ext_stats[tile][6] = abc[tile][2];
if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
area = 1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
if (area > lma_max_area) {
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 3;
// continue; // too wide maximum
}
} else {
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 4;
// continue; // not a maximum
}
ext_stats[tile][7] = 1.0/area; // area-lma_max_area;
ext_stats[tile][4] = 1.0/area_old;
}
double strength = Math.sqrt(avg/rrms);
ext_stats[tile][9] = (strength * lma_str_scale) + lma_str_offset;
ext_stats[tile][3] = Math.sqrt(strength / area ); // new strength
double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 5;
continue;
}
ext_stats[tile][8] = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 6;
}
return ext_stats;
}
// ext_stats[tile][3] = Math.max(abc[tile][0], abc[tile][2])-lma_min_ac;
public double [][] getDdNd(){ // this.all_pars should be current
double [][] ddnd = new double [NUM_CAMS][2];
for (int nc = 0; nc < NUM_CAMS; nc++) {
......
......@@ -2449,7 +2449,8 @@ public class Correlation2d {
imgdtt_params.lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lma_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset // convert lma-generated strength to match previous ones - add to result
);
......@@ -2547,6 +2548,7 @@ public class Correlation2d {
imgdtt_params.lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lma_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset // convert lma-generated strength to match previous ones - add to result
......@@ -2842,6 +2844,7 @@ public class Correlation2d {
imgdtt_params.lmas_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lmas_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lmas_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lmas_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset // convert lma-generated strength to match previous ones - add to result
......
......@@ -2151,6 +2151,7 @@ public class ImageDttCPU {
imgdtt_params.lmas_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lmas_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lmas_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lmas_max_area, // double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset // convert lma-generated strength to match previous ones - add to result
......@@ -2202,6 +2203,7 @@ public class ImageDttCPU {
imgdtt_params.lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lma_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
1.0, // imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
0.0); // imgdtt_params.lma_str_offset); // convert lma-generated strength to match previous ones - add to result
......@@ -2269,6 +2271,7 @@ public class ImageDttCPU {
imgdtt_params.lma_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lma_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset); // convert lma-generated strength to match previous ones - add to result
......@@ -3343,6 +3346,7 @@ public class ImageDttCPU {
imgdtt_params.lmas_max_rel_rms, // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lmas_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lmas_min_ac, // minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lmas_min_min_ac, // minimal of A and C coefficients minimum (measures sharpest point)
imgdtt_params.lmas_max_area, //double lma_max_area, // maximal half-area (if > 0.0)
imgdtt_params.lma_str_scale, // convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset // convert lma-generated strength to match previous ones - add to result
......
......@@ -128,6 +128,7 @@ public class ImageDttParameters {
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)
public double lmas_min_ac = 0.02; // minimal of a and C coefficients maximum (measures sharpest point/line)
public double lmas_min_min_ac = 0.007; // minimal of a and C coefficients minimum (measures sharpest point)
public double lmas_max_area = 0.0; // maximal half-area (if > 0.0)
public boolean lma_gaussian = false; // model correlation maximum as a Gaussian (false - as a parabola)
......@@ -163,10 +164,11 @@ public class ImageDttParameters {
public double lma_rms_diff = 0.003; //
public int lma_num_iter = 10; //
// Filtering and strength calculation
public double lma_max_rel_rms = 0.2; // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
public double lma_min_strength = 1.0; // minimal composite strength (sqrt(average amp squared over absolute RMS)
public double lma_max_rel_rms = 0.25; // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
public double lma_min_strength = 1.0; // minimal composite strength (sqrt(average amp squared over absolute RMS)
public double lma_min_ac = 0.05; // minimal of a and C coefficients maximum (measures sharpest point/line)
public double lma_max_area = 45.0; // maximal half-area (if > 0.0)
public double lma_min_min_ac = 0.015; // minimal of a and C coefficients minimum (measures sharpest point)
public double lma_max_area = 30.0; //45.0; // maximal half-area (if > 0.0)
public double lma_str_scale = 0.2; // convert lma-generated strength to match previous ones - scale
public double lma_str_offset = 0.05; // convert lma-generated strength to match previous ones - add to result
......@@ -388,6 +390,8 @@ public class ImageDttParameters {
"Discard tile if composite strength (average amplitude over SQRT of RMS) is below");
gd.addNumericField("Minimal max (A,C)", this.lmas_min_ac, 6, 8, "",
"Minimal value of max (A,C) coefficients to keep the tile (measures sharpest point/line correlation maximum)");
gd.addNumericField("Minimal min (A,C)", this.lmas_min_min_ac, 6, 8, "",
"Minimal value of min (A,C) coefficients to keep the tile (measures sharpest point correlation maximum)");
gd.addNumericField("Maximal area", this.lmas_max_area, 6, 8, "sq.pix",
"Maximal product of maximum half-width by half-height, ignore check if <=0");
......@@ -453,6 +457,8 @@ public class ImageDttParameters {
"Discard tile if composite strength (average amplitude over SQRT of RMS) is below");
gd.addNumericField("Minimal max (A,C)", this.lma_min_ac, 6, 8, "",
"Minimal value of max (A,C) coefficients to keep the tile (measures sharpest point/line correlation maximum)");
gd.addNumericField("Minimal min (A,C)", this.lma_min_min_ac, 6, 8, "",
"Minimal value of min (A,C) coefficients to keep the tile (measures sharpest point correlation maximum)");
gd.addNumericField("Maximal area", this.lma_max_area, 6, 8, "sq.pix",
"Maximal product of maximum half-width by half-height, ignore check if <=0");
......@@ -605,6 +611,7 @@ public class ImageDttParameters {
this.lmas_max_rel_rms = gd.getNextNumber();
this.lmas_min_strength = gd.getNextNumber();
this.lmas_min_ac = gd.getNextNumber();
this.lmas_min_min_ac = gd.getNextNumber();
this.lmas_max_area = gd.getNextNumber();
this.lma_gaussian= gd.getNextBoolean();
......@@ -638,6 +645,7 @@ public class ImageDttParameters {
this.lma_max_rel_rms = gd.getNextNumber();
this.lma_min_strength = gd.getNextNumber();
this.lma_min_ac = gd.getNextNumber();
this.lma_min_min_ac = gd.getNextNumber();
this.lma_max_area = gd.getNextNumber();
this.lma_str_scale = gd.getNextNumber();
......@@ -754,6 +762,7 @@ public class ImageDttParameters {
properties.setProperty(prefix+"lmas_max_rel_rms", this.lmas_max_rel_rms +"");
properties.setProperty(prefix+"lmas_min_strength", this.lmas_min_strength +"");
properties.setProperty(prefix+"lmas_min_ac", this.lmas_min_ac +"");
properties.setProperty(prefix+"lmas_min_min_ac", this.lmas_min_min_ac +"");
properties.setProperty(prefix+"lmas_max_area", this.lmas_max_area +"");
properties.setProperty(prefix+"lma_gaussian", this.lma_gaussian +"");
......@@ -788,6 +797,7 @@ public class ImageDttParameters {
properties.setProperty(prefix+"lma_max_rel_rms", this.lma_max_rel_rms +"");
properties.setProperty(prefix+"lma_min_strength", this.lma_min_strength +"");
properties.setProperty(prefix+"lma_min_ac", this.lma_min_ac +"");
properties.setProperty(prefix+"lma_min_min_ac", this.lma_min_min_ac +"");
properties.setProperty(prefix+"lma_max_area", this.lma_max_area +"");
properties.setProperty(prefix+"lma_str_scale", this.lma_str_scale +"");
properties.setProperty(prefix+"lma_str_offset", this.lma_str_offset +"");
......@@ -909,6 +919,7 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"lmas_max_rel_rms")!=null) this.lmas_max_rel_rms=Double.parseDouble(properties.getProperty(prefix+"lmas_max_rel_rms"));
if (properties.getProperty(prefix+"lmas_min_strength")!=null) this.lmas_min_strength=Double.parseDouble(properties.getProperty(prefix+"lmas_min_strength"));
if (properties.getProperty(prefix+"lmas_min_ac")!=null) this.lmas_min_ac=Double.parseDouble(properties.getProperty(prefix+"lmas_min_ac"));
if (properties.getProperty(prefix+"lmas_min_min_ac")!=null) this.lmas_min_min_ac=Double.parseDouble(properties.getProperty(prefix+"lmas_min_min_ac"));
if (properties.getProperty(prefix+"lmas_max_area")!=null) this.lmas_max_area=Double.parseDouble(properties.getProperty(prefix+"lmas_max_area"));
if (properties.getProperty(prefix+"lma_gaussian")!=null) this.lma_gaussian=Boolean.parseBoolean(properties.getProperty(prefix+"lma_gaussian"));
......@@ -941,6 +952,7 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"lma_max_rel_rms")!=null) this.lma_max_rel_rms=Double.parseDouble(properties.getProperty(prefix+"lma_max_rel_rms"));
if (properties.getProperty(prefix+"lma_min_strength")!=null) this.lma_min_strength=Double.parseDouble(properties.getProperty(prefix+"lma_min_strength"));
if (properties.getProperty(prefix+"lma_min_ac")!=null) this.lma_min_ac=Double.parseDouble(properties.getProperty(prefix+"lma_min_ac"));
if (properties.getProperty(prefix+"lma_min_min_ac")!=null) this.lma_min_min_ac=Double.parseDouble(properties.getProperty(prefix+"lma_min_min_ac"));
if (properties.getProperty(prefix+"lma_max_area")!=null) this.lma_max_area=Double.parseDouble(properties.getProperty(prefix+"lma_max_area"));
if (properties.getProperty(prefix+"lma_str_scale")!=null) this.lma_str_scale=Double.parseDouble(properties.getProperty(prefix+"lma_str_scale"));
if (properties.getProperty(prefix+"lma_str_offset")!=null) this.lma_str_offset=Double.parseDouble(properties.getProperty(prefix+"lma_str_offset"));
......@@ -1059,6 +1071,7 @@ public class ImageDttParameters {
idp.lmas_max_rel_rms= this.lmas_max_rel_rms;
idp.lmas_min_strength= this.lmas_min_strength;
idp.lmas_min_ac= this.lmas_min_ac;
idp.lmas_min_min_ac= this.lmas_min_min_ac;
idp.lmas_max_area= this.lmas_max_area;
idp.lma_gaussian = this.lma_gaussian;
......@@ -1091,6 +1104,7 @@ public class ImageDttParameters {
idp.lma_max_rel_rms= this.lma_max_rel_rms;
idp.lma_min_strength= this.lma_min_strength;
idp.lma_min_ac= this.lma_min_ac;
idp.lma_min_min_ac= this.lma_min_min_ac;
idp.lma_max_area= this.lma_max_area;
idp.lma_str_scale= this.lma_str_scale;
idp.lma_str_offset= this.lma_str_offset;
......
......@@ -48,6 +48,7 @@ import com.elphel.imagej.gpu.GPUTileProcessor;
import ij.ImagePlus;
import ij.ImageStack;
public class QuadCLT extends QuadCLTCPU {
int dbg_lev = 1;
private GPUTileProcessor.GpuQuad gpuQuad = null;
public QuadCLT(
String prefix,
......@@ -2314,11 +2315,12 @@ public class QuadCLT extends QuadCLTCPU {
threadsMax,
debugLevel - 2);
} else {// GPU
// First - measure and get fcorr_td, fdisp_dist, fpxpy
// First - measure and get fcorr_td, fdisp_dist, fpxpy
float [][][][] fcorr_td = new float[tilesY][tilesX][][];
float [][][][] fdisp_dist = new float[tilesY][tilesX][][];
float [][][][] fpxpy = new float[tilesY][tilesX][][];
final double gpu_fat_zero = clt_parameters.getGpuFatZero(isMonochrome());
image_dtt.clt_aberrations_quad_corr_GPU( // USED in LWIR
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
......@@ -2326,21 +2328,21 @@ public class QuadCLT extends QuadCLTCPU {
disparity_array, // clt_parameters.disparity, // final double disparity,
fcorr_td, // final float [][][][] corr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs
null, // final float [][][][] corr_combo_td, // [4][tilesY][tilesX][pair][4*64] TD of combo corrs: qud, cross, hor,vert
// each of the top elements may be null to skip particular combo type
// each of the top elements may be null to skip particular combo type
fdisp_dist, // final float [][][][] fdisp_dist, // [tilesY][tilesX][cams][4], // disparity derivatives vectors or null
fpxpy, // final float [][][][] fpxpy, // [tilesY][tilesX][cams][2], tile {pX,pY}
//// Uses quadCLT from gpuQuad
// correlation results - final and partial
// correlation results - final and partial
null, // [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
// [type][tilesY][tilesX] should be set by caller
// types: 0 - selected correlation (product+offset), 1 - sum
null, // 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
// [tilesY][tilesX] should be set by caller
// When clt_mismatch is non-zero, no far objects extraction will be attempted
null, // clt_mismatch, // [12][tilesY * tilesX] // ***** transpose unapplied ***** ?. null - do not calculate
// values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is
// values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is
null, // disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
// last 2 - contrast, avg/ "geometric average)
// last 2 - contrast, avg/ "geometric average)
0, // disparity_modes, // disparity_modes, // bit mask of disparity_map slices to calculate/return
null, // final double [][][][] texture_tiles, // compatible with the CPU ones
null, // texture_img, // texture_img, // null or [3][] (RGB) or [4][] RGBA
......@@ -2374,7 +2376,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.tileY, // final int debug_tileY,
threadsMax,
debugLevel);
lazy_eye_data = image_dtt.cltMeasureLazyEyeGPU ( // returns d,s lazy eye parameters
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
disparity_array, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
......@@ -2387,6 +2389,8 @@ public class QuadCLT extends QuadCLTCPU {
null, // geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
disparity_corr, // final double disparity_corr, // disparity at infinity
clt_parameters.tileStep, // final int tileStep, // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
clt_parameters.super_radius, // final int super_radius, // 0 - none, 1 - 3x3, 2 - 5x5,
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
threadsMax,
......@@ -2399,6 +2403,7 @@ public class QuadCLT extends QuadCLTCPU {
scan.resetProcessed();
return scan;
}
public void gpuResetCorrVector() {
if (getGPU() != null) {
getGPU().resetGeometryCorrectionVector();
......
......@@ -386,14 +386,60 @@ public class TileNeibs{
}
public int [] distanceFromEdge(
boolean [] tiles) {
int [] dfe = new int [tiles.length];
for (int i = 0; i < tiles.length; i++) dfe[i] = tiles[i] ? -1 : 0;
ArrayList<Integer> front = new ArrayList<Integer>();
int dist = 0;
for (boolean has_empty = true; has_empty;) {
has_empty = false;
for (int start_indx = 0; start_indx < tiles.length; start_indx++) if (dfe[start_indx] < 0){
has_empty = true;
// see if it has wave front around
boolean has_front_near = false;
for (int d = 0; (d < dirs) && !has_front_near; d++){
int ipx1 = getNeibIndex(start_indx, d);
if ((ipx1 >= 0) && (dfe[ipx1] == dist)) {
has_front_near = true;
}
}
if (has_front_near) {
dfe[start_indx] = dist+1;
front.add(start_indx);
// build wave front (may be several)
while (!front.isEmpty()) {
int ipx = front.remove(0);// get oldest element
for (int d = 0; (d < dirs) && !has_front_near; d++){
int ipx1 = getNeibIndex(ipx, d);
if ((ipx1 >= 0) && (dfe[ipx1] < 0)) { // fresh cell
// does it has front neighbor?
for (int d1 = 0; (d1 < dirs) && !has_front_near; d1++){
int ipx2 = getNeibIndex(ipx1, d1);
if ((ipx2 >= 0) && (dfe[ipx2] == dist)) { // old front cell
dfe[ipx1] = dist+1;
front.add(ipx1);
break;
}
}
}
}
}
}
}
dist++;
}
return dfe;
}
/**
* Enumerate clusters on rectangular area
* @param tiles selected tiles, size should be sizeX * sizeY
* @param ordered if true, order tiles from largest to smallest5
* @return integer array, where 0 is unused, 1+ cluster it belongs to
*/
public int [] enumerateClusters(
boolean [] tiles,
boolean ordered)
......@@ -513,4 +559,41 @@ public class TileNeibs{
return num_total_removed;
}
public boolean [] fillConcave(
boolean [] tiles // should be the same size
) {
boolean [] filled = tiles.clone();
int min_neibs = 4;
ArrayList<Integer> front = new ArrayList<Integer>();
for (int start_indx = 0; start_indx < tiles.length; start_indx++) if (!filled[start_indx]) {
int nneib = 0;
for (int dir = 0; dir < dirs; dir++) {
int id = getNeibIndex(start_indx, dir);
if ((id >= 0) && filled[id]) nneib++;
}
if (nneib >= min_neibs) {
front.add(start_indx); // do not mark yet
filled[start_indx] = true;
while (!front.isEmpty()) {
int seed = front.remove(0);// get oldest element
for (int d = 0; d < dirs; d++){
int indx = getNeibIndex(seed, d);
if ((indx >=0) && !filled[indx]) {
nneib = 0;
for (int dir = 0; dir < dirs; dir++) {
int id = getNeibIndex(indx, dir);
if ((id >= 0) && filled[id]) nneib++;
}
if (nneib >= min_neibs) {
front.add(indx); // do not mark yet
filled[indx] = true;
}
}
}
}
}
}
return filled;
}
}
......@@ -8325,11 +8325,14 @@ if (debugLevel > -100) return true; // temporarily !
"pre-adjust-extrinsic-scan-"+s); //String title)
}
}
double inf_min = -1.0;
double inf_max = 1.0;
if (num_adjust_main >= (adjust_main/2)) {
inf_min = -0.2;
inf_max = 0.05;
double inf_min = clt_parameters.ly_inf_min_broad; // -0.5;
double inf_max = clt_parameters.ly_inf_max_broad; // 0.5;
if (clt_parameters.ly_inf_force_fine || (num_adjust_main >= (adjust_main/2))) {
inf_min = clt_parameters.ly_inf_min_narrow; // -0.2;
inf_max = clt_parameters.ly_inf_max_narrow; // 0.05;
System.out.println("Late adjustment, using narrow band infinity detection, inf_min="+inf_min+", inf_max="+inf_max);
} else {
System.out.println("Early adjustment, using wide band infinity detection, inf_min="+inf_min+", inf_max="+inf_max);
}
boolean ok = quadCLT_main.extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -8407,7 +8410,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main.tp.clt_3d_passes.get( quadCLT_main.tp.clt_3d_passes.size() -1),
false); // boolean force_final);
if (debugLevel > -5){
if (debugLevel > -1) { //-5){
int scan_index = quadCLT_main.tp.clt_3d_passes.size() -1;
quadCLT_main.tp.showScan(
quadCLT_main.tp.clt_3d_passes.get(scan_index), // CLTPass3d scan,
......@@ -8508,6 +8511,18 @@ if (debugLevel > -100) return true; // temporarily !
}
if (num_restored < 2) {
System.out.println("No DSI from the main camera is available. Please re-run with 'clt_batch_explore' enabled to generate it");
if (quadCLT_main.correctionsParameters.clt_batch_save_extrinsics) {
saveProperties(
null, // String path, // full name with extension or w/o path to use x3d directory
null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_save_all) {
saveProperties(
null, // String path, // full name with extension or w/o path to use x3d directory
properties, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
continue; // skipping to the next file
}
}
......@@ -8681,6 +8696,8 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
if (quadCLT_main.correctionsParameters.clt_batch_save_extrinsics) {
saveProperties(
......