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  };
56  std::string get_time_string() const;
57 
59  std::string _filePath;
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);
78  void convert_motion_pose(rs2::frame& f);
79  void save_motion_pose_data_to_file();
80  };
81  } // namespace converter
82  } // namespace tools
83 } // namespace rs2
84 
85 
86 
87 #endif
GLuint GLfloat * val
std::string name() const override
void convert(rs2_format source, std::string &target)
Definition: animated.h:9
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
GLdouble f
std::map< std::pair< rs2_stream, int >, std::vector< motion_pose_frame_record > > _imu_pose_collection
int i
bool val_in_range(const T &val, const std::initializer_list< T > &list)
std::string to_string(T value)
stringify & operator<<(const T &val)


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:43:16