diff --git a/dlib/geometry/point_transforms.h b/dlib/geometry/point_transforms.h index 2c73ef48e..f3ea0da80 100644 --- a/dlib/geometry/point_transforms.h +++ b/dlib/geometry/point_transforms.h @@ -853,13 +853,14 @@ namespace dlib inline dpoint operator() ( const vector& p, - double& scale + double& scale, + double& distance ) const { vector temp = p-camera_pos; temp = proj*temp; - const double distance = temp.z()>0 ? temp.z() : 1e-9; - scale = dist_scale/distance; + distance = temp.z(); + scale = dist_scale/(temp.z()>0 ? temp.z() : 1e-9); temp.x() = temp.x()*scale + width; temp.y() = temp.y()*scale + width; return temp; @@ -869,8 +870,8 @@ namespace dlib const vector& p ) const { - double scale; - return (*this)(p,scale); + double scale, distance; + return (*this)(p,scale,distance); } inline friend void serialize (const camera_transform& item, std::ostream& out) diff --git a/dlib/geometry/point_transforms_abstract.h b/dlib/geometry/point_transforms_abstract.h index 41d5995c2..878c09288 100644 --- a/dlib/geometry/point_transforms_abstract.h +++ b/dlib/geometry/point_transforms_abstract.h @@ -644,7 +644,8 @@ namespace dlib dpoint operator() ( const vector& p, - double& scale + double& scale, + double& distance ) const; /*! ensures @@ -654,6 +655,9 @@ namespace dlib - #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. + - #distance == how far away the point is from the image plane. Objects in + front of the camera will have a positive distance and those behind a + negative distance. !*/ vector get_camera_pos(