1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Alekhin
2022-02-22 19:33:07 +00:00
256 changed files with 10503 additions and 5119 deletions
+8 -8
View File
@@ -1819,8 +1819,8 @@ OCL_TEST_P(ReduceSum, Mat)
{
generateTestData();
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_SUM, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_SUM, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_SUM, dtype));
double eps = ddepth <= CV_32S ? 1 : 7e-4;
OCL_EXPECT_MATS_NEAR(dst, eps);
@@ -1835,8 +1835,8 @@ OCL_TEST_P(ReduceMax, Mat)
{
generateTestData();
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_MAX, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_MAX, dtype));
OCL_EXPECT_MATS_NEAR(dst, 0);
}
@@ -1850,8 +1850,8 @@ OCL_TEST_P(ReduceMin, Mat)
{
generateTestData();
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_MIN, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_MIN, dtype));
OCL_EXPECT_MATS_NEAR(dst, 0);
}
@@ -1865,8 +1865,8 @@ OCL_TEST_P(ReduceAvg, Mat)
{
generateTestData();
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_AVG, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_AVG, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_AVG, dtype));
double eps = ddepth <= CV_32S ? 1 : 6e-6;
OCL_EXPECT_MATS_NEAR(dst, eps);
+24
View File
@@ -1918,5 +1918,29 @@ TEST(Core_InputOutput, FileStorage_16F_json)
test_20279(fs);
}
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_YAML)
{
FileStorage fs("invalid_path/test.yaml", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_XML)
{
FileStorage fs("invalid_path/test.xml", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_JSON)
{
FileStorage fs("invalid_path/test.json", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
}} // namespace
+17 -17
View File
@@ -93,7 +93,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
{
int srcType = src.type();
bool support = false;
if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )
if( opType == REDUCE_SUM || opType == REDUCE_AVG )
{
if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) )
support = true;
@@ -106,7 +106,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( srcType == CV_64F && dstType == CV_64F)
support = true;
}
else if( opType == CV_REDUCE_MAX )
else if( opType == REDUCE_MAX )
{
if( srcType == CV_8U && dstType == CV_8U )
support = true;
@@ -115,7 +115,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( srcType == CV_64F && dstType == CV_64F )
support = true;
}
else if( opType == CV_REDUCE_MIN )
else if( opType == REDUCE_MIN )
{
if( srcType == CV_8U && dstType == CV_8U)
support = true;
@@ -128,7 +128,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
return cvtest::TS::OK;
double eps = 0.0;
if ( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )
if ( opType == REDUCE_SUM || opType == REDUCE_AVG )
{
if ( dstType == CV_32F )
eps = 1.e-5;
@@ -152,10 +152,10 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( check )
{
char msg[100];
const char* opTypeStr = opType == CV_REDUCE_SUM ? "CV_REDUCE_SUM" :
opType == CV_REDUCE_AVG ? "CV_REDUCE_AVG" :
opType == CV_REDUCE_MAX ? "CV_REDUCE_MAX" :
opType == CV_REDUCE_MIN ? "CV_REDUCE_MIN" : "unknown operation type";
const char* opTypeStr = opType == REDUCE_SUM ? "REDUCE_SUM" :
opType == REDUCE_AVG ? "REDUCE_AVG" :
opType == REDUCE_MAX ? "REDUCE_MAX" :
opType == REDUCE_MIN ? "REDUCE_MIN" : "unknown operation type";
string srcTypeStr, dstTypeStr;
getMatTypeStr( src.type(), srcTypeStr );
getMatTypeStr( dstType, dstTypeStr );
@@ -195,19 +195,19 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
CV_Assert( 0 );
// 1. sum
tempCode = checkOp( src, dstType, CV_REDUCE_SUM, sum, dim );
tempCode = checkOp( src, dstType, REDUCE_SUM, sum, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 2. avg
tempCode = checkOp( src, dstType, CV_REDUCE_AVG, avg, dim );
tempCode = checkOp( src, dstType, REDUCE_AVG, avg, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 3. max
tempCode = checkOp( src, dstType, CV_REDUCE_MAX, max, dim );
tempCode = checkOp( src, dstType, REDUCE_MAX, max, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 4. min
tempCode = checkOp( src, dstType, CV_REDUCE_MIN, min, dim );
tempCode = checkOp( src, dstType, REDUCE_MIN, min, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
return code;
@@ -315,7 +315,7 @@ TEST(Core_PCA, accuracy)
Mat rBackPrjTestPoints = rPCA.backProject( rPrjTestPoints );
Mat avg(1, sz.width, CV_32FC1 );
cv::reduce( rPoints, avg, 0, CV_REDUCE_AVG );
cv::reduce( rPoints, avg, 0, REDUCE_AVG );
Mat Q = rPoints - repeat( avg, rPoints.rows, 1 ), Qt = Q.t(), eval, evec;
Q = Qt * Q;
Q = Q /(float)rPoints.rows;
@@ -1559,10 +1559,10 @@ TEST(Reduce, regression_should_fail_bug_4594)
cv::Mat src = cv::Mat::eye(4, 4, CV_8U);
std::vector<int> dst;
EXPECT_THROW(cv::reduce(src, dst, 0, CV_REDUCE_MIN, CV_32S), cv::Exception);
EXPECT_THROW(cv::reduce(src, dst, 0, CV_REDUCE_MAX, CV_32S), cv::Exception);
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_SUM, CV_32S));
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_AVG, CV_32S));
EXPECT_THROW(cv::reduce(src, dst, 0, REDUCE_MIN, CV_32S), cv::Exception);
EXPECT_THROW(cv::reduce(src, dst, 0, REDUCE_MAX, CV_32S), cv::Exception);
EXPECT_NO_THROW(cv::reduce(src, dst, 0, REDUCE_SUM, CV_32S));
EXPECT_NO_THROW(cv::reduce(src, dst, 0, REDUCE_AVG, CV_32S));
}
TEST(Mat, push_back_vector)
+1 -1
View File
@@ -3023,7 +3023,7 @@ TEST(CovariationMatrixVectorOfMatWithMean, accuracy)
cv::randu(src,cv::Scalar(-128), cv::Scalar(128));
cv::Mat goldMean;
cv::reduce(src,goldMean,0 ,CV_REDUCE_AVG, CV_32F);
cv::reduce(src,goldMean,0 ,REDUCE_AVG, CV_32F);
cv::calcCovarMatrix(src,gold,goldMean,singleMatFlags,CV_32F);
+65
View File
@@ -4,6 +4,15 @@
#include "test_precomp.hpp"
#include <cmath>
#include "opencv2/core/utils/logger.hpp"
#include <opencv2/core/utils/fp_control_utils.hpp>
#ifdef CV_CXX11
#include <chrono>
#include <thread>
#endif
namespace opencv_test { namespace {
TEST(Core_OutputArrayCreate, _1997)
@@ -243,6 +252,62 @@ TEST(Core_Parallel, propagate_exceptions)
}, cv::Exception);
}
class FPDenormalsHintCheckerParallelLoopBody : public cv::ParallelLoopBody
{
public:
FPDenormalsHintCheckerParallelLoopBody()
: isOK(true)
{
state_values_to_check = cv::details::saveFPDenormalsState(base_state);
}
~FPDenormalsHintCheckerParallelLoopBody() {}
void operator()(const cv::Range& r) const
{
CV_UNUSED(r);
cv::details::FPDenormalsModeState state;
if (cv::details::saveFPDenormalsState(state))
{
for (int i = 0; i < state_values_to_check; ++i)
{
if (base_state.reserved[i] != state.reserved[i])
{
CV_LOG_ERROR(NULL, cv::format("FP state[%d] mismatch: base=0x%08x thread=0x%08x", i, base_state.reserved[i], state.reserved[i]));
isOK = false;
cv::details::restoreFPDenormalsState(base_state);
}
}
}
else
{
// FP state is not supported
// no checks
}
#ifdef CV_CXX11
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#endif
}
cv::details::FPDenormalsModeState base_state;
int state_values_to_check;
mutable bool isOK;
};
TEST(Core_Parallel, propagate_fp_denormals_ignore_hint)
{
int nThreads = std::max(1, cv::getNumThreads()) * 3;
for (int i = 0; i < 4; ++i)
{
SCOPED_TRACE(cv::format("Case=%d: FP denormals ignore hint: %s\n", i, ((i & 1) != 0) ? "enable" : "disable"));
FPDenormalsIgnoreHintScope fp_denormals_scope((i & 1) != 0);
FPDenormalsHintCheckerParallelLoopBody job;
ASSERT_NO_THROW({
parallel_for_(cv::Range(0, nThreads), job);
});
EXPECT_TRUE(job.isOK);
}
}
TEST(Core_Version, consistency)
{
// this test verifies that OpenCV version loaded in runtime
-3
View File
@@ -6,9 +6,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/ts/ocl_test.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/core/cvdef.h"
#include "opencv2/core/private.hpp"
#include "opencv2/core/hal/hal.hpp"
+2 -2
View File
@@ -1398,8 +1398,8 @@ TEST(UMat, testTempObjects_Mat_issue_8693)
randu(srcUMat, -1.f, 1.f);
srcUMat.copyTo(srcMat);
reduce(srcUMat, srcUMat, 0, CV_REDUCE_SUM);
reduce(srcMat, srcMat, 0, CV_REDUCE_SUM);
reduce(srcUMat, srcUMat, 0, REDUCE_SUM);
reduce(srcMat, srcMat, 0, REDUCE_SUM);
srcUMat.convertTo(srcUMat, CV_64FC1);
srcMat.convertTo(srcMat, CV_64FC1);