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

This class store the track of keypoints. A track is a connected set of matching keypoints across multiple images. More...

#include <TracksOfPoints.h>

List of all members.

Public Member Functions

template<typename Type , int size>
 operator cv::Vec< Type, size > & ()
bool addMatch (const int image_src, const int point_idx)
bool containImage (const int image_wanted) const
bool containPoint (const int image_src, const int point_idx1) const
unsigned int getNbTrack () const
cv::DMatch toDMatch (const int img1, const int img2) const
void getMatch (const unsigned int index, int &idImage, int &idPoint) const
int getPointIndex (const unsigned int image) const
int getImageIndex (const unsigned int idx) const
double triangulateLinear (std::vector< PointOfView > &cameras, const std::vector< cv::Ptr< PointsToTrack > > &points_to_track, cv::Vec3d &points3D, const std::vector< bool > &masks=std::vector< bool >())
double triangulateRobust (std::vector< PointOfView > &cameras, const std::vector< cv::Ptr< PointsToTrack > > &points_to_track, cv::Vec3d &points3D, double reproj_error=4, const std::vector< bool > &masks=std::vector< bool >())
void removeOutliers (std::vector< PointOfView > &cameras, const std::vector< cv::Ptr< PointsToTrack > > &points_to_track, double reproj_error=4, std::vector< bool > *masks=NULL)
void set3DPosition (cv::Vec3d newPoint)
cv::Ptr< cv::Vec3d > get3DPosition ()
unsigned int getColor () const
void setColor (unsigned int c)

Static Public Member Functions

static void fusionDuplicates (std::vector< TrackOfPoints > &tracks)
static void keepTrackHavingImage (unsigned int idx_image, std::vector< TrackOfPoints > &tracks)
static void keepTrackWithImages (const std::vector< int > &imgList, std::vector< TrackOfPoints > &tracks)
static void mixTracks (const std::vector< TrackOfPoints > &list_tracks, std::vector< TrackOfPoints > *mixed_tracks)

Protected Member Functions

double errorEstimate (std::vector< PointOfView > &cameras, const std::vector< cv::Ptr< PointsToTrack > > &points_to_track, cv::Vec3d &points3D, const std::vector< bool > &masks=std::vector< bool >()) const

Protected Attributes

cv::Ptr< cv::Vec3d > point3D
 The corresponding 3D coordinates. If not available, Ptr is empty.
std::vector< unsigned int > images_indexes_
 List of image indexes of unordered points.
std::vector< unsigned int > point_indexes_
 List of point indexes of unordered points.
unsigned int color
 Color of this point (computed using the mean of every 2D points projections.
std::vector< bool > good_values
int track_consistance

Friends

class SequenceAnalyzer

Detailed Description

This class store the track of keypoints. A track is a connected set of matching keypoints across multiple images.

This class can be used as a Vec3d because it's the projection of a 3D points Of course, use triangulate method before to create this 3D point!

Discussion: Store index of points or 2D position?

Definition at line 23 of file TracksOfPoints.h.


Member Function Documentation

bool OpencvSfM::TrackOfPoints::addMatch ( const int  image_src,
const int  point_idx 
)

This function add matches to track

Parameters:
image_srcindex of source matches image
point_idxindex of point in source image
Returns:
true if this match is correct, false if inconsistent with Snavely's rules.

Definition at line 56 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::SequenceAnalyzer::addMatches(), fusionDuplicates(), mixTracks(), and OpencvSfM::SequenceAnalyzer::read().

bool OpencvSfM::TrackOfPoints::containImage ( const int  image_wanted) const [inline]

This function is used to know if the track contains the image

Parameters:
image_wantedindex of query image
Returns:
true if this track contain points from the query image

Definition at line 66 of file TracksOfPoints.h.

Referenced by OpencvSfM::StructureEstimator::computeStructure(), OpencvSfM::PointsToTrack::getKeyMatches(), OpencvSfM::EuclideanEstimator::initialReconstruction(), keepTrackHavingImage(), and keepTrackWithImages().

bool OpencvSfM::TrackOfPoints::containPoint ( const int  image_src,
const int  point_idx1 
) const

This function is used to know if the track contains the query point

Parameters:
image_srcindex of query image
point_idx1index of point in query image
Returns:
true if this track contain the point from the query image

Definition at line 156 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::SequenceAnalyzer::addMatches(), and mixTracks().

double OpencvSfM::TrackOfPoints::errorEstimate ( std::vector< PointOfView > &  cameras,
const std::vector< cv::Ptr< PointsToTrack > > &  points_to_track,
cv::Vec3d &  points3D,
const std::vector< bool > &  masks = std::vector<bool>( ) 
) const [protected]

Comptue an estimation of 2D reprojection error

Parameters:
cameraslist of cameras
points_to_tracklist of 2D points
points3D3d points to project with cameras
maskswanted points
Returns:
estimation of distance detween projections and measures.

Definition at line 217 of file TracksOfPoints.cpp.

Referenced by triangulateLinear().

void OpencvSfM::TrackOfPoints::fusionDuplicates ( std::vector< TrackOfPoints > &  tracks) [static]

Remove tracks having points in commun (mix them and set them inconsistant if needed...)

Parameters:
trackslist of tracks to analyze

Definition at line 95 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::SequenceAnalyzer::addImageToTracks(), and OpencvSfM::SequenceAnalyzer::computeMatches().

cv::Ptr<cv::Vec3d> OpencvSfM::TrackOfPoints::get3DPosition ( ) [inline]

Use this function to get the 3D point corresponding to this track

Returns:
pointer on the 3D coordinates (could be NULL!)

Definition at line 189 of file TracksOfPoints.h.

Referenced by OpencvSfM::StructureEstimator::removeOutliersTracks().

unsigned int OpencvSfM::TrackOfPoints::getColor ( ) const [inline]

Use this function to get the color of this track

Returns:
color of this track (ARGB packed into a int)

Definition at line 195 of file TracksOfPoints.h.

Referenced by OpencvSfM::SequenceAnalyzer::write().

int OpencvSfM::TrackOfPoints::getImageIndex ( const unsigned int  idx) const [inline]

use this function to get the image corresponding to the nth entry of this track

Parameters:
idxindex of wanted point
Returns:
number of image

Definition at line 124 of file TracksOfPoints.h.

Referenced by OpencvSfM::StructureEstimator::computeStructure().

void OpencvSfM::TrackOfPoints::getMatch ( const unsigned int  index,
int &  idImage,
int &  idPoint 
) const

use this function to get the n^th match value from this track

Parameters:
indexwhich match
idImageout value of the image index
idPointout value of the point index

Definition at line 206 of file TracksOfPoints.cpp.

unsigned int OpencvSfM::TrackOfPoints::getNbTrack ( ) const [inline]

This function is used to get the numbers of image for this track

Returns:
0 if inconsistent, >= 2 else

Definition at line 85 of file TracksOfPoints.h.

Referenced by OpencvSfM::StructureEstimator::computeStructure(), OpencvSfM::StructureEstimator::removeOutliersTracks(), OpencvSfM::SequenceAnalyzer::removePointsWithoutProjection(), and OpencvSfM::SequenceAnalyzer::write().

int OpencvSfM::TrackOfPoints::getPointIndex ( const unsigned int  image) const [inline]

use this function to get the index point of the wanted image

Parameters:
imageindex of wanted image
Returns:
index of point

Definition at line 110 of file TracksOfPoints.h.

Referenced by OpencvSfM::PointsToTrack::getKeyMatches().

void OpencvSfM::TrackOfPoints::keepTrackHavingImage ( unsigned int  idx_image,
std::vector< TrackOfPoints > &  tracks 
) [static]

Use this function to keep only tracks having image from first parameter

Parameters:
idx_imageindex of needed image
tracksvector of matches to clean...

Definition at line 402 of file TracksOfPoints.cpp.

void OpencvSfM::TrackOfPoints::keepTrackWithImages ( const std::vector< int > &  imgList,
std::vector< TrackOfPoints > &  tracks 
) [static]

Use this function to keep only tracks having at least 2 images from first parameter

Parameters:
imgListNeeded images indexes
tracksvector of matches to clean...

Definition at line 467 of file TracksOfPoints.cpp.

void OpencvSfM::TrackOfPoints::mixTracks ( const std::vector< TrackOfPoints > &  list_tracks,
std::vector< TrackOfPoints > *  mixed_tracks 
) [static]

add to mixed_tracks the new tracks from list_tracks who are not in mixed_tracks. Of course, as a track of points contains only indexes, be careful to mix two compatible vectors (i.e. share the same points indexes)

Parameters:
list_tracksfirst list of tracks to add into mixed_tracks
mixed_tracksoutput list of tracks

Definition at line 422 of file TracksOfPoints.cpp.

template<typename Type , int size>
OpencvSfM::TrackOfPoints::operator cv::Vec< Type, size > & ( ) [inline]

cast operator to use this object as a 3D point!

Definition at line 47 of file TracksOfPoints.h.

void OpencvSfM::TrackOfPoints::removeOutliers ( std::vector< PointOfView > &  cameras,
const std::vector< cv::Ptr< PointsToTrack > > &  points_to_track,
double  reproj_error = 4,
std::vector< bool > *  masks = NULL 
)

From the list of points of this track, remove each 2D points when reprojection error > reproj_error

Parameters:
camerascameras used to compute projection of 3D point.
points_to_track2D points used to compute reprojection error
reproj_errorThreshold used to reject outliners
masksused to knwo which point this function have to test.

Definition at line 368 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::StructureEstimator::removeOutliersTracks().

void OpencvSfM::TrackOfPoints::set3DPosition ( cv::Vec3d  newPoint) [inline]

Use this function to change the 3D coordinates corresponding to this track

Parameters:
newPointnew 3D coordinates

Definition at line 178 of file TracksOfPoints.h.

void OpencvSfM::TrackOfPoints::setColor ( unsigned int  c) [inline]

Use this function to change the color of this track

Parameters:
cnew color (ARGB packed into a int)

Definition at line 200 of file TracksOfPoints.h.

Referenced by OpencvSfM::SequenceAnalyzer::read().

DMatch OpencvSfM::TrackOfPoints::toDMatch ( const int  img1,
const int  img2 
) const

use this function to create a DMatch value from this track

Parameters:
img1train match image
img2query match image
Returns:
DMatch value

Definition at line 176 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::EuclideanEstimator::initialReconstruction().

double OpencvSfM::TrackOfPoints::triangulateLinear ( std::vector< PointOfView > &  cameras,
const std::vector< cv::Ptr< PointsToTrack > > &  points_to_track,
cv::Vec3d &  points3D,
const std::vector< bool > &  masks = std::vector<bool>( ) 
)

Using cameras and 2D points, try to find the 3D coordinates

Parameters:
camerascameras used to compute projection of 3D point.
points_to_track2D points used to compute projection
points3D3D coordinates of this tracks
masksused to knwo which point this function have to use.

Definition at line 242 of file TracksOfPoints.cpp.

Referenced by triangulateRobust().

double OpencvSfM::TrackOfPoints::triangulateRobust ( std::vector< PointOfView > &  cameras,
const std::vector< cv::Ptr< PointsToTrack > > &  points_to_track,
cv::Vec3d &  points3D,
double  reproj_error = 4,
const std::vector< bool > &  masks = std::vector<bool>( ) 
)

Using cameras and 2D points, try to find the best 3D coordinates which minimize the reprojection error using a RANSAC estimation

Parameters:
camerascameras used to compute projection of 3D point.
points_to_track2D points used to compute projection
points3D3D coordinates of the best estimation
reproj_errorThreshold used to reject outliners
masksused to knwo which point this function have to use.

Definition at line 299 of file TracksOfPoints.cpp.

Referenced by OpencvSfM::StructureEstimator::computeStructure(), and OpencvSfM::StructureEstimator::removeOutliersTracks().


Member Data Documentation

std::vector<bool> OpencvSfM::TrackOfPoints::good_values [protected]

Sometimes a 2d point is not good... This vector help us to know which points are correct...

Definition at line 36 of file TracksOfPoints.h.

Referenced by addMatch(), containPoint(), removeOutliers(), OpencvSfM::SequenceAnalyzer::removePointsWithoutProjection(), and OpencvSfM::SequenceAnalyzer::write().

if <0 the track is inconsistent if >0 represent the degree of consistence ( higher is better )

Definition at line 41 of file TracksOfPoints.h.

Referenced by addMatch(), OpencvSfM::SequenceAnalyzer::read(), and OpencvSfM::SequenceAnalyzer::write().


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