Commit e61d71b1 authored by Andrey Filippov's avatar Andrey Filippov

First SfM tests - 0.05m from 75m AGL

parent b3dc65da
......@@ -2506,6 +2506,89 @@ public class Correlation2d {
}
public static double [] getMaxProjCm(
double [] data,
int data_width, // = 2 * transform_size - 1;
double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
int refine, // re-center window around new maximum. 0 -no refines (single-pass)
double [] direction_XY,
boolean debug)
{
int data_height = data.length/data_width;
int center_xy = (data_width - 1)/2; // = transform_size - 1;
double x0 = center_xy, y0 = center_xy;
int imax= 0;
for (int i= 1; i < data.length;i++) {
if (data[i] > data[imax]) {
imax = i;
}
}
double mx = data[imax];
int ix0 = imax % data_width;
int iy0 = imax / data_width;
x0 = ix0;
y0 = iy0;
double disp0 = x0 * direction_XY[0] + y0 * direction_XY[1];
// if (fpn_mask != null
//calculate as "center of mass"
if (radius == 0) {
double s0 = 0, sx=0,sy = 0, sdisp = 0;
for (int iy = 0; iy < data_height; iy++) {
double y = iy - y0;
for (int ix = 0; ix < data_width; ix++) {
double x = ix - x0;
double d = data[iy * data_width + ix];
if (d > 0) { // ignore negative
s0 += d;
sx += d * x;
sy += d * y;
sdisp += d * (x * direction_XY[0] + y * direction_XY[1]);
} else if (Double.isNaN(d)) {
System.out.println("NaN in getMaxProjCm()");
return null;
}
}
}
x0 += sx / s0;
y0 += sy / s0;
disp0 += sdisp / s0;
} else {
double radius2 = radius*radius;
for (int nref = 0; nref <= refine; nref++) {
double s0 = 0, sx=0, sy = 0, sdisp = 0;
for (int iy = 0; iy < data_height; iy++) {
double y = iy - y0;
for (int ix = 0; ix < data_width; ix++) {
double x = ix - x0;
double r2= x*x + y*y;
if (r2 < radius2) {
double r = Math.sqrt(r2);
double d = data[iy * data_width + ix];
if (d > 0) { // ignore negative
d *= Math.cos(0.5*Math.PI*r/radius);
s0 += d;
sx += d * x;
sy += d * y;
sdisp += d * (x * direction_XY[0] + y * direction_XY[1]);
}
}
}
}
x0 += sx / s0;
y0 += sy / s0;
disp0 += sdisp / s0;
}
}
// double [] rslt = {x0 - center_xy, y0 - center_xy, mx};
double [] rslt = {disp0 - center_xy * (direction_XY[0] + direction_XY[1]), mx};
if (debug){
System.out.println("getMaxProjCm() -> "+rslt[0]+":"+rslt[1]);
}
return rslt;
}
/**
* Analyze 1d correlation (single centerline of the 3D phase correlation combined output
......
......@@ -1077,7 +1077,7 @@ public class GeometryCorrection {
debugLevel); // int debugLevel)
int pars = jt_delta.length;
int tilesX = qc_main.tp.getTilesX();
int tilesY = qc_main.tp.getTilesX();
int tilesY = qc_main.tp.getTilesY(); // 10.14.2023: was getTilesX()!
String [] titles = new String[6 * pars];
double [][] dbg_data = new double [6 * pars][tilesY * tilesX];
for (int i = 0; i < dbg_data.length; i++) for (int j = 0; j < dbg_data[i].length; j++) dbg_data[i][j]=Double.NaN;
......
......@@ -4892,14 +4892,21 @@ public class OpticalFlow {
mb_max_gain, // double mb_max_gain,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
QuadCLT[] scenes_pair = new QuadCLT[]{
quadCLTs[ref_index - 1],
quadCLTs[earliest_scene]};
StructureFromMotion.sfmPair(
int num_avg_pairs = 16; // number of scene pairs to average
QuadCLT[][] scenes_pairs = new QuadCLT[num_avg_pairs][2];
for (int i = 0; i < num_avg_pairs; i++) {
scenes_pairs[i][0] = quadCLTs[ref_index - 1 - i];
scenes_pairs[i][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i];
}
// QuadCLT[] scenes_pair = new QuadCLT[]{
// quadCLTs[ref_index - 1],
// quadCLTs[earliest_scene]};
combo_dsn_final = StructureFromMotion.sfmPair(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene,
scenes_pair, // final QuadCLT [] scenes,
scenes_pairs, // final QuadCLT [][] scenes_pairs,
// scenes_pair, // final QuadCLT [] scenes,
// num_avg_pairs, // final int num_avg_pairs, // number of scene pairs to average
mb_max_gain, // double mb_max_gain,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
......
......@@ -347,7 +347,6 @@ public class TDCorrTile {
final int [] corr_indices = new int [num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(ImageDtt.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger anum_tiles = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
......
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