CRH直方图和姿态识别代码
来源:互联网 发布:淘宝优惠券返利网 编辑:程序博客网 时间:2024/05/29 15:07
TCHAR szFilter[] = _T("所有文件(*.*)|*.*|pcd文件(*.pcd)|*.pcd|ply文件(*.ply)|*.ply|xyz文件(*.xyz)|*.xyz|"); // 构造打开文件对话框 CFileDialog fileDlg(TRUE, _T("pcd"), NULL, 0, szFilter, this); CString scenefilepath; CString modelfilepath; std::string scenefile; std::string modelfile; // Cloud for storing the object. pcl::PointCloud<pcl::PointXYZ>::Ptr scenecloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr modelcloud(new pcl::PointCloud<pcl::PointXYZ>); // 显示打开文件对话框 if (IDOK == fileDlg.DoModal()) { scenefilepath = fileDlg.GetPathName(); // Load the first file //pcl::PCLPointCloud2Ptr cloud; // Command line parsing bool format = true; bool use_camera = true; scenefile = WChar2Ansi(scenefilepath.GetBuffer(scenefilepath.GetLength())); int pos = scenefile.find_last_of('.'); std::string extensionName(scenefile.substr(pos + 1)); if (extensionName == "ply") { if (pcl::io::loadPLYFile<pcl::PointXYZ>(scenefile.c_str(), *scenecloud) != 0) { AfxMessageBox(_T("file is error")); } } if (extensionName == "pcd") { if (pcl::io::loadPCDFile<pcl::PointXYZ>(scenefile.c_str(), *scenecloud) != 0) { AfxMessageBox(_T("file is error")); } } } // 显示打开文件对话框 if (IDOK == fileDlg.DoModal()) { modelfilepath = fileDlg.GetPathName(); // Load the first file //pcl::PCLPointCloud2Ptr cloud; // Command line parsing bool format = true; bool use_camera = true; modelfile = WChar2Ansi(modelfilepath.GetBuffer(modelfilepath.GetLength())); int pos = modelfile.find_last_of('.'); std::string extensionName(modelfile.substr(pos + 1)); if (extensionName == "ply") { if (pcl::io::loadPLYFile<pcl::PointXYZ>(modelfile.c_str(), *modelcloud) != 0) { AfxMessageBox(_T("file is error")); } } if (extensionName == "pcd") { if (pcl::io::loadPCDFile<pcl::PointXYZ>(modelfile.c_str(), *modelcloud) != 0) { AfxMessageBox(_T("file is error")); } } } // Object for storing the normals. pcl::PointCloud<pcl::Normal>::Ptr scene_normals(new pcl::PointCloud<pcl::Normal>); pcl::PointCloud<pcl::Normal>::Ptr model_normals(new pcl::PointCloud<pcl::Normal>); // Estimate the normals. pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation; normalEstimation.setInputCloud(scenecloud); normalEstimation.setRadiusSearch(0.03); pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>); normalEstimation.setSearchMethod(kdtree); normalEstimation.compute(*scene_normals); normalEstimation.setInputCloud(modelcloud); normalEstimation.compute(*model_normals); //estimate centroid Eigen::Vector4f scene_centroid; Eigen::Vector4f model_centroid; pcl::compute3DCentroid<pcl::PointXYZ>(*scenecloud, scene_centroid); pcl::compute3DCentroid<pcl::PointXYZ>(*modelcloud, model_centroid); //estimate camera roll histogram pcl::CRHEstimation<pcl::PointXYZ, pcl::Normal, pcl::Histogram<90> > crh_; pcl::PointCloud<pcl::Histogram<90> >::Ptr scene_crh(new pcl::PointCloud<pcl::Histogram<90> >); pcl::PointCloud<pcl::Histogram<90> >::Ptr model_crh(new pcl::PointCloud<pcl::Histogram<90> >); crh_.setInputCloud(scenecloud); crh_.setInputNormals(scene_normals); crh_.setCentroid(scene_centroid); crh_.compute(*scene_crh); crh_.setInputCloud(modelcloud); crh_.setInputNormals(model_normals); crh_.setCentroid(model_centroid); crh_.compute(*model_crh); pcl::visualization::PCLPlotter crh_visualizer; crh_visualizer.addFeatureHistogram<pcl::Histogram<90>>(*scene_crh, 90, "scenefeature"); crh_visualizer.addFeatureHistogram<pcl::Histogram<90>>(*model_crh, 90, "modelfeature"); crh_visualizer.spin(); // CRH alignment object. pcl::CRHAlignment<pcl::PointXYZ, 90> alignment; alignment.setInputAndTargetView(scenecloud, modelcloud); // CRHAlignment works with Vector3f, not Vector4f. Eigen::Vector3f sceneCentroid3f(scene_centroid[0], scene_centroid[1], scene_centroid[2]); Eigen::Vector3f modelCentroid3f(model_centroid[0], model_centroid[1], model_centroid[2]); alignment.setInputAndTargetCentroids(sceneCentroid3f, modelCentroid3f); // Compute the roll angle(s). std::vector<float> angles; alignment.computeRollAngle(*scene_crh, *model_crh, angles); if (angles.size() > 0) { int pos = scenefile.find_last_of('.'); //std::string extensionName(scenefile.substr(pos + 1)); scenefile = scenefile.substr(0, pos); scenefile += ".txt"; std::ofstream fs; fs.open(scenefile.c_str()); for (int i = 0; i < angles.size(); i++) { //std::cout << "\t" << angles.at(i) << " degrees." << std::endl fs << angles.at(i) << "\n"; } fs.close(); }
阅读全文
0 0
- CRH直方图和姿态识别代码
- 姿态识别
- VR中姿态、定位和身份识别系统的设计
- 人脸姿态识别
- 车辆定位识别姿态提取
- 人体姿态识别之RMPE
- 直方图均衡化的算法和代码
- 直方图均衡化的算法和代码
- 神经网络--姿态识别论文综述备忘录
- 人脸识别、姿态识别问题处理步骤
- 直方图和核密度估计图r语言代码
- STM32的CRH、CRL、ODR和IDR寄存器的使用总结
- 直方图均衡化代码
- 颜色直方图特征代码
- 直方图计算代码
- 直方图均衡化代码
- 颜色直方图特征代码
- 姿态结算相关-----姿态的表示和传感器
- VPS中shadowsock配置SOCK5服务器
- Week04_day03 IO流(下) 字符流、缓冲流、转换流
- HashMap和ConcurrentHashMap原理解读(基于JDK1.7)
- G1收集器
- ubuntu16.04安装sublime-text-3
- CRH直方图和姿态识别代码
- 计算机网络概论
- 深度学习框架的评估与比较
- 【iOS笔记-异常-1】
- 数据结构程序设计——约瑟夫双向生死杀人游戏
- wannafly 练习8 D加边的无向图
- 猜你喜欢-DataCastle
- GitHub Code / Issues / Pull Requests / Wiki
- 列表