ARM摄像头工具包 v3.0 - 专为Jupyter环境和ARM设备优化,修复MJPEG流问题
Project description
aitoolkit-cam
极简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- 摄像头信息
🎯 使用场景
- 教育项目: 简单易懂的API,适合编程教学
- IoT应用: ARM设备上的视频监控
- Jupyter研究: 数据科学和机器学习中的图像处理
- Web应用: 快速集成视频流功能
- 原型开发: 快速搭建包含摄像头的应用原型
📞 技术支持
- 问题反馈: GitHub Issues
- 源代码: GitHub Repository
- 作者: Haitao Wang
- 邮箱: dianx12@163.com
📄 许可证
MIT License - 详见 LICENSE 文件。
🏷️ 标签
camera opencv video streaming web cv2 jupyter notebook education arm64 raspberry-pi real-time smart-stop mjpeg fastapi
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
323068501d37b726c1668cce6c7fd4cc37c20f6a025722ddf199eff970511727
|
|
| MD5 |
120c578294445a72c5d30baa125f1d61
|
|
| BLAKE2b-256 |
afa03b86e3be8b71cadadf2db8b5e00c30fd3a7227bcffb6fe9b90caa40fb47a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1e106d61fc24c6b1b15e4d2085f505461dded5929e2b256ae226839df7c134f
|
|
| MD5 |
146d60e4efb9b890363d609c2ca623b7
|
|
| BLAKE2b-256 |
4c3278e1515518742f2100c6f11669bd8667d68a778f3a9f4c6a1678bc2cddbd
|