Permalink
Browse files

Stereo triangulation: Bug fix: Check for NaN values.

  • Loading branch information...
1 parent 1e27185 commit e7c13d0c7b6f017434ddb02fff0a7810a7b30d73 @oleg-alexandrov oleg-alexandrov committed Oct 1, 2012
Showing with 12 additions and 2 deletions.
  1. +9 −2 src/asp/Sessions/DG/StereoSessionDG.cc
  2. +3 −0 src/asp/Sessions/RPC/RPCStereoModel.cc
@@ -72,6 +72,7 @@ class SecondsFrom {
}
};
+
// Helper functor that converts projected pixel indices and height
// value to unprojected pixel indices.
class OriginalCameraIndex : public ReturnFixedType<Vector2f> {
@@ -83,13 +84,19 @@ class OriginalCameraIndex : public ReturnFixedType<Vector2f> {
m_image_boundaries(bbox) {}
Vector2f operator()( Vector3 const& point ) const {
+
+ const double nan_val = std::numeric_limits<double>::quiet_NaN();
+
if ( point == Vector3() )
- return Vector2f(-1,-1);
+ return Vector2f(nan_val, nan_val);
+
Vector2f result = m_rpc.point_to_pixel( point );
if ( m_image_boundaries.contains( result ) )
return result;
- return Vector2f(-1,1);
+
+ return Vector2f(nan_val, nan_val);
}
+
};
namespace asp {
@@ -54,6 +54,9 @@ namespace asp {
Vector3 RPCStereoModel::operator()(Vector2 const& pix1, Vector2 const& pix2, double& error) const {
+ // Check for NaN values
+ if (pix1 != pix1 || pix2 != pix2) return Vector3();
+
const RPCModel *rpc_model1 = dynamic_cast<const RPCModel*>(m_camera1);
const RPCModel *rpc_model2 = dynamic_cast<const RPCModel*>(m_camera2);

0 comments on commit e7c13d0

Please sign in to comment.