1 /****************************************************************************
2 * MeshLab                                                           o o     *
3 * A versatile mesh processing toolbox                             o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2005                                                \/)\/    *
6 * Visual Computing Lab                                            /\/|      *
7 * ISTI - Italian National Research Council                           |      *
8 *                                                                    \      *
9 * All rights reserved.                                                      *
10 *                                                                           *
11 * This program is free software; you can redistribute it and/or modify      *
12 * it under the terms of the GNU General Public License as published by      *
13 * the Free Software Foundation; either version 2 of the License, or         *
14 * (at your option) any later version.                                       *
15 *                                                                           *
16 * This program is distributed in the hope that it will be useful,           *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
20 * for more details.                                                         *
21 *                                                                           *
22 ****************************************************************************/
23 
24 #ifndef KinectEditPlugin_H
25 #define KinectEditPlugin_H
26 
27 #include <QObject>
28 #include <common/interfaces.h>
29 #include <common/meshmodel.h>
30 #include <vector>
31 #include "ui_kinect.h"
32 
33 
34 
35 /* OCME include */
36 #include <wrap/gui/trackball.h>
37 
38 class KinectEditPlugin : public QObject, public MeshEditInterface
39 {
40 	Q_OBJECT
41 	Q_INTERFACES(MeshEditInterface)
42 
43 
44 
45 public:
46         KinectEditPlugin();
~KinectEditPlugin()47         virtual ~KinectEditPlugin() {}
48 
49     static const QString Info();
50 
51 	virtual bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/);
52 	virtual void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/);
53 
54 	virtual void Decorate(MeshModel &/*m*/, GLArea * /*parent*/);
55         virtual void mousePressEvent(QMouseEvent *, MeshModel &, GLArea * ) ;
56         virtual void mouseMoveEvent(QMouseEvent *, MeshModel &, GLArea * ) ;
57         virtual void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
58 
59 	void setTrackBall();
60 	void resetPlugin();
61 	QFont qFont;
62         QDockWidget * kinect_panel;
63         Ui::KinectDockWidget * odw;
64 	GLArea * gla;
65 	MeshModel * mm;						// mesh associated with ocme
66 	vcg::Trackball curr_track;
67         bool cumulate_frames;
68         float tilt,toinitialize;
69         GLuint  gl_depth_tex,    // texture to upload the kinect values
70                 gl_depth_tex_avg,
71                 gl_color_tex,
72                 foc_loc,
73                 shx_loc,
74                 point_cloud,    // VBO of 680*480 vertex
75 				pr,             // program to displace vertices
76 				gl_undistort_rgb_tex,
77 				gl_undistort_depth_tex;
78 
79         enum {VIEW_SCANNED_MODEL,VIEW_REAL_TIME} ViewMode;
80         struct Frame{ unsigned short data[640*480];};
81         float frames_avg[640*480];
82         float frames_var[640*480];
83         std::vector<Frame> frames;
84         unsigned char  rgb_stored[640*480*4];
85         bool ScanningConverged();
86         void InitializeGL();
87         void CleanupGL();
88 		void UndistortMaps();
89 public slots:
90         void loadCalibration();
91         void startScan();
92         void stopScan();
93         void saveScan();
94         void setViewMode();
95         void setTilt(double);
96 };
97 
98 #endif
99