LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::DistanceFromPixel Class Reference

This class derives the 3D position of an object from a 2D image point. More...

#include <ltiDistanceFromPixel.h>

Inheritance diagram for lti::DistanceFromPixel:
Inheritance graph
[legend]
Collaboration diagram for lti::DistanceFromPixel:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class DistanceFromPixel. More...

Public Member Functions

 DistanceFromPixel ()
 DistanceFromPixel (const parameters &par)
 DistanceFromPixel (const DistanceFromPixel &other)
virtual ~DistanceFromPixel ()
virtual const char * getTypeName () const
bool apply (const vector< int > &src, vector< float > &dest) const
bool apply (const vector< int > &src, float &dest) const
DistanceFromPixelcopy (const DistanceFromPixel &other)
DistanceFromPixeloperator= (const DistanceFromPixel &other)
virtual functorclone () const
const parametersgetParameters () const

Detailed Description

This class derives the 3D position of an object from a 2D image point.

Obviously we have to make some assumptions at first to get this to work.
First of all we are calculating the distance between a camera positioned at an arbitrary height and an object standing on a flat floor. We also assume that the optical axis of the camera is parallel to the floor.

Different parameters of the camera have to be known:

So here is some example code. The camera axis is not directly aligned along the axis on which the distance should be calculated. It is rotated a little bit down to the floor. Thus, we also have to use the class lti::coordinateTransformation:

 lti::coordinateTransformation coordTransform;
 lti::coordinateTransformation::parameters transformParam;
 float b;
 float fDataDisplacement[3] =  { 0, 0, -7};
 lti::vector<float> vDisplace(3,fDataDisplacement);
 
 std::cout << "y angle of cam (beta):" << std::endl; 
 std::cin >> b;
 transformParam.initParameters(0,b,0,vDisplace);
 coordTransform.setParameters(transformParam);
    
 lti::DistanceFromPixel distance;
 lti::DistanceFromPixel::parameters distanceParam;      
 lti::vector<int> imgCoordinate(2,0); 
 lti::vector<float> spaceCoordinate(3,0);
 
 // parameters for the Sony EVI D100P
 distanceParam.fHeight=41.0f;
 distanceParam.iPictureSizeX=379;   // x
 distanceParam.iPictureSizeY=262;   // y
 distanceParam.fD=19.07f;           // focal length in cm
 distanceParam.fKx=0.0555f;         // camera const in x-direction cm/pixel
 distanceParam.fKy=0.0555f;         // camera const in y-direction cm/pixel
 
 std::cout << "x coordinate of object on floor in pixel (integer) :";
 std::cin  >> imgCoordinate[0];
 std::cout << std::endl;
 std::cout << "y coordinate of object on floor in pixel (integer) :";
 std::cin  >> imgCoordinate[1];
 std::cout << std::endl;

 distance.setParameters(distanceParam);
 distance.apply(imgCoordinate,spaceCoordinate);
 std::cout << "3D coordinates of object in camera system: " << spaceCoordinate << std::endl;

 float eucliddist=0;
 distance.apply(imgCoordinate,eucliddist);
 std::cout << "Euclidian distance between object and camera: " << eucliddist << std::endl;

 std::cout << "Point " << spaceCoordinate << " in the camera coordinate system" << std::endl;
 coordTransform.apply(spaceCoordinate);
 std::cout << "has position " << spaceCoordinate << " in the global coordinate system." << std::endl;

Constructor & Destructor Documentation

lti::DistanceFromPixel::DistanceFromPixel (  ) 

Default constructor.

lti::DistanceFromPixel::DistanceFromPixel ( const parameters par  ) 

Construct a functor using the given parameters.

lti::DistanceFromPixel::DistanceFromPixel ( const DistanceFromPixel other  ) 

Copy constructor.

Parameters:
other the object to be copied
virtual lti::DistanceFromPixel::~DistanceFromPixel (  )  [virtual]

Destructor.


Member Function Documentation

bool lti::DistanceFromPixel::apply ( const vector< int > &  src,
float &  dest 
) const

This method calculates the euclidian distance between the 3D space position point of an image point and the camera.

The requirements needed for this to work are described above in the detailed description of this class.

Parameters:
src lti::vector<int> src(2,0)
dest float dest
Returns:
true if apply successful or false otherwise.
bool lti::DistanceFromPixel::apply ( const vector< int > &  src,
vector< float > &  dest 
) const

This method calculates the corresponding 3D space point from an 2D image point The requirements needed for this to work are described above in the detailed description of this class.

Parameters:
src lti::vector<int> src(2,0)
dest lti::vector<int> dest(3,0)
Returns:
true if apply successful or false otherwise.
virtual functor* lti::DistanceFromPixel::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements lti::functor.

DistanceFromPixel& lti::DistanceFromPixel::copy ( const DistanceFromPixel other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

const parameters& lti::DistanceFromPixel::getParameters (  )  const

Returns used parameters.

Reimplemented from lti::functor.

virtual const char* lti::DistanceFromPixel::getTypeName (  )  const [virtual]

Returns the name of this type ("DistanceFromPixel").

Reimplemented from lti::functor.

DistanceFromPixel& lti::DistanceFromPixel::operator= ( const DistanceFromPixel other  ) 

Alias for copy member.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:28:14 2010 for LTI-Lib by Doxygen 1.6.1