Ask Your Question
0

resize in cuda from python.

asked 2019-10-25 13:36:33 -0600

llaborelli gravatar image

Hello, I am trying to use resize in cuda from python with 4.1.1 compiled with cuda. cv2.cuda.remap is already working.

sdLum is an image

    lumGPU0 = cv2.cuda_GpuMat()
    lumGPU0.upload(sdLum)
    lumGPU = cv2.cuda_GpuMat()
    cv2.cuda.resize(lumGPU0,lumGPU,0, imgHDX, imgHDY, interpolation=cv2.INTER_CUBIC)

I get this runtime error : TypeError: Expected Ptr<cv::umat> for argument '%s'

Has anybody succedeed in using cv2.cuda.resize ?

Thanks in advance.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2019-10-25 14:53:17 -0600

updated 2019-10-28 05:13:52 -0600

You need to pass in the correct arguments, to find these in the python interpreter you can type

help(cv2.cuda.resize)

or if you are in a jupyter notebook you can get these by using shift+tab, I have included the output from this for for cv2.cuda.resize function below

Docstring:
resize(src, dsize[, dst[, fx[, fy[, interpolation[, stream]]]]]) -> dst
.   @brief Resizes an image.
.   
.   @Param src Source image.
.   @Param dst Destination image with the same type as src . The size is dsize (when it is non-zero)
.   or the size is computed from src.size() , fx , and fy .
.   @Param dsize Destination image size. If it is zero, it is computed as:
.   \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f]
.   Either dsize or both fx and fy must be non-zero.
.   @Param fx Scale factor along the horizontal axis. If it is zero, it is computed as:
.   \f[\texttt{(double)dsize.width/src.cols}\f]
.   @Param fy Scale factor along the vertical axis. If it is zero, it is computed as:
.   \f[\texttt{(double)dsize.height/src.rows}\f]
.   @Param interpolation Interpolation method. INTER_NEAREST , INTER_LINEAR and INTER_CUBIC are
.   supported for now.
.   @Param stream Stream for the asynchronous version.
.   
.   @sa resize
Type:      builtin_function_or_method

You should therefore be able to resize with the following

cv2.cuda.resize(lumGPU0,(imgHDX,imgHDY),lumGPU,interpolation=cv2.INTER_CUBIC)

if you pre-initialize lumGPU, e.g.

lumGPU = cv2.cuda_GpuMat(imgHDY,imgHDX,lumGPU0.type())

otherwise you will need lumGPU to be the return value

lumGPU = cv2.cuda.resize(lumGPU0,(imgHDX,imgHDY),interpolation=cv2.INTER_CUBIC)
edit flag offensive delete link more
0

answered 2020-02-25 08:03:04 -0600

Imran B gravatar image

updated 2020-02-25 08:03:19 -0600

Return the value like this

lumGPU = cv2.cuda.resize(lumGPU0,(imgHDX,imgHDY),interpolation=cv2.INTER_CUBIC)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-25 13:36:33 -0600

Seen: 6,794 times

Last updated: Feb 25 '20