#include "all.hpp"
#include "pcl_object_recognition.hpp"
int
main (int argc, char** argv)
{
parseCommandLine (argc, argv);
pcl::PointCloud<PointType>::Ptr model (new pcl::PointCloud<PointType> ());
pcl::PointCloud<PointType>::Ptr model_keypoints (new pcl::PointCloud<PointType> ());
pcl::PointCloud<PointType>::Ptr scene (new pcl::PointCloud<PointType> ());
pcl::PointCloud<PointType>::Ptr complete_scene (new pcl::PointCloud<PointType> ());
pcl::PointCloud<PointType>::Ptr scene_keypoints (new pcl::PointCloud<PointType> ());
pcl::PointCloud<NormalType>::Ptr model_normals (new pcl::PointCloud<NormalType> ());
pcl::PointCloud<NormalType>::Ptr scene_normals (new pcl::PointCloud<NormalType> ());
openni::VideoFrameRef irf;
openni::VideoFrameRef colorf;
OpenniStreamer openni_streamer;
Openni2pcl < pcl::PointXYZRGB > grabber;
NormalEstimator norm;
ClusterType cluster;
Uniform uniform;
pcl::RandomSample < pcl::PointXYZRGB > random;
Narf narf_estimator;
Sift sift_estimator;
Harris harris_estimator;
pcl::StatisticalOutlierRemoval < pcl::PointXYZRGB > sor;
Ransac < pcl::SampleConsensusModelSphere < pcl::PointXYZRGB >> ransac_estimator;
ColorSampling filter;
std::vector < pcl::PointCloud < pcl::PointXYZRGB > ::Ptr > model_list = ReadModels (argv);
if (model_list.size () == 0)
{
std::cout << " no models loaded " << std::endl;
return 1;
}
Ppfe ppfe_estimator (model_list[0]);
if (to_filter)
{
filter.AddCloud (*model_list[0]);
}
if (remove_outliers)
{
sor.setMeanK (50);
sor.setStddevMulThresh (0.5);
}
std::cout << "calculating model normals... " << std::endl;
if (!ppfe)
{
model_normals = norm.Get_normals (model_list[0]);
std::cout << "model size " << model_list[0]->points.size () << std::endl;
if (random_points)
{
random.setInputCloud (model_list[0]);
random.setSeed (std::rand ());
random.setSample (random_model_samples);
random.filter (*model_keypoints);
}
else
{
uniform.SetSamplingSize (model_ss);
uniform.GetKeypoints (model_list[0], model_keypoints);
}
}
else
{
model_keypoints = ppfe_estimator.GetModelKeypoints ();
}
// Visualization
Visualizer visualizer;
while (!visualizer.viewer_.wasStopped ())
{
//grab a frame and create the pointcloud
openni_streamer.rc_ = openni_streamer.ir_.readFrame (&irf);
openni_streamer.rc_ = openni_streamer.color_.readFrame (&colorf);
scene = grabber.get_point_cloud_openni2 (colorf, irf, distance, true);
copyPointCloud (*scene, *complete_scene);
if (segment)
scene = FindAndSubtractPlane (scene, segmentation_threshold, segmentation_iterations);
if (to_filter)
{
filter.FilterPointCloud (*scene, *scene);
}
if (remove_outliers)
{
sor.setInputCloud (scene);
sor.filter (*scene);
}
// Compute Normals
std::cout << "calculating scene normals... " << std::endl;
scene_normals = norm.Get_normals (scene);
if (ppfe)
{
//PPFEESTIMATOR
cluster = ppfe_estimator.GetCluster (scene);
scene_keypoints = ppfe_estimator.GetSceneKeypoints ();
show_correspondences = false;
}
else
{
if (narf)
{
//NARF
std::cout << "finding narf keypoints..." << std::endl;
narf_estimator.GetKeypoints (scene, scene_keypoints);
}
else if (sift)
{
//SIFT
std::cout << "finding sift keypoints..." << std::endl;
sift_estimator.GetKeypoints (scene, scene_keypoints);
}
else if (ransac)
{
//RANSAC
std::cout << "finding ransac keypoints..." << std::endl;
ransac_estimator.GetKeypoints (scene, scene_keypoints);
}
else if (harris)
{
//HARRIS
std::cout << "finding harris keypoints..." << std::endl;
harris_estimator.GetKeypoints (scene, scene_keypoints);
}
else if (random_points)
{
//RANDOM
std::cout << "using random keypoints..." << std::endl;
random.setInputCloud (scene);
random.setSample (random_scene_samples);
random.filter (*scene_keypoints);
}
else
{
//UNIFORM
std::cout << "finding uniform sampled keypoints..." << std::endl;
uniform.SetSamplingSize (scene_ss);
uniform.GetKeypoints (scene, scene_keypoints);
}
std::cout << "\tfound " << scene_keypoints->points.size () << " keypoints in the scene and " << model_keypoints->points.size () << " in the model" << std::endl;
pcl::CorrespondencesPtr model_scene_corrs (new pcl::Correspondences ());
if (fpfh)
{
std::cout << "using fpfh descriptors" << std::endl;
KeyDes<pcl::FPFHSignature33, pcl::FPFHEstimationOMP<pcl::PointXYZRGB, pcl::Normal, pcl::FPFHSignature33> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
else if (pfh)
{
std::cout << "using pfh descriptors" << std::endl;
KeyDes<pcl::PFHSignature125, pcl::PFHEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHSignature125> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
else if (pfhrgb)
{
std::cout << "using pfhrgb descriptors" << std::endl;
KeyDes<pcl::PFHRGBSignature250, pcl::PFHRGBEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PFHRGBSignature250> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
else if (ppf)
{
std::cout << "using ppf descriptors" << std::endl;
KeyDes<pcl::PPFSignature, pcl::PPFEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PPFSignature> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
else if (ppfrgb)
{
std::cout << "using ppfrgb descriptors" << std::endl;
KeyDes<pcl::PPFRGBSignature, pcl::PPFRGBEstimation<pcl::PointXYZRGB, pcl::Normal, pcl::PPFRGBSignature> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
else if (shot)
{
std::cout << "using shot descriptors" << std::endl;
KeyDes<pcl::SHOT352, pcl::SHOTEstimationOMP<PointType, NormalType, pcl::SHOT352> > est (model_list[0], model_keypoints, scene, scene_keypoints, model_normals, scene_normals);
model_scene_corrs = est.Run ();
}
std::cout << "Starting to cluster..." << std::endl;
if (use_hough)
{
//Hough3D
Hough hough;
cluster = hough.GetClusters (model_list[0], model_keypoints, model_normals, scene, scene_keypoints, scene_normals, model_scene_corrs);
}
else
{
//GEOMETRIC CONSISTENCY
GCG gcg;
cluster = gcg.GetClusters (model_list[0], scene, model_scene_corrs);
}
}
std::cout << "\tFound " << std::get < 0 > (cluster).size () << " model instance/instances " << std::endl;
SetViewPoint (complete_scene);
visualizer.Visualize (model_list[0], model_keypoints, complete_scene, scene_keypoints, cluster, scene);
}
return (0);
}
朱moyimi
- 粉丝: 79
- 资源: 1万+
最新资源
- 带载流子密度的双温模型matlab,电子晶格温度,电子密度,飞秒激光源模拟,有限元法解偏微分方程 德鲁德模型,带载流子密度变化
- GP026-仓库系统.zip
- HttpCanary_3.3.6.apk
- 线控制动系统仿真 Carsim和Simulink联合仿真线控制动系统BBW-EMB系统 包含简单的制动力分配和四个车轮的线控制动机构 四个车轮独立BLDCM三环PID闭环制动控制,最大真实还原线
- Comsol脉冲涡流无损检测仿真 图一:脉冲涡流仿真,检出电压信号 图二:脉冲涡流模型 图三:磁通密度模 图四:磁通密度模
- CC2530无线zigbee裸机代码实现光敏和热敏传感器数值读取.zip
- CC2530无线zigbee裸机代码实现继电器的控制.zip
- CC2530无线zigbee裸机代码实现看门口狗Watch Dog使用.zip
- CC2530无线zigbee裸机代码实现控制步进电机正反转.zip
- CC2530无线zigbee裸机代码实现人体红外传感器数值读取.zip
- CC2530无线zigbee裸机代码实现睡眠定时器唤醒系统.zip
- CC2530无线zigbee裸机代码实现外部中断控制LED开关.zip
- CC2530无线zigbee裸机代码实现外部中断控制流水灯.zip
- 基于51单片机的污水处理厂气体检测报警系统(protues仿真)-毕业设计
- CC2530无线zigbee裸机代码实现温度传感器DS18B20数值读取.zip
- CC2530无线zigbee裸机代码实现温湿度传感器DHT11数值读取.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈