CV-CUDA icon indicating copy to clipboard operation
CV-CUDA copied to clipboard

[QUESTION] Difference between CV-CUDA resize and OpenCV resize

Open mzchtx opened this issue 3 years ago • 0 comments

We found that the way of calculating coordinate mapping in CV-CUDA's resize is different from that of OpenCV (as shown in the pseudo-code in the figure below):

Due to floating-point calculation errors, the coordinates calculated by OpenCV and CV-CUDA will have a deviation, leading to differences in the final results. For example:

  • Python 3: 125 / np.float32(500 / 480) = 120.00000457763689 -> math.floor(120.00000457763689) = 120
  • Python 3: 125 / np.float64(500 / 480) = 119.99999999999999 -> math.floor(119.99999999999999) = 119
  • CUDA: float32(500 / 480) * 120 = 124.999992 -> __float2int_rd(124.999992) = 124

Does CV-CUDA do this for efficiency?

image

mzchtx avatar Jan 31 '23 02:01 mzchtx