ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
point2d.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // clang-format off
11 #include "util/alignment.h"
12 // clang-format on
13 
14 #include "util/types.h"
15 
16 namespace colmap {
17 
18 // 2D point class corresponds to a feature in an image. It may or may not have a
19 // corresponding 3D point if it is part of a triangulated track.
20 class Point2D {
21 public:
22  Point2D();
23 
24  // The coordinate in image space in pixels.
25  inline const Eigen::Vector2d& XY() const;
26  inline Eigen::Vector2d& XY();
27  inline double X() const;
28  inline double Y() const;
29  inline void SetXY(const Eigen::Vector2d& xy);
30 
31  // The identifier of the observed 3D point. If the image point does not
32  // observe a 3D point, the identifier is `kInvalidPoint3Did`.
33  inline point3D_t Point3DId() const;
34  inline bool HasPoint3D() const;
35  inline void SetPoint3DId(const point3D_t point3D_id);
36 
37  inline bool operator==(const Point2D& other) const;
38  inline bool operator!=(const Point2D& other) const;
39 
40 private:
41  // The image coordinates in pixels, starting at upper left corner with 0.
42  Eigen::Vector2d xy_;
43 
44  // The identifier of the 3D point. If the 2D point is not part of a 3D point
45  // track the identifier is `kInvalidPoint3DId` and `HasPoint3D() = false`.
46  point3D_t point3D_id_;
47 };
48 
50 // Implementation
52 
53 const Eigen::Vector2d& Point2D::XY() const { return xy_; }
54 
55 Eigen::Vector2d& Point2D::XY() { return xy_; }
56 
57 double Point2D::X() const { return xy_.x(); }
58 
59 double Point2D::Y() const { return xy_.y(); }
60 
61 void Point2D::SetXY(const Eigen::Vector2d& xy) { xy_ = xy; }
62 
63 point3D_t Point2D::Point3DId() const { return point3D_id_; }
64 
65 bool Point2D::HasPoint3D() const { return point3D_id_ != kInvalidPoint3DId; }
66 
67 void Point2D::SetPoint3DId(const point3D_t point3D_id) {
68  point3D_id_ = point3D_id;
69 }
70 
71 bool Point2D::operator==(const Point2D& other) const {
72  return XY() == other.XY() && Point3DId() == other.Point3DId();
73 }
74 
75 bool Point2D::operator!=(const Point2D& other) const {
76  return !(*this == other);
77 }
78 
79 } // namespace colmap
colmap::LineSegmentOrientation::VERTICAL
@ VERTICAL
types.h
Eigen
Definition: Eigen.h:103
colmap::Point2D::Point2D
Point2D()
Definition: point2d.cc:36
colmap::Bitmap::SetPixel
bool SetPixel(const int x, const int y, const BitmapColor< uint8_t > &color)
Definition: bitmap.cc:199
alignment.h
colmap::Bitmap
Definition: bitmap.h:51
point2d.h
colmap::Point2D::XY
const Eigen::Vector2d & XY() const
Definition: point2d.h:53
colmap::LineSegmentOrientation::UNDEFINED
@ UNDEFINED
colmap::Bitmap::Allocate
bool Allocate(const int width, const int height, const bool as_rgb)
Definition: bitmap.cc:104
testing.h
line.h
colmap::point3D_t
uint64_t point3D_t
Definition: types.h:72
size
int size
Definition: FileIOFactory.cpp:130
colmap::Point2D::operator!=
bool operator!=(const Point2D &other) const
Definition: point2d.h:75
colmap::Point2D::operator==
bool operator==(const Point2D &other) const
Definition: point2d.h:71
colmap::Point2D::Y
double Y() const
Definition: point2d.h:59
colmap::ClassifyLineSegmentOrientations
std::vector< LineSegmentOrientation > ClassifyLineSegmentOrientations(const std::vector< LineSegment > &segments, const double tolerance)
Definition: line.cc:79
colmap::Point2D
Definition: point2d.h:20
colmap::DetectLineSegments
std::vector< LineSegment > DetectLineSegments(const Bitmap &bitmap, const double min_length)
Definition: line.cc:42
colmap::Point2D::SetXY
void SetXY(const Eigen::Vector2d &xy)
Definition: point2d.h:61
colmap::BitmapColor
Definition: bitmap.h:30
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(TestDetectLineSegments)
Definition: line_test.cc:39
colmap::Point2D::Point3DId
point3D_t Point3DId() const
Definition: point2d.h:63
colmap::Point2D::HasPoint3D
bool HasPoint3D() const
Definition: point2d.h:65
colmap::kInvalidPoint3DId
const point3D_t kInvalidPoint3DId
Definition: types.h:80
colmap
Definition: AutomaticReconstructionController.h:17
colmap::LineSegmentOrientation::HORIZONTAL
@ HORIZONTAL
colmap::Point2D::X
double X() const
Definition: point2d.h:57
colmap::Point2D::SetPoint3DId
void SetPoint3DId(const point3D_t point3D_id)
Definition: point2d.h:67