Commit 73231f43 authored by Davis King's avatar Davis King

Added an optional scale output to the camera_transform.

parent a8055361
...@@ -842,19 +842,28 @@ namespace dlib ...@@ -842,19 +842,28 @@ namespace dlib
double get_camera_field_of_view() const { return camera_field_of_view; } double get_camera_field_of_view() const { return camera_field_of_view; }
unsigned long get_num_pixels() const { return num_pixels; } unsigned long get_num_pixels() const { return num_pixels; }
dpoint operator() ( inline dpoint operator() (
const vector<double>& p const vector<double>& p,
double& scale
) const ) const
{ {
vector<double> temp = p-camera_pos; vector<double> temp = p-camera_pos;
temp = proj*temp; temp = proj*temp;
const double distance = temp.z()>0 ? temp.z() : 1e-9; const double distance = temp.z()>0 ? temp.z() : 1e-9;
const double scale = dist_scale/distance; scale = dist_scale/distance;
temp.x() = temp.x()*scale + width; temp.x() = temp.x()*scale + width;
temp.y() = temp.y()*scale + width; temp.y() = temp.y()*scale + width;
return temp; return temp;
} }
dpoint operator() (
const vector<double>& p
) const
{
double scale;
return (*this)(p,scale);
}
inline friend void serialize (const camera_transform& item, std::ostream& out) inline friend void serialize (const camera_transform& item, std::ostream& out)
{ {
serialize(item.camera_pos, out); serialize(item.camera_pos, out);
......
...@@ -632,6 +632,20 @@ namespace dlib ...@@ -632,6 +632,20 @@ namespace dlib
plane is returned. plane is returned.
!*/ !*/
dpoint operator() (
const vector<double>& p,
double& scale
) const;
/*!
ensures
- Maps the given 3D point p into the 2D image plane defined by the camera
parameters given to this object's constructor. The 2D point in the image
plane is returned.
- #scale == a number that tells you how large things are at the point p.
Objects further from the camera appear smaller, in particular, they
appear #scale times their normal size.
!*/
vector<double> get_camera_pos( vector<double> get_camera_pos(
) const; ) const;
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment