7#ifndef __OPENCV_RGBD_LINEMOD_HPP__
8#define __OPENCV_RGBD_LINEMOD_HPP__
10#include "opencv2/core.hpp"
32 CV_WRAP
Feature() : x(0), y(0), label(0) {}
33 CV_WRAP
Feature(
int x,
int y,
int label);
39inline Feature::Feature(
int _x,
int _y,
int _label) : x(_x), y(_y), label(_label) {}
45 CV_PROP
int pyramid_level;
46 CV_PROP std::vector<Feature> features;
67 CV_WRAP
virtual void quantize(CV_OUT
Mat& dst)
const =0;
74 CV_WRAP
virtual bool extractTemplate(CV_OUT
Template& templ)
const =0;
87 Candidate(
int x,
int y,
int label,
float score);
92 return score > rhs.score;
108 std::vector<Feature>& features,
109 size_t num_features,
float distance);
112inline QuantizedPyramid::Candidate::Candidate(
int x,
int y,
int label,
float _score) : f(x, y, label), score(_score) {}
133 const Mat& mask =
Mat())
const
135 return processImpl(src, mask);
138 CV_WRAP
virtual String name()
const =0;
140 CV_WRAP
virtual void read(
const FileNode& fn) =0;
160 const Mat& mask)
const =0;
182 ColorGradient(
float weak_threshold,
size_t num_features,
float strong_threshold);
184 CV_WRAP
static Ptr<ColorGradient> create(
float weak_threshold,
size_t num_features,
float strong_threshold);
186 virtual String name() const CV_OVERRIDE;
188 virtual
void read(const
FileNode& fn) CV_OVERRIDE;
189 virtual
void write(
FileStorage& fs) const CV_OVERRIDE;
191 CV_PROP
float weak_threshold;
192 CV_PROP
size_t num_features;
193 CV_PROP
float strong_threshold;
197 const
Mat& mask) const CV_OVERRIDE;
221 DepthNormal(
int distance_threshold,
int difference_threshold,
size_t num_features,
222 int extract_threshold);
224 CV_WRAP
static Ptr<DepthNormal> create(
int distance_threshold,
int difference_threshold,
225 size_t num_features,
int extract_threshold);
227 virtual String name() const CV_OVERRIDE;
229 virtual
void read(const
FileNode& fn) CV_OVERRIDE;
230 virtual
void write(
FileStorage& fs) const CV_OVERRIDE;
232 CV_PROP
int distance_threshold;
233 CV_PROP
int difference_threshold;
234 CV_PROP
size_t num_features;
235 CV_PROP
int extract_threshold;
239 const
Mat& mask) const CV_OVERRIDE;
265 CV_WRAP
Match(
int x,
int y,
float similarity,
const String& class_id,
int template_id);
271 if (similarity != rhs.similarity)
272 return similarity > rhs.similarity;
274 return template_id < rhs.template_id;
277 bool operator==(
const Match& rhs)
const
279 return x == rhs.x && y == rhs.y && similarity == rhs.similarity && class_id == rhs.class_id;
284 CV_PROP_RW
float similarity;
285 CV_PROP_RW String class_id;
286 CV_PROP_RW
int template_id;
290Match::Match(
int _x,
int _y,
float _similarity,
const String& _class_id,
int _template_id)
291 : x(_x), y(_y), similarity(_similarity), class_id(_class_id), template_id(_template_id)
330 CV_WRAP
void match(
const std::vector<Mat>& sources,
float threshold, CV_OUT std::vector<Match>& matches,
331 const std::vector<String>& class_ids = std::vector<String>(),
333 const std::vector<Mat>& masks = std::vector<Mat>())
const;
345 CV_WRAP
int addTemplate(
const std::vector<Mat>& sources,
const String& class_id,
346 const Mat& object_mask, CV_OUT
Rect* bounding_box = NULL);
351 CV_WRAP
int addSyntheticTemplate(
const std::vector<Template>& templates,
const String& class_id);
359 CV_WRAP
const std::vector< Ptr<Modality> >& getModalities()
const {
return modalities; }
364 CV_WRAP
int getT(
int pyramid_level)
const {
return T_at_level[pyramid_level]; }
369 CV_WRAP
int pyramidLevels()
const {
return pyramid_levels; }
377 CV_WRAP
const std::vector<Template>& getTemplates(
const String& class_id,
int template_id)
const;
379 CV_WRAP
int numTemplates()
const;
380 CV_WRAP
int numTemplates(
const String& class_id)
const;
381 CV_WRAP
int numClasses()
const {
return static_cast<int>(class_templates.size()); }
383 CV_WRAP std::vector<String> classIds()
const;
385 CV_WRAP
void read(
const FileNode& fn);
388 String readClass(
const FileNode& fn,
const String &class_id_override =
"");
389 void writeClass(
const String& class_id,
FileStorage& fs)
const;
391 CV_WRAP
void readClasses(
const std::vector<String>& class_ids,
392 const String& format =
"templates_%s.yml.gz");
393 CV_WRAP
void writeClasses(
const String& format =
"templates_%s.yml.gz")
const;
396 std::vector< Ptr<Modality> > modalities;
398 std::vector<int> T_at_level;
400 typedef std::vector<Template> TemplatePyramid;
401 typedef std::map<String, std::vector<TemplatePyramid> > TemplatesMap;
402 TemplatesMap class_templates;
404 typedef std::vector<Mat> LinearMemories;
406 typedef std::vector< std::vector<LinearMemories> > LinearMemoryPyramid;
408 void matchClass(
const LinearMemoryPyramid& lm_pyramid,
409 const std::vector<Size>& sizes,
410 float threshold, std::vector<Match>& matches,
411 const String& class_id,
412 const std::vector<TemplatePyramid>& template_pyramids)
const;
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition: mat.hpp:295
File Storage Node class.
Definition: persistence.hpp:482
XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or readi...
Definition: persistence.hpp:304
n-dimensional dense array class
Definition: mat.hpp:802
Template class for 2D rectangles
Definition: core/types.hpp:421
Modality that computes quantized gradient orientations from a color image.
Definition: linemod.hpp:167
ColorGradient()
Default constructor. Uses reasonable default parameter values.
ColorGradient(float weak_threshold, size_t num_features, float strong_threshold)
Constructor.
Modality that computes quantized surface normals from a dense depth map.
Definition: linemod.hpp:204
DepthNormal(int distance_threshold, int difference_threshold, size_t num_features, int extract_threshold)
Constructor.
DepthNormal()
Default constructor. Uses reasonable default parameter values.
Object detector using the LINE template matching algorithm with any set of modalities.
Definition: linemod.hpp:299
Interface for modalities that plug into the LINE template matching representation.
Definition: linemod.hpp:120
Represents a modality operating over an image pyramid.
Definition: linemod.hpp:56
static void selectScatteredFeatures(const std::vector< Candidate > &candidates, std::vector< Feature > &features, size_t num_features, float distance)
Choose candidate features so that they are not bunched together.
CV_EXPORTS_W void pyrDown(InputArray src, OutputArray dst, const Size &dstsize=Size(), int borderType=BORDER_DEFAULT)
Blurs an image and downsamples it.
CV_EXPORTS_W double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
Applies a fixed-level threshold to each array element.
CV_EXPORTS_W Ptr< linemod::Detector > getDefaultLINEMOD()
Factory function for detector using LINE-MOD algorithm with color gradients and depth normals.
CV_EXPORTS_W void drawFeatures(InputOutputArray img, const std::vector< Template > &templates, const Point2i &tl, int size=10)
Debug function to draw linemod features
CV_EXPORTS_W void colormap(const Mat &quantized, CV_OUT Mat &dst)
Debug function to colormap a quantized image for viewing.
CV_EXPORTS_W Ptr< linemod::Detector > getDefaultLINE()
Factory function for detector using LINE algorithm with color gradients.
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74
Discriminant feature described by its location and label.
Definition: linemod.hpp:27
Represents a successful template match.
Definition: linemod.hpp:260
bool operator<(const Match &rhs) const
Sort matches with high similarity to the front
Definition: linemod.hpp:268
Candidate feature with a score
Definition: linemod.hpp:86
bool operator<(const Candidate &rhs) const
Sort candidates with high score to the front
Definition: linemod.hpp:90
Definition: linemod.hpp:42