1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-16 22:35:51 +08:00
Files
opencv_contrib/modules/fastcv/test/test_channel.cpp
adsha-quic 385bd6f35c Merge pull request #3891 from CodeLinaro:3rdPost
FastCV extension 3rd Post #3891

Adding FastCV extensions for merge, split, gemm and arithm APIs add, subtract

### 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
2025-03-19 11:11:29 +03:00

73 lines
2.1 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 {
typedef std::tuple<Size, int> ChannelMergeTestParams;
class ChannelMergeTest : public ::testing::TestWithParam<ChannelMergeTestParams> {};
typedef std::tuple<Size, int> ChannelSplitTestParams;
class ChannelSplitTest : public ::testing::TestWithParam<ChannelSplitTestParams> {};
TEST_P(ChannelMergeTest, accuracy)
{
int depth = CV_8UC1;
Size sz = std::get<0>(GetParam());
int count = std::get<1>(GetParam());
std::vector<Mat> src_mats;
RNG& rng = cv::theRNG();
for(int i = 0; i < count; i++)
{
Mat tmp(sz, depth);
src_mats.push_back(tmp);
cvtest::randUni(rng, src_mats[i], Scalar::all(0), Scalar::all(127));
}
Mat dst;
cv::fastcv::merge(src_mats, dst);
Mat ref;
cv::merge(src_mats, ref);
double normInf = cvtest::norm(ref, dst, cv::NORM_INF);
EXPECT_EQ(normInf, 0);
}
TEST_P(ChannelSplitTest, accuracy)
{
Size sz = std::get<0>(GetParam());
int cn = std::get<1>(GetParam());
std::vector<Mat> dst_mats(cn), ref_mats(cn);
RNG& rng = cv::theRNG();
Mat src(sz, CV_MAKE_TYPE(CV_8U,cn));
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(127));
cv::fastcv::split(src, dst_mats);
cv::split(src, ref_mats);
for(int i=0; i<cn; i++)
{
double normInf = cvtest::norm(ref_mats[i], dst_mats[i], cv::NORM_INF);
EXPECT_EQ(normInf, 0);
}
}
INSTANTIATE_TEST_CASE_P(FastCV_Extension, ChannelMergeTest,
::testing::Combine(::testing::Values(perf::szODD, perf::szVGA, perf::sz720p, perf::sz1080p), // sz
::testing::Values(2,3,4))); // count
INSTANTIATE_TEST_CASE_P(FastCV_Extension, ChannelSplitTest,
::testing::Combine(::testing::Values(perf::szODD, perf::szVGA, perf::sz720p, perf::sz1080p), // sz
::testing::Values(2,3,4))); // cn
}} // namespaces opencv_test, ::