ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
image.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 #include <cstdint>
11 #include <fstream>
12 #include <set>
13 #include <string>
14 #include <unordered_map>
15 #include <vector>
16 
17 #include "util/bitmap.h"
18 
19 namespace colmap {
20 namespace mvs {
21 
22 class Image {
23 public:
24  Image();
25  Image(const std::string& path,
26  const size_t width,
27  const size_t height,
28  const float* K,
29  const float* R,
30  const float* T);
31 
32  inline size_t GetWidth() const;
33  inline size_t GetHeight() const;
34 
35  void SetBitmap(const Bitmap& bitmap);
36  inline const Bitmap& GetBitmap() const;
37 
38  inline const std::string& GetPath() const;
39  inline const float* GetR() const;
40  inline const float* GetT() const;
41  inline const float* GetK() const;
42  inline const float* GetP() const;
43  inline const float* GetInvP() const;
44  inline const float* GetViewingDirection() const;
45 
46  void Rescale(const float factor);
47  void Rescale(const float factor_x, const float factor_y);
48  void Downsize(const size_t max_width, const size_t max_height);
49 
50 private:
51  std::string path_;
52  size_t width_;
53  size_t height_;
54  float K_[9];
55  float R_[9];
56  float T_[3];
57  float P_[12];
58  float inv_P_[12];
59  Bitmap bitmap_;
60 };
61 
62 void ComputeRelativePose(const float R1[9],
63  const float T1[3],
64  const float R2[9],
65  const float T2[3],
66  float R[9],
67  float T[3]);
68 
69 void ComposeProjectionMatrix(const float K[9],
70  const float R[9],
71  const float T[3],
72  float P[12]);
73 
74 void ComposeInverseProjectionMatrix(const float K[9],
75  const float R[9],
76  const float T[3],
77  float inv_P[12]);
78 
79 void ComputeProjectionCenter(const float R[9], const float T[3], float C[3]);
80 
81 void RotatePose(const float RR[9], float R[9], float T[3]);
82 
84 // Implementation
86 
87 size_t Image::GetWidth() const { return width_; }
88 
89 size_t Image::GetHeight() const { return height_; }
90 
91 const Bitmap& Image::GetBitmap() const { return bitmap_; }
92 
93 const std::string& Image::GetPath() const { return path_; }
94 
95 const float* Image::GetR() const { return R_; }
96 
97 const float* Image::GetT() const { return T_; }
98 
99 const float* Image::GetK() const { return K_; }
100 
101 const float* Image::GetP() const { return P_; }
102 
103 const float* Image::GetInvP() const { return inv_P_; }
104 
105 const float* Image::GetViewingDirection() const { return &R_[6]; }
106 
107 } // namespace mvs
108 } // namespace colmap
int width
int height
const float * GetViewingDirection() const
Definition: image.h:105
void SetBitmap(const Bitmap &bitmap)
Definition: image.cc:54
const float * GetK() const
Definition: image.h:99
size_t GetHeight() const
Definition: image.h:89
void Rescale(const float factor)
Definition: image.cc:60
const Bitmap & GetBitmap() const
Definition: image.h:91
const float * GetT() const
Definition: image.h:97
const float * GetR() const
Definition: image.h:95
const std::string & GetPath() const
Definition: image.h:93
const float * GetP() const
Definition: image.h:101
size_t GetWidth() const
Definition: image.h:87
void Downsize(const size_t max_width, const size_t max_height)
Definition: image.cc:83
const float * GetInvP() const
Definition: image.h:103
static const std::string path
Definition: PointCloud.cpp:59
void RotatePose(const float RR[9], float R[9], float T[3])
Definition: image.cc:132
void ComposeInverseProjectionMatrix(const float K[9], const float R[9], const float T[3], float inv_P[12])
Definition: image.cc:115
void ComputeProjectionCenter(const float R[9], const float T[3], float C[3])
Definition: image.cc:125
void ComposeProjectionMatrix(const float K[9], const float R[9], const float T[3], float P[12])
Definition: image.cc:106
void ComputeRelativePose(const float R1[9], const float T1[3], const float R2[9], const float T2[3], float R[9], float T[3])
Definition: image.cc:92