fix: 空渠道检测改用JSONObject.has + 移除gitignore误排除manifest

This commit is contained in:
LukeMackin
2026-07-19 23:10:03 +08:00
parent ffd05e3e17
commit a96560966c
33 changed files with 891 additions and 6 deletions

48
ocr_win.py Normal file
View File

@@ -0,0 +1,48 @@
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
print("Attempting Windows OCR...")
try:
import asyncio
from winsdk.windows.media.ocr import OcrEngine
from winsdk.windows.graphics.imaging import BitmapDecoder
from winsdk.windows.storage.streams import RandomAccessStreamReference
from winsdk.windows.globalization import Language
import os
async def ocr():
path = os.path.abspath(r"D:\Yuzu-GCA\screen2.png")
print(f"Opening: {path}")
# Try to get engine for Chinese
engine = OcrEngine.try_create_from_user_profile_languages()
if not engine:
print("No user profile languages, trying Chinese...")
engine = OcrEngine.try_create_from_language(Language("zh-Hans"))
if not engine:
print("Trying English...")
engine = OcrEngine.try_create_from_language(Language("en"))
if not engine:
print("No OCR engine available")
return
print(f"Using OCR engine: {engine.recognizer_language.display_name}")
file_stream = await RandomAccessStreamReference.create_from_file(path).open_read_async()
decoder = await BitmapDecoder.create_async(file_stream)
bitmap = await decoder.get_software_bitmap_async()
result = await engine.recognize_async(bitmap)
print(f"\n=== Windows OCR Result ({result.lines.size} lines) ===")
for line in result.lines:
print(line.text)
asyncio.run(ocr())
except ImportError as e:
print(f"winsdk not available: {e}")
except Exception as e:
print(f"Error: {e}")