Skip to content

Commit eeb7ef1

Browse files
committed
fixed bugs in covariance
1 parent bd711ff commit eeb7ef1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/sfm/triangulation/covariance_estimation.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ fn estimate_covariance_for_match<Feat: Feature>(
6262
let cov_point = n_inv.fixed_view::<4,4>(0,0);
6363
let j_e = Matrix3x4::<Float>::new(
6464
1.0/landmark_cam.w,0.0,0.0,-landmark_cam.x/landmark_cam.w.powi(2),
65-
0.0,1.0/landmark_cam.y,0.0,-landmark_cam.y/landmark_cam.w.powi(2),
66-
0.0,0.0,landmark_cam.z,-landmark_cam.z/landmark_cam.w.powi(2)
65+
0.0,1.0/landmark_cam.w,0.0,-landmark_cam.y/landmark_cam.w.powi(2),
66+
0.0,0.0,1.0/landmark_cam.w,-landmark_cam.z/landmark_cam.w.powi(2)
6767
);
6868
j_e*cov_point*j_e.transpose()
6969
}
@@ -73,12 +73,12 @@ fn estimate_covariance_for_match<Feat: Feature>(
7373
*/
7474
fn score_covariance(cov: &Matrix3<Float>) -> Float {
7575
let svd = cov.svd(false, false);
76-
(svd.singular_values[0] / svd.singular_values[2]).sqrt()
76+
(svd.singular_values[2] / svd.singular_values[0]).sqrt()
7777
}
7878

7979
pub fn score_camera_pairs<Feat: Feature, C: Camera<Float>>(
80-
match_map: &HashMap<(usize, usize),
81-
Vec<Match<Feat>>>, cam_map: &HashMap<usize, C>,
80+
match_map: &HashMap<(usize, usize), Vec<Match<Feat>>>,
81+
cam_map: &HashMap<usize, C>,
8282
landmark_map: &HashMap<(usize, usize), Vec<EuclideanLandmark<Float>>>,
8383
abs_pose_map: &HashMap<usize, Isometry3<Float>>,
8484
pixel_std: Float
@@ -103,7 +103,8 @@ pub fn score_camera_pairs<Feat: Feature, C: Camera<Float>>(
103103
let l_vec4 = Vector4::<Float>::new(l_vec.x,l_vec.y,l_vec.z,1.0);
104104
let cov = estimate_covariance_for_match(m,&l_vec4,&p1_prime,&inv_intrinsics_1,&p2_prime,&inv_intrinsics_2,pixel_std);
105105
let score_for_m = score_covariance(&cov);
106-
score_acc += score_for_m;
106+
let diff_to_target = ((0.5 as Float).sqrt() - score_for_m).abs();
107+
score_acc += diff_to_target;
107108
}
108109

109110
let score_avg = score_acc/(landmarks.len() as Float);

0 commit comments

Comments
 (0)