GSoC2011SfM
0.1
Google Summer of Code 2011: Structure from motion
|
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>
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! |
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.
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...
corresponding_image | Global index of image |
keypoints | the points we will try to track... |
descriptors | the 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.
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...
point | Keypoints to add |
min_dist | minimumů 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... |
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...
keypoints | Keypoints to add |
descriptors | of points, if any |
computeMissingDescriptor | if 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...
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...
forcing_recalculation | if true previous keypoints are removed... If false and if keypoints and descriptor exists, nothing is done. |
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
dist_min | minimum 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
force | if 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
point | coordinate of the point to search for |
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
index | of the wanted point |
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.
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"
matches | list of tracks. Only points found in tracks are returned |
otherImage | index 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
index | number of keypoints wanted |
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
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
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.
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!
dist_min | minimum 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.
image | Source image. |
outImg | Output image. Its content depends on flags value what is drawn in output image. See possible flags bit values. |
color | Color of keypoints |
flags | Possible 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.
node | Previously opened YAML file node |
points | output |
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.
fs | Previously opened YAML file node |
points | sequence to save... |
Definition at line 209 of file PointsToTrack.cpp.
cv::Mat OpencvSfM::PointsToTrack::descriptors_ [protected] |
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().
cv::Mat OpencvSfM::PointsToTrack::imageToAnalyse_ [protected] |
When available, the picture from where points are detected
Definition at line 54 of file PointsToTrack.h.
Referenced by OpencvSfM::PointsToTrackWithImage::computeColorOfPoints(), OpencvSfM::PointsToTrackWithImage::impl_computeDescriptors_(), OpencvSfM::PointsToTrackWithImage::impl_computeKeypoints_(), and OpencvSfM::PointsToTrackWithImage::PointsToTrackWithImage().
std::vector<cv::KeyPoint> OpencvSfM::PointsToTrack::keypoints_ [protected] |
This attribute will store points coordinates and sometimes orientation and size
Definition at line 43 of file PointsToTrack.h.
Referenced by addKeypoints(), OpencvSfM::PointsToTrackWithImage::computeColorOfPoints(), computeKeypoints(), computeKeypointsAndDesc(), getClosestKeypoint(), getKeyMatches(), OpencvSfM::PointsToTrackWithImage::impl_computeDescriptors_(), OpencvSfM::PointsToTrackWithImage::impl_computeKeypoints_(), impl_filterByDistance_(), printPointsOnImage(), read(), write(), and ~PointsToTrack().
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().