converter-csv.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2018 Intel Corporation. All Rights Reserved.
3 
4 #ifndef __RS_CONVERTER_CONVERTER_CSV_H
5 #define __RS_CONVERTER_CONVERTER_CSV_H
6 
7 
8 #include <fstream>
9 #include <map>
10 #include <mutex>
11 #include <condition_variable>
12 #include "../converter.hpp"
13 
14 
15 namespace rs2 {
16  namespace tools {
17  namespace converter {
18 
19  struct stringify
20  {
21  std::ostringstream ss;
22  template<class T> stringify& operator << (const T& val) { ss << val; return *this; }
23  operator std::string() const { return ss.str(); }
24  };
25 
26  template <typename T>
27  inline bool val_in_range(const T& val, const std::initializer_list<T>& list)
28  {
29  for (const auto& i : list) {
30  if (val == i) {
31  return true;
32  }
33  }
34  return false;
35  }
36 
37  class converter_csv : public converter_base {
38  protected:
40  motion_pose_frame_record(rs2_stream stream_type, int stream_index,
41  unsigned long long frame_number,
42  long long frame_ts, long long backend_ts, long long arrival_time,
43  double p1 = 0., double p2 = 0., double p3 = 0.,
44  double p4 = 0., double p5 = 0., double p6 = 0., double p7 = 0.);
45 
48  unsigned long long _frame_number;
49  long long _frame_ts; // Device-based timestamp. (msec)
50  long long _backend_ts; // Driver-based timestamp. (msec)
51  long long _arrival_time; // Host arrival timestamp (msec)
52  std::array<double, 7> _params; // The parameters are optional and sensor specific
53 
54  std::string to_string() const;
55  };
57 
60  std::map<std::pair<rs2_stream, int>, std::vector<motion_pose_frame_record>> _imu_pose_collection;
62  std::mutex _m;
63  std::condition_variable _cv;
64 
65 
66  public:
67 
68  converter_csv(const std::string& filePath, rs2_stream streamType = rs2_stream::RS2_STREAM_ANY);
69 
70  void convert(rs2::frame& frame) override;
71 
72  std::string name() const override
73  {
74  return "CSV converter";
75  }
76 
77  void convert_depth(rs2::depth_frame& depthframe);
80  };
81  } // namespace converter
82  } // namespace tools
83 } // namespace rs2
84 
85 
86 
87 #endif
rs2::tools::converter::val_in_range
bool val_in_range(const T &val, const std::initializer_list< T > &list)
Definition: converter-csv.hpp:27
example1 - object detection.p1
tuple p1
Definition: example1 - object detection.py:75
rs2::tools::converter::converter_csv::_streamType
rs2_stream _streamType
Definition: converter-csv.hpp:58
rs2::frame
Definition: rs_frame.hpp:345
rs2::tools::converter::converter_csv::converter_csv
converter_csv(const std::string &filePath, rs2_stream streamType=rs2_stream::RS2_STREAM_ANY)
Definition: converter-csv.cpp:44
rs2::tools::converter::converter_csv::_sub_workers_joined
bool _sub_workers_joined
Definition: converter-csv.hpp:61
test-hdr-long.frame_ts
frame_ts
Definition: test-hdr-long.py:350
rs2::tools::converter::converter_csv::motion_pose_frame_record::_stream_idx
int _stream_idx
Definition: converter-csv.hpp:47
rs2::tools::converter::converter_csv::motion_pose_frame_record::_backend_ts
long long _backend_ts
Definition: converter-csv.hpp:50
rs2::tools::converter::converter_csv::motion_pose_frame_record::_frame_number
unsigned long long _frame_number
Definition: converter-csv.hpp:48
rs2::tools::converter::converter_csv::motion_pose_frame_record
Definition: converter-csv.hpp:39
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
rs2::tools::converter::converter_csv::_cv
std::condition_variable _cv
Definition: converter-csv.hpp:63
arrival_time
@ arrival_time
Definition: rs-rosbag-inspector.cpp:347
rs2::tools::converter::converter_csv::motion_pose_frame_record::_frame_ts
long long _frame_ts
Definition: converter-csv.hpp:49
rs2::tools::converter::converter_csv::motion_pose_frame_record::_params
std::array< double, 7 > _params
Definition: converter-csv.hpp:52
rs2::tools::converter::stringify::operator<<
stringify & operator<<(const T &val)
Definition: converter-csv.hpp:22
rs2::tools::converter::converter_csv::convert_depth
void convert_depth(rs2::depth_frame &depthframe)
Definition: converter-csv.cpp:54
val
GLuint GLfloat * val
Definition: glad/glad/glad.h:3411
rs2::tools::converter::converter_csv::motion_pose_frame_record::motion_pose_frame_record
motion_pose_frame_record(rs2_stream stream_type, int stream_index, unsigned long long frame_number, long long frame_ts, long long backend_ts, long long arrival_time, double p1=0., double p2=0., double p3=0., double p4=0., double p5=0., double p6=0., double p7=0.)
Definition: converter-csv.cpp:12
rs2::tools::converter::converter_csv::name
std::string name() const override
Definition: converter-csv.hpp:72
f
GLdouble f
Definition: glad/glad/glad.h:1517
i
int i
Definition: rs-pcl-color.cpp:54
rs2::tools::converter::converter_csv::_filePath
std::string _filePath
Definition: converter-csv.hpp:59
rs2
Definition: animated.h:9
rs2::tools::converter::converter_csv::motion_pose_frame_record::to_string
std::string to_string() const
Definition: converter-csv.cpp:25
rs2::tools::converter::converter_csv::save_motion_pose_data_to_file
void save_motion_pose_data_to_file()
Definition: converter-csv.cpp:111
rs2::tools::converter::converter_base
Definition: converter.hpp:25
RS2_STREAM_ANY
@ RS2_STREAM_ANY
Definition: rs_sensor.h:45
rs2::tools::converter::converter_csv::_m
std::mutex _m
Definition: converter-csv.hpp:62
tools
Definition: lrs-device-controller.h:26
rs2::depth_frame
Definition: rs_frame.hpp:813
realdds::topics::metadata::header::key::frame_number
const std::string frame_number
Definition: sw-dev/test-motion.py:41
example1 - object detection.p2
tuple p2
Definition: example1 - object detection.py:76
rs2::tools::converter::converter_csv::get_time_string
std::string get_time_string() const
Definition: converter-csv.cpp:100
rs2::tools::converter::converter_csv::convert
void convert(rs2::frame &frame) override
Definition: converter-csv.cpp:205
rs2::tools::converter::stringify::ss
std::ostringstream ss
Definition: converter-csv.hpp:21
rs2::tools::converter::converter_csv::motion_pose_frame_record::_stream_type
rs2_stream _stream_type
Definition: converter-csv.hpp:46
rs2::tools::converter::converter_csv
Definition: converter-csv.hpp:37
rs2_stream
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:43
rs2::tools::converter::converter_csv::_imu_pose_collection
std::map< std::pair< rs2_stream, int >, std::vector< motion_pose_frame_record > > _imu_pose_collection
Definition: converter-csv.hpp:60
rs2::tools::converter::stringify
Definition: converter-csv.hpp:19
rs2::tools::converter::converter_csv::motion_pose_frame_record::_arrival_time
long long _arrival_time
Definition: converter-csv.hpp:51
rs2::tools::converter::converter_csv::convert_motion_pose
void convert_motion_pose(rs2::frame &f)
Definition: converter-csv.cpp:147


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Mon Apr 22 2024 02:12:55