Skip to content

Commit

Permalink
chore: 禁止cv::Mat日志刷屏
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 12, 2023
1 parent ab6e128 commit 378feff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/MaaFramework/Vision/OCRer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ OCRer::ResultsVec OCRer::predict_det_and_rec(const cv::Rect& roi) const
fastdeploy::vision::OCRResult ocr_result;
bool ret = ocrer_->Predict(image_roi, &ocr_result);
if (!ret) {
LogWarn << "inferencer return false" << VAR(ocrer_) << VAR(image_) << VAR(roi) << VAR(image_roi);
LogWarn << "inferencer return false" << VAR(ocrer_) << VAR(image_.size()) << VAR(roi) << VAR(image_roi.size());
draw_result(roi, {});
return {};
}
Expand Down Expand Up @@ -116,7 +116,7 @@ OCRer::Result OCRer::predict_only_rec(const cv::Rect& roi) const

bool ret = recer_->Predict(image_roi, &rec_text, &rec_score);
if (!ret) {
LogWarn << "recer_ return false" << VAR(recer_) << VAR(image_) << VAR(roi) << VAR(image_roi);
LogWarn << "recer_ return false" << VAR(recer_) << VAR(image_.size()) << VAR(roi) << VAR(image_roi.size());
draw_result(roi, {});
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Vision/TemplateComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MAA_VISION_NS_BEGIN
TemplateComparator::ResultsVec TemplateComparator::analyze(const cv::Mat& lhs, const cv::Mat& rhs) const
{
if (lhs.size() != rhs.size()) {
LogError << "lhs.size() != rhs.size()" << VAR(lhs) << VAR(rhs);
LogError << "lhs.size() != rhs.size()" << VAR(lhs.size()) << VAR(rhs.size());
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Vision/TemplateMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TemplateMatcher::ResultsVec TemplateMatcher::analyze() const
TemplateMatcher::ResultsVec TemplateMatcher::foreach_rois(const cv::Mat& templ) const
{
if (templ.empty()) {
LogWarn << name_ << "template is empty" << VAR(param_.template_paths) << VAR(templ);
LogWarn << name_ << "template is empty" << VAR(param_.template_paths) << VAR(templ.size());
return {};
}

Expand Down
10 changes: 9 additions & 1 deletion source/include/Utils/LoggerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include "Ranges.hpp"
#include "Time.hpp"

namespace cv
{
class Mat;
}

MAA_LOG_NS_BEGIN

#ifdef __GNUC__
Expand Down Expand Up @@ -81,7 +86,10 @@ struct StringConverter
std::string operator()(T&& value) const
{
if constexpr (std::is_function_v<std::remove_pointer_t<std::decay_t<T>>>) {
static_assert(!sizeof(T), "Function type is not supported");
static_assert(!sizeof(T), "Function type is not supported.");
}
else if constexpr (std::same_as<cv::Mat, std::decay_t<T>>) {
static_assert(!sizeof(T), "cv::Mat has too much data, don't print it!");
}
else if constexpr (std::same_as<std::filesystem::path, std::decay_t<T>>) {
return path_to_utf8_string(std::forward<T>(value));
Expand Down

0 comments on commit 378feff

Please sign in to comment.