RobotsIO
Loading...
Searching...
No Matches
Camera.h
1/*
2 * Copyright (C) 2019 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#ifndef ROBOTSIO_CAMERA_H
9#define ROBOTSIO_CAMERA_H
10
11#include <RobotsIO/Camera/CameraParameters.h>
12#include <RobotsIO/Camera/DatasetParameters.h>
13#include <RobotsIO/Utils/ProbeContainer.h>
14
15#include <Eigen/Dense>
16
17#include <limits>
18#include <opencv2/opencv.hpp>
19
20#include <cstdint>
21#include <fstream>
22#include <string>
23
24namespace RobotsIO {
25 namespace Camera {
26 class Camera;
27 }
28}
29
30
32{
33public:
34 Camera();
35
36 virtual ~Camera();
37
38 virtual bool status() const;
39
40 virtual bool reset();
41
46 virtual std::pair<bool, Eigen::MatrixXd> deprojection_matrix() const;
47
48 virtual std::pair<bool, RobotsIO::Camera::CameraParameters> parameters() const;
49
54 virtual std::pair<bool, Eigen::MatrixXf> depth(const bool& blocking) = 0;
55
56 virtual std::pair<bool, Eigen::MatrixXd> point_cloud(const bool& blocking, const double& maximum_depth = std::numeric_limits<double>::infinity(), const bool& use_root_frame = false, const bool& enable_colors = false);
57
58 virtual std::pair<bool, Eigen::Transform<double, 3, Eigen::Affine>> pose(const bool& blocking) = 0;
59
60 virtual std::pair<bool, cv::Mat> rgb(const bool& blocking) = 0;
61
62 virtual std::pair<bool, double> time_stamp_rgb() const;
63
64 virtual std::pair<bool, double> time_stamp_depth() const;
65
70 virtual std::pair<bool, Eigen::VectorXd> auxiliary_data(const bool& blocking);
71
72 virtual std::size_t auxiliary_data_size() const;
73
78 virtual std::int32_t frame_index() const;
79
80 virtual bool is_offline() const;
81
82 virtual bool set_frame_index(const std::int32_t& index);
83
84 virtual bool step_frame();
85
90 virtual bool log_frame(const bool& log_depth = false);
91
92 virtual bool start_log(const std::string& path);
93
94 virtual bool stop_log();
95
96protected:
97 virtual bool initialize();
98
99 bool status_ = true;
100
105 virtual bool evaluate_deprojection_matrix();
106
108
109 Eigen::MatrixXd deprojection_matrix_;
110
111 bool deprojection_matrix_initialized_ = false;
112
116 Camera(const std::string& data_path, const std::size_t& width, const std::size_t& height, const double& fx, const double& cx, const double& fy, const double& cy);
117
122 virtual std::pair<bool, Eigen::MatrixXf> depth_offline();
123
124 virtual std::pair<bool, Eigen::Transform<double, 3, Eigen::Affine>> pose_offline();
125
126 virtual std::pair<bool, cv::Mat> rgb_offline();
127
128 virtual std::pair<bool, double> time_stamp_rgb_offline() const;
129
130 virtual std::pair<bool, double> time_stamp_depth_offline() const;
131
136 virtual std::pair<bool, Eigen::VectorXd> auxiliary_data_offline();
137
138 /*
139 * Offline playback.
140 */
141
142 std::string compose_index(const std::size_t& index);
143
144 virtual std::pair<bool, Eigen::MatrixXd> load_data();
145
146 RobotsIO::Camera::DatasetParameters dataset_parameters_;
147
148 const bool offline_mode_ = false;
149
150 Eigen::MatrixXd data_;
151
152 std::int32_t frame_index_ = -1;
153
154 std::size_t rgb_offset_ = 0;
155
156 std::size_t depth_offset_ = 0;
157
158 std::size_t number_frames_;
159
160 /*
161 * Data logging.
162 */
163
164 std::ofstream log_;
165
166 std::string log_path_;
167
168 std::int32_t log_index_ = 0;
169
174 const std::string log_name_ = "Camera";
175};
176
177#endif /* ROBOTSIO_CAMERA_H */
virtual std::pair< bool, Eigen::MatrixXd > deprojection_matrix() const
Definition: Camera.cpp:53
virtual std::pair< bool, Eigen::MatrixXf > depth_offline()
Definition: Camera.cpp:392
virtual bool evaluate_deprojection_matrix()
Definition: Camera.cpp:339
virtual bool log_frame(const bool &log_depth=false)
Definition: Camera.cpp:241
virtual std::int32_t frame_index() const
Definition: Camera.cpp:190
virtual std::pair< bool, Eigen::VectorXd > auxiliary_data_offline()
Definition: Camera.cpp:519
const std::string log_name_
Definition: Camera.h:174
virtual std::pair< bool, Eigen::MatrixXf > depth(const bool &blocking)=0
virtual std::pair< bool, Eigen::VectorXd > auxiliary_data(const bool &blocking)
Definition: Camera.cpp:178