UMAT cannot invoke GPU

Hi experts,

I use UMat to do picture operation via Android studio NDK and C++ language, but looks cannot invoke GPU.
if I switch to Android studio NDK java, looks it can.
for C++, code as below:
cv::Mat originalImage;
cv::UMat uimage;
originalImage = cv::imread(“/data/local/tmp/pic/pic5.jpg”);
cv::resize(uimage, uimage, cv::Size(640, 480), fx, fy, cv::INTER_LINEAR);

for Java, it’s similar. read picture via Mat, then copyto UMat, and do operations.

can anyone provide some suggestions?

I don’t know how to do it on Android Studio NDK, but I know how to do it on SWISchip RK3568, first you need to manually open something like this
Secondly, we should pay attention to whether the image we read is double (CV_64F) type data UMat, UMat matrix or GPU does not support double (CV_64F) type data

Hi Faning,
Thanks a lot for your reply.
my chip is Qualcomm6490.
it can trigger it via java code, but c++ doesn’t work.
and I don’t know how to debug it, like how to enable log and get it, even there has log module, but it doesn’t help.

I guess it’s caused by OpenCL nested in OpenCV, the OpenCL doesn’t support.
but only log can confirm it.

even I set as below, but OpenCL still not available.

__android_log_print(ANDROID_LOG_INFO, "OpenCV", "OpenCL is %s",(cv::ocl::haveOpenCL() ? "available" : "not available"));

Another point I forgot to mention to you is that not all OpenCV functions support OpenCl, the support is based on InputArray or OutputArray, for example, the input and output are Array
void filter2D(InputArray src,OutputArray dst,int ddepth,InputArray kernel,
Point anchor=Point(-1, -1),double delta=0, int borderType=BORDER_DEFAULT )
For example, not supported: Input specifies Mat
void calcHist( const Mat* images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false );

1 Like

If OpenCL is available, print “available”; Otherwise print “not available”.
If your device prints “not available”, which means the name does not support OpenCl, it may not have a GPU

but very strange, if using java code, it can trigger it.
java code is much more simple, just add implementation in AndroidManifest.xml file. like:


c++ code, I download opencv sdk from website, and compile the static library in.
but still doesn’t work.
I guess it’s caused by OpenCL module nested in OpenCV

It’s possible. I’ve just been exposed to this area and gained more knowledge. Thank you