当前位置:网站首页>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);
}
边栏推荐
- (十)树的基础部分(二)
- 【深度学习21天学习挑战赛】1、我的手写被模型成功识别——CNN实现mnist手写数字识别模型学习笔记
- (十一)树--堆排序
- k9s-终端UI工具
- Introduction of linear regression 01 - API use cases
- Attention Is All You Need(Transformer)
- flink on yarn指定第三方jar包
- Kubernetes基本入门-名称空间资源(三)
- npm install dependency error npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
- TensorFlow2学习笔记:8、tf.keras实现线性回归,Income数据集:受教育年限与收入数据集
猜你喜欢
The pipeline mechanism in sklearn
(十二)树--哈夫曼树
【CV-Learning】Convolutional Neural Network
两个APP进行AIDL通信
Kubernetes基本入门-概念介绍(一)
[CV-Learning] Convolutional Neural Network Preliminary Knowledge
Briefly say Q-Q map; stats.probplot (QQ map)
【go语言入门笔记】12、指针
Jupyter Notebook installed library;ModuleNotFoundError: No module named 'plotly' solution.
MySql--存储引擎以及索引
随机推荐
线性回归02---波士顿房价预测
【CV-Learning】卷积神经网络预备知识
DeblurGAN-v2: Deblurring (Orders-of-Magnitude) Faster and Better 图像去模糊
The use of the attribute of the use of the animation and ButterKnife
【深度学习21天学习挑战赛】2、复杂样本分类识别——卷积神经网络(CNN)服装图像分类
TypeError: load() missing 1 required positional argument: ‘Loader‘
postgres recursive query
Deep Adversarial Decomposition: A Unified Framework for Separating Superimposed Images
CAS与自旋锁、ABA问题
Use of double pointers
MySQL事务详解(事务隔离级别、实现、MVCC、幻读问题)
Image-Adaptive YOLO for Object Detection in Adverse Weather Conditions
剑指 Offer 20226/30
TensorFlow2 study notes: 7. Optimizer
PostgreSQL模式(Schema)
Logistic Regression --- Introduction, API Introduction, Case: Cancer Classification Prediction, Classification Evaluation, and ROC Curve and AUC Metrics
Kubernetes基本入门-元数据资源(四)
【CV-Learning】线性分类器(SVM基础)
JPEG2jpg
剑指 Offer 2022/7/11