MI Lab/Intel RealSense - 2022.02~2022.06

[RealSense] rs-capture 예제 실행

코딩뽀시래기 2022. 2. 23. 20:53
728x90

일단 거리값을 가져오는 예제를 실행해보면서 realsense가 제대로 동작하고 있다는 것은 알아봤다. 다음으로 시각적으로 볼 수 있는 예제를 실행해보고 싶어서 rs-capture 예제를 테스트 해봤다.

 

https://dev.intelrealsense.com/docs/rs-capture

 

rs-capture

Streaming and rendering Depth & RGB data to the screen

dev.intelrealsense.com

 

// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include "example.hpp"          // Include short list of convenience functions for rendering

// Capture Example demonstrates how to
// capture depth and color video streams and render them to the screen
int main(int argc, char* argv[]) try
{
    rs2::log_to_console(RS2_LOG_SEVERITY_ERROR);
    // Create a simple OpenGL window for rendering:
    window app(1280, 720, "RealSense Capture Example");

    // Declare depth colorizer for pretty visualization of depth data
    rs2::colorizer color_map;
    // Declare rates printer for showing streaming rates of the enabled streams.
    rs2::rates_printer printer;

    // Declare RealSense pipeline, encapsulating the actual device and sensors
    rs2::pipeline pipe;

    // Start streaming with default recommended configuration
    // The default video configuration contains Depth and Color streams
    // If a device is capable to stream IMU data, both Gyro and Accelerometer are enabled by default
    pipe.start();

    while (app) // Application still alive?
    {
        rs2::frameset data = pipe.wait_for_frames().    // Wait for next set of frames from the camera
            apply_filter(printer).     // Print each enabled stream frame rate
            apply_filter(color_map);   // Find and colorize the depth data

// The show method, when applied on frameset, break it to frames and upload each frame into a gl textures
// Each texture is displayed on different viewport according to it's stream unique id
        app.show(data);
    }

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

 당연히 example.hpp를 사용하기 위해 헤더파일로 추가해줬고, example.hpp에서 example-utils.hpp를 필요로 하는 것 같아서 그것도 추가해줬다.

 

+) 참고

https://github.com/IntelRealSense/librealsense/tree/master/examples

 

GitHub - IntelRealSense/librealsense: Intel® RealSense™ SDK

Intel® RealSense™ SDK. Contribute to IntelRealSense/librealsense development by creating an account on GitHub.

github.com

 

그런데...! 또 오류 발생.

이젠 없으면 허전할 거 같은 오류들... 또 해결을 해보자.

728x90