Last active
December 27, 2022 14:31
-
-
Save UnaNancyOwen/40195f32a9ad4fa09ac5 to your computer and use it in GitHub Desktop.
Convert to cv::Mat from pcl::PointCloud<pcl::PointXYZRGBA> that retrieved from Kinect v1/v2 sensor using KinectGrabber/Kinect2Grabber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( !cloud->empty() ){ | |
// Create cv::Mat | |
image = cv::Mat( cloud->height, cloud->width, CV_8UC4 ); | |
// pcl::PointCloud to cv::Mat | |
#pragma omp parallel for | |
for( int y = 0; y < image.rows; y++ ) { | |
for( int x = 0; x < image.cols; x++ ) { | |
pcl::PointXYZRGBA point = cloud->at( x, y ); | |
image.at<cv::Vec4b>( y, x )[0] = point.b; | |
image.at<cv::Vec4b>( y, x )[1] = point.g; | |
image.at<cv::Vec4b>( y, x )[2] = point.r; | |
image.at<cv::Vec4b>( y, x )[3] = point.a; | |
} | |
} | |
} |
Author
UnaNancyOwen
commented
Mar 15, 2016
maybe should be
auto image = cv::Mat( cloud->height, cloud->width, CV_8UC4 );
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment