Skip to content

Commit

Permalink
Format using the cmake target
Browse files Browse the repository at this point in the history
  • Loading branch information
kunaltyagi committed Oct 21, 2019
1 parent 8d0638e commit 4c60553
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 42 deletions.
11 changes: 8 additions & 3 deletions ml/include/pcl/ml/ferns/fern.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class PCL_EXPORTS Fern {
stream.write(reinterpret_cast<const char*>(&num_of_decisions_),
sizeof(num_of_decisions_));

for (std::size_t feature_index = 0; feature_index < features_.size(); ++feature_index) {
for (std::size_t feature_index = 0; feature_index < features_.size();
++feature_index) {
features_[feature_index].serialize(stream);
}

Expand Down Expand Up @@ -121,7 +122,8 @@ class PCL_EXPORTS Fern {
thresholds_.resize(num_of_decisions_);
nodes_.resize(0x1 << num_of_decisions_);

for (std::size_t feature_index = 0; feature_index < features_.size(); ++feature_index) {
for (std::size_t feature_index = 0; feature_index < features_.size();
++feature_index) {
features_[feature_index].deserialize(stream);
}

Expand All @@ -140,7 +142,10 @@ class PCL_EXPORTS Fern {
*
* \param node_index the index of the node to access
*/
inline NodeType& operator[](const std::size_t node_index) { return nodes_[node_index]; }
inline NodeType& operator[](const std::size_t node_index)
{
return nodes_[node_index];
}

/** Access operator for nodes.
*
Expand Down
9 changes: 6 additions & 3 deletions ml/include/pcl/ml/impl/dt/decision_tree_trainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType
float best_feature_information_gain = 0.0f;

const std::size_t num_of_features = features.size();
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
// evaluate features
feature_handler_->evaluateFeature(
features[feature_index], data_set_, examples, feature_results, flags);
Expand Down Expand Up @@ -222,7 +223,8 @@ pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType
const std::size_t num_of_branches = stats_estimator_->getNumOfBranches();

std::vector<std::size_t> branch_counts(num_of_branches, 0);
for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
++branch_counts[branch_indices[example_index]];
}

Expand All @@ -247,7 +249,8 @@ pcl::DecisionTreeTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType
branch_labels.reserve(branch_counts[branch_index]);
branch_examples.reserve(branch_counts[branch_index]);

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
if (branch_indices[example_index] == branch_index) {
branch_examples.push_back(examples[example_index]);
branch_labels.push_back(label_data[example_index]);
Expand Down
27 changes: 18 additions & 9 deletions ml/include/pcl/ml/impl/ferns/fern_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::eva
std::vector<std::vector<unsigned char>> flags(num_of_features);
std::vector<std::vector<unsigned char>> branch_indices(num_of_features);

for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
results[feature_index].reserve(num_of_examples);
flags[feature_index].reserve(num_of_examples);
branch_indices[feature_index].reserve(num_of_examples);
Expand All @@ -103,9 +104,11 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::eva
branch_indices[feature_index]);
}

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
std::size_t node_index = 0;
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
node_index *= num_of_branches;
node_index += branch_indices[feature_index][example_index];
}
Expand Down Expand Up @@ -138,7 +141,8 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
std::vector<std::vector<unsigned char>> flags(num_of_features);
std::vector<std::vector<unsigned char>> branch_indices(num_of_features);

for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
results[feature_index].reserve(num_of_examples);
flags[feature_index].reserve(num_of_examples);
branch_indices[feature_index].reserve(num_of_examples);
Expand All @@ -154,9 +158,11 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::
branch_indices[feature_index]);
}

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
std::size_t node_index = 0;
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
node_index *= num_of_branches;
node_index += branch_indices[feature_index][example_index];
}
Expand Down Expand Up @@ -189,7 +195,8 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::get
std::vector<std::vector<unsigned char>> flags(num_of_features);
std::vector<std::vector<unsigned char>> branch_indices(num_of_features);

for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
results[feature_index].reserve(num_of_examples);
flags[feature_index].reserve(num_of_examples);
branch_indices[feature_index].reserve(num_of_examples);
Expand All @@ -205,9 +212,11 @@ pcl::FernEvaluator<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::get
branch_indices[feature_index]);
}

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
std::size_t node_index = 0;
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
node_index *= num_of_branches;
node_index += branch_indices[feature_index][example_index];
}
Expand Down
24 changes: 16 additions & 8 deletions ml/include/pcl/ml/impl/ferns/fern_trainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
std::vector<std::vector<float>> feature_results(num_of_features_);
std::vector<std::vector<unsigned char>> flags(num_of_features_);

for (std::size_t feature_index = 0; feature_index < num_of_features_; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features_;
++feature_index) {
feature_results[feature_index].reserve(num_of_examples);
flags[feature_index].reserve(num_of_examples);

Expand All @@ -107,7 +108,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
num_of_features_); // [feature_index][branch_index][flag_index]

// - initialize branch feature results and flags
for (std::size_t feature_index = 0; feature_index < num_of_features_; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features_;
++feature_index) {
branch_feature_results[feature_index].resize(1);
branch_flags[feature_index].resize(1);
branch_examples[feature_index].resize(1);
Expand All @@ -123,7 +125,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
// get thresholds
std::vector<std::vector<float>> thresholds(num_of_features_);

for (std::size_t feature_index = 0; feature_index < num_of_features_; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features_;
++feature_index) {
thresholds.reserve(num_of_thresholds_);
createThresholdsUniform(num_of_thresholds_,
feature_results[feature_index],
Expand All @@ -135,7 +138,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
float best_feature_threshold = 0.0f;
float best_feature_information_gain = 0.0f;

for (std::size_t feature_index = 0; feature_index < num_of_features_; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features_;
++feature_index) {
for (std::size_t threshold_index = 0; threshold_index < num_of_thresholds_;
++threshold_index) {
float information_gain = 0.0f;
Expand Down Expand Up @@ -169,7 +173,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
fern.accessThreshold(depth_index) = best_feature_threshold;

// update branch feature results and flags
for (std::size_t feature_index = 0; feature_index < num_of_features_; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features_;
++feature_index) {
std::vector<std::vector<float>>& cur_branch_feature_results =
branch_feature_results[feature_index];
std::vector<std::vector<unsigned char>>& cur_branch_flags =
Expand All @@ -191,7 +196,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
std::vector<std::vector<LabelType>> new_branch_label_data(
total_num_of_new_branches); // [branch_index][example_index]

for (std::size_t branch_index = 0; branch_index < cur_branch_feature_results.size();
for (std::size_t branch_index = 0;
branch_index < cur_branch_feature_results.size();
++branch_index) {
const std::size_t num_of_examples_in_this_branch =
cur_branch_feature_results[branch_index].size();
Expand All @@ -206,7 +212,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train

// split results into different branches
const std::size_t base_branch_index = branch_index * num_of_branches;
for (std::size_t example_index = 0; example_index < num_of_examples_in_this_branch;
for (std::size_t example_index = 0;
example_index < num_of_examples_in_this_branch;
++example_index) {
const std::size_t combined_branch_index =
base_branch_index + branch_indices[example_index];
Expand Down Expand Up @@ -260,7 +267,8 @@ pcl::FernTrainer<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::train
std::vector<std::vector<ExampleIndex>> node_examples(
0x1 << fern_depth_); // [node_index][example_index]

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
std::size_t node_index = 0;
for (std::size_t depth_index = 0; depth_index < fern_depth_; ++depth_index) {
node_index *= num_of_branches;
Expand Down
30 changes: 20 additions & 10 deletions ml/include/pcl/ml/multi_channel_2d_comparison_feature_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class PCL_EXPORTS MultiChannel2DComparisonFeatureHandler
std::vector<MultiChannel2DComparisonFeature<PointXY32i>>& features)
{
features.resize(num_of_features);
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
features[feature_index].p1 = PointXY32i::randomPoint(-feature_window_width_ / 2,
feature_window_width_ / 2,
-feature_window_height_ / 2,
Expand Down Expand Up @@ -152,11 +153,15 @@ class PCL_EXPORTS MultiChannel2DComparisonFeatureHandler
const int center_col_index = example.x;
const int center_row_index = example.y;

const std::size_t p1_col = static_cast<std::size_t>(feature.p1.x + center_col_index);
const std::size_t p1_row = static_cast<std::size_t>(feature.p1.y + center_row_index);
const std::size_t p1_col =
static_cast<std::size_t>(feature.p1.x + center_col_index);
const std::size_t p1_row =
static_cast<std::size_t>(feature.p1.y + center_row_index);

const std::size_t p2_col = static_cast<std::size_t>(feature.p2.x + center_col_index);
const std::size_t p2_row = static_cast<std::size_t>(feature.p2.y + center_row_index);
const std::size_t p2_col =
static_cast<std::size_t>(feature.p2.x + center_col_index);
const std::size_t p2_row =
static_cast<std::size_t>(feature.p2.y + center_row_index);

const unsigned char channel = feature.channel;

Expand Down Expand Up @@ -240,7 +245,8 @@ class PCL_EXPORTS ScaledMultiChannel2DComparisonFeatureHandler
std::vector<MultiChannel2DComparisonFeature<PointXY32f>>& features)
{
features.resize(num_of_features);
for (std::size_t feature_index = 0; feature_index < num_of_features; ++feature_index) {
for (std::size_t feature_index = 0; feature_index < num_of_features;
++feature_index) {
features[feature_index].p1 = PointXY32f::randomPoint(-feature_window_width_ / 2,
feature_window_width_ / 2,
-feature_window_height_ / 2,
Expand Down Expand Up @@ -308,11 +314,15 @@ class PCL_EXPORTS ScaledMultiChannel2DComparisonFeatureHandler
scale = static_cast<float>(data_set(
example.data_set_id, center_col_index, center_row_index)[SCALE_CHANNEL]);

const std::size_t p1_col = static_cast<std::size_t>(scale * feature.p1.x + center_col_index);
const std::size_t p1_row = static_cast<std::size_t>(scale * feature.p1.y + center_row_index);
const std::size_t p1_col =
static_cast<std::size_t>(scale * feature.p1.x + center_col_index);
const std::size_t p1_row =
static_cast<std::size_t>(scale * feature.p1.y + center_row_index);

const std::size_t p2_col = static_cast<std::size_t>(scale * feature.p2.x + center_col_index);
const std::size_t p2_row = static_cast<std::size_t>(scale * feature.p2.y + center_row_index);
const std::size_t p2_col =
static_cast<std::size_t>(scale * feature.p2.x + center_col_index);
const std::size_t p2_row =
static_cast<std::size_t>(scale * feature.p2.y + center_row_index);

const unsigned char channel = feature.channel;

Expand Down
16 changes: 12 additions & 4 deletions ml/include/pcl/ml/multi_channel_2d_data_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class PCL_EXPORTS MultiChannel2DData {
* \param[in] channel the channel index
*/
inline DATA_TYPE&
operator()(const std::size_t col_index, const std::size_t row_index, const std::size_t channel)
operator()(const std::size_t col_index,
const std::size_t row_index,
const std::size_t channel)
{
return data_[NUM_OF_CHANNELS * (row_index * width_ + col_index) + channel];
};
Expand All @@ -117,7 +119,9 @@ class PCL_EXPORTS MultiChannel2DData {
* \param[in] channel the channel index
*/
inline const DATA_TYPE&
operator()(const std::size_t col_index, const std::size_t row_index, const std::size_t channel) const
operator()(const std::size_t col_index,
const std::size_t row_index,
const std::size_t channel) const
{
return data_[NUM_OF_CHANNELS * (row_index * width_ + col_index) + channel];
};
Expand Down Expand Up @@ -180,7 +184,9 @@ class PCL_EXPORTS MultiChannel2DDataSet {
* \param[in] row the row of the desired location
*/
inline DATA_TYPE*
operator()(const std::size_t data_set_id, const std::size_t col, const std::size_t row)
operator()(const std::size_t data_set_id,
const std::size_t col,
const std::size_t row)
{
return (*data_set_[data_set_id])(col, row);
};
Expand All @@ -192,7 +198,9 @@ class PCL_EXPORTS MultiChannel2DDataSet {
* \param[in] row the row of the desired location
*/
inline const DATA_TYPE*
operator()(const std::size_t data_set_id, const std::size_t col, const std::size_t row) const
operator()(const std::size_t data_set_id,
const std::size_t col,
const std::size_t row) const
{
return (*data_set_[data_set_id])(col, row);
};
Expand Down
9 changes: 6 additions & 3 deletions ml/include/pcl/ml/regression_variance_stats_estimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ class PCL_EXPORTS RegressionVarianceStatsEstimator
++branch_element_count[num_of_branches];
}

for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
unsigned char branch_index;
computeBranchIndex(
results[example_index], flags[example_index], threshold, branch_index);
Expand All @@ -200,7 +201,8 @@ class PCL_EXPORTS RegressionVarianceStatsEstimator
}

std::vector<float> variances(num_of_branches + 1, 0);
for (std::size_t branch_index = 0; branch_index < num_of_branches + 1; ++branch_index) {
for (std::size_t branch_index = 0; branch_index < num_of_branches + 1;
++branch_index) {
const float mean_sum =
static_cast<float>(sums[branch_index]) / branch_element_count[branch_index];
const float mean_sqr_sum = static_cast<float>(sqr_sums[branch_index]) /
Expand Down Expand Up @@ -280,7 +282,8 @@ class PCL_EXPORTS RegressionVarianceStatsEstimator

LabelDataType sum = 0.0f;
LabelDataType sqr_sum = 0.0f;
for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index) {
for (std::size_t example_index = 0; example_index < num_of_examples;
++example_index) {
const LabelDataType label = label_data[example_index];

sum += label;
Expand Down
4 changes: 3 additions & 1 deletion stereo/include/pcl/stereo/impl/disparity_map_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ pcl::DisparityMapConverter<PointT>::setDisparityMap(
template <typename PointT>
void
pcl::DisparityMapConverter<PointT>::setDisparityMap(
const std::vector<float>& disparity_map, const std::size_t width, const std::size_t height)
const std::vector<float>& disparity_map,
const std::size_t width,
const std::size_t height)
{
disparity_map_width_ = width;
disparity_map_height_ = height;
Expand Down
3 changes: 2 additions & 1 deletion stereo/src/digital_elevation_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ pcl::DigitalElevationMapBuilder::compute(pcl::PointCloud<PointDEM>& out_cloud)
} // column

// For all histograms.
for (std::size_t index_column = 0; index_column < resolution_column_; ++index_column) {
for (std::size_t index_column = 0; index_column < resolution_column_;
++index_column) {
for (std::size_t index_disparity = 0; index_disparity < resolution_disparity_;
++index_disparity) {
std::size_t index = index_column + index_disparity * resolution_column_;
Expand Down

0 comments on commit 4c60553

Please sign in to comment.