69 lines
1.8 KiB
Python
Executable File
69 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
"""
|
||
测试AI相机集成的脚本
|
||
"""
|
||
|
||
import sys
|
||
import os
|
||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
from utils.image_raw import ImageProcessor
|
||
import time
|
||
|
||
def test_ai_camera_integration():
|
||
"""测试AI相机集成功能"""
|
||
print("开始测试AI相机集成...")
|
||
|
||
try:
|
||
# 创建图像处理器实例
|
||
processor = ImageProcessor()
|
||
print("✓ 图像处理器创建成功")
|
||
|
||
# 启动处理器
|
||
processor.run()
|
||
print("✓ 图像处理器启动成功")
|
||
|
||
# 等待一段时间让相机启动
|
||
print("等待相机启动...")
|
||
time.sleep(3)
|
||
|
||
# 测试获取图像
|
||
image = processor.get_current_image()
|
||
if image is not None:
|
||
print(f"✓ 成功获取图像,尺寸: {image.shape}")
|
||
else:
|
||
print("⚠ 未获取到图像")
|
||
|
||
# 测试异步QR码扫描
|
||
print("启动异步QR码扫描...")
|
||
processor.start_async_scan(interval=1.0)
|
||
|
||
# 运行一段时间
|
||
print("运行10秒进行测试...")
|
||
time.sleep(10)
|
||
|
||
# 停止扫描
|
||
processor.stop_async_scan()
|
||
print("✓ 异步扫描已停止")
|
||
|
||
# 获取QR码结果
|
||
qr_result, qr_time = processor.get_last_qr_result()
|
||
if qr_result:
|
||
print(f"✓ 扫描到QR码: {qr_result}")
|
||
else:
|
||
print("ℹ 未扫描到QR码")
|
||
|
||
# 清理资源
|
||
processor.destroy()
|
||
print("✓ 资源清理完成")
|
||
|
||
print("测试完成!")
|
||
|
||
except Exception as e:
|
||
print(f"❌ 测试失败: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
|
||
if __name__ == "__main__":
|
||
test_ai_camera_integration()
|