Output the simulated output to file:
| 40 | |
| 41 | // Output the simulated output to file: |
| 42 | void |
| 43 | write_sim_output(const std::string& fname_root) |
| 44 | { |
| 45 | pcl::PointCloud<pcl::PointXYZRGB>::Ptr pc_out(new pcl::PointCloud<pcl::PointXYZRGB>); |
| 46 | |
| 47 | // Read Color Buffer from the GPU before creating PointCloud: |
| 48 | // By default the buffers are not read back from the GPU |
| 49 | simexample->rl_->getColorBuffer(); |
| 50 | simexample->rl_->getDepthBuffer(); |
| 51 | // Add noise directly to the CPU depth buffer |
| 52 | simexample->rl_->addNoise(); |
| 53 | |
| 54 | // Optional argument to save point cloud in global frame: |
| 55 | // Save camera relative: |
| 56 | // simexample->rl_->getPointCloud(pc_out); |
| 57 | // Save in global frame - applying the camera frame: |
| 58 | // simexample->rl_->getPointCloud(pc_out,true,simexample->camera_->getPose()); |
| 59 | // Save in local frame |
| 60 | simexample->rl_->getPointCloud(pc_out, false, simexample->camera_->getPose()); |
| 61 | // TODO: what to do when there are more than one simulated view? |
| 62 | |
| 63 | if (!pc_out->points.empty()) { |
| 64 | std::cout << pc_out->size() << " points written to file\n"; |
| 65 | |
| 66 | pcl::PCDWriter writer; |
| 67 | // writer.write ( string (fname_root + ".pcd"), *pc_out, false); /// ASCII |
| 68 | writer.writeBinary(std::string(fname_root + ".pcd"), *pc_out); |
| 69 | // std::cout << "finished writing file\n"; |
| 70 | } |
| 71 | else { |
| 72 | std::cout << pc_out->size() << " points in cloud, not written\n"; |
| 73 | } |
| 74 | |
| 75 | // simexample->write_score_image (simexample->rl_->getScoreBuffer (), |
| 76 | // string (fname_root + "_score.png") ); |
| 77 | simexample->write_rgb_image(simexample->rl_->getColorBuffer(), |
| 78 | std::string(fname_root + "_rgb.png")); |
| 79 | simexample->write_depth_image(simexample->rl_->getDepthBuffer(), |
| 80 | std::string(fname_root + "_depth.png")); |
| 81 | // simexample->write_depth_image_uint (simexample->rl_->getDepthBuffer (), |
| 82 | // string (fname_root + "_depth_uint.png") ); |
| 83 | |
| 84 | // Demo interacton with RangeImage: |
| 85 | pcl::RangeImagePlanar rangeImage; |
| 86 | simexample->rl_->getRangeImagePlanar(rangeImage); |
| 87 | } |
| 88 | |
| 89 | // A 'halo' camera - a circular ring of poses all pointing at a center point |
| 90 | // @param: focus_center: the center points |
no test coverage detected