Skip to content

Commit b810a49

Browse files
committed
first commit
1 parent 1a56f96 commit b810a49

File tree

447 files changed

+98069
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

447 files changed

+98069
-0
lines changed

GUI Program/RansacGAqt/CMakeLists.txt

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
2+
project(ransac_ga_qt)
3+
4+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
5+
set(CMAKE_CXX_FLAGS "-fPIC")
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11")
7+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/outputDirectory)
8+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libfreenect2pclgrabber-master/modules)
9+
10+
find_package (Qt4 REQUIRED)
11+
#find_package (Qt5 REQUIRED COMPONENTS Core Gui Widgets)
12+
find_package (VTK REQUIRED)
13+
find_package (PCL 1.7.1 REQUIRED)
14+
find_package(OpenCV REQUIRED)
15+
find_package(Freenect2 REQUIRED)
16+
17+
18+
set (project_SOURCES src/main.cpp src/window/pclviewer.cpp src/objects/objects_body.cpp src/ransac/ransac_body.cpp)
19+
set (project_HEADERS include/pclviewer.h include/objects.h include/ransac.h)
20+
set (project_FORMS ui/pclviewer.ui)
21+
22+
QT4_WRAP_UI (project_FORMS_HEADERS ${project_FORMS})
23+
QT4_WRAP_CPP (project_HEADERS_MOC ${project_HEADERS})
24+
25+
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
26+
FILE(GLOB_RECURSE LibFiles "include/*.h")
27+
add_custom_target(headers SOURCES ${LibFiles})
28+
include(${QT_USE_FILE})
29+
ADD_DEFINITIONS (${QT_DEFINITIONS})
30+
31+
include_directories (include
32+
third_party/versor/include
33+
third_party/versor/include/vsr
34+
third_party/libfreenect2pclgrabber-master
35+
${PCL_INCLUDE_DIRS}
36+
${FREENECT2_INCLUDE_DIRS}
37+
${OpenCV_INCLUDE_DIRS}
38+
${Qt5_INCLUDE_DIRS}
39+
${Qt5Widgets_INCLUDE_DIRS}
40+
${Qt5Core_INCLUDE_DIRS}
41+
)
42+
43+
link_directories (${PCL_LIBRARY_DIRS})
44+
add_definitions (${PCL_DEFINITIONS})
45+
46+
add_library(versor
47+
third_party/versor/src/space/vsr_cga3D_op.cpp
48+
third_party/versor/src/space/vsr_cga3D_frame.cpp
49+
third_party/versor/src/space/vsr_cga3D_round.cpp
50+
src/main.cpp
51+
src/objects/objects_body.cpp
52+
src/ransac/ransac_body.cpp
53+
#src/window/pclviewer.cpp
54+
third_party/libfreenect2pclgrabber-master/k2g.cpp
55+
)
56+
57+
set(VTK_LIBRARIES vtkRendering vtkGraphics vtkHybrid QVTK)
58+
59+
60+
#qt5_wrap_ui(project_FORMS_HEADERS ${project_FORMS})
61+
#qt5_wrap_cpp(project_HEADERS_MOC ${project_HEADERS})
62+
63+
64+
ADD_EXECUTABLE (main ${project_SOURCES} ${QT_SOURCES} ${project_FORMS_HEADERS} ${project_HEADERS_MOC})
65+
66+
TARGET_LINK_LIBRARIES (main ${QT_LIBRARIES} versor ${PCL_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${FREENECT2_LIBRARY} ${OpenCV_LIBS} ${VTK_LIBRARIES})
67+
68+
69+
70+

GUI Program/RansacGAqt/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RansacGAqt
2+
3+
Dependencies:
4+
5+
- Versor library https://github.com/wolftype/versor.git #Alredy included in "third party" folder, does not need to be installed#
6+
7+
Kinect 2 grabber:
8+
k2g https://github.com/giacomodabisias/libfreenect2pclgrabber.git #Alredy included in "third party folder", does not need to be installed#
9+
libfreenect2 https://github.com/OpenKinect/libfreenect2/blob/master/README.md #Install this#
10+
11+
12+
- OpenCV #Install this#
13+
- PCL 1.7.2 (depends on: boost, eigen3, flann, vtk) http://pointclouds.org/documentation/tutorials/compiling_pcl_posix.php #Install this#
14+
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//
2+
// Created by Aksel Sveier. Spring 2016
3+
//
4+
5+
#ifndef RANSACGA_OBJECTS_H
6+
#define RANSACGA_OBJECTS_H
7+
8+
#endif //RANSACGA_OBJECTS_H
9+
10+
#include <vsr/space/vsr_cga3D_op.h>
11+
#include <pcl/point_types.h>
12+
#include <pcl/common/common_headers.h>
13+
14+
using namespace vsr;
15+
using namespace vsr::cga;
16+
using namespace pcl;
17+
18+
19+
//Class that creates and handles spheres with CGA
20+
class sphere{
21+
public:
22+
float radius, x, y, z; //Floats for storing the parameters of the sphere
23+
Pnt dualSphere; //Stores the IPNS representation
24+
Sph sphe; //Stores the OPNS representation
25+
26+
void defineDual(float x, float y, float z, float r); //Creates a sphere from center(x,y,z) coordinates and radius
27+
void defineDual(Pnt p1, Pnt p2, Pnt p3, Pnt p4); //Creates a sphere from 4 points in conformal space.
28+
void defineDual(PointCloud<PointXYZRGB>::Ptr cl1, PointCloud<PointXYZRGB>::Ptr cl2, PointCloud<PointXYZRGB>::Ptr cl3, PointCloud<PointXYZRGB>::Ptr cl4); //Creates a sphere from 4 points from a pointcloud.
29+
void defineDual(PointCloud<PointXYZRGB>::Ptr cl, vector<int> index); //Creates a sphere in from 4 indexed points in a point cloud
30+
private:
31+
float calcRadius(Pnt dSph); //Function that calculates radius
32+
Pnt normalize(Pnt dSph); //Function that normalizes a conformal vector
33+
};
34+
35+
//Class that creates and handles planes with CGA
36+
class plane
37+
{
38+
public:
39+
Pnt dualPlane; //Stores the IPNS representation
40+
Pnt normDualPlane; //Stores the normalized IPNS representation
41+
42+
void defineDual(Pnt p1, Pnt p2, Pnt p3); //Creates a plane from 3 points in conformal space
43+
void defineDual(PointCloud<PointXYZRGB>::Ptr cl, int *index); //Creates a plane from 3 indexed points in a point cloud
44+
private:
45+
void normalize(Pnt dPln); //Function that normalizes a conformal vector
46+
};
47+
48+
//Class that creates and handles circles with CGA
49+
class circle
50+
{
51+
public:
52+
float radius = 0; //Float for storing the circle radius
53+
Pnt circleCenter; //Point in conformal space for storing the circle center
54+
Par circle; //Store the OPNS representation
55+
Cir dualCircle; //Stores the IPNS representation
56+
Pnt plane; //Stores the plane the the circle lie on
57+
58+
void defineCircle(Pnt p1, Pnt p2, Pnt p3); //Creates circle from 3 points in conformal space
59+
void defineCircle(PointXYZRGB p1, PointXYZRGB p2, PointXYZRGB p3); //Creates a circle from 3 point from a point cloud
60+
void defineCircle(PointCloud<PointXYZRGB>::Ptr cl, int *index); //Creates circle from 3 indexed points in a point cloud
61+
62+
private:
63+
void calcRadius(Pnt p); //Function that finds the cricle radius
64+
void findNormal(Pnt pln); //Creates the plane that the cricle lie on
65+
};
66+
67+
//Class that creates and handles cylinders with CGA
68+
class cylinder{
69+
//Since there is no representation of a cylinder in CGA a cylinder will be represente by a circle on a plane.
70+
//The direction of the normal of the plane in the circle center will be the center-axis of the cylinder
71+
public:
72+
Pnt plan; //Store the IPNS representation of a plane
73+
Pnt center; //Stores the center in a conformal vector
74+
float radius = 0; //Float for storing the radius
75+
76+
void defineCylinder(Pnt p1, Pnt p2, float rad); //Creates a cylinder from two points in conformal space on the center axis and a radius
77+
void defineCylinder(Pnt p1, Pnt p2, Pnt p3); //Creates a cylinder from 3 points in conformal space
78+
void defineCylinder(PointCloud<PointXYZRGB>::Ptr cl, int *index); //Creates the cylinder from 3 indexed points in a point cloud
79+
};
80+
+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
//
2+
// Created by Aksel Sveier. Spring 2016
3+
//
4+
5+
#ifndef PCLVIEWER_H
6+
#define PCLVIEWER_H
7+
8+
#include <iostream>
9+
10+
// Qt
11+
#include <QMainWindow>
12+
#include <QVTKWidget.h>
13+
14+
// Point Cloud Library
15+
#include <pcl/point_cloud.h>
16+
#include <pcl/point_types.h>
17+
#include <pcl/visualization/pcl_visualizer.h>
18+
#include <pcl/filters/passthrough.h>
19+
#include <pcl/filters/extract_indices.h>
20+
#include <pcl/filters/voxel_grid.h>
21+
#include <pcl/filters/statistical_outlier_removal.h>
22+
23+
// Visualization Toolkit (VTK)
24+
#include <vtkRenderWindow.h>
25+
26+
//Grabber
27+
#include "k2g.h"
28+
29+
//Ransac
30+
#include <ransac.h>
31+
#include <vsr/space/vsr_cga3D_op.h>
32+
33+
typedef pcl::PointXYZRGB PointT;
34+
typedef pcl::PointCloud<PointT> PointCloudT;
35+
36+
namespace Ui
37+
{
38+
class PCLViewer;
39+
}
40+
41+
class PCLViewer : public QMainWindow
42+
{
43+
Q_OBJECT
44+
45+
public:
46+
explicit PCLViewer (QWidget *parent = 0);
47+
~PCLViewer ();
48+
//files for storing data
49+
ofstream myfile;
50+
51+
//Datasets
52+
boost::shared_ptr<PointCloudT> cl_raw;
53+
PointCloudT::Ptr cl_filtered;
54+
PointCloudT::Ptr segmented_plane;
55+
56+
//Delete these
57+
PointCloudT::Ptr cam1;
58+
PointCloudT::Ptr cam2;
59+
PointCloudT::Ptr cam3;
60+
61+
//Objects
62+
ransacSphere ranSph;
63+
ransacSpheres ranSpheres;
64+
ransacPlane ranPln;
65+
ransacCircle ranCir;
66+
ransacCylinder2 ranCyl;
67+
Pnt plane; //dual representation of plane
68+
Pnt sphere; //dual representation of sphere
69+
Pnt sphere1;
70+
Pnt sphere2; //dual representation of sphere
71+
float sphereRadius;
72+
float cylRadius;
73+
double cylTresh;
74+
float inlierTresh;
75+
76+
std::clock_t t1,t2;
77+
public slots:
78+
void processFrameAndUpdateGUI();
79+
80+
void pSliderValueChanged (int value);
81+
82+
void XsliderChanged (int value);
83+
void X_2sliderChanged(int value);
84+
85+
void YsliderChanged (int value);
86+
void Y_2sliderChanged(int value);
87+
88+
void ZsliderChanged (int value);
89+
void Z_2sliderChanged(int value);
90+
91+
public Q_SLOTS:
92+
/******************************************
93+
** Auto-connections (connectSlotsByName())
94+
*******************************************/
95+
void on_pushButton_normalize_clicked();
96+
void on_pushButton_addNoise_clicked();
97+
void on_pushButton_findSphereEx_clicked();
98+
void on_pushButton_removeNoise_clicked();
99+
void on_pushButton_findCylinderEx_clicked();
100+
101+
protected:
102+
103+
float x, x_;
104+
float y, y_;
105+
float z, z_;
106+
107+
private slots:
108+
109+
void findPlaneClicked();
110+
111+
void findSphereClicked();
112+
113+
void findCircleClicked();
114+
115+
void sphRadius_valueChanged(double value);
116+
117+
void startStopKinectClicked();
118+
119+
void segmentPlaneClicked();
120+
121+
void removeShapesClicked();
122+
123+
void refreshClicked();
124+
125+
void checkBoxSegmentClicked();
126+
127+
void inlierTresh_valueChanged(double value);
128+
129+
130+
131+
void findCylinderClicked();
132+
133+
void cylRadius_valueChanged(double value);
134+
135+
void meanPointCloudsClicked();
136+
137+
void nrDatasets_valueChanged(double value);
138+
139+
void cylTresh_valueChanged(double value);
140+
141+
void loadImageClicked();
142+
143+
144+
145+
void doStuffClicked();
146+
147+
void confirmClicked();
148+
149+
void saveImageClicked();
150+
151+
void checkBoxKeepImageClicked();
152+
153+
void trackSphereClicked();
154+
155+
void trackSphere(Pnt sph);
156+
157+
void trackPlaneClicked();
158+
159+
void trackPlane();
160+
161+
void trackSphere2Clicked();
162+
163+
void applyTrans();
164+
165+
void findAllSpheresClicked();
166+
167+
void writeClicked();
168+
169+
void iterations_valueChanged(double arg1);
170+
171+
172+
173+
private:
174+
K2G *k2g;
175+
Ui::PCLViewer *ui;
176+
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
177+
QTimer* timr;
178+
179+
//Bools to controle the program
180+
bool kinStarted = false;
181+
bool grabNewFrame = true;
182+
bool segmented = false;
183+
bool checkBoxSeg = true;
184+
bool dostuff = false;
185+
bool allSpheres = false;
186+
int allit = 0;
187+
188+
189+
bool sphereFound = false;
190+
bool planeFound = false;
191+
bool circleFound = false;
192+
bool cylinderFound = false;
193+
bool trackSph1 = false;
194+
bool trackSph2 = false;
195+
bool trackPln = false;
196+
int whichSphere = 0;
197+
198+
int frames_saved = 1;
199+
int iterations = 10000;
200+
bool checkBoxKeep = false;
201+
202+
203+
204+
//Object based registration
205+
int obj = 1;
206+
Eigen::Vector3f O1;
207+
Eigen::Vector3f O2;
208+
Eigen::Vector3f O3;
209+
210+
211+
//Mean Point Cloud
212+
double nrDatasets;
213+
PointCloudT::Ptr mean_cloud;
214+
pcl::VoxelGrid<PointT> voxel;
215+
pcl::StatisticalOutlierRemoval<PointT> stat;
216+
217+
//Filter
218+
pcl::PointIndices::Ptr indices_shown;
219+
pcl::PassThrough<PointT>::Ptr pass;
220+
pcl::ExtractIndices<pcl::PointXYZRGB> extract;
221+
std::vector<int> indices;
222+
pcl::PointIndices::Ptr indices_segmented;
223+
void filter(PointCloudT::Ptr cl);
224+
225+
};
226+
227+
#endif // PCLVIEWER_H

0 commit comments

Comments
 (0)