|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef COLMAP_SRC_BASE_TRACK_H_ |
|
#define COLMAP_SRC_BASE_TRACK_H_ |
|
|
|
#include <vector> |
|
|
|
#include "util/logging.h" |
|
#include "util/types.h" |
|
|
|
namespace colmap { |
|
|
|
|
|
struct TrackElement { |
|
TrackElement(); |
|
TrackElement(const image_t image_id, const point2D_t point2D_idx); |
|
|
|
image_t image_id; |
|
|
|
point2D_t point2D_idx; |
|
}; |
|
|
|
class Track { |
|
public: |
|
Track(); |
|
|
|
|
|
inline size_t Length() const; |
|
|
|
|
|
inline const std::vector<TrackElement>& Elements() const; |
|
inline std::vector<TrackElement>& Elements(); |
|
inline void SetElements(std::vector<TrackElement> elements); |
|
|
|
|
|
inline const TrackElement& Element(const size_t idx) const; |
|
inline TrackElement& Element(const size_t idx); |
|
inline void SetElement(const size_t idx, const TrackElement& element); |
|
|
|
|
|
inline void AddElement(const TrackElement& element); |
|
inline void AddElement(const image_t image_id, const point2D_t point2D_idx); |
|
inline void AddElements(const std::vector<TrackElement>& elements); |
|
|
|
|
|
inline void DeleteElement(const size_t idx); |
|
void DeleteElement(const image_t image_id, const point2D_t point2D_idx); |
|
|
|
|
|
|
|
inline void Reserve(const size_t num_elements); |
|
|
|
|
|
inline void Compress(); |
|
|
|
private: |
|
std::vector<TrackElement> elements_; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
size_t Track::Length() const { return elements_.size(); } |
|
|
|
const std::vector<TrackElement>& Track::Elements() const { return elements_; } |
|
|
|
std::vector<TrackElement>& Track::Elements() { return elements_; } |
|
|
|
void Track::SetElements(std::vector<TrackElement> elements) { |
|
elements_ = std::move(elements); |
|
} |
|
|
|
|
|
const TrackElement& Track::Element(const size_t idx) const { |
|
return elements_.at(idx); |
|
} |
|
|
|
TrackElement& Track::Element(const size_t idx) { return elements_.at(idx); } |
|
|
|
void Track::SetElement(const size_t idx, const TrackElement& element) { |
|
elements_.at(idx) = element; |
|
} |
|
|
|
void Track::AddElement(const TrackElement& element) { |
|
elements_.push_back(element); |
|
} |
|
|
|
void Track::AddElement(const image_t image_id, const point2D_t point2D_idx) { |
|
elements_.emplace_back(image_id, point2D_idx); |
|
} |
|
|
|
void Track::AddElements(const std::vector<TrackElement>& elements) { |
|
elements_.insert(elements_.end(), elements.begin(), elements.end()); |
|
} |
|
|
|
void Track::DeleteElement(const size_t idx) { |
|
CHECK_LT(idx, elements_.size()); |
|
elements_.erase(elements_.begin() + idx); |
|
} |
|
|
|
void Track::Reserve(const size_t num_elements) { |
|
elements_.reserve(num_elements); |
|
} |
|
|
|
void Track::Compress() { elements_.shrink_to_fit(); } |
|
|
|
} |
|
|
|
#endif |
|
|