| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef COLMAP_SRC_BASE_IMAGE_H_ |
| #define COLMAP_SRC_BASE_IMAGE_H_ |
|
|
| #include <string> |
| #include <vector> |
|
|
| #include <Eigen/Core> |
|
|
| #include "base/camera.h" |
| #include "base/point2d.h" |
| #include "base/visibility_pyramid.h" |
| #include "util/alignment.h" |
| #include "util/logging.h" |
| #include "util/math.h" |
| #include "util/types.h" |
|
|
| namespace colmap { |
|
|
| |
| |
| |
| class Image { |
| public: |
| EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
|
|
| Image(); |
|
|
| |
| |
| void SetUp(const Camera& camera); |
| void TearDown(); |
|
|
| |
| inline image_t ImageId() const; |
| inline void SetImageId(const image_t image_id); |
|
|
| |
| inline const std::string& Name() const; |
| inline std::string& Name(); |
| inline void SetName(const std::string& name); |
|
|
| |
| |
| inline camera_t CameraId() const; |
| inline void SetCameraId(const camera_t camera_id); |
| |
| inline bool HasCamera() const; |
|
|
| |
| inline bool IsRegistered() const; |
| inline void SetRegistered(const bool registered); |
|
|
| |
| inline point2D_t NumPoints2D() const; |
|
|
| |
| |
| inline point2D_t NumPoints3D() const; |
|
|
| |
| |
| inline point2D_t NumObservations() const; |
| inline void SetNumObservations(const point2D_t num_observations); |
|
|
| |
| inline point2D_t NumCorrespondences() const; |
| inline void SetNumCorrespondences(const point2D_t num_observations); |
|
|
| |
| |
| |
| inline point2D_t NumVisiblePoints3D() const; |
|
|
| |
| |
| |
| |
| |
| inline size_t Point3DVisibilityScore() const; |
|
|
| |
| |
| inline const Eigen::Vector4d& Qvec() const; |
| inline Eigen::Vector4d& Qvec(); |
| inline double Qvec(const size_t idx) const; |
| inline double& Qvec(const size_t idx); |
| inline void SetQvec(const Eigen::Vector4d& qvec); |
|
|
| |
| inline const Eigen::Vector4d& QvecPrior() const; |
| inline Eigen::Vector4d& QvecPrior(); |
| inline double QvecPrior(const size_t idx) const; |
| inline double& QvecPrior(const size_t idx); |
| inline bool HasQvecPrior() const; |
| inline void SetQvecPrior(const Eigen::Vector4d& qvec); |
|
|
| |
| |
| inline const Eigen::Vector3d& Tvec() const; |
| inline Eigen::Vector3d& Tvec(); |
| inline double Tvec(const size_t idx) const; |
| inline double& Tvec(const size_t idx); |
| inline void SetTvec(const Eigen::Vector3d& tvec); |
|
|
| |
| inline const Eigen::Vector3d& TvecPrior() const; |
| inline Eigen::Vector3d& TvecPrior(); |
| inline double TvecPrior(const size_t idx) const; |
| inline double& TvecPrior(const size_t idx); |
| inline bool HasTvecPrior() const; |
| inline void SetTvecPrior(const Eigen::Vector3d& tvec); |
|
|
| |
| inline const class Point2D& Point2D(const point2D_t point2D_idx) const; |
| inline class Point2D& Point2D(const point2D_t point2D_idx); |
| inline const std::vector<class Point2D>& Points2D() const; |
| void SetPoints2D(const std::vector<Eigen::Vector2d>& points); |
| void SetPoints2D(const std::vector<class Point2D>& points); |
|
|
| |
| void SetPoint3DForPoint2D(const point2D_t point2D_idx, |
| const point3D_t point3D_id); |
|
|
| |
| void ResetPoint3DForPoint2D(const point2D_t point2D_idx); |
|
|
| |
| |
| inline bool IsPoint3DVisible(const point2D_t point2D_idx) const; |
|
|
| |
| bool HasPoint3D(const point3D_t point3D_id) const; |
|
|
| |
| |
| |
| void IncrementCorrespondenceHasPoint3D(const point2D_t point2D_idx); |
|
|
| |
| |
| |
| |
| |
| void DecrementCorrespondenceHasPoint3D(const point2D_t point2D_idx); |
|
|
| |
| void NormalizeQvec(); |
|
|
| |
| Eigen::Matrix3x4d ProjectionMatrix() const; |
|
|
| |
| Eigen::Matrix3x4d InverseProjectionMatrix() const; |
|
|
| |
| Eigen::Matrix3d RotationMatrix() const; |
|
|
| |
| Eigen::Vector3d ProjectionCenter() const; |
|
|
| |
| Eigen::Vector3d ViewingDirection() const; |
|
|
| |
| static const int kNumPoint3DVisibilityPyramidLevels; |
|
|
| private: |
| |
| image_t image_id_; |
|
|
| |
| std::string name_; |
|
|
| |
| |
| camera_t camera_id_; |
|
|
| |
| bool registered_; |
|
|
| |
| |
| point2D_t num_points3D_; |
|
|
| |
| |
| point2D_t num_observations_; |
|
|
| |
| point2D_t num_correspondences_; |
|
|
| |
| |
| |
| point2D_t num_visible_points3D_; |
|
|
| |
| Eigen::Vector4d qvec_; |
| Eigen::Vector3d tvec_; |
|
|
| |
| Eigen::Vector4d qvec_prior_; |
| Eigen::Vector3d tvec_prior_; |
|
|
| |
| std::vector<class Point2D> points2D_; |
|
|
| |
| std::vector<point2D_t> num_correspondences_have_point3D_; |
|
|
| |
| |
| VisibilityPyramid point3D_visibility_pyramid_; |
| }; |
|
|
| |
| |
| |
|
|
| image_t Image::ImageId() const { return image_id_; } |
|
|
| void Image::SetImageId(const image_t image_id) { image_id_ = image_id; } |
|
|
| const std::string& Image::Name() const { return name_; } |
|
|
| std::string& Image::Name() { return name_; } |
|
|
| void Image::SetName(const std::string& name) { name_ = name; } |
|
|
| inline camera_t Image::CameraId() const { return camera_id_; } |
|
|
| inline void Image::SetCameraId(const camera_t camera_id) { |
| CHECK_NE(camera_id, kInvalidCameraId); |
| camera_id_ = camera_id; |
| } |
|
|
| inline bool Image::HasCamera() const { return camera_id_ != kInvalidCameraId; } |
|
|
| bool Image::IsRegistered() const { return registered_; } |
|
|
| void Image::SetRegistered(const bool registered) { registered_ = registered; } |
|
|
| point2D_t Image::NumPoints2D() const { |
| return static_cast<point2D_t>(points2D_.size()); |
| } |
|
|
| point2D_t Image::NumPoints3D() const { return num_points3D_; } |
|
|
| point2D_t Image::NumObservations() const { return num_observations_; } |
|
|
| void Image::SetNumObservations(const point2D_t num_observations) { |
| num_observations_ = num_observations; |
| } |
|
|
| point2D_t Image::NumCorrespondences() const { return num_correspondences_; } |
|
|
| void Image::SetNumCorrespondences(const point2D_t num_correspondences) { |
| num_correspondences_ = num_correspondences; |
| } |
|
|
| point2D_t Image::NumVisiblePoints3D() const { return num_visible_points3D_; } |
|
|
| size_t Image::Point3DVisibilityScore() const { |
| return point3D_visibility_pyramid_.Score(); |
| } |
|
|
| const Eigen::Vector4d& Image::Qvec() const { return qvec_; } |
|
|
| Eigen::Vector4d& Image::Qvec() { return qvec_; } |
|
|
| inline double Image::Qvec(const size_t idx) const { return qvec_(idx); } |
|
|
| inline double& Image::Qvec(const size_t idx) { return qvec_(idx); } |
|
|
| void Image::SetQvec(const Eigen::Vector4d& qvec) { qvec_ = qvec; } |
|
|
| const Eigen::Vector4d& Image::QvecPrior() const { return qvec_prior_; } |
|
|
| Eigen::Vector4d& Image::QvecPrior() { return qvec_prior_; } |
|
|
| inline double Image::QvecPrior(const size_t idx) const { |
| return qvec_prior_(idx); |
| } |
|
|
| inline double& Image::QvecPrior(const size_t idx) { return qvec_prior_(idx); } |
|
|
| inline bool Image::HasQvecPrior() const { return !IsNaN(qvec_prior_.sum()); } |
|
|
| void Image::SetQvecPrior(const Eigen::Vector4d& qvec) { qvec_prior_ = qvec; } |
|
|
| const Eigen::Vector3d& Image::Tvec() const { return tvec_; } |
|
|
| Eigen::Vector3d& Image::Tvec() { return tvec_; } |
|
|
| inline double Image::Tvec(const size_t idx) const { return tvec_(idx); } |
|
|
| inline double& Image::Tvec(const size_t idx) { return tvec_(idx); } |
|
|
| void Image::SetTvec(const Eigen::Vector3d& tvec) { tvec_ = tvec; } |
|
|
| const Eigen::Vector3d& Image::TvecPrior() const { return tvec_prior_; } |
|
|
| Eigen::Vector3d& Image::TvecPrior() { return tvec_prior_; } |
|
|
| inline double Image::TvecPrior(const size_t idx) const { |
| return tvec_prior_(idx); |
| } |
|
|
| inline double& Image::TvecPrior(const size_t idx) { return tvec_prior_(idx); } |
|
|
| inline bool Image::HasTvecPrior() const { return !IsNaN(tvec_prior_.sum()); } |
|
|
| void Image::SetTvecPrior(const Eigen::Vector3d& tvec) { tvec_prior_ = tvec; } |
|
|
| const class Point2D& Image::Point2D(const point2D_t point2D_idx) const { |
| return points2D_.at(point2D_idx); |
| } |
|
|
| class Point2D& Image::Point2D(const point2D_t point2D_idx) { |
| return points2D_.at(point2D_idx); |
| } |
|
|
| const std::vector<class Point2D>& Image::Points2D() const { return points2D_; } |
|
|
| bool Image::IsPoint3DVisible(const point2D_t point2D_idx) const { |
| return num_correspondences_have_point3D_.at(point2D_idx) > 0; |
| } |
|
|
| } |
|
|
| EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION_CUSTOM(colmap::Image) |
|
|
| #endif |
|
|