Commit 23452c5b authored by Andrey Filippov's avatar Andrey Filippov

Testing fast single-stage poses that require DSI for ref scene only

parent 57bfb4d6
......@@ -737,6 +737,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
panelClt5aux = new Panel();
panelClt5aux.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("LIST extrinsics", panelClt5aux, color_report);
addButton("Aux Build Series", panelClt5aux, color_stop);
addButton("Aux Inter Test", panelClt5aux, color_stop);
addButton("Aux Inter Pairs", panelClt5aux, color_process);
addButton("Aux Inter LMA", panelClt5aux, color_stop);
......@@ -5132,6 +5133,13 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
testInterScene(false);
return;
/* ======================================================================== */
} else if (label.equals("Aux Build Series")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
buildSeries(true);
return;
/* ======================================================================== */
} else if (label.equals("Aux Inter Test")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
......@@ -6745,6 +6753,102 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
+ Runtime.getRuntime().freeMemory() + " (of " + Runtime.getRuntime().totalMemory() + ")");
return true;
}
public boolean buildSeries(boolean use_aux) {
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("++++++++++++++ Building series from scratch ++++++++++++++");
}
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 (use_aux) {
if (CLT_PARAMETERS.useGPU(true) && (QUAD_CLT_AUX != null) && (GPU_QUAD_AUX == null)) { // if GPU AUX is
// needed
try {
GPU_QUAD_AUX = new GpuQuad(//
GPU_TILE_PROCESSOR, QUAD_CLT_AUX, CLT_PARAMETERS.gpu_debug_level);
} 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);
}
} 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, CLT_PARAMETERS.gpu_debug_level);
} 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;
CLT_PARAMETERS.setColorProcParameters(COLOR_PROC_PARAMETERS, false);
CLT_PARAMETERS.setColorProcParameters(COLOR_PROC_PARAMETERS_AUX, true);
CLT_PARAMETERS.setRGBParameters(RGB_PARAMETERS);
try {
TWO_QUAD_CLT.buildSeriesTQ(
quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
// QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
CHANNEL_GAINS_PARAMETERS, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, // EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
PROPERTIES, // Properties properties,
true, // false, // boolean reset_from_extrinsics,
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 testInterLMA(boolean use_aux) {
long startTime = System.nanoTime();
......@@ -7791,12 +7895,14 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
System.out.println("++++++++++++++ Copying JP4 source files ++++++++++++++");
}
try {
TWO_QUAD_CLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
null, // String set_name
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
DEBUG_LEVEL);
} catch (Exception e) {
// TODO Auto-generated catch block
......
......@@ -328,6 +328,7 @@ public class JP46_Reader_camera implements PlugIn, ActionListener {
imp = openJpegOrGif(directory, fileName);
if (imp == null) {
IJ.showMessage("JP46 Reader Error", "Could not open "+directory+"" + fileName + " as JPEG/JP46");
System.out.println("JP46 Reader Error: Could not open "+directory+"" + fileName + " as JPEG/JP46");
} else {
if ((imp_src==null)&& showImage) imp.show(); /* Shows before re-ordering*/
ElphelMakerNote = readElphelMakerNote(directory, fileName, 16,xtraExif); /* after or 8.2.2 */
......
......@@ -2438,9 +2438,11 @@ public class Correlation2d {
for (int ix = 0; ix < data_width; ix++) {
double x = ix - x0;
double d = data[iy * data_width + ix];
s0 += d;
sx += d * x;
sy += d * y;
if (d > 0) { // ignore negative
s0 += d;
sx += d * x;
sy += d * y;
}
}
}
x0 += sx / s0;
......@@ -2457,10 +2459,12 @@ public class Correlation2d {
if (r2 < radius2) {
double r = Math.sqrt(r2);
double d = data[iy * data_width + ix];
d *= Math.cos(0.5*Math.PI*r/radius);
s0 += d;
sx += d * x;
sy += d * y;
if (d > 0) { // ignore negative
d *= Math.cos(0.5*Math.PI*r/radius);
s0 += d;
sx += d * x;
sy += d * y;
}
}
}
}
......
......@@ -1987,6 +1987,23 @@ public class ErsCorrection extends GeometryCorrection {
}
}
public static double [][] combineXYZATR(
double [][] reference_xyzatr,
double [][] scene_xyzatr){
return combineXYZATR(
reference_xyzatr[0],
reference_xyzatr[1],
scene_xyzatr[0],
scene_xyzatr[1]);
}
public static double [][] invertXYZATR(
double [][] source_xyzatr){
return invertXYZATR(
source_xyzatr[0],
source_xyzatr[1]);
}
public static double [][] combineXYZATR(
double [] reference_xyz,
double [] reference_atr,
......
......@@ -320,6 +320,9 @@ public class GeometryCorrection {
System.arraycopy(right, 0, egc.right, 0, min_nc);
System.arraycopy(height, 0, egc.height, 0, min_nc);
System.arraycopy(roll, 0, egc.roll, 0, min_nc);
if (woi_tops == null) {
woi_tops = new int[min_nc];
}
System.arraycopy(woi_tops, 0, egc.woi_tops,0, min_nc);
for (int n = 0; n < min_nc; n++) {
egc.pXY0[n] = pXY0[n].clone();
......
......@@ -2467,6 +2467,10 @@ public class ImageDtt extends ImageDttCPU {
final int n_recenter, // when cosine window, re-center window this many times
final double min_str, // = 0.25;
final double min_str_sum, // = 0.8; // 5;
final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8)
final double half_disparity, // 5.0; // Reduce weight twice for this disparity
final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice
final int debug_tileX,
final int debug_tileY,
final int threadsMax, // maximal number of threads to launch
......@@ -2477,6 +2481,7 @@ public class ImageDtt extends ImageDttCPU {
System.out.println("clt_process_tl_interscene(): this.gpuQuad is null, bailing out");
return null;
}
// final int min_neibs = clt_parameters.imp.min_neibs;
final boolean extra_sum = true; // use sum of pixel-domain correlations (TD have artifacts for low contrast
// - maybe -related to float vs. double - not tested yet
// final int width = gpuQuad.getImageWidth();
......@@ -2657,15 +2662,19 @@ public class ImageDtt extends ImageDttCPU {
centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass)
false); // boolean debug)
if ((mv != null) && (mv[2] < min_str)) {
mv = null;
if (mv != null) {
if (mv[2] < min_str) {
mv = null;
} else {
mv[2] -= min_str;
}
}
if (mv != null) {
if (pXpYD == null) {
coord_motion[0][nTile] = mv;
} else {
if (pXpYD[nTile] != null) { // seems always
coord_motion[0][nTile] = pXpYD[nTile];
coord_motion[0][nTile] = pXpYD[nTile].clone();
coord_motion[1][nTile] = mv;
}
}
......@@ -2675,9 +2684,88 @@ public class ImageDtt extends ImageDttCPU {
};
}
startAndJoin(threads);
ai.set(0);
final int tiles = tilesX * tilesY;
final double [][] mv = coord_motion[coord_motion.length - 1];
final double [][] pxd = (coord_motion.length>1) ? coord_motion[0] : null;
final double scale_num_neib = ((weight_zero_neibs >= 0) && (weight_zero_neibs < 1.0)) ? (weight_zero_neibs * 8/(1.0 - weight_zero_neibs)): 0.0;
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
double l2;
TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
if ((mv[nTile] != null) && (pXpYD[nTile] != null)) {
int num_neibs=0;
double sx=0.0, sy=0.0;
for (int dir = 0; dir < 8; dir++) {
int nTile1 = tn.getNeibIndex(nTile, dir);
if ((nTile1 >= 0) &&
(mv[nTile1] != null) &&
(pXpYD[nTile1] != null) &&
!Double.isNaN(mv[nTile1][2]) &&
!Double.isNaN(mv[nTile1][0]) &&
!Double.isNaN(mv[nTile1][1])){
num_neibs++;
sx += mv[nTile1][0];
sy += mv[nTile1][1];
}
}
if (num_neibs < min_neibs) { // filter by minimal neighbors
mv[nTile][2] = 0;
/*
mv[nTile] = null;
if (pxd != null) {
pxd[nTile] = null;
}
*/
continue;
}
if ((weight_zero_neibs >= 0) && (weight_zero_neibs < 1.0)) { // scale weight by number of neighbors
mv[nTile][2] *= (num_neibs + scale_num_neib)/(8.0 + scale_num_neib);
}
if (half_disparity > 0.0) { // scale by disparity
mv[nTile][2] *= half_disparity/(half_disparity + pxd[nTile][2]);
}
if ((half_avg_diff > 0.0) &&(num_neibs > 0)) {
double dx = mv[nTile][0] - sx / num_neibs;
double dy = mv[nTile][1] - sy / num_neibs;
l2 = Math.sqrt(dx * dx + dy * dy);
mv[nTile][2] *= half_avg_diff/(half_avg_diff + l2);
}
}
}
}
};
}
startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
double l2;
TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
if ((mv[nTile] != null) && (pXpYD[nTile] != null)) {
if (mv[nTile][2] <= 0) {
mv[nTile] = null;
if (pxd != null) {
pxd[nTile] = null;
}
}
}
}
}
};
}
startAndJoin(threads);
return coord_motion;
}
// using most of the ImageDttCPU.clt_process_tl_correlations
......
......@@ -389,7 +389,7 @@ public class IntersceneLma {
Matrix wjtjlambda = new Matrix(getWJtJlambda(
lambda, // *10, // temporary
this.last_jt)); // double [][] jt)
if (debug_level > 1) {
if (debug_level > 2) {
try {
System.out.println("getFxDerivs(): getChecksum(this.y_vector)="+ getChecksum(this.y_vector));
System.out.println("getFxDerivs(): getChecksum(this.weights)="+ getChecksum(this.weights));
......@@ -427,7 +427,7 @@ public class IntersceneLma {
System.out.println("Jt * (y-fx)");
jty.print(18, 6);
}
if (debug_level > 1) {
if (debug_level > 2) {
try {
System.out.println("getFxDerivs(): getChecksum(jtjl_inv)="+getChecksum(jtjl_inv));
System.out.println("getFxDerivs(): getChecksum(jty)= "+getChecksum(jty));
......@@ -451,7 +451,7 @@ public class IntersceneLma {
for (int i = 0; i < parameters_vector.length; i++) {
new_vector[i] += scale * delta[i];
}
if (debug_level > 1) {
if (debug_level > 2) {
try {
System.out.println("getFxDerivs(): getChecksum(mdelta)= "+getChecksum(mdelta));
System.out.println("getFxDerivs(): getChecksum(delta)= "+getChecksum(delta));
......@@ -793,7 +793,7 @@ public class IntersceneLma {
fx [i + 2 * macrotile_centers.length] = vector[i]; // - parameters_initial[i]; // scale will be combined with weights
jt[i][i + 2 * macrotile_centers.length] = 1.0; // scale will be combined with weights
}
if (debug_level > 1) {
if (debug_level > 2) {
try {
System.out.println ("getFxDerivs(): getChecksum(fx)="+getChecksum(fx));
if (jt != null) {
......
......@@ -5615,6 +5615,26 @@ if (debugLevel < -100) {
return quadCLT;
}
public QuadCLT spawnNoModelQuadCLT(
String set_name,
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, //
int threadsMax,
int debugLevel)
{
QuadCLT quadCLT = new QuadCLT(this, set_name); //null
quadCLT.restoreNoModel(
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;
}
}
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