-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataset.h
60 lines (49 loc) · 1.51 KB
/
dataset.h
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
#pragma once
#include "attitude.h"
#include "cartesian_position.h"
#include "geodetic_position.h"
#include "intrinsics.h"
#include "opencv2/core.hpp"
/// \brief A set of data for each image in the dataset.
struct DataElement
{
int img_num;
cv::Mat image;
Intrinsics intrinsics;
CartesianPosition camera_position_in_body;
Attitude camera_attitude_in_body;
GeodeticPosition body_position_in_geo;
Attitude body_attitude_in_geo;
};
/// \brief Represents the dataset for the lab.
class Dataset
{
public:
/// \brief Constructs a dataset.
/// \param folder_name the folder where the dataset resides.
explicit Dataset(const std::string& folder_name)
: folder_name_(folder_name)
, curr_file_num_{first_file_num}
, get_succeeded_{true}
{}
/// \brief Reads the next data element.
/// \param[out] element Data is read into this element.
/// \return True if success.
bool getNext(DataElement& element);
/// \brief Checks if there is more data.
/// \return True if more data.
bool hasNext() const;
/// \brief Checks if last get operation succeeded.
/// \return True if success.
explicit operator bool() const;
static constexpr int first_file_num = 502;
static constexpr int last_file_num = 611;
private:
void readImage(DataElement& element) const;
void readMetadata(DataElement& element) const;
std::string folder_name_;
int curr_file_num_;
bool get_succeeded_;
};
/// \brief Stream operator for getting the next data element.
Dataset& operator>>(Dataset& dataset, DataElement& element);