From 3c5eb513dd0fe24e6cadb3dd08f006bc9c6936de Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Mon, 5 Dec 2016 11:17:40 +0300 Subject: [PATCH] Fixed OpenVX to OpenCV compatibility for NN remap --- modules/imgproc/src/imgwarp.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index c7f5b3c31b..0fa520228e 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -4766,12 +4766,28 @@ static bool openvx_remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation #endif break; case INTER_NEAREST: +/* NEAREST_NEIGHBOR mode disabled since OpenCV round half to even while OpenVX sample implementation round half up #if VX_VERSION > VX_VERSION_1_0 inter_type = VX_INTERPOLATION_NEAREST_NEIGHBOR; #else inter_type = VX_INTERPOLATION_TYPE_NEAREST_NEIGHBOR; #endif + if (!map1.empty()) + for (int y = 0; y < map1.rows; ++y) + { + float* line = map1.ptr(y); + for (int x = 0; x < map1.cols; ++x) + line[x] = cvRound(line[x]); + } + if (!map2.empty()) + for (int y = 0; y < map2.rows; ++y) + { + float* line = map2.ptr(y); + for (int x = 0; x < map2.cols; ++x) + line[x] = cvRound(line[x]); + } break; +*/ case INTER_AREA://AREA interpolation mode is unsupported default: return false;