Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 namespace cob_3d_registration {
00057
00058 template <typename Point>
00059 bool Registration_Corrospondence<Point>::compute_features() {
00060 if(register_.size()<1) {
00061 register_ = *this->input_org_;
00062 return true;
00063 }
00064
00065 return keypoints_ && keypoints_->compute(register_, *this->input_org_);
00066 }
00067
00068 template <typename Point>
00069 bool Registration_Corrospondence<Point>::compute_corrospondences() {
00070
00071 all_correspondences_.reset(new pcl::registration::Correspondences);
00072 keypoints_->getCorrespondences (*all_correspondences_);
00073
00074
00075
00076 return true;
00077 }
00078
00079 template <typename Point>
00080 bool Registration_Corrospondence<Point>::compute_transformation() {
00081 Eigen::Matrix4f transform = Eigen::Matrix4f::Identity();
00082
00083
00084 pcl::registration::CorrespondencesPtr good_correspondences (new pcl::registration::Correspondences);
00085
00086 rejectBadCorrespondences(all_correspondences_, *good_correspondences);
00087
00088 if(good_correspondences->size()<3) {
00089 ROS_ERROR("not enough coresspondences");
00090 return false;
00091 }
00092
00093
00094 pcl::registration::TransformationEstimationSVD<Point, Point> trans_est;
00095 trans_est.estimateRigidTransformation (*keypoints_->getSourcePoints(), *keypoints_->getTargetPoints(), *good_correspondences, transform);
00096
00097 this->transformation_ = transform*this->transformation_;
00098
00099 std::cout<<"transf\n"<<this->transformation_<<"\n";
00100
00101 register_ = *this->input_org_;
00102
00103 return true;
00104 }
00105
00106
00107 template <typename Point>
00108 void Registration_Corrospondence<Point>::rejectBadCorrespondences (const pcl::registration::CorrespondencesPtr &all_correspondences,
00109 pcl::registration::Correspondences &remaining_correspondences)
00110 {
00111 pcl::registration::CorrespondenceRejectorDistance rej;
00112
00113
00114 rej.setMaximumDistance (rejection_dis_);
00115 rej.setInputCorrespondences (all_correspondences);
00116 rej.getCorrespondeces (remaining_correspondences);
00117
00118 ROS_INFO("rejectBadCorrespondences %d %d", (int)all_correspondences->size(), (int)remaining_correspondences.size());
00119 }
00120
00121
00122 }
00123
00124 #define PCL_INSTANTIATE_Registration_Corrospondence(T) template class PCL_EXPORTS cob_3d_registration::Registration_Corrospondence<T>;
00125