gpu_seeded_hue_segmentation.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id:$
*
*/
#ifndef PCL_GPU_SEEDED_HUE_SEGMENTATION_H_
#define PCL_GPU_SEEDED_HUE_SEGMENTATION_H_
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/PointIndices.h>
#include <pcl/pcl_macros.h>
#include <pcl/gpu/octree/octree.hpp>
#include <pcl/gpu/containers/device_array.hpp>
namespace pcl
{
namespace gpu
{
void
seededHueSegmentation (const boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> > &host_cloud_,
const pcl::gpu::Octree::Ptr &tree,
float tolerance,
PointIndices &clusters_in,
PointIndices &clusters_out,
float delta_hue = 0.0);
class SeededHueSegmentation
{
public:
typedef pcl::PointXYZ PointType;
typedef pcl::PointCloud<pcl::PointXYZ> PointCloudHost;
typedef PointCloudHost::Ptr PointCloudHostPtr;
typedef PointCloudHost::ConstPtr PointCloudHostConstPtr;
typedef PointIndices::Ptr PointIndicesPtr;
typedef PointIndices::ConstPtr PointIndicesConstPtr;
typedef pcl::gpu::Octree GPUTree;
typedef pcl::gpu::Octree::Ptr GPUTreePtr;
typedef pcl::gpu::Octree::PointCloud CloudDevice;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** \brief Empty constructor. */
SeededHueSegmentation () : delta_hue_ (0.0)
{};
/** \brief Provide a pointer to the search object.
* \param tree a pointer to the spatial search object.
*/
inline void setSearchMethod (const GPUTreePtr &tree) { tree_ = tree; }
/** \brief Get a pointer to the search method used.
* @todo fix this for a generic search tree
*/
inline GPUTreePtr getSearchMethod () { return (tree_); }
/** \brief Set the spatial cluster tolerance as a measure in the L2 Euclidean space
* \param tolerance the spatial cluster tolerance as a measure in the L2 Euclidean space
*/
inline void setClusterTolerance (double tolerance) { cluster_tolerance_ = tolerance; }
/** \brief Get the spatial cluster tolerance as a measure in the L2 Euclidean space. */
inline double getClusterTolerance () { return (cluster_tolerance_); }
inline void setInput (CloudDevice input) {input_ = input;}
inline void setHostCloud (PointCloudHostPtr host_cloud) {host_cloud_ = host_cloud;}
/** \brief Set the tollerance on the hue
* \param[in] delta_hue the new delta hue
*/
inline void
setDeltaHue (float delta_hue) { delta_hue_ = delta_hue; }
/** \brief Get the tolerance on the hue */
inline float
getDeltaHue () { return (delta_hue_); }
/** \brief Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
* \param indices_in
* \param indices_out
*/
void segment (PointIndices &indices_in, PointIndices &indices_out);
protected:
/** \brief the input cloud on the GPU */
CloudDevice input_;
/** \brief the original cloud the Host */
PointCloudHostPtr host_cloud_;
/** \brief A pointer to the spatial search object. */
GPUTreePtr tree_;
/** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */
double cluster_tolerance_;
/** \brief The allowed difference on the hue*/
float delta_hue_;
/** \brief Class getName method. */
virtual std::string getClassName () const { return ("gpu::SeededHueSegmentation"); }
};
/** \brief Sort clusters method (for std::sort).
* \ingroup segmentation
*/
inline bool
comparePointClusters (const pcl::PointIndices &a, const pcl::PointIndices &b)
{
return (a.indices.size () < b.indices.size ());
}
}
}
#endif //PCL_GPU_SEEDED_HUE_SEGMENTATION_H_
pcl::gpu::SeededHueSegmentation::setClusterTolerance
void setClusterTolerance(double tolerance)
Set the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:96
pcl::gpu::SeededHueSegmentation::setDeltaHue
void setDeltaHue(float delta_hue)
Set the tollerance on the hue.
Definition: gpu_seeded_hue_segmentation.h:109
pcl::gpu::SeededHueSegmentation::host_cloud_
PointCloudHostPtr host_cloud_
the original cloud the Host
Definition: gpu_seeded_hue_segmentation.h:126
pcl
Definition: convolution.h:45
pcl::gpu::Octree::Ptr
boost::shared_ptr< Octree > Ptr
Types.
Definition: octree.hpp:67
pcl::gpu::SeededHueSegmentation::PointIndicesPtr
PointIndices::Ptr PointIndicesPtr
Definition: gpu_seeded_hue_segmentation.h:70
pcl::PointIndices::indices
std::vector< int > indices
Definition: PointIndices.h:19
pcl::gpu::SeededHueSegmentation::getSearchMethod
GPUTreePtr getSearchMethod()
Get a pointer to the search method used.
Definition: gpu_seeded_hue_segmentation.h:91
pcl::gpu::Octree
Octree implementation on GPU.
Definition: octree.hpp:56
pcl::gpu::comparePointClusters
bool comparePointClusters(const pcl::PointIndices &a, const pcl::PointIndices &b)
Sort clusters method (for std::sort).
Definition: gpu_extract_clusters.h:162
pcl::gpu::SeededHueSegmentation::tree_
GPUTreePtr tree_
A pointer to the spatial search object.
Definition: gpu_seeded_hue_segmentation.h:129
pcl::PointCloud< pcl::PointXYZ >::Ptr
boost::shared_ptr< PointCloud< pcl::PointXYZ > > Ptr
Definition: point_cloud.h:428
pcl::gpu::SeededHueSegmentation::getClassName
virtual std::string getClassName() const
Class getName method.
Definition: gpu_seeded_hue_segmentation.h:138
pcl::gpu::SeededHueSegmentation::SeededHueSegmentation
SeededHueSegmentation()
Empty constructor.
Definition: gpu_seeded_hue_segmentation.h:80
pcl::gpu::DeviceArray< PointType >
pcl::PointIndices
Definition: PointIndices.h:12
point_types.h
Defines all the PCL implemented PointT point type structures.
pcl::PointXYZ
A point structure representing Euclidean xyz coordinates.
Definition: point_types.hpp:281
pcl::gpu::SeededHueSegmentation::CloudDevice
pcl::gpu::Octree::PointCloud CloudDevice
Definition: gpu_seeded_hue_segmentation.h:76
pcl::gpu::SeededHueSegmentation::setSearchMethod
void setSearchMethod(const GPUTreePtr &tree)
Provide a pointer to the search object.
Definition: gpu_seeded_hue_segmentation.h:86
pcl::PointCloud< pcl::PointXYZ >::ConstPtr
boost::shared_ptr< const PointCloud< pcl::PointXYZ > > ConstPtr
Definition: point_cloud.h:429
pcl::gpu::SeededHueSegmentation::delta_hue_
float delta_hue_
The allowed difference on the hue.
Definition: gpu_seeded_hue_segmentation.h:135
pcl::PointCloud< pcl::PointXYZRGB >
pcl::gpu::SeededHueSegmentation::PointCloudHostConstPtr
PointCloudHost::ConstPtr PointCloudHostConstPtr
Definition: gpu_seeded_hue_segmentation.h:68
pcl::gpu::SeededHueSegmentation::segment
void segment(PointIndices &indices_in, PointIndices &indices_out)
Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
Definition: gpu_seeded_hue_segmentation.hpp:141
pcl::gpu::SeededHueSegmentation::GPUTree
pcl::gpu::Octree GPUTree
Definition: gpu_seeded_hue_segmentation.h:73
pcl::PointIndices::Ptr
boost::shared_ptr< ::pcl::PointIndices > Ptr
Definition: PointIndices.h:22
pcl::gpu::SeededHueSegmentation
Definition: gpu_seeded_hue_segmentation.h:62
pcl::gpu::SeededHueSegmentation::input_
CloudDevice input_
the input cloud on the GPU
Definition: gpu_seeded_hue_segmentation.h:123
pcl::gpu::SeededHueSegmentation::PointType
pcl::PointXYZ PointType
Definition: gpu_seeded_hue_segmentation.h:65
pcl::gpu::SeededHueSegmentation::getDeltaHue
float getDeltaHue()
Get the tolerance on the hue.
Definition: gpu_seeded_hue_segmentation.h:113
pcl::gpu::SeededHueSegmentation::GPUTreePtr
pcl::gpu::Octree::Ptr GPUTreePtr
Definition: gpu_seeded_hue_segmentation.h:74
pcl::gpu::SeededHueSegmentation::PointIndicesConstPtr
PointIndices::ConstPtr PointIndicesConstPtr
Definition: gpu_seeded_hue_segmentation.h:71
pcl::gpu::SeededHueSegmentation::setInput
void setInput(CloudDevice input)
Definition: gpu_seeded_hue_segmentation.h:101
pcl::gpu::SeededHueSegmentation::PointCloudHostPtr
PointCloudHost::Ptr PointCloudHostPtr
Definition: gpu_seeded_hue_segmentation.h:67
pcl::gpu::seededHueSegmentation
void seededHueSegmentation(const boost::shared_ptr< pcl::PointCloud< pcl::PointXYZRGB > > &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, PointIndices &clusters_in, PointIndices &clusters_out, float delta_hue=0.0)
pcl::gpu::SeededHueSegmentation::PointCloudHost
pcl::PointCloud< pcl::PointXYZ > PointCloudHost
Definition: gpu_seeded_hue_segmentation.h:66
pcl::gpu::SeededHueSegmentation::setHostCloud
void setHostCloud(PointCloudHostPtr host_cloud)
Definition: gpu_seeded_hue_segmentation.h:103
pcl::gpu::SeededHueSegmentation::getClusterTolerance
double getClusterTolerance()
Get the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:99
pcl::PointIndices::ConstPtr
boost::shared_ptr< ::pcl::PointIndices const > ConstPtr
Definition: PointIndices.h:23
pcl::gpu::SeededHueSegmentation::cluster_tolerance_
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:132