Ask Your Question

Revision history [back]

How to set up opencl in opencv for android

hi,everyone, I want to use opencl module in opencv in my android application. I use native C++ and the version of opencv is 3.1.0. I first run the following code in win32 console application on my computer, the opencl module works, but when I directly use this code on android platform, I find that "haveOpenCL" return 0. The question is:

  • How can opencv find the openCL lib path, for example, the path of libopenCL.so in my android device is

/vendor/lib/libOpenCL.so

Where can I set this lib path in my program?

  • Is any tutorial for building opencl module on opencv for android?

Any suggestions are welcome!

#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>


using namespace cv;
using namespace std;
int main(int argc, char** argv)
{

cv::ocl::setUseOpenCL(true);
cout << cv::ocl::haveOpenCL() << endl;
if (cv::ocl::haveOpenCL())
{
cout << "OpenCL IS avaiable ..." << endl;
//return 0;
}

UMat img;
img = imread("test.jpg").
getUMat(ACCESS_READ);

UMat result;
cv::Mat H = cv::Mat::eye(3, 3, CV_64FC1);

for (int i=0;i<800;i++)
{
warpPerspective(img, result, H, img.size());
}

return 0;
}