MaaFw 2.1.0__py3-none-manylinux2014_x86_64.whl → 5.4.0b1__py3-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maa/__init__.py +7 -5
- maa/agent/__init__.py +12 -0
- maa/agent/agent_server.py +350 -0
- maa/agent_client.py +291 -0
- maa/bin/libMaaAdbControlUnit.so +0 -0
- maa/bin/libMaaAgentClient.so +0 -0
- maa/bin/libMaaAgentServer.so +0 -0
- maa/bin/libMaaCustomControlUnit.so +0 -0
- maa/bin/libMaaFramework.so +0 -0
- maa/bin/libMaaToolkit.so +0 -0
- maa/bin/libMaaUtils.so +0 -0
- maa/bin/libc++.so.1 +0 -0
- maa/bin/libc++abi.so.1 +0 -0
- maa/bin/libfastdeploy_ppocr.so +0 -0
- maa/bin/{libopencv_world4.so.408 → libonnxruntime.so.1} +0 -0
- maa/bin/{libonnxruntime.so.1.18.0 → libopencv_world4.so.411} +0 -0
- maa/bin/libunwind.so.1 +0 -0
- maa/bin/plugins/libMaaPluginDemo.so +0 -0
- maa/buffer.py +297 -153
- maa/context.py +449 -34
- maa/controller.py +760 -113
- maa/custom_action.py +46 -3
- maa/custom_recognition.py +69 -11
- maa/define.py +539 -42
- maa/event_sink.py +103 -0
- maa/job.py +95 -36
- maa/library.py +182 -53
- maa/pipeline.py +509 -0
- maa/resource.py +598 -71
- maa/tasker.py +696 -156
- maa/toolkit.py +125 -165
- maafw-5.4.0b1.dist-info/METADATA +297 -0
- maafw-5.4.0b1.dist-info/RECORD +35 -0
- maafw-5.4.0b1.dist-info/WHEEL +4 -0
- MaaFw-2.1.0.dist-info/METADATA +0 -166
- MaaFw-2.1.0.dist-info/RECORD +0 -26
- MaaFw-2.1.0.dist-info/WHEEL +0 -4
- MaaFw-2.1.0.dist-info/top_level.txt +0 -1
- maa/bin/libMaaDbgControlUnit.so +0 -0
- maa/notification_handler.py +0 -191
- {MaaFw-2.1.0.dist-info → maafw-5.4.0b1.dist-info/licenses}/LICENSE.md +0 -0
maa/custom_action.py
CHANGED
|
@@ -8,6 +8,20 @@ from .define import *
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class CustomAction(ABC):
|
|
11
|
+
"""自定义动作基类 / Custom action base class
|
|
12
|
+
|
|
13
|
+
用于实现自定义的 Pipeline 动作。继承此类并实现 run 方法,
|
|
14
|
+
然后通过 Resource.register_custom_action 或 AgentServer.register_custom_action 注册。
|
|
15
|
+
Used to implement custom Pipeline actions. Inherit this class and implement the run method,
|
|
16
|
+
then register via Resource.register_custom_action or AgentServer.register_custom_action.
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
class MyAction(CustomAction):
|
|
20
|
+
def run(self, context, argv):
|
|
21
|
+
context.tasker.controller.post_click(100, 100).wait()
|
|
22
|
+
return True
|
|
23
|
+
"""
|
|
24
|
+
|
|
11
25
|
_handle: MaaCustomActionCallback
|
|
12
26
|
|
|
13
27
|
def __init__(self):
|
|
@@ -15,8 +29,19 @@ class CustomAction(ABC):
|
|
|
15
29
|
|
|
16
30
|
@dataclass
|
|
17
31
|
class RunArg:
|
|
32
|
+
"""run 方法的参数 / Arguments for run method
|
|
33
|
+
|
|
34
|
+
Attributes:
|
|
35
|
+
task_detail: 当前任务详情 / Current task detail
|
|
36
|
+
node_name: 当前节点名 / Current node name
|
|
37
|
+
custom_action_name: 自定义动作名 / Custom action name
|
|
38
|
+
custom_action_param: 自定义动作参数 (JSON 字符串) / Custom action parameter (JSON string)
|
|
39
|
+
reco_detail: 前序识别详情 / Previous recognition detail
|
|
40
|
+
box: 前序识别位置 / Previous recognition box
|
|
41
|
+
"""
|
|
42
|
+
|
|
18
43
|
task_detail: TaskDetail
|
|
19
|
-
|
|
44
|
+
node_name: str
|
|
20
45
|
custom_action_name: str
|
|
21
46
|
custom_action_param: str
|
|
22
47
|
reco_detail: RecognitionDetail
|
|
@@ -24,6 +49,12 @@ class CustomAction(ABC):
|
|
|
24
49
|
|
|
25
50
|
@dataclass
|
|
26
51
|
class RunResult:
|
|
52
|
+
"""run 方法的返回结果 / Return result of run method
|
|
53
|
+
|
|
54
|
+
Attributes:
|
|
55
|
+
success: 动作是否执行成功 / Whether the action executed successfully
|
|
56
|
+
"""
|
|
57
|
+
|
|
27
58
|
success: bool
|
|
28
59
|
|
|
29
60
|
@abstractmethod
|
|
@@ -32,6 +63,15 @@ class CustomAction(ABC):
|
|
|
32
63
|
context: Context,
|
|
33
64
|
argv: RunArg,
|
|
34
65
|
) -> Union[RunResult, bool]:
|
|
66
|
+
"""执行自定义动作 / Execute custom action
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
context: 任务上下文,可用于执行其他操作 / Task context, can be used to execute other operations
|
|
70
|
+
argv: 动作参数 / Action arguments
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Union[RunResult, bool]: 执行结果,可返回 RunResult 或 bool / Execution result, can return RunResult or bool
|
|
74
|
+
"""
|
|
35
75
|
raise NotImplementedError
|
|
36
76
|
|
|
37
77
|
@property
|
|
@@ -47,7 +87,7 @@ class CustomAction(ABC):
|
|
|
47
87
|
def _c_run_agent(
|
|
48
88
|
c_context: MaaContextHandle,
|
|
49
89
|
c_task_id: MaaTaskId,
|
|
50
|
-
|
|
90
|
+
c_node_name: ctypes.c_char_p,
|
|
51
91
|
c_custom_action_name: ctypes.c_char_p,
|
|
52
92
|
c_custom_action_param: ctypes.c_char_p,
|
|
53
93
|
c_reco_id: MaaRecoId,
|
|
@@ -74,7 +114,7 @@ class CustomAction(ABC):
|
|
|
74
114
|
context,
|
|
75
115
|
CustomAction.RunArg(
|
|
76
116
|
task_detail=task_detail,
|
|
77
|
-
|
|
117
|
+
node_name=c_node_name.decode(),
|
|
78
118
|
custom_action_name=c_custom_action_name.decode(),
|
|
79
119
|
custom_action_param=c_custom_action_param.decode(),
|
|
80
120
|
reco_detail=reco_detail,
|
|
@@ -88,5 +128,8 @@ class CustomAction(ABC):
|
|
|
88
128
|
elif isinstance(result, bool):
|
|
89
129
|
return int(result)
|
|
90
130
|
|
|
131
|
+
elif result is None:
|
|
132
|
+
return int(True)
|
|
133
|
+
|
|
91
134
|
else:
|
|
92
135
|
raise TypeError(f"Invalid return type: {result!r}")
|
maa/custom_recognition.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
+
import json
|
|
2
3
|
from dataclasses import dataclass
|
|
3
4
|
from abc import ABC, abstractmethod
|
|
4
|
-
from typing import Tuple
|
|
5
5
|
|
|
6
6
|
import numpy
|
|
7
7
|
|
|
@@ -11,6 +11,20 @@ from .define import *
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class CustomRecognition(ABC):
|
|
14
|
+
"""自定义识别器基类 / Custom recognition base class
|
|
15
|
+
|
|
16
|
+
用于实现自定义的 Pipeline 识别算法。继承此类并实现 analyze 方法,
|
|
17
|
+
然后通过 Resource.register_custom_recognition 或 AgentServer.register_custom_recognition 注册。
|
|
18
|
+
Used to implement custom Pipeline recognition algorithms. Inherit this class and implement the analyze method,
|
|
19
|
+
then register via Resource.register_custom_recognition or AgentServer.register_custom_recognition.
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
class MyRecognition(CustomRecognition):
|
|
23
|
+
def analyze(self, context, argv):
|
|
24
|
+
# 返回识别到的位置,或 None 表示未识别到
|
|
25
|
+
return (100, 100, 50, 50)
|
|
26
|
+
"""
|
|
27
|
+
|
|
14
28
|
_handle: MaaCustomRecognitionCallback
|
|
15
29
|
|
|
16
30
|
def __init__(self):
|
|
@@ -18,8 +32,19 @@ class CustomRecognition(ABC):
|
|
|
18
32
|
|
|
19
33
|
@dataclass
|
|
20
34
|
class AnalyzeArg:
|
|
35
|
+
"""analyze 方法的参数 / Arguments for analyze method
|
|
36
|
+
|
|
37
|
+
Attributes:
|
|
38
|
+
task_detail: 当前任务详情 / Current task detail
|
|
39
|
+
node_name: 当前节点名 / Current node name
|
|
40
|
+
custom_recognition_name: 自定义识别器名 / Custom recognition name
|
|
41
|
+
custom_recognition_param: 自定义识别器参数 (JSON 字符串) / Custom recognition parameter (JSON string)
|
|
42
|
+
image: 待识别的图像 (BGR 格式) / Image to recognize (BGR format)
|
|
43
|
+
roi: 识别区域 / Recognition region of interest
|
|
44
|
+
"""
|
|
45
|
+
|
|
21
46
|
task_detail: TaskDetail
|
|
22
|
-
|
|
47
|
+
node_name: str
|
|
23
48
|
custom_recognition_name: str
|
|
24
49
|
custom_recognition_param: str
|
|
25
50
|
image: numpy.ndarray
|
|
@@ -27,8 +52,15 @@ class CustomRecognition(ABC):
|
|
|
27
52
|
|
|
28
53
|
@dataclass
|
|
29
54
|
class AnalyzeResult:
|
|
55
|
+
"""analyze 方法的返回结果 / Return result of analyze method
|
|
56
|
+
|
|
57
|
+
Attributes:
|
|
58
|
+
box: 识别到的位置,None 表示未识别到 / Recognized position, None means not recognized
|
|
59
|
+
detail: 识别详情,会被记录到识别结果中 / Recognition details, will be recorded in recognition result
|
|
60
|
+
"""
|
|
61
|
+
|
|
30
62
|
box: Optional[RectType]
|
|
31
|
-
detail:
|
|
63
|
+
detail: dict
|
|
32
64
|
|
|
33
65
|
@abstractmethod
|
|
34
66
|
def analyze(
|
|
@@ -36,6 +68,18 @@ class CustomRecognition(ABC):
|
|
|
36
68
|
context: Context,
|
|
37
69
|
argv: AnalyzeArg,
|
|
38
70
|
) -> Union[AnalyzeResult, Optional[RectType]]:
|
|
71
|
+
"""执行自定义识别 / Execute custom recognition
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
context: 任务上下文,可用于执行其他操作 / Task context, can be used to execute other operations
|
|
75
|
+
argv: 识别参数 / Recognition arguments
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Union[AnalyzeResult, Optional[RectType]]: 识别结果。可返回 AnalyzeResult、RectType 或 None。
|
|
79
|
+
返回 None 表示未识别到。
|
|
80
|
+
Recognition result. Can return AnalyzeResult, RectType, or None.
|
|
81
|
+
Return None means not recognized.
|
|
82
|
+
"""
|
|
39
83
|
raise NotImplementedError
|
|
40
84
|
|
|
41
85
|
@property
|
|
@@ -51,7 +95,7 @@ class CustomRecognition(ABC):
|
|
|
51
95
|
def _c_analyze_agent(
|
|
52
96
|
c_context: MaaContextHandle,
|
|
53
97
|
c_task_id: MaaTaskId,
|
|
54
|
-
|
|
98
|
+
c_node_name: ctypes.c_char_p,
|
|
55
99
|
c_custom_reco_name: ctypes.c_char_p,
|
|
56
100
|
c_custom_reco_param: ctypes.c_char_p,
|
|
57
101
|
c_image: MaaImageBufferHandle,
|
|
@@ -77,7 +121,7 @@ class CustomRecognition(ABC):
|
|
|
77
121
|
context,
|
|
78
122
|
CustomRecognition.AnalyzeArg(
|
|
79
123
|
task_detail=task_detail,
|
|
80
|
-
|
|
124
|
+
node_name=c_node_name.decode(),
|
|
81
125
|
custom_recognition_name=c_custom_reco_name.decode(),
|
|
82
126
|
custom_recognition_param=c_custom_reco_param.decode(),
|
|
83
127
|
image=image,
|
|
@@ -92,15 +136,29 @@ class CustomRecognition(ABC):
|
|
|
92
136
|
if isinstance(result, CustomRecognition.AnalyzeResult):
|
|
93
137
|
if result.box:
|
|
94
138
|
rect_buffer.set(result.box)
|
|
95
|
-
detail_buffer.set(result.detail)
|
|
139
|
+
detail_buffer.set(json.dumps(result.detail, ensure_ascii=False))
|
|
96
140
|
return int(result.box is not None)
|
|
97
141
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
142
|
+
# RectType
|
|
143
|
+
elif (
|
|
144
|
+
isinstance(result, Rect)
|
|
145
|
+
or (
|
|
146
|
+
isinstance(result, list)
|
|
147
|
+
and len(result) == 4
|
|
148
|
+
and all(isinstance(x, int) for x in result)
|
|
149
|
+
)
|
|
150
|
+
or (isinstance(result, numpy.ndarray) and result.size == 4)
|
|
151
|
+
or (
|
|
152
|
+
isinstance(result, tuple)
|
|
153
|
+
and len(result) == 4
|
|
154
|
+
and all(isinstance(x, int) for x in result)
|
|
155
|
+
)
|
|
156
|
+
):
|
|
102
157
|
rect_buffer.set(result)
|
|
103
158
|
return int(True)
|
|
104
159
|
|
|
160
|
+
elif result is None:
|
|
161
|
+
return int(False)
|
|
162
|
+
|
|
105
163
|
else:
|
|
106
|
-
raise
|
|
164
|
+
raise TypeError(f"Invalid return type: {result!r}")
|