From 8ddfd8135b78400be7bbb67c092559892c6e4539 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 20 Dec 2021 21:19:26 -0500 Subject: [PATCH] use passed in calibration for initialization and add EmptyCal serialization --- gtsam/geometry/SphericalCamera.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gtsam/geometry/SphericalCamera.h b/gtsam/geometry/SphericalCamera.h index 59658f3ce..4880423d3 100644 --- a/gtsam/geometry/SphericalCamera.h +++ b/gtsam/geometry/SphericalCamera.h @@ -43,9 +43,22 @@ class GTSAM_EXPORT EmptyCal { EmptyCal() {} virtual ~EmptyCal() = default; using shared_ptr = boost::shared_ptr; + + /// return DOF, dimensionality of tangent space + inline static size_t Dim() { return dimension; } + void print(const std::string& s) const { std::cout << "empty calibration: " << s << std::endl; } + + private: + /// Serialization function + friend class boost::serialization::access; + template + void serialize(Archive& ar, const unsigned int /*version*/) { + ar& boost::serialization::make_nvp( + "EmptyCal", boost::serialization::base_object(*this)); + } }; /** @@ -58,9 +71,9 @@ class GTSAM_EXPORT SphericalCamera { public: enum { dimension = 6 }; - typedef Unit3 Measurement; - typedef std::vector MeasurementVector; - typedef EmptyCal CalibrationType; + using Measurement = Unit3; + using MeasurementVector = std::vector; + using CalibrationType = EmptyCal; private: Pose3 pose_; ///< 3D pose of camera @@ -83,8 +96,8 @@ class GTSAM_EXPORT SphericalCamera { /// Constructor with empty intrinsics (needed for smart factors) explicit SphericalCamera(const Pose3& pose, - const boost::shared_ptr& cal) - : pose_(pose), emptyCal_(boost::make_shared()) {} + const EmptyCal::shared_ptr& cal) + : pose_(pose), emptyCal_(cal) {} /// @} /// @name Advanced Constructors @@ -95,7 +108,7 @@ class GTSAM_EXPORT SphericalCamera { virtual ~SphericalCamera() = default; /// return shared pointer to calibration - const boost::shared_ptr& sharedCalibration() const { + const EmptyCal::shared_ptr& sharedCalibration() const { return emptyCal_; } @@ -213,6 +226,9 @@ class GTSAM_EXPORT SphericalCamera { void serialize(Archive& ar, const unsigned int /*version*/) { ar& BOOST_SERIALIZATION_NVP(pose_); } + + public: + GTSAM_MAKE_ALIGNED_OPERATOR_NEW }; // end of class SphericalCamera