Search code examples
c++opencvcomputer-visionimage-resizing

OpenCV 3.4: the result of resize in CPU and CUDA are not match in C++


I am using OpenCV with C++ to resize a frame

Following is the code that I use in CPU

cv::resize(in_mat, out_mat, out_mat.size(), 0, 0, cv::INTER_LINEAR);

The code for CUDA is as follows

cv::cuda::resize(dev_in_mat, dev_out_mat, dev_out_mat.size(), 0, 0, cv::INTER_LINEAR, stream);

The issue is, I get different outputs for both. Why does that happen?


Solution

  • This is a known problem in OpenCV. See the issue report here

    There seems being two versions currently, one with npp (legacy) and another one without it (newer):

    legacy version and newer version

    It also seems that this issue is an active one and has been bumped up to priority:normal meaning we should see a fix soon, just follow that thread and you'll be fine!

    Hope I helped, this was my first post on SO :D

    Edit:

    To build without NPP one must build a branch separate to the master branch in OpenCV:

    See the newer version here

    1. Git clone / Download as Zip
    2. Follow instructions on page for building OpenCV

    If reinstalling opencv-contrib from this branch does not fix it, then its a bug in opencv and you've got to wait util someone updates it here