本文整理汇总了C++中eigen::Vector4d::noalias方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4d::noalias方法的具体用法?C++ Vector4d::noalias怎么用?C++ Vector4d::noalias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Vector4d
的用法示例。
在下文中一共展示了Vector4d::noalias方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//\fn Eigen::Vector4d triangulate(Point2f p1, Point2f p2, ExtrinsicParam e1, ExtrinsicParam e2);
///\brief This function triangulate a point in 3D.
///\param p1 The first point detected on the first image (cam1).
///\param p2 The second point detected on the second image (cam 2).
///\param e1 The first extrinsic object (cam1).
///\param e2 The second extrinsic object (cam2).
///\return The value of the triangulated point.
Eigen::Vector4d triangulate(cv::Point2f p1, cv::Point2f p2, ExtrinsicParam e1, ExtrinsicParam e2)
{
std::cout << "p1 = " << p1 << "\tp2 = " << p2 << std::endl;
Eigen::Matrix3d K = e1.getCameraMatrix(), K1 = e2.getCameraMatrix();
Eigen::MatrixXd Rt, Rt1;
Rt.resize(3,4);
Rt << e1.getRotationMatrix(), e1.getTranslationVector();
Rt1.resize(3,4);
Rt1 << e2.getRotationMatrix(), e2.getTranslationVector();
Eigen::MatrixXd KRt, KRt1;
KRt.noalias() = K*Rt;
KRt1.noalias() = K1*Rt1;
double p1x = (p1.x-K(0,2))/K(0,0);
double p2x = (p2.x-K1(0,2))/K1(0,0);
double p1y = (p1.y-K(1,2))/K(1,1);
double p2y = (p2.y-K1(1,2))/K1(1,1);
Eigen::VectorXd dist, dist1;
dist.resize(5);
dist1.resize(5);
dist << -0.133553,
0.078593,
0.001123,
0.001457,
-0.043746;
dist1 << -0.113323,
-0.023496,
-0.013891,
-0.003838,
0.267853;
double r2 = (p1x)*(p1x) + (p1y)*(p1y);
double xu1 = (p1x)*(1+dist(0)*r2+dist(1)*r2*r2+dist(4)*r2*r2*r2) + dist(2)*2*(p1x)*(p1y) + dist(3)*(r2+2*(p1x)*(p1x));
double yu1 = (p1y)*(1+dist(0)*r2+dist(1)*r2*r2+dist(4)*r2*r2*r2) + dist(3)*2*(p1x)*(p1y) + dist(2)*(r2+2*(p1y)*(p1y));
r2 = (p2x)*(p2x) + (p2y)*(p2y);
double xu2 = (p2x)*(1+dist(0)*r2+dist(1)*r2*r2+dist(4)*r2*r2*r2) + dist(2)*2*(p2x)*(p2y) + dist(3)*(r2+2*(p2x)*(p2x));
double yu2 = (p2y)*(1+dist(0)*r2+dist(1)*r2*r2+dist(4)*r2*r2*r2) + dist(3)*2*(p2x)*(p2y) + dist(2)*(r2+2*(p2y)*(p2y));
//std::cout << "xu1=" << xu1 << "\tyu1=" << yu1 << std::endl;
Eigen::Vector3d P1, P2;
P1(0) = p1.x;
P1(1) = p1.y;
P1(2) = 1.;
P2(0) = p2.x;
P2(1) = p2.y;
P2(2) = 1.;
P1.noalias() = e1.undistortPoint(P1);
P2.noalias() = e2.undistortPoint(P2);
Eigen::Matrix4d A;
/*A << (xu1)*Rt.row(2) - Rt.row(0),
(yu1)*Rt.row(2) - Rt.row(1),
(xu2)*Rt1.row(2) - Rt1.row(0),
(yu2)*Rt1.row(2) - Rt1.row(1);*/
A << (P1(0))*Rt.row(2) - Rt.row(0),
(P1(1))*Rt.row(2) - Rt.row(1),
(P2(0))*Rt1.row(2) - Rt1.row(0),
(P2(1))*Rt1.row(2) - Rt1.row(1);
Eigen::Matrix4d At, AtA;
At.noalias() = A.transpose();
AtA.noalias() = At*A;
Eigen::MatrixXd AInv;
pseudoInverse(A,AInv);
Eigen::EigenSolver<Eigen::Matrix4d> es(AtA);
double init = false;
Eigen::Vector4d min;
double indexOfMin;
for (int i=0; i < es.eigenvectors().cols(); i++)
{
if (es.eigenvectors().col(i).imag().isApprox(Eigen::Vector4d::Zero()))
{
Eigen::Vector4d real = es.eigenvectors().col(i).real();
double one = real(3);
real = (1./one)*real;
if (!init)
{
min.noalias() = real;
indexOfMin = i;
init = true;
}
else if (es.eigenvalues()[i].real() < es.eigenvalues()[indexOfMin].real())
{
min.noalias() = real;
indexOfMin = i;
}
}
}
std::cout << "triangulated point =\n" << min << std::endl;
return min;
}