Go to the documentation of this file.00001
00024 #include "rgbdtools/features/feature_detector.h"
00025
00026 namespace rgbdtools {
00027
00028 FeatureDetector::FeatureDetector():
00029 compute_descriptors_(false),
00030 max_range_(7.0),
00031 max_stdev_(0.15),
00032 smooth_(0)
00033 {
00034
00035 }
00036
00037 FeatureDetector::~FeatureDetector()
00038 {
00039
00040 }
00041
00042 void FeatureDetector::findFeatures(RGBDFrame& frame)
00043 {
00044 boost::mutex::scoped_lock(mutex_);
00045
00046 const cv::Mat& input_img = frame.rgb_img;
00047
00048 cv::Mat gray_img(input_img.rows, input_img.cols, CV_8UC1);
00049 const cv::Mat* ptarget_img = NULL;
00050
00051 if (input_img.type() != CV_8UC1)
00052 {
00053
00054 cvtColor(input_img, gray_img, CV_BGR2GRAY);
00055 ptarget_img = &gray_img;
00056 }
00057 else
00058 ptarget_img = &input_img;
00059
00060
00061 if(smooth_ > 0)
00062 {
00063 int blur_size = smooth_*2 + 1;
00064 cv::GaussianBlur(*ptarget_img, *ptarget_img, cv::Size(blur_size, blur_size), 0);
00065 }
00066
00067
00069 frame.keypoints.clear();
00070 frame.descriptors = cv::Mat();
00071
00072
00073 findFeatures(frame, *ptarget_img);
00074
00075
00076 frame.computeDistributions(max_range_, max_stdev_);
00077 }
00078
00079 void FeatureDetector::setComputeDescriptors(bool compute_descriptors)
00080 {
00081 compute_descriptors_ = compute_descriptors;
00082 }
00083
00084 void FeatureDetector::setSmooth(int smooth)
00085 {
00086 smooth_ = smooth;
00087 }
00088
00089 void FeatureDetector::setMaxRange(double max_range)
00090 {
00091 max_range_ = max_range;
00092 }
00093
00094 void FeatureDetector::setMaxStDev(double max_stdev)
00095 {
00096 max_stdev_ = max_stdev;
00097 }
00098
00099 int FeatureDetector::getSmooth() const
00100 {
00101 return smooth_;
00102 }
00103
00104 double FeatureDetector::getMaxRange() const
00105 {
00106 return max_range_;
00107 }
00108
00109 double FeatureDetector::getMaxStDev() const
00110 {
00111 return max_stdev_;
00112 }
00113
00114 }