Commit 7c17ebab authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Fixed FPN mitigation - using farthest scene if perfect is not available

parent 590d3aba
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -1389,6 +1389,8 @@ public class Interscene {
			// find closest but farther than fpn_mitigate_dist;
			fpn_pairs[ipair][0] = fpn_index; 
			fpn_pairs[ipair][1] = -1;
			double max_dist = 0.0;
			int best_cond_pair = -1;
			double best_dist = Double.NaN;
			for (int i = latest_scene; i >= earliest_scene; i--) {
				double fpn_dist = quadCLTs[latest_scene].estimateAverageShift(
@@ -1397,6 +1399,7 @@ public class Interscene {
						avg_z,                    // double average_z,
						false,                    // boolean use_rot,
						rectilinear);                   // boolean rectilinear)
				
				if (fpn_dist < fpn_mitigate_dist) {
					fpn_dist = quadCLTs[i].estimateAverageShift(
							scenes_xyzatr[i], // double [][] xyzatr0,
@@ -1411,7 +1414,16 @@ public class Interscene {
						fpn_pairs[ipair][1] = i;
						need_fpn_mitigate[fpn_pairs[ipair][0]] = false;
					}
				} else if (fpn_dist > max_dist) {
					max_dist = fpn_dist;
					best_cond_pair = i;
				}
			}
			if (fpn_pairs[ipair][1] < 0) {
				System.out.print("Failed to find a good pair for scene #"+fpn_pairs[ipair][0]+". ");
				System.out.println("Using #"+best_cond_pair+" with distance = "+max_dist+" pix.");
				fpn_pairs[ipair][1] = best_cond_pair;
				need_fpn_mitigate[fpn_pairs[ipair][0]] = false;
			}
		}
		return fpn_pairs;