mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 17:24:28 +08:00

Add warpAffine and resizeDown APIs in FastCV Extension #3936 - Added warpAffine function to apply affine transformations. 2x3 affine transformations for both CV_8UC1 and CV_8UC3 input 2x2 matrix-based patch extraction for grayscale images, with ROI. - Deprecated resizeDownBy2 and resizeDownBy4 functions. - Introduced resizeDown function to down-scale images using specified scaling factors or dimensions, supporting both single-channel (CV_8UC1) and two-channel (CV_8UC2) images. ### 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 - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] 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
87 lines
2.6 KiB
C++
87 lines
2.6 KiB
C++
/*
|
|
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "test_precomp.hpp"
|
|
|
|
namespace opencv_test { namespace {
|
|
|
|
TEST(resizeDownBy2, accuracy)
|
|
{
|
|
cv::Mat inputImage = cv::imread(cvtest::findDataFile("cv/shared/box_in_scene.png"), cv::IMREAD_GRAYSCALE);
|
|
|
|
cv::Mat resized_image;
|
|
|
|
cv::fastcv::resizeDown(inputImage, resized_image, cv::Size(inputImage.cols / 2, inputImage.rows / 2), 0, 0);
|
|
|
|
EXPECT_FALSE(resized_image.empty());
|
|
|
|
cv::Mat resizedImageOpenCV;
|
|
cv::resize(inputImage, resizedImageOpenCV, cv::Size(inputImage.cols / 2, inputImage.rows / 2), 0, 0, INTER_AREA);
|
|
|
|
double maxVal = cv::norm(resized_image, resizedImageOpenCV, cv::NORM_INF);
|
|
|
|
CV_Assert(maxVal < 10 && "Difference between images is too high!");
|
|
}
|
|
|
|
TEST(resizeDownBy4, accuracy)
|
|
{
|
|
cv::Mat inputImage = cv::imread(cvtest::findDataFile("cv/shared/box_in_scene.png"), cv::IMREAD_GRAYSCALE);
|
|
|
|
Size dsize;
|
|
cv::Mat resized_image;
|
|
|
|
cv::fastcv::resizeDown(inputImage, resized_image, dsize, 0.25, 0.25);
|
|
|
|
EXPECT_FALSE(resized_image.empty());
|
|
|
|
cv::Mat resizedImageOpenCV;
|
|
cv::resize(inputImage, resizedImageOpenCV, cv::Size(inputImage.cols / 4, inputImage.rows / 4), 0, 0, INTER_AREA);
|
|
|
|
double maxVal = cv::norm(resized_image, resizedImageOpenCV, cv::NORM_INF);
|
|
|
|
CV_Assert(maxVal < 10 && "Difference between images is too high!");
|
|
}
|
|
|
|
TEST(resizeDownMN, accuracy)
|
|
{
|
|
cv::Mat inputImage = cv::imread(cvtest::findDataFile("cv/cascadeandhog/images/class57.png"), cv::IMREAD_GRAYSCALE);
|
|
|
|
cv::Mat resized_image;
|
|
|
|
cv::fastcv::resizeDown(inputImage, resized_image, cv::Size(800, 640), 0, 0);
|
|
|
|
EXPECT_FALSE(resized_image.empty());
|
|
|
|
cv::Mat resizedImageOpenCV;
|
|
cv::resize(inputImage, resizedImageOpenCV, cv::Size(800, 640), 0, 0, INTER_LINEAR);
|
|
|
|
double maxVal = cv::norm(resized_image, resizedImageOpenCV, cv::NORM_INF);
|
|
|
|
CV_Assert(maxVal < 78 && "Difference between images is too high!");
|
|
}
|
|
|
|
TEST(resizeDownInterleaved, accuracy)
|
|
{
|
|
cv::Mat inputImage = cv::Mat::zeros(512, 512, CV_8UC2);
|
|
cv::randu(inputImage, cv::Scalar(0), cv::Scalar(255));
|
|
|
|
|
|
Size dsize;
|
|
cv::Mat resized_image;
|
|
|
|
cv::fastcv::resizeDown(inputImage, resized_image, dsize, 0.500, 0.125);
|
|
|
|
EXPECT_FALSE(resized_image.empty());
|
|
|
|
|
|
cv::Mat resizedImageOpenCV;
|
|
cv::resize(inputImage, resizedImageOpenCV, dsize, 0.500, 0.125, INTER_AREA);
|
|
|
|
double maxVal = cv::norm(resized_image, resizedImageOpenCV, cv::NORM_INF);
|
|
|
|
CV_Assert(maxVal < 10 && "Difference between images is too high!");
|
|
}
|
|
|
|
}} // namespaces opencv_test, ::
|