1 | initial version |
Nice spot by @supra56. CUDA looks to be installed properly, you are just passing the wrong arguments and not using autocomplete for function names.
GpuMat should be working fine, you just have a typo (always best to use autocomplete), it should be
cv2.cuda_GpuMat()
not
cv2.cuda_GpuMAT()
I think the second problem is that you are passing a numpy array instead of a GpuMat to resize. Some cuda functions may accept numpy arrays but I would advise against it and always pass GpuMat unless the function explicitly requires a numpy array. All that said all the below should work
cuMat = cv2.cuda_GpuMat(npMat)
q = cv2.cuda.resize(cuMat,dsize=(100,100))
or
q=cv2.cuda.resize(cv2.cuda_GpuMat(npMat),dsize=(100,100))
or
q = cv2.cuda_GpuMat((100,100),cuMat.type())
cv2.cuda.resize(cv2.cuda_GpuMat(npMat),(100,100),q)
I would suggest the last one because it avoids allocating the return matrix on each invocation, so it will be much much faster, which you can verify by comparing
%timeit cv2.cuda.resize(cuMat,(100,100))
%timeit cv2.cuda.resize(cuMat,(100,100),q)
2 | No.2 Revision |
Nice spot by @supra56. CUDA looks to be installed properly, you are just passing the wrong arguments and not using autocomplete for function names.
GpuMat should be working fine, you just have a typo (always best to use autocomplete), it should be
cv2.cuda_GpuMat()
not
cv2.cuda_GpuMAT()
I think the second problem is that you are passing a numpy array instead of a GpuMat to resize. Some cuda functions may accept numpy arrays but I would advise against it and always pass GpuMat unless the function explicitly requires a numpy array. All that said all the below should work
cuMat = cv2.cuda_GpuMat(npMat)
q = cv2.cuda.resize(cuMat,dsize=(100,100))
or
q=cv2.cuda.resize(cv2.cuda_GpuMat(npMat),dsize=(100,100))
or
q = cv2.cuda_GpuMat((100,100),cuMat.type())
cv2.cuda.resize(cv2.cuda_GpuMat(npMat),(100,100),q)
cv2.cuda.resize(cuMat,(100,100),q)
I would suggest the last one because it avoids allocating the return matrix on each invocation, so it will be much much faster, which you can verify by comparing
%timeit cv2.cuda.resize(cuMat,(100,100))
%timeit cv2.cuda.resize(cuMat,(100,100),q)