Berkeley SfM
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
bsfm::View Class Reference

#include <view.h>

Public Types

typedef std::shared_ptr< ViewPtr
 
typedef std::shared_ptr< const ViewConstPtr
 

Public Member Functions

 ~View ()
 
void SetCamera (const ::bsfm::Camera &camera)
 
::bsfm::CameraMutableCamera ()
 
const ::bsfm::CameraCamera () const
 
ViewIndex Index () const
 
const std::vector< Observation::Ptr > & Observations () const
 
bool HasObservedLandmark (LandmarkIndex landmark_index) const
 
void UpdateObservedLandmarks ()
 
const std::unordered_set< LandmarkIndex > & ObservedLandmarks () const
 

Static Public Member Functions

static View::Ptr Create (const ::bsfm::Camera &camera)
 
static View::Ptr GetView (ViewIndex view_index)
 
static ViewIndex NumExistingViews ()
 
static bool IsValidView (ViewIndex view_index)
 
static void ResetViews ()
 
static bool SortByIndex (const View::Ptr &lhs, const View::Ptr &rhs)
 

Private Member Functions

 View (const ::bsfm::Camera &camera)
 
void AddObservation (const Observation::Ptr &observation)
 

Static Private Member Functions

static ViewIndex NextViewIndex ()
 

Private Attributes

::bsfm::Camera camera_
 
ViewIndex view_index_
 
std::vector< Observation::Ptrobservations_
 
std::unordered_set< LandmarkIndexlandmarks_
 

Static Private Attributes

static std::unordered_map< ViewIndex, View::Ptrview_registry_
 
static ViewIndex current_view_index_ = 0
 

Friends

class Observation
 

Detailed Description

Definition at line 64 of file view.h.

Member Typedef Documentation

typedef std::shared_ptr<const View> bsfm::View::ConstPtr

Definition at line 67 of file view.h.

typedef std::shared_ptr<View> bsfm::View::Ptr

Definition at line 66 of file view.h.

Constructor & Destructor Documentation

bsfm::View::~View ( )
inline

Definition at line 73 of file view.h.

73 {}
bsfm::View::View ( const ::bsfm::Camera camera)
private

Definition at line 136 of file view.cpp.

137  : view_index_(NextViewIndex()), camera_(camera) {}
::bsfm::Camera camera_
Definition: view.h:136
static ViewIndex NextViewIndex()
Definition: view.cpp:141
ViewIndex view_index_
Definition: view.h:139

Member Function Documentation

void bsfm::View::AddObservation ( const Observation::Ptr observation)
private

Definition at line 104 of file view.cpp.

104  {
105  CHECK_NOTNULL(observation.get());
106  observations_.push_back(observation);
107 }
std::vector< Observation::Ptr > observations_
Definition: view.h:147
const ::bsfm::Camera & bsfm::View::Camera ( ) const

Definition at line 96 of file view.cpp.

96  {
97  return camera_;
98 }
::bsfm::Camera camera_
Definition: view.h:136
View::Ptr bsfm::View::Create ( const ::bsfm::Camera camera)
static

Definition at line 51 of file view.cpp.

51  {
52  // Create a new View, implicitly assigning a unique index.
53  View::Ptr view(new View(camera));
54  view_registry_.insert(std::make_pair(view->Index(), view));
55  return view;
56 }
static std::unordered_map< ViewIndex, View::Ptr > view_registry_
Definition: view.h:143
std::shared_ptr< View > Ptr
Definition: view.h:66
View(const ::bsfm::Camera &camera)
Definition: view.cpp:136
View::Ptr bsfm::View::GetView ( ViewIndex  view_index)
static

Definition at line 60 of file view.cpp.

60  {
61  auto registry_element = view_registry_.find(view_index);
62  if (registry_element == view_registry_.end()) {
63  LOG(WARNING)
64  << "View does not exist in registry. Returning a null pointer.";
65  return View::Ptr();
66  }
67 
68  return registry_element->second;
69 }
static std::unordered_map< ViewIndex, View::Ptr > view_registry_
Definition: view.h:143
std::shared_ptr< View > Ptr
Definition: view.h:66
bool bsfm::View::HasObservedLandmark ( LandmarkIndex  landmark_index) const

Definition at line 113 of file view.cpp.

113  {
114  return landmarks_.count(landmark_index);
115 }
std::unordered_set< LandmarkIndex > landmarks_
Definition: view.h:152
ViewIndex bsfm::View::Index ( ) const

Definition at line 100 of file view.cpp.

100  {
101  return view_index_;
102 }
ViewIndex view_index_
Definition: view.h:139
bool bsfm::View::IsValidView ( ViewIndex  view_index)
static

Definition at line 77 of file view.cpp.

77  {
78  return view_index <= current_view_index_;
79 }
static ViewIndex current_view_index_
Definition: view.h:155
bsfm::Camera & bsfm::View::MutableCamera ( )

Definition at line 92 of file view.cpp.

92  {
93  return camera_;
94 }
::bsfm::Camera camera_
Definition: view.h:136
ViewIndex bsfm::View::NextViewIndex ( )
staticprivate

Definition at line 141 of file view.cpp.

141  {
142  return current_view_index_++;
143 }
static ViewIndex current_view_index_
Definition: view.h:155
ViewIndex bsfm::View::NumExistingViews ( )
static

Definition at line 72 of file view.cpp.

72  {
73  return view_registry_.size();
74 }
static std::unordered_map< ViewIndex, View::Ptr > view_registry_
Definition: view.h:143
const std::vector< Observation::Ptr > & bsfm::View::Observations ( ) const

Definition at line 109 of file view.cpp.

109  {
110  return observations_;
111 }
std::vector< Observation::Ptr > observations_
Definition: view.h:147
const std::unordered_set< LandmarkIndex > & bsfm::View::ObservedLandmarks ( ) const

Definition at line 127 of file view.cpp.

127  {
128  return landmarks_;
129 }
std::unordered_set< LandmarkIndex > landmarks_
Definition: view.h:152
void bsfm::View::ResetViews ( )
static

Definition at line 83 of file view.cpp.

83  {
85  view_registry_.clear();
86 }
static std::unordered_map< ViewIndex, View::Ptr > view_registry_
Definition: view.h:143
static ViewIndex current_view_index_
Definition: view.h:155
void bsfm::View::SetCamera ( const ::bsfm::Camera camera)

Definition at line 88 of file view.cpp.

88  {
89  camera_ = camera;
90 }
::bsfm::Camera camera_
Definition: view.h:136
bool bsfm::View::SortByIndex ( const View::Ptr lhs,
const View::Ptr rhs 
)
static

Definition at line 131 of file view.cpp.

131  {
132  return lhs->Index()< rhs->Index();
133 }
void bsfm::View::UpdateObservedLandmarks ( )

Definition at line 117 of file view.cpp.

117  {
118  for (const auto& observation : observations_) {
119  CHECK_NOTNULL(observation.get());
120  if (!observation->IsIncorporated()) continue;
121 
122  // Calls to std::set::insert() will overwrite old key value pairs.
123  landmarks_.insert(observation->GetLandmark()->Index());
124  }
125 }
std::unordered_set< LandmarkIndex > landmarks_
Definition: view.h:152
std::vector< Observation::Ptr > observations_
Definition: view.h:147

Friends And Related Function Documentation

friend class Observation
friend

Definition at line 132 of file view.h.

Member Data Documentation

::bsfm::Camera bsfm::View::camera_
private

Definition at line 136 of file view.h.

ViewIndex bsfm::View::current_view_index_ = 0
staticprivate

Definition at line 155 of file view.h.

std::unordered_set<LandmarkIndex> bsfm::View::landmarks_
private

Definition at line 152 of file view.h.

std::vector<Observation::Ptr> bsfm::View::observations_
private

Definition at line 147 of file view.h.

ViewIndex bsfm::View::view_index_
private

Definition at line 139 of file view.h.

std::unordered_map< ViewIndex, View::Ptr > bsfm::View::view_registry_
staticprivate

Definition at line 143 of file view.h.


The documentation for this class was generated from the following files: