perf: reuse image array to improve memory performance

This commit is contained in:
2026-07-05 18:55:37 +08:00
parent d34c082ef3
commit aa4afbf6a2
4 changed files with 74 additions and 80 deletions
+3 -4
View File
@@ -1,4 +1,3 @@
import typing as t
from dataclasses import dataclass
from functools import wraps
from json.decoder import JSONDecodeError
@@ -10,8 +9,8 @@ from lxml import etree
from module.base.utils import *
from module.device.connection import Connection
from module.device.method.utils import (RETRY_TRIES, retry_sleep, handle_adb_error,
ImageTruncated, PackageNotInstalled, possible_reasons)
from module.device.method.utils import (ImageTruncated, PackageNotInstalled, RETRY_TRIES, handle_adb_error,
possible_reasons, retry_sleep)
from module.exception import RequestHumanTakeover
from module.logger import logger
@@ -122,7 +121,7 @@ class Uiautomator2(Connection):
if image is None:
raise ImageTruncated('Empty image after cv2.imdecode')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB, dst=image)
if image is None:
raise ImageTruncated('Empty image after cv2.cvtColor')