title: How to fix "TypeError: Expected Ptr<cv::UMat> for argument '%s'"
body: <p>I'm writing codes to accelerate my program using CUDA, but I got a tricky error. I have no idea about it.My environment is OpenCV 4.1.1, python 3.6.
  Here is my code.</p>
  
  <p>I define a function to rotate the img,</p>
  
  <pre><code>def rotate(img, angle):
      '''
      '''    
      if len(img.shape) == 3:
          (rows, cols, channels) = img.shape
          out_size = (cols, rows, channels)
      else:
          (rows, cols) = img.shape
          out_size = (cols, rows)
  
      if angle == 0:
          dst = img
  
      else:
          # img_gpu = cv2.cuda_GpuMat()
          img_gpu = cv2.cuda_GpuMat()
          out_gpu = cv2.cuda_GpuMat()
  #         M_gpu = cv2.cuda_GpuMat()
  #         out_size_gpu = cv2.cuda_GpuMat()
  #         border_value_gpu = cv2.cuda_GpuMat()
  
          m = cv2.getRotationMatrix2D((cols/2, rows/2), angle, 1) 
          img_gpu.upload(img)
  #         M_gpu.upload(M)
  #         out_size_gpu.upload((12000, 6000))
  #         border_value_gpu.upload((0, 0, 0))
          cols_gpu = cv2.cuda_GpuMat()
          rows_gpu = cv2.cuda_GpuMat()
          cols_gpu.upload(cols)
          rows_gpu.upload(rows)
  
          print(type(img))
          print(img.shape)
          (row,col) = img.shape
          print([img_gpu.size()[0],img_gpu.size()[1]])
  #         M = np.float32([[1,0,100],[0,1,50]])
  #         out=cv2.UMat(out_gpu,(284,284))
          out_gpu = cv2.cuda.warpAffine(img_gpu, m, (col,row))
  
          dst = out_gpu.download()
  
      return dst
  </code></pre>
  
  <p>then I call it.</p>
  
  <pre><code>img = cv2.imread('../FengZhan/temp.png',0)
  img_rotate = rotate(img, -10)
  </code></pre>
  
  <p>it cannot work and has the following error:</p>
  
  <pre><code>&lt;ipython-input-48-41cd06952793&gt; in rotate(img, angle)
       36 #         M = np.float32([[1,0,100],[0,1,50]])
       37 #         out=cv2.UMat(out_gpu,(284,284))
  ---&gt; 38         out_gpu = cv2.cuda.warpAffine(img_gpu, m, (col,row))
       39 
       40         dst = out_gpu.download()
  
  TypeError: Expected Ptr&lt;cv::UMat&gt; for argument '%s'
  </code></pre>
  
  <p>I tried to replace img_gpu with cv2.UMat(img_gpu), but it still cannot work.
  Anybody help me?</p>