I'm trying to crop Image using cv2.cuda and I tried cuda_gpumat.adjustroi()
Hi all,
I'm trying to crop image using cv2.cuda. I done crop with cv2.UMat
With UMat
cropped = cv2.UMat(p, [minX, maxX], [minY, maxY])
With cv2.cuda_gpumat.adjustroi()
cropped = p.adjustROI(minX, maxX, minY, maxY)
My Code :
import cv2
#im=cv2.imread('Remap.png')
im = (1024,1024,3)
print(im.shape)
a=(im.shape[0]*2,im.shape[1]*2)
gpu = cv2.cuda_GpuMat()
gpu.upload(im)
b=cv2.cuda.resize(gpu,a)
print(b.size())
maxX=500
maxY=500
minX = 500
minY= 500
b.adjustROI(maxY,minY, minX, maxX)
print("Adjust ROI : ",b.size())
cropped = cv2.UMat(a, [minX, maxX], [minY, maxY])
print("Umat : ",cropped.size())
and the problem is ?
You got wrongly. The 500( maxX and maxY) is too far but depending on sizes of image.
And your problem doesn't showing an error
b.adjustROI(maxY,minY, minX, maxX)
Do not used multiply operation
a=(im.shape[0]*2,im.shape[1]*2)
. You're setting 2048 x 2048.I'm trying to resize it and then crop it.
Does the answer help resizing with cuda and this too
Does this work?
to:
Then:
to