新增代码
This commit is contained in:
36
difyPlugin/verify_qrcode.py
Normal file
36
difyPlugin/verify_qrcode.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""验证二维码服务(纯 OpenCV 方案)"""
|
||||
import sys
|
||||
import asyncio
|
||||
|
||||
try:
|
||||
from app.services.workcase.qrcode import QrCodeService
|
||||
print("✓ 二维码服务导入成功")
|
||||
|
||||
async def test():
|
||||
service = QrCodeService()
|
||||
|
||||
# 测试生成
|
||||
result = await service.generate_qrcode("https://github.com", size=300)
|
||||
if result["success"]:
|
||||
print("✓ 二维码生成成功")
|
||||
|
||||
# 测试解析
|
||||
parse_result = await service.parse_qrcode(result["image"], strategy="auto")
|
||||
if parse_result["success"]:
|
||||
print(f"✓ 二维码解析成功: {parse_result['content']}")
|
||||
print(f" 使用策略: {parse_result['strategy_used']}")
|
||||
print(f" 尝试次数: {parse_result['total_attempts']}")
|
||||
else:
|
||||
print(f"✗ 解析失败: {parse_result.get('error', '未知错误')}")
|
||||
else:
|
||||
print(f"✗ 生成失败: {result.get('error', '未知错误')}")
|
||||
|
||||
asyncio.run(test())
|
||||
print("\n✅ 所有测试通过 - 纯 OpenCV 方案运行正常")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ 错误: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user