当前位置: 首页 > news >正文

多相机depth-rgb图组完整性分拣器_MATLAB实现

文件夹中数据规则为,一张BMP格式的RGB图像会有一张同名的raw格式的深度图,一共有三个相机,三个相机的数据为一组,例如:1_0.bmp,1_0.raw,1_1.bmp,1_1.raw,1_2.bmp,1_2.raw为一组相机的数据。现在文件夹中数据存在缺失情况,可能缺失某个相机的raw格式的深度。使用matlab代码筛选文件夹中的数据,将一组数据中存在缺少raw格式的这组数据放在一个文件夹,不存在确实的六个数据统一放在一个文件夹。

分析:
MATLAB 脚本用于把“成组”数据分成两类:

  1. 六个文件齐全(3 个 .bmp + 3 个 .raw);
  2. 缺失任一 .raw 的整组数据(其余文件也一起搬走)。

脚本假设所有文件都在当前工作目录下,并按如下命名规则:
{组号}_{相机号}.bmp{组号}_{相机号}.raw,相机号固定为 0/1/2。

%%
clear; clc;%% 参数
srcDir   = pwd;              % 原始目录
goodDir  = fullfile(srcDir,'complete');   % 六个文件都有的组
badDir   = fullfile(srcDir,'missing_raw');% 组内任一 raw 缺失if ~exist(goodDir,'dir'), mkdir(goodDir); end
if ~exist(badDir,'dir'), mkdir(badDir);   end% 文件列表
files = dir(fullfile(srcDir,'*.*'));
names = {files.name};
isBMP = endsWith(names, '.bmp', 'IgnoreCase', true);
isRAW = endsWith(names, '.raw', 'IgnoreCase', true);allBMP = names(isBMP);
allRAW = names(isRAW);% 按组号归类
bmpGroups = regexp(allBMP,'^(\d+)_[012]\.bmp$','tokens','once');
rawGroups = regexp(allRAW,'^(\d+)_[012]\.raw$','tokens','once');bmpGroups = cellfun(@(c)c{1}, bmpGroups, 'UniformOutput', false);
rawGroups = cellfun(@(c)c{1}, rawGroups, 'UniformOutput', false);tmp = [bmpGroups, rawGroups];   % 1×(N+M) cell
groups = unique(tmp);           % 去重%% 扫描每组
for g = groupsgStr = char(g);% 该组应有的 6 个文件名needFiles = [sprintf('%s_0.bmp',gStr);sprintf('%s_1.bmp',gStr);sprintf('%s_2.bmp',gStr);sprintf('%s_0.raw',gStr);sprintf('%s_1.raw',gStr);sprintf('%s_2.raw',gStr)];% 实际存在的 6 个文件existFlag = ismember(needFiles, names);% 判断 raw 是否完整rawExist  = existFlag(4:6);if all(rawExist)% 六个文件都在 → completetgt = goodDir;else% 任一 raw 缺失 → missing_rawtgt = badDir;endneedFiles = strcat(gStr, {'_0.bmp','_1.bmp','_2.bmp', ...'_0.raw','_1.raw','_2.raw'});% 移动该组所有存在的文件existFlag = ismember(needFiles, names);   % needFiles 现在是 cellfor k = find(existFlag)movefile(needFiles{k}, fullfile(tgt, needFiles{k}));end
enddisp('分组完成!');

使用方法

  1. 将脚本保存为 classifyGroups.m,放在数据根目录。
  2. 运行 classifyGroups,脚本会自动创建 completemissing_raw 两个子文件夹并把相应文件移入。

实现效果
在这里插入图片描述


文章转载自:
http://afreet.hnsdj.cn
http://attentively.hnsdj.cn
http://chozrim.hnsdj.cn
http://antichlor.hnsdj.cn
http://awedness.hnsdj.cn
http://catholicize.hnsdj.cn
http://backstage.hnsdj.cn
http://antiterrorist.hnsdj.cn
http://arterial.hnsdj.cn
http://alterne.hnsdj.cn
http://cheero.hnsdj.cn
http://adieu.hnsdj.cn
http://archaeornis.hnsdj.cn
http://adversary.hnsdj.cn
http://bolwtorch.hnsdj.cn
http://assize.hnsdj.cn
http://breezeless.hnsdj.cn
http://anthropochory.hnsdj.cn
http://amorite.hnsdj.cn
http://azotic.hnsdj.cn
http://bushmanship.hnsdj.cn
http://chillness.hnsdj.cn
http://bridgeable.hnsdj.cn
http://anthropometrist.hnsdj.cn
http://beidaihe.hnsdj.cn
http://borofluoride.hnsdj.cn
http://abrazo.hnsdj.cn
http://certain.hnsdj.cn
http://bardolino.hnsdj.cn
http://aggiornamento.hnsdj.cn
http://www.dtcms.com/a/280389.html

相关文章:

  • @[TOC](模拟) # 1.替换所有的问号(easy)
  • 学C++做游戏,先搞懂这些基础要点
  • 《大数据技术原理与应用》实验报告六 Flink编程实践
  • 使用JS编写用户信息采集表单
  • 【Python3-Django】快速掌握DRF:ModelViewSet实战指南
  • OneCode 3.0 从0到1干货——AIGC及MCP注解驱动开发物联网AI决策应用
  • 全新 Python 项目托管到 Gitee 私有仓库完整流程(带详细命令注释)
  • OpenVINO initialization error: Failed to find plugins.xml file
  • uv 使用指导文档
  • 【机器学习深度学习】LoRA 微调详解:大模型时代的高效适配利器
  • BlueLotus XSS管理后台使用指南
  • GeoTools 工厂设计模式
  • 传输协议和消息队列
  • AR眼镜:重塑医学教育,开启智能教学新时代
  • 同步辐射XAFS和XRD协同用于高熵合金的研究应用
  • 香港站群服务器租用:为什么需要选择不同C类IP?
  • python的广东省家庭旅游接待信息管理系统
  • k8s之Attach 和 Mount
  • C++回顾 Day7
  • k8s之Snapshots 详解
  • Linux C IO多路复用
  • 静态补丁脚本 - 修改 libtolua.so
  • Unity音游开发全指南:模板与免费资源高效构建节奏游戏
  • Ubuntu 22.04 安装 mysql-server服务端
  • docker拉取nacos镜像失败
  • golang语法-----标准化输入输出
  • 渗透测试技术_Nessus工具(三):输出报告
  • 构建 Go 可执行文件镜像 | 探索轻量级 Docker 基础镜像(我应该选择哪个 Docker 镜像?)
  • STM32小实验三--让蜂鸣器响起来
  • Pytorch中张量的索引和切片使用详解和代码示例