1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-18 17:24:28 +08:00
Files
opencv_contrib/modules/fastcv/perf/perf_pyramid.cpp
quic-xuezha 67815e94c8 Merge pull request #3844 from CodeLinaro:xuezha_2ndPost
FastCV Extension code for OpenCV 2ndpost-1 #3844

Depends on: [opencv/opencv#26617](https://github.com/opencv/opencv/pull/26617)
Requires binary from [opencv/opencv_3rdparty#90](https://github.com/opencv/opencv_3rdparty/pull/90)

### 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
2024-12-20 18:13:09 +03:00

77 lines
2.4 KiB
C++

/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "perf_precomp.hpp"
namespace opencv_test {
typedef std::tuple<bool /*useFloat*/, int /*nLevels*/, bool /*scaleBy2*/> PyramidTestParams;
class PyramidTest : public ::perf::TestBaseWithParam<PyramidTestParams> { };
PERF_TEST_P(PyramidTest, checkAllVersions, // version, useFloat, nLevels
::testing::Values(
PyramidTestParams { true, 2, true}, PyramidTestParams { true, 3, true}, PyramidTestParams { true, 4, true},
PyramidTestParams {false, 2, true}, PyramidTestParams {false, 3, true}, PyramidTestParams {false, 4, true},
PyramidTestParams {false, 2, false}, PyramidTestParams {false, 3, false}, PyramidTestParams {false, 4, false}
))
{
auto par = GetParam();
bool useFloat = std::get<0>(par);
int nLevels = std::get<1>(par);
bool scaleBy2 = std::get<2>(par);
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
if (useFloat)
{
cv::Mat f;
src.convertTo(f, CV_32F);
src = f;
}
while(next())
{
std::vector<cv::Mat> pyr;
startTimer();
cv::fastcv::buildPyramid(src, pyr, nLevels, scaleBy2);
stopTimer();
}
SANITY_CHECK_NOTHING();
}
typedef std::tuple<MatType, size_t> SobelPyramidTestParams;
class SobelPyramidTest : public ::perf::TestBaseWithParam<SobelPyramidTestParams> {};
PERF_TEST_P(SobelPyramidTest, checkAllTypes,
::testing::Combine(::testing::Values(CV_8S, CV_16S, CV_32F),
::testing::Values(3, 6)))
{
auto p = GetParam();
int type = std::get<0>(p);
size_t nLevels = std::get<1>(p);
// NOTE: test files should be manually loaded to folder on a device, for example like this:
// adb push fastcv/misc/bilateral_recursive/ /sdcard/testdata/fastcv/bilateral/
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
std::vector<cv::Mat> pyr;
cv::fastcv::buildPyramid(src, pyr, nLevels);
while(next())
{
std::vector<cv::Mat> pyrDx, pyrDy;
startTimer();
cv::fastcv::sobelPyramid(pyr, pyrDx, pyrDy, type);
stopTimer();
}
SANITY_CHECK_NOTHING();
}
} // namespace