当前位置:网站首页>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);
}边栏推荐
猜你喜欢

TensorFlow2 study notes: 7. Optimizer

The pipeline mechanism in sklearn

yolov3中数据读入(一)

Kubernetes基础入门(完整版)

【CV-Learning】Object Detection & Instance Segmentation

AIDL communication between two APPs

剑指 Offer 2022/7/1

flink问题整理

flink sql left join数据倾斜问题解决

MAE 论文《Masked Autoencoders Are Scalable Vision Learners》
随机推荐
安卓连接mysql数据库,使用okhttp
sklearn中的学习曲线learning_curve函数
【CV-Learning】线性分类器(SVM基础)
fill_between in Matplotlib; np.argsort() function
Kubernetes基础入门(完整版)
Deep Adversarial Decomposition: A Unified Framework for Separating Superimposed Images
记一次flink程序优化
Logistic Regression --- Introduction, API Introduction, Case: Cancer Classification Prediction, Classification Evaluation, and ROC Curve and AUC Metrics
双重指针的使用
TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset
DeblurGAN-v2: Deblurring (Orders-of-Magnitude) Faster and Better 图像去模糊
[Introduction to go language] 12. Pointer
MySQL最左前缀原则【我看懂了hh】
【go语言入门笔记】13、 结构体(struct)
Jupyter Notebook安装库;ModuleNotFoundError: No module named ‘plotly‘解决方案。
基于PyTorch的FCN-8s语义分割模型搭建
MySQL事务详解(事务隔离级别、实现、MVCC、幻读问题)
剑指 Offer 2022/7/3
多项式回归(PolynomialFeatures)
动手学深度学习__张量