Problem in implementing rotation invariant BRIEF
Hi,
As part of my research on binary descriptor, I'm implementing a rotation invariant version of BRIEF. Basically, I rotate the sampling points by the angle of the patch (given from the detector).
First question: Is this something that I can contribute to OpenCV? will the moderators be interested?
Now, I'm having linking problems with the function:
AlgorithmInfo* info() const;
I'm getting "unresolved external symbol" with the function's name.
Here is my code: in fetures2d.hpp":
class CV_EXPORTS InvariantBriefDescriptorExtractor : public DescriptorExtractor
{
public:
static const int PATCH_SIZE = 48;
static const int KERNEL_SIZE = 9;
// bytes is a length of descriptor in bytes. It can be equal 16, 32 or 64 bytes.
InvariantBriefDescriptorExtractor(int bytes = 32);
virtual void read(const FileNode&);
virtual void write(FileStorage&) const;
virtual int descriptorSize() const;
virtual int descriptorType() const;
AlgorithmInfo* info() const;
protected:
virtual void computeImpl(const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const;
typedef void(*PixelTestFn)(const Mat&, const vector<KeyPoint>&, const int *, Mat&);
int bytes_;
PixelTestFn test_fn_;
static int bit_pattern_64_[512 * 4];
};
And the file BriefRI.cpp (which contains the implementation):
#include "precomp.hpp"
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
using namespace cv;
static void calculateSums(const Mat &sum, const int &count, const int *pattern, float &cos_theta, float &sin_theta, KeyPoint pt);
inline int smoothedSum(const Mat& sum, const KeyPoint& pt, int y, int x)
{
static const int HALF_KERNEL = BriefDescriptorExtractor::KERNEL_SIZE / 2;
int img_y = (int)(pt.pt.y + 0.5) + y;
int img_x = (int)(pt.pt.x + 0.5) + x;
return sum.at<int>(img_y + HALF_KERNEL + 1, img_x + HALF_KERNEL + 1)
- sum.at<int>(img_y + HALF_KERNEL + 1, img_x - HALF_KERNEL)
- sum.at<int>(img_y - HALF_KERNEL, img_x + HALF_KERNEL + 1)
+ sum.at<int>(img_y - HALF_KERNEL, img_x - HALF_KERNEL);
}
static void pixelTests16(const Mat& sum, const std::vector<KeyPoint>& keypoints, const int *pattern, Mat& descriptors)
{
for (int i = 0; i < (int)keypoints.size(); ++i)
{
uchar* desc = descriptors.ptr(i);
const KeyPoint& pt = keypoints[i];
float angle = pt.angle;
angle *= (float)(CV_PI / 180.f);
float cos_theta = cos(angle);
float sin_theta = sin(angle);
int count = 0;
for (int ix = 0; ix < 16; ix++){
for (int jx = 7; jx >= 0; jx--){
int suma, sumb;
calculateSums(sum, count, pattern,cos_theta, sin_theta, pt);
desc[ix] += (uchar)((suma< sumb) << jx);
count += 4;
}
}
}
}
static void pixelTests32(const Mat& sum, const std::vector<KeyPoint>& keypoints, const int *pattern, Mat& descriptors)
{
for (int i = 0; i < (int)keypoints.size(); ++i)
{
uchar* desc = descriptors.ptr(i);
const KeyPoint& pt = keypoints[i];
float angle = pt.angle;
angle *= (float)(CV_PI / 180.f);
float cos_theta = cos(angle);
float sin_theta = sin(angle);
int count = 0;
for (int ix = 0; ix < 32; ix++){
for (int jx = 7; jx >= 0; jx--){
int suma, sumb;
calculateSums(sum, count, pattern,cos_theta, sin_theta, pt);
desc[ix] += (uchar)((suma< sumb) << jx);
count += 4;
}
}
}
}
static void pixelTests64(const Mat& sum, const std::vector<KeyPoint>& keypoints, const int *pattern, Mat& descriptors)
{
for (int i = 0; i < (int)keypoints.size(); ++i)
{
uchar* desc = descriptors.ptr(i);
const KeyPoint& pt = keypoints[i];
float angle = pt.angle;
angle *= (float)(CV_PI / 180 ...
Did you implement the info() function? I can't find it in the provided code.
Thanks for the not @MathieuBarnachon. Indeed I didn't implement it - I solved it by adding some code to features2d_init.