Skip to content

Commit

Permalink
LinescanModelLMA: Move to its own file, not used only for linescan
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Apr 7, 2016
1 parent efc79cc commit 9ba961b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 40 deletions.
5 changes: 0 additions & 5 deletions src/vw/Camera/CameraSolve.h
Expand Up @@ -18,11 +18,6 @@

/// \file CameraSolve.h
///
/// Contains assorted functions for solving for camera matrices.
/// This is an expansion on Math/Geometry.h but requires that
/// container p1 is Vector3 and container p2 is Vector4 since
/// cameras map 3D points to 2D locations.
///
#ifndef __CAMERA_CAMERA_SOLVE_H__
#define __CAMERA_CAMERA_SOLVE_H__

Expand Down
8 changes: 4 additions & 4 deletions src/vw/Camera/LinescanModel.cc
Expand Up @@ -16,21 +16,21 @@
// __END_LICENSE__

#include <vw/Camera/LinescanModel.h>
#include <vw/Camera/CameraSolve.h>

namespace vw {
namespace camera {

Vector2 LinescanModel
::point_to_pixel(Vector3 const& point) const {
return point_to_pixel(point, -1); // Redirect to other function with no guess
Vector2 LinescanModel::point_to_pixel(Vector3 const& point) const {
return point_to_pixel(point, -1); // Redirect to thefunction with no guess
}


Vector2 LinescanModel::point_to_pixel(Vector3 const& point, double starty) const {

// Use the generic solver to find the pixel
// - This method will be slower but works for more complicated geometries
LinescanGenericLMA model( this, point );
CameraGenericLMA model( this, point );
int status;
Vector2 start = m_image_size / 2.0; // Use the center as the initial guess
if (starty >= 0) // If the user provided a line number guess..
Expand Down
31 changes: 0 additions & 31 deletions src/vw/Camera/LinescanModel.h
Expand Up @@ -139,37 +139,6 @@ namespace camera {
Vector3 apply_velocity_aberration_correction(Vector2 const& pixel,
Vector3 const& uncorrected_vector) const;

protected:

// Levenberg Marquardt solver for linescan number (y) and pixel
// number (x) for the given point in space. The obtained solution
// pixel (x, y) must be such that the vector from this camera
// pixel goes through the given point. This version does uses only
// functions declared in LinescanModel class and should work for
// any LineScan camera. Some cameras may be able to use a faster
// implementation that solves for y first and then for x seperately.
class LinescanGenericLMA : public math::LeastSquaresModelBase<LinescanGenericLMA> {
const LinescanModel* m_model;
Vector3 m_point;
public:
typedef Vector2 domain_type; // 2D pixel, input to cost function vector
typedef Vector3 result_type; // 3D error, output of cost function vector
typedef Matrix<double, 3, 2> jacobian_type;

LinescanGenericLMA( const LinescanModel* model, const vw::Vector3& pt ) :
m_model(model), m_point(pt) {}

// Minimize the difference between the vector from the pixel and
// the vector from the point to the camera.
inline result_type operator()( domain_type const& pix ) const {
try {
return m_model->pixel_to_vector(pix) - normalize(m_point - m_model->camera_center(pix));
} catch(...) { // Handle camera misses by returning a very large error
return Vector3(999999,999999,999999);
}
}
}; // End class LinescanGenericLMA

}; // End class LinescanModel

/*
Expand Down
1 change: 1 addition & 0 deletions src/vw/Camera/Makefile.am
Expand Up @@ -30,6 +30,7 @@ endif
if HAVE_PKG_LAPACK
lapack_headers = \
CameraGeometry.h \
CameraSolve.h \
Extrinsics.h \
LensDistortion.h \
LinescanModel.h \
Expand Down

0 comments on commit 9ba961b

Please sign in to comment.