Files
aisee/aisee_flutter/README.md
2026-03-02 22:57:35 +08:00

115 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AISee Flutter 实时相机
实时相机图像捕获和传输演示项目。
## 功能特性
- ✅ 实时相机预览
- ✅ 图像自动压缩640x480质量 85%
- ✅ 定时捕获(每 500ms 一帧)
- ✅ 异步上传到后端
- ✅ 单张拍照并分析
- ✅ 前后摄像头切换
- ✅ 实时状态显示
## 快速开始
### 1. 安装依赖
```bash
flutter pub get
```
### 2. 配置后端地址
编辑 `lib/utils/app_config.dart`
```dart
// Android 模拟器
static const String apiBaseUrl = 'http://10.0.2.2:8000';
// 真机(改为你的电脑 IP
static const String apiBaseUrl = 'http://192.168.1.100:8000';
```
### 3. 运行项目
```bash
flutter run
```
## 项目结构
```
lib/
├── main.dart # 入口和首页
├── screens/
│ └── camera_screen.dart # 相机页面
├── services/
│ ├── camera_service.dart # 相机服务
│ └── api_service.dart # API 服务
└── utils/
└── app_config.dart # 配置
```
## 使用说明
1. **打开相机**:点击首页"打开相机"按钮
2. **拍照分析**:拍摄单张照片并上传分析
3. **开始传输**:每 500ms 自动捕获并上传
4. **停止传输**:停止实时捕获
5. **切换摄像头**:前后摄像头切换
## 配置参数
`lib/utils/app_config.dart` 中调整:
```dart
static const int imageMaxWidth = 640; // 图像宽度
static const int imageMaxHeight = 480; // 图像高度
static const int imageQuality = 85; // JPEG 质量
static const Duration captureInterval = Duration(milliseconds: 500); // 捕获间隔
```
## 后端 API
需要实现以下端点:
```
POST /api/v1/images/upload # 上传图像
POST /api/v1/analysis/analyze # 分析图像
```
详细文档见项目根目录的技术方案文档。
## 依赖
- camera: ^0.10.5+9
- image: ^4.1.7
- dio: ^5.4.1
- permission_handler: ^11.3.0
- provider: ^6.1.1
## 常见问题
**Q: 相机权限被拒绝?**
A: 在手机设置中授予相机权限并重启应用。
**Q: 网络连接失败?**
A: 检查后端服务是否启动,确认 IP 地址配置正确。
**Q: 上传速度慢?**
A: 降低图像分辨率或增加捕获间隔。
---
更多信息请查看项目文档。
- [Learn Flutter](https://docs.flutter.dev/get-started/learn-flutter)
- [Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Flutter learning resources](https://docs.flutter.dev/reference/learning-resources)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.