Using OpenCL accelerated functions with OpenCV3 in Python

后端 未结 3 891
小蘑菇
小蘑菇 2021-01-02 08:28

OpenCV3 introduced its T-API (Transparent API) which gives the user the possibility to use functions which are GPU (or other OpenCL enabled device) accelerated, I\'m struggl

3条回答
  •  -上瘾入骨i
    2021-01-02 09:09

    The Transparent API is supported in OpenCV 3.2 and above. Here is an example code.

    import cv2
    
    img = cv2.UMat(cv2.imread("image.jpg", cv2.IMREAD_COLOR))
    imgUMat = cv2.UMat(img)
    gray = cv2.cvtColor(imgUMat, cv2.COLOR_BGR2GRAY)
    gray = cv2.GaussianBlur(gray, (7, 7), 1.5)
    gray = cv2.Canny(gray, 0, 50)
    
    cv2.imshow("edges", gray)
    cv2.waitKey();
    

    More details can be found at OpenCV Transparent API

提交回复
热议问题