MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / createAndAddTemplate

Method createAndAddTemplate

recognition/src/linemod.cpp:57–103  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

55
56//////////////////////////////////////////////////////////////////////////////////////////////
57int
58pcl::LINEMOD::createAndAddTemplate (const std::vector<pcl::QuantizableModality*> & modalities,
59 const std::vector<pcl::MaskMap*> & masks,
60 const pcl::RegionXY & region)
61{
62 // assuming width and height is same for all modalities; should we check this??
63 //const int width = modalities[0]->getQuantizedMap().getWidth ();
64 //const int height = modalities[0]->getQuantizedMap().getHeight ();
65
66 SparseQuantizedMultiModTemplate linemod_template;
67
68 // select N features from every modality (N = 50, hardcoded; CHANGE this to a parameter!!!)
69 const std::size_t nr_features_per_modality = 63;
70 const std::size_t nr_modalities = modalities.size();
71 for (std::size_t modality_index = 0; modality_index < nr_modalities; ++modality_index)
72 {
73 const MaskMap & mask = *(masks[modality_index]);
74 modalities[modality_index]->extractFeatures(mask, nr_features_per_modality, modality_index,
75 linemod_template.features);
76 }
77
78 // up to now all features are relative to the input frame; make them relative to the region center
79 //const int centerX = region.x+region.width/2;
80 //const int centerY = region.y+region.height/2;
81
82 const std::size_t nr_features = linemod_template.features.size();
83 for (std::size_t feature_index = 0; feature_index < nr_features; ++feature_index)
84 {
85 //linemod_template.features[feature_index].x -= centerX;
86 //linemod_template.features[feature_index].y -= centerY;
87 linemod_template.features[feature_index].x -= region.x;
88 linemod_template.features[feature_index].y -= region.y;
89 }
90
91 // set region relative to the center
92 linemod_template.region.x = 0;
93 linemod_template.region.y = 0;
94 //linemod_template.region.x = region.x - centerX;
95 //linemod_template.region.y = region.y - centerY;
96 linemod_template.region.width = region.width;
97 linemod_template.region.height = region.height;
98
99 // add template to template storage
100 templates_.push_back(linemod_template);
101
102 return static_cast<int> (templates_.size () - 1);
103}
104
105//////////////////////////////////////////////////////////////////////////////////////////////
106int

Callers 1

trainTemplateFunction · 0.45

Calls 3

sizeMethod · 0.45
extractFeaturesMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected