Skip to content

Commit

Permalink
Adding modifications in channel tests and pyramid roi as suggested by…
Browse files Browse the repository at this point in the history
… Alexander
  • Loading branch information
adsha-quic committed Mar 6, 2025
1 parent 3c63f54 commit 15ea63c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
7 changes: 2 additions & 5 deletions modules/fastcv/include/opencv2/fastcv/pyramid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ namespace fastcv {
//! @{

/**
* @brief Creates a gradient pyramid from an image pyramid.
* @brief Creates a gradient pyramid from an image pyramid
* Note: The borders are ignored during gradient calculation.
*
* @param pyr Input pyramid of 1-channel 8-bit images. Only continuous images are supported.
* @param dx Horizontal Sobel gradient pyramid of the same size as pyr
* @param dy Verical Sobel gradient pyramid of the same size as pyr
* @param outType Type of output data, can be CV_8S, CV_16S or CV_32F
* @param clearBuffers If set to 1, output buffers are set to 0 before computation, to remove garbage values.
*/
CV_EXPORTS_W void sobelPyramid(InputArrayOfArrays pyr, OutputArrayOfArrays dx, OutputArrayOfArrays dy, int outType = CV_8S,
int clearBuffers = 0);
CV_EXPORTS_W void sobelPyramid(InputArrayOfArrays pyr, OutputArrayOfArrays dx, OutputArrayOfArrays dy, int outType = CV_8S);

/**
* @brief Builds an image pyramid of float32 arising from a single
Expand Down
4 changes: 2 additions & 2 deletions modules/fastcv/perf/perf_pyramid.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -66,7 +66,7 @@ PERF_TEST_P(SobelPyramidTest, checkAllTypes,
{
std::vector<cv::Mat> pyrDx, pyrDy;
startTimer();
cv::fastcv::sobelPyramid(pyr, pyrDx, pyrDy, type, 1);
cv::fastcv::sobelPyramid(pyr, pyrDx, pyrDy, type);
stopTimer();
}

Expand Down
13 changes: 2 additions & 11 deletions modules/fastcv/src/pyramid.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand All @@ -8,7 +8,7 @@
namespace cv {
namespace fastcv {

void sobelPyramid(InputArrayOfArrays _pyr, OutputArrayOfArrays _dx, OutputArrayOfArrays _dy, int outType, int clearBuffers)
void sobelPyramid(InputArrayOfArrays _pyr, OutputArrayOfArrays _dx, OutputArrayOfArrays _dy, int outType)
{
INITIALIZATION_CHECK;

Expand Down Expand Up @@ -65,15 +65,6 @@ void sobelPyramid(InputArrayOfArrays _pyr, OutputArrayOfArrays _dx, OutputArrayO
CV_Error(cv::Error::StsInternal, cv::format("fcvPyramidAllocate returned code %d", retCodey));
}

if(clearBuffers == 1)
{
for(size_t i=0; i<nLevels; i++)
{
memset((void*)ldx[i].ptr, 0, ldx[i].width * ldx[i].height * pyrElemSz);
memset((void*)ldy[i].ptr, 0, ldy[i].width * ldy[i].height * pyrElemSz);
}
}

int returnCode = -1;
switch (outType)
{
Expand Down
4 changes: 0 additions & 4 deletions modules/fastcv/test/test_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ TEST_P(ChannelMergeTest, accuracy)
cv::merge(src_mats, ref);

double normInf = cvtest::norm(ref, dst, cv::NORM_INF);
double normL2 = cvtest::norm(ref, dst, cv::NORM_L2);

EXPECT_EQ(normInf, 0);
EXPECT_EQ(normL2, 0);
}

TEST_P(ChannelSplitTest, accuracy)
Expand All @@ -59,9 +57,7 @@ TEST_P(ChannelSplitTest, accuracy)
for(int i=0; i<cn; i++)
{
double normInf = cvtest::norm(ref_mats[i], dst_mats[i], cv::NORM_INF);
double normL2 = cvtest::norm(ref_mats[i], dst_mats[i], cv::NORM_L2);
EXPECT_EQ(normInf, 0);
EXPECT_EQ(normL2, 0);
}
}

Expand Down
11 changes: 6 additions & 5 deletions modules/fastcv/test/test_pyramid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TEST_P(SobelPyramidTest, accuracy)
cv::fastcv::buildPyramid(src, pyr, nLevels);

std::vector<cv::Mat> pyrDx, pyrDy;
cv::fastcv::sobelPyramid(pyr, pyrDx, pyrDy, type, 1);
cv::fastcv::sobelPyramid(pyr, pyrDx, pyrDy, type);

ASSERT_EQ(pyrDx.size(), nLevels);
ASSERT_EQ(pyrDy.size(), nLevels);
Expand Down Expand Up @@ -126,16 +126,17 @@ TEST_P(SobelPyramidTest, accuracy)
{
cv::Mat ref, dst;
double normInf, normL2;
ref = refPyrDx[i];
dst = pyrDx[i];
cv::Rect roi(1, 1, pyr[i].cols - 2, pyr[i].rows - 2);
ref = refPyrDx[i](roi);
dst = pyrDx[i](roi);
normInf = cvtest::norm(dst, ref, cv::NORM_INF);
normL2 = cvtest::norm(dst, ref, cv::NORM_L2) / dst.total();

EXPECT_LE(normInf, 76.1);
EXPECT_LT(normL2, 0.4);

ref = refPyrDy[i];
dst = pyrDy[i];
ref = refPyrDy[i](roi);
dst = pyrDy[i](roi);
normInf = cvtest::norm(dst, ref, cv::NORM_INF);
normL2 = cvtest::norm(dst, ref, cv::NORM_L2) / dst.total();

Expand Down

0 comments on commit 15ea63c

Please sign in to comment.