-
Notifications
You must be signed in to change notification settings - Fork 16
/
demo.cpp
52 lines (42 loc) · 1.62 KB
/
demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//Author: Khuong Thanh Gia Hieu
//Viet Nam - Bach Khoa University - CK16KSCD
#include "PPF.h"
#include <thread>
#include <mutex>
int main()
{
//In this project, we use PPF Descriptor from this paper, please read before continue:
//Fast and Robust Pose Estimation Algorithm for Bin Picking Using Point Pair Feature
//Mingyu Li and Koichi Hashimoto
//International Conference on Pattern Recognition (ICPR)
DescriptorPPF* descr(new DescriptorPPF());
std::cout << "Descriptor type: " << descr->getType() << endl;
//Load model
descr->setModelPath("../data/model/bi/6914.STL");
std::cout << "Done Preparation ... !" << std::endl;
//Load scene
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> ("../data/scene/bi/scene0.pcd", *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file\n");
return (-1);
}
descr->storeLatestCloud(cloud);
//We MUST process and visualize from different thread, or the program will crash
// Start processing from different thread
auto _3D_Matching_Lambda = [&descr]() {
descr->prepareModelDescriptor();
descr->_3D_Matching();
};
std::thread _3D_Matching_Thread(_3D_Matching_Lambda);
std::cout << "Processing Thread Started ... !" << std::endl;
// Start visualizing from different thread
while (!descr->customViewer.viewer->wasStopped()) {
descr->customViewer.viewer->spinOnce(300);
std::this_thread::sleep_for(std::chrono::microseconds(300000));
}
//Wait for thread to finish before closing the program
if (_3D_Matching_Thread.joinable())
_3D_Matching_Thread.join();
return 0;
}