15 vnl_double_2
const& image_point,
16 vnl_double_4
const& plane,
17 vnl_double_3
const& initial_guess,
18 vnl_double_3& world_point,
20 double relative_diameter)
23 if (cam->
type_name()==
"vpgl_generic_camera")
29 ray = gcam->ray(image_point[0], image_point[1]);
30 if (!vgl_intersection<double>(ray, gplane, ipt))
32 world_point[0]=ipt.
x(); world_point[1]=ipt.
y(); world_point[2]=ipt.
z();
37 vnl_double_2 x1(0.000, 0.0000);
47 double u=0,
v=0, X=world_point[0], Y=world_point[1], Z=world_point[2];
49 vnl_double_2 final_proj;
50 final_proj[0]=u; final_proj[1]=
v;
51 double err = (final_proj-image_point).magnitude();
55 std::cerr <<
"ERROR: backprojection error = " << err << std::endl;
70 double relative_diameter)
76 ipt[0]=image_point.
x(); ipt[1]=image_point.
y();
77 pl[0]=plane.
a(); pl[1]=plane.
b(); pl[2]=plane.
c(); pl[3]=plane.
d();
78 ig[0]=initial_guess.
x(); ig[1]=initial_guess.
y(); ig[2]=initial_guess.
z();
80 world_point.
set(wp[0], wp[1], wp[2]);
87 vnl_double_2
const& image_point,
88 vnl_double_4
const& plane,
89 vnl_double_3
const& initial_guess,
90 vnl_double_3& world_point,
92 double relative_diameter)
95 return bproj_plane(cam, image_point, plane, initial_guess, world_point, error_tol, relative_diameter);
105 double relative_diameter)
108 return bproj_plane(cam, image_point, plane, initial_guess, world_point, error_tol, relative_diameter);
138 double relative_diameter)
143 constexpr
double z_off = 10.0;
147 if (!
bproj_plane(cam, img_pt, plane_high, guess, point_high, error_tol, relative_diameter)) {
151 to_camera = point_high - point;
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_zero_term_delta(double d)
void set_max_iterations(int n)
void set_params(vnl_vector_fixed< double, 3 > const &xyz, vnl_vector_fixed< double, 2 > &x)
set the parameter values from the 3-d point.
void point_3d(vnl_vector_fixed< double, 2 > const &x, vnl_vector_fixed< double, 3 > &xyz)
get the 3-d point defined by the parameters (and the plane).
void minimize(vnl_vector< double > &x)
static bool bproj_point_vector(vpgl_proj_camera< double > const &cam, vgl_point_2d< double > const &point, vgl_vector_2d< double > const &vect, vgl_plane_3d< double > &plane)
Backproject a point with associated direction vector in the image to a plane in 3-d,...
virtual vgl_homg_line_3d_2_points< T > backproject(const vgl_homg_point_2d< T > &image_point) const
Find the 3d ray that goes through the camera center and the provided image point.
void set_relative_diameter(double r)
virtual std::string type_name() const
class identity functions for casting.
virtual void project(const T x, const T y, const T z, T &u, T &v) const =0
The generic camera interface. u represents image column, v image row.
static bool direction_to_camera(vpgl_local_rational_camera< double > const &cam, vgl_point_3d< double > const &point, vgl_vector_3d< double > &to_camera, double error_tol=0.05, double relative_diameter=1.0)
Use backprojection to determine direction to camera from 3-d point.
void set(Type px, Type py, Type pz)
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.