CV-CUDA
CV-CUDA copied to clipboard
[QUESTION] : Must the shape of the output tensor for warp_affine_into be same with its input tensor?
In opencv's warpAffine,we can specify the size of the output image through the dsize parameter. In cvcuda,if I want specify the size of the output image, I tried to specify the output tensor's shape,I want to know if it is correct approach. The following code snippet, I want to affine from a large image to obtain a small image:
# opencv
warped_img_cv2 = cv2.warpAffine(image, mat, (256, 256), borderValue=0.0)
#cvcuda
inverted_mat = cv2.invertAffineTransform(mat)
warped_img_cvcuda = cvcuda.Tensor((256, 256, 3), np.uint8,"HWC")
cvcuda.warp_affine_into(
dst=nvcv_img256,
src=image,
xform=inverted_mat,
flags=cvcuda.Interp.LINEAR,
border_mode=cvcuda.Border.CONSTANT,
border_value=[0])
same question
兄弟,我决定再接一个constomcrop,自己裁剪
用warpaffineinfo这个函数可以搞定size问题,我有空的时候贴清晰的代码上来
You have to set dst dimension as you desire. This work for me.
dst = torch.empty((h, w, c), device='cuda').to(torch.uint8)
dst = cvcuda.as_tensor(dst, 'HWC')
用warpaffineinfo这个函数可以搞定size问题,我有空的时候贴清晰的代码上来
老哥,可以瞅瞅你的代码不,我试了个不同尺寸的输出,会报内存对齐问题