Skip to content

Commit

Permalink
fix: 修复template_bank_存储错误
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Aug 30, 2023
1 parent 8190d7f commit 08641d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions source/MaaFramework/Resource/TemplateConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const std::vector<cv::Mat>& TemplateConfig::load_images(const std::string& name)
cv::Mat templ_mat;
for (const auto& root : paths.roots | MAA_RNS::views::reverse) {
auto path = root / MAA_NS::path(filename);
templ_mat = load_image(name, path);
templ_mat = load_single_image(path);
if (!templ_mat.empty()) {
break;
}
Expand All @@ -89,20 +89,20 @@ const std::vector<cv::Mat>& TemplateConfig::load_images(const std::string& name)
return template_cache_.emplace(name, std::move(images)).first->second;
}

cv::Mat TemplateConfig::load_image(const std::string& name, const std::filesystem::path& path) const
cv::Mat TemplateConfig::load_single_image(const std::filesystem::path& path) const
{
if (auto bank_iter = template_bank_.find(path); bank_iter != template_bank_.end()) {
LogDebug << "Withdraw image" << VAR(name) << VAR(path);
LogDebug << "Withdraw image" << VAR(path);
return bank_iter->second;
}
else if (std::filesystem::exists(path)) {
LogDebug << "Read image" << VAR(name) << VAR(path);
LogDebug << "Read image" << VAR(path);
cv::Mat temp = MAA_NS::imread(path);
template_bank_.emplace(name, temp);
template_bank_.emplace(path, temp);
return temp;
}

LogDebug << "Image not found" << VAR(name) << VAR(path);
LogDebug << "Image not found" << VAR(path);
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Resource/TemplateConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TemplateConfig : public NonCopyable
public:
const std::vector<cv::Mat>& get_template_images(const std::string& name) const;
const std::vector<cv::Mat>& load_images(const std::string& name) const;
cv::Mat load_image(const std::string& name, const std::filesystem::path& path) const;
cv::Mat load_single_image(const std::filesystem::path& path) const;

private:
// for lazy load
Expand Down

0 comments on commit 08641d9

Please sign in to comment.