42 #ifndef PCL_GPU_PEOPLE_LABEL_SEGMENT_H_ 43 #define PCL_GPU_PEOPLE_LABEL_SEGMENT_H_ 46 #include "pcl/gpu/people/label_blob2.h" 47 #include "pcl/gpu/people/label_common.h" 56 #include <pcl/point_cloud.h> 58 #include <pcl/conversions.h> 59 #include <pcl/common/eigen.h> 62 #include <pcl/PointIndices.h> 72 namespace label_skeleton
246 assert(lmap_in.depth() == CV_8UC1);
247 assert(dmap.depth() == CV_16U);
248 assert(lmap_out.depth() == CV_8UC1);
250 assert(lmap_in.rows == dmap.rows);
251 assert(lmap_in.cols == dmap.cols);
252 assert(lmap_out.rows == dmap.rows);
253 assert(lmap_out.cols == dmap.cols);
256 unsigned int half_patch = 2;
257 unsigned int depthThres = 300;
260 unsigned int endrow = (lmap_in.rows - half_patch);
261 unsigned int endcol = (lmap_in.cols - half_patch);
263 unsigned int endheight, endwidth;
267 const short* drow_offset;
268 const char* lrow_offset;
271 for(
unsigned int h = (0 + half_patch); h < endrow; h++)
273 endheight = (h + half_patch);
275 drow = dmap.ptr<
short>(h);
276 loutrow = lmap_out.ptr<
char>(h);
279 for(
unsigned int w = (0 + half_patch); w < endcol; w++)
281 endwidth = (w + half_patch);
289 for(
unsigned int h_l = (h - half_patch); h_l <= endheight; h_l++)
291 drow_offset = dmap.ptr<
short>(h_l);
292 lrow_offset = lmap_in.ptr<
char>(h_l);
295 for(
unsigned int w_l = (w - half_patch); w_l <= endwidth; w_l++)
298 depth_l = drow_offset[w_l];
300 if(abs(depth - depth_l) <
static_cast<int> (depthThres))
302 label = lrow_offset[w_l];
303 votes[
static_cast<unsigned int>(label)]++;
308 unsigned int max = 0;
313 if(votes[static_cast<unsigned int>(i)] > max)
315 max = votes[
static_cast<unsigned int>(i)];
333 unsigned int sizeThres,
334 std::vector< std::vector<
Blob2, Eigen::aligned_allocator<Blob2> > >& sorted,
335 std::vector< std::vector<pcl::PointIndices> >& indices)
337 assert(sorted.size () == indices.size ());
341 for(
unsigned int lab = 0; lab < indices.size(); ++lab)
343 unsigned int lid = 0;
345 for(
unsigned int l = 0; l < indices[lab].size(); l++)
348 if(indices[lab][l].indices.size() > sizeThres)
369 sorted[lab].push_back(b);
383 std::cout <<
"(I) : giveSortedBlobsInfo(): Size of outer vector: " << sorted.size() << std::endl;
384 for(
unsigned int i = 0; i < sorted.size(); i++)
386 std::cout <<
"(I) : giveSortedBlobsInfo(): Found " << sorted[i].size() <<
" parts of type " << i << std::endl;
387 std::cout <<
"(I) : giveSortedBlobsInfo(): indices : ";
388 for(
unsigned int j = 0; j < sorted[i].size(); j++)
390 std::cout <<
" id:" << sorted[i][j].id <<
" lid:" << sorted[i][j].lid;
392 std::cout << std::endl;
401 #endif //#ifndef LABELSKEL_SEGMENT_H
part_t
Our code is forseen to use maximal use 32 labels.
void smoothLabelImage(cv::Mat &lmap_in, cv::Mat &dmap, cv::Mat &lmap_out)
this function smooths the label image based on label and depth
Define standard C methods and C++ classes that are common to all methods.
pcl::PointIndices indices
Defines all the PCL implemented PointT point type structures.
void getMinMax3D(const pcl::PointCloud< PointT > &cloud, PointT &min_pt, PointT &max_pt)
Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud...
int giveSortedBlobsInfo(std::vector< std::vector< Blob2, Eigen::aligned_allocator< Blob2 > > > &sorted)
This function is a stupid helper function to debug easilier, it print out how the matrix was sorted...
void sortIndicesToBlob2(const pcl::PointCloud< pcl::PointXYZ > &cloud_in, unsigned int sizeThres, std::vector< std::vector< Blob2, Eigen::aligned_allocator< Blob2 > > > &sorted, std::vector< std::vector< pcl::PointIndices > > &indices)
This function takes a number of indices with label and sorts them in the blob matrix.
void eigen33(const Matrix &mat, typename Matrix::Scalar &eigenvalue, Vector &eigenvector)
determines the eigenvector and eigenvalue of the smallest eigenvalue of the symmetric positive semi d...
unsigned int computeCovarianceMatrixNormalized(const pcl::PointCloud< PointT > &cloud, const Eigen::Matrix< Scalar, 4, 1 > ¢roid, Eigen::Matrix< Scalar, 3, 3 > &covariance_matrix)
Compute normalized the 3x3 covariance matrix of a given set of points.
unsigned int compute3DCentroid(ConstCloudIterator< PointT > &cloud_iterator, Eigen::Matrix< Scalar, 4, 1 > ¢roid)
Compute the 3D (X-Y-Z) centroid of a set of points and return it as a 3D vector.
Eigen::Matrix3f eigenvect
Define methods for measuring time spent in code blocks.
Define methods for centroid estimation and covariance matrix calculus.
This structure containts all parameters to describe blobs and their parent/child relations.