mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 11:21:39 +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
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
namespace opencv_test {
|
|
|
|
typedef perf::TestBaseWithParam<std::tuple<Size, int>> ResizePerfTest;
|
|
|
|
PERF_TEST_P(ResizePerfTest, run, ::testing::Combine(
|
|
::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
|
::testing::Values(2, 4) // resize factor
|
|
))
|
|
{
|
|
Size size = std::get<0>(GetParam());
|
|
int factor = std::get<1>(GetParam());
|
|
|
|
cv::Mat inputImage(size, CV_8UC1);
|
|
cv::randu(inputImage, cv::Scalar::all(0), cv::Scalar::all(255));
|
|
|
|
cv::Mat resized_image;
|
|
Size dsize(inputImage.cols / factor, inputImage.rows / factor);
|
|
|
|
while (next())
|
|
{
|
|
startTimer();
|
|
cv::fastcv::resizeDown(inputImage, resized_image, dsize, 0, 0);
|
|
stopTimer();
|
|
}
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
typedef perf::TestBaseWithParam<std::tuple<Size, double, double, int>> ResizeByMnPerfTest;
|
|
|
|
PERF_TEST_P(ResizeByMnPerfTest, run, ::testing::Combine(
|
|
::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
|
::testing::Values(0.35, 0.65), // inv_scale_x
|
|
::testing::Values(0.35, 0.65), // inv_scale_y
|
|
::testing::Values(CV_8UC1, CV_8UC2) // data type
|
|
))
|
|
{
|
|
Size size = std::get<0>(GetParam());
|
|
double inv_scale_x = std::get<1>(GetParam());
|
|
double inv_scale_y = std::get<2>(GetParam());
|
|
int type = std::get<3>(GetParam());
|
|
|
|
cv::Mat inputImage(size, type);
|
|
cv::randu(inputImage, cv::Scalar::all(0), cv::Scalar::all(255));
|
|
|
|
Size dsize;
|
|
cv::Mat resized_image;
|
|
|
|
while (next())
|
|
{
|
|
startTimer();
|
|
cv::fastcv::resizeDown(inputImage, resized_image, dsize, inv_scale_x, inv_scale_y);
|
|
stopTimer();
|
|
}
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
} // namespace
|