1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #28562 from akretz:fix_ipp_warpAffine

Fix IPP warpAffine #28562

The issue is that we compute the inverse transformation and pass that to the HAL, but tell IPP that we use the actual transformation.

https://github.com/opencv/opencv/blob/a269a489b94b84717691533a04f79d9a0e5f479a/modules/imgproc/src/imgwarp.cpp#L2399-L2412

I have added an additional test with `CV_16S` Mats to test the IPP implementation, because right now no other `warpAffine` test enters the IPP branch.

This fixes #28554.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Adrian Kretz
2026-02-24 10:21:57 +01:00
committed by GitHub
parent f563016da2
commit 261222ebf6
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ int ipp_hal_warpAffine(int src_type, const uchar *src_data, size_t src_step, int
iwSrc.Init({src_width, src_height}, ippiGetDataType(src_type), CV_MAT_CN(src_type), NULL, src_data, IwSize(src_step));
::ipp::IwiImage iwDst({dst_width, dst_height}, ippiGetDataType(src_type), CV_MAT_CN(src_type), NULL, dst_data, dst_step);
::ipp::IwiBorderType ippBorder(ippiGetBorderType(borderType), {borderValue[0], borderValue[1], borderValue[2], borderValue[3]});
IwTransDirection iwTransDirection = iwTransForward;
IwTransDirection iwTransDirection = iwTransInverse;
if((int)ippBorder == -1)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
+27
View File
@@ -1561,6 +1561,33 @@ TEST(Imgproc_Warp, regression_19566) // valgrind should detect problem if any
}
TEST(Imgproc_Warp, regression_28554)
{
const Size inSize(128, 128);
const Size outSize(256, 256);
Mat inMat = Mat::ones(inSize, CV_16S);
Mat outMat = Mat(outSize, CV_16S);
Mat coeffs = Mat::eye(2, 3, CV_64F);
coeffs.at<double>(0, 2) = 64.;
coeffs.at<double>(1, 2) = 64.;
warpAffine(
inMat,
outMat,
coeffs,
outSize,
INTER_NEAREST,
cv::BORDER_CONSTANT,
0.0
);
Mat reference = Mat::zeros(outSize, CV_16S);
reference(cv::Rect(64, 64, 128, 128)) = 1;
ASSERT_EQ(0.0, cvtest::norm(reference, outMat, NORM_INF));
}
TEST(Imgproc_GetAffineTransform, singularity)
{
Point2f A_sample[3];