mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 10:00:44 +08:00
feat: support GPU OCR
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <meojson/json.hpp>
|
||||
|
||||
#include "Config/GeneralConfig.h"
|
||||
#include "Config/Miscellaneous/OcrPack.h"
|
||||
#include "Config/ResourceLoader.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "Status.h"
|
||||
@@ -34,6 +35,24 @@ using namespace asst;
|
||||
bool ::AsstExtAPI::set_static_option(StaticOptionKey key, const std::string& value)
|
||||
{
|
||||
Log.info(__FUNCTION__, "| key", static_cast<int>(key), "value", value);
|
||||
|
||||
switch (key) {
|
||||
case StaticOptionKey::CpuOCR: {
|
||||
WordOcr::get_instance().use_cpu();
|
||||
CharOcr::get_instance().use_cpu();
|
||||
return true;
|
||||
} break;
|
||||
case StaticOptionKey::GpuOCR: {
|
||||
int device_id = std::stoi(value);
|
||||
WordOcr::get_instance().use_gpu(device_id);
|
||||
CharOcr::get_instance().use_gpu(device_id);
|
||||
return true;
|
||||
} break;
|
||||
default:
|
||||
Log.error(__FUNCTION__, "| unknown key:", static_cast<int>(key));
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user