mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
fix.尝试修复几个崩溃问题(不知道有没有效果)
https://github.com/MistEO/MeoAssistantArknights/issues/183 https://github.com/MistEO/MeoAssistantArknights/issues/182
This commit is contained in:
@@ -47,14 +47,17 @@ std::vector<asst::TextRect> asst::OcrPack::recognize(const cv::Mat image, const
|
||||
float scores[MaxBoxSize] = { 0 };
|
||||
size_t size = 0;
|
||||
|
||||
std::vector<uchar> buf;
|
||||
cv::imencode(".png", image, buf);
|
||||
|
||||
if (!without_det) {
|
||||
Log.trace("Ocr System");
|
||||
PaddleOcrSystemWithData(m_ocr, image.rows, image.cols, image.type(), image.data,
|
||||
PaddleOcrSystem(m_ocr, buf.data(), buf.size(),
|
||||
false, boxes, strs, scores, &size, nullptr, nullptr);
|
||||
}
|
||||
else {
|
||||
Log.trace("Ocr Rec");
|
||||
PaddleOcrRecWithData(m_ocr, image.rows, image.cols, image.type(), image.data,
|
||||
PaddleOcrRec(m_ocr, buf.data(), buf.size(),
|
||||
strs, scores, &size, nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -116,7 +119,6 @@ std::vector<asst::TextRect> asst::OcrPack::recognize(const cv::Mat image, const
|
||||
return pred(tr);
|
||||
};
|
||||
Log.trace("OcrPack::recognize | roi : ", roi.to_string());
|
||||
// 使用 data 直接传给 paddleocr, 如果不 clone, image.data 会出错
|
||||
cv::Mat roi_img = image(utils::make_rect<cv::Rect>(roi)).clone();
|
||||
cv::Mat roi_img = image(utils::make_rect<cv::Rect>(roi));
|
||||
return recognize(roi_img, rect_cor, without_det);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ void asst::PenguinPack::set_language(const std::string& server)
|
||||
|
||||
std::string asst::PenguinPack::recognize(const cv::Mat image)
|
||||
{
|
||||
return penguin::recognize_with_data(image.rows, image.cols, image.type(), image.data);
|
||||
std::vector<uchar> buf;
|
||||
cv::imencode(".png", image, buf);
|
||||
return penguin::recognize(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
bool asst::PenguinPack::load_json(const std::string& stage_path, const std::string& hash_path)
|
||||
@@ -83,8 +85,9 @@ bool asst::PenguinPack::load_templ(const std::string& item_id, const std::string
|
||||
m_last_error = "templ is empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
penguin::load_templ_with_data(item_id.c_str(), image.rows, image.cols, image.type(), image.data);
|
||||
std::vector<uchar> buf;
|
||||
cv::imencode(".png", image, buf);
|
||||
penguin::load_templ(item_id.c_str(), buf.data(), buf.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user