30 template <
class C>
static inline void eval(
unsigned int three,
const uint8_t*
p,
const int w,
const int barrier, C& corners) {
33 if (three & (BIT << 16)) {
34 if (is_corner_12<Greater>(
p,
w, barrier))
37 if (is_corner_12<Less>(
p,
w, barrier))
47 template <
class C>
static inline void eval(
unsigned int,
const uint8_t* ,
const int ,
const int , C& ) {}
50 template <
int CHUNKS,
class C>
inline void process_16(
unsigned int three,
const uint8_t*
p,
const int w,
const int barrier, C& corners)
52 three |= (three >> 16);
53 const int BITS = 16/CHUNKS;
54 const int mask = ((1<<BITS)-1);
55 for (
int i=0; i<CHUNKS; ++i) {
64 #if MRPT_HAS_SSE2 && MRPT_HAS_OPENCV 66 template <
bool Aligned>
72 size_t *ptr_feat_index_by_row, *ptr_feat_index_end;
73 if (out_feats_index_by_row)
75 out_feats_index_by_row->resize(I->height);
76 ptr_feat_index_by_row = &(*out_feats_index_by_row)[0];
77 ptr_feat_index_end = ptr_feat_index_by_row+out_feats_index_by_row->size();
80 ptr_feat_index_by_row = NULL;
81 ptr_feat_index_end=NULL;
84 const int w = I->width;
85 const int stride = 3*I->widthStep;
86 typedef std::list<const uint8_t*> Passed;
92 const __m128i barriers = _mm_set1_epi8((
uint8_t)barrier);
94 for (
int i=3; i<I->height-3; ++i) {
96 for (
int j=0; j<
w/16; ++j,
p+=16) {
99 const __m128i here = load_si128<Aligned>((
const __m128i*)(
p));
100 lo = _mm_subs_epu8(here, barriers);
101 hi = _mm_adds_epu8(barriers, here);
103 const __m128i above = load_si128<Aligned>((
const __m128i*)(
p-
stride));
104 const __m128i below = load_si128<Aligned>((
const __m128i*)(
p+
stride));
105 unsigned int up_flags, down_flags;
108 const unsigned int either_ud = up_flags | down_flags;
110 unsigned int left_flags;
112 const __m128i other = _mm_loadu_si128((
const __m128i*)(
p-3));
115 const unsigned int both_ud = up_flags & down_flags;
116 if (both_ud | (either_ud&left_flags)) {
117 unsigned int right_flags;
119 const __m128i other = _mm_loadu_si128((
const __m128i*)(
p+3));
122 const unsigned int at_least_three = (either_ud & (left_flags & right_flags)) | (both_ud & (left_flags | right_flags));
123 if (at_least_three) {
124 process_16<4>(at_least_three,
p,
w, barrier, passed);
131 for(
int j=(
w/16) * 16; j <
w-3; j++,
p++)
133 int cb = *
p + barrier;
134 int c_b = *
p - barrier;
138 if(!num_above && !num_below)
142 num_above+=
p[-3] > cb;
143 num_below+=
p[-3] < c_b;
148 num_above +=
p[3] > cb;
152 if((num_above&1) && is_corner_12<Greater>(
p,
w, barrier))
155 else if(num_below & 2)
158 num_below +=
p[3] < c_b;
161 if((num_below&1) && is_corner_12<Less>(
p,
w, barrier))
170 if (ptr_feat_index_by_row) {
171 *ptr_feat_index_by_row++ = corners.
size();
172 *ptr_feat_index_by_row++ = corners.
size();
173 *ptr_feat_index_by_row++ = corners.
size();
178 const uint8_t* row_start = (
const uint8_t*)I->imageData + I->widthStep*3;
183 if (ptr_feat_index_by_row)
184 *ptr_feat_index_by_row++=corners.
size();
186 row_start= (
const uint8_t*)I->imageData + I->widthStep*(++
row);
189 int x = *it - row_start;
190 if (
x > 2 &&
x <
w-3)
195 if (ptr_feat_index_by_row) {
196 *ptr_feat_index_by_row++ = corners.
size();
197 *ptr_feat_index_by_row++ = corners.
size();
198 *ptr_feat_index_by_row++ = corners.
size();
199 ASSERT_(ptr_feat_index_by_row==ptr_feat_index_end)
205 #endif // MRPT_HAS_SSE2 && MRPT_HAS_OPENCV 217 else if (I->width < 22 || I->height < 7)
222 faster_corner_detect_12<true>(I, corners, barrier, octave,out_feats_index_by_row);
224 faster_corner_detect_12<false>(I, corners, barrier, octave,out_feats_index_by_row);
bool is_aligned< 16 >(const void *ptr)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void fast_corner_detect_12(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void fast_corner_detect_plain_12(const IplImage *i, TSimpleFeatureList &corners, int b, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void push_back_fast(const FEATURE &f)
static void eval(unsigned int three, const uint8_t *p, const int w, const int barrier, C &corners)
#define CHECK_BARRIER(lo, hi, other, flags)
GLubyte GLubyte GLubyte GLubyte w
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
static void eval(unsigned int, const uint8_t *, const int, const int, C &)
GLenum GLenum GLvoid * row
void faster_corner_detect_12(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void process_16(unsigned int three, const uint8_t *p, const int w, const int barrier, C &corners)