Skip to main content

ARM摄像头工具包 v3.0 - 专为Jupyter环境和ARM设备优化,修复MJPEG流问题

Project description

aitoolkit-cam

PyPI version Python versions License

极简Python摄像头库 - 专为ARM设备和Jupyter环境设计的高性能摄像头工具包。

🚀 特性

  • 🎯 简单易用: 三行代码即可启动摄像头流
  • 🔧 MJPEG流修复: v3.0版本完全解决视频流断流问题
  • 🏢 多客户端支持: 支持多用户同时访问摄像头流
  • 📱 Jupyter优化: 专为Jupyter notebook环境优化
  • 🔄 ARM64优化: 针对树莓派等ARM设备优化性能
  • ⚡ FastAPI集成: 内置Web服务器,一键启动视频流
  • 🎨 实时图像处理: 内置多种滤镜和图像处理功能

🛠️ 安装

pip install aitoolkit-cam

📖 快速开始

基本使用

from aitoolkit_cam import Camera

# 启动摄像头
with Camera(source=0, max_frames=100) as cam:
    url = cam.start()
    print(f"视频流地址: {url}")

    # 处理每一帧
    for frame in cam:
        # 在这里添加你的图像处理代码
        processed_frame = your_processing_function(frame)
        cam.show(processed_frame)

FastAPI Web服务

from fastapi import FastAPI
from aitoolkit_cam import add_camera_routes

app = FastAPI()
add_camera_routes(app, prefix="/camera")

# 访问 http://localhost:8000/camera/stream 查看视频流

Jupyter Notebook中使用

import aitoolkit_cam

# 快速启动摄像头管理器
manager = aitoolkit_cam.camera_manager
print(f"摄像头状态: {manager.is_running}")

# 获取单帧图像
frame = manager.read_frame()
if frame is not None:
    print(f"成功获取帧: {frame.shape}")

🔧 高级功能

图像滤镜

from aitoolkit_cam import Camera, ImageFilters

with Camera() as cam:
    filters = ImageFilters()
    url = cam.start()

    for frame in cam:
        # 应用复古滤镜
        vintage_frame = filters.vintage(frame)
        cam.show(vintage_frame)

设备管理

from aitoolkit_cam import list_available_cameras, get_optimal_camera

# 列出所有可用摄像头
cameras = list_available_cameras()
print(f"发现 {len(cameras)} 个摄像头设备")

# 自动选择最佳摄像头
best_camera = get_optimal_camera()
print(f"推荐使用摄像头: {best_camera}")

📋 版本历史

v3.0.0 (2025-10-06)

  • 重大修复: 完全解决MJPEG视频流断流问题
  • 多客户端支持: 添加JPEG缓存机制,支持多用户同时访问
  • 连接稳定性: 改进错误处理和恢复机制
  • 浏览器兼容性: 添加Content-Length头,提高兼容性
  • 性能优化: 优化ARM设备上的性能表现

v2.0.0

  • 修复MJPEG流显示问题
  • 改进多客户端支持

v1.1.0

  • 基础摄像头功能
  • Jupyter环境集成

🔧 API文档

Camera类

Camera(source=0, width=640, height=480, fps=20, max_frames=None)

参数:

  • source: 摄像头设备索引或路径
  • width: 视频宽度 (默认: 640)
  • height: 视频高度 (默认: 480)
  • fps: 帧率 (默认: 20)
  • max_frames: 最大帧数限制 (默认: None)

FastAPI集成

add_camera_routes(app, prefix="/camera")

端点:

  • GET /camera/stream - MJPEG视频流
  • GET /camera/frame - 单帧JPEG图像
  • GET /camera/info - 摄像头信息

🎯 使用场景

  1. 教育项目: 简单易懂的API,适合编程教学
  2. IoT应用: ARM设备上的视频监控
  3. Jupyter研究: 数据科学和机器学习中的图像处理
  4. Web应用: 快速集成视频流功能
  5. 原型开发: 快速搭建包含摄像头的应用原型

📞 技术支持

📄 许可证

MIT License - 详见 LICENSE 文件。

🏷️ 标签

camera opencv video streaming web cv2 jupyter notebook education arm64 raspberry-pi real-time smart-stop mjpeg fastapi

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

aitoolkit_cam-3.5.0.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

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

aitoolkit_cam-3.5.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file aitoolkit_cam-3.5.0.tar.gz.

File metadata

  • Download URL: aitoolkit_cam-3.5.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aitoolkit_cam-3.5.0.tar.gz
Algorithm Hash digest
SHA256 323068501d37b726c1668cce6c7fd4cc37c20f6a025722ddf199eff970511727
MD5 120c578294445a72c5d30baa125f1d61
BLAKE2b-256 afa03b86e3be8b71cadadf2db8b5e00c30fd3a7227bcffb6fe9b90caa40fb47a

See more details on using hashes here.

File details

Details for the file aitoolkit_cam-3.5.0-py3-none-any.whl.

File metadata

  • Download URL: aitoolkit_cam-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aitoolkit_cam-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1e106d61fc24c6b1b15e4d2085f505461dded5929e2b256ae226839df7c134f
MD5 146d60e4efb9b890363d609c2ca623b7
BLAKE2b-256 4c3278e1515518742f2100c6f11669bd8667d68a778f3a9f4c6a1678bc2cddbd

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