40 for (
int i = 0; i <
markers.size(); ++i) {
54struct EuclideanResectCostFunction {
56 typedef Vec FMatrixType;
57 typedef Vec6 XMatrixType;
60 const EuclideanReconstruction& reconstruction,
61 const Mat3& initial_R)
71 Vec3 t = dRt.tail<3>();
76 for (
int i = 0; i <
markers.size(); ++i) {
77 const EuclideanPoint& point =
79 Vec3 projected =
R * point.X + t;
80 projected /= projected(2);
81 residuals[2 * i + 0] = projected(0) -
markers[i].x;
82 residuals[2 * i + 1] = projected(1) -
markers[i].y;
102 for (
int i = 0; i <
markers.size(); i++) {
105 LG <<
"Points for resect:\n" << points_2d;
114 LG <<
"Resection for image " <<
markers[0].image <<
" failed;"
115 <<
" trying fallback projective resection.";
117 LG <<
"No fallback; failing resection for " <<
markers[0].image;
127 for (
int i = 0; i <
markers.size(); i++) {
128 points_3d_homogeneous.col(i).head<3>() = points_3d.col(i);
129 points_3d_homogeneous(3, i) = 1.0;
132 if ((
P * points_3d_homogeneous.col(0))(2) < 0) {
133 LG <<
"Point behind camera; switch sign.";
141 Eigen::JacobiSVD<Mat3> svd(
R, Eigen::ComputeFullU | Eigen::ComputeFullV);
143 LG <<
"Resection rotation is: " << svd.singularValues().transpose();
144 LG <<
"Determinant is: " <<
R.determinant();
147 R = svd.matrixU() * svd.matrixV().transpose();
149 Vec3 xx =
R * points_3d.col(0) + t;
151 LG <<
"Final point is still behind camera...";
164 Vec6 dRt = Vec6::Zero();
167 Solver solver(resect_cost);
169 Solver::SolverParameters
params;
170 solver.minimize(
params, &dRt);
171 LG <<
"LM found incremental rotation: " << dRt.head<3>().
transpose();
178 LG <<
"Resection for image " <<
markers[0].image <<
" got:\n"
192struct ProjectiveResectCostFunction {
194 typedef Vec FMatrixType;
195 typedef Vec12 XMatrixType;
198 const ProjectiveReconstruction& reconstruction)
203 Map<const Mat34>
P(vector_P.data(), 3, 4);
208 for (
int i = 0; i <
markers.size(); ++i) {
209 const ProjectivePoint& point =
211 Vec3 projected =
P * point.X;
212 projected /= projected(2);
213 residuals[2 * i + 0] = projected(0) -
markers[i].x;
214 residuals[2 * i + 1] = projected(1) -
markers[i].y;
234 for (
int i = 0; i <
markers.size(); i++) {
235 points_3d_homogeneous.col(i) =
238 LG <<
"Points for resect:\n" << points_2d;
245 if ((
P * points_3d_homogeneous.col(0))(2) < 0) {
246 LG <<
"Point behind camera; switch sign.";
260 Solver solver(resect_cost);
262 Solver::SolverParameters
params;
263 solver.minimize(
params, &vector_P);
269 LG <<
"Resection for image " <<
markers[0].image <<
" got:\n"
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Map
btMatrix3x3 transpose() const
Return the transpose of the matrix.
ProjectivePoint * PointForTrack(int track)
Returns a pointer to the point corresponding to track.
void InsertCamera(int image, const Mat34 &P)
const vector< Marker > & markers
const ProjectiveReconstruction & reconstruction
bool EuclideanResection(const Mat2X &x_camera, const Mat3X &X_world, Mat3 *R, Vec3 *t, ResectionMethod method)
void Resection(const Matrix< T, 2, Dynamic > &x, const Matrix< T, 4, Dynamic > &X, Matrix< T, 3, 4 > *P)
Eigen::Matrix< double, 6, 1 > Vec6
bool ProjectiveResect(const vector< Marker > &markers, ProjectiveReconstruction *reconstruction)
Mat3 RotationFromEulerVector(Vec3 euler_vector)
Returns the rotaiton matrix built from given vector of euler angles.
Eigen::Matrix< double, 3, 3 > Mat3
bool EuclideanResect(const vector< Marker > &markers, EuclideanReconstruction *reconstruction, bool final_pass)
void KRt_From_P(const Mat34 &P, Mat3 *Kp, Mat3 *Rp, Vec3 *tp)
Eigen::Matrix< double, 3, 4 > Mat34
Eigen::Matrix< double, 4, Eigen::Dynamic > Mat4X
Eigen::Matrix< double, 3, Eigen::Dynamic > Mat3X
Eigen::Matrix< double, 12, 1 > Vec12
Eigen::Matrix< double, 2, Eigen::Dynamic > Mat2X