(
self,
context: Context,
argv: CustomRecognition.AnalyzeArg,
)
| 23 | """ |
| 24 | |
| 25 | def analyze( |
| 26 | self, |
| 27 | context: Context, |
| 28 | argv: CustomRecognition.AnalyzeArg, |
| 29 | ) -> CustomRecognition.AnalyzeResult | RectType | None: |
| 30 | |
| 31 | data = parse_params(argv.custom_recognition_param) |
| 32 | expected = data.get("expected") |
| 33 | inverse = data.get("inverse", False) |
| 34 | |
| 35 | img = context.tasker.controller.post_screencap().wait().get() |
| 36 | |
| 37 | roi_list = [ |
| 38 | [325, 286, 93, 30], |
| 39 | [568, 284, 93, 30], |
| 40 | [798, 286, 107, 28], |
| 41 | [1047, 285, 93, 30], |
| 42 | [327, 547, 93, 30], |
| 43 | [566, 546, 93, 30], |
| 44 | [806, 546, 93, 30], |
| 45 | [1046, 547, 93, 30], |
| 46 | ] |
| 47 | |
| 48 | for roi in roi_list: |
| 49 | try: |
| 50 | reco_detail = context.run_recognition( |
| 51 | "BankShopTemplate", |
| 52 | img, |
| 53 | {"BankShopTemplate": {"roi": roi, "expected": expected}}, |
| 54 | ) |
| 55 | |
| 56 | if is_hit(reco_detail): |
| 57 | if inverse: |
| 58 | return None |
| 59 | return reco_detail.box |
| 60 | except Exception as e: |
| 61 | logger.warning(f"Recognition error: {e}") |
| 62 | continue |
| 63 | |
| 64 | if inverse: |
| 65 | return [0, 0, 0, 0] |
| 66 | return None |
nothing calls this directly
no test coverage detected