55 template<
typename Po
intT>
165 for (
const auto& idx: indexVector_arg)
168 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
169 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
172 avgRed += (colorInt >> 0) & 0xFF;
173 avgGreen += (colorInt >> 8) & 0xFF;
174 avgBlue += (colorInt >> 16) & 0xFF;
204 encodePoints (
const Indices& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
211 avgRed = avgGreen = avgBlue = 0;
214 for (
const auto& idx: indexVector_arg)
217 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
218 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
221 avgRed += (colorInt >> 0) & 0xFF;
222 avgGreen += (colorInt >> 8) & 0xFF;
223 avgBlue += (colorInt >> 16) & 0xFF;
230 unsigned char diffRed;
231 unsigned char diffGreen;
232 unsigned char diffBlue;
240 for (
const auto& idx: indexVector_arg)
242 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
243 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
246 diffRed = (
static_cast<unsigned char> (avgRed)) ^
static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
247 diffGreen = (
static_cast<unsigned char> (avgGreen)) ^
static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
248 diffBlue = (
static_cast<unsigned char> (avgBlue)) ^
static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
283 assert (beginIdx_arg <= endIdx_arg);
286 const index_t pointCount = endIdx_arg - beginIdx_arg;
299 for (
index_t i = 0; i < pointCount; i++)
301 unsigned int colorInt;
315 colorInt = ((avgRed ^ diffRed) << 0) |
316 ((avgGreen ^ diffGreen) << 8) |
317 ((avgBlue ^ diffBlue) << 16);
322 colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
325 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
326 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
339 setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
341 assert (beginIdx_arg <= endIdx_arg);
344 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
347 for (std::size_t i = 0; i < pointCount; i++)
349 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
350 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
380 template<
typename Po
intT>
388 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
void decodePoints(PointCloudPtr outputCloud_arg, uindex_t beginIdx_arg, uindex_t endIdx_arg, unsigned char rgba_offset_arg)
Decode color information.
void encodeAverageOfPoints(const Indices &indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
Encode averaged color information for a subset of points from point cloud.
std::vector< char > & getAverageDataVector()
Get reference to vector containing averaged color data.
void initializeDecoding()
Initialize decoding of color information.
void setDefaultColor(PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg)
Set default color to points.
std::vector< char > pointDiffColorDataVector_
Vector for storing differential color information
std::vector< char > pointAvgColorDataVector_
Vector for storing average color information
std::vector< char >::const_iterator pointAvgColorDataVector_Iterator_
Iterator on average color information vector.
void initializeEncoding()
Initialize encoding of color information.
virtual ~ColorCoding()
Empty class constructor.
unsigned char colorBitReduction_
Amount of bits to be removed from color components before encoding.
unsigned char getBitDepth()
Retrieve color bit depth of encoded color information.
ColorCoding()
Constructor.
std::vector< char > & getDifferentialDataVector()
Get reference to vector containing differential color data.
void encodePoints(const Indices &indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
Encode color information of a subset of points from point cloud.
std::vector< char >::const_iterator pointDiffColorDataVector_Iterator_
Iterator on differential color information vector.
void setVoxelCount(unsigned int voxelCount_arg)
Set amount of voxels containing point color information and reserve memory.
static const int defaultColor_
void setBitDepth(unsigned char bitDepth_arg)
Define color bit depth of encoded color information.
void setPointCount(unsigned int pointCount_arg)
Set amount of points within point cloud to be encoded and reserve memory.
PointCloudPtr output_
Pointer to output point cloud dataset.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.