Merge branch 'master' into dev

This commit is contained in:
MistEO
2021-10-30 01:56:49 +08:00
5 changed files with 61 additions and 8 deletions

View File

@@ -197,6 +197,39 @@ bool Controller::try_capture(const EmulatorInfo& info, bool without_handle)
m_emulator_info = info;
adb_dir = '"' + utils::string_replace_all(m_emulator_info.adb.path, "[ExecDir]", utils::get_cur_dir()) + '"';
}
// 针对雷电模拟器连接问题的专用补丁
if (m_emulator_info.handle.class_name == "LDPlayerMainFrame") {
log.trace("LDPlayer Connection Patch Activated.");
std::string connect_cmd = utils::string_replace_all("[Adb] devices", "[Adb]", adb_dir);
auto devices_result = call_command(connect_cmd);
std::string devices_list(
std::make_move_iterator(devices_result.begin()),
std::make_move_iterator(devices_result.end()));
// 查找连接的所有设备
std::string device = {};
if (devices_list.find("emulator") != devices_list.npos) {
device = devices_list.substr(devices_list.find("emulator"), 13);
m_emulator_info.adb.connect = "";
}
else if (devices_list.find("127") != devices_list.npos) {
device = devices_list.substr(devices_list.find("127"), 14);
}
if (device.empty()) {
log.trace("no device detected.");
return false;
}
log.trace("device detected: ", device);
m_emulator_info.adb.connect = utils::string_replace_all(m_emulator_info.adb.connect, "127.0.0.1:5555", device);
m_emulator_info.adb.click = utils::string_replace_all(m_emulator_info.adb.click, "-e", "-s " + device);
m_emulator_info.adb.swipe = utils::string_replace_all(m_emulator_info.adb.swipe, "-e", "-s " + device);
m_emulator_info.adb.display = utils::string_replace_all(m_emulator_info.adb.display, "-e", "-s " + device);
m_emulator_info.adb.screencap = utils::string_replace_all(m_emulator_info.adb.screencap, "-e", "-s " + device);
}
std::string connect_cmd = utils::string_replace_all(m_emulator_info.adb.connect, "[Adb]", adb_dir);
auto&& [connect_ret, connect_result] = call_command(connect_cmd);

View File

@@ -85,8 +85,8 @@ bool asst::MatchImageAnalyzer::match_templ(const cv::Mat& templ)
bool asst::MatchImageAnalyzer::comp_hist(const cv::Mat& hist, const cv::Rect roi)
{
cv::Mat roi_image = m_image(utils::make_rect<cv::Rect>(m_roi))(roi);
double score = 1.0 - cv::compareHist(to_hist(roi_image), hist, cv::HISTCMP_BHATTACHARYYA);
cv::Mat image_roi = m_image(utils::make_rect<cv::Rect>(m_roi))(roi);
double score = 1.0 - cv::compareHist(to_hist(image_roi), hist, cv::HISTCMP_BHATTACHARYYA);
if (score > 0.7) { // 得分太低的肯定不对,没必要打印
log.trace("comp_hist |", m_templ_name, "score:", score);

View File

@@ -9,7 +9,7 @@ namespace MeoAsstGui
public class ViewStatusStorage
{
private static string _configFilename = System.Environment.CurrentDirectory + "\\gui.json";
private static JObject _viewStatus;
private static JObject _viewStatus = new JObject();
public static string Get(string key, string defalut_value)
{
@@ -36,6 +36,11 @@ namespace MeoAsstGui
{
string jsonStr = sr.ReadToEnd();
_viewStatus = (JObject)JsonConvert.DeserializeObject(jsonStr);
// 文件存在但为空会读出来一个null感觉c#这库有bug
if (_viewStatus == null)
{
_viewStatus = new JObject();
}
}
}
catch (Exception)