MCPcopy Create free account
hub / github.com/Pamphlett/Outram / plane_geometric_verify

Method plane_geometric_verify

src/STDesc.cpp:2722–2781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2720}
2721
2722double STDescManager::plane_geometric_verify(
2723 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr &source_cloud,
2724 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr &target_cloud,
2725 const std::pair<Eigen::Vector3d, Eigen::Matrix3d> &transform) {
2726 Eigen::Vector3d t = transform.first;
2727 Eigen::Matrix3d rot = transform.second;
2728 pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr kd_tree(
2729 new pcl::KdTreeFLANN<pcl::PointXYZ>);
2730 pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud(
2731 new pcl::PointCloud<pcl::PointXYZ>);
2732 for (size_t i = 0; i < target_cloud->size(); i++) {
2733 pcl::PointXYZ pi;
2734 pi.x = target_cloud->points[i].x;
2735 pi.y = target_cloud->points[i].y;
2736 pi.z = target_cloud->points[i].z;
2737 input_cloud->push_back(pi);
2738 }
2739 kd_tree->setInputCloud(input_cloud);
2740 std::vector<int> pointIdxNKNSearch(1);
2741 std::vector<float> pointNKNSquaredDistance(1);
2742 double useful_match = 0;
2743 double normal_threshold = config_setting_.normal_threshold_;
2744 double dis_threshold = config_setting_.dis_threshold_;
2745 for (size_t i = 0; i < source_cloud->size(); i++) {
2746 pcl::PointXYZINormal searchPoint = source_cloud->points[i];
2747 pcl::PointXYZ use_search_point;
2748 use_search_point.x = searchPoint.x;
2749 use_search_point.y = searchPoint.y;
2750 use_search_point.z = searchPoint.z;
2751 Eigen::Vector3d pi(searchPoint.x, searchPoint.y, searchPoint.z);
2752 pi = rot * pi + t;
2753 use_search_point.x = pi[0];
2754 use_search_point.y = pi[1];
2755 use_search_point.z = pi[2];
2756 Eigen::Vector3d ni(searchPoint.normal_x, searchPoint.normal_y,
2757 searchPoint.normal_z);
2758 ni = rot * ni;
2759 int K = 3;
2760 if (kd_tree->nearestKSearch(use_search_point, K, pointIdxNKNSearch,
2761 pointNKNSquaredDistance) > 0) {
2762 for (size_t j = 0; j < K; j++) {
2763 pcl::PointXYZINormal nearstPoint =
2764 target_cloud->points[pointIdxNKNSearch[j]];
2765 Eigen::Vector3d tpi(nearstPoint.x, nearstPoint.y, nearstPoint.z);
2766 Eigen::Vector3d tni(nearstPoint.normal_x, nearstPoint.normal_y,
2767 nearstPoint.normal_z);
2768 Eigen::Vector3d normal_inc = ni - tni;
2769 Eigen::Vector3d normal_add = ni + tni;
2770 double point_to_plane = fabs(tni.transpose() * (pi - tpi));
2771 if ((normal_inc.norm() < normal_threshold ||
2772 normal_add.norm() < normal_threshold) &&
2773 point_to_plane < dis_threshold) {
2774 useful_match++;
2775 break;
2776 }
2777 }
2778 }
2779 }

Callers

nothing calls this directly

Calls 4

nearestKSearchMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
setInputCloudMethod · 0.45

Tested by

no test coverage detected