I am very newbie on this topic and I need same simplified answers. I am trying to concat/merge images together in GPU by using cv2.cuda. I have understood that space needs to be allocate for new, merged image and then tiles can be placed by using CopyTo-function. I am not sure about the syntax how to do this correctly. Example with source 4 pics to be merged to 2 rows and two columns below. But this do not work like this. Can someone help with syntax or propose alternative method?
import cv2
gpu_image01 = cv2.cuda_GpuMat()
gpu_image02 = cv2.cuda_GpuMat()
gpu_image03 = cv2.cuda_GpuMat()
gpu_image04 = cv2.cuda_GpuMat()
image01 = cv2.imread('img1.png')
image02 = cv2.imread('img2.png')
image03 = cv2.imread('img3.png')
image04 = cv2.imread('img4.png')
gpu_image01.upload(image01)
gpu_image02.upload(image02)
gpu_image03.upload(image03)
gpu_image04.upload(image04)
new_image = cv2.cuda_GpuMat(2, 2)
new_image.copyTo(gpu_image01,(0,0))
new_image.copyTo(gpu_image02,(0,1))
new_image.copyTo(gpu_image03,(1,0))
new_image.copyTo(gpu_image04,(1,1))
result = new_image.download()
Error code from the provided example above:
TypeError: Expected Ptr<cv::cuda::GpuMat::Allocator> for argument 'allocator'
I have tried different ways without success. For example, if not try to specify matrix size, I get:
TypeError: Expected Ptr<cv::UMat> for argument 'mask'