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 ...
随机推荐
- idea上 实现了Serializable接口,要自动生成serialVersionUID的方法
需要点进setting ->搜索Inspections-->右侧选择java 下拉 进入Serialization issue--->勾选Serializable class wit ...
- Java面试题及答案解析
面向对象编程(OOP) Java是一个支持并发.基于类和面向对象的计算机编程语言.下面列出了面向对象软件开发的优点: 代码开发模块化,更易维护和修改. 代码复用. 增强代码的可靠性和灵活性. 增加代码 ...
- 使用Nginx实现反向代理 - 不同的子域名映射到不同的后台地址
1.配置IP域名 C:\Windows\System32\drivers\etc\hosts中加入 127.0.0.1 8081.max.com 127.0.0.1 8082.max.com 2.配置 ...
- Topshelf 使用
前言 在写后台代码的过程中,经常会遇到要写一些单独的服务.以前呢,直接用的是 .NET 下的 “Windows 服务” 控件开发的. 这个传统的控件开发起来很不方面,使用也不友好.发现有用 Topsh ...
- m_strcmp
strcmp比较两个字符串的大小,strcmp(str1, str2); 从str1和str2的第一个元素比较直到出现不同,或者遇到'\0'结束.如果str1 > str2 返回正数,str1 ...
- 个人项目———Java实现WordCount
2018年系统分析与设计—个人项目作业 题目来自于 :https://edu.cnblogs.com/campus/xnsy/2018Systemanalysisanddesign/homework/ ...
- 关于Mybatis查询结果的封装
1.结果封装为List<Object> 接口示例: public List<Members> selectMembersListByName(String name); 配置文 ...
- HTML5 服务器发送事件(Server-Sent Events)
沈阳SEO:HTML5 服务器发送事件(server-sent event)允许网页获得来自服务器的更新. Server-Sent 事件 - 单向消息传递 Server-Sent 事件指的是网页自动获 ...
- ACWing P372 棋盘覆盖 题解
Analysis 这是一个经典的二分图问题,我们将图进行奇偶染色,注意边界条件的判断.再跑一遍匈牙利算法就行了,跟上一题很像. #include<iostream> #include< ...
- BZOJ 4368: [IOI2015]boxes纪念品盒 贪心
题意:给定一个环,环上有一些点包裹,你要从 $0$ 号点出发,然后每次带上一个容量为 $k$ 的背包. 问:如果要把所有的包裹都带回 $0$ 好点最少要走多少距离. 每一次只有 $3$ 种走法:走整圆 ...