forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.cpp
77 lines (59 loc) · 1.93 KB
/
converter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
#include <fstream>
#include "converter.hpp"
using namespace rs2::tools::converter;
void rs2::tools::converter::metadata_to_txtfile(const rs2::frame& frm, const std::string& filename)
{
std::ofstream file;
file.open(filename);
file << "Stream: " << rs2_stream_to_string(frm.get_profile().stream_type()) << "\n";
// Record all the available metadata attributes
for (size_t i = 0; i < RS2_FRAME_METADATA_COUNT; i++)
{
rs2_frame_metadata_value metadata_val = (rs2_frame_metadata_value)i;
if (frm.supports_frame_metadata(metadata_val))
{
file << rs2_frame_metadata_to_string(metadata_val) << ": "
<< frm.get_frame_metadata(metadata_val) << "\n";
}
}
file.close();
}
bool converter_base::frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber)
{
if (_framesMap.find(streamType) == _framesMap.end()) {
_framesMap.emplace(streamType, std::unordered_set<frame_number_t>());
}
auto& set = _framesMap[streamType];
bool result = (set.find(frameNumber) != set.end());
if (!result) {
set.emplace(frameNumber);
}
return result;
}
void converter_base::wait_sub_workers()
{
for_each(_subWorkers.begin(), _subWorkers.end(),
[](std::thread& t) {
t.join();
});
_subWorkers.clear();
}
void converter_base::wait()
{
_worker.join();
}
std::string converter_base::get_statistics()
{
std::stringstream result;
result << name() << '\n';
for (auto& i : _framesMap) {
result << '\t'
<< i.second.size() << ' '
<< (static_cast<rs2_stream>(i.first) != rs2_stream::RS2_STREAM_ANY ? rs2_stream_to_string(static_cast<rs2_stream>(i.first)) : "")
<< " frame(s) processed"
<< '\n';
}
return (result.str());
}