Skip to content

Commit

Permalink
Made the camera_transform output the point's distance.
Browse files Browse the repository at this point in the history
  • Loading branch information
davisking committed Jun 2, 2015
1 parent 1294d6d commit acca22a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions dlib/geometry/point_transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,14 @@ namespace dlib

inline dpoint operator() (
const vector<double>& p,
double& scale
double& scale,
double& distance
) const
{
vector<double> 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;
Expand All @@ -869,8 +870,8 @@ namespace dlib
const vector<double>& 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)
Expand Down
6 changes: 5 additions & 1 deletion dlib/geometry/point_transforms_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ namespace dlib

dpoint operator() (
const vector<double>& p,
double& scale
double& scale,
double& distance
) const;
/*!
ensures
Expand All @@ -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<double> get_camera_pos(
Expand Down

0 comments on commit acca22a

Please sign in to comment.