55 template<
typename Po
intT>
160 for (
const auto& idx: indexVector_arg)
163 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
164 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
167 avgRed += (colorInt >> 0) & 0xFF;
168 avgGreen += (colorInt >> 8) & 0xFF;
169 avgBlue += (colorInt >> 16) & 0xFF;
173 const auto len =
static_cast<uindex_t> (indexVector_arg.size());
199 encodePoints (
const Indices& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
206 avgRed = avgGreen = avgBlue = 0;
209 for (
const auto& idx: indexVector_arg)
212 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
213 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
216 avgRed += (colorInt >> 0) & 0xFF;
217 avgGreen += (colorInt >> 8) & 0xFF;
218 avgBlue += (colorInt >> 16) & 0xFF;
222 const auto len =
static_cast<uindex_t> (indexVector_arg.size());
225 unsigned char diffRed;
226 unsigned char diffGreen;
227 unsigned char diffBlue;
235 for (
const auto& idx: indexVector_arg)
237 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
238 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
241 diffRed = (
static_cast<unsigned char> (avgRed)) ^
static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
242 diffGreen = (
static_cast<unsigned char> (avgGreen)) ^
static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
243 diffBlue = (
static_cast<unsigned char> (avgBlue)) ^
static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
278 assert (beginIdx_arg <= endIdx_arg);
281 const index_t pointCount = endIdx_arg - beginIdx_arg;
294 for (
index_t i = 0; i < pointCount; i++)
296 unsigned int colorInt;
310 colorInt = ((avgRed ^ diffRed) << 0) |
311 ((avgGreen ^ diffGreen) << 8) |
312 ((avgBlue ^ diffBlue) << 16);
317 colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
320 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
321 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
334 setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
336 assert (beginIdx_arg <= endIdx_arg);
339 auto pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
342 for (std::size_t i = 0; i < pointCount; i++)
344 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
345 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
375 template<
typename Po
intT>
383 #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()=default
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.
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.
ColorCoding()=default
Constructor.
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.