featuresextractor.cpp
Go to the documentation of this file.
00001 #include "featuresextractor.h"
00002 
00003 FeaturesExtractor::FeaturesExtractor()
00004 {
00005 }
00006 
00007 std::vector<cv::Point2f> FeaturesExtractor::mapFeatures(cv::Mat & map,
00008                                                         const int & maxCorners,
00009                                                         const double & qualityLevel,
00010                                                         const double & minDistance,
00011                                                         const int & blockSize,
00012                                                         const bool & useHarrisDetector,
00013                                                         const double & k)
00014 {
00015     //Extracted Points
00016     std::vector<cv::Point2f> corners;
00017 
00018     //Extract Map Points
00019 
00020     for(int ii=1;ii<(map.rows)-1;ii++)
00021     {
00022         for(int jj=1;jj<(map.cols)-1;jj++)
00023         {
00024             if((cv::Point3i(map.at<cv::Vec3b>(ii,jj)).x==0) && (cv::Point3i(map.at<cv::Vec3b>(ii,jj)).y==0) && (cv::Point3i(map.at<cv::Vec3b>(ii,jj)).z==0))
00025             {
00026                 corners.push_back(cv::Point(jj,ii));
00027             }
00028         }
00029     }
00030 
00031     //Scale
00032     for(int gp=0;gp<corners.size();gp++)
00033     {
00034         corners[gp].x-=map.cols/2.0;
00035         corners[gp].y-=map.rows/2.0;
00036     }
00037 
00038    return corners;
00039 }
00040 
00041 pcl::PointCloud<pcl::PointXYZI>::Ptr FeaturesExtractor::localFeatures(const pcl::PointCloud<point_type>::Ptr point_cloud_in)
00042 {
00043     pcl::PointCloud<point_type>::Ptr point_cloud_out(new pcl::PointCloud<point_type>());
00044 
00045     pcl::HarrisKeypoint3D <point_type, point_type> detector;
00046     pcl::PointCloud<point_type>::Ptr keypoints (new pcl::PointCloud<point_type>);
00047     detector.setInputCloud (point_cloud_in);
00048     //detector.setNonMaxSupression (true);
00049     //detector.setThreshold (0.1);
00050     detector.setRadius(0.05);
00051     pcl::StopWatch watch;
00052     detector.compute (*keypoints);
00053     //pcl::console::print_highlight ("Detected %zd points in %lfs\n from %zd", keypoints->size (), watch.getTimeSeconds (), point_cloud_in->size());
00054     pcl::IndicesConstPtr keypoints_indices = detector.getIndices ();
00055 
00056     pcl::ExtractIndices<point_type> extract;
00057 
00058     extract.setInputCloud (point_cloud_in);
00059     extract.setIndices (keypoints_indices);
00060     extract.setNegative (false);
00061     extract.filter (*point_cloud_out);
00062     return point_cloud_out;
00063 }
00064 


ekf_localization
Author(s):
autogenerated on Sat Jun 8 2019 20:11:55