Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pcl/visualization/cloud_viewer.h>
- #include <iostream>
- #include <pcl/io/io.h>
- #include <pcl/io/pcd_io.h>
- #include <pcl/point_cloud.h>
- #include <pcl/point_types.h>
- /*
- * Sample code for reading point clouds in the RGB-D Object Dataset using the Point Cloud Library
- *
- * Author: Kevin Lai
- */
- int user_data;
- void
- viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
- {
- viewer.setBackgroundColor (1.0, 0.5, 1.0);
- pcl::PointXYZRGBIM o;
- o.x = 1.0;
- o.y = 0;
- o.z = 0;
- viewer.addSphere (o, 0.25, "sphere", 0);
- std::cout << "i only run once" << std::endl;
- }
- void
- viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
- {
- static unsigned count = 0;
- std::stringstream ss;
- ss << "Once per viewer loop: " << count++;
- viewer.removeShape ("text", 0);
- viewer.addText (ss.str(), 200, 300, "text", 0);
- //FIXME: possible race condition here:
- user_data++;
- }
- struct PointXYZRGBIM
- {
- union
- {
- struct
- {
- float x;
- float y;
- float z;
- float rgb;
- float imX;
- float imY;
- };
- float data[6];
- };
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW
- } EIGEN_ALIGN16;
- POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZRGBIM,
- (float, x, x)
- (float, y, y)
- (float, z, z)
- (float, rgb, rgb)
- (float, imX, imX)
- (float, imY, imY)
- )
- int
- main (int argc, char** argv)
- {
- pcl::PointCloud<PointXYZRGBIM>::Ptr cloud (new pcl::PointCloud<PointXYZRGBIM>);
- if (pcl::io::loadPCDFile<PointXYZRGBIM> ("/home/karan/bowl_1_1_1.pcd", *cloud) == -1) //* load the file
- {
- printf ("Couldn't read file test_pcd.pcd \n");
- return (-1);
- }
- std::cout << "Loaded "
- << cloud->width * cloud->height
- << " data points from test_pcd.pcd with the following fields: "
- << std::endl;
- pcl::visualization::CloudViewer viewer("Cloud Viewer");
- viewer.showCloud(cloud);
- viewer.runOnVisualizationThreadOnce(viewerOneOff);
- viewer.runOnVisualizationThreadOnce(viewerPsycho);
- while (!viewer.wasStopped())
- {
- user_data++;
- }
- return 0;
- /*for (size_t i = 0; i < cloud->points.size (); ++i){
- uint32_t rgb = *reinterpret_cast<int*>(&cloud->points[i].rgb);
- uint8_t r = (rgb >> 16) & 0x0000ff;
- uint8_t g = (rgb >> 8) & 0x0000ff;
- uint8_t b = (rgb) & 0x0000ff;
- std::cout << " " << cloud->points[i].x
- << " " << cloud->points[i].y
- << " " << cloud->points[i].z
- << " " << (int)r
- << " " << (int)g
- << " " << (int)b
- << " " << cloud->points[i].imX
- << " " << cloud->points[i].imY << std::endl;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement