Skip to main content

摄像头小程序实时预览出图时间统计工具

Project description

摄像头小程序实时预览出图时间统计工具

本项目用于测试摄像头小程序实时预览出图时间,并将每次测试的结果(含不出图的情况)汇总成友好的报表和明细列表,便于后续分析。

功能概览

  1. 自动化触发播放/出图:利用 uiautomator2 控制设备进入指定摄像头预览并点击播放按钮。
  2. 黑屏检测:通过裁剪预览区域并计算平均亮度,判断是否真正出图。
  3. 耗时统计:多次执行测试,将成功与失败(不出图)记录到列表。
  4. 结果导出:以文本或 CSV 形式保存统计结果,包含平均值、最大/最小值、不出图率等指标。

目录结构

anjia_test/
├── anjia_test/               # 可发布的 Python 包(导入名:anjia_test)
│   ├── __init__.py
│   ├── cli.py                # 命令行入口:anjia-test
│   └── utils/
│       ├── notify_wx.py
│       ├── time_count.py
│       └── time_statistic.py
├── requirements.txt          # 依赖包
├── pyproject.toml            # 打包/发布配置
└── README.md

环境要求

  • Python 3.9+
  • 已开启调试模式并能通过 USB/Wi-Fi 连接的安卓设备
  • 电脑端安装了与设备匹配的 ADB 驱动

安装依赖

pip install -r requirements.txt

快速开始

  1. 连接设备:确保安卓设备与电脑连接,uiautomator2 能够正常识别。
  2. 安装(开发模式)
    pip install -e .
    
  3. 启动命令行工具
    anjia-test -c 10 -n "单目摄像头A" -t 30 -f csv -o result/test.txt -w "<wecom_webhook>"
    
  4. 查看输出:程序会在控制台打印每次测试的耗时,并在 result/ 目录下生成带时间戳的统计文件(文本或 CSV)。

自定义用法

  • 调整测试次数或最大等待时间:
    from anjia_test import time_statistics, save_time_statistics
    import uiautomator2 as u2
    
    d = u2.connect()
    time_data = time_statistics(device=d, count=5, camera_name="单目摄像头A", overdue_time=30)
    save_time_statistics(time_statistics=time_data, file_path="result/test.txt", format_type="csv", overdue_time=30)
    
  • 若原始耗时单位为毫秒,可在 save_time_statistics 中指定 time_unit="milliseconds",函数会自动转换为秒并保持统计正确。

输出示例

生成的文本报告包含:

  • 总测试次数、成功次数、不出图次数、不出图率
  • 有效耗时的总计、平均值、最大值、最小值
  • 每次测试的状态与原始耗时值

CSV 文件在上述内容外,还会追加原始秒值和毫秒值,方便进一步分析。


如需扩展更多指标(例如失败截图保存、AI 识别等),可基于 utils/time_count.pyutils/time_statistic.py 进行定制。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anjia_test-1.0.3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anjia_test-1.0.3-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file anjia_test-1.0.3.tar.gz.

File metadata

  • Download URL: anjia_test-1.0.3.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for anjia_test-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9eebbf89cf73cf6a73bed9ccf7285848a027a75ba398eef6875401404a584f8e
MD5 5d27bdda1d7fd1c1136fd0b9b91edb82
BLAKE2b-256 a976e218cba899a0e37661098b19c9eded668d30d0462e075f3aebdedef28ab8

See more details on using hashes here.

File details

Details for the file anjia_test-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: anjia_test-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for anjia_test-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 86f9a153e413d7c8245f7667fe2922a848fd9a1f19edb399381a3b1147e72511
MD5 101a5a3e3791dd46c375612be50b9f94
BLAKE2b-256 d5cf33e8720eabdd85799ff763d174c807d70a170ba700721c4f83750f5443ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page