完成加载全部文字图片并识别的逻辑

This commit is contained in:
MistEO
2021-08-16 01:15:47 +08:00
parent 54a80a75c7
commit 4e06c19f3e
50 changed files with 163 additions and 14 deletions

View File

@@ -49,12 +49,15 @@ bool InfrastConfiger::_load(const std::string& filename)
for (json::value& oper_name : comb_info["comb"].as_array())
{
std::string oper_name_str = oper_name.as_string();
m_mfg_opers.emplace(oper_name_str);
comb_vec.emplace_back(std::move(oper_name_str));
}
m_mfg_combs.emplace_back(std::move(comb_vec));
}
m_mfg_end = root["Manufacturing"]["end"].as_string();
for (json::value& oper : root["Manufacturing"]["all"].as_array())
{
m_mfg_opers.emplace(oper["name"].as_string());
}
// óÒ×Õ¾ TODO¡­¡­
}

View File

@@ -68,8 +68,13 @@ Assistance::Assistance(AsstCallback callback, void* callback_arg)
return;
}
// for debug
m_identify_ptr->add_text_image("森蚺", GetResourceDir() + "operators\\森蚺.png");
for (const std::string& name : InfrastConfiger::get_instance().m_mfg_opers) {
ret = m_identify_ptr->add_text_image(name, GetResourceDir() + "operators\\" + Utf8ToGbk(name) + ".png");
if (!ret) {
callback_error();
return;
}
}
m_working_thread = std::thread(working_proc, this);
m_msg_thread = std::thread(msg_proc, this);

View File

@@ -250,10 +250,9 @@ std::vector<TextArea> asst::Identify::feature_matching(const cv::Mat& mat)
}
}
cv::Rect draw_rect;
constexpr static const int MatchSizeThreshold = 10;
if (good_points.size() >= MatchSizeThreshold) {
std::cout << Utf8ToGbk(key) << " " << good_points.size() << " / " << query_keypoints.size() << std::endl;
constexpr static const double MatchSizeRatioThreshold = 0.075;
if (good_points.size() >= query_keypoints.size() * MatchSizeRatioThreshold) {
TextArea textarea;
textarea.text = key;
int left = 0, right = 0, top = 0, bottom = 0;
@@ -272,20 +271,21 @@ std::vector<TextArea> asst::Identify::feature_matching(const cv::Mat& mat)
}
}
textarea.rect = { left, top, right - left, bottom - top };
draw_rect = { left + 129, top, right - left, bottom - top };
//draw_rect = { left + 129, top, right - left, bottom - top };
matched_text_area.emplace_back(std::move(textarea));
}
// for debug
cv::Mat text_mat = cv::imread(GetResourceDir() + "operators\\森蚺.png");
cv::Mat text_mat = cv::imread(GetResourceDir() + "operators\\" + Utf8ToGbk(key) + ".png");
cv::Mat approach_mat;
cv::drawMatches(text_mat, query_keypoints, mat, train_keypoints, approach_matches, approach_mat);
// cv::rectangle(approach_mat, draw_rect, cv::Scalar(0, 0, 255), 10);
cv::drawMatches(text_mat, query_keypoints, mat, train_keypoints, ransac_matchs, approach_mat);
cv::Mat good_mat;
cv::drawMatches(text_mat, query_keypoints, mat, train_keypoints, good_matchs, good_mat);
// cv::rectangle(good_mat, draw_rect, cv::Scalar(0, 0, 255), 10);
}
return matched_text_area;
}

View File

@@ -697,7 +697,11 @@ bool asst::InfrastStationTask::run()
// for debug
const cv::Mat& debug_image = get_format_image(true);
m_identify_ptr->feature_matching(debug_image);
auto res = m_identify_ptr->feature_matching(debug_image);
for (auto textarea : res) {
std::cout << Utf8ToGbk(textarea.text) << std::endl;
}
//std::vector<std::vector<std::string>> all_oper_combs; // 所有的干员组合
//std::unordered_set<std::string> all_oper_name; // 所有干员名

View File

@@ -26,7 +26,144 @@
}
],
"end": "月见夜",
"end_Doc": "识别到这个词,就认为干员遍历结束,一般用排序里最后的那个干员(?)"
"end_Doc": "识别到这个词,就认为干员遍历结束,一般用排序里最后的那个干员(?)",
"all": [
{
"name": "食铁兽"
},
{
"name": "断罪者"
},
{
"name": "白雪"
},
{
"name": "Castle-3"
},
{
"name": "霜叶"
},
{
"name": "红豆"
},
{
"name": "帕拉斯"
},
{
"name": "砾"
},
{
"name": "夜烟"
},
{
"name": "斑点"
},
{
"name": "清流"
},
{
"name": "迷迭香"
},
{
"name": "槐琥"
},
{
"name": "梅尔"
},
{
"name": "赫默"
},
{
"name": "白面鸮"
},
{
"name": "水月"
},
{
"name": "调香师"
},
{
"name": "杰西卡"
},
{
"name": "史都华德"
},
{
"name": "香草"
},
{
"name": "石棉"
},
{
"name": "泡普卡"
},
{
"name": "芬"
},
{
"name": "克洛丝"
},
{
"name": "豆苗"
},
{
"name": "流星"
},
{
"name": "夜刀"
},
{
"name": "温蒂"
},
{
"name": "森蚺"
},
{
"name": "异客"
},
{
"name": "蛇屠箱"
},
{
"name": "黑角"
},
{
"name": "卡缇"
},
{
"name": "米格鲁"
},
{
"name": "火神"
},
{
"name": "贝娜"
},
{
"name": "卡达"
},
{
"name": "稀音"
},
{
"name": "泡泡"
},
{
"name": "刻俄柏"
},
{
"name": "红云"
},
{
"name": "艾雅法拉"
},
{
"name": "炎熔"
},
{
"name": "月见夜"
}
]
},
"Trade": {
"Doc": "贸易站"

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
resource/operators/砾.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
resource/operators/芬.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB