From 2f5fb22935077eb5b5879b314fdf929c2d22ec1b Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 20 May 2022 23:04:27 +0800 Subject: [PATCH] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=8E=89=E8=90=BD=E8=AF=86=E5=88=AB=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 2 +- src/MeoAssistant/Controller.cpp | 4 ++-- src/MeoAssistant/Controller.h | 2 +- src/MeoAssistant/StageDropsImageAnalyzer.cpp | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 5a7fbe1505..93ca6bd26e 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -6505,7 +6505,7 @@ "roi": [ 62, 89, - 45, + 43, 23 ], "maskRange": [ diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index 98cb3fd72e..9ab6a6249f 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -368,7 +368,7 @@ void asst::Controller::clear_info() noexcept m_width = 0; m_height = 0; m_control_scale = 1.0; - m_scale_size = decltype(m_scale_size)(); + m_scale_size = { WindowWidthDefault, WindowHeightDefault }; } int asst::Controller::push_cmd(const std::string& cmd) @@ -395,7 +395,7 @@ bool asst::Controller::screencap() //if (true) { // std::unique_lock image_lock(m_image_mutex); - // m_cache_image = cv::imread("err.png"); + // m_cache_image = cv::imread("err/1.png"); // return true; //} diff --git a/src/MeoAssistant/Controller.h b/src/MeoAssistant/Controller.h index b446379ec9..47e2d117bb 100644 --- a/src/MeoAssistant/Controller.h +++ b/src/MeoAssistant/Controller.h @@ -127,7 +127,7 @@ namespace asst } m_adb; std::string m_uuid; - std::pair m_scale_size; + std::pair m_scale_size = { WindowWidthDefault, WindowHeightDefault }; double m_control_scale = 1.0; int m_width = 0; int m_height = 0; diff --git a/src/MeoAssistant/StageDropsImageAnalyzer.cpp b/src/MeoAssistant/StageDropsImageAnalyzer.cpp index 473e7a767a..5e20ae6172 100644 --- a/src/MeoAssistant/StageDropsImageAnalyzer.cpp +++ b/src/MeoAssistant/StageDropsImageAnalyzer.cpp @@ -233,7 +233,7 @@ bool asst::StageDropsImageAnalyzer::analyze_baseline() cv::inRange(gray, task_ptr->mask_range.first, task_ptr->mask_range.second, bin); cv::Rect bounding_rect = cv::boundingRect(bin); - cv::Mat bounding = bin(bounding_rect); + cv::Mat bounding = gray(bounding_rect); int x_offset = task_ptr->roi.x + bounding_rect.x; int y_offset = task_ptr->roi.y + bounding_rect.y; @@ -246,8 +246,12 @@ bool asst::StageDropsImageAnalyzer::analyze_baseline() int spacing = 0; // split + int threshold = task_ptr->mask_range.first; + uchar pre_value = 0; for (int i = 0; i < bounding.cols; ++i) { - bool is_white = bounding.at(0, i); + uchar value = bounding.at(0, i); + bool is_white = value > threshold && pre_value - value < threshold; + pre_value = value; if (in && !is_white) { in = false;