Skip to content

Commit

Permalink
[apps] transition boost -> std pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRAgostinho committed Dec 3, 2019
1 parent 666a5a7 commit 04905ae
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
15 changes: 7 additions & 8 deletions apps/include/pcl/apps/nn_classification.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <cfloat>
#include <algorithm>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>

namespace pcl
{
Expand Down Expand Up @@ -71,7 +70,7 @@ namespace pcl

/** \brief Result is a list of class labels and scores */
using Result = std::pair<std::vector<std::string>, std::vector<float> >;
using ResultPtr = boost::shared_ptr<Result>;
using ResultPtr = std::shared_ptr<Result>;

// TODO setIndices method, distance metrics and reset tree

Expand Down Expand Up @@ -228,11 +227,11 @@ namespace pcl
* \param k_sqr_distances the resultant squared distances to the neighboring points
* \return a square distance to each training class
*/
boost::shared_ptr<std::vector<float> >
std::shared_ptr<std::vector<float>>
getSmallestSquaredDistances (std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
{
// Reserve space for distances
boost::shared_ptr<std::vector<float> > sqr_distances (new std::vector<float> (classes_.size (), FLT_MAX));
auto sqr_distances = std::make_shared<std::vector<float>> (classes_.size (), FLT_MAX);

// Select square distance to each class
for (std::vector<int>::const_iterator i = k_indices.begin (); i != k_indices.end (); ++i)
Expand All @@ -251,11 +250,11 @@ namespace pcl
getLinearBestScores (std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
{
// Get smallest squared distances and transform them to a score for each class
boost::shared_ptr<std::vector<float> > sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);
auto sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);

// Transform distances to scores
double sum_dist = 0;
boost::shared_ptr<std::pair<std::vector<std::string>, std::vector<float> > > result (new std::pair<std::vector<std::string>, std::vector<float> > ());
auto result = std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>> ();
result->first.reserve (classes_.size ());
result->second.reserve (classes_.size ());
for (std::vector<float>::const_iterator it = sqr_distances->begin (); it != sqr_distances->end (); ++it)
Expand All @@ -282,10 +281,10 @@ namespace pcl
getGaussianBestScores (float gaussian_param, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
{
// Get smallest squared distances and transform them to a score for each class
boost::shared_ptr<std::vector<float> > sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);
auto sqr_distances = getSmallestSquaredDistances (k_indices, k_sqr_distances);

// Transform distances to scores
boost::shared_ptr<std::pair<std::vector<std::string>, std::vector<float> > > result (new std::pair<std::vector<std::string>, std::vector<float> > ());
auto result = std::make_shared<std::pair<std::vector<std::string>, std::vector<float>>> ();
result->first.reserve (classes_.size ());
result->second.reserve (classes_.size ());
for (std::vector<float>::const_iterator it = sqr_distances->begin (); it != sqr_distances->end (); ++it)
Expand Down
4 changes: 2 additions & 2 deletions apps/src/face_detection/openni_frame_source.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "pcl/apps/face_detection/openni_frame_source.h"
#include <pcl/io/pcd_io.h>
#include <boost/make_shared.hpp>
#include <pcl/make_shared.h>

namespace OpenNIFrameSource
{
Expand Down Expand Up @@ -33,7 +33,7 @@ namespace OpenNIFrameSource
{
mutex_.lock ();
++frame_counter_;
most_recent_frame_ = boost::make_shared < PointCloud > (*cloud); // Make a copy of the frame
most_recent_frame_ = pcl::make_shared<PointCloud> (*cloud); // Make a copy of the frame
mutex_.unlock ();
}

Expand Down
4 changes: 2 additions & 2 deletions apps/src/grabcut_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class GrabCutHelper : public pcl::GrabCut<pcl::PointXYZRGB>
using pcl::GrabCut<pcl::PointXYZRGB>::input_;

public:
using Ptr = boost::shared_ptr<GrabCutHelper>;
using ConstPtr = boost::shared_ptr<const GrabCutHelper>;
using Ptr = std::shared_ptr<GrabCutHelper>;
using ConstPtr = std::shared_ptr<const GrabCutHelper>;

GrabCutHelper (std::uint32_t K = 5, float lambda = 50.f)
: pcl::GrabCut<pcl::PointXYZRGB> (K, lambda)
Expand Down
3 changes: 2 additions & 1 deletion apps/src/multiscale_feature_persistence_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <pcl/features/fpfh.h>

#include <pcl/visualization/cloud_viewer.h>
#include <pcl/make_shared.h>

using namespace pcl;

Expand Down Expand Up @@ -108,7 +109,7 @@ main (int argc, char **argv)
feature_persistence.setDistanceMetric (pcl::CS);

PointCloud<FPFHSignature33>::Ptr output_features (new PointCloud<FPFHSignature33> ());
boost::shared_ptr<std::vector<int> > output_indices (new std::vector<int> ());
auto output_indices = pcl::make_shared<std::vector<int>> ();
feature_persistence.determinePersistentFeatures (*output_features, output_indices);

PCL_INFO ("persistent features cloud size: %u\n", output_features->points.size ());
Expand Down
4 changes: 2 additions & 2 deletions apps/src/openni_mls_smoothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class OpenNISmoothing;
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
void *stop_void)
{
boost::shared_ptr<bool> stop = *static_cast<boost::shared_ptr<bool>*> (stop_void);
std::shared_ptr<bool> stop = *static_cast<std::shared_ptr<bool>*> (stop_void);
if (event.getKeySym () == "s" && event.keyDown ())
{
*stop = ! *stop;
Expand Down Expand Up @@ -167,7 +167,7 @@ class OpenNISmoothing
CloudConstPtr cloud_;
CloudPtr cloud_smoothed_;
int viewport_input_, viewport_smoothed_;
boost::shared_ptr<bool> stop_computing_;
std::shared_ptr<bool> stop_computing_;
};

void
Expand Down
2 changes: 1 addition & 1 deletion apps/src/openni_mobile_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using namespace std::chrono_literals;

struct PointCloudBuffers
{
using Ptr = boost::shared_ptr<PointCloudBuffers>;
using Ptr = std::shared_ptr<PointCloudBuffers>;
std::vector<short> points;
std::vector<unsigned char> rgb;
};
Expand Down

0 comments on commit 04905ae

Please sign in to comment.