Realsense D430 save
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的更多相关文章
- Realsense D430 python pointclound
来自:https://github.com/IntelRealSense/librealsense/issues/1231------------------------------ import p ...
- VIN-Fusion config with Realsense D435i
### First shot Copy the .launch file in package VINS-Fusion to the directory of realsense2_cameara/l ...
- ubuntu连接多个realsense d435
ubuntu连接多个realsense d435 import pyrealsense2 as rs import numpy as np import cv2 import time import ...
- Backbone中的model和collection在做save或者create操作时, 如何选择用POST还是PUT方法 ?
Model和Collection和后台的WEB server进行数据同步非常方便, 都只需要在实行里面添加一url就可以了,backbone会在model进行save或者collection进行cre ...
- 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 ...
- (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 ...
- 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? 彩票中了大 ...
- canvas的save与restore方法的作用
网上搜罗了一堆资料,最后总结一下. save:用来保存Canvas的状态.save之后,可以调用Canvas的平移.放缩.旋转.错切.裁剪等操作. restore:用来恢复Canvas之前保存的状态. ...
- Unity 好坑的Save Scene
在编辑一个Untiy工程的时候,有很多的教程提到了 "Save Scene",也知道是干么用的.但是,后面打开工程的时候,工程界面是很多东西都不见了,又忘了有个Save Scene ...
随机推荐
- HTTP协议通信原理 与常见报错信息
HTTP协议通信原理 请求报文 请求行 GET index.html HTTP 1.1 请求方法:get 读取服务器数据内容 post 提交存储服务端数据(用户注册) 协议版本: ht ...
- unity之中级必备知识
Mask,Scroll Rect实现图拖拽:新建Imag,添加Mask,Scroll Rect组件:新建Image,托放在Scroll下的Content:新建Scroll Bar实现滚动条的同步:托放 ...
- P2921 [USACO08DEC]在农场万圣节[SCC缩点]
题目描述 每年,在威斯康星州,奶牛们都会穿上衣服,收集农夫约翰在N(1<=N<=100,000)个牛棚隔间中留下的糖果,以此来庆祝美国秋天的万圣节. 由于牛棚不太大,FJ通过指定奶牛必须遵 ...
- IntelliJ IDEA如何默认使用阿里云的Maven仓库
点击IntelliJ IDEA的config中的setting选项 在<mirrors>节点中加上一个子节点,然后保存即可: <mirror> <id>alimav ...
- Windows 对外开放端口号
前记 今天在做 Kafka 消息传输时,本地连接服务器的 Kafka 出现问题.连接不上,想到新的服务器应该是防火墙关闭所致. 我呢,就用了最直接暴力的方法:关闭防火墙~~~~(哈哈哈) 问题是解决了 ...
- 2019-2020-1 20199312《Linux内核原理与分析》第四周作业
计算机和操作系统的法宝 计算机三个法宝 存储程序计算机.函数调用堆栈机制.中断 操作系统:中断中断上下文的切换--保护和恢复现场 进程上下文的切换. Linux源代码目录分析 arch目录:代码量庞大 ...
- Apicloud 之按两次后退键退出应用
api.addEventListener({ name: 'keyback' }, function(ret, err) { if (flag == 1) { api.closeWidget({ si ...
- appium问题汇总(持续更新。。。)
WEBVIEW_unknown adb版本较低,adb 1.0.32版本不支持安卓8.x版本,更新adb版本后正常 Install homebrew ruby -e "$(curl -fsS ...
- hash 算法
Hash,一般翻译做“散列”,也有直接音译为“哈希”的,就是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定长度的输出,该输出就是散列值.这种转换是一种压缩映射,也就是 ...
- *51nod 1815
从若干个数中选出最大的任意两数取模之后的结果 严格次大值 对于此题 首先缩点 然后拓扑排序 维护到达每个点的最大值与严格次大值 感觉思路与代码都OK啊 then.... #include <io ...