@@ -172,6 +172,13 @@ void FeatureExtractor::computeViewJob(const FeatureExtractorViewJob& job, bool u
172
172
double pixelRatio = 1.0 ;
173
173
job.view ().getImage ().getDoubleMetadata ({" PixelAspectRatio" }, pixelRatio);
174
174
175
+ std::array<Vec2, 5 > shifts;
176
+ shifts[0 ] = Vec2 (-1 , 0 );
177
+ shifts[1 ] = Vec2 (1 , 0 );
178
+ shifts[2 ] = Vec2 (0 , -1 );
179
+ shifts[3 ] = Vec2 (0 , 1 );
180
+ shifts[4 ] = Vec2 (0 , 0 );
181
+
175
182
if (pixelRatio != 1.0 )
176
183
{
177
184
// Resample input image in order to work with square pixels
@@ -265,23 +272,30 @@ void FeatureExtractor::computeViewJob(const FeatureExtractorViewJob& job, bool u
265
272
for (size_t i = 0 , n = regions->RegionCount (); i != n; ++i)
266
273
{
267
274
const Vec2 position = regions->GetRegionPosition (i);
268
- const int x = int (position.x ());
269
- const int y = int (position.y ());
270
-
271
-
272
275
bool masked = false ;
273
276
274
277
// Check if point lies inside potential fisheye circle
275
278
if ((position - circleCenter).norm () > circleRadius)
276
279
{
277
280
masked = true ;
278
281
}
279
- // Check if the optional image mask tells us to ignore this coordinate
280
- else if (x < mask.width () && y < mask.height ())
282
+ else
281
283
{
282
- if ((mask (y, x) == 0 && !_maskInvert) || (mask (y, x) != 0 && _maskInvert))
284
+ const double scale = regions->Features ()[i].scale ();
285
+ // Check if the optional image mask tells us to ignore this coordinate
286
+ for (int idx = 0 ; idx < shifts.size (); idx++)
283
287
{
284
- masked = true ;
288
+ const Vec2 npos = position + scale * shifts[idx];
289
+ const int x = int (npos.x ());
290
+ const int y = int (npos.y ());
291
+
292
+ if (x >= 0 && y >= 0 && x < mask.width () && y < mask.height ())
293
+ {
294
+ if ((mask (y, x) == 0 && !_maskInvert) || (mask (y, x) != 0 && _maskInvert))
295
+ {
296
+ masked = true ;
297
+ }
298
+ }
285
299
}
286
300
}
287
301
0 commit comments