2

OpenCV 3.0 now uses T-API (Transparent API), see:

https://github.com/Itseez/opencv/wiki/Opencv3

it does not need to specify cv::ocl::Canny, cv::gpu::Canny etc; cv::Canny just works on both CPU and GPU.

And this is an example:

http://www.learnopencv.com/opencv-transparent-api/

My question is:

This works with OpenCV with Python? Can anyone give me an example?

Rui Martins
  • 3,337
  • 5
  • 35
  • 40
  • 1
    I've already posted the same question a while ago. You can see it here: http://stackoverflow.com/questions/31990646/using-opencl-accelerated-functions-with-opencv3-in-python/32052464#32052464 – Arqu Nov 09 '15 at 10:19

1 Answers1

4

In C++ to use OpenCL implementations of methods - you should pass UMat instead of Mat, when you call method from Python with numpy array or so - you effectively call it with Mat as argument.

UMat was adopted for Python bindings since OpenCV 3.2. Now you can pass cv2.UMat(someNumpyMat) to function just like in C++.

Example:

ps, descs_umat = orb.detectAndCompute(cv2.UMat(img), None)
descs = descs_umat.get()
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
res = matcher.match(descs_umat, descs_umat)
Polar Nick
  • 75
  • 7