Ask Your Question

Flamenco's profile - activity

2019-06-30 13:50:42 -0600 received badge  Notable Question (source)
2016-10-26 14:03:43 -0600 received badge  Popular Question (source)
2012-08-08 22:17:55 -0600 received badge  Supporter (source)
2012-07-24 02:38:28 -0600 received badge  Nice Question (source)
2012-07-24 02:13:34 -0600 received badge  Student (source)
2012-07-22 22:43:39 -0600 asked a question pcl::PointCloud to cv::Mat -> optimal way?

Hi everybody!

I would like to transform my point cloud 3D coordinates:

pcl::PointCloud<pcl::PointXYZ> point_cloud;

to an OpenCV matrix:

cv::Mat point_cloud_matrix;

I could define a 3 channel float matrix with one row per point in the point cloud, like this:

cv::Mat point_cloud_matrix(point_cloud.points.size(), 1, CV_32FC3);

and then manually copy each point on the point cloud to the matrix. But, it feels like a little bit brute force approach.

Can anyone suggest a more elegant way to do it? My ultimate goal is to apply OpenCV's k-means algorithm to extract clusters of points.

Thanks in advance!