OpenCV  4.0.0
Open Source Computer Vision
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
cv::linemod::Detector Class Reference

Object detector using the LINE template matching algorithm with any set of modalities. More...

#include "linemod.hpp"

Public Member Functions

 Detector ()
 Empty constructor, initialize with read(). More...
 
 Detector (const std::vector< Ptr< Modality > > &modalities, const std::vector< int > &T_pyramid)
 Constructor. More...
 
int addSyntheticTemplate (const std::vector< Template > &templates, const String &class_id)
 Add a new object template computed by external means. More...
 
int addTemplate (const std::vector< Mat > &sources, const String &class_id, const Mat &object_mask, Rect *bounding_box=NULL)
 Add new object template. More...
 
std::vector< StringclassIds () const
 
const std::vector< Ptr< Modality > > & getModalities () const
 Get the modalities used by this detector. More...
 
int getT (int pyramid_level) const
 Get sampling step T at pyramid_level. More...
 
const std::vector< Template > & getTemplates (const String &class_id, int template_id) const
 Get the template pyramid identified by template_id. More...
 
void match (const std::vector< Mat > &sources, float threshold, std::vector< Match > &matches, const std::vector< String > &class_ids=std::vector< String >(), OutputArrayOfArrays quantized_images=noArray(), const std::vector< Mat > &masks=std::vector< Mat >()) const
 Detect objects by template matching. More...
 
int numClasses () const
 
int numTemplates () const
 
int numTemplates (const String &class_id) const
 
int pyramidLevels () const
 Get number of pyramid levels used by this detector. More...
 
void read (const FileNode &fn)
 
String readClass (const FileNode &fn, const String &class_id_override="")
 
void readClasses (const std::vector< String > &class_ids, const String &format="templates_%s.yml.gz")
 
void write (FileStorage &fs) const
 
void writeClass (const String &class_id, FileStorage &fs) const
 
void writeClasses (const String &format="templates_%s.yml.gz") const
 

Protected Types

typedef std::vector< MatLinearMemories
 
typedef std::vector< std::vector< LinearMemories > > LinearMemoryPyramid
 
typedef std::vector< TemplateTemplatePyramid
 
typedef std::map< String, std::vector< TemplatePyramid > > TemplatesMap
 

Protected Member Functions

void matchClass (const LinearMemoryPyramid &lm_pyramid, const std::vector< Size > &sizes, float threshold, std::vector< Match > &matches, const String &class_id, const std::vector< TemplatePyramid > &template_pyramids) const
 

Protected Attributes

TemplatesMap class_templates
 
std::vector< Ptr< Modality > > modalities
 
int pyramid_levels
 
std::vector< int > T_at_level
 

Detailed Description

Object detector using the LINE template matching algorithm with any set of modalities.

Member Typedef Documentation

§ LinearMemories

typedef std::vector<Mat> cv::linemod::Detector::LinearMemories
protected

§ LinearMemoryPyramid

typedef std::vector< std::vector<LinearMemories> > cv::linemod::Detector::LinearMemoryPyramid
protected

§ TemplatePyramid

typedef std::vector<Template> cv::linemod::Detector::TemplatePyramid
protected

§ TemplatesMap

typedef std::map<String, std::vector<TemplatePyramid> > cv::linemod::Detector::TemplatesMap
protected

Constructor & Destructor Documentation

§ Detector() [1/2]

cv::linemod::Detector::Detector ( )
Python:
<linemod_Detector object>=cv.linemod_Detector()
<linemod_Detector object>=cv.linemod_Detector(modalities, T_pyramid)

Empty constructor, initialize with read().

§ Detector() [2/2]

cv::linemod::Detector::Detector ( const std::vector< Ptr< Modality > > &  modalities,
const std::vector< int > &  T_pyramid 
)
Python:
<linemod_Detector object>=cv.linemod_Detector()
<linemod_Detector object>=cv.linemod_Detector(modalities, T_pyramid)

Constructor.

Parameters
modalitiesModalities to use (color gradients, depth normals, ...).
T_pyramidValue of the sampling step T at each pyramid level. The number of pyramid levels is T_pyramid.size().

Member Function Documentation

§ addSyntheticTemplate()

int cv::linemod::Detector::addSyntheticTemplate ( const std::vector< Template > &  templates,
const String class_id 
)
Python:
retval=cv.linemod_Detector.addSyntheticTemplate(templates, class_id)

Add a new object template computed by external means.

§ addTemplate()

int cv::linemod::Detector::addTemplate ( const std::vector< Mat > &  sources,
const String class_id,
const Mat object_mask,
Rect bounding_box = NULL 
)
Python:
retval, bounding_box=cv.linemod_Detector.addTemplate(sources, class_id, object_mask)

Add new object template.

Parameters
sourcesSource images, one for each modality.
class_idObject class ID.
object_maskMask separating object from background.
[out]bounding_boxOptionally return bounding box of the extracted features.
Returns
Template ID, or -1 if failed to extract a valid template.

§ classIds()

std::vector<String> cv::linemod::Detector::classIds ( ) const
Python:
retval=cv.linemod_Detector.classIds()

§ getModalities()

const std::vector< Ptr<Modality> >& cv::linemod::Detector::getModalities ( ) const
inline
Python:
retval=cv.linemod_Detector.getModalities()

Get the modalities used by this detector.

You are not permitted to add/remove modalities, but you may dynamic_cast them to tweak parameters.

§ getT()

int cv::linemod::Detector::getT ( int  pyramid_level) const
inline
Python:
retval=cv.linemod_Detector.getT(pyramid_level)

Get sampling step T at pyramid_level.

§ getTemplates()

const std::vector<Template>& cv::linemod::Detector::getTemplates ( const String class_id,
int  template_id 
) const
Python:
retval=cv.linemod_Detector.getTemplates(class_id, template_id)

Get the template pyramid identified by template_id.

For example, with 2 modalities (Gradient, Normal) and two pyramid levels (L0, L1), the order is (GradientL0, NormalL0, GradientL1, NormalL1).

§ match()

void cv::linemod::Detector::match ( const std::vector< Mat > &  sources,
float  threshold,
std::vector< Match > &  matches,
const std::vector< String > &  class_ids = std::vector< String >(),
OutputArrayOfArrays  quantized_images = noArray(),
const std::vector< Mat > &  masks = std::vector< Mat >() 
) const
Python:
matches, quantized_images=cv.linemod_Detector.match(sources, threshold[, class_ids[, quantized_images[, masks]]])

Detect objects by template matching.

Matches globally at the lowest pyramid level, then refines locally stepping up the pyramid.

Parameters
sourcesSource images, one for each modality.
thresholdSimilarity threshold, a percentage between 0 and 100.
[out]matchesTemplate matches, sorted by similarity score.
class_idsIf non-empty, only search for the desired object classes.
[out]quantized_imagesOptionally return vector<Mat> of quantized images.
masksThe masks for consideration during matching. The masks should be CV_8UC1 where 255 represents a valid pixel. If non-empty, the vector must be the same size as sources. Each element must be empty or the same size as its corresponding source.

§ matchClass()

void cv::linemod::Detector::matchClass ( const LinearMemoryPyramid lm_pyramid,
const std::vector< Size > &  sizes,
float  threshold,
std::vector< Match > &  matches,
const String class_id,
const std::vector< TemplatePyramid > &  template_pyramids 
) const
protected

§ numClasses()

int cv::linemod::Detector::numClasses ( ) const
inline
Python:
retval=cv.linemod_Detector.numClasses()

§ numTemplates() [1/2]

int cv::linemod::Detector::numTemplates ( ) const
Python:
retval=cv.linemod_Detector.numTemplates()
retval=cv.linemod_Detector.numTemplates(class_id)

§ numTemplates() [2/2]

int cv::linemod::Detector::numTemplates ( const String class_id) const
Python:
retval=cv.linemod_Detector.numTemplates()
retval=cv.linemod_Detector.numTemplates(class_id)

§ pyramidLevels()

int cv::linemod::Detector::pyramidLevels ( ) const
inline
Python:
retval=cv.linemod_Detector.pyramidLevels()

Get number of pyramid levels used by this detector.

§ read()

void cv::linemod::Detector::read ( const FileNode fn)
Python:
None=cv.linemod_Detector.read(fn)

§ readClass()

String cv::linemod::Detector::readClass ( const FileNode fn,
const String class_id_override = "" 
)

§ readClasses()

void cv::linemod::Detector::readClasses ( const std::vector< String > &  class_ids,
const String format = "templates_%s.yml.gz" 
)
Python:
None=cv.linemod_Detector.readClasses(class_ids[, format])

§ write()

void cv::linemod::Detector::write ( FileStorage fs) const

§ writeClass()

void cv::linemod::Detector::writeClass ( const String class_id,
FileStorage fs 
) const

§ writeClasses()

void cv::linemod::Detector::writeClasses ( const String format = "templates_%s.yml.gz") const
Python:
None=cv.linemod_Detector.writeClasses([, format])

Member Data Documentation

§ class_templates

TemplatesMap cv::linemod::Detector::class_templates
protected

§ modalities

std::vector< Ptr<Modality> > cv::linemod::Detector::modalities
protected

§ pyramid_levels

int cv::linemod::Detector::pyramid_levels
protected

§ T_at_level

std::vector<int> cv::linemod::Detector::T_at_level
protected

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