Commit a9b8fb83 authored by Vitaly Tuzov's avatar Vitaly Tuzov

GaussianBlur of the source image for LATCH descriptor made optional

parent 0bd061f0
...@@ -160,6 +160,7 @@ LATCH is a binary descriptor based on learned comparisons of triplets of image p ...@@ -160,6 +160,7 @@ LATCH is a binary descriptor based on learned comparisons of triplets of image p
* rotationInvariance - whether or not the descriptor should compansate for orientation changes. * rotationInvariance - whether or not the descriptor should compansate for orientation changes.
* half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x * half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x
then the half_ssd_size should be (7-1)/2 = 3. then the half_ssd_size should be (7-1)/2 = 3.
* sigma - sigma value for GaussianBlur smoothing of the source image. Source image will be used without smoothing in case sigma value is 0.
Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then
you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT. you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT.
...@@ -170,7 +171,7 @@ Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures ...@@ -170,7 +171,7 @@ Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures
class CV_EXPORTS_W LATCH : public Feature2D class CV_EXPORTS_W LATCH : public Feature2D
{ {
public: public:
CV_WRAP static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3); CV_WRAP static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size = 3, double sigma = 2.0);
}; };
/** @brief Class implementing DAISY descriptor, described in @cite Tola10 /** @brief Class implementing DAISY descriptor, described in @cite Tola10
......
...@@ -63,7 +63,7 @@ namespace cv ...@@ -63,7 +63,7 @@ namespace cv
public: public:
enum { PATCH_SIZE = 48 }; enum { PATCH_SIZE = 48 };
LATCHDescriptorExtractorImpl(int bytes = 32, bool rotationInvariance = true, int half_ssd_size = 3); LATCHDescriptorExtractorImpl(int bytes = 32, bool rotationInvariance = true, int half_ssd_size = 3, double sigma = 2.0);
virtual void read( const FileNode& ); virtual void read( const FileNode& );
virtual void write( FileStorage& ) const; virtual void write( FileStorage& ) const;
...@@ -81,14 +81,15 @@ namespace cv ...@@ -81,14 +81,15 @@ namespace cv
PixelTestFn test_fn_; PixelTestFn test_fn_;
bool rotationInvariance_; bool rotationInvariance_;
int half_ssd_size_; int half_ssd_size_;
double sigma_;
std::vector<int> sampling_points_ ; std::vector<int> sampling_points_ ;
}; };
Ptr<LATCH> LATCH::create(int bytes, bool rotationInvariance, int half_ssd_size) Ptr<LATCH> LATCH::create(int bytes, bool rotationInvariance, int half_ssd_size, double sigma)
{ {
return makePtr<LATCHDescriptorExtractorImpl>(bytes, rotationInvariance, half_ssd_size); return makePtr<LATCHDescriptorExtractorImpl>(bytes, rotationInvariance, half_ssd_size, sigma);
} }
void CalcuateSums(int count, const std::vector<int> &points, bool rotationInvariance, const Mat &grayImage, const KeyPoint &pt, int &suma, int &sumc, float cos_theta, float sin_theta, int half_ssd_size); void CalcuateSums(int count, const std::vector<int> &points, bool rotationInvariance, const Mat &grayImage, const KeyPoint &pt, int &suma, int &sumc, float cos_theta, float sin_theta, int half_ssd_size);
...@@ -403,8 +404,8 @@ namespace cv ...@@ -403,8 +404,8 @@ namespace cv
LATCHDescriptorExtractorImpl::LATCHDescriptorExtractorImpl(int bytes, bool rotationInvariance, int half_ssd_size) : LATCHDescriptorExtractorImpl::LATCHDescriptorExtractorImpl(int bytes, bool rotationInvariance, int half_ssd_size, double sigma) :
bytes_(bytes), test_fn_(NULL), rotationInvariance_(rotationInvariance), half_ssd_size_(half_ssd_size) bytes_(bytes), test_fn_(NULL), rotationInvariance_(rotationInvariance), half_ssd_size_(half_ssd_size), sigma_(sigma)
{ {
switch (bytes) switch (bytes)
{ {
...@@ -502,15 +503,27 @@ namespace cv ...@@ -502,15 +503,27 @@ namespace cv
Mat grayImage; Mat grayImage;
GaussianBlur(image, grayImage, cv::Size(3, 3), 2, 2); switch (image.type())
{
if (image.type() != CV_8U) cvtColor(image, grayImage, COLOR_BGR2GRAY); case CV_8UC1:
grayImage = image;
break;
case CV_8UC3:
cvtColor(image, grayImage, COLOR_BGR2GRAY);
break;
case CV_8UC4:
cvtColor(image, grayImage, COLOR_BGRA2GRAY);
break;
default:
CV_Error(Error::StsBadArg, "Image should be 8UC1, 8UC3 or 8UC4");
}
if (sigma_ != 0.)
GaussianBlur(grayImage, grayImage, cv::Size(3, 3), sigma_, sigma_);
//Remove keypoints very close to the border //Remove keypoints very close to the border
KeyPointsFilter::runByImageBorder(keypoints, image.size(), PATCH_SIZE / 2 + half_ssd_size_); KeyPointsFilter::runByImageBorder(keypoints, image.size(), PATCH_SIZE / 2 + half_ssd_size_);
bool _1d = false; bool _1d = false;
Mat descriptors; Mat descriptors;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment