MaaFw 4.4.0b1__py3-none-manylinux2014_x86_64.whl → 5.4.0__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.
Potentially problematic release.
This version of MaaFw might be problematic. Click here for more details.
- maa/agent/agent_server.py +221 -3
- maa/agent_client.py +170 -2
- 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/libonnxruntime.so.1 +0 -0
- maa/bin/{libopencv_world4.so.408 → libopencv_world4.so.411} +0 -0
- maa/bin/libunwind.so.1 +0 -0
- maa/bin/plugins/libMaaPluginDemo.so +0 -0
- maa/buffer.py +168 -0
- maa/context.py +402 -10
- maa/controller.py +685 -44
- maa/custom_action.py +43 -0
- maa/custom_recognition.py +61 -9
- maa/define.py +450 -20
- maa/event_sink.py +103 -0
- maa/job.py +77 -1
- maa/library.py +118 -50
- maa/pipeline.py +509 -0
- maa/resource.py +430 -21
- maa/tasker.py +630 -90
- maa/toolkit.py +52 -91
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/METADATA +90 -45
- maafw-5.4.0.dist-info/RECORD +35 -0
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/WHEEL +1 -1
- maa/bin/libMaaDbgControlUnit.so +0 -0
- maa/notification_handler.py +0 -197
- maafw-4.4.0b1.dist-info/RECORD +0 -30
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/licenses/LICENSE.md +0 -0
maa/define.py
CHANGED
|
@@ -16,7 +16,9 @@ MaaCtrlId = MaaId
|
|
|
16
16
|
MaaResId = MaaId
|
|
17
17
|
MaaTaskId = MaaId
|
|
18
18
|
MaaRecoId = MaaId
|
|
19
|
+
MaaActId = MaaId
|
|
19
20
|
MaaNodeId = MaaId
|
|
21
|
+
MaaSinkId = MaaId
|
|
20
22
|
MaaInvalidId = MaaId(0)
|
|
21
23
|
|
|
22
24
|
MaaStringBufferHandle = ctypes.c_void_p
|
|
@@ -66,11 +68,12 @@ class MaaGlobalOptionEnum(IntEnum):
|
|
|
66
68
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
67
69
|
SaveDraw = 2
|
|
68
70
|
|
|
71
|
+
# Deprecated
|
|
69
72
|
# Dump all screenshots and actions
|
|
70
73
|
#
|
|
71
74
|
# Recording will evaluate to true if any of this or MaaCtrlOptionEnum::MaaCtrlOption_Recording
|
|
72
75
|
# is true. value: bool, eg: true; val_size: sizeof(bool)
|
|
73
|
-
Recording = 3
|
|
76
|
+
# Recording = 3
|
|
74
77
|
|
|
75
78
|
# The level of log output to stdout
|
|
76
79
|
#
|
|
@@ -88,6 +91,23 @@ class MaaGlobalOptionEnum(IntEnum):
|
|
|
88
91
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
89
92
|
DebugMode = 6
|
|
90
93
|
|
|
94
|
+
# Whether to save screenshot on error
|
|
95
|
+
#
|
|
96
|
+
# value: bool, eg: true; val_size: sizeof(bool)
|
|
97
|
+
SaveOnError = 7
|
|
98
|
+
|
|
99
|
+
# Image quality for draw images
|
|
100
|
+
#
|
|
101
|
+
# value: int, eg: 85; val_size: sizeof(int)
|
|
102
|
+
# default value is 85, range: [0, 100]
|
|
103
|
+
DrawQuality = 8
|
|
104
|
+
|
|
105
|
+
# Recognition image cache limit
|
|
106
|
+
#
|
|
107
|
+
# value: size_t, eg: 4096; val_size: sizeof(size_t)
|
|
108
|
+
# default value is 4096
|
|
109
|
+
RecoImageCacheLimit = 9
|
|
110
|
+
|
|
91
111
|
|
|
92
112
|
class MaaCtrlOptionEnum(IntEnum):
|
|
93
113
|
Invalid = 0
|
|
@@ -105,10 +125,11 @@ class MaaCtrlOptionEnum(IntEnum):
|
|
|
105
125
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
106
126
|
ScreenshotUseRawSize = 3
|
|
107
127
|
|
|
128
|
+
# Deprecated
|
|
108
129
|
# Dump all screenshots and actions
|
|
109
130
|
# this option will || with MaaGlobalOptionEnum.Recording
|
|
110
131
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
111
|
-
Recording = 5
|
|
132
|
+
# Recording = 5
|
|
112
133
|
|
|
113
134
|
|
|
114
135
|
class MaaInferenceDeviceEnum(IntEnum):
|
|
@@ -163,8 +184,25 @@ MaaAdbScreencapMethod = ctypes.c_uint64
|
|
|
163
184
|
|
|
164
185
|
class MaaAdbScreencapMethodEnum(IntEnum):
|
|
165
186
|
"""
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
Adb screencap method flags.
|
|
188
|
+
|
|
189
|
+
Use bitwise OR to set the methods you need.
|
|
190
|
+
MaaFramework will test all provided methods and use the fastest available one.
|
|
191
|
+
|
|
192
|
+
Default: All methods except RawByNetcat, MinicapDirect, MinicapStream
|
|
193
|
+
|
|
194
|
+
Note: MinicapDirect and MinicapStream use lossy JPEG encoding, which may
|
|
195
|
+
significantly reduce template matching accuracy. Not recommended.
|
|
196
|
+
|
|
197
|
+
| Method | Speed | Compatibility | Encoding | Notes |
|
|
198
|
+
|-----------------------|------------|---------------|----------|-----------------------------------|
|
|
199
|
+
| EncodeToFileAndPull | Slow | High | Lossless | |
|
|
200
|
+
| Encode | Slow | High | Lossless | |
|
|
201
|
+
| RawWithGzip | Medium | High | Lossless | |
|
|
202
|
+
| RawByNetcat | Fast | Low | Lossless | |
|
|
203
|
+
| MinicapDirect | Fast | Low | Lossy | |
|
|
204
|
+
| MinicapStream | Very Fast | Low | Lossy | |
|
|
205
|
+
| EmulatorExtras | Very Fast | Low | Lossless | Emulators only: MuMu 12, LDPlayer 9 |
|
|
168
206
|
"""
|
|
169
207
|
|
|
170
208
|
Null = 0
|
|
@@ -186,9 +224,21 @@ MaaAdbInputMethod = ctypes.c_uint64
|
|
|
186
224
|
|
|
187
225
|
class MaaAdbInputMethodEnum(IntEnum):
|
|
188
226
|
"""
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
227
|
+
Adb input method flags.
|
|
228
|
+
|
|
229
|
+
Use bitwise OR to set the methods you need.
|
|
230
|
+
MaaFramework will select the first available method according to priority.
|
|
231
|
+
|
|
232
|
+
Priority (high to low): EmulatorExtras > Maatouch > MinitouchAndAdbKey > AdbShell
|
|
233
|
+
|
|
234
|
+
Default: All methods except EmulatorExtras
|
|
235
|
+
|
|
236
|
+
| Method | Speed | Compatibility | Notes |
|
|
237
|
+
|----------------------|-------|---------------|---------------------------------------|
|
|
238
|
+
| AdbShell | Slow | High | |
|
|
239
|
+
| MinitouchAndAdbKey | Fast | Medium | Key press still uses AdbShell |
|
|
240
|
+
| Maatouch | Fast | Medium | |
|
|
241
|
+
| EmulatorExtras | Fast | Low | Emulators only: MuMu 12 |
|
|
192
242
|
"""
|
|
193
243
|
|
|
194
244
|
Null = 0
|
|
@@ -205,29 +255,176 @@ class MaaAdbInputMethodEnum(IntEnum):
|
|
|
205
255
|
MaaWin32ScreencapMethod = ctypes.c_uint64
|
|
206
256
|
|
|
207
257
|
|
|
208
|
-
# No bitwise OR, just set it
|
|
209
258
|
class MaaWin32ScreencapMethodEnum(IntEnum):
|
|
259
|
+
"""
|
|
260
|
+
Win32 screencap method.
|
|
261
|
+
|
|
262
|
+
No bitwise OR, select ONE method only.
|
|
263
|
+
|
|
264
|
+
No default value. Client should choose one as default.
|
|
265
|
+
|
|
266
|
+
Different applications use different rendering methods, there is no universal solution.
|
|
267
|
+
|
|
268
|
+
| Method | Speed | Compatibility | Require Admin | Background Support | Notes |
|
|
269
|
+
|-------------------------|-----------|---------------|---------------|--------------------|----------------------------------|
|
|
270
|
+
| GDI | Fast | Medium | No | No | |
|
|
271
|
+
| FramePool | Very Fast | Medium | No | Yes | Requires Windows 10 1903+ |
|
|
272
|
+
| DXGI_DesktopDup | Very Fast | Low | No | No | Desktop duplication (full screen)|
|
|
273
|
+
| DXGI_DesktopDup_Window | Very Fast | Low | No | No | Desktop duplication then crop |
|
|
274
|
+
| PrintWindow | Medium | Medium | No | Yes | |
|
|
275
|
+
| ScreenDC | Fast | High | No | No | |
|
|
276
|
+
|
|
277
|
+
Note: When a window is minimized on Windows, all screencap methods will fail.
|
|
278
|
+
Avoid minimizing the target window.
|
|
279
|
+
"""
|
|
280
|
+
|
|
210
281
|
Null = 0
|
|
211
282
|
|
|
212
283
|
GDI = 1
|
|
213
284
|
FramePool = 1 << 1
|
|
214
285
|
DXGI_DesktopDup = 1 << 2
|
|
286
|
+
DXGI_DesktopDup_Window = 1 << 3
|
|
287
|
+
PrintWindow = 1 << 4
|
|
288
|
+
ScreenDC = 1 << 5
|
|
215
289
|
|
|
216
290
|
|
|
217
291
|
MaaWin32InputMethod = ctypes.c_uint64
|
|
218
292
|
|
|
219
293
|
|
|
220
|
-
# No bitwise OR, just set it
|
|
221
294
|
class MaaWin32InputMethodEnum(IntEnum):
|
|
295
|
+
"""
|
|
296
|
+
Win32 input method.
|
|
297
|
+
|
|
298
|
+
No bitwise OR, select ONE method only.
|
|
299
|
+
|
|
300
|
+
No default value. Client should choose one as default.
|
|
301
|
+
|
|
302
|
+
Different applications process input differently, there is no universal solution.
|
|
303
|
+
|
|
304
|
+
| Method | Compatibility | Require Admin | Seize Mouse | Background Support | Notes |
|
|
305
|
+
|------------------------------|---------------|---------------|--------------|--------------------|-------------------------------------------------------------|
|
|
306
|
+
| Seize | High | No | Yes | No | |
|
|
307
|
+
| SendMessage | Medium | Maybe | No | Yes | |
|
|
308
|
+
| PostMessage | Medium | Maybe | No | Yes | |
|
|
309
|
+
| LegacyEvent | Low | No | Yes | No | |
|
|
310
|
+
| PostThreadMessage | Low | Maybe | No | Yes | |
|
|
311
|
+
| SendMessageWithCursorPos | Medium | Maybe | Briefly | Yes | Designed for apps that check real cursor position |
|
|
312
|
+
| PostMessageWithCursorPos | Medium | Maybe | Briefly | Yes | Designed for apps that check real cursor position |
|
|
313
|
+
|
|
314
|
+
Note:
|
|
315
|
+
- Admin rights mainly depend on the target application's privilege level.
|
|
316
|
+
If the target runs as admin, MaaFramework should also run as admin for compatibility.
|
|
317
|
+
- "WithCursorPos" methods briefly move the cursor to target position, send message,
|
|
318
|
+
then restore cursor position. This "briefly" seizes the mouse but won't block user operations.
|
|
319
|
+
"""
|
|
320
|
+
|
|
222
321
|
Null = 0
|
|
223
322
|
|
|
224
323
|
Seize = 1
|
|
225
324
|
SendMessage = 1 << 1
|
|
325
|
+
PostMessage = 1 << 2
|
|
326
|
+
LegacyEvent = 1 << 3
|
|
327
|
+
PostThreadMessage = 1 << 4
|
|
328
|
+
SendMessageWithCursorPos = 1 << 5
|
|
329
|
+
PostMessageWithCursorPos = 1 << 6
|
|
226
330
|
|
|
227
331
|
|
|
228
332
|
# No bitwise OR, just set it
|
|
229
333
|
MaaDbgControllerType = ctypes.c_uint64
|
|
230
334
|
|
|
335
|
+
# No bitwise OR, just set it
|
|
336
|
+
MaaGamepadType = ctypes.c_uint64
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class MaaGamepadTypeEnum(IntEnum):
|
|
340
|
+
"""
|
|
341
|
+
Virtual gamepad type for GamepadController (Windows only).
|
|
342
|
+
|
|
343
|
+
No bitwise OR, select ONE type only.
|
|
344
|
+
|
|
345
|
+
Requires ViGEm Bus Driver to be installed.
|
|
346
|
+
|
|
347
|
+
| Type | Description |
|
|
348
|
+
|-------------|---------------------------------------|
|
|
349
|
+
| Xbox360 | Microsoft Xbox 360 Controller (wired) |
|
|
350
|
+
| DualShock4 | Sony DualShock 4 Controller (wired) |
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
Xbox360 = 0
|
|
354
|
+
DualShock4 = 1
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class MaaGamepadButtonEnum(IntEnum):
|
|
358
|
+
"""
|
|
359
|
+
Gamepad button flags (XUSB protocol values).
|
|
360
|
+
|
|
361
|
+
Use bitwise OR to combine multiple buttons.
|
|
362
|
+
DS4 face buttons are aliases to Xbox face buttons.
|
|
363
|
+
"""
|
|
364
|
+
|
|
365
|
+
# D-pad
|
|
366
|
+
DPAD_UP = 0x0001
|
|
367
|
+
DPAD_DOWN = 0x0002
|
|
368
|
+
DPAD_LEFT = 0x0004
|
|
369
|
+
DPAD_RIGHT = 0x0008
|
|
370
|
+
|
|
371
|
+
# Control buttons
|
|
372
|
+
START = 0x0010
|
|
373
|
+
BACK = 0x0020
|
|
374
|
+
LEFT_THUMB = 0x0040 # L3
|
|
375
|
+
RIGHT_THUMB = 0x0080 # R3
|
|
376
|
+
|
|
377
|
+
# Shoulder buttons
|
|
378
|
+
LB = 0x0100 # Left Bumper / L1
|
|
379
|
+
RB = 0x0200 # Right Bumper / R1
|
|
380
|
+
|
|
381
|
+
# Guide button
|
|
382
|
+
GUIDE = 0x0400
|
|
383
|
+
|
|
384
|
+
# Face buttons (Xbox layout)
|
|
385
|
+
A = 0x1000
|
|
386
|
+
B = 0x2000
|
|
387
|
+
X = 0x4000
|
|
388
|
+
Y = 0x8000
|
|
389
|
+
|
|
390
|
+
# DS4 face buttons (aliases to Xbox buttons)
|
|
391
|
+
CROSS = A
|
|
392
|
+
CIRCLE = B
|
|
393
|
+
SQUARE = X
|
|
394
|
+
TRIANGLE = Y
|
|
395
|
+
L1 = LB
|
|
396
|
+
R1 = RB
|
|
397
|
+
L3 = LEFT_THUMB
|
|
398
|
+
R3 = RIGHT_THUMB
|
|
399
|
+
OPTIONS = START
|
|
400
|
+
SHARE = BACK
|
|
401
|
+
|
|
402
|
+
# DS4 special buttons (unique values)
|
|
403
|
+
PS = 0x10000
|
|
404
|
+
TOUCHPAD = 0x20000
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class MaaGamepadContactEnum(IntEnum):
|
|
408
|
+
"""
|
|
409
|
+
Gamepad contact (analog stick or trigger) mapping for touch_down/touch_move/touch_up.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
LEFT_STICK = 0 # x: -32768~32767, y: -32768~32767
|
|
413
|
+
RIGHT_STICK = 1 # x: -32768~32767, y: -32768~32767
|
|
414
|
+
LEFT_TRIGGER = 2 # pressure: 0~255
|
|
415
|
+
RIGHT_TRIGGER = 3 # pressure: 0~255
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
MaaControllerFeature = ctypes.c_uint64
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
# Use bitwise OR to set the features you need
|
|
422
|
+
class MaaControllerFeatureEnum(IntEnum):
|
|
423
|
+
Null = 0
|
|
424
|
+
|
|
425
|
+
UseMouseDownAndUpInsteadOfClick = 1
|
|
426
|
+
UseKeyboardDownAndUpInsteadOfClick = 1 << 1
|
|
427
|
+
|
|
231
428
|
|
|
232
429
|
class MaaDbgControllerTypeEnum(IntEnum):
|
|
233
430
|
Null = 0
|
|
@@ -238,8 +435,8 @@ class MaaDbgControllerTypeEnum(IntEnum):
|
|
|
238
435
|
|
|
239
436
|
FUNCTYPE = ctypes.WINFUNCTYPE if (platform.system() == "Windows") else ctypes.CFUNCTYPE
|
|
240
437
|
|
|
241
|
-
|
|
242
|
-
None, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p
|
|
438
|
+
MaaEventCallback = FUNCTYPE(
|
|
439
|
+
None, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p
|
|
243
440
|
)
|
|
244
441
|
|
|
245
442
|
MaaCustomRecognitionCallback = FUNCTYPE(
|
|
@@ -282,11 +479,19 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
282
479
|
MaaBool,
|
|
283
480
|
ctypes.c_void_p,
|
|
284
481
|
)
|
|
482
|
+
ConnectedFunc = FUNCTYPE(
|
|
483
|
+
MaaBool,
|
|
484
|
+
ctypes.c_void_p,
|
|
485
|
+
)
|
|
285
486
|
RequestUuidFunc = FUNCTYPE(
|
|
286
487
|
MaaBool,
|
|
287
488
|
ctypes.c_void_p,
|
|
288
489
|
MaaStringBufferHandle,
|
|
289
490
|
)
|
|
491
|
+
GetFeaturesFunc = FUNCTYPE(
|
|
492
|
+
MaaControllerFeature,
|
|
493
|
+
ctypes.c_void_p,
|
|
494
|
+
)
|
|
290
495
|
StartAppFunc = FUNCTYPE(
|
|
291
496
|
MaaBool,
|
|
292
497
|
ctypes.c_char_p,
|
|
@@ -338,7 +543,7 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
338
543
|
ctypes.c_int32,
|
|
339
544
|
ctypes.c_void_p,
|
|
340
545
|
)
|
|
341
|
-
|
|
546
|
+
ClickKeyFunc = FUNCTYPE(
|
|
342
547
|
MaaBool,
|
|
343
548
|
ctypes.c_int32,
|
|
344
549
|
ctypes.c_void_p,
|
|
@@ -348,9 +553,27 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
348
553
|
ctypes.c_char_p,
|
|
349
554
|
ctypes.c_void_p,
|
|
350
555
|
)
|
|
556
|
+
KeyDownFunc = FUNCTYPE(
|
|
557
|
+
MaaBool,
|
|
558
|
+
ctypes.c_int32,
|
|
559
|
+
ctypes.c_void_p,
|
|
560
|
+
)
|
|
561
|
+
KeyUpFunc = FUNCTYPE(
|
|
562
|
+
MaaBool,
|
|
563
|
+
ctypes.c_int32,
|
|
564
|
+
ctypes.c_void_p,
|
|
565
|
+
)
|
|
566
|
+
ScrollFunc = FUNCTYPE(
|
|
567
|
+
MaaBool,
|
|
568
|
+
ctypes.c_int32,
|
|
569
|
+
ctypes.c_int32,
|
|
570
|
+
ctypes.c_void_p,
|
|
571
|
+
)
|
|
351
572
|
_fields_ = [
|
|
352
573
|
("connect", ConnectFunc),
|
|
574
|
+
("connected", ConnectedFunc),
|
|
353
575
|
("request_uuid", RequestUuidFunc),
|
|
576
|
+
("get_features", GetFeaturesFunc),
|
|
354
577
|
("start_app", StartAppFunc),
|
|
355
578
|
("stop_app", StopAppFunc),
|
|
356
579
|
("screencap", ScreencapFunc),
|
|
@@ -359,8 +582,11 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
359
582
|
("touch_down", TouchDownFunc),
|
|
360
583
|
("touch_move", TouchMoveFunc),
|
|
361
584
|
("touch_up", TouchUpFunc),
|
|
362
|
-
("
|
|
585
|
+
("click_key", ClickKeyFunc),
|
|
363
586
|
("input_text", InputTextFunc),
|
|
587
|
+
("key_down", KeyDownFunc),
|
|
588
|
+
("key_up", KeyUpFunc),
|
|
589
|
+
("scroll", ScrollFunc),
|
|
364
590
|
]
|
|
365
591
|
|
|
366
592
|
|
|
@@ -396,6 +622,41 @@ class Status:
|
|
|
396
622
|
return self._status == MaaStatusEnum.running
|
|
397
623
|
|
|
398
624
|
|
|
625
|
+
@dataclass
|
|
626
|
+
class Point:
|
|
627
|
+
x: int = 0
|
|
628
|
+
y: int = 0
|
|
629
|
+
|
|
630
|
+
def __add__(
|
|
631
|
+
self,
|
|
632
|
+
other: Union[
|
|
633
|
+
"Point",
|
|
634
|
+
Tuple[int, int],
|
|
635
|
+
List[int],
|
|
636
|
+
],
|
|
637
|
+
):
|
|
638
|
+
if (
|
|
639
|
+
isinstance(other, Point)
|
|
640
|
+
or isinstance(other, tuple)
|
|
641
|
+
or (isinstance(other, list) and len(other) == 2)
|
|
642
|
+
):
|
|
643
|
+
x1, y1 = self
|
|
644
|
+
x2, y2 = other
|
|
645
|
+
return Point(
|
|
646
|
+
x1 + x2,
|
|
647
|
+
y1 + y2,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
raise TypeError(f"Cannot add {type(other).__name__} to Point")
|
|
651
|
+
|
|
652
|
+
def __iter__(self):
|
|
653
|
+
yield self.x
|
|
654
|
+
yield self.y
|
|
655
|
+
|
|
656
|
+
def __getitem__(self, key):
|
|
657
|
+
return list(self)[key]
|
|
658
|
+
|
|
659
|
+
|
|
399
660
|
@dataclass
|
|
400
661
|
class Rect:
|
|
401
662
|
x: int = 0
|
|
@@ -434,12 +695,15 @@ class Rect:
|
|
|
434
695
|
yield self.h
|
|
435
696
|
|
|
436
697
|
def __getitem__(self, key):
|
|
437
|
-
return self
|
|
698
|
+
return list(self)[key]
|
|
438
699
|
|
|
439
|
-
@property
|
|
440
|
-
def roi(self):
|
|
441
|
-
return list(self)
|
|
442
700
|
|
|
701
|
+
PointType = Union[
|
|
702
|
+
Point,
|
|
703
|
+
List[int],
|
|
704
|
+
numpy.ndarray,
|
|
705
|
+
Tuple[int, int],
|
|
706
|
+
]
|
|
443
707
|
|
|
444
708
|
RectType = Union[
|
|
445
709
|
Rect,
|
|
@@ -457,6 +721,31 @@ class AlgorithmEnum(StrEnum):
|
|
|
457
721
|
OCR = "OCR"
|
|
458
722
|
NeuralNetworkClassify = "NeuralNetworkClassify"
|
|
459
723
|
NeuralNetworkDetect = "NeuralNetworkDetect"
|
|
724
|
+
And = "And"
|
|
725
|
+
Or = "Or"
|
|
726
|
+
Custom = "Custom"
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
class ActionEnum(StrEnum):
|
|
730
|
+
DoNothing = "DoNothing"
|
|
731
|
+
Click = "Click"
|
|
732
|
+
LongPress = "LongPress"
|
|
733
|
+
Swipe = "Swipe"
|
|
734
|
+
MultiSwipe = "MultiSwipe"
|
|
735
|
+
ClickKey = "ClickKey"
|
|
736
|
+
LongPressKey = "LongPressKey"
|
|
737
|
+
InputText = "InputText"
|
|
738
|
+
StartApp = "StartApp"
|
|
739
|
+
StopApp = "StopApp"
|
|
740
|
+
Scroll = "Scroll"
|
|
741
|
+
TouchDown = "TouchDown"
|
|
742
|
+
TouchMove = "TouchMove"
|
|
743
|
+
TouchUp = "TouchUp"
|
|
744
|
+
KeyDown = "KeyDown"
|
|
745
|
+
KeyUp = "KeyUp"
|
|
746
|
+
StopTask = "StopTask"
|
|
747
|
+
Command = "Command"
|
|
748
|
+
Shell = "Shell"
|
|
460
749
|
Custom = "Custom"
|
|
461
750
|
|
|
462
751
|
|
|
@@ -502,6 +791,20 @@ class CustomRecognitionResult:
|
|
|
502
791
|
detail: Union[str, Dict]
|
|
503
792
|
|
|
504
793
|
|
|
794
|
+
@dataclass
|
|
795
|
+
class AndRecognitionResult:
|
|
796
|
+
"""And 算法识别结果,包含所有子识别的完整详情"""
|
|
797
|
+
|
|
798
|
+
sub_results: List["RecognitionDetail"]
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
@dataclass
|
|
802
|
+
class OrRecognitionResult:
|
|
803
|
+
"""Or 算法识别结果,包含已执行子识别的完整详情"""
|
|
804
|
+
|
|
805
|
+
sub_results: List["RecognitionDetail"]
|
|
806
|
+
|
|
807
|
+
|
|
505
808
|
RecognitionResult = Union[
|
|
506
809
|
TemplateMatchResult,
|
|
507
810
|
FeatureMatchResult,
|
|
@@ -509,6 +812,8 @@ RecognitionResult = Union[
|
|
|
509
812
|
OCRResult,
|
|
510
813
|
NeuralNetworkClassifyResult,
|
|
511
814
|
NeuralNetworkDetectResult,
|
|
815
|
+
AndRecognitionResult,
|
|
816
|
+
OrRecognitionResult,
|
|
512
817
|
CustomRecognitionResult,
|
|
513
818
|
]
|
|
514
819
|
|
|
@@ -520,6 +825,8 @@ AlgorithmResultDict = {
|
|
|
520
825
|
AlgorithmEnum.OCR: OCRResult,
|
|
521
826
|
AlgorithmEnum.NeuralNetworkClassify: NeuralNetworkClassifyResult,
|
|
522
827
|
AlgorithmEnum.NeuralNetworkDetect: NeuralNetworkDetectResult,
|
|
828
|
+
AlgorithmEnum.And: AndRecognitionResult,
|
|
829
|
+
AlgorithmEnum.Or: OrRecognitionResult,
|
|
523
830
|
AlgorithmEnum.Custom: CustomRecognitionResult,
|
|
524
831
|
}
|
|
525
832
|
|
|
@@ -528,11 +835,12 @@ AlgorithmResultDict = {
|
|
|
528
835
|
class RecognitionDetail:
|
|
529
836
|
reco_id: int
|
|
530
837
|
name: str
|
|
531
|
-
algorithm: AlgorithmEnum
|
|
838
|
+
algorithm: Union[AlgorithmEnum, str]
|
|
839
|
+
hit: bool
|
|
532
840
|
box: Optional[Rect]
|
|
533
841
|
|
|
534
842
|
all_results: List[RecognitionResult]
|
|
535
|
-
|
|
843
|
+
filtered_results: List[RecognitionResult]
|
|
536
844
|
best_result: Optional[RecognitionResult]
|
|
537
845
|
|
|
538
846
|
raw_detail: Dict
|
|
@@ -540,11 +848,133 @@ class RecognitionDetail:
|
|
|
540
848
|
draw_images: List[numpy.ndarray] # only valid in debug mode
|
|
541
849
|
|
|
542
850
|
|
|
851
|
+
@dataclass
|
|
852
|
+
class ClickActionResult:
|
|
853
|
+
point: Point
|
|
854
|
+
contact: int
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
@dataclass
|
|
858
|
+
class LongPressActionResult:
|
|
859
|
+
point: Point
|
|
860
|
+
duration: int
|
|
861
|
+
contact: int
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
@dataclass
|
|
865
|
+
class SwipeActionResult:
|
|
866
|
+
begin: Point
|
|
867
|
+
end: List[Point]
|
|
868
|
+
end_hold: List[int]
|
|
869
|
+
duration: List[int]
|
|
870
|
+
only_hover: bool
|
|
871
|
+
starting: int
|
|
872
|
+
contact: int
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
@dataclass
|
|
876
|
+
class MultiSwipeActionResult:
|
|
877
|
+
swipes: List[SwipeActionResult]
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
@dataclass
|
|
881
|
+
class ClickKeyActionResult:
|
|
882
|
+
keycode: List[int]
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
@dataclass
|
|
886
|
+
class LongPressKeyActionResult:
|
|
887
|
+
keycode: List[int]
|
|
888
|
+
duration: int
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
@dataclass
|
|
892
|
+
class InputTextActionResult:
|
|
893
|
+
text: str
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
@dataclass
|
|
897
|
+
class AppActionResult:
|
|
898
|
+
package: str
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
@dataclass
|
|
902
|
+
class ScrollActionResult:
|
|
903
|
+
dx: int
|
|
904
|
+
dy: int
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
@dataclass
|
|
908
|
+
class TouchActionResult:
|
|
909
|
+
contact: int
|
|
910
|
+
point: Point
|
|
911
|
+
pressure: int
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
@dataclass
|
|
915
|
+
class ShellActionResult:
|
|
916
|
+
cmd: str
|
|
917
|
+
timeout: int
|
|
918
|
+
success: bool
|
|
919
|
+
output: str
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
ActionResult = Union[
|
|
923
|
+
ClickActionResult,
|
|
924
|
+
LongPressActionResult,
|
|
925
|
+
SwipeActionResult,
|
|
926
|
+
MultiSwipeActionResult,
|
|
927
|
+
ClickKeyActionResult,
|
|
928
|
+
LongPressKeyActionResult,
|
|
929
|
+
InputTextActionResult,
|
|
930
|
+
AppActionResult,
|
|
931
|
+
ScrollActionResult,
|
|
932
|
+
TouchActionResult,
|
|
933
|
+
ShellActionResult,
|
|
934
|
+
None,
|
|
935
|
+
]
|
|
936
|
+
|
|
937
|
+
ActionResultDict = {
|
|
938
|
+
ActionEnum.DoNothing: None,
|
|
939
|
+
ActionEnum.Click: ClickActionResult,
|
|
940
|
+
ActionEnum.LongPress: LongPressActionResult,
|
|
941
|
+
ActionEnum.Swipe: SwipeActionResult,
|
|
942
|
+
ActionEnum.MultiSwipe: MultiSwipeActionResult,
|
|
943
|
+
ActionEnum.ClickKey: ClickKeyActionResult,
|
|
944
|
+
ActionEnum.LongPressKey: LongPressKeyActionResult,
|
|
945
|
+
ActionEnum.InputText: InputTextActionResult,
|
|
946
|
+
ActionEnum.StartApp: AppActionResult,
|
|
947
|
+
ActionEnum.StopApp: AppActionResult,
|
|
948
|
+
ActionEnum.Scroll: ScrollActionResult,
|
|
949
|
+
ActionEnum.TouchDown: TouchActionResult,
|
|
950
|
+
ActionEnum.TouchMove: TouchActionResult,
|
|
951
|
+
ActionEnum.TouchUp: TouchActionResult,
|
|
952
|
+
ActionEnum.KeyDown: ClickKeyActionResult,
|
|
953
|
+
ActionEnum.KeyUp: ClickKeyActionResult,
|
|
954
|
+
ActionEnum.StopTask: None,
|
|
955
|
+
ActionEnum.Command: None,
|
|
956
|
+
ActionEnum.Shell: ShellActionResult,
|
|
957
|
+
ActionEnum.Custom: None,
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
@dataclass
|
|
962
|
+
class ActionDetail:
|
|
963
|
+
action_id: int
|
|
964
|
+
name: str
|
|
965
|
+
action: Union[ActionEnum, str]
|
|
966
|
+
box: Rect
|
|
967
|
+
success: bool
|
|
968
|
+
result: Optional[ActionResult]
|
|
969
|
+
raw_detail: Dict
|
|
970
|
+
|
|
971
|
+
|
|
543
972
|
@dataclass
|
|
544
973
|
class NodeDetail:
|
|
545
974
|
node_id: int
|
|
546
975
|
name: str
|
|
547
|
-
recognition: RecognitionDetail
|
|
976
|
+
recognition: Optional[RecognitionDetail]
|
|
977
|
+
action: Optional[ActionDetail]
|
|
548
978
|
completed: bool
|
|
549
979
|
|
|
550
980
|
|