From b8354bd1c22a5cff830033ac86f77be4e0287252 Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 4 Mar 2024 00:28:07 +0800 Subject: [PATCH] fix: testing error --- source/MaaFramework/Instance/InstanceStatus.cpp | 6 ++---- source/MaaFramework/Task/SyncContext.cpp | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/MaaFramework/Instance/InstanceStatus.cpp b/source/MaaFramework/Instance/InstanceStatus.cpp index 31c1787e5..c0b91ade5 100644 --- a/source/MaaFramework/Instance/InstanceStatus.cpp +++ b/source/MaaFramework/Instance/InstanceStatus.cpp @@ -118,10 +118,8 @@ bool InstanceStatus::cv_mat_equal(const cv::Mat& lhs, const cv::Mat& rhs) if (lhs.cols != rhs.cols || lhs.rows != rhs.rows || lhs.dims != rhs.dims) { return false; } - cv::Mat diff; - cv::compare(lhs, rhs, diff, cv::CMP_NE); - int nz = cv::countNonZero(diff); - return nz == 0; + + return std::equal(lhs.begin(), lhs.end(), rhs.begin()); } MAA_NS_END diff --git a/source/MaaFramework/Task/SyncContext.cpp b/source/MaaFramework/Task/SyncContext.cpp index 771bc5a64..45765bb0d 100644 --- a/source/MaaFramework/Task/SyncContext.cpp +++ b/source/MaaFramework/Task/SyncContext.cpp @@ -44,6 +44,10 @@ bool SyncContext::run_recognizer(cv::Mat image, std::string task, std::string_vi LogError << "Instance is null"; return false; } + if (image.empty()) { + LogError << "Image is empty"; + return false; + } auto json_opt = json::parse(param); if (!json_opt) {