rs-save-to-disk.cpp

// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015-2017 Intel Corporation. All Rights Reserved. #include <librealsense2/rs.hpp> // Include RealSense Cross Platform API #include <fstream> // File IO
#include <iostream> // Terminal IO
#include <sstream> // Stringstreams // 3rd party header for writing png files
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h" // Helper function for writing metadata to disk as a csv file
void metadata_to_csv(const rs2::frame& frm, const std::string& filename); // This sample captures 30 frames and writes the last frame to disk.
// It can be useful for debugging an embedded system with no display.
int main(int argc, char * argv[]) try
{
// Declare depth colorizer for pretty visualization of depth data
rs2::colorizer color_map; // Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Start streaming with default recommended configuration
pipe.start(); // Capture 30 frames to give autoexposure, etc. a chance to settle
for (auto i = ; i < ; ++i) pipe.wait_for_frames(); // Wait for the next set of frames from the camera. Now that autoexposure, etc.
// has settled, we will write these to disk
for (auto&& frame : pipe.wait_for_frames())
{
// We can only save video frames as pngs, so we skip the rest
if (auto vf = frame.as<rs2::video_frame>())
{
auto stream = frame.get_profile().stream_type();
// Use the colorizer to get an rgb image for the depth stream
if (vf.is<rs2::depth_frame>()) vf = color_map(frame); // Write images to disk
std::stringstream png_file;
png_file << "rs-save-to-disk-output-" << vf.get_profile().stream_name() << ".png";
stbi_write_png(png_file.str().c_str(), vf.get_width(), vf.get_height(),
vf.get_bytes_per_pixel(), vf.get_data(), vf.get_stride_in_bytes());
std::cout << "Saved " << png_file.str() << std::endl; // Record per-frame metadata for UVC streams
std::stringstream csv_file;
csv_file << "rs-save-to-disk-output-" << vf.get_profile().stream_name()
<< "-metadata.csv";
metadata_to_csv(vf, csv_file.str());
}
} 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;
} void metadata_to_csv(const rs2::frame& frm, const std::string& filename)
{
std::ofstream csv; csv.open(filename); // std::cout << "Writing metadata to " << filename << endl;
csv << "Stream," << rs2_stream_to_string(frm.get_profile().stream_type()) << "\nMetadata Attribute,Value\n"; // Record all the available metadata attributes
for (size_t i = ; i < RS2_FRAME_METADATA_COUNT; i++)
{
if (frm.supports_frame_metadata((rs2_frame_metadata_value)i))
{
csv << rs2_frame_metadata_to_string((rs2_frame_metadata_value)i) << ","
<< frm.get_frame_metadata((rs2_frame_metadata_value)i) << "\n";
}
} csv.close();
}

Realsense D430 save的更多相关文章

  1. Realsense D430 python pointclound

    来自:https://github.com/IntelRealSense/librealsense/issues/1231------------------------------ import p ...

  2. VIN-Fusion config with Realsense D435i

    ### First shot Copy the .launch file in package VINS-Fusion to the directory of realsense2_cameara/l ...

  3. ubuntu连接多个realsense d435

    ubuntu连接多个realsense d435 import pyrealsense2 as rs import numpy as np import cv2 import time import ...

  4. Backbone中的model和collection在做save或者create操作时, 如何选择用POST还是PUT方法 ?

    Model和Collection和后台的WEB server进行数据同步非常方便, 都只需要在实行里面添加一url就可以了,backbone会在model进行save或者collection进行cre ...

  5. redis-内存异常 Redis is configured to save RDB snapshots解决

    连接reids获取数据时提示 Redis is configured to save RDB snapshots, but is currently not able to persist on di ...

  6. (error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk

    今天运行Redis时发生错误,错误信息如下: (error) MISCONF Redis is configured to save RDB snapshots, but is currently n ...

  7. Money, save or spend, this is a problem .

    Win a lottery? Had a great hand at the casino? Did fortune shine upon you in the stock market? 彩票中了大 ...

  8. canvas的save与restore方法的作用

    网上搜罗了一堆资料,最后总结一下. save:用来保存Canvas的状态.save之后,可以调用Canvas的平移.放缩.旋转.错切.裁剪等操作. restore:用来恢复Canvas之前保存的状态. ...

  9. Unity 好坑的Save Scene

    在编辑一个Untiy工程的时候,有很多的教程提到了 "Save Scene",也知道是干么用的.但是,后面打开工程的时候,工程界面是很多东西都不见了,又忘了有个Save Scene ...

随机推荐

  1. Spring Boot 2发送邮件手把手图文教程

    原文:http://www.itmuch.com/spring-boot/send-email/ 本文基于:Spring Boot 2.1.3,理论支持Spring Boot 2.x所有版本. 最近有 ...

  2. mniGraffle常用快捷键

    OmniGraffle 是 Mac 上的绘图利器.Graffle 在很多方面对标 Windows 系统上的 Microsoft Visio,是制作各种文档的绝妙工具. 变换移动 放大:Cmd+Shif ...

  3. PWA相关代码

    sw.js 文件 let CacheName = 'plus-v1'; var filesToCache = [ ]; self.addEventListener('install', functio ...

  4. jquerymobile tap事件被触发两次

    首先介绍一下这个问题出现的背景:我在写网站时想要一套代码兼容手机端和pc端,所以用了jquery和jquery mobile,点击事件用的jquerymobile tap事件,但是在移动端测试时出现点 ...

  5. mysql - 所有笔记

    # 编码: 1. 查看创建数据库时设置的编码格式: shwo create database 数据库名; 2. 查看创建表时所设置的 编码格式 和 字段详细 show create table 表名; ...

  6. LightOJ-1008-Fibsieve`s Fantabulous Birthday(推公式)

    链接: https://vjudge.net/problem/LightOJ-1008 题意: Fibsieve had a fantabulous (yes, it's an actual word ...

  7. [other] Div

    https://www.luogu.org/problemnew/show/U16765 解法一 随机输出一组合法解. 复杂度 O(1) 预计得分 10~??? 解法二 看完题目基本能想到大力贪心,通 ...

  8. spring boot aop 切库实现读写分离

    项目结构: 主要代码 : 配置数据库 配置datasource 线程隔离: 已上传git gitee地址:https://gitee.com/xxoo0_297/springboot-aop.git

  9. Python3数字

    Python3数字数据类型用于存储数值. 数据类型是不允许改变的,这就意味着,如果改变数字数据类型的值,将重新分配内存空间. Python支持三种不同不同的数值类型: 整型(int):通常是被称为整型 ...

  10. windows7上启动jmeter报错,寻求解决办法?

    背景: 已安装jdk 12,已配置环境变量,点击jmeter.bat 或者进入cmd启动jmter都无法启动 如图: 情况1.在cmd模式下报错 情况2: 打开运行,输入“powershell ise ...