8 # include <vcl_msvc_warnings.h> 22 unsigned num_unknowns,
unsigned num_residuals)
25 rcam_(rcam), img_pts_(img_pts), geo_pts_(std::move(geo_pts))
27 num_corrs_ = static_cast<unsigned>(img_pts.size());
44 std::cout <<
"x(" << unknowns[0] <<
' ' << unknowns[1] <<
")\n" 45 <<
"y(" << unknowns[2] <<
' ' << unknowns[3] <<
")\n" 46 <<
"z(" << unknowns[4] <<
' ' << unknowns[5] <<
")\n";
58 projection_error[ir++] = (pp.
x()-c.
x())*(pp.
x()-c.
x());
59 projection_error[ir++] = (pp.
y()-c.
y())*(pp.
y()-c.
y());
62 projection_error[ir++] = std::fabs(pp.
x()-c.
x());
63 projection_error[ir++] = std::fabs(pp.
y()-c.
y());
65 std::cout <<
"perror[" << i <<
"](" << projection_error[ir-2] <<
' ' 66 << projection_error[ir-1] <<
")\n";
83 auto npts = static_cast<unsigned>( img_pts.size() );
86 for (
unsigned i = 0; i<npts; ++i)
87 zoff += geo_pts[i].z();
97 double xshift = 0, yshift = 0;
99 for (
unsigned i = 0; i<npts; ++i)
106 xshift += geo_pts[i].
x()- bp_pt.
x();
107 yshift += geo_pts[i].y()- bp_pt.
y();
109 xoff = xo + xshift/npts;
110 yoff = yo + yshift/npts;
123 double xoff=0, yoff=0, zoff=0;
124 if (!initial_offsets(initial_rcam, img_pts, geo_pts, xoff, yoff, zoff))
126 auto num_corrs = static_cast<unsigned>( img_pts.size() );
127 unsigned num_unknowns = 3;
128 unsigned num_residuals = num_corrs*2;
131 num_unknowns, num_residuals);
175 std::cout <<
"Min error of " << levmarq.
get_end_error() <<
" at the following local minima : " <<
'\n';
178 adj_rcam = initial_rcam;
186 for (
unsigned i = 0; i<num_corrs; ++i)
190 double d = vgl_distance<double>(c, pp);
191 std::cout <<
"p[" << i <<
"]->(" << pp.
x() <<
' ' << pp.
y() <<
")\n" 192 <<
"c(" << c.
x() <<
' ' << c.
y() <<
"): " << d <<
'\n';
void set_f_tolerance(double v)
std::vector< vgl_point_2d< double > > img_pts_
vpgl_rational_camera< double > rcam_
vpgl_adjust_lsqr(vpgl_rational_camera< double > const &rcam, std::vector< vgl_point_2d< double > > const &img_pts, std::vector< vgl_point_3d< double > > geo_pts, unsigned num_unknowns, unsigned num_residuals)
Constructor.
The 3-d offset and scale parameters of rational cameras typically must be adjusted to compensate for ...
static bool adjust(vpgl_rational_camera< double > const &initial_rcam, std::vector< vgl_point_2d< double > > img_pts, std::vector< vgl_point_3d< double > > geo_pts, vpgl_rational_camera< double > &adj_rcam)
A function adjust the rational camera 3-d scales and offsets.
double get_end_error() const
void set_verbose(bool verb)
void set_scale(const coor_index coor_index, const T scale)
set a specific scale value.
void set_offset(const coor_index coor_index, const T offset)
set a specific scale value.
Adjust 3-d offset and scale to align rational cameras to geolocations.
void set_max_function_evals(int v)
void f(vnl_vector< double > const &x, vnl_vector< double > &fx) override
The main function.
Find the 3-d point closest to the intersection of rays from >= 2 cameras.
void set_epsilon_function(double v)
T scale(const coor_index coor_index) const
get a specific scale value.
void diagnose_outcome() const
T offset(const coor_index coor_index) const
get a specific offset value.
bool minimize(vnl_vector< double > &x)
static bool bproj_plane(const vpgl_camera< double > *cam, vnl_double_2 const &image_point, vnl_double_4 const &plane, vnl_double_3 const &initial_guess, vnl_double_3 &world_point, double error_tol=0.05, double relative_diameter=1.0)
Generic camera interfaces (pointer for abstract class).
Methods for back_projecting from cameras to 3-d geometric structures.
std::vector< vgl_point_3d< double > > geo_pts_
void project(const T x, const T y, const T z, T &u, T &v) const override
The generic camera interface. u represents image column, v image row.
void set_x_tolerance(double v)