1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include <librealsense2/rs.hpp>
- #include <iostream>
- int main(int argc, char *argv[])
- try
- {
- rs2::pointcloud pc;
- rs2::points points;
- rs2::pipeline pipe;
- pipe.start();
- auto frames = pipe.wait_for_frames();
- auto color = frames.get_color_frame();
- // For cameras that don't have RGB sensor, we'll map the pointcloud to infrared instead of color
- if (!color)
- color = frames.get_infrared_frame();
- pc.map_to(color);
- auto depth = frames.get_depth_frame();
- points = pc.calculate(depth);
- points.export_to_ply("test.ply", color);
- return EXIT_SUCCESS;
- }
- catch (const rs2::error &e)
- {
- std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
- return EXIT_FAILURE;
- }
- catch (const std::exception &e)
- {
- std::cerr << e.what() << std::endl;
- return EXIT_FAILURE;
- }
|