OKVIS ROS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NCameraSystem.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2  * OKVIS - Open Keyframe-based Visual-Inertial SLAM
3  * Copyright (c) 2015, Autonomous Systems Lab / ETH Zurich
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of Autonomous Systems Lab / ETH Zurich nor the names of
14  * its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Created on: Mar 30, 2015
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  * Modified: Andreas Forster (an.forster@gmail.com)
32  *********************************************************************************/
33 
41 #ifndef INCLUDE_OKVIS_NCAMERASYSTEM_HPP_
42 #define INCLUDE_OKVIS_NCAMERASYSTEM_HPP_
43 
44 #include <memory>
45 #pragma GCC diagnostic push
46 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
47 #include <opencv2/core/core.hpp> // Code that causes warning goes here
48 #pragma GCC diagnostic pop
50 #include <okvis/assert_macros.hpp>
52 
54 namespace okvis {
56 namespace cameras {
57 
62 {
63  public:
64  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65  OKVIS_DEFINE_EXCEPTION(Exception,std::runtime_error)
66 
67 
73  };
74 
76  inline NCameraSystem();
82  inline NCameraSystem(const std::vector<std::shared_ptr<const okvis::kinematics::Transformation>> & T_SC,
83  const std::vector<std::shared_ptr<const cameras::CameraBase>> & cameraGeometries,
84  const std::vector<DistortionType>& distortionTypes,
85  bool computeOverlaps);
86 
88  inline virtual ~NCameraSystem();
89 
95  inline void reset(const std::vector<std::shared_ptr<const okvis::kinematics::Transformation>> & T_SC,
96  const std::vector<std::shared_ptr<const cameras::CameraBase>> & cameraGeometries,
97  const std::vector<DistortionType>& distortionTypes,
98  bool computeOverlaps);
99 
105  inline void addCamera(std::shared_ptr<const okvis::kinematics::Transformation> T_SC,
106  std::shared_ptr<const cameras::CameraBase> cameraGeometry,
108  bool computeOverlaps = true);
109 
112  inline size_t numCameras() const;
113 
115  void computeOverlaps();
116 
120  inline std::shared_ptr<const okvis::kinematics::Transformation> T_SC(size_t cameraIndex) const;
121 
125  inline std::shared_ptr<const cameras::CameraBase> cameraGeometry(size_t cameraIndex) const;
126 
130  inline DistortionType distortionType(size_t cameraIndex) const;
131 
137  inline const cv::Mat overlap(size_t cameraIndexSeenBy,
138  size_t cameraIndex) const;
139 
144  inline bool hasOverlap(size_t cameraIndexSeenBy, size_t cameraIndex) const;
145 
146  protected:
149  inline bool overlapComputationValid() const;
150  std::vector<std::shared_ptr<const okvis::kinematics::Transformation>> T_SC_;
151  std::vector<std::shared_ptr<const cameras::CameraBase>> cameraGeometries_;
152  std::vector<DistortionType> distortionTypes_;
153  std::vector<std::vector<cv::Mat>> overlapMats_;
154  std::vector<std::vector<bool>> overlaps_;
155 };
156 
157 } // namespace cameras
158 } // namespace okvis
159 
161 
162 #endif /* INCLUDE_OKVIS_NCAMERASYSTEM_HPP_ */
void reset(const std::vector< std::shared_ptr< const okvis::kinematics::Transformation >> &T_SC, const std::vector< std::shared_ptr< const cameras::CameraBase >> &cameraGeometries, const std::vector< DistortionType > &distortionTypes, bool computeOverlaps)
Reset with vector of extrinsics and geometries.
Definition: NCameraSystem.hpp:78
Use with okvis::cameras::RadialTangentialDistortion.
Definition: NCameraSystem.hpp:70
void addCamera(std::shared_ptr< const okvis::kinematics::Transformation > T_SC, std::shared_ptr< const cameras::CameraBase > cameraGeometry, DistortionType distortionType, bool computeOverlaps=true)
Append with a single camera.
Definition: NCameraSystem.hpp:102
NCameraSystem()
Default constructor.
Definition: NCameraSystem.hpp:48
Use with okvis::cameras::EquidistantDistortion.
Definition: NCameraSystem.hpp:69
void computeOverlaps()
compute all the overlaps of fields of view. Attention: can be expensive.
Definition: NCameraSystem.cpp:50
This trivially doesn't do anything in terms of distortion. This is useful for testing, or working with pre-undistorted images.
Definition: NoDistortion.hpp:54
std::vector< std::vector< bool > > overlaps_
Overlaps between cameras: binary.
Definition: NCameraSystem.hpp:154
std::shared_ptr< const okvis::kinematics::Transformation > T_SC(size_t cameraIndex) const
get the pose of the IMU frame S with respect to the camera cameraIndex
Definition: NCameraSystem.hpp:119
A class that assembles multiple cameras into a system of (potentially different) cameras.
Definition: NCameraSystem.hpp:61
std::vector< DistortionType > distortionTypes_
Definition: NCameraSystem.hpp:152
virtual ~NCameraSystem()
Destructor that doesn't do anything really.
Definition: NCameraSystem.hpp:73
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
std::vector< std::shared_ptr< const cameras::CameraBase > > cameraGeometries_
Camera geometries.
Definition: NCameraSystem.hpp:151
std::vector< std::vector< cv::Mat > > overlapMats_
Overlaps between cameras: mats.
Definition: NCameraSystem.hpp:153
This file contains some useful assert macros.
Use with okvis::cameras::RadialTangentialDistortion.
Definition: NCameraSystem.hpp:72
DistortionType
The enumeration of the currently supported distortion types.
Definition: NCameraSystem.hpp:68
const cv::Mat overlap(size_t cameraIndexSeenBy, size_t cameraIndex) const
Get the overlap mask. Sorry for the weird syntax, but remember that cv::Mat is essentially a shared p...
Definition: NCameraSystem.hpp:145
DistortionType distortionType(size_t cameraIndex) const
get the distortion type of the camera
Definition: NCameraSystem.hpp:137
Header file for the CameraBase class.
std::vector< std::shared_ptr< const okvis::kinematics::Transformation > > T_SC_
Mounting transformations from IMU.
Definition: NCameraSystem.hpp:150
Header implementation file for the NCameraSystem class.
Header file for the Transformation class.
bool hasOverlap(size_t cameraIndexSeenBy, size_t cameraIndex) const
Can the first camera see parts of the FOV of the second camera?
Definition: NCameraSystem.hpp:161
bool overlapComputationValid() const
Use this to check overlapMats_ and overlaps_ have correct sizes.
Definition: NCameraSystem.hpp:178
size_t numCameras() const
Obtatin the number of cameras currently added.
Definition: NCameraSystem.hpp:202
std::shared_ptr< const cameras::CameraBase > cameraGeometry(size_t cameraIndex) const
get the camera geometry of camera cameraIndex
Definition: NCameraSystem.hpp:128