Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
tools
recorder
rs-record.cpp
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3
4
#include <
librealsense2/rs.hpp
>
5
#include <iostream>
6
#include <iomanip>
7
#include <thread>
8
#include <mutex>
9
#include <stdio.h>
10
#include <memory>
11
#include <functional>
12
#include <thread>
13
#include <string.h>
14
#include <chrono>
15
#include "
tclap/CmdLine.h
"
16
17
using namespace
TCLAP
;
18
19
int
main
(
int
argc,
char
* argv[])
try
20
{
21
// Parse command line arguments
22
CmdLine
cmd
(
"librealsense rs-record example tool"
,
' '
);
23
ValueArg<int>
time(
"t"
,
"Time"
,
"Amount of time to record (in seconds)"
,
false
, 10,
""
);
24
ValueArg<std::string>
out_file(
"f"
,
"FullFilePath"
,
"the file where the data will be saved to"
,
false
,
"test.bag"
,
""
);
25
26
cmd.
add
(time);
27
cmd.
add
(out_file);
28
cmd.
parse
(argc, argv);
29
30
rs2::pipeline
pipe
;
31
rs2::config
cfg
;
32
cfg.
enable_record_to_file
(out_file.
getValue
());
33
34
std::mutex
m
;
35
auto
callback
= [&](
const
rs2::frame
& frame)
36
{
37
std::lock_guard<std::mutex>
lock
(m);
38
auto
t
=
std::chrono::system_clock::now
();
39
static
auto
tk =
t
;
40
static
auto
t0
=
t
;
41
if
(
t
- tk >= std::chrono::seconds(1)) {
42
std::cout
<<
"\r"
<< std::setprecision(3) << std::fixed
43
<<
"Recording t = "
<< std::chrono::duration_cast<std::chrono::seconds>(
t
-
t0
).
count
() <<
"s"
<< std::flush;
44
tk =
t
;
45
}
46
};
47
48
rs2::pipeline_profile
profiles
= pipe.
start
(cfg,
callback
);
49
50
auto
t
=
std::chrono::system_clock::now
();
51
auto
t0
=
t
;
52
while
(
t
-
t0
<= std::chrono::seconds(time.
getValue
())) {
53
std::this_thread::sleep_for(std::chrono::milliseconds(10));
54
t
=
std::chrono::system_clock::now
();
55
}
56
std::cout
<<
"\nFinished"
<< std::endl;
57
58
pipe.
stop
();
59
60
return
EXIT_SUCCESS;
61
}
62
catch
(
const
rs2::error
&
e
)
63
{
64
std::cerr
<<
"RealSense error calling "
<< e.
get_failed_function
() <<
"("
<< e.
get_failed_args
() <<
"):\n "
<< e.what() << std::endl;
65
return
EXIT_FAILURE;
66
}
67
catch
(
const
std::exception& e)
68
{
69
std::cerr
<< e.what() << std::endl;
70
return
EXIT_FAILURE;
71
}
rs2::error
Definition:
rs_types.hpp:92
rs2::textual_icons::lock
static const textual_icon lock
Definition:
model-views.h:218
export_ply_example.pipe
pipe
Definition:
export_ply_example.py:18
rs2::config
Definition:
rs_pipeline.hpp:124
rs2::frame
Definition:
rs_frame.hpp:343
rs2::pipeline::stop
void stop()
Definition:
rs_pipeline.hpp:488
opencv_pointcloud_viewer.now
now
Definition:
opencv_pointcloud_viewer.py:302
rs2::pipeline_profile
Definition:
rs_pipeline.hpp:18
m
const GLfloat * m
Definition:
glext.h:6814
t0
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition:
glext.h:9721
main
int main(int argc, char *argv[])
Definition:
rs-record.cpp:19
rs.hpp
TCLAP::ValueArg
Definition:
ValueArg.h:43
rmse.e
e
Definition:
rmse.py:177
t
GLdouble t
Definition:
glad/glad/glad.h:1830
rs2::error::get_failed_args
const std::string & get_failed_args() const
Definition:
rs_types.hpp:117
test-got-playback-frames.cfg
cfg
Definition:
test-got-playback-frames.py:115
Catch::cout
std::ostream & cout()
t265_stereo.profiles
profiles
Definition:
t265_stereo.py:139
t265_stereo.callback
def callback(frame)
Definition:
t265_stereo.py:91
TCLAP::ValueArg::getValue
T & getValue()
Definition:
ValueArg.h:322
rs2::pipeline
Definition:
rs_pipeline.hpp:362
test-fw-updater.cmd
list cmd
Definition:
test-fw-updater.py:113
TCLAP::CmdLine::parse
void parse(int argc, const char *const *argv)
Definition:
CmdLine.h:433
rs2::config::enable_record_to_file
void enable_record_to_file(const std::string &file_name)
Definition:
rs_pipeline.hpp:263
count
GLint GLsizei count
Definition:
glad/glad/glad.h:2302
CmdLine.h
Catch::cerr
std::ostream & cerr()
TCLAP::CmdLine::add
void add(Arg &a)
Definition:
CmdLine.h:413
TCLAP
Definition:
Arg.h:57
rs2::pipeline::start
pipeline_profile start()
Definition:
rs_pipeline.hpp:392
TCLAP::CmdLine
Definition:
CmdLine.h:70
rs2::error::get_failed_function
const std::string & get_failed_function() const
Definition:
rs_types.hpp:112
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:47:40