Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is orb running in plain mode instead of OpenCL implementation?

system information :

Ubunut 18.04

OpenCV4.0.1

OpenCL C 2.0 beignet 1.3

Device : Intel(R) HD Graphics Skylake ULT GT2

Hi, I'm trying to run Feature2D detection using ORB with detectAndCompute. first i set CV_OPENCL_RUN_VERBOSE to 1 to enable traces and re-compile OpenCV.

then i check if OpenCL is configurated can be used and if the default device is my graphical chipset

if (!cv::ocl::haveOpenCL())
  {
    return -1;
  }
  if(!cv::ocl::useOpenCL())
  {
    cv::ocl::setUseOpenCL(true);   
  }
  cv::ocl::Device d=cv::ocl::Device::getDefault();
  cout << "Device Name: " << d.name().c_str() << endl;
  cout << "available:         " << d.available() << endl;
  cout << "imageSupport:      " << d.imageSupport() << endl;
  cout << "OpenCL_C_Version:  " << d.OpenCL_C_Version() << endl;
  cout << "Use OpenCL:        " << cv::ocl::useOpenCL() << endl;
  cout << endl;

when i try a simple code,

 UMat m(2000,2000,CV_8UC3, Scalar(100,200,0));
 UMat r;
 GaussianBlur(m,r,Size(5,5),0);

it's ok, i get the following trace :

GaussianBlur: Plain implementation is running

ocl_sepFilter2D: OpenCL implementation is running

GaussianBlur: OpenCL implementation is running

it run on my chipset and on my cpu (so it seems to work's)

then i start feature detection :

 Ptr<Feature2D> detector=ORB::create(1500);
 UMat res;
 vector<KeyPoint> keypoints;
 detector->detectAndCompute(m,UMat(), keypoints,res);

i get the following log :
ocl::isOpenCLActivated() : 1 OCL_FORCE_CHECK(_image.isUMat() || _descriptors.isUMat()) : 1 _image.isUMat() : 1 _descriptors.isUMat() : 1 cvtColor: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running Use OpenCLFlag in computeKeyPoints : 1 FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running

All the function were executed in plain mode...

Why is this happen ? How may i fix it?

thank's

Why is orb running in plain mode instead of OpenCL implementation?

system information :

Ubunut 18.04

OpenCV4.0.1

OpenCL C 2.0 beignet 1.3

Device : Intel(R) HD Graphics Skylake ULT GT2

Hi, I'm trying to run Feature2D detection using ORB with detectAndCompute. first i set CV_OPENCL_RUN_VERBOSE to 1 to enable traces and re-compile OpenCV.

then i check if OpenCL is configurated can be used and if the default device is my graphical chipset

if (!cv::ocl::haveOpenCL())
  {
    return -1;
  }
  if(!cv::ocl::useOpenCL())
  {
    cv::ocl::setUseOpenCL(true);   
  }
  cv::ocl::Device d=cv::ocl::Device::getDefault();
  cout << "Device Name: " << d.name().c_str() << endl;
  cout << "available:         " << d.available() << endl;
  cout << "imageSupport:      " << d.imageSupport() << endl;
  cout << "OpenCL_C_Version:  " << d.OpenCL_C_Version() << endl;
  cout << "Use OpenCL:        " << cv::ocl::useOpenCL() << endl;
  cout << endl;

when i try a simple code,

 UMat m(2000,2000,CV_8UC3, Scalar(100,200,0));
 UMat r;
 GaussianBlur(m,r,Size(5,5),0);

it's ok, i get the following trace :

GaussianBlur: Plain implementation is running

ocl_sepFilter2D: OpenCL implementation is running

GaussianBlur: OpenCL implementation is running

it run on my chipset and on my cpu (so it seems to work's)

then i start feature detection :

 Ptr<Feature2D> detector=ORB::create(1500);
 UMat res;
 vector<KeyPoint> keypoints;
 detector->detectAndCompute(m,UMat(), keypoints,res);

i get the following log :
ocl::isOpenCLActivated() : 1 OCL_FORCE_CHECK(_image.isUMat() || _descriptors.isUMat()) : 1 _image.isUMat() : 1 _descriptors.isUMat() : 1 cvtColor: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running resize: Plain implementation is running copyMakeBorder: Plain implementation is running Use OpenCLFlag in computeKeyPoints : 1 FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running FAST: Plain implementation is running

All the function were executed in plain mode...

Why is this happen ? How may i fix it?

thank's

EDIT : I'm getting closer... after a long debbugin step, in find that in ORB Detect fct, it's impossible to launch FAST in OpenCL mode.

 for( level = 0; level < nlevels; level++ )
{
    int featuresNum = nfeaturesPerLevel[level];
    Mat img = imagePyramid(layerInfo[level]);
    Mat mask = maskPyramid.empty() ? Mat() : maskPyramid(layerInfo[level]);

    // Detect FAST features, 20 is a good threshold
    {
    Ptr<FastFeatureDetector> fd = FastFeatureDetector::create(fastThreshold, true);
    fd->detect(img, keypoints, mask);
    }

as you can see detect is launch with a Mat object. the worst is that uimagePyramid (UMat version of imagePyramid) exist (and is fill with imagePyramid earlier) but never used. So it's a bit desturbing, everybody said OpenCL ORB version work's weel but the detect fonction cannot use OpenCL.... What am I doing wrong??????

if i modify the code by explicitly setting call with UMat. FAST is launch in OpenCL mode

 for( level = 0; level < nlevels; level++ )
{
    int featuresNum = nfeaturesPerLevel[level];
    Mat img = imagePyramid(layerInfo[level]);
    Mat mask = maskPyramid.empty() ? Mat() : maskPyramid(layerInfo[level]);

    // Detect FAST features, 20 is a good threshold
    {
    Ptr<FastFeatureDetector> fd = FastFeatureDetector::create(fastThreshold, true);
    fd->detect(img.getUMat(AccessFlag::ACCESS_RW), keypoints, mask);
    }