Skip to content
This repository
Browse code

RPC: Clean up whitespace

  • Loading branch information...
commit c6473f5f2e45a3fb7554a05076603f699fe05cb9 1 parent 3061be0
Zack Moratto zmoratto authored
42 src/asp/Sessions/RPC/RPCModel.cc
@@ -77,7 +77,7 @@ namespace asp {
77 77 Vector2 const& xy_scale,
78 78 Vector3 const& lonlatheight_offset,
79 79 Vector3 const& lonlatheight_scale ) :
80   - m_datum(datum), m_line_num_coeff(line_num_coeff),
  80 + m_datum(datum), m_line_num_coeff(line_num_coeff),
81 81 m_line_den_coeff(line_den_coeff), m_sample_num_coeff(samp_num_coeff),
82 82 m_sample_den_coeff(samp_den_coeff), m_xy_offset(xy_offset),
83 83 m_xy_scale(xy_scale), m_lonlatheight_offset(lonlatheight_offset),
@@ -97,19 +97,19 @@ namespace asp {
97 97 elem_quot(geodetic - m_lonlatheight_offset, m_lonlatheight_scale);
98 98
99 99 Vector2 normalized_pixel = normalized_geodetic_to_normalized_pixel( normalized_geodetic );
100   -
  100 +
101 101 return elem_prod( normalized_pixel, m_xy_scale ) + m_xy_offset;
102 102 }
103 103
104 104 Vector2 RPCModel::normalized_geodetic_to_normalized_pixel( Vector3 const& normalized_geodetic ) const {
105 105
106 106 CoeffVec term = calculate_terms( normalized_geodetic );
107   -
  107 +
108 108 Vector2 normalized_pixel( dot_prod(term,m_sample_num_coeff) /
109 109 dot_prod(term,m_sample_den_coeff),
110 110 dot_prod(term,m_line_num_coeff) /
111 111 dot_prod(term,m_line_den_coeff) );
112   -
  112 +
113 113 return normalized_pixel;
114 114 }
115 115
@@ -178,7 +178,7 @@ namespace asp {
178 178
179 179 vw::Matrix<double, 20, 3> RPCModel::terms_Jacobian3( vw::Vector3 const& normalized_geodetic ) {
180 180 // Partial derivatives of the terms returned by the
181   - // calculate_terms() function in respect to all three
  181 + // calculate_terms() function in respect to all three
182 182 // variables only (unlike the terms_Jacobian2() function).
183 183
184 184 vw::Matrix<double, 20, 3> M;
@@ -263,13 +263,13 @@ namespace asp {
263 263
264 264 // This function is different from geodetic_to_pixel_Jacobian() in
265 265 // several respects:
266   -
  266 +
267 267 // 1. The input is the normalized geodetic, and the derivatives
268 268 // are in respect to the normalized geodetic as well.
269   -
  269 +
270 270 // 2. The derivatives are taken only in respect to the first two
271 271 // variables (normalized lon and lat, no height).
272   -
  272 +
273 273 // 3. The output is in normalized pixels (see m_xy_scale and m_xy_offset).
274 274
275 275 CoeffVec term = calculate_terms( normalized_geodetic );
@@ -296,7 +296,7 @@ namespace asp {
296 296 Matrix<double, 2, 3> J;
297 297
298 298 Vector2 B = geodetic_to_pixel(geodetic);
299   -
  299 +
300 300 Vector2 B0 = (geodetic_to_pixel(geodetic + Vector3(tol, 0, 0 )) - B)/tol;
301 301 Vector2 B1 = (geodetic_to_pixel(geodetic + Vector3(0, tol, 0 )) - B)/tol;
302 302 Vector2 B2 = (geodetic_to_pixel(geodetic + Vector3(0, 0, tol)) - B)/tol;
@@ -304,10 +304,10 @@ namespace asp {
304 304 select_col(J, 0) = B0;
305 305 select_col(J, 1) = B1;
306 306 select_col(J, 2) = B2;
307   -
  307 +
308 308 return J;
309 309 }
310   -
  310 +
311 311 Vector2 RPCModel::image_to_ground( Vector2 const& pixel, double height, Vector2 lonlat_guess ) const {
312 312
313 313 // Given a pixel (the projection of a point onto the camera image)
@@ -316,10 +316,10 @@ namespace asp {
316 316 // for the lonlat.
317 317
318 318 // The absolute tolerance is experimental, needs more investigation
319   - double abs_tolerance = 1e-6;
  319 + double abs_tolerance = 1e-6;
320 320
321 321 Vector2 normalized_pixel = elem_quot(pixel - m_xy_offset, m_xy_scale);
322   -
  322 +
323 323 // Initial guess for the normalized lon and lat
324 324 if (lonlat_guess == Vector2(0.0, 0.0)){
325 325 lonlat_guess = subvector(m_lonlatheight_offset, 0, 2);
@@ -332,7 +332,7 @@ namespace asp {
332 332 // If the input guess is NaN or unreasonable, use 0 as initial guess
333 333 normalized_lonlat = Vector2(0.0, 0.0);
334 334 }
335   -
  335 +
336 336 // 10 iterations should be enough for Newton's method to converge
337 337 for (int iter = 0; iter < 10; iter++){
338 338
@@ -340,7 +340,7 @@ namespace asp {
340 340 normalized_geodetic[0] = normalized_lonlat[0];
341 341 normalized_geodetic[1] = normalized_lonlat[1];
342 342 normalized_geodetic[2] = (height - m_lonlatheight_offset[2])/m_lonlatheight_scale[2];
343   -
  343 +
344 344 Vector2 p = normalized_geodetic_to_normalized_pixel(normalized_geodetic);
345 345 Matrix<double, 2, 2> J = normalized_geodetic_to_pixel_Jacobian(normalized_geodetic);
346 346
@@ -363,23 +363,23 @@ namespace asp {
363 363 if (norm_try < abs_tolerance) {
364 364 break;
365 365 }
366   -
  366 +
367 367 }
368 368
369 369 Vector2 lonlat
370 370 = elem_prod( normalized_lonlat,
371 371 subvector(m_lonlatheight_scale, 0, 2) )
372 372 + subvector(m_lonlatheight_offset, 0, 2);
373   -
  373 +
374 374 return lonlat;
375   -
  375 +
376 376 }
377 377
378 378 void RPCModel::point_and_dir(Vector2 const& pix, Vector3 & P, Vector3 & dir ) const {
379 379
380 380 // Find a point which gets projected onto the current pixel,
381 381 // and the direction of the ray going through that point.
382   -
  382 +
383 383 double height_up = m_lonlatheight_offset[2];
384 384 double height_dn = m_lonlatheight_offset[2] - m_lonlatheight_scale[2];
385 385
@@ -389,7 +389,7 @@ namespace asp {
389 389 // Cache these for the future
390 390 m_lonlat_guess_up = lonlat_up;
391 391 m_lonlat_guess_dn = lonlat_dn;
392   -
  392 +
393 393 Vector3 geo_up = Vector3(lonlat_up[0], lonlat_up[1], height_up);
394 394 Vector3 geo_dn = Vector3(lonlat_dn[0], lonlat_dn[1], height_dn);
395 395
@@ -407,7 +407,7 @@ namespace asp {
407 407 point_and_dir(pix, P, dir);
408 408 return P;
409 409 }
410   -
  410 +
411 411 Vector3 RPCModel::pixel_to_vector(Vector2 const& pix ) const {
412 412 // Find the normalized direction of the ray back-projected through
413 413 // the camera from the current pixel.
8 src/asp/Sessions/RPC/RPCModel.h
@@ -21,7 +21,7 @@
21 21 // 3D Feature Extraction from Multiple Satellite Images Described by
22 22 // RPCs." Proceedings of ASPRS 2004 Conference, Denver, Colorado, May,
23 23 // 2004.
24   -
  24 +
25 25 #ifndef __STEREO_SESSION_RPC_MODEL_H__
26 26 #define __STEREO_SESSION_RPC_MODEL_H__
27 27
@@ -42,7 +42,7 @@ namespace asp {
42 42 vw::Vector3 m_lonlatheight_offset;
43 43 vw::Vector3 m_lonlatheight_scale;
44 44 mutable vw::Vector2 m_lonlat_guess_up, m_lonlat_guess_dn;
45   -
  45 +
46 46 void initialize( vw::DiskImageResourceGDAL* resource );
47 47 public:
48 48 RPCModel( std::string const& filename );
@@ -95,9 +95,9 @@ namespace asp {
95 95 vw::Matrix<double, 2, 2> normalized_geodetic_to_pixel_Jacobian(vw::Vector3 const& normalized_geodetic ) const;
96 96 vw::Vector2 image_to_ground(vw::Vector2 const& pixel, double height,
97 97 vw::Vector2 lonlat_guess = vw::Vector2(0.0, 0.0)) const;
98   -
  98 +
99 99 void point_and_dir(vw::Vector2 const& pix, vw::Vector3 & P, vw::Vector3 & dir ) const;
100   -
  100 +
101 101 };
102 102
103 103 inline std::ostream& operator<<(std::ostream& os, const RPCModel& rpc) {
14 src/asp/Sessions/RPC/RPCStereoModel.cc
@@ -48,7 +48,7 @@ namespace asp {
48 48 submatrix(J, 2, 0, 2, 3) = m_rpc_model2->geodetic_to_pixel_Jacobian(x);
49 49 return J;
50 50 }
51   -
  51 +
52 52 };
53 53 }
54 54
@@ -72,12 +72,12 @@ namespace asp {
72 72
73 73 Vector3 origin2, vec2;
74 74 rpc_model2->point_and_dir(pix2, origin2, vec2);
75   -
  75 +
76 76 if (are_nearly_parallel(vec1, vec2)){
77 77 error = 0.0;
78 78 return Vector3();
79 79 }
80   -
  80 +
81 81 result = triangulate_point(origin1, vec1,
82 82 origin2, vec2,
83 83 error);
@@ -85,13 +85,13 @@ namespace asp {
85 85 if ( m_least_squares ){
86 86
87 87 // Refine triangulation
88   -
  88 +
89 89 detail::RPCTriangulateLMA model(rpc_model1, rpc_model2);
90 90 Vector4 objective( pix1[0], pix1[1], pix2[0], pix2[1] );
91 91 int status = 0;
92 92
93 93 Vector3 initialGeodetic = rpc_model1->datum().cartesian_to_geodetic(result);
94   -
  94 +
95 95 // To do: Find good values for the numbers controlling the convergence
96 96 Vector3 finalGeodetic = levenberg_marquardt( model, initialGeodetic,
97 97 objective, status, 1e-3, 1e-6, 10 );
@@ -103,9 +103,9 @@ namespace asp {
103 103 return result;
104 104
105 105 } catch (...) {}
106   -
  106 +
107 107 error = 0.0;
108 108 return Vector3();
109 109 }
110   -
  110 +
111 111 } // namespace asp
5 src/asp/Sessions/RPC/RPCStereoModel.h
@@ -32,7 +32,7 @@ namespace vw {
32 32 namespace asp {
33 33
34 34 class RPCStereoModel: public vw::stereo::StereoModel {
35   -
  35 +
36 36 public:
37 37
38 38 //------------------------------------------------------------------
@@ -42,7 +42,7 @@ namespace asp {
42 42 vw::camera::CameraModel const* camera_model2,
43 43 bool least_squares_refine = false):
44 44 vw::stereo::StereoModel(camera_model1, camera_model2, least_squares_refine){}
45   -
  45 +
46 46 //------------------------------------------------------------------
47 47 // Public Methods
48 48 //------------------------------------------------------------------
@@ -59,4 +59,3 @@ namespace asp {
59 59 } // namespace asp
60 60
61 61 #endif // __ASP_RPC_RPCSTEREOMODEL_H__
62   -
2  src/asp/Sessions/RPC/StereoSessionRPC.cc
@@ -40,5 +40,5 @@ namespace asp {
40 40 std::string const& camera_file ) {
41 41 return boost::shared_ptr<camera::CameraModel>(StereoSessionDG::read_rpc_model(image_file, camera_file));
42 42 }
43   -
  43 +
44 44 } // namespace asp
24 src/asp/Tools/stereo_tri.cc
@@ -59,15 +59,15 @@ class StereoAndErrorView : public ImageViewBase<StereoAndErrorView<DisparityImag
59 59
60 60 template <class T>
61 61 inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value == 1),Vector3>::type
62   - StereoModelHelper( StereoModelT const& model, Vector2 const& index,
63   - T const& disparity, double& error ) const {
  62 + StereoModelHelper( StereoModelT const& model, Vector2 const& index,
  63 + T const& disparity, double& error ) const {
64 64 return model( index, Vector2( index[0] + disparity, index[1] ), error );
65 65 }
66 66
67 67 template <class T>
68 68 inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value != 1),Vector3>::type
69   - StereoModelHelper( StereoModelT const& model, Vector2 const& index,
70   - T const& disparity, double& error ) const {
  69 + StereoModelHelper( StereoModelT const& model, Vector2 const& index,
  70 + T const& disparity, double& error ) const {
71 71 return model( index, Vector2( index[0] + disparity[0],
72 72 index[1] + disparity[1] ), error );
73 73 }
@@ -139,14 +139,14 @@ class StereoLUTAndErrorView : public ImageViewBase<StereoLUTAndErrorView<Dispari
139 139
140 140 template <class T>
141 141 inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value == 1),Vector3>::type
142   - StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
  142 + StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
143 143 return m_stereo_model( m_lut_image1(i,j),
144 144 m_lut_image2( float(i) + disparity, j ), error );
145 145 }
146 146
147 147 template <class T>
148 148 inline typename boost::enable_if_c<IsCompound<T>::value && (CompoundNumChannels<typename UnmaskedPixelType<T>::type>::value != 1),Vector3>::type
149   - StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
  149 + StereoModelHelper( size_t i, size_t j, T const& disparity, double& error ) const {
150 150
151 151 float i2 = float(i) + disparity[0];
152 152 float j2 = float(j) + disparity[1];
@@ -224,7 +224,7 @@ class StereoLUTAndErrorView : public ImageViewBase<StereoLUTAndErrorView<Dispari
224 224 preraster = BBox2i(bbox.min() + floor(Vector2f(input_min[0],input_min[1])),
225 225 bbox.max() + ceil(Vector2(input_max[0],input_max[1])) );
226 226 }
227   -
  227 +
228 228 return prerasterize_type( disparity_preraster,
229 229 m_lut_image1.prerasterize(bbox),
230 230 m_lut_image2_org.prerasterize(preraster),
@@ -287,7 +287,7 @@ void stereo_triangulation( Options const& opt ) {
287 287
288 288 boost::shared_ptr<camera::CameraModel> camera_model1, camera_model2;
289 289 opt.session->camera_models(camera_model1, camera_model2);
290   -
  290 +
291 291 #if HAVE_PKG_VW_BUNDLEADJUSTMENT
292 292 // If the user has generated a set of position and pose
293 293 // corrections using the bundle_adjust program, we read them in
@@ -324,12 +324,11 @@ void stereo_triangulation( Options const& opt ) {
324 324
325 325 if (opt.stereo_session_string == "rpc")
326 326 vw_throw(InputErr() << "Stereo with RPC cameras cannot have the camera as the universe center.\n");
327   -
  327 +
328 328 universe_radius_func =
329 329 stereo::UniverseRadiusFunc(camera_model1->camera_center(Vector2()),
330 330 stereo_settings().near_universe_radius,
331 331 stereo_settings().far_universe_radius);
332   -
333 332 } else if ( stereo_settings().universe_center == "zero" ) {
334 333 universe_radius_func =
335 334 stereo::UniverseRadiusFunc(Vector3(),
@@ -337,7 +336,6 @@ void stereo_triangulation( Options const& opt ) {
337 336 stereo_settings().far_universe_radius);
338 337 }
339 338
340   -
341 339 // Apply radius function and stereo model in one go
342 340 vw_out() << "\t--> Generating a 3D point cloud. " << std::endl;
343 341 ImageViewRef<Vector4> point_cloud;
@@ -399,7 +397,7 @@ void stereo_triangulation( Options const& opt ) {
399 397 int main( int argc, char* argv[] ) {
400 398
401 399 stereo_register_sessions();
402   -
  400 +
403 401 Options opt;
404 402 try {
405 403 handle_arguments( argc, argv, opt,
@@ -407,7 +405,7 @@ int main( int argc, char* argv[] ) {
407 405
408 406 // Internal Processes
409 407 //---------------------------------------------------------
410   -
  408 +
411 409 if (opt.stereo_session_string != "rpc"){
412 410 stereo_triangulation<stereo::StereoModel>( opt );
413 411 }else{

0 comments on commit c6473f5

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