Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RPC: Clean up whitespace

  • Loading branch information...
commit c6473f5f2e45a3fb7554a05076603f699fe05cb9 1 parent 3061be0
Zack Moratto authored
View
42 src/asp/Sessions/RPC/RPCModel.cc
@@ -77,7 +77,7 @@ namespace asp {
Vector2 const& xy_scale,
Vector3 const& lonlatheight_offset,
Vector3 const& lonlatheight_scale ) :
- m_datum(datum), m_line_num_coeff(line_num_coeff),
+ m_datum(datum), m_line_num_coeff(line_num_coeff),
m_line_den_coeff(line_den_coeff), m_sample_num_coeff(samp_num_coeff),
m_sample_den_coeff(samp_den_coeff), m_xy_offset(xy_offset),
m_xy_scale(xy_scale), m_lonlatheight_offset(lonlatheight_offset),
@@ -97,19 +97,19 @@ namespace asp {
elem_quot(geodetic - m_lonlatheight_offset, m_lonlatheight_scale);
Vector2 normalized_pixel = normalized_geodetic_to_normalized_pixel( normalized_geodetic );
-
+
return elem_prod( normalized_pixel, m_xy_scale ) + m_xy_offset;
}
Vector2 RPCModel::normalized_geodetic_to_normalized_pixel( Vector3 const& normalized_geodetic ) const {
CoeffVec term = calculate_terms( normalized_geodetic );
-
+
Vector2 normalized_pixel( dot_prod(term,m_sample_num_coeff) /
dot_prod(term,m_sample_den_coeff),
dot_prod(term,m_line_num_coeff) /
dot_prod(term,m_line_den_coeff) );
-
+
return normalized_pixel;
}
@@ -178,7 +178,7 @@ namespace asp {
vw::Matrix<double, 20, 3> RPCModel::terms_Jacobian3( vw::Vector3 const& normalized_geodetic ) {
// Partial derivatives of the terms returned by the
- // calculate_terms() function in respect to all three
+ // calculate_terms() function in respect to all three
// variables only (unlike the terms_Jacobian2() function).
vw::Matrix<double, 20, 3> M;
@@ -263,13 +263,13 @@ namespace asp {
// This function is different from geodetic_to_pixel_Jacobian() in
// several respects:
-
+
// 1. The input is the normalized geodetic, and the derivatives
// are in respect to the normalized geodetic as well.
-
+
// 2. The derivatives are taken only in respect to the first two
// variables (normalized lon and lat, no height).
-
+
// 3. The output is in normalized pixels (see m_xy_scale and m_xy_offset).
CoeffVec term = calculate_terms( normalized_geodetic );
@@ -296,7 +296,7 @@ namespace asp {
Matrix<double, 2, 3> J;
Vector2 B = geodetic_to_pixel(geodetic);
-
+
Vector2 B0 = (geodetic_to_pixel(geodetic + Vector3(tol, 0, 0 )) - B)/tol;
Vector2 B1 = (geodetic_to_pixel(geodetic + Vector3(0, tol, 0 )) - B)/tol;
Vector2 B2 = (geodetic_to_pixel(geodetic + Vector3(0, 0, tol)) - B)/tol;
@@ -304,10 +304,10 @@ namespace asp {
select_col(J, 0) = B0;
select_col(J, 1) = B1;
select_col(J, 2) = B2;
-
+
return J;
}
-
+
Vector2 RPCModel::image_to_ground( Vector2 const& pixel, double height, Vector2 lonlat_guess ) const {
// Given a pixel (the projection of a point onto the camera image)
@@ -316,10 +316,10 @@ namespace asp {
// for the lonlat.
// The absolute tolerance is experimental, needs more investigation
- double abs_tolerance = 1e-6;
+ double abs_tolerance = 1e-6;
Vector2 normalized_pixel = elem_quot(pixel - m_xy_offset, m_xy_scale);
-
+
// Initial guess for the normalized lon and lat
if (lonlat_guess == Vector2(0.0, 0.0)){
lonlat_guess = subvector(m_lonlatheight_offset, 0, 2);
@@ -332,7 +332,7 @@ namespace asp {
// If the input guess is NaN or unreasonable, use 0 as initial guess
normalized_lonlat = Vector2(0.0, 0.0);
}
-
+
// 10 iterations should be enough for Newton's method to converge
for (int iter = 0; iter < 10; iter++){
@@ -340,7 +340,7 @@ namespace asp {
normalized_geodetic[0] = normalized_lonlat[0];
normalized_geodetic[1] = normalized_lonlat[1];
normalized_geodetic[2] = (height - m_lonlatheight_offset[2])/m_lonlatheight_scale[2];
-
+
Vector2 p = normalized_geodetic_to_normalized_pixel(normalized_geodetic);
Matrix<double, 2, 2> J = normalized_geodetic_to_pixel_Jacobian(normalized_geodetic);
@@ -363,23 +363,23 @@ namespace asp {
if (norm_try < abs_tolerance) {
break;
}
-
+
}
Vector2 lonlat
= elem_prod( normalized_lonlat,
subvector(m_lonlatheight_scale, 0, 2) )
+ subvector(m_lonlatheight_offset, 0, 2);
-
+
return lonlat;
-
+
}
void RPCModel::point_and_dir(Vector2 const& pix, Vector3 & P, Vector3 & dir ) const {
// Find a point which gets projected onto the current pixel,
// and the direction of the ray going through that point.
-
+
double height_up = m_lonlatheight_offset[2];
double height_dn = m_lonlatheight_offset[2] - m_lonlatheight_scale[2];
@@ -389,7 +389,7 @@ namespace asp {
// Cache these for the future
m_lonlat_guess_up = lonlat_up;
m_lonlat_guess_dn = lonlat_dn;
-
+
Vector3 geo_up = Vector3(lonlat_up[0], lonlat_up[1], height_up);
Vector3 geo_dn = Vector3(lonlat_dn[0], lonlat_dn[1], height_dn);
@@ -407,7 +407,7 @@ namespace asp {
point_and_dir(pix, P, dir);
return P;
}
-
+
Vector3 RPCModel::pixel_to_vector(Vector2 const& pix ) const {
// Find the normalized direction of the ray back-projected through
// the camera from the current pixel.
View
8 src/asp/Sessions/RPC/RPCModel.h
@@ -21,7 +21,7 @@
// 3D Feature Extraction from Multiple Satellite Images Described by
// RPCs." Proceedings of ASPRS 2004 Conference, Denver, Colorado, May,
// 2004.
-
+
#ifndef __STEREO_SESSION_RPC_MODEL_H__
#define __STEREO_SESSION_RPC_MODEL_H__
@@ -42,7 +42,7 @@ namespace asp {
vw::Vector3 m_lonlatheight_offset;
vw::Vector3 m_lonlatheight_scale;
mutable vw::Vector2 m_lonlat_guess_up, m_lonlat_guess_dn;
-
+
void initialize( vw::DiskImageResourceGDAL* resource );
public:
RPCModel( std::string const& filename );
@@ -95,9 +95,9 @@ namespace asp {
vw::Matrix<double, 2, 2> normalized_geodetic_to_pixel_Jacobian(vw::Vector3 const& normalized_geodetic ) const;
vw::Vector2 image_to_ground(vw::Vector2 const& pixel, double height,
vw::Vector2 lonlat_guess = vw::Vector2(0.0, 0.0)) const;
-
+
void point_and_dir(vw::Vector2 const& pix, vw::Vector3 & P, vw::Vector3 & dir ) const;
-
+
};
inline std::ostream& operator<<(std::ostream& os, const RPCModel& rpc) {
View
14 src/asp/Sessions/RPC/RPCStereoModel.cc
@@ -48,7 +48,7 @@ namespace asp {
submatrix(J, 2, 0, 2, 3) = m_rpc_model2->geodetic_to_pixel_Jacobian(x);
return J;
}
-
+
};
}
@@ -72,12 +72,12 @@ namespace asp {
Vector3 origin2, vec2;
rpc_model2->point_and_dir(pix2, origin2, vec2);
-
+
if (are_nearly_parallel(vec1, vec2)){
error = 0.0;
return Vector3();
}
-
+
result = triangulate_point(origin1, vec1,
origin2, vec2,
error);
@@ -85,13 +85,13 @@ namespace asp {
if ( m_least_squares ){
// Refine triangulation
-
+
detail::RPCTriangulateLMA model(rpc_model1, rpc_model2);
Vector4 objective( pix1[0], pix1[1], pix2[0], pix2[1] );
int status = 0;
Vector3 initialGeodetic = rpc_model1->datum().cartesian_to_geodetic(result);
-
+
// To do: Find good values for the numbers controlling the convergence
Vector3 finalGeodetic = levenberg_marquardt( model, initialGeodetic,
objective, status, 1e-3, 1e-6, 10 );
@@ -103,9 +103,9 @@ namespace asp {
return result;
} catch (...) {}
-
+
error = 0.0;
return Vector3();
}
-
+
} // namespace asp
View
5 src/asp/Sessions/RPC/RPCStereoModel.h
@@ -32,7 +32,7 @@ namespace vw {
namespace asp {
class RPCStereoModel: public vw::stereo::StereoModel {
-
+
public:
//------------------------------------------------------------------
@@ -42,7 +42,7 @@ namespace asp {
vw::camera::CameraModel const* camera_model2,
bool least_squares_refine = false):
vw::stereo::StereoModel(camera_model1, camera_model2, least_squares_refine){}
-
+
//------------------------------------------------------------------
// Public Methods
//------------------------------------------------------------------
@@ -59,4 +59,3 @@ namespace asp {
} // namespace asp
#endif // __ASP_RPC_RPCSTEREOMODEL_H__
-
View
2  src/asp/Sessions/RPC/StereoSessionRPC.cc
@@ -40,5 +40,5 @@ namespace asp {
std::string const& camera_file ) {
return boost::shared_ptr<camera::CameraModel>(StereoSessionDG::read_rpc_model(image_file, camera_file));
}
-
+
} // namespace asp
View
24 src/asp/Tools/stereo_tri.cc
@@ -59,15 +59,15 @@ class StereoAndErrorView : public ImageViewBase<StereoAndErrorView<DisparityImag
template <class T>
inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value == 1),Vector3>::type
- StereoModelHelper( StereoModelT const& model, Vector2 const& index,
- T const& disparity, double& error ) const {
+ StereoModelHelper( StereoModelT const& model, Vector2 const& index,
+ T const& disparity, double& error ) const {
return model( index, Vector2( index[0] + disparity, index[1] ), error );
}
template <class T>
inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value != 1),Vector3>::type
- StereoModelHelper( StereoModelT const& model, Vector2 const& index,
- T const& disparity, double& error ) const {
+ StereoModelHelper( StereoModelT const& model, Vector2 const& index,
+ T const& disparity, double& error ) const {
return model( index, Vector2( index[0] + disparity[0],
index[1] + disparity[1] ), error );
}
@@ -139,14 +139,14 @@ class StereoLUTAndErrorView : public ImageViewBase<StereoLUTAndErrorView<Dispari
template <class T>
inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value == 1),Vector3>::type
- StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
+ StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
return m_stereo_model( m_lut_image1(i,j),
m_lut_image2( float(i) + disparity, j ), error );
}
template <class T>
inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value != 1),Vector3>::type
- StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
+ StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
float i2 = float(i) + disparity[0];
float j2 = float(j) + disparity[1];
@@ -224,7 +224,7 @@ class StereoLUTAndErrorView : public ImageViewBase<StereoLUTAndErrorView<Dispari
preraster = BBox2i(bbox.min() + floor(Vector2f(input_min[0],input_min[1])),
bbox.max() + ceil(Vector2(input_max[0],input_max[1])) );
}
-
+
return prerasterize_type( disparity_preraster,
m_lut_image1.prerasterize(bbox),
m_lut_image2_org.prerasterize(preraster),
@@ -287,7 +287,7 @@ void stereo_triangulation( Options const& opt ) {
boost::shared_ptr<camera::CameraModel> camera_model1, camera_model2;
opt.session->camera_models(camera_model1, camera_model2);
-
+
#if HAVE_PKG_VW_BUNDLEADJUSTMENT
// If the user has generated a set of position and pose
// corrections using the bundle_adjust program, we read them in
@@ -324,12 +324,11 @@ void stereo_triangulation( Options const& opt ) {
if (opt.stereo_session_string == "rpc")
vw_throw(InputErr() << "Stereo with RPC cameras cannot have the camera as the universe center.\n");
-
+
universe_radius_func =
stereo::UniverseRadiusFunc(camera_model1->camera_center(Vector2()),
stereo_settings().near_universe_radius,
stereo_settings().far_universe_radius);
-
} else if ( stereo_settings().universe_center == "zero" ) {
universe_radius_func =
stereo::UniverseRadiusFunc(Vector3(),
@@ -337,7 +336,6 @@ void stereo_triangulation( Options const& opt ) {
stereo_settings().far_universe_radius);
}
-
// Apply radius function and stereo model in one go
vw_out() << "\t--> Generating a 3D point cloud. " << std::endl;
ImageViewRef<Vector4> point_cloud;
@@ -399,7 +397,7 @@ void stereo_triangulation( Options const& opt ) {
int main( int argc, char* argv[] ) {
stereo_register_sessions();
-
+
Options opt;
try {
handle_arguments( argc, argv, opt,
@@ -407,7 +405,7 @@ int main( int argc, char* argv[] ) {
// Internal Processes
//---------------------------------------------------------
-
+
if (opt.stereo_session_string != "rpc"){
stereo_triangulation<stereo::StereoModel>( opt );
}else{

0 comments on commit c6473f5

Please sign in to comment.
Something went wrong with that request. Please try again.