28 #if MRPT_HAS_SSE2 && MRPT_HAS_OPENCV 30 template <
bool Aligned>
36 size_t *ptr_feat_index_by_row;
37 if (out_feats_index_by_row)
39 out_feats_index_by_row->resize(I->height);
40 ptr_feat_index_by_row = &(*out_feats_index_by_row)[0];
43 ptr_feat_index_by_row = NULL;
46 const int w = I->width;
47 const int stride = 3*I->widthStep;
50 const __m128i barriers = _mm_set1_epi8((
uint8_t)barrier);
52 int xend = I->width - 3;
53 xend -= (I->width-3) % 16;
56 if (ptr_feat_index_by_row) {
57 *ptr_feat_index_by_row++ = corners.
size();
58 *ptr_feat_index_by_row++ = corners.
size();
59 *ptr_feat_index_by_row++ = corners.
size();
62 for(
int y=3;
y < I->height - 3;
y++)
64 if (ptr_feat_index_by_row)
65 *ptr_feat_index_by_row++=corners.
size();
67 for(
int x=3;
x < 16;
x++)
68 if(is_corner_9<Less>( (
const uint8_t*)I->imageData+I->widthStep*
y+
x, I->widthStep, barrier) || is_corner_9<Greater>((
const uint8_t*)I->imageData+I->widthStep*
y+
x, I->widthStep, barrier))
71 for(
int x=16;
x < xend;
x+=16)
76 const __m128i here = load_si128<Aligned>((
const __m128i*)(
p));
77 lo = _mm_subs_epu8(here, barriers);
78 hi = _mm_adds_epu8(barriers, here);
80 unsigned int ans_0, ans_8, possible;
82 __m128i top = load_si128<Aligned>((
const __m128i*)(
p-
stride));
83 __m128i bottom = load_si128<Aligned>((
const __m128i*)(
p+
stride));
87 possible = ans_0 | ans_8;
92 unsigned int ans_15, ans_1;
94 __m128i
a = _mm_loadu_si128((
const __m128i*)(
p-1-
stride));
95 __m128i
c = _mm_insert_epi16(_mm_srli_si128(
a,2), *(
const unsigned short*)(
p+15-
stride), 7);
98 possible &= ans_8 | (ans_15 & ans_1);
103 unsigned int ans_9, ans_7;
105 __m128i d = _mm_loadu_si128((
const __m128i*)(
p-1+
stride));
106 __m128i f = _mm_insert_epi16(_mm_srli_si128(d,2), *(
const unsigned short*)(
p+15+
stride), 7);
109 possible &= ans_9 | (ans_0 & ans_1);
110 possible &= ans_7 | (ans_15 & ans_0);
115 unsigned int ans_12, ans_4;
117 __m128i left = _mm_loadu_si128((
const __m128i*)(
p-3));
118 __m128i right = _mm_loadu_si128((
const __m128i*)(
p+3));
121 possible &= ans_12 | (ans_4 & (ans_1 | ans_7));
122 possible &= ans_4 | (ans_12 & (ans_9 | ans_15));
127 unsigned int ans_14, ans_6;
129 __m128i ul = _mm_loadu_si128((
const __m128i*)(
p-2-2*
w));
130 __m128i lr = _mm_loadu_si128((
const __m128i*)(
p+2+2*
w));
134 const unsigned int ans_6_7 = ans_6 & ans_7;
135 possible &= ans_14 | (ans_6_7 & (ans_4 | (ans_8 & ans_9)));
136 possible &= ans_1 | (ans_6_7) | ans_12;
139 const unsigned int ans_14_15 = ans_14 & ans_15;
140 possible &= ans_6 | (ans_14_15 & (ans_12 | (ans_0 & ans_1)));
141 possible &= ans_9 | (ans_14_15) | ans_4;
147 unsigned int ans_10, ans_2;
149 __m128i ll = _mm_loadu_si128((
const __m128i*)(
p-2+2*
w));
150 __m128i ur = _mm_loadu_si128((
const __m128i*)(
p+2-2*
w));
154 const unsigned int ans_1_2 = ans_1 & ans_2;
155 possible &= ans_10 | (ans_1_2 & ((ans_0 & ans_15) | ans_4));
156 possible &= ans_12 | (ans_1_2) | (ans_6 & ans_7);
159 const unsigned int ans_9_10 = ans_9 & ans_10;
160 possible &= ans_2 | (ans_9_10 & ((ans_7 & ans_8) | ans_12));
161 possible &= ans_4 | (ans_9_10) | (ans_14 & ans_15);
163 possible &= ans_8 | ans_14 | ans_2;
164 possible &= ans_0 | ans_10 | ans_6;
169 unsigned int ans_13, ans_5;
171 __m128i
g = _mm_loadu_si128((
const __m128i*)(
p-3-
w));
172 __m128i l = _mm_loadu_si128((
const __m128i*)(
p+3+
w));
175 const unsigned int ans_15_0 = ans_15 & ans_0;
176 const unsigned int ans_7_8 = ans_7 & ans_8;
178 const unsigned int ans_12_13 = ans_12 & ans_13;
179 possible &= ans_5 | (ans_12_13 & ans_14 & ((ans_15_0) | ans_10));
180 possible &= ans_7 | (ans_1 & ans_2) | (ans_12_13);
181 possible &= ans_2 | (ans_12_13) | (ans_7_8);
184 const unsigned int ans_4_5 = ans_4 & ans_5;
185 const unsigned int ans_9_10 = ans_9 & ans_10;
186 possible &= ans_13 | (ans_4_5 & ans_6 & ((ans_7_8) | ans_2));
187 possible &= ans_15 | (ans_4_5) | (ans_9_10);
188 possible &= ans_10 | (ans_4_5) | (ans_15_0);
189 possible &= ans_15 | (ans_9_10) | (ans_4_5);
192 possible &= ans_8 | (ans_13 & ans_14) | ans_2;
193 possible &= ans_0 | (ans_5 & ans_6) | ans_10;
199 unsigned int ans_11, ans_3;
201 __m128i ii = _mm_loadu_si128((
const __m128i*)(
p-3+
w));
202 __m128i jj = _mm_loadu_si128((
const __m128i*)(
p+3-
w));
206 const unsigned int ans_2_3 = ans_2 & ans_3;
207 possible &= ans_11 | (ans_2_3 & ans_4 & ((ans_0 & ans_1) | (ans_5 & ans_6)));
208 possible &= ans_13 | (ans_7 & ans_8) | (ans_2_3);
209 possible &= ans_8 | (ans_2_3) | (ans_13 & ans_14);
212 const unsigned int ans_11_12 = ans_11 & ans_12;
213 possible &= ans_3 | (ans_10 & ans_11_12 & ((ans_8 & ans_9) | (ans_13 & ans_14)));
214 possible &= ans_1 | (ans_11_12) | (ans_6 & ans_7);
215 possible &= ans_6 | (ans_0 & ans_1) | (ans_11_12);
218 const unsigned int ans_3_4 = ans_3 & ans_4;
219 possible &= ans_9 | (ans_3_4) | (ans_14 & ans_15);
220 possible &= ans_14 | (ans_8 & ans_9) | (ans_3_4);
223 const unsigned int ans_10_11 = ans_10 & ans_11;
224 possible &= ans_5 | (ans_15 & ans_0) | (ans_10_11);
225 possible &= ans_0 | (ans_10_11) | (ans_5 & ans_6);
232 possible |= (possible >> 16);
236 if(possible & (1<< 0))
238 if(possible & (1<< 1))
240 if(possible & (1<< 2))
242 if(possible & (1<< 3))
244 if(possible & (1<< 4))
246 if(possible & (1<< 5))
248 if(possible & (1<< 6))
250 if(possible & (1<< 7))
255 if(possible & (1<< 8))
257 if(possible & (1<< 9))
259 if(possible & (1<<10))
261 if(possible & (1<<11))
263 if(possible & (1<<12))
265 if(possible & (1<<13))
267 if(possible & (1<<14))
269 if(possible & (1<<15))
274 for(
int x=xend;
x < I->width - 3;
x++)
275 if(is_corner_9<Less>((
const uint8_t*)I->imageData+I->widthStep*
y+
x, I->widthStep, barrier) || is_corner_9<Greater>((
const uint8_t*)I->imageData+I->widthStep*
y+
x, I->widthStep, barrier))
280 if (ptr_feat_index_by_row) {
281 *ptr_feat_index_by_row++ = corners.size();
282 *ptr_feat_index_by_row++ = corners.size();
283 *ptr_feat_index_by_row++ = corners.size();
289 #endif // MRPT_HAS_SSE2 && MRPT_HAS_OPENCV 300 else if (I->width < 22 || I->height < 7)
305 faster_corner_detect_9<true>(I, corners, barrier,octave,out_feats_index_by_row);
307 faster_corner_detect_9<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 push_back_fast(const FEATURE &f)
void fast_corner_detect_9(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
#define CHECK_BARRIER(lo, hi, other, flags)
GLubyte GLubyte GLubyte GLubyte w
void fast_corner_detect_plain_9(const IplImage *i, TSimpleFeatureList &corners, int b, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void faster_corner_detect_9(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLubyte GLubyte GLubyte a