本文整理汇总了C++中ModelType::optimizeModelCoefficients方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelType::optimizeModelCoefficients方法的具体用法?C++ ModelType::optimizeModelCoefficients怎么用?C++ ModelType::optimizeModelCoefficients使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelType
的用法示例。
在下文中一共展示了ModelType::optimizeModelCoefficients方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verifyPlaneSac
void verifyPlaneSac (ModelType & model, SacType & sac, unsigned int inlier_number = 2000, float tol = 1e-1f,
float refined_tol = 1e-1f, float proj_tol = 1e-3f)
{
// Algorithm tests
bool result = sac.computeModel ();
ASSERT_EQ (result, true);
std::vector<int> sample;
sac.getModel (sample);
EXPECT_EQ (int (sample.size ()), 3);
std::vector<int> inliers;
sac.getInliers (inliers);
EXPECT_GE (int (inliers.size ()), inlier_number);
Eigen::VectorXf coeff;
sac.getModelCoefficients (coeff);
EXPECT_EQ (int (coeff.size ()), 4);
EXPECT_NEAR (coeff[0]/coeff[3], plane_coeffs_[0], tol);
EXPECT_NEAR (coeff[1]/coeff[3], plane_coeffs_[1], tol);
EXPECT_NEAR (coeff[2]/coeff[3], plane_coeffs_[2], tol);
Eigen::VectorXf coeff_refined;
model->optimizeModelCoefficients (inliers, coeff, coeff_refined);
EXPECT_EQ (int (coeff_refined.size ()), 4);
EXPECT_NEAR (coeff_refined[0]/coeff_refined[3], plane_coeffs_[0], refined_tol);
EXPECT_NEAR (coeff_refined[1]/coeff_refined[3], plane_coeffs_[1], refined_tol);
// This test fails in Windows (VS 2010) -- not sure why yet -- relaxing the constraint from 1e-2 to 1e-1
// This test fails in MacOS too -- not sure why yet -- disabling
//EXPECT_NEAR (coeff_refined[2]/coeff_refined[3], plane_coeffs_[2], refined_tol);
// Projection tests
PointCloud<PointXYZ> proj_points;
model->projectPoints (inliers, coeff_refined, proj_points);
EXPECT_NEAR (proj_points.points[20].x, 1.1266, proj_tol);
EXPECT_NEAR (proj_points.points[20].y, 0.0152, proj_tol);
EXPECT_NEAR (proj_points.points[20].z, -0.0156, proj_tol);
EXPECT_NEAR (proj_points.points[30].x, 1.1843, proj_tol);
EXPECT_NEAR (proj_points.points[30].y, -0.0635, proj_tol);
EXPECT_NEAR (proj_points.points[30].z, -0.0201, proj_tol);
EXPECT_NEAR (proj_points.points[50].x, 1.0749, proj_tol);
EXPECT_NEAR (proj_points.points[50].y, -0.0586, proj_tol);
EXPECT_NEAR (proj_points.points[50].z, 0.0587, refined_tol);
}