NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
depth_image_features_and_points.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
22 
23 #include <opencv2/core.hpp>
24 #include <opencv2/features2d.hpp>
25 #include <opencv2/imgproc.hpp>
26 
27 #include <pcl/kdtree/impl/kdtree_flann.hpp>
28 #include <pcl/search/impl/search.hpp>
29 #include <pcl/search/impl/kdtree.hpp>
30 
31 #ifndef DEPTH_ODOMETRY_DEPTH_IMAGE_FEATURES_AND_POINTS_H_
32 #define DEPTH_ODOMETRY_DEPTH_IMAGE_FEATURES_AND_POINTS_H_
33 
34 namespace depth_odometry {
36  public:
37  // TODO(rsoussan): Pass clahe as boost optional ref! add default as boost none!
39  const cv::Ptr<cv::CLAHE> clahe, const bool normals_required = false)
40  : depth_image_(depth_image) {
41  if (clahe) {
42  cv::Mat clahe_image;
43  clahe->apply(depth_image_.image(), clahe_image);
44  feature_image_.reset(new vision_common::FeatureImage(clahe_image, feature_detector));
45  } else {
46  feature_image_.reset(new vision_common::FeatureImage(depth_image_.image(), feature_detector));
47  }
48 
49  if (normals_required) {
50  kdtree_.reset(new pcl::search::KdTree<pcl::PointXYZI>());
51  filtered_point_cloud_ =
52  point_cloud_common::FilteredPointCloud<pcl::PointXYZI>(depth_image_.unfiltered_point_cloud());
53  kdtree_->setInputCloud(filtered_point_cloud_);
54  }
55  }
56 
57  boost::optional<Eigen::Vector3d> Normal(const Eigen::Vector3d& point_3d, const double search_radius) const {
58  return point_cloud_common::GetNormal(point_3d, *filtered_point_cloud_, *kdtree_, search_radius);
59  }
60 
61  const vision_common::FeatureImage& feature_image() const { return *feature_image_; }
62 
63  const localization_measurements::DepthImage& depth_image() const { return depth_image_; }
64 
65  private:
67  std::unique_ptr<vision_common::FeatureImage> feature_image_;
68  pcl::search::KdTree<pcl::PointXYZI>::Ptr kdtree_;
69  pcl::PointCloud<pcl::PointXYZI>::Ptr filtered_point_cloud_;
70 };
71 } // namespace depth_odometry
72 #endif // DEPTH_ODOMETRY_DEPTH_IMAGE_FEATURES_AND_POINTS_H_
utilities.h
depth_odometry::DepthImageFeaturesAndPoints::depth_image
const localization_measurements::DepthImage & depth_image() const
Definition: depth_image_features_and_points.h:63
depth_odometry::DepthImageFeaturesAndPoints::Normal
boost::optional< Eigen::Vector3d > Normal(const Eigen::Vector3d &point_3d, const double search_radius) const
Definition: depth_image_features_and_points.h:57
depth_odometry::DepthImageFeaturesAndPoints
Definition: depth_image_features_and_points.h:35
localization_measurements::DepthImage::image
const cv::Mat & image() const
Definition: depth_image.h:40
feature_image.h
depth_odometry
Definition: depth_image_features_and_points.h:34
vision_common::FeatureImage
Definition: feature_image.h:27
localization_measurements::DepthImage::unfiltered_point_cloud
const pcl::PointCloud< pcl::PointXYZI >::Ptr unfiltered_point_cloud() const
Definition: depth_image.h:41
localization_measurements::DepthImage
Definition: depth_image.h:32
depth_odometry::DepthImageFeaturesAndPoints::DepthImageFeaturesAndPoints
DepthImageFeaturesAndPoints(const localization_measurements::DepthImage &depth_image, cv::Feature2D &feature_detector, const cv::Ptr< cv::CLAHE > clahe, const bool normals_required=false)
Definition: depth_image_features_and_points.h:38
point_cloud_common::Vector3d
Eigen::Vector3d Vector3d(const PointType &point)
Definition: utilities.h:328
depth_image.h
point_cloud_common::GetNormal
boost::optional< Eigen::Vector3d > GetNormal(const Eigen::Vector3d &point, const pcl::PointCloud< PointType > &cloud, const pcl::search::KdTree< PointType > &kdtree, const double search_radius=0.03)
Definition: utilities.h:338
depth_odometry::DepthImageFeaturesAndPoints::feature_image
const vision_common::FeatureImage & feature_image() const
Definition: depth_image_features_and_points.h:61