From 9b3ee995526afa352a894fe34462540689edf2d1 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 26 May 2015 18:58:29 -0700 Subject: [PATCH] Fixes to VW pixel projection error handling --- src/vw/BundleAdjustment/AdjustBase.h | 2 +- src/vw/BundleAdjustment/AdjustRef.h | 4 ++-- src/vw/BundleAdjustment/AdjustRobustRef.h | 4 ++-- src/vw/BundleAdjustment/AdjustRobustSparse.h | 4 ++-- src/vw/BundleAdjustment/AdjustSparse.h | 4 ++-- src/vw/BundleAdjustment/BundleAdjustReport.h | 12 ++++++++---- src/vw/BundleAdjustment/ModelBase.h | 8 ++++---- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/vw/BundleAdjustment/AdjustBase.h b/src/vw/BundleAdjustment/AdjustBase.h index 0142cb436..eb23d4419 100644 --- a/src/vw/BundleAdjustment/AdjustBase.h +++ b/src/vw/BundleAdjustment/AdjustBase.h @@ -288,7 +288,7 @@ namespace ba { unweighted_error = cmeasure->dominant() - m_model(i, camera_idx,m_model.A_parameters(camera_idx), m_model.B_parameters(i)); - } catch (const camera::PixelToRayErr& e) { + } catch (const camera::PointToPixelErr& e) { vw_out(WarningMessage,"ba") << "Unable to calculate starting error for point"; } double mag = norm_2(unweighted_error); diff --git a/src/vw/BundleAdjustment/AdjustRef.h b/src/vw/BundleAdjustment/AdjustRef.h index 8fa17c551..cc0314fff 100644 --- a/src/vw/BundleAdjustment/AdjustRef.h +++ b/src/vw/BundleAdjustment/AdjustRef.h @@ -166,7 +166,7 @@ namespace ba { this->m_model(i, camera_idx, this->m_model.A_parameters(camera_idx), this->m_model.B_parameters(i)); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} double mag = norm_2(unweighted_error); double weight = sqrt(this->m_robust_cost_func(mag)) / mag; subvector(error,2*idx,2) = unweighted_error * weight; @@ -307,7 +307,7 @@ namespace ba { this->m_model(i, camera_idx, this->m_model.A_parameters(camera_idx)-cam_delta, this->m_model.B_parameters(i)-pt_delta); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} double mag = norm_2(unweighted_error); double weight = sqrt(this->m_robust_cost_func(mag)) / mag; subvector(new_error,2*idx,2) = unweighted_error * weight; diff --git a/src/vw/BundleAdjustment/AdjustRobustRef.h b/src/vw/BundleAdjustment/AdjustRobustRef.h index 7d9544895..1e42d7b0e 100644 --- a/src/vw/BundleAdjustment/AdjustRobustRef.h +++ b/src/vw/BundleAdjustment/AdjustRobustRef.h @@ -178,7 +178,7 @@ namespace ba { this->m_model(i, camera_idx, this->m_model.A_parameters(camera_idx), this->m_model.B_parameters(i)); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} // Fill in the entries of the sigma matrix with the uncertainty of the observations. Matrix2x2 inverse_cov; Vector2 pixel_sigma = (*(this->m_control_net))[i][m].sigma(); @@ -342,7 +342,7 @@ namespace ba { this->m_model(i, camera_idx, this->m_model.A_parameters(camera_idx)-cam_delta, this-> m_model.B_parameters(i)-pt_delta); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} Matrix2x2 inverse_cov = submatrix(sigma, 2*idx, 2*idx, 2, 2); // Populate the S_weights, mu_weights vectors diff --git a/src/vw/BundleAdjustment/AdjustRobustSparse.h b/src/vw/BundleAdjustment/AdjustRobustSparse.h index 5704c4f11..7daf682f0 100644 --- a/src/vw/BundleAdjustment/AdjustRobustSparse.h +++ b/src/vw/BundleAdjustment/AdjustRobustSparse.h @@ -174,7 +174,7 @@ namespace ba { unweighted_error = (**fiter).m_location - this->m_model(i,j,this->m_model.A_parameters(j), this->m_model.B_parameters(i)); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} Vector2 pixel_sigma = (**fiter).m_scale; Matrix2x2 inverse_cov; @@ -449,7 +449,7 @@ namespace ba { try { unweighted_error = (**fiter).m_location - this->m_model(i,j,new_a,new_b); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} Matrix2x2 inverse_cov; Vector2 pixel_sigma = (**fiter).m_scale; diff --git a/src/vw/BundleAdjustment/AdjustSparse.h b/src/vw/BundleAdjustment/AdjustSparse.h index 977233257..296dead4c 100644 --- a/src/vw/BundleAdjustment/AdjustSparse.h +++ b/src/vw/BundleAdjustment/AdjustSparse.h @@ -170,7 +170,7 @@ namespace ba { error = measure->m_location - this->m_model(i,j,this->m_model.A_parameters(j), this->m_model.B_parameters(i) ); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} if ( error != Vector2() ) { double mag = norm_2(error); @@ -440,7 +440,7 @@ namespace ba { try { error = (**fiter).m_location - this->m_model((**fiter).m_point_id,j,new_a,new_b); - } catch (const camera::PixelToRayErr& e) {} + } catch (const camera::PointToPixelErr& e) {} double mag = norm_2( error ); double weight = sqrt( this->m_robust_cost_func(mag)) / mag; error *= weight; diff --git a/src/vw/BundleAdjustment/BundleAdjustReport.h b/src/vw/BundleAdjustment/BundleAdjustReport.h index 7af66b4fb..b7696effd 100644 --- a/src/vw/BundleAdjustment/BundleAdjustReport.h +++ b/src/vw/BundleAdjustment/BundleAdjustReport.h @@ -262,10 +262,14 @@ namespace ba { math::CDFAccumulator image_cdf; BOOST_FOREACH( ControlPoint const& cp, *network ) { BOOST_FOREACH( ControlMeasure const& cm, cp ) { - image_cdf(m_model.image_compare(cm.position(), - m_model(cp_index,cm.image_id(), - m_model.A_parameters(cm.image_id()), - m_model.B_parameters(cp_index)))); + try{ + image_cdf(m_model.image_compare(cm.position(), + m_model(cp_index,cm.image_id(), + m_model.A_parameters(cm.image_id()), + m_model.B_parameters(cp_index)))); + } catch(const camera::PointToPixelErr& e) { + // Missed pixels are not included in the reporting statistics! + } } cp_index++; } diff --git a/src/vw/BundleAdjustment/ModelBase.h b/src/vw/BundleAdjustment/ModelBase.h index b6e7dd60a..5bbc3c0d3 100644 --- a/src/vw/BundleAdjustment/ModelBase.h +++ b/src/vw/BundleAdjustment/ModelBase.h @@ -74,7 +74,7 @@ namespace ba { try { // Get nominal function value h0 = impl()(i,j,a_j,b_i); - } catch (const camera::PixelToRayErr& e) { + } catch (const camera::PointToPixelErr& e) { // Unable to project this point into the camera, so abort! return J; } @@ -93,7 +93,7 @@ namespace ba { try { Vector2 hi = impl()(i,j,a_j_prime, b_i); select_col(J,n) = (hi-h0)/epsilon; - } catch (const camera::PixelToRayErr& e) { + } catch (const camera::PointToPixelErr& e) { select_col(J,n) = Vector2(); } } @@ -114,7 +114,7 @@ namespace ba { try { // Get nominal function value h0 = impl()(i,j,a_j, b_i); - } catch (const camera::PixelToRayErr& e) { + } catch (const camera::PointToPixelErr& e) { // Unable to project this point into the camera so abort! return J; } @@ -133,7 +133,7 @@ namespace ba { try { Vector2 hi = impl()(i,j,a_j,b_i_prime); select_col(J,n) = (hi-h0)/epsilon; - } catch (const camera::PixelToRayErr& e) { + } catch (const camera::PointToPixelErr& e) { select_col(J,n) = Vector2(); } }