45 const float* K,
const float* R,
const float* T)
47 memcpy(K_, K, 9 *
sizeof(
float));
48 memcpy(R_, R, 9 *
sizeof(
float));
49 memcpy(T_, T, 3 *
sizeof(
float));
56 CHECK_EQ(width_, bitmap_.
Width());
57 CHECK_EQ(height_, bitmap_.
Height());
63 const size_t new_width = std::round(width_ * factor_x);
64 const size_t new_height = std::round(height_ * factor_y);
66 if (bitmap_.
Data() !=
nullptr) {
67 bitmap_.
Rescale(new_width, new_height);
70 const float scale_x = new_width /
static_cast<float>(width_);
71 const float scale_y = new_height /
static_cast<float>(height_);
84 if (width_ <= max_width && height_ <= max_height) {
87 const float factor_x =
static_cast<float>(max_width) / width_;
88 const float factor_y =
static_cast<float>(max_height) / height_;
89 Rescale(std::min(factor_x, factor_y));
93 const float R2[9],
const float T2[3],
float R[9],
95 const Eigen::Map<const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> R1_m(R1);
96 const Eigen::Map<const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> R2_m(R2);
97 const Eigen::Map<const Eigen::Matrix<float, 3, 1>> T1_m(T1);
98 const Eigen::Map<const Eigen::Matrix<float, 3, 1>> T2_m(T2);
99 Eigen::Map<Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> R_m(R);
100 Eigen::Map<Eigen::Vector3f> T_m(T);
102 R_m = R2_m * R1_m.transpose();
103 T_m = T2_m - R_m * T1_m;
107 const float T[3],
float P[12]) {
108 Eigen::Map<Eigen::Matrix<float, 3, 4, Eigen::RowMajor>> P_m(P);
110 Eigen::Map<
const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>>(R);
111 P_m.rightCols<1>() = Eigen::Map<const Eigen::Vector3f>(T);
112 P_m = Eigen::Map<const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>>(K) * P_m;
116 const float T[3],
float inv_P[12]) {
117 Eigen::Matrix<float, 4, 4, Eigen::RowMajor> P;
119 P.row(3) = Eigen::Vector4f(0, 0, 0, 1);
120 const Eigen::Matrix4f inv_P_temp = P.inverse();
121 Eigen::Map<Eigen::Matrix<float, 3, 4, Eigen::RowMajor>> inv_P_m(inv_P);
122 inv_P_m = inv_P_temp.topRows<3>();
126 const Eigen::Map<const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> R_m(R);
127 const Eigen::Map<const Eigen::Matrix<float, 3, 1>> T_m(T);
128 Eigen::Map<Eigen::Vector3f> C_m(C);
129 C_m = -R_m.transpose() * T_m;
133 Eigen::Map<Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> R_m(R);
134 Eigen::Map<Eigen::Matrix<float, 3, 1>> T_m(T);
135 const Eigen::Map<const Eigen::Matrix<float, 3, 3, Eigen::RowMajor>> RR_m(RR);
void Rescale(const int new_width, const int new_height, const FREE_IMAGE_FILTER filter=FILTER_BILINEAR)
const FIBITMAP * Data() const
void SetBitmap(const Bitmap &bitmap)
void Rescale(const float factor)
void Downsize(const size_t max_width, const size_t max_height)
static const std::string path
void RotatePose(const float RR[9], float R[9], float T[3])
void ComposeInverseProjectionMatrix(const float K[9], const float R[9], const float T[3], float inv_P[12])
void ComputeProjectionCenter(const float R[9], const float T[3], float C[3])
void ComposeProjectionMatrix(const float K[9], const float R[9], const float T[3], float P[12])
void ComputeRelativePose(const float R1[9], const float T1[3], const float R2[9], const float T2[3], float R[9], float T[3])