当前位置:网站首页>MFC 打开与保存点云PCD文件
MFC 打开与保存点云PCD文件
2022-08-04 05:29:00 【视觉菜鸟Leonardo】
关键一句代码:
CFileDialog FileDlg(true, sDefaultDir, _T(""), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFileFilter, NULL);CFileDialog 第一个参数为Ture时代表打开文件,为false时代表保存文件
添加点云数据之前,需要清空原有的数据
m_spViewer->removeAllPointClouds();打开PCD,并显示于界面上的VTK窗口
void CPointCloud::PC_OpenPointCloud(boost::shared_ptr<pcl::visualization::PCLVisualizer>& m_spViewer,
vtkRenderWindowInteractor* m_rwndinIren,
vtkRenderWindow* m_rwndRenWin, CString& sFilePath)
{
//打开文件*.pcd *.ply *.obj
CString sDefaultDir = _T("请选择路径"); //设置默认打开文件夹
CString sFileFilter = _T("文件(*.pcd;*.ply;*.obj)|*.pcd;*.ply;*.obj|All File (*.*)|*.*||"); //设置文件过滤
CFileDialog FileDlg(true, sDefaultDir, _T(""), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFileFilter, NULL);
//弹出选择文件对话框
if (FileDlg.DoModal() == IDOK)
{
sFilePath = FileDlg.GetPathName();//得到完整的文件名和目录名拓展名
CString sFilename = FileDlg.GetFileName();
}
string sFile = CT2A(sFilePath.GetBuffer()); //CString格式转String格式
//std::string sFilename = "huba_part.pcd";
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile(sFile, *cloud); //载入点云
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color(cloud, 255, 255, 255); //设置点云颜色
//初始化点云数据
m_spViewer->removeAllPointClouds();
//添加点云数据
m_spViewer->addPointCloud<pcl::PointXYZ>(cloud, single_color, "sample cloud");
m_spViewer->resetCamera();//使点云显示在屏幕中间,并绕中心操作
m_rwndinIren->Render();
m_rwndRenWin->Render();
}保存PCD:
void CApplicationDlg::OnBnClickedSavefile()
{
//保存文件*.pcd *.ply *.obj
CString sDefaultDir = _T("请选择路径"); //设置默认打开文件夹
CString sFileFilter = _T("文件(*.pcd;*.ply;*.obj)|*.pcd;*.ply;*.obj|All File (*.*)|*.*||"); //设置文件过滤
CFileDialog FileDlg(false, sDefaultDir, _T(""), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFileFilter, NULL);
CString filename;
if (FileDlg.DoModal() != IDOK)
filename = FileDlg.GetPathName();
bool binary = false;
bool use_camera = true;
int pos = filename.ReverseFind('.');
if (pos == -1)
return;
CString ext = filename.Right(filename.GetLength() - pos);
pcl::io::savePCDFileASCII(filename.GetString(), *CloudFull);
}边栏推荐
猜你喜欢
k3s-轻量级Kubernetes

MySQL事务详解(事务隔离级别、实现、MVCC、幻读问题)

两个APP进行AIDL通信

(十)树的基础部分(二)

Thoroughly understand box plot analysis

ReentrantLock(公平锁、非公平锁)可重入锁原理

Kubernetes基本入门-元数据资源(四)

TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset

Image-Adaptive YOLO for Object Detection in Adverse Weather Conditions

Kubernetes基础入门(完整版)
随机推荐
剑指 Offer 2022/7/3
记一次flink程序优化
剑指 Offer 2022/7/2
动手学深度学习_多层感知机
读研碎碎念
Briefly say Q-Q map; stats.probplot (QQ map)
Jupyter Notebook installed library;ModuleNotFoundError: No module named 'plotly' solution.
【深度学习21天学习挑战赛】2、复杂样本分类识别——卷积神经网络(CNN)服装图像分类
【CV-Learning】图像分类
Introduction of linear regression 01 - API use cases
Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL
Data reading in yolov3 (1)
动手学深度学习_线性回归
(十三)二叉排序树
flink自定义轮询分区产生的问题
BatchNorm&&LayerNorm
[Deep Learning 21 Days Learning Challenge] Memo: What does our neural network model look like? - detailed explanation of model.summary()
yolov3 data reading (2)
线性回归02---波士顿房价预测
【深度学习21天学习挑战赛】1、我的手写被模型成功识别——CNN实现mnist手写数字识别模型学习笔记