| 81 | } |
| 82 | |
| 83 | MaaBool CustomReco( |
| 84 | MaaContext* context, |
| 85 | MaaTaskId task_id, |
| 86 | const char* node_name, |
| 87 | const char* custom_recognition_name, |
| 88 | const char* custom_recognition_param, |
| 89 | const MaaImageBuffer* image, |
| 90 | const MaaRect* roi, |
| 91 | void* trans_arg, |
| 92 | MaaRect* out_box, |
| 93 | MaaStringBuffer* out_detail) |
| 94 | { |
| 95 | using Ret = std::optional<std::tuple<MaaRect, std::string>>; |
| 96 | auto ctx = reinterpret_cast<maajs::CallbackContext*>(trans_arg); |
| 97 | auto result = ctx->Call<Ret>([&](maajs::FunctionType func) { |
| 98 | auto env = func.Env(); |
| 99 | auto self = maajs::ObjectType::New(env); |
| 100 | |
| 101 | self["context"] = ContextImpl::locate_object(env, context); |
| 102 | self["id"] = maajs::JSConvert<MaaTaskId>::to_value(env, task_id); |
| 103 | self["task"] = maajs::StringType::New(env, node_name); |
| 104 | self["name"] = maajs::StringType::New(env, custom_recognition_name); |
| 105 | self["param"] = maajs::JsonParse(env, custom_recognition_param); |
| 106 | self["image"] = ImageBufferRefer(image).data(env); |
| 107 | self["roi"] = maajs::JSConvert<MaaRect>::to_value(env, *roi); |
| 108 | |
| 109 | return func.Call(self, { self }); |
| 110 | }); |
| 111 | if (result) { |
| 112 | *out_box = std::get<0>(*result); |
| 113 | StringBuffer(out_detail, false).set(std::get<1>(*result)); |
| 114 | return true; |
| 115 | } |
| 116 | else { |
| 117 | return false; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | MaaBool CustomAct( |
| 122 | MaaContext* context, |
nothing calls this directly
no test coverage detected