fix: Clean up blank lines and enhance readability across multiple files
- Removed excessive blank lines from various markdown and Python files to improve readability and maintainability. - Ensured consistent formatting across documentation and code files, enhancing overall project clarity. - Updated logging mechanisms for better consistency and debugging support.
This commit is contained in:
1 parent
f36f1a9593
commit
5d22250b05
35 files changed
+15431
-3674
No files matched your search
+50
-38
@@ -1109,43 +1109,45 @@ class underlying_operations:
|
||||
img1 = img # img1 is used later, initialize from img
|
||||
img2 = None
|
||||
text2 = None
|
||||
if (not text) and max(w, h) <= 1200:
|
||||
try:
|
||||
img2 = img.resize((w * 2, h * 2), _RESAMPLE.LANCZOS)
|
||||
try:
|
||||
from PIL import ImageEnhance
|
||||
|
||||
img2_sharpened = img2.filter(
|
||||
ImageFilter.UnsharpMask(radius=1.5, percent=180, threshold=3)
|
||||
)
|
||||
enhancer = ImageEnhance.Contrast(img2_sharpened)
|
||||
img2 = enhancer.enhance(1.2)
|
||||
except Exception:
|
||||
img2 = img2.filter(ImageFilter.SHARPEN)
|
||||
|
||||
if getattr(self, "ocr_type", None) == "easyocr":
|
||||
result2 = self.ocr.readtext(np.array(img2))
|
||||
extract_result2 = self.extract_ocr_content(result2, return_confidence=True)
|
||||
if isinstance(extract_result2, tuple):
|
||||
text2, ocr_confidence_info = extract_result2
|
||||
else:
|
||||
text2 = extract_result2
|
||||
if text2:
|
||||
text = text2
|
||||
result = result2
|
||||
else:
|
||||
result2 = self.ocr.ocr(np.array(img2))
|
||||
if result2 != [None]:
|
||||
extract_result2 = self.extract_ocr_content(result2, return_confidence=True)
|
||||
if isinstance(extract_result2, tuple):
|
||||
text2, ocr_confidence_info = extract_result2
|
||||
else:
|
||||
text2 = extract_result2
|
||||
if text2:
|
||||
text = text2
|
||||
result = result2
|
||||
except Exception:
|
||||
pass
|
||||
# 禁用二次OCR识别(用户要求:没有GPU,不需要二次OCR)
|
||||
# 如果第一次识别失败,直接返回空结果,避免耗时3-4秒的二次识别
|
||||
# if (not text) and max(w, h) <= 1200:
|
||||
# try:
|
||||
# img2 = img.resize((w * 2, h * 2), _RESAMPLE.LANCZOS)
|
||||
# try:
|
||||
# from PIL import ImageEnhance
|
||||
#
|
||||
# img2_sharpened = img2.filter(
|
||||
# ImageFilter.UnsharpMask(radius=1.5, percent=180, threshold=3)
|
||||
# )
|
||||
# enhancer = ImageEnhance.Contrast(img2_sharpened)
|
||||
# img2 = enhancer.enhance(1.2)
|
||||
# except Exception:
|
||||
# img2 = img2.filter(ImageFilter.SHARPEN)
|
||||
#
|
||||
# if getattr(self, "ocr_type", None) == "easyocr":
|
||||
# result2 = self.ocr.readtext(np.array(img2))
|
||||
# extract_result2 = self.extract_ocr_content(result2, return_confidence=True)
|
||||
# if isinstance(extract_result2, tuple):
|
||||
# text2, ocr_confidence_info = extract_result2
|
||||
# else:
|
||||
# text2 = extract_result2
|
||||
# if text2:
|
||||
# text = text2
|
||||
# result = result2
|
||||
# else:
|
||||
# result2 = self.ocr.ocr(np.array(img2))
|
||||
# if result2 != [None]:
|
||||
# extract_result2 = self.extract_ocr_content(result2, return_confidence=True)
|
||||
# if isinstance(extract_result2, tuple):
|
||||
# text2, ocr_confidence_info = extract_result2
|
||||
# else:
|
||||
# text2 = extract_result2
|
||||
# if text2:
|
||||
# text = text2
|
||||
# result = result2
|
||||
# except Exception:
|
||||
# pass
|
||||
|
||||
if picname in ("福袋内容", "福袋倒计时") and not text:
|
||||
try:
|
||||
@@ -1650,9 +1652,19 @@ class underlying_operations:
|
||||
right_down_y=1500,
|
||||
steps=200,
|
||||
):
|
||||
"""划动屏幕"""
|
||||
"""划动屏幕
|
||||
|
||||
参数说明:
|
||||
- left_up_x, left_up_y: 滑动起始位置(手指按下位置)
|
||||
- right_down_x, right_down_y: 滑动结束位置(手指抬起位置)
|
||||
- steps: 滑动步数(影响滑动速度,数值越大滑动越慢)
|
||||
|
||||
执行命令:adb shell input swipe <start_x> <start_y> <end_x> <end_y> <duration_ms>
|
||||
"""
|
||||
import subprocess
|
||||
adb_cmd = self._adb()
|
||||
# 注意:adb input swipe 的参数顺序是:start_x start_y end_x end_y duration_ms
|
||||
# 这里 left_up_x/y 是起始位置,right_down_x/y 是结束位置
|
||||
cmd = f"{adb_cmd} -s {device_id} shell input swipe {left_up_x} {left_up_y} {right_down_x} {right_down_y} {steps}"
|
||||
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user