Matt Van Horn fe5ab36245 imgproc: fix IPP HAL warpAffine INTER_NEAREST not bit-exact with native
The IPP HAL (hal/ipp/src/warp_ipp.cpp) routed cv::warpAffine with
INTER_NEAREST to iwiWarpAffine for CV_16S{C1,C3,C4}, CV_64F{C1,C3,C4}
and CV_16UC4 via the non-enforced (default) impl[] dispatch table,
whose comment promises results "strictly aligned to OpenCV
implementation". That contract was broken: IPP rounds source
coordinates at the half-pixel boundary differently from the native
fixed-point kernel (warpAffineBlocklineNN, 10-bit AB_BITS), so under
rotation or fractional translation about 0.05-0.07% of destination
pixels resolve to a different source pixel. Because INTER_NEAREST does
no blending, those pixels take entirely different values, so warping
identical data as e.g. CV_16S (IPP path) versus CV_16U (native path)
produced non-identical output, and x86_64 (IPP) silently diverged from
ARM (no IPP). This is the same "Different results" behavior for which
IPP warpAffine was disabled from ~2017 through 4.11.

Zero the INTER_NEAREST column of the non-enforced dispatch table for
the affected types so the dispatch guard falls back to the native
kernel, restoring the "strictly aligned" contract. The LINEAR and
CUBIC columns for these rows were already 0, so IPP was only ever used
for NEAREST here. The IPP_CALLS_ENFORCED table is left untouched so the
opt-in performance-benchmarking build still exercises IPP.

Adds a regression test (Imgproc_Warp.regression_29279) that warps a
gradient image with INTER_NEAREST as each affected type and asserts
bit-exact equality with a native (CV_32F) reference across several
rotation angles and a fractional translation.

Fixes #29279
2026-07-18 10:12:16 -07:00
2020-02-26 15:12:45 +03:00
2026-07-09 12:35:42 +03:00
2018-10-11 17:57:51 +00:00
2025-08-01 09:50:10 +03:00
2024-03-03 23:37:07 +05:30

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Description
Languages
C++ 87.6%
C 3.2%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%