本文整理汇总了C++中SE3::screenHessian方法的典型用法代码示例。如果您正苦于以下问题:C++ SE3::screenHessian方法的具体用法?C++ SE3::screenHessian怎么用?C++ SE3::screenHessian使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SE3
的用法示例。
在下文中一共展示了SE3::screenHessian方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testScreenHessian
static bool testScreenHessian()
{
Eigen::Matrix<double, 6, 1> delta = Eigen::Matrix<double, 6, 1>::Zero();
Eigen::Matrix<double, 6, 6> shNumericX, shNumericY, shX, shY;
SE3<double> pose;
pose.set( Math::deg2Rad( 10.0 ), Math::deg2Rad( 40.0 ), Math::deg2Rad( -120.0 ), -100.0, 200.0, 300.0 );
Eigen::Matrix<double, 3, 3> K( Eigen::Matrix<double, 3, 3>::Zero() );
K( 0, 0 ) = 650.0; K( 0, 2 ) = 320.0;
K( 1, 1 ) = 650.0; K( 1, 2 ) = 240.0;
K( 2, 2 ) = 1.0;
Eigen::Matrix<double, 3, 1> point, ptrans;
Eigen::Matrix<double, 2, 1> sp, ff, fb, bf, bb, xxf, xxb, hess;
point[ 0 ] = 100; point[ 1 ] = 200; point[ 2 ] = 300;
// project the point with current parameters
pose.transform( ptrans, point );
projectWithCam( sp, ptrans, K );
double h = 0.001;
for( size_t i = 0; i < 6; i++ ){
for( size_t j = 0; j < 6; j++ ){
if( i == j ){
// +
delta[ j ] = h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( xxf, ptrans, K );
delta[ j ] = -2 * h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( xxb, ptrans, K );
hess = ( xxb - 2 * sp + xxf ) / ( h*h );
// back to start
delta[ j ] = h;
pose.apply( delta );
delta[ j ] = 0;
} else {
delta[ i ] = h;
delta[ j ] = h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( ff, ptrans, K );
pose.apply( -delta );
delta[ i ] = h;
delta[ j ] = -h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( fb, ptrans, K );
pose.apply( -delta );
delta[ i ] = -h;
delta[ j ] = h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( bf, ptrans, K );
pose.apply( -delta );
delta[ i ] = -h;
delta[ j ] = -h;
pose.apply( delta );
pose.transform( ptrans, point );
projectWithCam( bb, ptrans, K );
pose.apply( -delta );
hess = ( ff - bf - fb + bb ) / ( 4 * h * h );
delta.setZero();
}
shNumericX( i, j ) = hess[ 0 ];
shNumericY( i, j ) = hess[ 1 ];
}
}
pose.transform( ptrans, point );
pose.screenHessian( shX, shY, ptrans, K );
bool b, ret = true;
Eigen::Matrix<double, 6, 6> jDiff;
jDiff = shNumericX - shX;
b = ( jDiff.array().abs().sum() / ( double )( jDiff.rows() * jDiff.cols() ) ) < 0.0001;
CVTTEST_PRINT( "Pose ScreenHessian X", b );
if( !b ){
std::cout << "Analytic:\n" << shX << std::endl;
std::cout << "Numeric:\n" << shNumericX << std::endl;
std::cout << "Difference:\n" << jDiff << std::endl;
}
ret &= b;
jDiff = shNumericY - shY;
b = ( jDiff.array().abs().sum() / ( double )( jDiff.rows() * jDiff.cols() ) ) < 0.0001;
//.........这里部分代码省略.........