如何实现基于MFC对话框的PCL显示
答案:2 悬赏:0 手机版
解决时间 2021-02-01 03:37
- 提问者网友:自食苦果
- 2021-01-31 10:58
如何实现基于MFC对话框的PCL显示
最佳答案
- 五星知识达人网友:深街酒徒
- 2021-01-31 11:28
void CPCLDialogDlg::OnBnClickedOpenpcd()
{
this->viewer->removeAllPointClouds ();
// TODO: Add your control notification handler code here
static TCHAR BASED_CODE szFilter[] = _T("PCD (*.pcd )|*.pcd||");
CFileDialog cFileDialog(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT| OFN_NOCHANGEDIR ,szFilter);
if (cFileDialog.DoModal() == IDOK)
{
/////////////////////////////////////////////////////////////////////////////
//文档名称
std::string filename;
filename = cFileDialog.GetPathName();
//reset data
this->binary_blob.reset();
binary_blob = sensor_msgs::PointCloud2::Ptr (new sensor_msgs::PointCloud2);
// read new data
//*.pcd文件
pcl::PCDReader pcd_reader;
if (pcd_reader.read ((char*)_bstr_t(filename.c_str()), *binary_blob) != 0) //* load the file
{
MessageBox (_T("Couldn't read PCData file!"));
return;
}
}
if (binary_blob == NULL)
{
MessageBox("Please load PCD file firstly!");
return;
}
else
{
//其他句柄
if (pcl::getFieldIndex(*binary_blob, "rgb") > 0)
{
color_Handler = pcl::mfc_visualization::PointCloudColorHandlerRGBField::Ptr
(new pcl::mfc_visualization::PointCloudColorHandlerRGBField (binary_blob));
this->viewer->addPointCloud(binary_blob, color_Handler, sensor_origin, sensor_orientation);
}
else
{
xyz_Handler = pcl::mfc_visualization::PointCloudGeometryHandlerXYZ::Ptr
(new pcl::mfc_visualization::PointCloudGeometryHandlerXYZ (binary_blob));
this->viewer->addPointCloud(binary_blob, xyz_Handler, sensor_origin, sensor_orientation);
}
this->viewer->resetCamera();
}
}
{
this->viewer->removeAllPointClouds ();
// TODO: Add your control notification handler code here
static TCHAR BASED_CODE szFilter[] = _T("PCD (*.pcd )|*.pcd||");
CFileDialog cFileDialog(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT| OFN_NOCHANGEDIR ,szFilter);
if (cFileDialog.DoModal() == IDOK)
{
/////////////////////////////////////////////////////////////////////////////
//文档名称
std::string filename;
filename = cFileDialog.GetPathName();
//reset data
this->binary_blob.reset();
binary_blob = sensor_msgs::PointCloud2::Ptr (new sensor_msgs::PointCloud2);
// read new data
//*.pcd文件
pcl::PCDReader pcd_reader;
if (pcd_reader.read ((char*)_bstr_t(filename.c_str()), *binary_blob) != 0) //* load the file
{
MessageBox (_T("Couldn't read PCData file!"));
return;
}
}
if (binary_blob == NULL)
{
MessageBox("Please load PCD file firstly!");
return;
}
else
{
//其他句柄
if (pcl::getFieldIndex(*binary_blob, "rgb") > 0)
{
color_Handler = pcl::mfc_visualization::PointCloudColorHandlerRGBField
(new pcl::mfc_visualization::PointCloudColorHandlerRGBField
this->viewer->addPointCloud(binary_blob, color_Handler, sensor_origin, sensor_orientation);
}
else
{
xyz_Handler = pcl::mfc_visualization::PointCloudGeometryHandlerXYZ
(new pcl::mfc_visualization::PointCloudGeometryHandlerXYZ
this->viewer->addPointCloud(binary_blob, xyz_Handler, sensor_origin, sensor_orientation);
}
this->viewer->resetCamera();
}
}
全部回答
- 1楼网友:酒安江南
- 2021-01-31 12:03
void cpcldialogdlg::onbnclickedopenpcd()
{
this->viewer->removeallpointclouds ();
// todo: add your control notification handler code here
static tchar based_code szfilter[] = _t("pcd (*.pcd )|*.pcd||");
cfiledialog cfiledialog(true, null, null, ofn_hidereadonly | ofn_overwriteprompt| ofn_nochangedir ,szfilter);
if (cfiledialog.domodal() == idok)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯