Skip to content

[hal_rvv] Add cv::integral implementation and more types of input for test #27060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 21, 2025
Prev Previous commit
Next Next commit
feat: add accuracy test of all input cases for cv::integral
Co-authored-by: Liutong HAN <liutong2020@iscas.ac.cn>
  • Loading branch information
YooLc and hanliutong committed Apr 11, 2025
commit 4539c886a749ec756eb21faab2dfd1633debdf52
35 changes: 25 additions & 10 deletions modules/imgproc/test/test_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,19 +1684,34 @@ void CV_IntegralTest::get_test_array_types_and_sizes( int test_case_idx,
vector<vector<Size> >& sizes, vector<vector<int> >& types )
{
RNG& rng = ts->get_rng();
int depth = cvtest::randInt(rng) % 2, sum_depth;
int cn = cvtest::randInt(rng) % 4 + 1;
cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
Size sum_size;

depth = depth == 0 ? CV_8U : CV_32F;
int b = (cvtest::randInt(rng) & 1) != 0;
sum_depth = depth == CV_8U && b ? CV_32S : b ? CV_32F : CV_64F;
const int depths[12][3] = {
{CV_8U, CV_32S, CV_64F},
{CV_8U, CV_32S, CV_32F},
{CV_8U, CV_32S, CV_32S},
{CV_8U, CV_32F, CV_64F},
{CV_8U, CV_32F, CV_32F},
{CV_8U, CV_64F, CV_64F},
{CV_16U, CV_64F, CV_64F},
{CV_16S, CV_64F, CV_64F},
{CV_32F, CV_32F, CV_64F},
{CV_32F, CV_32F, CV_32F},
{CV_32F, CV_64F, CV_64F},
{CV_64F, CV_64F, CV_64F},
};

int random_choice = cvtest::randInt(rng) % 12;
int depth = depths[random_choice][0];
int sum_depth = depths[random_choice][1];
int sqsum_depth = depths[random_choice][2];

types[INPUT][0] = CV_MAKETYPE(depth,cn);
types[INPUT][0] = CV_MAKETYPE(depth, cn);
types[OUTPUT][0] = types[REF_OUTPUT][0] =
types[OUTPUT][2] = types[REF_OUTPUT][2] = CV_MAKETYPE(sum_depth, cn);
types[OUTPUT][1] = types[REF_OUTPUT][1] = CV_MAKETYPE(CV_64F, cn);
types[OUTPUT][1] = types[REF_OUTPUT][1] = CV_MAKETYPE(sqsum_depth, cn);

sum_size.width = sizes[INPUT][0].width + 1;
sum_size.height = sizes[INPUT][0].height + 1;
Expand Down Expand Up @@ -1738,15 +1753,15 @@ void CV_IntegralTest::run_func()

static void test_integral( const Mat& img, Mat* sum, Mat* sqsum, Mat* tilted )
{
CV_Assert( img.depth() == CV_32F );
CV_Assert( img.depth() == CV_64F );

sum->create(img.rows+1, img.cols+1, CV_64F);
if( sqsum )
sqsum->create(img.rows+1, img.cols+1, CV_64F);
if( tilted )
tilted->create(img.rows+1, img.cols+1, CV_64F);

const float* data = img.ptr<float>();
const double* data = img.ptr<double>();
double* sdata = sum->ptr<double>();
double* sqdata = sqsum ? sqsum->ptr<double>() : 0;
double* tdata = tilted ? tilted->ptr<double>() : 0;
Expand Down Expand Up @@ -1788,7 +1803,7 @@ static void test_integral( const Mat& img, Mat* sum, Mat* sqsum, Mat* tilted )
else
{
ts += tdata[x-tstep-1];
if( data > img.ptr<float>() )
if( data > img.ptr<double>() )
{
ts += data[x-step-1];
if( x < size.width )
Expand Down Expand Up @@ -1824,7 +1839,7 @@ void CV_IntegralTest::prepare_to_validation( int /*test_case_idx*/ )
{
if( cn > 1 )
cvtest::extract(src, plane, i);
plane.convertTo(srcf, CV_32F);
plane.convertTo(srcf, CV_64F);

test_integral( srcf, &psum, sqsum0 ? &psqsum : 0, tsum0 ? &ptsum : 0 );
psum.convertTo(psum2, sum0->depth());
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy