mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -104,14 +104,16 @@ struct LogTagAuto
|
||||
// non-null. Do not re-define.
|
||||
#define CV_LOGTAG_GLOBAL cv::utils::logging::internal::getGlobalLogTag()
|
||||
|
||||
#define CV_LOG_WITH_TAG(tag, msgLevel, ...) \
|
||||
#define CV_LOG_WITH_TAG(tag, msgLevel, extra_check0, extra_check1, ...) \
|
||||
for(;;) { \
|
||||
extra_check0; \
|
||||
const auto cv_temp_msglevel = (cv::utils::logging::LogLevel)(msgLevel); \
|
||||
if (cv_temp_msglevel >= (CV_LOG_STRIP_LEVEL)) break; \
|
||||
auto cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_EXPAND_NAME(tag)); \
|
||||
if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_FALLBACK); \
|
||||
if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_GLOBAL); \
|
||||
if (cv_temp_logtagptr && (cv_temp_msglevel > cv_temp_logtagptr->level)) break; \
|
||||
extra_check1; \
|
||||
std::stringstream cv_temp_logstream; \
|
||||
cv_temp_logstream << __VA_ARGS__; \
|
||||
cv::utils::logging::internal::writeLogMessageEx( \
|
||||
@@ -124,28 +126,91 @@ struct LogTagAuto
|
||||
break; \
|
||||
}
|
||||
|
||||
#define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, __VA_ARGS__)
|
||||
#define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
#define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, __VA_ARGS__)
|
||||
#define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, __VA_ARGS__)
|
||||
#define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, __VA_ARGS__)
|
||||
#define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), __VA_ARGS__)
|
||||
#define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , , __VA_ARGS__)
|
||||
#define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , , __VA_ARGS__)
|
||||
#define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , , __VA_ARGS__)
|
||||
#define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , , __VA_ARGS__)
|
||||
#define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , , __VA_ARGS__)
|
||||
#define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , , __VA_ARGS__)
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
||||
# undef CV_LOG_INFO
|
||||
# define CV_LOG_INFO(tag, ...)
|
||||
#undef CV_LOG_INFO
|
||||
#define CV_LOG_INFO(tag, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
||||
# undef CV_LOG_DEBUG
|
||||
# define CV_LOG_DEBUG(tag, ...)
|
||||
#undef CV_LOG_DEBUG
|
||||
#define CV_LOG_DEBUG(tag, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
||||
# undef CV_LOG_VERBOSE
|
||||
# define CV_LOG_VERBOSE(tag, v, ...)
|
||||
#undef CV_LOG_VERBOSE
|
||||
#define CV_LOG_VERBOSE(tag, v, ...)
|
||||
#endif
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CV__LOG_ONCE_CHECK_PRE \
|
||||
static bool _cv_log_once_ ## __LINE__ = false; \
|
||||
if (_cv_log_once_ ## __LINE__) break;
|
||||
|
||||
#define CV__LOG_ONCE_CHECK_POST \
|
||||
_cv_log_once_ ## __LINE__ = true;
|
||||
|
||||
#define CV__LOG_IF_CHECK(logging_cond) \
|
||||
if (!(logging_cond)) break;
|
||||
|
||||
//! @endcond
|
||||
|
||||
|
||||
// CV_LOG_ONCE_XXX macros
|
||||
|
||||
#define CV_LOG_ONCE_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
||||
#define CV_LOG_ONCE_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
||||
#define CV_LOG_ONCE_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
||||
#define CV_LOG_ONCE_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
||||
#define CV_LOG_ONCE_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
||||
#undef CV_LOG_ONCE_INFO
|
||||
#define CV_LOG_ONCE_INFO(tag, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
||||
#undef CV_LOG_ONCE_DEBUG
|
||||
#define CV_LOG_ONCE_DEBUG(tag, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
||||
#undef CV_LOG_ONCE_VERBOSE
|
||||
#define CV_LOG_ONCE_VERBOSE(tag, v, ...)
|
||||
#endif
|
||||
|
||||
|
||||
// CV_LOG_IF_XXX macros
|
||||
|
||||
#define CV_LOG_IF_FATAL(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
#define CV_LOG_IF_ERROR(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
#define CV_LOG_IF_WARNING(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
#define CV_LOG_IF_INFO(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
||||
#undef CV_LOG_IF_INFO
|
||||
#define CV_LOG_IF_INFO(tag, logging_cond, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
||||
#undef CV_LOG_IF_DEBUG
|
||||
#define CV_LOG_IF_DEBUG(tag, logging_cond, ...)
|
||||
#endif
|
||||
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
||||
#undef CV_LOG_IF_VERBOSE
|
||||
#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...)
|
||||
#endif
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
}}} // namespace
|
||||
|
||||
@@ -193,8 +193,8 @@ void writeLogMessage(LogLevel logLevel, const char* message)
|
||||
case LOG_LEVEL_INFO: ss << "[ INFO:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_DEBUG: ss << "[DEBUG:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_VERBOSE: ss << message << std::endl; break;
|
||||
default:
|
||||
return;
|
||||
case LOG_LEVEL_SILENT: return; // avoid compiler warning about incomplete switch
|
||||
case ENUM_LOG_LEVEL_FORCE_INT: return; // avoid compiler warning about incomplete switch
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
int android_logLevel = ANDROID_LOG_INFO;
|
||||
|
||||
@@ -117,8 +117,17 @@ public:
|
||||
|
||||
void transpose(const MatExpr& expr, MatExpr& res) const CV_OVERRIDE;
|
||||
|
||||
Size size(const MatExpr& expr) const CV_OVERRIDE
|
||||
{
|
||||
return Size(
|
||||
(expr.flags & GEMM_2_T) ? expr.b.rows : expr.b.cols,
|
||||
(expr.flags & GEMM_1_T) ? expr.a.cols : expr.a.rows
|
||||
);
|
||||
}
|
||||
|
||||
static void makeExpr(MatExpr& res, int flags, const Mat& a, const Mat& b,
|
||||
double alpha=1, const Mat& c=Mat(), double beta=1);
|
||||
|
||||
};
|
||||
|
||||
static MatOp_GEMM g_MatOp_GEMM;
|
||||
@@ -199,7 +208,7 @@ static inline bool isReciprocal(const MatExpr& e) { return isBin(e,'/') && (!e.b
|
||||
static inline bool isT(const MatExpr& e) { return e.op == &g_MatOp_T; }
|
||||
static inline bool isInv(const MatExpr& e) { return e.op == &g_MatOp_Invert; }
|
||||
static inline bool isSolve(const MatExpr& e) { return e.op == &g_MatOp_Solve; }
|
||||
static inline bool isGEMM(const MatExpr& e) { return e.op == &g_MatOp_GEMM; }
|
||||
//static inline bool isGEMM(const MatExpr& e) { return e.op == &g_MatOp_GEMM; }
|
||||
static inline bool isMatProd(const MatExpr& e) { return e.op == &g_MatOp_GEMM && (!e.c.data || e.beta == 0); }
|
||||
static inline bool isInitializer(const MatExpr& e) { return e.op == getGlobalMatOpInitializer(); }
|
||||
|
||||
@@ -1240,8 +1249,6 @@ Size MatExpr::size() const
|
||||
{
|
||||
if( isT(*this) || isInv(*this) )
|
||||
return Size(a.rows, a.cols);
|
||||
if( isGEMM(*this) )
|
||||
return Size(b.cols, a.rows);
|
||||
if( isSolve(*this) )
|
||||
return Size(b.cols, a.cols);
|
||||
if( isInitializer(*this) )
|
||||
|
||||
@@ -2019,6 +2019,29 @@ TEST(Core_MatExpr, issue_16655)
|
||||
<< "Mat: CV_8UC3 != " << typeToString(ab_mat.type());
|
||||
}
|
||||
|
||||
TEST(Core_MatExpr, issue_16689)
|
||||
{
|
||||
Mat a(Size(10, 5), CV_32FC1, 5);
|
||||
Mat b(Size(10, 5), CV_32FC1, 2);
|
||||
Mat bt(Size(5, 10), CV_32FC1, 3);
|
||||
{
|
||||
MatExpr r = a * bt; // gemm
|
||||
EXPECT_EQ(Mat(r).size(), r.size()) << "[10x5] x [5x10] => [5x5]";
|
||||
}
|
||||
{
|
||||
MatExpr r = a * b.t(); // gemm
|
||||
EXPECT_EQ(Mat(r).size(), r.size()) << "[10x5] x [10x5].t() => [5x5]";
|
||||
}
|
||||
{
|
||||
MatExpr r = a.t() * b; // gemm
|
||||
EXPECT_EQ(Mat(r).size(), r.size()) << "[10x5].t() x [10x5] => [10x10]";
|
||||
}
|
||||
{
|
||||
MatExpr r = a.t() * bt.t(); // gemm
|
||||
EXPECT_EQ(Mat(r).size(), r.size()) << "[10x5].t() x [5x10].t() => [10x10]";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
TEST(Core_Eigen, eigen2cv_check_Mat_type)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// 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 "opencv2/core/utils/logger.defines.hpp"
|
||||
#undef CV_LOG_STRIP_LEVEL
|
||||
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
||||
#include "opencv2/core/utils/logger.hpp"
|
||||
#include "opencv2/core/utils/buffer_area.private.hpp"
|
||||
|
||||
@@ -287,6 +290,53 @@ TEST(CommandLineParser, testScalar)
|
||||
EXPECT_EQ(parser.get<Scalar>("s5"), Scalar(5, -4, 3, 2));
|
||||
}
|
||||
|
||||
|
||||
TEST(Logger, DISABLED_message)
|
||||
{
|
||||
int id = 42;
|
||||
CV_LOG_VERBOSE(NULL, 0, "Verbose message: " << id);
|
||||
CV_LOG_VERBOSE(NULL, 1, "Verbose message: " << id);
|
||||
CV_LOG_DEBUG(NULL, "Debug message: " << id);
|
||||
CV_LOG_INFO(NULL, "Info message: " << id);
|
||||
CV_LOG_WARNING(NULL, "Warning message: " << id);
|
||||
CV_LOG_ERROR(NULL, "Error message: " << id);
|
||||
CV_LOG_FATAL(NULL, "Fatal message: " << id);
|
||||
}
|
||||
|
||||
static int testLoggerMessageOnce(int id)
|
||||
{
|
||||
CV_LOG_ONCE_VERBOSE(NULL, 0, "Verbose message: " << id++);
|
||||
CV_LOG_ONCE_VERBOSE(NULL, 1, "Verbose message: " << id++);
|
||||
CV_LOG_ONCE_DEBUG(NULL, "Debug message: " << id++);
|
||||
CV_LOG_ONCE_INFO(NULL, "Info message: " << id++);
|
||||
CV_LOG_ONCE_WARNING(NULL, "Warning message: " << id++);
|
||||
CV_LOG_ONCE_ERROR(NULL, "Error message: " << id++);
|
||||
// doesn't make sense: CV_LOG_ONCE_FATAL
|
||||
return id;
|
||||
}
|
||||
TEST(Logger, DISABLED_message_once)
|
||||
{
|
||||
int check_id_first = testLoggerMessageOnce(42);
|
||||
EXPECT_GT(check_id_first, 42);
|
||||
int check_id_second = testLoggerMessageOnce(0);
|
||||
EXPECT_EQ(0, check_id_second);
|
||||
}
|
||||
|
||||
TEST(Logger, DISABLED_message_if)
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
CV_LOG_IF_VERBOSE(NULL, 0, i == 0 || i == 42, "Verbose message: " << i);
|
||||
CV_LOG_IF_VERBOSE(NULL, 1, i == 0 || i == 42, "Verbose message: " << i);
|
||||
CV_LOG_IF_DEBUG(NULL, i == 0 || i == 42, "Debug message: " << i);
|
||||
CV_LOG_IF_INFO(NULL, i == 0 || i == 42, "Info message: " << i);
|
||||
CV_LOG_IF_WARNING(NULL, i == 0 || i == 42, "Warning message: " << i);
|
||||
CV_LOG_IF_ERROR(NULL, i == 0 || i == 42, "Error message: " << i);
|
||||
CV_LOG_IF_FATAL(NULL, i == 0 || i == 42, "Fatal message: " << i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Samples, findFile)
|
||||
{
|
||||
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
|
||||
|
||||
Reference in New Issue
Block a user