Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFMatcher (OpenCL implementation) on ARM Mali T764 #11503

Open
GerardWalsh opened this issue May 11, 2018 · 0 comments
Open

BFMatcher (OpenCL implementation) on ARM Mali T764 #11503

GerardWalsh opened this issue May 11, 2018 · 0 comments

Comments

@GerardWalsh
Copy link

GerardWalsh commented May 11, 2018

System information

OpenCV => 3.4
Operating System / Platform => TinkerOS latest
Compiler => g++
Hardware platform => Tinker Board 2GB

Detailed description

I have run into a similar problem as this question when and trying to use the TAPI of OpenCV with the goal of using the GPU on the ASUS Tinkerboard. How does one change the local work size for a particular function?

In my case I'm trying to implement

#include <opencv2/features2d.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>
#include <vector>
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

void print_ocl_device_name() {
    vector<ocl::PlatformInfo> platforms;
    ocl::getPlatfomsInfo(platforms);

    for (size_t i = 0; i < platforms.size(); i++) {
        const cv::ocl::PlatformInfo* platform = &platforms[i];
        cout << "Platform Name: " << platform->name().c_str() << "\n";

        for (int j = 0; j < platform->deviceNumber(); j++) {
            cv::ocl::Device current_device;
            platform->getDevice(current_device, j);
            int deviceType = current_device.type();
            cout << "Device " << j << ": " << current_device.name() << "\n";
        }
    }

    ocl::Device default_device = ocl::Device::getDefault();
    cout << "Used device: " << default_device.name() << "\n";
}

int main(void) {
    print_ocl_device_name();

    RNG r(239);
    Mat desc1(5100, 64, CV_32F);
    Mat desc2(5046, 64, CV_32F);
    r.fill(desc1, RNG::UNIFORM, Scalar::all(0.0), Scalar::all(1.0));
    r.fill(desc2, RNG::UNIFORM, Scalar::all(0.0), Scalar::all(1.0));

    for (int i = 0; i < 1000 * 1000; i++) {
        BFMatcher matcher(NORM_L2);

        UMat udesc1, udesc2;
        desc1.copyTo(udesc1);
        desc2.copyTo(udesc2);
        vector< vector<DMatch> > nn_matches;

        matcher.knnMatch(udesc1, udesc2, nn_matches, 2);

        printf("%d\n", i);
    }

    return 0;
}

and the problem, clEnqueueNDRangeKernel' failed with error 'out of resources' (-5), occurs when I call the particular line matcher.knnMatch(). I navigated to /modules/src/matchers.cpp and changed the int block_size to 4, as clinfo says the preferred work size is 4. Recompiled the code with g++ but same error was thrown: OpenCL error CL_OUT_OF_RESOURCES (-5) during call: clEnqueueNDRangeKernel('BruteForceMatch_knnMatch', dims=2, globalsize=480x16x1, localsize=16x16x1) sync=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants