41#include <pcl/ml/feature_handler.h>
42#include <pcl/ml/multi_channel_2d_comparison_feature.h>
43#include <pcl/ml/multi_channel_2d_data_set.h>
44#include <pcl/ml/multiple_data_2d_example_index.h>
45#include <pcl/ml/point_xy_32f.h>
46#include <pcl/ml/point_xy_32i.h>
55template <
class DATA_TYPE, std::
size_t NUM_OF_CHANNELS>
58 pcl::MultiChannel2DDataSet<DATA_TYPE, NUM_OF_CHANNELS>,
59 pcl::MultipleData2DExampleIndex> {
80 feature_window_width_ = width;
81 feature_window_height_ = height;
97 features[
feature_index].p1 = PointXY32i::randomPoint(-feature_window_width_ / 2,
98 feature_window_width_ / 2,
99 -feature_window_height_ / 2,
100 feature_window_height_ / 2);
101 features[
feature_index].p2 = PointXY32i::randomPoint(-feature_window_width_ / 2,
102 feature_window_width_ / 2,
103 -feature_window_height_ / 2,
104 feature_window_height_ / 2);
105 features[
feature_index].channel =
static_cast<unsigned char>(
122 std::vector<MultipleData2DExampleIndex>&
examples,
124 std::vector<unsigned char>& flags)
const
150 unsigned char&
flag)
const
155 const std::size_t
p1_col =
157 const std::size_t
p1_row =
160 const std::size_t
p2_col =
162 const std::size_t
p2_row =
165 const unsigned char channel = feature.channel;
183 std::ostream&
stream)
const
185 stream <<
"ERROR: RegressionVarianceStatsEstimator does not implement "
186 "generateCodeForBranchIndex(...)";
197 int feature_window_width_;
199 int feature_window_height_;
204template <
class DATA_TYPE,
205 std::size_t NUM_OF_CHANNELS,
206 std::size_t SCALE_CHANNEL,
210 pcl::MultiChannel2DDataSet<DATA_TYPE, NUM_OF_CHANNELS>,
211 pcl::MultipleData2DExampleIndex> {
232 feature_window_width_ = width;
233 feature_window_height_ = height;
249 features[
feature_index].p1 = PointXY32f::randomPoint(-feature_window_width_ / 2,
250 feature_window_width_ / 2,
251 -feature_window_height_ / 2,
252 feature_window_height_ / 2);
253 features[
feature_index].p2 = PointXY32f::randomPoint(-feature_window_width_ / 2,
254 feature_window_width_ / 2,
255 -feature_window_height_ / 2,
256 feature_window_height_ / 2);
257 features[
feature_index].channel =
static_cast<unsigned char>(
274 std::vector<MultipleData2DExampleIndex>&
examples,
276 std::vector<unsigned char>& flags)
const
302 unsigned char&
flag)
const
313 scale =
static_cast<float>(
data_set(
316 const std::size_t
p1_col =
318 const std::size_t
p1_row =
321 const std::size_t
p2_col =
323 const std::size_t
p2_row =
326 const unsigned char channel = feature.channel;
344 std::ostream&
stream)
const
346 stream <<
"ERROR: ScaledMultiChannel2DComparisonFeatureHandler does not implement "
347 "generateCodeForBranchIndex(...)"
366 int feature_window_width_;
368 int feature_window_height_;
371template <
class DATA_TYPE,
372 std::size_t NUM_OF_CHANNELS,
373 std::size_t SCALE_CHANNEL,
376:
public pcl::FeatureHandlerCodeGenerator<
377 pcl::MultiChannel2DComparisonFeature<pcl::PointXY32f>,
378 pcl::MultiChannel2DDataSet<DATA_TYPE, NUM_OF_CHANNELS>,
379 pcl::MultipleData2DExampleIndex> {
385 generateEvalFunctionCode(std::ostream&
stream)
const;
389 std::ostream&
stream)
const;
392template <
class DATA_TYPE,
393 std::size_t NUM_OF_CHANNELS,
394 std::size_t SCALE_CHANNEL,
397ScaledMultiChannel2DComparisonFeatureHandlerCCodeGenerator<
404 stream <<
"const float scale = 1.0f / static_cast<float> (*data_ptr);"
406 stream <<
"" << std::endl;
407 stream <<
"struct LocalFeatureHandler" << std::endl;
408 stream <<
"{" << std::endl;
410 <<
" * a_ptr, const float a_x1, const float a_y1, const float a_x2, const "
411 "float a_y2, const float a_scale, const int a_width, float & a_result, "
412 "unsigned char & a_flags)"
414 stream <<
" {" << std::endl;
415 stream <<
" a_result = *(a_ptr + static_cast<int> (a_scale*a_x1) + "
416 "(static_cast<int> (a_scale*a_y1)*a_width)) - *(a_ptr + static_cast<int> "
417 "(a_scale*a_x2) + (static_cast<int> (a_scale*a_y2)*a_width));"
419 stream <<
" }" << std::endl;
420 stream <<
"};" << std::endl;
423 stream <<
"ERROR: generateEvalFunctionCode not implemented" << std::endl;
437 std::ostream&
stream)
const
439 stream <<
"LocalFeatureHandler::eval (data_ptr, " << feature.p1.x <<
", "
440 << feature.p1.y <<
", " << feature.p2.x <<
", " << feature.p2.y <<
", "
441 <<
"scale, width, result, flags);" << std::endl;
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
Utility class interface which is used for creating and evaluating features.
Feature utility class that handles the creation and evaluation of RGBD comparison features.
virtual ~MultiChannel2DComparisonFeatureHandler()
Destructor.
void evaluateFeature(const MultiChannel2DComparisonFeature< PointXY32i > &feature, MultiChannel2DDataSet< DATA_TYPE, NUM_OF_CHANNELS > &data_set, std::vector< MultipleData2DExampleIndex > &examples, std::vector< float > &results, std::vector< unsigned char > &flags) const
Evaluates a feature for a set of examples on the specified data set.
void setFeatureWindowSize(int width, int height)
Sets the feature window size.
void evaluateFeature(const MultiChannel2DComparisonFeature< PointXY32i > &feature, MultiChannel2DDataSet< DATA_TYPE, NUM_OF_CHANNELS > &data_set, const MultipleData2DExampleIndex &example, float &result, unsigned char &flag) const
Evaluates a feature for one examples on the specified data set.
MultiChannel2DComparisonFeatureHandler(const int feature_window_width, const int feature_window_height)
Constructor.
void generateCodeForEvaluation(const MultiChannel2DComparisonFeature< PointXY32i > &feature, std::ostream &stream) const
Generates code for feature evaluation.
void createRandomFeatures(const std::size_t num_of_features, std::vector< MultiChannel2DComparisonFeature< PointXY32i > > &features)
Creates random features.
virtual ~ScaledMultiChannel2DComparisonFeatureHandlerCCodeGenerator()
ScaledMultiChannel2DComparisonFeatureHandlerCCodeGenerator()
Feature utility class that handles the creation and evaluation of RGBD comparison features.
void evaluateFeature(const MultiChannel2DComparisonFeature< PointXY32f > &feature, MultiChannel2DDataSet< DATA_TYPE, NUM_OF_CHANNELS > &data_set, std::vector< MultipleData2DExampleIndex > &examples, std::vector< float > &results, std::vector< unsigned char > &flags) const
Evaluates a feature for a set of examples on the specified data set.
void evaluateFeature(const MultiChannel2DComparisonFeature< PointXY32f > &feature, MultiChannel2DDataSet< DATA_TYPE, NUM_OF_CHANNELS > &data_set, const MultipleData2DExampleIndex &example, float &result, unsigned char &flag) const
Evaluates a feature for one examples on the specified data set.
void generateCodeForEvaluation(const MultiChannel2DComparisonFeature< PointXY32f > &feature, std::ostream &stream) const
Generates code for feature evaluation.
void createRandomFeatures(const std::size_t num_of_features, std::vector< MultiChannel2DComparisonFeature< PointXY32f > > &features)
Creates random features.
virtual ~ScaledMultiChannel2DComparisonFeatureHandler()
Destructor.
void setFeatureWindowSize(int width, int height)
Sets the feature window size.
ScaledMultiChannel2DComparisonFeatureHandler(const int feature_window_width, const int feature_window_height)
Constructor.
Define standard C methods and C++ classes that are common to all methods.
Example index for a set of 2D data blocks.