mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
// 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 <atomic>
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
namespace opencv_test {
|
||||
namespace {
|
||||
|
||||
using namespace cv::utils::logging;
|
||||
using namespace cv::utils::logging::internal;
|
||||
|
||||
TEST(Core_Logger_Replace, WriteLogMessageRestoreCallWithNullOk)
|
||||
{
|
||||
replaceWriteLogMessage(nullptr);
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
TEST(Core_Logger_Replace, WriteLogMessageExRestoreCallWithNullOk)
|
||||
{
|
||||
replaceWriteLogMessageEx(nullptr);
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 1000, "func", "msg");
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
std::atomic<uint32_t>& getCallFlagger()
|
||||
{
|
||||
static std::atomic<uint32_t> callFlagger(0);
|
||||
return callFlagger;
|
||||
}
|
||||
|
||||
std::atomic<uint32_t>& getCallCounter()
|
||||
{
|
||||
static std::atomic<uint32_t> callCounter(0);
|
||||
return callCounter;
|
||||
}
|
||||
|
||||
void myWriteLogMessage(LogLevel, const char*)
|
||||
{
|
||||
getCallFlagger().fetch_or(1024u);
|
||||
getCallCounter().fetch_add(1u);
|
||||
}
|
||||
|
||||
void myWriteLogMessageEx(LogLevel, const char*, const char*, int, const char*, const char*)
|
||||
{
|
||||
getCallFlagger().fetch_or(2048u);
|
||||
getCallCounter().fetch_add(1u);
|
||||
}
|
||||
|
||||
TEST(Core_Logger_Replace, WriteLogMessageReplaceRestore)
|
||||
{
|
||||
uint32_t step_0 = getCallCounter().load();
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
uint32_t step_1 = getCallCounter().load();
|
||||
EXPECT_EQ(step_0, step_1);
|
||||
replaceWriteLogMessage(nullptr);
|
||||
uint32_t step_2 = getCallCounter().load();
|
||||
EXPECT_EQ(step_1, step_2);
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
uint32_t step_3 = getCallCounter().load();
|
||||
EXPECT_EQ(step_2, step_3);
|
||||
replaceWriteLogMessage(myWriteLogMessage);
|
||||
uint32_t step_4 = getCallCounter().load();
|
||||
EXPECT_EQ(step_3, step_4);
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
uint32_t step_5 = getCallCounter().load();
|
||||
EXPECT_EQ(step_4 + 1, step_5);
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
uint32_t step_6 = getCallCounter().load();
|
||||
EXPECT_EQ(step_5 + 1, step_6);
|
||||
replaceWriteLogMessage(nullptr);
|
||||
uint32_t step_7 = getCallCounter().load();
|
||||
EXPECT_EQ(step_6, step_7);
|
||||
writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, "msg");
|
||||
uint32_t step_8 = getCallCounter().load();
|
||||
EXPECT_EQ(step_7, step_8);
|
||||
uint32_t flags = getCallFlagger().load();
|
||||
EXPECT_NE(flags & 1024u, 0u);
|
||||
}
|
||||
|
||||
TEST(Core_Logger_Replace, WriteLogMessageExReplaceRestore)
|
||||
{
|
||||
uint32_t step_0 = getCallCounter().load();
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 0, "func", "msg");
|
||||
uint32_t step_1 = getCallCounter().load();
|
||||
EXPECT_EQ(step_0, step_1);
|
||||
replaceWriteLogMessageEx(nullptr);
|
||||
uint32_t step_2 = getCallCounter().load();
|
||||
EXPECT_EQ(step_1, step_2);
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 0, "func", "msg");
|
||||
uint32_t step_3 = getCallCounter().load();
|
||||
EXPECT_EQ(step_2, step_3);
|
||||
replaceWriteLogMessageEx(myWriteLogMessageEx);
|
||||
uint32_t step_4 = getCallCounter().load();
|
||||
EXPECT_EQ(step_3, step_4);
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 0, "func", "msg");
|
||||
uint32_t step_5 = getCallCounter().load();
|
||||
EXPECT_EQ(step_4 + 1, step_5);
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 0, "func", "msg");
|
||||
uint32_t step_6 = getCallCounter().load();
|
||||
EXPECT_EQ(step_5 + 1, step_6);
|
||||
replaceWriteLogMessageEx(nullptr);
|
||||
uint32_t step_7 = getCallCounter().load();
|
||||
EXPECT_EQ(step_6, step_7);
|
||||
writeLogMessageEx(cv::utils::logging::LOG_LEVEL_DEBUG, "tag", "file", 0, "func", "msg");
|
||||
uint32_t step_8 = getCallCounter().load();
|
||||
EXPECT_EQ(step_7, step_8);
|
||||
uint32_t flags = getCallFlagger().load();
|
||||
EXPECT_NE(flags & 2048u, 0u);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -1208,6 +1208,42 @@ TEST(Core_Mat, reshape_ndims_4)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_Mat, reinterpret_Mat_8UC3_8SC3)
|
||||
{
|
||||
cv::Mat A(8, 16, CV_8UC3, cv::Scalar(1, 2, 3));
|
||||
cv::Mat B = A.reinterpret(CV_8SC3);
|
||||
|
||||
EXPECT_EQ(A.data, B.data);
|
||||
EXPECT_EQ(B.type(), CV_8SC3);
|
||||
}
|
||||
|
||||
TEST(Core_Mat, reinterpret_Mat_8UC4_32FC1)
|
||||
{
|
||||
cv::Mat A(8, 16, CV_8UC4, cv::Scalar(1, 2, 3, 4));
|
||||
cv::Mat B = A.reinterpret(CV_32FC1);
|
||||
|
||||
EXPECT_EQ(A.data, B.data);
|
||||
EXPECT_EQ(B.type(), CV_32FC1);
|
||||
}
|
||||
|
||||
TEST(Core_Mat, reinterpret_OutputArray_8UC3_8SC3) {
|
||||
cv::Mat A(8, 16, CV_8UC3, cv::Scalar(1, 2, 3));
|
||||
cv::OutputArray C(A);
|
||||
cv::Mat B = C.reinterpret(CV_8SC3);
|
||||
|
||||
EXPECT_EQ(A.data, B.data);
|
||||
EXPECT_EQ(B.type(), CV_8SC3);
|
||||
}
|
||||
|
||||
TEST(Core_Mat, reinterpret_OutputArray_8UC4_32FC1) {
|
||||
cv::Mat A(8, 16, CV_8UC4, cv::Scalar(1, 2, 3, 4));
|
||||
cv::OutputArray C(A);
|
||||
cv::Mat B = C.reinterpret(CV_32FC1);
|
||||
|
||||
EXPECT_EQ(A.data, B.data);
|
||||
EXPECT_EQ(B.type(), CV_32FC1);
|
||||
}
|
||||
|
||||
TEST(Core_Mat, push_back)
|
||||
{
|
||||
Mat a = (Mat_<float>(1,2) << 3.4884074f, 1.4159607f);
|
||||
|
||||
@@ -1214,7 +1214,7 @@ bool CV_OperationsTest::TestSVD()
|
||||
cvtest::norm(Vt*Vt.t(), I, NORM_INF) > FLT_EPSILON ||
|
||||
W.at<float>(2) < 0 || W.at<float>(1) < W.at<float>(2) ||
|
||||
W.at<float>(0) < W.at<float>(1) ||
|
||||
cvtest::norm(U*Mat::diag(W)*Vt, Q, NORM_INF) > FLT_EPSILON )
|
||||
cvtest::norm(U*Mat::diag(W)*Vt, Q, NORM_INF) > FLT_EPSILON*2 )
|
||||
throw test_excep();
|
||||
}
|
||||
catch(const test_excep&)
|
||||
|
||||
Reference in New Issue
Block a user