21#ifndef LIBMV_MULTIVIEW_PROJECTION_H_
22#define LIBMV_MULTIVIEW_PROJECTION_H_
34 const Vec2& principal_point,
35 const Vec2& principal_point_new,
43 const Vec2& principal_point,
45 double aspect_ratio_new,
54 return h.head<2>() / h(2);
57 return h.head<3>() / h(3);
61 e.row(0) = h.row(0).array() / h.row(2).array();
62 e.row(1) = h.row(1).array() / h.row(2).array();
69 h.block(0, 0, 2, x.cols()) =
x;
74 h->resize(3, x.cols());
75 h->block(0, 0, 2, x.cols()) =
x;
80 h.block(0, 0, 3, x.cols()) =
x;
85 h->resize(4, x.cols());
86 h->block(0, 0, 3, x.cols()) =
x;
92 return Vec3(
x(0),
x(1), 1);
95 return Vec4(
x(0),
x(1),
x(2), 1);
105 return hx.head<2>() / hx(2);
114 *x = hx.head<2>() / hx(2);
126 *x = hx.head<2>() / hx(2);
130 x->resize(2,
X.cols());
131 for (
int c = 0; c <
X.cols(); ++c) {
133 x->col(c) = hx.head<2>() / hx(2);
144 x->resize(2,
X.cols());
145 for (
int c = 0; c <
X.cols(); ++c) {
149 x->col(c) = hx.head<2>() / hx(2);
154 x->resize(2, ids.size());
157 for (
int c = 0; c < ids.size(); ++c) {
158 HX <<
X.col(ids[c]), 1.0;
160 x->col(c) = hx.head<2>() / hx(2);
184 double condition_1 =
P.row(2).dot(
X) *
X[3];
185 double condition_2 =
X[2] *
X[3];
186 if (condition_1 > 0 && condition_2 > 0) {
195 X_homo.segment<3>(0) =
X;
211 const Mat4X& X_world,
213 size_t num_points = x_image.cols();
215 return dx.norm() / num_points;
220 const Mat3X& X_world,
226 size_t num_points = x_image.cols();
228 return dx.norm() / num_points;
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void EuclideanToHomogeneous(const Mat &X, Mat *H)
Eigen::Matrix< double, 3, 3 > Mat3
void HomogeneousToEuclidean(const Mat &H, Mat *X)
void HomogeneousToNormalizedCamera(const Mat3X &x, const Mat3 &K, Mat2X *n)
void ProjectionShiftPrincipalPoint(const Mat34 &P, const Vec2 &principal_point, const Vec2 &principal_point_new, Mat34 *P_new)
double Depth(const Mat3 &R, const Vec3 &t, const Vec3 &X)
double RootMeanSquareError(const Mat2X &x_image, const Mat4X &X_world, const Mat34 &P)
Estimates the root mean square error (2D)
Vec2 Project(const Mat34 &P, const Vec3 &X)
void KRt_From_P(const Mat34 &P, Mat3 *Kp, Mat3 *Rp, Vec3 *tp)
Eigen::Matrix< double, 3, 4 > Mat34
Eigen::Matrix< unsigned int, Eigen::Dynamic, 1 > Vecu
Eigen::Matrix< double, 4, Eigen::Dynamic > Mat4X
Eigen::Matrix< double, 3, Eigen::Dynamic > Mat3X
void ProjectionChangeAspectRatio(const Mat34 &P, const Vec2 &principal_point, double aspect_ratio, double aspect_ratio_new, Mat34 *P_new)
Vec2 ImageToNormImageCoordinates(Mat3 &Kinverse, Vec2 &x)
Eigen::Matrix< double, 2, Eigen::Dynamic > Mat2X
void P_From_KRt(const Mat3 &K, const Mat3 &R, const Vec3 &t, Mat34 *P)
bool isInFrontOfCamera(const Mat34 &P, const Vec4 &X)
void EuclideanToNormalizedCamera(const Mat2X &x, const Mat3 &K, Mat2X *n)