@@ -45,6 +45,7 @@ The references are:
45
45
#include " fast_score.hpp"
46
46
#include " opencl_kernels_features2d.hpp"
47
47
48
+ #include " opencv2/core/openvx/ovx_defs.hpp"
48
49
#if defined _MSC_VER
49
50
# pragma warning( disable : 4127)
50
51
#endif
@@ -329,6 +330,67 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
329
330
}
330
331
#endif
331
332
333
+
334
+ #ifdef HAVE_OPENVX
335
+ static bool openvx_FAST (InputArray _img, std::vector<KeyPoint>& keypoints,
336
+ int _threshold, bool nonmaxSuppression, int type)
337
+ {
338
+ using namespace ivx ;
339
+
340
+ // Nonmax suppression is done differently in OpenCV than in OpenVX
341
+ // 9/16 is the only supported mode in OpenVX
342
+ if (nonmaxSuppression || type != FastFeatureDetector::TYPE_9_16)
343
+ return false ;
344
+
345
+ Mat imgMat = _img.getMat ();
346
+ if (imgMat.empty () || imgMat.type () != CV_8UC1)
347
+ return false ;
348
+
349
+ try
350
+ {
351
+ Context context = Context::create ();
352
+ Image img = Image::createFromHandle (context, Image::matTypeToFormat (imgMat.type ()),
353
+ Image::createAddressing (imgMat), (void *)imgMat.data );
354
+ ivx::Scalar threshold = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, _threshold);
355
+ vx_size capacity = imgMat.cols * imgMat.rows ;
356
+ Array corners = Array::create (context, VX_TYPE_KEYPOINT, capacity);
357
+
358
+ ivx::Scalar numCorners = ivx::Scalar::create<VX_TYPE_SIZE>(context, 0 );
359
+
360
+ IVX_CHECK_STATUS (vxuFastCorners (context, img, threshold, (vx_bool)nonmaxSuppression, corners, numCorners));
361
+
362
+ size_t nPoints = numCorners.getValue <vx_size>();
363
+ keypoints.clear (); keypoints.reserve (nPoints);
364
+ std::vector<vx_keypoint_t > vxCorners;
365
+ corners.copyTo (vxCorners);
366
+ for (size_t i = 0 ; i < nPoints; i++)
367
+ {
368
+ vx_keypoint_t kp = vxCorners[i];
369
+ // if nonmaxSuppression is false, kp.strength is undefined
370
+ keypoints.push_back (KeyPoint ((float )kp.x , (float )kp.y , 7 .f , -1 , kp.strength ));
371
+ }
372
+
373
+ #ifdef VX_VERSION_1_1
374
+ // we should take user memory back before release
375
+ // (it's not done automatically according to standard)
376
+ img.swapHandle ();
377
+ #endif
378
+ }
379
+ catch (RuntimeError & e)
380
+ {
381
+ VX_DbgThrow (e.what ());
382
+ }
383
+ catch (WrapperError & e)
384
+ {
385
+ VX_DbgThrow (e.what ());
386
+ }
387
+
388
+ return true ;
389
+ }
390
+
391
+ #endif
392
+
393
+
332
394
void FAST (InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
333
395
{
334
396
CV_INSTRUMENT_REGION ()
@@ -342,6 +404,9 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
342
404
}
343
405
#endif
344
406
407
+ CV_OVX_RUN (true ,
408
+ openvx_FAST (_img, keypoints, threshold, nonmax_suppression, type))
409
+
345
410
switch (type) {
346
411
case FastFeatureDetector::TYPE_5_8:
347
412
FAST_t<8 >(_img, keypoints, threshold, nonmax_suppression);
0 commit comments