41 #ifndef PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_ORGANIZED_PROJECTION_IMPL_HPP_
42 #define PCL_REGISTRATION_CORRESPONDENCE_ESTIMATION_ORGANIZED_PROJECTION_IMPL_HPP_
46 namespace registration {
48 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
55 target_cloud_updated_ =
false;
60 if (!target_->isOrganized()) {
61 PCL_WARN(
"[pcl::registration::%s::initCompute] Target cloud is not organized.\n",
62 getClassName().c_str());
67 projection_matrix_(0, 0) = fx_;
68 projection_matrix_(1, 1) = fy_;
69 projection_matrix_(0, 2) = cx_;
70 projection_matrix_(1, 2) = cy_;
75 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
79 const double max_distance)
84 correspondences.resize(indices_->size());
85 std::size_t c_index = 0;
87 for (
const auto& src_idx : (*indices_)) {
89 const Eigen::Vector4f p_src(src_to_tgt_transformation_ *
90 (*input_)[src_idx].getVector4fMap());
91 const Eigen::Vector3f p_src3(p_src[0], p_src[1], p_src[2]);
92 const Eigen::Vector3f uv(projection_matrix_ * p_src3);
98 const int u =
static_cast<int>(uv[0] / uv[2]);
99 const int v =
static_cast<int>(uv[1] / uv[2]);
101 if (u >= 0 && u <
static_cast<int>(target_->width) && v >= 0 &&
102 v < static_cast<int>(target_->height)) {
103 const PointTarget& pt_tgt = target_->at(u, v);
107 if (std::abs(uv[2] - pt_tgt.z) > depth_threshold_)
110 const double dist = (p_src3 - pt_tgt.getVector3fMap()).norm();
111 if (dist < max_distance)
113 src_idx, v * target_->width + u,
static_cast<float>(dist));
118 correspondences.resize(c_index);
121 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
125 const double max_distance)
129 determineCorrespondences(correspondences, max_distance);
Abstract CorrespondenceEstimationBase class.
void determineReciprocalCorrespondences(Correspondences &correspondences, const double max_distance)
Computes the correspondences, applying a maximum Euclidean distance threshold.
void determineCorrespondences(Correspondences &correspondences, const double max_distance)
Computes the correspondences, applying a maximum Euclidean distance threshold.
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Correspondence represents a match between two entities (e.g., points, descriptors,...