GSoC2011SfM  0.1
Google Summer of Code 2011: Structure from motion
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
OpencvSfM::PointsToTrack Class Reference

This class can be used to store informations about point and features. This is an abstract class: you can't use it directly. Use for instance PointsToTrackWithImage. More...

#include <PointsToTrack.h>

Inheritance diagram for OpencvSfM::PointsToTrack:
OpencvSfM::PointsToTrackWithImage

List of all members.

Public Member Functions

 PointsToTrack (int corresponding_image=-1, std::vector< cv::KeyPoint > keypoints=std::vector< cv::KeyPoint >(0), cv::Mat descriptors=cv::Mat())
virtual ~PointsToTrack (void)
void free_descriptors (bool force=false)
int computeKeypointsAndDesc (bool forcing_recalculation=false)
int computeKeypoints ()
void computeDescriptors ()
void addKeypoints (std::vector< cv::KeyPoint > keypoints, cv::Mat descriptors=cv::Mat(), bool computeMissingDescriptor=false)
unsigned int addKeypoint (const cv::KeyPoint point, double min_dist=1.0)
std::vector< cv::KeyPoint > & getModifiableKeypoints ()
const std::vector< cv::KeyPoint > & getKeypoints () const
void getKeyMatches (const std::vector< TrackOfPoints > &matches, int otherImage, std::vector< cv::Point2f > &pointsVals) const
const cv::KeyPoint & getKeypoint (unsigned int index) const
size_t getClosestKeypoint (cv::Point2f point)
cv::Mat getDescriptors () const
cv::Mat getImage ()
void printPointsOnImage (const cv::Mat &image, cv::Mat &outImg, const cv::Scalar &color=cv::Scalar::all(-1), int flags=cv::DrawMatchesFlags::DEFAULT) const
unsigned int getColor (unsigned int index) const
void filterByDistance (double dist_min)

Static Public Member Functions

static void read (const cv::FileNode &node, PointsToTrack &points)
static void write (cv::FileStorage &fs, const PointsToTrack &points)

Protected Member Functions

 DECLARE_MUTEX (worker_exclusion)
virtual int impl_computeKeypoints_ ()
virtual void impl_computeDescriptors_ ()
void impl_filterByDistance_ (double dist_min)

Protected Attributes

unsigned int nb_workers_
std::vector< cv::KeyPoint > keypoints_
cv::Mat descriptors_
cv::Mat imageToAnalyse_
std::vector< unsigned int > RGB_values_
int corresponding_image_
 index of frame when available

Static Protected Attributes

static int glob_number_images_ = 0
 total numbers of images!

Detailed Description

This class can be used to store informations about point and features. This is an abstract class: you can't use it directly. Use for instance PointsToTrackWithImage.

To create a structure from motion, most methods use points to compute the structure. This class focus on the first task in SfM: find points in image which are easy to track... When available, a feature vector for each points is very helpful: the matching will be easier.

Definition at line 25 of file PointsToTrack.h.


Constructor & Destructor Documentation

OpencvSfM::PointsToTrack::PointsToTrack ( int  corresponding_image = -1,
std::vector< cv::KeyPoint >  keypoints = std::vector<cv::KeyPoint>( 0 ),
cv::Mat  descriptors = cv::Mat( ) 
)

this constructor create an object with available information...

Parameters:
corresponding_imageGlobal index of image
keypointsthe points we will try to track...
descriptorsthe feature vector for each points...

Definition at line 15 of file PointsToTrack.cpp.

OpencvSfM::PointsToTrack::~PointsToTrack ( void  ) [virtual]

Destructor : delete points and features vectors

Definition at line 42 of file PointsToTrack.cpp.


Member Function Documentation

unsigned int OpencvSfM::PointsToTrack::addKeypoint ( const cv::KeyPoint  point,
double  min_dist = 1.0 
) [inline]

This method is used to add a keypoint at the end of the points vector...

Parameters:
pointKeypoints to add
min_distminimumů distance between wanted point to add and any existing point... If below this threshold, the point will not being added and the index returned will be the index of the closest point...
Returns:
index of the added keypoint.

Definition at line 130 of file PointsToTrack.h.

void OpencvSfM::PointsToTrack::addKeypoints ( std::vector< cv::KeyPoint >  keypoints,
cv::Mat  descriptors = cv::Mat( ),
bool  computeMissingDescriptor = false 
)

This method is used to add Keypoints...

Parameters:
keypointsKeypoints to add
descriptorsof points, if any
computeMissingDescriptorif true, the missing descriptors are computed.

Definition at line 129 of file PointsToTrack.cpp.

void OpencvSfM::PointsToTrack::computeDescriptors ( )

This method is used to compute only descriptors...

Definition at line 121 of file PointsToTrack.cpp.

Referenced by addKeypoints().

int OpencvSfM::PointsToTrack::computeKeypoints ( )

This method is used to compute only Keypoints...

Returns:
the number of points

Definition at line 112 of file PointsToTrack.cpp.

int OpencvSfM::PointsToTrack::computeKeypointsAndDesc ( bool  forcing_recalculation = false)

This method is used to compute both Keypoints and descriptors...

Parameters:
forcing_recalculationif true previous keypoints are removed... If false and if keypoints and descriptor exists, nothing is done.
Returns:
the number of points

Definition at line 49 of file PointsToTrack.cpp.

Referenced by write().

OpencvSfM::PointsToTrack::DECLARE_MUTEX ( worker_exclusion  ) [protected]

As we want to be able to compute points using parallel execution, and as not every Opencv functions are thread safe, use this mutex to take care of critical portions.

void OpencvSfM::PointsToTrack::filterByDistance ( double  dist_min)

Use this function to filter point by distance between each other

Parameters:
dist_minminimum distance allowed between points

Definition at line 105 of file PointsToTrack.cpp.

Referenced by addKeypoints(), and computeKeypoints().

void OpencvSfM::PointsToTrack::free_descriptors ( bool  force = false)

To preserve memory, we use this method to free descriptors

Parameters:
forceif true, the descriptors are removed

Definition at line 29 of file PointsToTrack.cpp.

size_t OpencvSfM::PointsToTrack::getClosestKeypoint ( cv::Point2f  point)

this method return the closest points from parameter

Parameters:
pointcoordinate of the point to search for
Returns:
index of the point

Definition at line 248 of file PointsToTrack.cpp.

unsigned int OpencvSfM::PointsToTrack::getColor ( unsigned int  index) const [inline]

Use this function to get the color of a point

Parameters:
indexof the wanted point
Returns:
color packed into the ARGB format

Definition at line 215 of file PointsToTrack.h.

cv::Mat OpencvSfM::PointsToTrack::getDescriptors ( ) const [inline]

this method return the descritors for each points in a matrix with size ( n*m ), where n is the number of points and m is the desciptor size.

Returns:
descritors for each points in a matrix with size ( n*m ), where n is the number of points and m is the desciptor size.

Definition at line 195 of file PointsToTrack.h.

cv::Mat OpencvSfM::PointsToTrack::getImage ( ) [inline]

Get the image used to compute points

Definition at line 199 of file PointsToTrack.h.

void OpencvSfM::PointsToTrack::getKeyMatches ( const std::vector< TrackOfPoints > &  matches,
int  otherImage,
std::vector< cv::Point2f > &  pointsVals 
) const

This method update the points coordinates (last parameter) corresponding to tracks containing image index "otherImage"

Parameters:
matcheslist of tracks. Only points found in tracks are returned
otherImageindex of wanted image
pointsVals[ out ] points found in tracks

Definition at line 228 of file PointsToTrack.cpp.

const cv::KeyPoint& OpencvSfM::PointsToTrack::getKeypoint ( unsigned int  index) const [inline]

this method return the points coordinates of the i^th entry

Parameters:
indexnumber of keypoints wanted
Returns:
points coordinates and when available orientation and size

Definition at line 180 of file PointsToTrack.h.

const std::vector<cv::KeyPoint>& OpencvSfM::PointsToTrack::getKeypoints ( ) const [inline]

this method return the points coordinates and sometimes orientation and size

Returns:
points coordinates and when available orientation and size

Definition at line 165 of file PointsToTrack.h.

std::vector<cv::KeyPoint>& OpencvSfM::PointsToTrack::getModifiableKeypoints ( ) [inline]

this method return the points coordinates and sometimes orientation and size

Returns:
points coordinates and when available orientation and size

Definition at line 160 of file PointsToTrack.h.

virtual void OpencvSfM::PointsToTrack::impl_computeDescriptors_ ( ) [inline, protected, virtual]

This is the method you should implement when you create a new descriptors extractor...

Reimplemented in OpencvSfM::PointsToTrackWithImage.

Definition at line 72 of file PointsToTrack.h.

Referenced by computeDescriptors(), computeKeypointsAndDesc(), and impl_filterByDistance_().

virtual int OpencvSfM::PointsToTrack::impl_computeKeypoints_ ( ) [inline, protected, virtual]

This is the method you should implement when you create a new point detector algorithm.

Returns:
the number of points

Reimplemented in OpencvSfM::PointsToTrackWithImage.

Definition at line 67 of file PointsToTrack.h.

Referenced by computeKeypoints(), and computeKeypointsAndDesc().

void OpencvSfM::PointsToTrack::impl_filterByDistance_ ( double  dist_min) [protected]

Use this function to filter point by distance between each other Not thread safe!

Parameters:
dist_minminimum distance allowed between points

Definition at line 75 of file PointsToTrack.cpp.

Referenced by computeKeypointsAndDesc(), and filterByDistance().

void OpencvSfM::PointsToTrack::printPointsOnImage ( const cv::Mat &  image,
cv::Mat &  outImg,
const cv::Scalar &  color = cv::Scalar::all( -1 ),
int  flags = cv::DrawMatchesFlags::DEFAULT 
) const

To show the points on image, use this function to draw points on it.

Parameters:
imageSource image.
outImgOutput image. Its content depends on flags value what is drawn in output image. See possible flags bit values.
colorColor of keypoints
flagsPossible flags bit values is defined by DrawMatchesFlags ( see http://opencv.willowgarage.com/documentation/cpp/features2d_drawing_function_of_keypoints_and_matches.html#cv-drawmatches )

Definition at line 161 of file PointsToTrack.cpp.

void OpencvSfM::PointsToTrack::read ( const cv::FileNode &  node,
PointsToTrack points 
) [static]

Load the points from a YAML file.

Parameters:
nodePreviously opened YAML file node
pointsoutput

Definition at line 167 of file PointsToTrack.cpp.

void OpencvSfM::PointsToTrack::write ( cv::FileStorage &  fs,
const PointsToTrack points 
) [static]

Save the points into a YAML file.

Parameters:
fsPreviously opened YAML file node
pointssequence to save...

Definition at line 209 of file PointsToTrack.cpp.


Member Data Documentation

this attribute will store descritors for each points in a matrix with size ( n*m ), where n is the number of points and m is the desciptor size.

Definition at line 49 of file PointsToTrack.h.

Referenced by addKeypoints(), computeKeypointsAndDesc(), free_descriptors(), OpencvSfM::PointsToTrackWithImage::impl_computeDescriptors_(), impl_filterByDistance_(), read(), write(), and ~PointsToTrack().

std::vector<cv::KeyPoint> OpencvSfM::PointsToTrack::keypoints_ [protected]
unsigned int OpencvSfM::PointsToTrack::nb_workers_ [protected]

To preserve memory, we need to know how many process are working with theses points...

Definition at line 38 of file PointsToTrack.h.

Referenced by computeDescriptors(), computeKeypointsAndDesc(), free_descriptors(), impl_filterByDistance_(), PointsToTrack(), and read().

std::vector<unsigned int> OpencvSfM::PointsToTrack::RGB_values_ [protected]

When available, the color of each point can be stored here.

Definition at line 58 of file PointsToTrack.h.

Referenced by OpencvSfM::PointsToTrackWithImage::computeColorOfPoints(), read(), and write().


The documentation for this class was generated from the following files:
 All Classes Functions Variables