点云数据采集课题------Realsence SR300深度摄像机学习------官方SDK中例子学习

Realsence SR300深度摄像机源码学习

  • 官方SDK2中结合pcl获取点云的例子

官方SDK2中结合pcl获取点云的例子

// License: Apache 2.0. See LICENSE file in root directory.
// 许可证:Apache2.0。请参阅根目录中的许可文件。
// Copyright(c) 2015-2017 Intel Corporation. All Rights Reserved.
// 版权所有(c)2015-2017英特尔公司。保留所有权利。

#include  // Include RealSense Cross Platform API |包括RealSense跨平台API
#include "example.hpp"          // Include short list of convenience functions for rendering |包括用于呈现的便利函数的简短列表

#include             // std::min, std::max

// Helper functions |帮手函数
void register_glfw_callbacks(window& app, glfw_state& app_state);

int main(int argc, char * argv[]) try
{
     
    // Create a simple OpenGL window for rendering:
	// 创建一个简单的OpenGL窗口进行渲染:
    window app(1280, 720, "RealSense Pointcloud Example");
    // Construct an object to manage view state
	// 构造一个对象来管理视图状态
    glfw_state app_state;
    // register callbacks to allow manipulation of the pointcloud
	// 注册回调以允许操作点云
    register_glfw_callbacks(app, app_state);

    // Declare pointcloud object, for calculating pointclouds and texture mappings
	// 声明pointcloud对象,用于计算pointclouds和纹理映射
    rs2::pointcloud pc;
    // We want the points object to be persistent so we can display the last cloud when a frame drops、
	// 我们希望points对象是持久的,以便在帧下降时显示最后一个云
    rs2::points points;

    // Declare RealSense pipeline, encapsulating the actual device and sensors
	// 声明RealSense管道,封装实际设备和传感器
    rs2::pipeline pipe;
    // Start streaming with default recommended configuration
	// 使用默认推荐配置启动流式处理
    pipe.start();

    while (app) // Application still alive? |判定程序是否关闭
    {
     
        // Wait for the next set of frames from the camera |等待相机的下一组帧
        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
		// 对于没有RGB传感器的相机,我们将把点云映射到红外而不是颜色
        if (!color)
            color = frames.get_infrared_frame();

        // Tell pointcloud object to map to this color frame
		// 告诉pointcloud对象映射到此颜色框架
        pc.map_to(color);

        auto depth = frames.get_depth_frame();

        // Generate the pointcloud and texture mappings
		// 生成点云和纹理映射
        points = pc.calculate(depth);

        // Upload the color frame to OpenGL
		// 将颜色框架上传到OpenGL
        app_state.tex.upload(color);

        // Draw the pointcloud
		// 绘制点云
        draw_pointcloud(app.width(), app.height(), app_state, points);
    }

    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;
}

你可能感兴趣的:(好像没干啥,C++)