Commit c6d346ea authored by Andrey Filippov's avatar Andrey Filippov

multy-reference amendment to the previous commit

parent dd7e6ced
......@@ -293,6 +293,61 @@ public class EstimateSceneRange {
center, earliest, latest, earliest_prescan, latest_prescan, needs_prescan );
}
private static void ensureSfmOnlyReferenceGpu(
final CLTParameters clt_parameters,
final QuadCLT[] quadCLTs,
final int cent_index,
final boolean[] reliable_ref,
final double[][] pXpYD_ref,
final TpTask[][] tp_tasks_ref,
final int debugLevel) {
if ((tp_tasks_ref != null) && (tp_tasks_ref.length > 0) && (tp_tasks_ref[0] != null)) {
return;
}
if ((tp_tasks_ref == null) || (tp_tasks_ref.length == 0)) {
return;
}
final boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
final double[] ref_disparity = quadCLTs[cent_index].getDLS()[use_lma_dsi ? 1 : 0];
final double[][] pXpYD_ref1 = OpticalFlow.transformToScenePxPyD(
null,
ref_disparity,
Interscene.ZERO3,
Interscene.ZERO3,
quadCLTs[cent_index],
quadCLTs[cent_index]);
double[][] pXpYD_ref_use = pXpYD_ref1;
if ((pXpYD_ref != null) && (pXpYD_ref.length >= pXpYD_ref1.length)) {
System.arraycopy(
pXpYD_ref1,
0,
pXpYD_ref,
0,
pXpYD_ref1.length);
pXpYD_ref_use = pXpYD_ref;
}
final TpTask[][] tp_tasks_ref2 = Interscene.setReferenceGPU(
clt_parameters,
quadCLTs[cent_index],
ref_disparity,
pXpYD_ref_use,
null,
reliable_ref,
clt_parameters.imp.margin,
0.0,
0.0,
null,
debugLevel);
System.arraycopy(
tp_tasks_ref2,
0,
tp_tasks_ref,
0,
Math.min(
tp_tasks_ref.length,
tp_tasks_ref2.length));
}
public static boolean scanSfmIMS(
......@@ -305,6 +360,30 @@ public class EstimateSceneRange {
final boolean batch_mode,
final boolean updateStatus,
final int debugLevel) {
return scanSfmIMS(
clt_parameters,
estimateSceneRange,
quadCLTs,
quadCLT_main,
colorProcParameters,
set_channels,
batch_mode,
updateStatus,
debugLevel,
false);
}
public static boolean scanSfmIMS(
final CLTParameters clt_parameters,
EstimateSceneRange estimateSceneRange,
final QuadCLT[] quadCLTs,
final QuadCLT quadCLT_main,
final ColorProcParameters colorProcParameters,
final SetChannels [] set_channels,
final boolean batch_mode,
final boolean updateStatus,
final int debugLevel,
final boolean sfm_only) {
int earliest = estimateSceneRange.earliest; // was earliest_prescan
int latest = estimateSceneRange.latest; // was latest_prescan
// The current version does not use smaller range (prescan) as it uses SFM
......@@ -381,7 +460,8 @@ public class EstimateSceneRange {
quadCLTs[cent_index].setQuadClt(); // just in case ?
if (debugLevel > -3) {
System.out.println("scanSfmIMS(): lma_use_Z="+lma_use_Z+", lma_use_R="+lma_use_R+ ", lma_ovlp_ZR="+lma_ovlp_ZR+", ref_scene= "+quadCLTs[cent_index].getImageName());
System.out.println("scanSfmIMS(): lma_use_Z="+lma_use_Z+", lma_use_R="+lma_use_R+ ", lma_ovlp_ZR="+lma_ovlp_ZR+
", ref_scene= "+quadCLTs[cent_index].getImageName()+", sfm_only="+sfm_only);
}
boolean[] param_select =
ErsCorrection.getParamSelect( // ZR - always
......@@ -551,7 +631,17 @@ public class EstimateSceneRange {
double mb_max_gain = clt_parameters.imp.mb_max_gain_inter; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
TpTask[][] tp_tasks_ref = new TpTask[2][];
double [][] pXpYD_ref = new double [tilesX*tilesY][];
ArrayList<Integer> fpn_list = new ArrayList<Integer>();
if (sfm_only) {
ensureSfmOnlyReferenceGpu(
clt_parameters,
quadCLTs,
cent_index,
reliable_ref,
pXpYD_ref,
tp_tasks_ref,
debugLevel);
}
ArrayList<Integer> fpn_list = new ArrayList<Integer>();
double [] reg_weights = clt_parameters.ilp.ilma_regularization_weights;
final double max_rms = clt_parameters.imp.eig_use? clt_parameters.imp.eig_max_rms: clt_parameters.imp.max_rms;
double avg_z = quadCLTs[cent_index].getAverageZ(true); // use lma
......@@ -650,6 +740,64 @@ public class EstimateSceneRange {
if (est_shift < min_offset) { // min_max[0]) {
fail_reason[0]=Interscene.FAIL_REASON_MIN;
prefiltered = true;
} else if (sfm_only) {
ensureSfmOnlyReferenceGpu(
clt_parameters,
quadCLTs,
cent_index,
reliable_ref,
pXpYD_ref,
tp_tasks_ref,
debugLevel);
coord_motion = Interscene.interCorrPair( // return [tile]{ref_pXpYD, dXdYS}
clt_parameters, // CLTParameters clt_parameters,
false, // boolean use3D,
false, // boolean fpn_disable,
mb_max_gain, // double mb_max_gain,
min_max, // double [] min_max,
fail_reason, // int [] fail_reason,
quadCLTs[cent_index],// QuadCLT ref_scene,
null, // double [] ref_disparity,
quadCLTs[cent_index],// QuadCLT first_scene,
pXpYD_ref, // double [][] pXpYD_ref,
tp_tasks_ref[0], // TpTask[] tp_tasks_ref,
quadCLTs[scene_index], // QuadCLT scene,
initial_pose[0], // double [] scene_xyz,
initial_pose[1], // double [] scene_atr,
reliable_scene, // boolean [] selection,
clt_parameters.imp.margin, // int margin,
clt_parameters.imp.sensor_mask_inter, // int sensor_mask_inter,
null, // float [][][] accum_2d_corr,
null, // float [][] dbg_corr_fpn,
false, // boolean near_important,
false, // boolean all_fpn,
true, // boolean initial_adjust,
null, // double [][] mb_vectors,
-1, // int niter,
img_debug_LMA, // boolean img_debug,
clt_parameters.imp.debug_level, // int imp_debug_level
debugLevel); // int debug_level
adjust_OK =
(coord_motion != null) &&
(coord_motion.length >= 2) &&
(coord_motion[0] != null) &&
(coord_motion[1] != null);
if (adjust_OK) {
scenes_xyzatr[scene_index] = new double [][]{
initial_pose[0].clone(),
initial_pose[1].clone()
};
lma_rms[0] = (min_max.length > 2) ? min_max[2] : 0.0;
if (lma_rms.length > 2) {
lma_rms[2] = 0.0;
}
if (lma_rms.length > 3) {
lma_rms[3] = 0.0;
}
if (lma_rms.length > 4) {
lma_rms[4] = 0.0;
}
}
} else {
// boolean img_debug_LMA = debugLevel>1000; // to set manually for debug
// pXpYD_ref = new double [tilesX*tilesY][]; // reset it not to use previous value not needed, controlled by tp_tasks_ref[0]
......@@ -688,11 +836,12 @@ public class EstimateSceneRange {
clt_parameters.imp.debug_level); // int debugLevel);
adjust_OK = scenes_xyzatr[scene_index] != null;
}
// skipping roll and zoom check - they are done earlier.
// skipping roll and zoom check - they are done earlier.
if (!adjust_OK) {
System.out.println("scanSfmIMS(): LMA failed at nscene = "+scene_index+". Reason = "+fail_reason[0]+
System.out.println("scanSfmIMS(): "+(sfm_only ? "interCorrPair" : "LMA")+
" failed at nscene = "+scene_index+". Reason = "+fail_reason[0]+
" ("+Interscene.getFailReason(fail_reason[0])+")"+
(prefiltered? (". It was prefiltered w/o LMA as est_shift="+est_shift+" < "+min_offset):""));
(prefiltered? (". It was prefiltered as est_shift="+est_shift+" < "+min_offset):""));
if (fail_reason[0]==Interscene.FAIL_REASON_MIN) {
fpn_list.add(scene_index);
scenes_xyzatr[scene_index] = initial_pose;
......@@ -806,7 +955,7 @@ public class EstimateSceneRange {
}
// Mitigate FPN - orient the scenes that were too close to the reference by matching them to other, not-so-close scenes
// with already known poses
if (fmg_initial_en && !fpn_list.isEmpty()) {
if (!sfm_only && fmg_initial_en && !fpn_list.isEmpty()) {
// here max_offset is not critical, min_offset can be 0 too
// double [] min_max = {min_offset, max_offset, 0.0} ; // {min, max, actual rms)
double [] min_max = {Double.NaN, max_offset, 0.0} ; // {min, max, actual rms)
......
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