|
|
# 文件保存路径结构说明
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
本系统采用分层目录结构保存相机拍摄的图片和点云数据,便于管理和查找。
|
|
|
|
|
|
## 路径格式
|
|
|
|
|
|
### 完整路径格式
|
|
|
|
|
|
```
|
|
|
basePath/日期/类型/SN_类型_时间戳.扩展名
|
|
|
```
|
|
|
|
|
|
### 路径组成
|
|
|
|
|
|
| 组成部分 | 说明 | 示例 |
|
|
|
|---------|------|------|
|
|
|
| basePath | 基础保存路径 | `D:/output` |
|
|
|
| 日期 | 拍摄日期(yyyyMMdd) | `20250325` |
|
|
|
| 类型 | 文件类型文件夹 | `amplitude`、`rgb`、`depth`、`depthColor`、`pointCloud` |
|
|
|
| SN | 相机序列号 | `192.168.1.100` |
|
|
|
| 类型 | 重复文件类型 | `amplitude`、`rgb`、`depth`、`depthColor`、`pointcloud` |
|
|
|
| 时间戳 | 拍摄时间(yyyyMMdd_HHmmss) | `20250325_143022` |
|
|
|
| 扩展名 | 文件扩展名 | `.png`、`.pcd` |
|
|
|
|
|
|
## 目录树示例
|
|
|
|
|
|
```
|
|
|
D:/output/
|
|
|
├── 20250325/ # 日期:2025年3月25日
|
|
|
│ ├── amplitude/ # 强度图
|
|
|
│ │ ├── 192.168.1.100_amplitude_20250325_143022.png
|
|
|
│ │ ├── 192.168.1.101_amplitude_20250325_143023.png
|
|
|
│ │ └── 192.168.1.102_amplitude_20250325_143024.png
|
|
|
│ ├── rgb/ # RGB彩色图
|
|
|
│ │ ├── 192.168.1.100_rgb_20250325_143022.png
|
|
|
│ │ ├── 192.168.1.101_rgb_20250325_143023.png
|
|
|
│ │ └── 192.168.1.102_rgb_20250325_143024.png
|
|
|
│ ├── depth/ # 深度图
|
|
|
│ │ ├── 192.168.1.100_depth_20250325_143022.png
|
|
|
│ │ ├── 192.168.1.101_depth_20250325_143023.png
|
|
|
│ │ └── 192.168.1.102_depth_20250325_143024.png
|
|
|
│ ├── depthColor/ # 彩色深度图
|
|
|
│ │ ├── 192.168.1.100_depth_color_20250325_143022.png
|
|
|
│ │ ├── 192.168.1.101_depth_color_20250325_143023.png
|
|
|
│ │ └── 192.168.1.102_depth_color_20250325_143024.png
|
|
|
│ └── pointCloud/ # 点云数据
|
|
|
│ ├── 192.168.1.100_pointcloud_20250325_143022.pcd
|
|
|
│ ├── 192.168.1.101_pointcloud_20250325_143023.pcd
|
|
|
│ └── 192.168.1.102_pointcloud_20250325_143024.pcd
|
|
|
├── 20250326/ # 日期:2025年3月26日
|
|
|
│ ├── amplitude/
|
|
|
│ ├── rgb/
|
|
|
│ ├── depth/
|
|
|
│ ├── depthColor/
|
|
|
│ └── pointCloud/
|
|
|
└── 20250327/ # 日期:2025年3月27日
|
|
|
├── amplitude/
|
|
|
├── rgb/
|
|
|
├── depth/
|
|
|
├── depthColor/
|
|
|
└── pointCloud/
|
|
|
```
|
|
|
|
|
|
## 文件命名规则
|
|
|
|
|
|
### 命名格式
|
|
|
|
|
|
```
|
|
|
{SN}_{type}_{timestamp}.{ext}
|
|
|
```
|
|
|
|
|
|
### 示例说明
|
|
|
|
|
|
| 文件名 | 说明 |
|
|
|
|--------|------|
|
|
|
| `192.168.1.100_amplitude_20250325_143022.png` | 相机192.168.1.100在2025年3月25日14:30:22拍摄的强度图 |
|
|
|
| `192.168.1.100_rgb_20250325_143022.png` | 相机192.168.1.100在2025年3月25日14:30:22拍摄的RGB图 |
|
|
|
| `192.168.1.100_depth_20250325_143022.png` | 相机192.168.1.100在2025年3月25日14:30:22拍摄的深度图 |
|
|
|
| `192.168.1.100_depth_color_20250325_143022.png` | 相机192.168.1.100在2025年3月25日14:30:22拍摄的彩色深度图 |
|
|
|
| `192.168.1.100_pointcloud_20250325_143022.pcd` | 相机192.168.1.100在2025年3月25日14:30:22拍摄的点云数据 |
|
|
|
|
|
|
## 类型说明
|
|
|
|
|
|
| 类型文件夹 | 文件扩展名 | 说明 |
|
|
|
|-----------|-----------|------|
|
|
|
| `amplitude` | `.png` | 强度图(灰度图) |
|
|
|
| `rgb` | `.png` | RGB彩色图像 |
|
|
|
| `depth` | `.png` | 深度图(灰度表示) |
|
|
|
| `depthColor` | `.png` | 彩色深度图(使用伪彩色映射) |
|
|
|
| `pointCloud` | `.pcd` | 3D点云数据(PCD格式) |
|
|
|
|
|
|
## 使用建议
|
|
|
|
|
|
### 1. 按日期管理数据
|
|
|
|
|
|
```
|
|
|
# 查看某一天的所有数据
|
|
|
D:/output/20250325/
|
|
|
|
|
|
# 删除某一天的数据
|
|
|
rm -rf D:/output/20250325/
|
|
|
```
|
|
|
|
|
|
### 2. 按类型批量处理
|
|
|
|
|
|
```
|
|
|
# 处理所有点云数据
|
|
|
D:/output/20250325/pointCloud/
|
|
|
|
|
|
# 处理所有RGB图像
|
|
|
D:/output/20250325/rgb/
|
|
|
```
|
|
|
|
|
|
### 3. 按相机查找
|
|
|
|
|
|
```
|
|
|
# 查找某个相机的所有数据
|
|
|
find D:/output/20250325/ -name "192.168.1.100_*"
|
|
|
```
|
|
|
|
|
|
### 4. 定期清理旧数据
|
|
|
|
|
|
```java
|
|
|
// 删除30天前的数据
|
|
|
import java.io.File;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
public class DataCleaner {
|
|
|
public static void cleanOldData(String basePath, int daysToKeep) {
|
|
|
LocalDate cutoffDate = LocalDate.now().minusDays(daysToKeep);
|
|
|
File baseDir = new File(basePath);
|
|
|
|
|
|
File[] dateDirs = baseDir.listFiles(File::isDirectory);
|
|
|
if (dateDirs == null) return;
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
|
for (File dateDir : dateDirs) {
|
|
|
try {
|
|
|
LocalDate dirDate = LocalDate.parse(dateDir.getName(), formatter);
|
|
|
if (dirDate.isBefore(cutoffDate)) {
|
|
|
deleteDirectory(dateDir);
|
|
|
System.out.println("已删除: " + dateDir.getAbsolutePath());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
System.err.println("无法解析日期: " + dateDir.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static void deleteDirectory(File dir) {
|
|
|
File[] files = dir.listFiles();
|
|
|
if (files != null) {
|
|
|
for (File file : files) {
|
|
|
if (file.isDirectory()) {
|
|
|
deleteDirectory(file);
|
|
|
} else {
|
|
|
file.delete();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dir.delete();
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
cleanOldData("D:/output", 30); // 保留30天
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 5. 数据备份策略
|
|
|
|
|
|
```bash
|
|
|
# 备份指定日期的数据
|
|
|
tar -czf backup_20250325.tar.gz D:/output/20250325/
|
|
|
|
|
|
# 备份指定类型的数据
|
|
|
tar -czf backup_pointcloud.tar.gz D:/output/*/pointCloud/
|
|
|
```
|
|
|
|
|
|
### 6. 数据迁移
|
|
|
|
|
|
```java
|
|
|
// 将数据迁移到新位置
|
|
|
import java.nio.file.*;
|
|
|
|
|
|
public class DataMigrator {
|
|
|
public static void migrateData(String oldPath, String newPath) throws IOException {
|
|
|
Path source = Paths.get(oldPath);
|
|
|
Path target = Paths.get(newPath);
|
|
|
|
|
|
// 递归复制目录
|
|
|
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
|
|
|
@Override
|
|
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
|
|
Path targetDir = target.resolve(source.relativize(dir));
|
|
|
Files.createDirectories(targetDir);
|
|
|
return FileVisitResult.CONTINUE;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
|
|
Path targetFile = target.resolve(source.relativize(file));
|
|
|
Files.copy(file, targetFile, StandardCopyOption.REPLACE_EXISTING);
|
|
|
return FileVisitResult.CONTINUE;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
migrateData("D:/output", "E:/backup");
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## API响应示例
|
|
|
|
|
|
### 单次拍照(点云)
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"success": true,
|
|
|
"errorCode": 0,
|
|
|
"errorMessage": null,
|
|
|
"errorDescription": "成功",
|
|
|
"retryCount": 1,
|
|
|
"cameraSn": "192.168.1.100",
|
|
|
"filePaths": {
|
|
|
"pointCloud": "D:/output/20250325/pointCloud/192.168.1.100_pointcloud_20250325_143022.pcd"
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 全类型拍照
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"success": true,
|
|
|
"errorCode": 0,
|
|
|
"errorMessage": null,
|
|
|
"errorDescription": "成功",
|
|
|
"retryCount": 1,
|
|
|
"cameraSn": "192.168.1.100",
|
|
|
"filePaths": {
|
|
|
"amplitude": "D:/output/20250325/amplitude/192.168.1.100_amplitude_20250325_143022.png",
|
|
|
"rgb": "D:/output/20250325/rgb/192.168.1.100_rgb_20250325_143022.png",
|
|
|
"depth": "D:/output/20250325/depth/192.168.1.100_depth_20250325_143022.png",
|
|
|
"depthColor": "D:/output/20250325/depthColor/192.168.1.100_depth_color_20250325_143022.png",
|
|
|
"pointCloud": "D:/output/20250325/pointCloud/192.168.1.100_pointcloud_20250325_143022.pcd"
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## 注意事项
|
|
|
|
|
|
1. **目录自动创建**:系统会自动创建所需的目录结构,无需手动创建
|
|
|
2. **时间戳精度**:时间戳精确到秒,同一秒内多次拍照文件名会重复
|
|
|
3. **文件覆盖**:如果文件名相同,新文件会覆盖旧文件
|
|
|
4. **权限要求**:确保程序对basePath有读写权限
|
|
|
5. **磁盘空间**:注意监控磁盘空间,特别是保存点云数据时
|
|
|
6. **路径长度**:Windows系统路径长度限制为260字符,建议使用较短的basePath
|
|
|
|
|
|
## 常见问题
|
|
|
|
|
|
### Q1: 如何修改日期格式?
|
|
|
|
|
|
答:日期格式在 `LxCameraServiceImpl.java` 中定义:
|
|
|
|
|
|
```java
|
|
|
String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
```
|
|
|
|
|
|
可以修改为 `yyyy-MM-dd` 等其他格式。
|
|
|
|
|
|
### Q2: 如何修改文件命名规则?
|
|
|
|
|
|
答:文件名在 `LxCameraServiceImpl.java` 中生成:
|
|
|
|
|
|
```java
|
|
|
String ampPath = basePath + "/" + date + "/amplitude/" + cameraSn + "_amplitude_" + timestamp + ".png";
|
|
|
```
|
|
|
|
|
|
可以根据需要修改。
|
|
|
|
|
|
### Q3: 如何压缩历史数据?
|
|
|
|
|
|
答:可以使用zip或tar命令:
|
|
|
|
|
|
```bash
|
|
|
# 压缩2025年3月的所有数据
|
|
|
tar -czf output_202503.tar.gz D:/output/20250325/ D:/output/20250326/ D:/output/20250327/
|
|
|
|
|
|
# 压缩后删除原始数据
|
|
|
rm -rf D:/output/20250325/ D:/output/20250326/ D:/output/20250327/
|
|
|
```
|
|
|
|
|
|
### Q4: 如何统计磁盘占用?
|
|
|
|
|
|
答:使用以下命令:
|
|
|
|
|
|
```bash
|
|
|
# Windows
|
|
|
powershell "Get-ChildItem D:/output -Recurse | Measure-Object -Property Length -Sum"
|
|
|
|
|
|
# Linux/Mac
|
|
|
du -sh D:/output/*
|
|
|
```
|