vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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<tuple<Size, int>> IntegrateYUVPerfTest;
|
||||
|
||||
PERF_TEST_P(IntegrateYUVPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8U) // image depth
|
||||
)
|
||||
)
|
||||
{
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int depth = get<1>(GetParam());
|
||||
|
||||
cv::Mat Y(srcSize, depth), CbCr(srcSize.height/2, srcSize.width, depth);
|
||||
cv::Mat IY, ICb, ICr;
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, Y, Scalar::all(0), Scalar::all(255));
|
||||
cvtest::randUni(rng, CbCr, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
TEST_CYCLE() cv::fastcv::integrateYUV(Y, CbCr, IY, ICb, ICr);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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<float /*sigmaColor*/, float /*sigmaSpace*/> BilateralRecursivePerfParams;
|
||||
typedef perf::TestBaseWithParam<BilateralRecursivePerfParams> BilateralRecursivePerfTest;
|
||||
|
||||
PERF_TEST_P(BilateralRecursivePerfTest, run,
|
||||
::testing::Combine(::testing::Values(0.01f, 0.03f, 0.1f, 1.f, 5.f),
|
||||
::testing::Values(0.01f, 0.05f, 0.1f, 1.f, 5.f))
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
float sigmaColor = std::get<0>(p);
|
||||
float sigmaSpace = std::get<1>(p);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
Mat dst;
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::bilateralRecursive(src, dst, sigmaColor, sigmaSpace);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
typedef std::tuple<float /*sigmaColor*/, float /*sigmaSpace*/, cv::Size, int > BilateralPerfParams;
|
||||
typedef perf::TestBaseWithParam<BilateralPerfParams> BilateralPerfTest;
|
||||
|
||||
|
||||
PERF_TEST_P(BilateralPerfTest, run,
|
||||
::testing::Combine(::testing::Values(0.01f, 0.03f, 0.1f, 1.f, 5.f),
|
||||
::testing::Values(0.01f, 0.05f, 0.1f, 1.f, 5.f),
|
||||
::testing::Values(Size(8, 8), Size(640, 480), Size(800, 600)),
|
||||
::testing::Values(5, 7, 9))
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
float sigmaColor = std::get<0>(p);
|
||||
float sigmaSpace = std::get<1>(p);
|
||||
cv::Size size = std::get<2>(p);
|
||||
int d = get<3>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
Mat dst;
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::bilateralFilter(src, dst, d, sigmaColor, sigmaSpace);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int, bool>> GaussianBlurPerfTest;
|
||||
|
||||
PERF_TEST_P(GaussianBlurPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8U,CV_16S,CV_32S), // image depth
|
||||
::testing::Values(3, 5), // kernel size
|
||||
::testing::Values(true,false) // blur border
|
||||
)
|
||||
)
|
||||
{
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int depth = get<1>(GetParam());
|
||||
int ksize = get<2>(GetParam());
|
||||
bool border = get<3>(GetParam());
|
||||
|
||||
// For some cases FastCV not support, so skip them
|
||||
if((ksize!=5) && (depth!=CV_8U))
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
|
||||
cv::Mat src(srcSize, depth);
|
||||
cv::Mat dst;
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::gaussianBlur(src, dst, ksize, border);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int>> Filter2DPerfTest;
|
||||
|
||||
PERF_TEST_P(Filter2DPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8U,CV_16S,CV_32F), // dst image depth
|
||||
::testing::Values(3, 5, 7, 9, 11) // kernel size
|
||||
)
|
||||
)
|
||||
{
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int ddepth = get<1>(GetParam());
|
||||
int ksize = get<2>(GetParam());
|
||||
|
||||
cv::Mat src(srcSize, CV_8U);
|
||||
cv::Mat kernel;
|
||||
cv::Mat dst;
|
||||
|
||||
switch (ddepth)
|
||||
{
|
||||
case CV_8U:
|
||||
case CV_16S:
|
||||
{
|
||||
kernel.create(ksize,ksize,CV_8S);
|
||||
break;
|
||||
}
|
||||
case CV_32F:
|
||||
{
|
||||
kernel.create(ksize,ksize,CV_32F);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cv::randu(src, 0, 256);
|
||||
cv::randu(kernel, INT8_MIN, INT8_MAX);
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::filter2D(src, dst, ddepth, kernel);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int>> SepFilter2DPerfTest;
|
||||
|
||||
PERF_TEST_P(SepFilter2DPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8U,CV_16S), // dst image depth
|
||||
::testing::Values(3, 5, 7, 9, 11, 13, 15, 17) // kernel size
|
||||
)
|
||||
)
|
||||
{
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int ddepth = get<1>(GetParam());
|
||||
int ksize = get<2>(GetParam());
|
||||
|
||||
cv::Mat src(srcSize, ddepth);
|
||||
cv::Mat kernel(1, ksize, ddepth);
|
||||
cv::Mat dst;
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
cvtest::randUni(rng, kernel, Scalar::all(INT8_MIN), Scalar::all(INT8_MAX));
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::sepFilter2D(src, dst, ddepth, kernel, kernel);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, Size, int>> NormalizeLocalBoxPerfTest;
|
||||
|
||||
PERF_TEST_P(NormalizeLocalBoxPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8U,CV_32F), // src image depth
|
||||
::testing::Values(Size(3,3),Size(5,5)), // patch size
|
||||
::testing::Values(0,1) // use std dev or not
|
||||
)
|
||||
)
|
||||
{
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int depth = get<1>(GetParam());
|
||||
Size sz = get<2>(GetParam());
|
||||
bool useStdDev = get<3>(GetParam());
|
||||
|
||||
cv::Mat src(srcSize, depth);
|
||||
cv::Mat dst;
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
TEST_CYCLE() cv::fastcv::normalizeLocalBox(src, dst, sz, useStdDev);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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<tuple<Size, int, int>> Filter2DPerfTest_DSP;
|
||||
|
||||
PERF_TEST_P(Filter2DPerfTest_DSP, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p), // image size
|
||||
::testing::Values(CV_8U,CV_16S,CV_32F), // dst image depth
|
||||
::testing::Values(3, 5, 7) // kernel size
|
||||
)
|
||||
)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
//Initialize DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int ddepth = get<1>(GetParam());
|
||||
int ksize = get<2>(GetParam());
|
||||
|
||||
cv::Mat src;
|
||||
src.allocator = cv::fastcv::getQcAllocator();
|
||||
src.create(srcSize, CV_8U);
|
||||
|
||||
cv::Mat kernel;
|
||||
cv::Mat dst;
|
||||
kernel.allocator = cv::fastcv::getQcAllocator();
|
||||
dst.allocator = cv::fastcv::getQcAllocator();
|
||||
|
||||
switch (ddepth)
|
||||
{
|
||||
case CV_8U:
|
||||
case CV_16S:
|
||||
{
|
||||
kernel.create(ksize,ksize,CV_8S);
|
||||
break;
|
||||
}
|
||||
case CV_32F:
|
||||
{
|
||||
kernel.create(ksize,ksize,CV_32F);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cv::randu(src, 0, 256);
|
||||
cv::randu(kernel, INT8_MIN, INT8_MAX);
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::filter2D(src, dst, ddepth, kernel);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
//De-Initialize DSP
|
||||
cv::fastcv::dsp::fcvdspdeinit();
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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<int /* nPts */, int /*nDims*/, int /*nClusters*/> ClusterEuclideanPerfParams;
|
||||
typedef perf::TestBaseWithParam<ClusterEuclideanPerfParams> ClusterEuclideanPerfTest;
|
||||
|
||||
PERF_TEST_P(ClusterEuclideanPerfTest, run,
|
||||
::testing::Combine(::testing::Values(100, 1000, 10000), // nPts
|
||||
::testing::Values(2, 10, 32), // nDims
|
||||
::testing::Values(5, 10, 16)) // nClusters
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
int nPts = std::get<0>(p);
|
||||
int nDims = std::get<1>(p);
|
||||
int nClusters = std::get<2>(p);
|
||||
|
||||
Mat points(nPts, nDims, CV_8U);
|
||||
Mat clusterCenters(nClusters, nDims, CV_32F);
|
||||
|
||||
Mat trueMeans(nClusters, nDims, CV_32F);
|
||||
Mat stddevs(nClusters, nDims, CV_32F);
|
||||
std::vector<int> trueClusterSizes(nClusters, 0);
|
||||
std::vector<int> trueClusterBindings(nPts, 0);
|
||||
std::vector<float> trueSumDists(nClusters, 0);
|
||||
|
||||
cv::RNG& rng = cv::theRNG();
|
||||
for (int i = 0; i < nClusters; i++)
|
||||
{
|
||||
Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F);
|
||||
rng.fill(mean, cv::RNG::UNIFORM, 0, 256);
|
||||
rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16);
|
||||
int lo = i * nPts / nClusters;
|
||||
int hi = (i + 1) * nPts / nClusters;
|
||||
|
||||
for (int d = 0; d < nDims; d++)
|
||||
{
|
||||
rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL,
|
||||
mean.at<double>(d), stdev.at<double>(d));
|
||||
}
|
||||
|
||||
float sd = 0;
|
||||
for (int j = lo; j < hi; j++)
|
||||
{
|
||||
Mat pts64f;
|
||||
points.row(j).convertTo(pts64f, CV_64F);
|
||||
sd += cv::norm(mean, pts64f, NORM_L2);
|
||||
trueClusterBindings.at(j) = i;
|
||||
trueClusterSizes.at(i)++;
|
||||
}
|
||||
trueSumDists.at(i) = sd;
|
||||
|
||||
// let's shift initial cluster center a bit
|
||||
Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i));
|
||||
|
||||
mean.copyTo(trueMeans.row(i));
|
||||
stdev.copyTo(stddevs.row(i));
|
||||
}
|
||||
|
||||
while(next())
|
||||
{
|
||||
Mat newClusterCenters;
|
||||
std::vector<int> clusterSizes, clusterBindings;
|
||||
std::vector<float> clusterSumDists;
|
||||
startTimer();
|
||||
cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int, int>> SobelPerfTest;
|
||||
|
||||
PERF_TEST_P(SobelPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(3,5,7), // kernel size
|
||||
::testing::Values(BORDER_CONSTANT, BORDER_REPLICATE), // border type
|
||||
::testing::Values(0) // border value
|
||||
)
|
||||
)
|
||||
{
|
||||
Size srcSize = get<0>(GetParam());
|
||||
int ksize = get<1>(GetParam());
|
||||
int border = get<2>(GetParam());
|
||||
int borderValue = get<3>(GetParam());
|
||||
|
||||
cv::Mat dx, dy, src(srcSize, CV_8U);
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::sobel(src,dx,dy,ksize,border,borderValue);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int>> Sobel3x3u8PerfTest;
|
||||
|
||||
PERF_TEST_P(Sobel3x3u8PerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(CV_8S, CV_16S, CV_32F), // image depth
|
||||
::testing::Values(0, 1) // normalization
|
||||
)
|
||||
)
|
||||
{
|
||||
Size srcSize = get<0>(GetParam());
|
||||
int ddepth = get<1>(GetParam());
|
||||
int normalization = get<2>(GetParam());
|
||||
|
||||
cv::Mat dx, dy, src(srcSize, CV_8U);
|
||||
RNG& rng = cv::theRNG();
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
|
||||
if((normalization ==0) && (ddepth == CV_8S))
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::sobel3x3u8(src, dx, dy, ddepth, normalization);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
} //namespace
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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<tuple<Size, int, pair<int, int>, bool>> CannyPerfTest;
|
||||
|
||||
PERF_TEST_P(CannyPerfTest, run,
|
||||
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
|
||||
::testing::Values(3, 5, 7), // aperture size
|
||||
::testing::Values(make_pair(0, 50), make_pair(100, 150), make_pair(50, 150)), // low and high thresholds
|
||||
::testing::Values(false, true) // L2gradient
|
||||
)
|
||||
)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
//Initialize DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
cv::Size srcSize = get<0>(GetParam());
|
||||
int apertureSize = get<1>(GetParam());
|
||||
auto thresholds = get<2>(GetParam());
|
||||
bool L2gradient = get<3>(GetParam());
|
||||
|
||||
cv::Mat src;
|
||||
src.allocator = cv::fastcv::getQcAllocator();
|
||||
src.create(srcSize, CV_8UC1);
|
||||
|
||||
cv::Mat dst;
|
||||
dst.allocator = cv::fastcv::getQcAllocator();
|
||||
|
||||
cv::randu(src, 0, 256);
|
||||
|
||||
int lowThreshold = thresholds.first;
|
||||
int highThreshold = thresholds.second;
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::Canny(src, dst, lowThreshold, highThreshold, apertureSize, L2gradient);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
//De-Initialize DSP
|
||||
cv::fastcv::dsp::fcvdspdeinit();
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} //namespace
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 /*useScores*/, int /*barrier*/, int /*border*/, bool /*nmsEnabled*/> FAST10PerfParams;
|
||||
typedef perf::TestBaseWithParam<FAST10PerfParams> FAST10PerfTest;
|
||||
|
||||
PERF_TEST_P(FAST10PerfTest, run,
|
||||
::testing::Combine(::testing::Bool(), // useScores
|
||||
::testing::Values(10, 30, 50), // barrier
|
||||
::testing::Values( 4, 10, 32), // border
|
||||
::testing::Bool() // nonmax suppression
|
||||
)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
bool useScores = std::get<0>(p);
|
||||
int barrier = std::get<1>(p);
|
||||
int border = std::get<2>(p);
|
||||
bool nmsEnabled = std::get<3>(p);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
std::vector<int> coords, scores;
|
||||
while(next())
|
||||
{
|
||||
coords.clear();
|
||||
scores.clear();
|
||||
startTimer();
|
||||
cv::fastcv::FAST10(src, noArray(), coords, useScores ? scores : noArray(), barrier, border, nmsEnabled);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef perf::TestBaseWithParam<cv::Size> FFTExtPerfTest;
|
||||
|
||||
PERF_TEST_P_(FFTExtPerfTest, forward)
|
||||
{
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat dst;
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::FFT(src, dst);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(FFTExtPerfTest, inverse)
|
||||
{
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat fwd, back;
|
||||
cv::fastcv::FFT(src, fwd);
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::IFFT(fwd, back);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FastCV_Extension, FFTExtPerfTest,
|
||||
::testing::Values(Size(8, 8), Size(128, 128), Size(32, 256), Size(512, 512),
|
||||
Size(32, 1), Size(512, 1)));
|
||||
|
||||
/// DCT ///
|
||||
|
||||
typedef perf::TestBaseWithParam<cv::Size> DCTExtPerfTest;
|
||||
|
||||
PERF_TEST_P_(DCTExtPerfTest, forward)
|
||||
{
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat dst, ref;
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::DCT(src, dst);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(DCTExtPerfTest, inverse)
|
||||
{
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat fwd, back;
|
||||
cv::fastcv::DCT(src, fwd);
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::IDCT(fwd, back);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FastCV_Extension, DCTExtPerfTest,
|
||||
::testing::Values(Size(8, 8), Size(128, 128), Size(32, 256), Size(512, 512)));
|
||||
} // namespace
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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<cv::Size> FFT_DSPExtPerfTest;
|
||||
|
||||
PERF_TEST_P_(FFT_DSPExtPerfTest, forward)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
//Initialize DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
|
||||
Mat src;
|
||||
src.allocator = cv::fastcv::getQcAllocator();
|
||||
src.create(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat dst;
|
||||
dst.allocator = cv::fastcv::getQcAllocator();
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::FFT(src, dst);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
//De-Initialize DSP
|
||||
cv::fastcv::dsp::fcvdspdeinit();
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(FFT_DSPExtPerfTest, inverse)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
//Initialize DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
Size size = GetParam();
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
|
||||
Mat src;
|
||||
src.allocator = cv::fastcv::getQcAllocator();
|
||||
src.create(size, CV_8UC1);
|
||||
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat fwd, back;
|
||||
fwd.allocator = cv::fastcv::getQcAllocator();
|
||||
back.allocator = cv::fastcv::getQcAllocator();
|
||||
|
||||
cv::fastcv::dsp::FFT(src, fwd);
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::IFFT(fwd, back);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
//De-Initialize DSP
|
||||
cv::fastcv::dsp::fcvdspdeinit();
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FastCV_Extension, FFT_DSPExtPerfTest,
|
||||
::testing::Values(Size(256, 256), Size(512, 512)));
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef tuple<cv::Size /*imgSize*/, int /*nPts*/, int /*channels*/> FillConvexPerfParams;
|
||||
typedef perf::TestBaseWithParam<FillConvexPerfParams> FillConvexPerfTest;
|
||||
|
||||
PERF_TEST_P(FillConvexPerfTest, randomDraw, Combine(
|
||||
testing::Values(Size(640, 480), Size(512, 512), Size(1920, 1080)),
|
||||
testing::Values(4, 64, 1024),
|
||||
testing::Values(1, 2, 3, 4)
|
||||
))
|
||||
{
|
||||
auto p = GetParam();
|
||||
|
||||
Size imgSize = std::get<0>(p);
|
||||
int nPts = std::get<1>(p);
|
||||
int channels = std::get<2>(p);
|
||||
|
||||
cv::RNG rng = cv::theRNG();
|
||||
|
||||
std::vector<Point> allPts, contour;
|
||||
for (int i = 0; i < nPts; i++)
|
||||
{
|
||||
allPts.push_back(Point(rng() % imgSize.width, rng() % imgSize.height));
|
||||
}
|
||||
cv::convexHull(allPts, contour);
|
||||
|
||||
Scalar color(rng() % 256, rng() % 256, rng() % 256);
|
||||
|
||||
Mat img(imgSize, CV_MAKE_TYPE(CV_8U, channels), Scalar(0));
|
||||
|
||||
while(next())
|
||||
{
|
||||
img = 0;
|
||||
startTimer();
|
||||
cv::fastcv::fillConvexPoly(img, contour, color);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(FillConvexPerfTest, circle, Combine(
|
||||
testing::Values(Size(640, 480), Size(512, 512), Size(1920, 1080)),
|
||||
testing::Values(4, 64, 1024),
|
||||
testing::Values(1, 2, 3, 4)
|
||||
))
|
||||
{
|
||||
auto p = GetParam();
|
||||
|
||||
Size imgSize = std::get<0>(p);
|
||||
int nPts = std::get<1>(p);
|
||||
int channels = std::get<2>(p);
|
||||
|
||||
cv::RNG rng = cv::theRNG();
|
||||
|
||||
float r = std::min(imgSize.width, imgSize.height) / 2 * 0.9f;
|
||||
float angle = CV_PI * 2.0f / (float)nPts;
|
||||
std::vector<Point2i> contour;
|
||||
for (int i = 0; i < nPts; i++)
|
||||
{
|
||||
Point2f pt(r * cos((float)i * angle),
|
||||
r * sin((float)i * angle));
|
||||
contour.push_back({ imgSize.width / 2 + int(pt.x),
|
||||
imgSize.height / 2 + int(pt.y)});
|
||||
}
|
||||
Scalar color(rng() % 256, rng() % 256, rng() % 256);
|
||||
|
||||
Mat img(imgSize, CV_MAKE_TYPE(CV_8U, channels), Scalar(0));
|
||||
|
||||
while(next())
|
||||
{
|
||||
img = 0;
|
||||
startTimer();
|
||||
cv::fastcv::fillConvexPoly(img, contour, color);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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<cv::Size> HistogramPerfParams;
|
||||
typedef perf::TestBaseWithParam<HistogramPerfParams> HistogramPerfTest;
|
||||
|
||||
|
||||
PERF_TEST_P(HistogramPerfTest, run,
|
||||
testing::Values(perf::szQVGA, perf::szVGA, perf::sz720p, perf::sz1080p)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
cv::Size size = std::get<0>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
|
||||
Mat hist(1, 256, CV_32SC1);
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::calcHist(src, hist);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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<std::string /* file name */, double /* threshold */ > HoughLinesPerfParams;
|
||||
typedef perf::TestBaseWithParam<HoughLinesPerfParams> HoughLinesPerfTest;
|
||||
|
||||
PERF_TEST_P(HoughLinesPerfTest, run,
|
||||
::testing::Combine(::testing::Values("cv/shared/pic5.png",
|
||||
"stitching/a1.png",
|
||||
"cv/shared/pic5.png",
|
||||
"cv/shared/pic1.png"), // images
|
||||
::testing::Values(0.05, 0.25, 0.5, 0.75, 5) // threshold
|
||||
)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
std::string fname = std::get<0>(p);
|
||||
double thrld = std::get<1>(p);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile(fname), cv::IMREAD_GRAYSCALE);
|
||||
// make it aligned by 8
|
||||
cv::Mat withBorder;
|
||||
int bpix = ((src.cols & 0xfffffff8) + 8) - src.cols;
|
||||
cv::copyMakeBorder(src, withBorder, 0, 0, 0, bpix, BORDER_REFLECT101);
|
||||
src = withBorder;
|
||||
|
||||
while(next())
|
||||
{
|
||||
std::vector<cv::Vec4f> lines;
|
||||
startTimer();
|
||||
cv::fastcv::houghLines(src, lines, thrld);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
static void initFastCVTests()
|
||||
{
|
||||
cvtest::registerGlobalSkipTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
}
|
||||
|
||||
CV_PERF_TEST_MAIN(imgproc, initFastCVTests())
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef std::tuple<int /*rows1*/, int /*cols1*/, int /*cols2*/> MatMulPerfParams;
|
||||
typedef perf::TestBaseWithParam<MatMulPerfParams> MatMulPerfTest;
|
||||
|
||||
typedef std::tuple<int /*rows1*/, int /*cols1*/, int /*cols2*/, float> MatMulGemmPerfParams;
|
||||
typedef perf::TestBaseWithParam<MatMulGemmPerfParams> MatMulGemmPerfTest;
|
||||
|
||||
PERF_TEST_P(MatMulPerfTest, run,
|
||||
::testing::Combine(::testing::Values(8, 16, 128, 256), // rows1
|
||||
::testing::Values(8, 16, 128, 256), // cols1
|
||||
::testing::Values(8, 16, 128, 256)) // cols2
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
int rows1 = std::get<0>(p);
|
||||
int cols1 = std::get<1>(p);
|
||||
int cols2 = std::get<2>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src1(rows1, cols1, CV_8SC1), src2(cols1, cols2, CV_8SC1);
|
||||
cvtest::randUni(rng, src1, Scalar::all(-128), Scalar::all(128));
|
||||
cvtest::randUni(rng, src2, Scalar::all(-128), Scalar::all(128));
|
||||
|
||||
Mat dst;
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::matmuls8s32(src1, src2, dst);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(MatMulGemmPerfTest, run,
|
||||
::testing::Combine(::testing::Values(8, 16, 128, 256), // rows1
|
||||
::testing::Values(8, 16, 128, 256), // cols1
|
||||
::testing::Values(8, 16, 128, 256), // cols2
|
||||
::testing::Values(2.5, 5.8)) // alpha
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
int rows1 = std::get<0>(p);
|
||||
int cols1 = std::get<1>(p);
|
||||
int cols2 = std::get<2>(p);
|
||||
float alpha = std::get<3>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src1(rows1, cols1, CV_32FC1), src2(cols1, cols2, CV_32FC1);
|
||||
cvtest::randUni(rng, src1, Scalar::all(-128.0), Scalar::all(128.0));
|
||||
cvtest::randUni(rng, src2, Scalar::all(-128.0), Scalar::all(128.0));
|
||||
|
||||
Mat dst;
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::gemm(src1, src2, dst, alpha, noArray(), 0);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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<cv::Size, MatType, int /*iterations*/, float /*epsilon*/, Size /*winSize*/> MeanShiftPerfParams;
|
||||
typedef perf::TestBaseWithParam<MeanShiftPerfParams> MeanShiftPerfTest;
|
||||
|
||||
PERF_TEST_P(MeanShiftPerfTest, run,
|
||||
::testing::Combine(::testing::Values(Size(128, 128), Size(640, 480), Size(800, 600)),
|
||||
::testing::Values(CV_8U, CV_32S, CV_32F), // type
|
||||
::testing::Values(2, 10, 100), // nIterations
|
||||
::testing::Values(0.01f, 0.1f, 1.f, 10.f), // epsilon
|
||||
::testing::Values(Size(8, 8), Size(13, 48), Size(64, 64)) // window size
|
||||
)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
cv::Size size = std::get<0>(p);
|
||||
MatType type = std::get<1>(p);
|
||||
int iters = std::get<2>(p);
|
||||
float eps = std::get<3>(p);
|
||||
Size winSize = std::get<4>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
|
||||
const int nPts = 20;
|
||||
Mat ptsMap(size, CV_8UC1, Scalar(255));
|
||||
for(size_t i = 0; i < nPts; ++i)
|
||||
{
|
||||
ptsMap.at<uchar>(rng() % size.height, rng() % size.width) = 0;
|
||||
}
|
||||
Mat distTrans(size, CV_8UC1);
|
||||
cv::distanceTransform(ptsMap, distTrans, DIST_L2, DIST_MASK_PRECISE);
|
||||
Mat vsrc = 255 - distTrans;
|
||||
Mat src;
|
||||
vsrc.convertTo(src, type);
|
||||
|
||||
Point startPt(rng() % (size.width - winSize.width),
|
||||
rng() % (size.height - winSize.height));
|
||||
Rect startRect(startPt, winSize);
|
||||
|
||||
cv::TermCriteria termCrit( TermCriteria::EPS + TermCriteria::MAX_ITER, iters, eps);
|
||||
|
||||
Rect window = startRect;
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::meanShift(src, window, termCrit);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
// we use such nested structure to combine test values
|
||||
typedef std::tuple< std::tuple<bool /* useBboxes */, bool /* useContourData */>,
|
||||
int /* numNeighbors */, std::string /*file path*/> MSERPerfParams;
|
||||
typedef perf::TestBaseWithParam<MSERPerfParams> MSERPerfTest;
|
||||
|
||||
PERF_TEST_P(MSERPerfTest, run,
|
||||
::testing::Combine(::testing::Values(std::tuple<bool, bool> { true, false},
|
||||
std::tuple<bool, bool> {false, false},
|
||||
std::tuple<bool, bool> { true, true}
|
||||
), // useBboxes, useContourData
|
||||
::testing::Values(4, 8), // numNeighbors
|
||||
::testing::Values("cv/shared/baboon.png", "cv/mser/puzzle.png")
|
||||
)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
bool useBboxes = std::get<0>(std::get<0>(p));
|
||||
bool useContourData = std::get<1>(std::get<0>(p));
|
||||
int numNeighbors = std::get<1>(p); // 4 or 8
|
||||
std::string imgPath = std::get<2>(p);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile(imgPath), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
uint32_t delta = 2;
|
||||
uint32_t minArea = 256;
|
||||
uint32_t maxArea = (int)src.total()/4;
|
||||
float maxVariation = 0.15f;
|
||||
float minDiversity = 0.2f;
|
||||
|
||||
cv::Ptr<cv::fastcv::FCVMSER> mser;
|
||||
mser = cv::fastcv::FCVMSER::create(src.size(), numNeighbors, delta, minArea, maxArea,
|
||||
maxVariation, minDiversity);
|
||||
|
||||
while(next())
|
||||
{
|
||||
std::vector<std::vector<Point>> contours;
|
||||
std::vector<cv::Rect> bboxes;
|
||||
std::vector<cv::fastcv::FCVMSER::ContourData> contourData;
|
||||
|
||||
startTimer();
|
||||
if (useBboxes)
|
||||
{
|
||||
if (useContourData)
|
||||
{
|
||||
mser->detect(src, contours, bboxes, contourData);
|
||||
}
|
||||
else
|
||||
{
|
||||
mser->detect(src, contours, bboxes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mser->detect(src, contours);
|
||||
}
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __FASTCV_EXT_PERF_PRECOMP_HPP__
|
||||
#define __FASTCV_EXT_PERF_PRECOMP_HPP__
|
||||
|
||||
#include <opencv2/ts.hpp>
|
||||
#include <opencv2/geometry.hpp>
|
||||
#include <opencv2/features.hpp>
|
||||
#include <opencv2/fastcv.hpp>
|
||||
|
||||
namespace opencv_test {
|
||||
using namespace perf;
|
||||
} // namespace
|
||||
|
||||
#define CV_TEST_TAG_FASTCV_SKIP_DSP "fastcv_skip_dsp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef std::tuple<cv::Size /*srcSize*/> SumOfAbsDiffsPerfParams;
|
||||
typedef perf::TestBaseWithParam<SumOfAbsDiffsPerfParams> SumOfAbsDiffsPerfTest;
|
||||
|
||||
PERF_TEST_P(SumOfAbsDiffsPerfTest, run,
|
||||
::testing::Values(cv::Size(640, 480), // VGA
|
||||
cv::Size(1280, 720), // 720p
|
||||
cv::Size(1920, 1080)) // 1080p
|
||||
)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
// Initialize FastCV DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
auto p = GetParam();
|
||||
cv::Size srcSize = std::get<0>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
cv::Mat patch, src;
|
||||
|
||||
patch.allocator = cv::fastcv::getQcAllocator(); // Use FastCV allocator for patch
|
||||
src.allocator = cv::fastcv::getQcAllocator(); // Use FastCV allocator for src
|
||||
|
||||
patch.create(8, 8, CV_8UC1);
|
||||
src.create(srcSize, CV_8UC1);
|
||||
|
||||
cvtest::randUni(rng, patch, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
cvtest::randUni(rng, src, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
|
||||
cv::Mat dst;
|
||||
dst.allocator = cv::fastcv::getQcAllocator(); // Use FastCV allocator for dst
|
||||
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::sumOfAbsoluteDiffs(patch, src, dst);
|
||||
stopTimer();
|
||||
}
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef std::tuple<cv::Size, bool /*type*/> ThresholdOtsuPerfParams;
|
||||
typedef perf::TestBaseWithParam<ThresholdOtsuPerfParams> ThresholdOtsuPerfTest;
|
||||
|
||||
PERF_TEST_P(ThresholdOtsuPerfTest, run,
|
||||
::testing::Combine(::testing::Values(Size(320, 240), Size(640, 480), Size(1280, 720), Size(1920, 1080)),
|
||||
::testing::Values(false, true) // type
|
||||
)
|
||||
)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_FASTCV_SKIP_DSP);
|
||||
|
||||
//Initialize DSP
|
||||
int initStatus = cv::fastcv::dsp::fcvdspinit();
|
||||
ASSERT_EQ(initStatus, 0) << "Failed to initialize FastCV DSP";
|
||||
|
||||
auto p = GetParam();
|
||||
cv::Size size = std::get<0>(p);
|
||||
bool type = std::get<1>(p);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
|
||||
cv::Mat src;
|
||||
src.allocator = cv::fastcv::getQcAllocator();
|
||||
src.create(size, CV_8UC1);
|
||||
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
cv::Mat dst;
|
||||
dst.allocator = cv::fastcv::getQcAllocator();
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::dsp::thresholdOtsu(src, dst, type);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
//De-Initialize DSP
|
||||
cv::fastcv::dsp::fcvdspdeinit();
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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<cv::Size, int /*lowThresh*/, int /*highThresh*/, int /*trueValue*/, int /*falseValue*/> ThresholdRangePerfParams;
|
||||
typedef perf::TestBaseWithParam<ThresholdRangePerfParams> ThresholdRangePerfTest;
|
||||
|
||||
PERF_TEST_P(ThresholdRangePerfTest, run,
|
||||
::testing::Combine(::testing::Values(Size(8, 8), Size(640, 480), Size(800, 600)),
|
||||
::testing::Values(0, 15, 128, 255), // lowThresh
|
||||
::testing::Values(0, 15, 128, 255), // highThresh
|
||||
::testing::Values(0, 15, 128, 255), // trueValue
|
||||
::testing::Values(0, 15, 128, 255) // falseValue
|
||||
)
|
||||
)
|
||||
{
|
||||
auto p = GetParam();
|
||||
cv::Size size = std::get<0>(p);
|
||||
int loThresh = std::get<1>(p);
|
||||
int hiThresh = std::get<2>(p);
|
||||
int trueValue = std::get<3>(p);
|
||||
int falseValue = std::get<4>(p);
|
||||
|
||||
int lowThresh = std::min(loThresh, hiThresh);
|
||||
int highThresh = std::max(loThresh, hiThresh);
|
||||
|
||||
RNG& rng = cv::theRNG();
|
||||
Mat src(size, CV_8UC1);
|
||||
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(256));
|
||||
|
||||
Mat dst;
|
||||
while(next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::thresholdRange(src, dst, lowThresh, highThresh, trueValue, falseValue);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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<int /*winSize*/, bool /*useSobelPyramid*/, bool /*useInitialEstimate*/ > TrackingTestParams;
|
||||
class TrackingTest : public ::perf::TestBaseWithParam<TrackingTestParams> {};
|
||||
|
||||
PERF_TEST_P(TrackingTest, checkAllVersions,
|
||||
::testing::Combine(::testing::Values(5, 7, 9), // window size
|
||||
::testing::Bool(), // useSobelPyramid
|
||||
::testing::Bool() // useInitialEstimate
|
||||
))
|
||||
{
|
||||
auto par = GetParam();
|
||||
|
||||
int winSz = std::get<0>(par);
|
||||
bool useSobelPyramid = std::get<1>(par);
|
||||
bool useInitialEstimate = std::get<2>(par);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
double ang = 5.0 * CV_PI / 180.0;
|
||||
cv::Matx33d tr = {
|
||||
cos(ang), -sin(ang), 1,
|
||||
sin(ang), cos(ang), 2,
|
||||
0, 0, 1
|
||||
};
|
||||
cv::Matx33d orig {
|
||||
1, 0, -(double)src.cols / 2,
|
||||
0, 1, -(double)src.rows / 2,
|
||||
0, 0, 1
|
||||
};
|
||||
cv::Matx33d back {
|
||||
1, 0, (double)src.cols / 2,
|
||||
0, 1, (double)src.rows / 2,
|
||||
0, 0, 1
|
||||
};
|
||||
cv::Matx23d trans = (back * tr * orig).get_minor<2, 3>(0, 0);
|
||||
|
||||
cv::Mat dst;
|
||||
cv::warpAffine(src, dst, trans, src.size());
|
||||
|
||||
int nLevels = 4;
|
||||
std::vector<cv::Mat> srcPyr, dstPyr;
|
||||
|
||||
cv::buildPyramid(src, srcPyr, nLevels - 1);
|
||||
cv::buildPyramid(dst, dstPyr, nLevels - 1);
|
||||
|
||||
cv::Matx23f transf = trans;
|
||||
int nPts = 32;
|
||||
std::vector<cv::Point2f> ptsIn, ptsEst, ptsExpected;
|
||||
for (int i = 0; i < nPts; i++)
|
||||
{
|
||||
cv::Point2f p { (((float)cv::theRNG())*0.5f + 0.25f) * src.cols,
|
||||
(((float)cv::theRNG())*0.5f + 0.25f) * src.rows };
|
||||
ptsIn.push_back(p);
|
||||
ptsExpected.push_back(transf * cv::Vec3f(p.x, p.y, 1.0));
|
||||
ptsEst.push_back(p);
|
||||
}
|
||||
|
||||
cv::TermCriteria termCrit;
|
||||
termCrit.type = cv::TermCriteria::COUNT | cv::TermCriteria::EPS;
|
||||
termCrit.maxCount = 7;
|
||||
termCrit.epsilon = 0.03f * 0.03f;
|
||||
|
||||
std::vector<cv::Mat> srcDxPyr, srcDyPyr;
|
||||
if (useSobelPyramid)
|
||||
{
|
||||
cv::fastcv::sobelPyramid(srcPyr, srcDxPyr, srcDyPyr, CV_8S);
|
||||
}
|
||||
|
||||
while(next())
|
||||
{
|
||||
std::vector<int32_t> statusVec(nPts);
|
||||
std::vector<cv::Point2f> ptsOut(nPts);
|
||||
startTimer();
|
||||
if (useSobelPyramid)
|
||||
{
|
||||
cv::fastcv::trackOpticalFlowLK(src, dst, srcPyr, dstPyr, srcDxPyr, srcDyPyr,
|
||||
ptsIn, ptsOut, statusVec, {winSz, winSz});
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::fastcv::trackOpticalFlowLK(src, dst, srcPyr, dstPyr, ptsIn, ptsOut, (useInitialEstimate ? ptsEst : noArray()),
|
||||
statusVec, {winSz, winSz}, termCrit);
|
||||
}
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
static void getInvertMatrix(Mat& src, Size dstSize, Mat& M)
|
||||
{
|
||||
RNG& rng = cv::theRNG();
|
||||
Point2f s[4], d[4];
|
||||
|
||||
s[0] = Point2f(0,0);
|
||||
d[0] = Point2f(0,0);
|
||||
s[1] = Point2f(src.cols-1.f,0);
|
||||
d[1] = Point2f(dstSize.width-1.f,0);
|
||||
s[2] = Point2f(src.cols-1.f,src.rows-1.f);
|
||||
d[2] = Point2f(dstSize.width-1.f,dstSize.height-1.f);
|
||||
s[3] = Point2f(0,src.rows-1.f);
|
||||
d[3] = Point2f(0,dstSize.height-1.f);
|
||||
|
||||
float buffer[16];
|
||||
Mat tmp( 1, 16, CV_32FC1, buffer );
|
||||
rng.fill( tmp, 1, Scalar::all(0.), Scalar::all(0.1) );
|
||||
|
||||
for(int i = 0; i < 4; i++ )
|
||||
{
|
||||
s[i].x += buffer[i*4]*src.cols/2;
|
||||
s[i].y += buffer[i*4+1]*src.rows/2;
|
||||
d[i].x += buffer[i*4+2]*dstSize.width/2;
|
||||
d[i].y += buffer[i*4+3]*dstSize.height/2;
|
||||
}
|
||||
|
||||
cv::getPerspectiveTransform( s, d ).convertTo( M, M.depth() );
|
||||
|
||||
// Invert the perspective matrix
|
||||
invert(M,M);
|
||||
}
|
||||
|
||||
static cv::Mat getInverseAffine(const cv::Mat& affine)
|
||||
{
|
||||
// Extract the 2x2 part
|
||||
cv::Mat rotationScaling = affine(cv::Rect(0, 0, 2, 2));
|
||||
|
||||
// Invert the 2x2 part
|
||||
cv::Mat inverseRotationScaling;
|
||||
cv::invert(rotationScaling, inverseRotationScaling);
|
||||
|
||||
// Extract the translation part
|
||||
cv::Mat translation = affine(cv::Rect(2, 0, 1, 2));
|
||||
|
||||
// Compute the new translation
|
||||
cv::Mat inverseTranslation = -inverseRotationScaling * translation;
|
||||
|
||||
// Construct the inverse affine matrix
|
||||
cv::Mat inverseAffine = cv::Mat::zeros(2, 3, CV_32F);
|
||||
inverseRotationScaling.copyTo(inverseAffine(cv::Rect(0, 0, 2, 2)));
|
||||
inverseTranslation.copyTo(inverseAffine(cv::Rect(2, 0, 1, 2)));
|
||||
|
||||
return inverseAffine;
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<Size> WarpPerspective2PlanePerfTest;
|
||||
|
||||
PERF_TEST_P(WarpPerspective2PlanePerfTest, run,
|
||||
::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p))
|
||||
{
|
||||
cv::Size dstSize = GetParam();
|
||||
cv::Mat img = imread(cvtest::findDataFile("cv/shared/baboon.png"));
|
||||
Mat src(img.rows, img.cols, CV_8UC1);
|
||||
cvtColor(img,src,cv::COLOR_BGR2GRAY);
|
||||
cv::Mat dst1, dst2, matrix;
|
||||
matrix.create(3,3,CV_32FC1);
|
||||
|
||||
getInvertMatrix(src, dstSize, matrix);
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::warpPerspective2Plane(src, src, dst1, dst2, matrix, dstSize);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<tuple<Size, int, int>> WarpPerspectivePerfTest;
|
||||
|
||||
PERF_TEST_P(WarpPerspectivePerfTest, run,
|
||||
::testing::Combine( ::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p),
|
||||
::testing::Values(INTER_NEAREST, INTER_LINEAR, INTER_AREA),
|
||||
::testing::Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_TRANSPARENT)))
|
||||
{
|
||||
cv::Size dstSize = get<0>(GetParam());
|
||||
int interplation = get<1>(GetParam());
|
||||
int borderType = get<2>(GetParam());
|
||||
cv::Scalar borderValue = Scalar::all(100);
|
||||
|
||||
cv::Mat src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
EXPECT_FALSE(src.empty());
|
||||
|
||||
cv::Mat dst, matrix, ref;
|
||||
matrix.create(3, 3, CV_32FC1);
|
||||
|
||||
getInvertMatrix(src, dstSize, matrix);
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::warpPerspective(src, dst, matrix, dstSize, interplation, borderType, borderValue);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< tuple<MatType, Size> > WarpAffine3ChannelPerf;
|
||||
|
||||
PERF_TEST_P(WarpAffine3ChannelPerf, run, Combine(
|
||||
Values(CV_8UC3),
|
||||
Values( szVGA, sz720p, sz1080p)
|
||||
))
|
||||
{
|
||||
Size sz, szSrc(512, 512);
|
||||
int dataType;
|
||||
dataType = get<0>(GetParam());
|
||||
sz = get<1>(GetParam());
|
||||
|
||||
cv::Mat src(szSrc, dataType), dst(sz, dataType);
|
||||
|
||||
cvtest::fillGradient<uint8_t>(src);
|
||||
|
||||
//Affine matrix
|
||||
float angle = 30.0; // Rotation angle in degrees
|
||||
float scale = 2.2; // Scale factor
|
||||
cv::Mat affine = cv::getRotationMatrix2D(cv::Point2f(100, 100), angle, scale);
|
||||
|
||||
// Compute the inverse affine matrix
|
||||
cv::Mat inverseAffine = getInverseAffine(affine);
|
||||
|
||||
// Create the dstBorder array
|
||||
Mat dstBorder;
|
||||
|
||||
declare.in(src).out(dst);
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::warpAffine(src, dst, inverseAffine, sz);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<cv::Size, cv::Point2f, cv::Mat>> WarpAffineROIPerfTest;
|
||||
|
||||
PERF_TEST_P(WarpAffineROIPerfTest, run, ::testing::Combine(
|
||||
::testing::Values(cv::Size(50, 50), cv::Size(100, 100)), // patch size
|
||||
::testing::Values(cv::Point2f(50.0f, 50.0f), cv::Point2f(100.0f, 100.0f)), // position
|
||||
::testing::Values((cv::Mat_<float>(2, 2) << 1, 0, 0, 1), // identity matrix
|
||||
(cv::Mat_<float>(2, 2) << cos(CV_PI), -sin(CV_PI), sin(CV_PI), cos(CV_PI))) // rotation matrix
|
||||
))
|
||||
{
|
||||
cv::Size patchSize = std::get<0>(GetParam());
|
||||
cv::Point2f position = std::get<1>(GetParam());
|
||||
cv::Mat affine = std::get<2>(GetParam());
|
||||
|
||||
cv::Mat src = cv::imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
// Create ROI with top-left at the specified position
|
||||
cv::Rect roiRect(static_cast<int>(position.x), static_cast<int>(position.y), patchSize.width, patchSize.height);
|
||||
|
||||
// Ensure ROI is within image bounds
|
||||
roiRect = roiRect & cv::Rect(0, 0, src.cols, src.rows);
|
||||
cv::Mat roi = src(roiRect);
|
||||
|
||||
cv::Mat patch;
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::warpAffine(roi, patch, affine, patchSize);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam<tuple<int, int> > WarpAffinePerfTest;
|
||||
|
||||
PERF_TEST_P(WarpAffinePerfTest, run, ::testing::Combine(
|
||||
::testing::Values(cv::InterpolationFlags::INTER_NEAREST, cv::InterpolationFlags::INTER_LINEAR, cv::InterpolationFlags::INTER_AREA),
|
||||
::testing::Values(0, 255) // Black and white borders
|
||||
))
|
||||
{
|
||||
// Load the source image
|
||||
cv::Mat src = cv::imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(src.empty());
|
||||
|
||||
// Generate random values for the affine matrix
|
||||
std::srand(std::time(0));
|
||||
float angle = static_cast<float>(std::rand() % 360); // Random angle between 0 and 360 degrees
|
||||
float scale = static_cast<float>(std::rand() % 200) / 100.0f + 0.5f; // Random scale between 0.5 and 2.5
|
||||
float tx = static_cast<float>(std::rand() % 100) - 50; // Random translation between -50 and 50
|
||||
float ty = static_cast<float>(std::rand() % 100) - 50; // Random translation between -50 and 50
|
||||
float radians = angle * CV_PI / 180.0;
|
||||
cv::Mat affine = (cv::Mat_<float>(2, 3) << scale * cos(radians), -scale * sin(radians), tx,
|
||||
scale * sin(radians), scale * cos(radians), ty);
|
||||
|
||||
// Compute the inverse affine matrix
|
||||
cv::Mat inverseAffine = getInverseAffine(affine);
|
||||
|
||||
// Define the destination size
|
||||
cv::Size dsize(src.cols, src.rows);
|
||||
|
||||
// Define the output matrix
|
||||
cv::Mat dst;
|
||||
|
||||
// Get the parameters
|
||||
int interpolation = std::get<0>(GetParam());
|
||||
int borderValue = std::get<1>(GetParam());
|
||||
|
||||
while (next())
|
||||
{
|
||||
startTimer();
|
||||
cv::fastcv::warpAffine(src, dst, inverseAffine, dsize, interpolation, borderValue);
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} //namespace
|
||||
Reference in New Issue
Block a user