vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
@@ -0,0 +1,60 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include <bitset>
namespace opencv_test { namespace {
class CV_AverageHashTest : public cvtest::BaseTest
{
public:
CV_AverageHashTest();
~CV_AverageHashTest();
protected:
void run(int /* idx */);
};
CV_AverageHashTest::CV_AverageHashTest(){}
CV_AverageHashTest::~CV_AverageHashTest(){}
void CV_AverageHashTest::run(int )
{
cv::Mat const input = (cv::Mat_<uchar>(8, 8) <<
1, 5, 4, 6, 3, 2, 7, 8,
2, 4, 8, 9, 2, 1, 4, 3,
3, 4, 5, 7, 9, 8, 7, 6,
1, 2, 3, 4, 5, 6, 7, 8,
8, 7, 2, 3, 6, 4, 5, 1,
3, 4, 1, 2, 9, 8, 4, 2,
6, 7, 8, 9, 7, 4, 3, 2,
8, 7, 6, 5, 4, 3, 2, 1);
cv::Mat hash;
cv::img_hash::averageHash(input, hash);
bool const expectResult[] =
{
0,0,0,1,0,0,1,1,
0,0,1,1,0,0,0,0,
0,0,0,1,1,1,1,1,
0,0,0,0,0,1,1,1,
1,1,0,0,1,0,0,0,
0,0,0,0,1,1,0,0,
1,1,1,1,1,0,0,0,
1,1,1,0,0,0,0,0
};
uchar const *hashPtr = hash.ptr<uchar>(0);
for(int i = 0; i != hash.cols; ++i)
{
std::bitset<8> const bits = hashPtr[i];
for(int j = 0; j != 8; ++j)
{
EXPECT_EQ(bits[j], expectResult[i*8+j]);
}
}
}
TEST(average_hash_test, accuracy) { CV_AverageHashTest test; test.safe_run(); }
}} // namespace
@@ -0,0 +1,214 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include <bitset>
namespace opencv_test { namespace {
using namespace cv::img_hash;
/**
*The expected results of this test case are come from the Phash library,
*I use it as golden model
*/
class CV_BlockMeanHashTest : public cvtest::BaseTest
{
public:
CV_BlockMeanHashTest();
protected:
void run(int /* idx */);
void testMeanMode0();
void testMeanMode1();
void testHashMode0();
void testHashMode1();
cv::Mat input;
cv::Mat hash;
Ptr<cv::img_hash::BlockMeanHash> bmh;
};
CV_BlockMeanHashTest::CV_BlockMeanHashTest()
{
input.create(256, 256, CV_8U);
for(int row = 0; row != input.rows; ++row)
{
uchar value = static_cast<uchar>(row);
for(int col = 0; col != input.cols; ++col)
{
input.at<uchar>(row, col) = value++;
}
}
bmh = BlockMeanHash::create(BLOCK_MEAN_HASH_MODE_0);
}
void CV_BlockMeanHashTest::testMeanMode0()
{
std::vector<double> const &features = bmh->getMean();
double const expectResult[] =
{15,31,47,63,79,95,111,127,143,159,175,191,207,223,239,135,
31,47,63,79,95,111,127,143,159,175,191,207,223,239,135,15,
47,63,79,95,111,127,143,159,175,191,207,223,239,135,15,31,
63,79,95,111,127,143,159,175,191,207,223,239,135,15,31,47,
79,95,111,127,143,159,175,191,207,223,239,135,15,31,47,63,
95,111,127,143,159,175,191,207,223,239,135,15,31,47,63,79,
111,127,143,159,175,191,207,223,239,135,15,31,47,63,79,95,
127,143,159,175,191,207,223,239,135,15,31,47,63,79,95,111,
143,159,175,191,207,223,239,135,15,31,47,63,79,95,111,127,
159,175,191,207,223,239,135,15,31,47,63,79,95,111,127,143,
175,191,207,223,239,135,15,31,47,63,79,95,111,127,143,159,
191,207,223,239,135,15,31,47,63,79,95,111,127,143,159,175,
207,223,239,135,15,31,47,63,79,95,111,127,143,159,175,191,
223,239,135,15,31,47,63,79,95,111,127,143,159,175,191,207,
239,135,15,31,47,63,79,95,111,127,143,159,175,191,207,223,
135,15,31,47,63,79,95,111,127,143,159,175,191,207,223,239,};
for(size_t i = 0; i != features.size(); ++i)
{
ASSERT_NEAR(features[i], expectResult[i], 0.0001);
}
}
void CV_BlockMeanHashTest::testMeanMode1()
{
std::vector<double> const &features = bmh->getMean();
double const expectResult[] =
{15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,
23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,
31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,
39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,
47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,
55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,
63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,
71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,
79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,
87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,
95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,
103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,
111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,
119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,
127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,
135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,
143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,
151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,
159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,
167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,
175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,
183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,
191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,
199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,
207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,
215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,
223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,
231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,
239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,
219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,
135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,};
for(size_t i = 0; i != features.size(); ++i)
{
ASSERT_NEAR(features[i], expectResult[i], 0.0001);
}
}
void CV_BlockMeanHashTest::testHashMode0()
{
bool const expectResult[] =
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,
0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,
0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,
1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,
1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,
1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
};
for(int i = 0; i != hash.cols; ++i)
{
std::bitset<8> const bits = hash.at<uchar>(0, i);
for(size_t j = 0; j != bits.size(); ++j)
{
EXPECT_EQ(expectResult[i*8+j], bits[j]);
}
}
}
void CV_BlockMeanHashTest::testHashMode1()
{
bool const expectResult[] =
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
};
for(int i = 0; i != hash.cols; ++i)
{
std::bitset<8> const bits = hash.at<uchar>(0, i);
if(i != hash.cols-1)
{
for(size_t j = 0; j != bits.size(); ++j)
{
EXPECT_EQ(expectResult[i*8+j], bits[j]);
}
}
else
{
//when mode == 1, there will be 961 block mean
//that is why we only check one bit at here
EXPECT_EQ(expectResult[i*8], bits[0]);
}
}
}
void CV_BlockMeanHashTest::run(int)
{
bmh->compute(input, hash);
testMeanMode0();
testHashMode0();
bmh->setMode(BLOCK_MEAN_HASH_MODE_1);
bmh->compute(input, hash);
testMeanMode1();
testHashMode1();
}
TEST(block_mean_hash_test, accuracy) { CV_BlockMeanHashTest test; test.safe_run(); }
}} // namespace
+7
View File
@@ -0,0 +1,7 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")
@@ -0,0 +1,62 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace opencv_test { namespace {
class CV_MarrHildrethTest : public cvtest::BaseTest
{
public:
CV_MarrHildrethTest();
~CV_MarrHildrethTest();
protected:
void run(int /* idx */);
};
CV_MarrHildrethTest::CV_MarrHildrethTest(){}
CV_MarrHildrethTest::~CV_MarrHildrethTest(){}
void CV_MarrHildrethTest::run(int )
{
cv::Mat_<uchar> input(512,512);
int val = 0;
for(int row = 0; row != input.rows; ++row)
{
for(int col = 0; col != input.cols; ++col)
{
input.at<uchar>(row, col) = val % 256;
++val;
}
}
cv::Mat hash;
cv::img_hash::marrHildrethHash(input, hash);
uchar const expectResult[] =
{
252, 126, 63, 31, 143, 199, 227, 241,
248, 252, 126, 63, 31, 143, 199, 227,
241, 248, 252, 126, 63, 31, 143, 199,
227, 241, 248, 252, 126, 63, 31, 143,
199, 227, 241, 248, 31, 143, 199, 227,
241, 248, 252, 126, 63, 252, 126, 63,
31, 143, 199, 227, 241, 248, 252, 126,
63, 31, 143, 199, 227, 241, 248, 252,
126, 63, 31, 143, 199, 227, 241, 248
};
uchar const *hashPtr = hash.ptr<uchar>(0);
for(int i = 0; i != 72; ++i)
{
if(hashPtr[i] != expectResult[i])
{
ts->printf(cvtest::TS::LOG, "Wrong hash value \n");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
return;
}
}
}
TEST(marr_hildreth_test, accuracy) { CV_MarrHildrethTest test; test.safe_run(); }
}} // namespace
+60
View File
@@ -0,0 +1,60 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include <bitset>
namespace opencv_test { namespace {
class CV_PHashTest : public cvtest::BaseTest
{
public:
CV_PHashTest();
~CV_PHashTest();
protected:
void run(int /* idx */);
};
CV_PHashTest::CV_PHashTest(){}
CV_PHashTest::~CV_PHashTest(){}
void CV_PHashTest::run(int )
{
cv::Mat input(32, 32, CV_8U);
cv::Mat hash;
uchar value = 0;
uchar *inPtr = input.ptr<uchar>(0);
for(size_t i = 0; i != 32*32; ++i)
{
inPtr[i] = value++;
}
cv::img_hash::pHash(input, hash);
bool const expectResult[] =
{
1,0,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,
};
uchar const *hashPtr = hash.ptr<uchar>(0);
for(int i = 0; i != hash.cols; ++i)
{
std::bitset<8> const bits = hashPtr[i];
for(int j = 0; j != 8; ++j)
{
EXPECT_EQ(bits[j], expectResult[i*8+j]);
}
}
}
TEST(average_phash_test, accuracy) { CV_PHashTest test; test.safe_run(); }
}} // namespace
+10
View File
@@ -0,0 +1,10 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include "opencv2/ts.hpp"
#include "opencv2/img_hash.hpp"
#endif
@@ -0,0 +1,154 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace opencv_test { namespace {
using namespace cv::img_hash;
/**
*The expected results of this test case are come from the phash library,
*I use it as golden model
*/
class CV_RadialVarianceHashTest : public cvtest::BaseTest
{
public:
CV_RadialVarianceHashTest();
protected:
void run(int /* idx */);
//this test case do not use the original "golden data"
//of pHash library, I add a small value to nb_pixels in
//the function "ph_feature_vector" to avoid NaN value
void testComputeHash();
void testFeatures();
//void testHash(); // TODO unused
void testPixPerLine();
void testProjection();
cv::Mat input;
Ptr<cv::img_hash::RadialVarianceHash> rvh;
};
CV_RadialVarianceHashTest::CV_RadialVarianceHashTest()
{
input.create(8, 8, CV_8U);
uchar *inPtr = input.ptr<uchar>(0);
for(size_t i = 0; i != input.total(); ++i)
{
inPtr[i] = static_cast<uchar>(i);
}
rvh = RadialVarianceHash::create(1, 10);
}
void CV_RadialVarianceHashTest::testComputeHash()
{
cv::Mat hashOne(1, 40, CV_8U);
uchar buffer[] =
{
52, 41, 49, 64, 40, 67, 76, 71, 69,
55, 58, 68, 72, 78, 63, 73, 66, 77,
60, 57, 48, 59, 62, 74, 70, 47, 46,
51, 45, 44, 42, 61, 54, 75, 50, 79,
65, 43, 53, 56
};
cv::Mat hashTwo(1, 40, CV_8U, buffer);
for(uchar i = 0; i != 40; ++i)
{
hashOne.at<uchar>(0, i) = i;
}
double const actual = rvh->compare(hashOne, hashTwo);
ASSERT_NEAR(0.481051, actual, 0.0001);
}
void CV_RadialVarianceHashTest::testFeatures()
{
std::vector<double> const &features = rvh->getFeatures();
double const expectResult[] =
{-1.35784,-0.42703,0.908487,-1.39327,1.17313,
1.47515,-0.0156121,0.774335,-0.116755,-1.02059};
for(size_t i = 0; i != features.size(); ++i)
{
ASSERT_NEAR(features[i], expectResult[i], 0.0001);
}
}
#if 0 // unused
void CV_RadialVarianceHashTest::testHash()
{
cv::Mat const hash = rvh->getHash();
uchar const expectResult[] =
{
127, 92, 0, 158, 101,
88, 14, 136, 227, 160,
127, 94, 27, 118, 240,
166, 153, 96, 254, 162,
127, 162, 255, 96, 153,
166, 240, 118, 27, 94,
127, 160, 227, 136, 14,
88, 101, 158, 0, 92
};
for(int i = 0; i != hash.cols; ++i)
{
EXPECT_EQ(hash.at<uchar>(0, i), expectResult[i]);
}
}
#endif
void CV_RadialVarianceHashTest::testPixPerLine()
{
cv::Mat const pixPerLine = rvh->getPixPerLine(input);
uchar const expectResult[] =
{
8,8,8,0,8,15,7,5,8,8,
};
bool const equal =
std::equal(expectResult, expectResult + pixPerLine.total(),
pixPerLine.ptr<int>(0));
if(equal == false)
{
ts->printf(cvtest::TS::LOG, "Wrong pixel per line value \n");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
}
}
void CV_RadialVarianceHashTest::testProjection()
{
cv::Mat const proj = rvh->getProjection();
uchar const expectResult[] =
{
32, 33, 34, 35, 36, 37, 38, 39,
16, 17, 18, 27, 36, 37, 46, 47,
0, 9, 18, 19, 36, 45, 46, 55,
0, 0, 0, 0, 0, 0, 0, 0,
2, 10, 18, 27, 36, 44, 53, 61,
4, 59, 51, 44, 36, 29, 22, 14,
0, 58, 51, 43, 36, 30, 22, 15,
0, 0, 58, 43, 36, 21, 6, 0,
56, 49, 42, 43, 36, 21, 22, 15,
40, 41, 42, 35, 36, 29, 22, 23
};
bool const equal =
std::equal(expectResult, expectResult + proj.total(),
proj.ptr<uchar>(0));
if(equal == false)
{
ts->printf(cvtest::TS::LOG, "Wrong projection value \n");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
}
}
void CV_RadialVarianceHashTest::run(int)
{
testPixPerLine();
testProjection();
testFeatures();
testComputeHash();
}
TEST(radial_variance_hash_test, accuracy) { CV_RadialVarianceHashTest test; test.safe_run(); }
}} // namespace