1 | initial version |
Because of the way the python bindings are generated, currently all CUDA functions (except cudacodec.nextFrame()
) require at least one argument to be of type GpuMat()
. If not the bindings will assume that the input (in your case raw) is a Mat, hence the error.
Anyway they are still a work in progress but in the meantime just pass in the dst array as shown below
sz = (1920,1080,3)
npMat = (np.random.random(sz)*255).astype(np.float)
cuMat = cv.cuda_GpuMat(npMat)
cuMat8U = cv.cuda_GpuMat(sz[:2],cv.CV_8UC3)
alpha = 50
beta = 45
b = cuMat.convertTo(cv.CV_8U,alpha,beta,cv.cuda.Stream_Null(),cuMat8U)
Note: If you don't pass in the dst arrays to OpenCV python functions, the functions will allocate a new array on every invocation. Therefore you probably always want to pre-allocate the dst arrays to avoid this allocation cost.
2 | No.2 Revision |
Because of the way the python bindings are generated, currently all CUDA functions (except cudacodec.nextFrame()
) require at least one argument to be of type GpuMat()
. If not the bindings will assume that the input (in your case raw) is a Mat, hence the error.
Anyway they are still a work in progress but in the meantime just pass in the dst array as shown below
sz = (1920,1080,3)
(1080,1920,3)
npMat = (np.random.random(sz)*255).astype(np.float)
cuMat = cv.cuda_GpuMat(npMat)
cuMat8U = cv.cuda_GpuMat(sz[:2],cv.CV_8UC3)
cv.cuda_GpuMat(sz[0],sz[1],cv.CV_8UC3)
alpha = 50
beta = 45
b = cuMat.convertTo(cv.CV_8U,alpha,beta,cv.cuda.Stream_Null(),cuMat8U)
Note: If you don't pass in the dst arrays to OpenCV python functions, the functions will allocate a new array on every invocation. Therefore you probably always want to pre-allocate the dst arrays to avoid this allocation cost.