From 0afda9211dbcf97d6e77a3b5885e2956f87ccc8c Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 5 Sep 2021 22:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=BF=E8=88=8D=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E2=80=9C=E4=BC=91=E6=81=AF=E4=B8=AD=E2=80=9D=E5=B9=B2?= =?UTF-8?q?=E5=91=98=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MeoAssistance/Identify.cpp | 7 +- MeoAssistance/InfrastDormTask.cpp | 118 +++++++++++++++++++++++++- MeoAssistance/InfrastDormTask.h | 9 ++ MeoAssistance/OcrAbstractTask.cpp | 4 +- MeoAssistance/OcrAbstractTask.h | 2 +- resource/template/special/Resting.png | Bin 0 -> 5115 bytes 6 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 resource/template/special/Resting.png diff --git a/MeoAssistance/Identify.cpp b/MeoAssistance/Identify.cpp index f7ebb0b160..a043a9760c 100644 --- a/MeoAssistance/Identify.cpp +++ b/MeoAssistance/Identify.cpp @@ -330,14 +330,15 @@ std::vector asst::Identify::find_all_images( bool need_push = true; // 如果有两个点离得太近,只取里面得分高的那个 // 一般相邻的都是刚刚push进去的,这里倒序快一点 + constexpr static int MinDistance = 10; for (auto iter = results.rbegin(); iter != results.rend(); ++ iter) { - if (std::abs(j - iter->rect.x) < 5 - || std::abs(i - iter->rect.y) < 5) { + if (std::abs(j - iter->rect.x) < MinDistance + && std::abs(i - iter->rect.y) < MinDistance) { if (iter->score < value) { iter->rect = rect; iter->score = value; - need_push = false; } // else 这个点就放弃了 + need_push = false; break; } } diff --git a/MeoAssistance/InfrastDormTask.cpp b/MeoAssistance/InfrastDormTask.cpp index a0622b1bc6..720ed8fd2c 100644 --- a/MeoAssistance/InfrastDormTask.cpp +++ b/MeoAssistance/InfrastDormTask.cpp @@ -1,9 +1,13 @@ #include "InfrastDormTask.h" +#include +#include + #include #include "WinMacro.h" #include "Identify.h" +#include "Configer.h" using namespace asst; @@ -22,8 +26,12 @@ bool asst::InfrastDormTask::run() m_callback(AsstMsg::PtrIsNull, json::value(), m_callback_arg); return false; } - - enter_dorm(2); + + enter_dorm(0); + sleep(1000); + enter_operator_selection(); + sleep(1000); + clear_and_select_the_resting(); return true; } @@ -32,7 +40,6 @@ bool asst::InfrastDormTask::enter_dorm(int index) { cv::Mat image = get_format_image(); // 普通的和mini的,正常情况应该只有一个有结果,另一个是empty - // 为了防止识别漏了,这里阈值先放低一点 auto dorm_result = m_identify_ptr->find_all_images(image, "Dorm", 0.8); auto dorm_mini_result = m_identify_ptr->find_all_images(image, "DormMini", 0.8); @@ -60,3 +67,108 @@ bool asst::InfrastDormTask::enter_dorm(int index) return false; } + +bool asst::InfrastDormTask::enter_next_dorm() +{ + static const Rect swipe_down_begin( // 向下滑动起点 + Configer::WindowWidthDefault * 0.3, + Configer::WindowHeightDefault * 0.8, + Configer::WindowWidthDefault * 0.2, + Configer::WindowWidthDefault * 0.1); + static const Rect swipe_down_end( // 向下滑动终点 + Configer::WindowWidthDefault * 0.3, + Configer::WindowHeightDefault * 0.2, + Configer::WindowWidthDefault * 0.2, + Configer::WindowWidthDefault * 0.1); + + static const int swipe_dwon_duration = 1000; // 向下滑动持续时间 + + m_control_ptr->swipe(swipe_down_begin, swipe_down_end, swipe_dwon_duration); + + static const Rect double_click_rect( + Configer::WindowWidthDefault * 0.4, + Configer::WindowHeightDefault * 0.4, + Configer::WindowWidthDefault * 0.2, + Configer::WindowWidthDefault * 0.2 + ); + + m_control_ptr->click(double_click_rect); + m_control_ptr->click(double_click_rect); + + return true; +} + +bool asst::InfrastDormTask::enter_operator_selection() +{ + // 有这些文字之一就说明“进驻信息”这个按钮已经点开了 + static const std::vector info_opened_flags = { + GbkToUtf8("当前房间入住信息"), + GbkToUtf8("进驻人数"), + GbkToUtf8("清空") + }; + + std::vector