VisualObjectDB Class Reference

VisualObjectDatabase. More...

#include <SIFT/VisualObjectDB.H>

Collaboration diagram for VisualObjectDB:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 VisualObjectDB ()
 Constructor; use operator>> and operator<< to load/save.
 ~VisualObjectDB ()
 Destructor.
bool loadFrom (const std::string &fname, bool preloadImage=true)
 Easy loading from file.
bool saveTo (const std::string &fname)
 Easy saving to file.
std::string getName () const
 name access methods
void setName (const std::string &name)
uint numObjects () const
 get number of objects in the database
const rutz::shared_ptr
< VisualObject > & 
getObject (const uint index) const
 object getter
void setObject (const uint index, const rutz::shared_ptr< VisualObject > &obj)
 object setter
void eraseObject (const uint index)
 erase object
void clearObjects (uint size=0)
rutz::shared_ptr< VisualObjectgetObject (const std::string objectName) const
 object getter by name
bool addObject (const rutz::shared_ptr< VisualObject > &obj, bool uniqueName=true)
 add object
void buildKDTree ()
 Build a giant internal KDTree from all our Keypoints.
uint getObjectMatches (const rutz::shared_ptr< VisualObject > obj, std::vector< rutz::shared_ptr< VisualObjectMatch > > &matches, const VisualObjectMatchAlgo algo=VOMA_SIMPLE, const uint maxn=5U, const float kcoeff=0.5F, const float acoeff=0.5F, const float minscore=1.0F, const uint mink=3U, const uint kthresh=6U, const bool sortbypf=false)
 find match for the keypoints in the scene
uint getObjectMatchesParallel (const rutz::shared_ptr< VisualObject > obj, std::vector< rutz::shared_ptr< VisualObjectMatch > > &matches, const uint numthreads=4, const float kcoeff=0.5F, const float acoeff=0.5F, const float minscore=1.0F, const uint mink=3U, const uint kthresh=6U, const bool sortbypf=false)
 find match for the keypoints in the scene, parallel version
void createVisualObjectDB (std::istream &is, VisualObjectDB &vdb, bool preloadImage=true)

Friends

std::istream & operator>> (std::istream &is, VisualObjectDB &vdb)
 Load a VisualObjectDB from an istream.
std::ostream & operator<< (std::ostream &os, const VisualObjectDB &vdb)
 Save a VisualObjectDB to an ostream.

Detailed Description

VisualObjectDatabase.

Definition at line 52 of file VisualObjectDB.H.


Constructor & Destructor Documentation

VisualObjectDB::VisualObjectDB (  ) 

Constructor; use operator>> and operator<< to load/save.

Definition at line 51 of file VisualObjectDB.C.

VisualObjectDB::~VisualObjectDB (  ) 

Destructor.

Definition at line 56 of file VisualObjectDB.C.


Member Function Documentation

bool VisualObjectDB::addObject ( const rutz::shared_ptr< VisualObject > &  obj,
bool  uniqueName = true 
)

add object

Returns:
true if the object was added, false if it was not added because an object with the same name already exists (uniqueName=true) in the database. This invalidates any internal KDTree we may have.

Definition at line 92 of file VisualObjectDB.C.

References rutz::shared_ptr< T >::reset().

Referenced by main(), and SceneRec::trainFeature().

void VisualObjectDB::buildKDTree (  ) 

Build a giant internal KDTree from all our Keypoints.

This will automatically be called by getObjectMatches() if an up-to-date KDTree is not internally available. This function is made public because it may take a while to run, and is best run just after loading a DB, rather than on the first match attempt. If an up-to-date KDTree is already internally available, this is a no-op.

Definition at line 137 of file VisualObjectDB.C.

References rutz::shared_ptr< T >::is_valid(), and rutz::shared_ptr< T >::reset().

Referenced by getObjectMatches().

void VisualObjectDB::eraseObject ( const uint  index  )  [inline]

erase object

Definition at line 191 of file VisualObjectDB.H.

References ASSERT.

std::string VisualObjectDB::getName ( void   )  const [inline]

name access methods

Definition at line 182 of file VisualObjectDB.H.

Referenced by operator<<().

rutz::shared_ptr< VisualObject > VisualObjectDB::getObject ( const std::string  objectName  )  const [inline]

object getter by name

Returns an uninitialized rutz::shared_ptr is not found.

Definition at line 211 of file VisualObjectDB.H.

const rutz::shared_ptr< VisualObject > & VisualObjectDB::getObject ( const uint  index  )  const [inline]

object getter

Definition at line 204 of file VisualObjectDB.H.

References ASSERT.

uint VisualObjectDB::getObjectMatches ( const rutz::shared_ptr< VisualObject obj,
std::vector< rutz::shared_ptr< VisualObjectMatch > > &  matches,
const VisualObjectMatchAlgo  algo = VOMA_SIMPLE,
const uint  maxn = 5U,
const float  kcoeff = 0.5F,
const float  acoeff = 0.5F,
const float  minscore = 1.0F,
const uint  mink = 3U,
const uint  kthresh = 6U,
const bool  sortbypf = false 
)

find match for the keypoints in the scene

Parameters:
obj the VisualObject to match against the objects in our database.
matches list of matches which satisfy all criteria, sorted by matching score. Note: the list is initially cleared.
algo the algorithm to use for matching (see VisualObjectMatch.H).
maxn the maximum number of object matches to return. NOTE: we will return the first maxn matches found without exploring the database any further. If this is not desirable, use a large matchn. You can also use sortbypf below to attempt that these first matches will indeed be the best ones.
kcoeff coefficient for keypoint distance, used to score a match. See VisualObjectMatch::getScore().
acoeff coefficient for affine distance, used to score a match. See VisualObjectMatch::getScore().
minscore min acceptable VisualObjectMatch::getScore(kcoeff, acoeff).
mink minimum number of matching keypoints in an object match.
kthresh threshold to use for keypoint selection in obj; see VisualObject constructor and ScaleSpace.
sortbypf sort our database by similarity of preattentive visual features if true. This is incompatible with KDTree-based matching algos, which would not benefit from this sorting.
Returns:
the number of matches found (== matches.size())

Definition at line 182 of file VisualObjectDB.C.

References buildKDTree(), KeypointMatch::distSq, KeypointMatch::distSq2, max(), KeypointMatch::refkp, and KeypointMatch::tstkp.

Referenced by SceneRec::computeLocation(), InferotemporalCortexI::evolve(), and main().

uint VisualObjectDB::getObjectMatchesParallel ( const rutz::shared_ptr< VisualObject obj,
std::vector< rutz::shared_ptr< VisualObjectMatch > > &  matches,
const uint  numthreads = 4,
const float  kcoeff = 0.5F,
const float  acoeff = 0.5F,
const float  minscore = 1.0F,
const uint  mink = 3U,
const uint  kthresh = 6U,
const bool  sortbypf = false 
)

find match for the keypoints in the scene, parallel version

Definition at line 370 of file VisualObjectDB.C.

References WorkThreadServer::enqueueJob(), WorkThreadServer::flushQueue(), and rutz::make_shared().

bool VisualObjectDB::loadFrom ( const std::string fname,
bool  preloadImage = true 
)

Easy loading from file.

This will just open a file and use operator>> on it. Returns true on success.

Definition at line 60 of file VisualObjectDB.C.

References numObjects().

Referenced by ComplexObject::ComplexObject(), SceneRec::loadVisualDB(), and main().

uint VisualObjectDB::numObjects (  )  const [inline]

get number of objects in the database

Definition at line 188 of file VisualObjectDB.H.

Referenced by SceneRec::computeLocation(), InferotemporalCortexI::evolve(), loadFrom(), SceneRec::loadVisualDB(), and saveTo().

bool VisualObjectDB::saveTo ( const std::string fname  ) 

Easy saving to file.

This will just open a file and use operator<< on it. Returns true on success.

Definition at line 76 of file VisualObjectDB.C.

References numObjects().

Referenced by SceneRec::loadVisualDB(), main(), and SceneRec::trainFeature().

void VisualObjectDB::setObject ( const uint  index,
const rutz::shared_ptr< VisualObject > &  obj 
) [inline]

object setter

Definition at line 226 of file VisualObjectDB.H.

References ASSERT.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const VisualObjectDB vdb 
) [friend]

Save a VisualObjectDB to an ostream.

Definition at line 472 of file VisualObjectDB.C.

std::istream& operator>> ( std::istream &  is,
VisualObjectDB vdb 
) [friend]

Load a VisualObjectDB from an istream.

Definition at line 440 of file VisualObjectDB.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:03 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3