18 #ifndef PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP 19 #define PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP 25 #include "../base.hpp" 26 #include "../util/std_util.hpp" 27 #include "../util/math.hpp" 28 #include "../image.hpp" 30 #ifndef PIC_DISABLE_EIGEN 32 #ifndef PIC_EIGEN_NOT_BUNDLED 33 #include "../externals/Eigen/Dense" 35 #include <Eigen/Dense> 42 #ifndef PIC_DISABLE_EIGEN 69 sample[0] = int(r * cosf(theta));
70 sample[1] = int(r * sinf(theta));
80 unsigned int n2 =
n * 2;
85 for(
unsigned int i = 0; i < n2; i += 2) {
98 unsigned int n =
sizeof(
unsigned int) * 8;
100 unsigned int ret = 0;
102 for(
unsigned int i = 0; i <
n; i++) {
103 if((
x & (1 << i)) == 0) {
121 unsigned int bits =
sizeof(
unsigned int) * 8;
122 unsigned int subBlock =
n / bits;
125 desc =
new unsigned int[subBlock];
130 for(
unsigned int i = 0; i < subBlock; i++) {
131 unsigned int value = 0;
133 for(
unsigned int j = 0; j < bits; j++) {
134 int cShifted = c * 2;
136 float *p_x_val = (*img)(x0 +
x[cShifted], y0 +
x[cShifted + 1]);
137 float *p_y_val = (*img)(x0 +
y[cShifted], y0 +
y[cShifted + 1]);
142 for(
int k = 0; k < img->
channels; k++) {
147 unsigned int ret = (p_x < p_y) ? 1 : 0;
170 m =
new std::mt19937(seed);
172 auto seed_time = std::chrono::system_clock::now().time_since_epoch().count();
173 m =
new std::mt19937(
int (seed_time));
177 this->sigma_sq = float(
S *
S) / 25.0f;
178 this->sigma_sq_2 = 2.0f * this->
sigma_sq;
212 if(!img->checkCoordinates(x0, y0)) {
216 return getAux(img, x0, y0,
x,
y, desc);
219 #ifndef PIC_DISABLE_EIGEN 227 std::vector< Eigen::Vector2f > &corners,
228 std::vector< uint* > &descs)
232 for(
unsigned int i = 0; i < corners.size(); i++) {
233 int x0 = int(corners[i][0]);
234 int y0 = int(corners[i][1]);
235 descs.push_back(
get(img, x0, y0, NULL));
245 return n / (
sizeof(
unsigned int) * 8);
257 if((fv0 == NULL) || (fv1 == NULL)) {
262 for(
uint i = 0; i < nfv; i++) {
unsigned int uint
Definition: base.hpp:23
BRIEFDescriptor(int S=32, int n=256, int seed=1)
BRIEFDescriptor.
Definition: brief_descriptor.hpp:167
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
int S
Definition: brief_descriptor.hpp:50
std::mt19937 * m
Definition: brief_descriptor.hpp:53
The BRIEFDescriptor class.
Definition: brief_descriptor.hpp:47
float sigma_sq
Definition: brief_descriptor.hpp:52
const float C_PI_2
Definition: math.hpp:52
void generateSamples(unsigned int n)
generateSamples
Definition: brief_descriptor.hpp:77
void release()
Release deallocates memory.
Definition: brief_descriptor.hpp:191
int * y
Definition: brief_descriptor.hpp:56
uint * getAux(Image *img, int x0, int y0, int *x, int *y, uint *desc=NULL)
getAux computes a descriptor at position (x0,y0) with size n.
Definition: brief_descriptor.hpp:119
~BRIEFDescriptor()
Definition: brief_descriptor.hpp:183
int * x
Definition: brief_descriptor.hpp:56
static uint match(uint *fv0, uint *fv1, uint nfv)
match matches two descriptors. Note: Higher scores means better matching.
Definition: brief_descriptor.hpp:255
The Image class stores an image as buffer of float.
Definition: image.hpp:60
void getAll(Image *img, std::vector< Eigen::Vector2f > &corners, std::vector< uint * > &descs)
getAll
Definition: brief_descriptor.hpp:226
float sigma_sq_2
Definition: brief_descriptor.hpp:52
Definition: bilateral_separation.hpp:25
unsigned int n
Definition: brief_descriptor.hpp:51
PIC_INLINE float getRandom(unsigned int n)
Random returns a number in [0, 2^32 - 1] to a float in [0, 1].
Definition: math.hpp:138
#define MAX(a, b)
Definition: math.hpp:73
int getDescriptorSize()
getDescriptorSize returns the descriptor size.
Definition: brief_descriptor.hpp:244
static unsigned int countZeros(unsigned int x)
countZeros
Definition: brief_descriptor.hpp:96
void generateSample(int *sample)
generateSample
Definition: brief_descriptor.hpp:62