Reputation: 3868
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?
Upvotes: 2
Views: 2883
Reputation: 75
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)
Upvotes: 4