I'm experimenting with T-Api of opencv python. Currently I'm trying to convert a normal RGB image to gray scale and save it with T-Api enabled. Here's the snippet
import cv2
import dlib
im = cv2.UMat(cv2.imread('input.png',1))
print(im)
imMat = cv2.UMat(im)
gray = cv2.cvtColor(imMat,cv2.COLOR_BGR2GRAY)
cv2.imwrite('gray.png',gray)
The output is as follows along with the error
<cv2.UMat object at 0x7fd1e400e378>
<cv2.UMat object at 0x7fc97d0ec390>
Segmentation fault (core dumped)
I have tried this before the above operations
cv2.ocl.setUseOpenCL(True)
print(cv2.ocl.haveOpenCL())
The above print statement is outputting false, I was thinking I need to compile by opencv with OpenCL support inorder for cv2.UMat to work but i'm able to print out both im outputs. I copied the code from this example, it seems to work fine
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();
Where exactly am I going wrong?