-
Notifications
You must be signed in to change notification settings - Fork 0
/
KinectHelper.h
114 lines (79 loc) · 3.06 KB
/
KinectHelper.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* File: KinectHelper.h
* Author: ros
*
* Created on 28. April 2011, 15:07
*/
#ifndef KINECTHELPER_H
#define KINECTHELPER_H
#define DEG2RAD(x) (x * (3.14159 / 180))
#include <opencv/cv.h>
#include <libfreenect/libfreenect.h>
#include <cvblob.h>
#include <functional>
#include <iostream>
#include <queue>
#include <list>
#include <cmath>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include "CvShapes.h"
#include "PlayingField.h"
#define BNU boost::numeric::ublas
/*
bool fartherRight(CvPoint a, CvPoint b);
bool fartherLeft(CvPoint a, CvPoint b);
bool fartherUp(CvPoint a, CvPoint b);
bool fartherDown(CvPoint a, CvPoint b);
void Raster(CvPoint& point, double x, double y);
std::queue<CvPoint> Border(std::vector<CvPoint> points, std::function<bool()> func);
*/
typedef enum {
Vertical,
Horizontal,
} Orientation;
class KinectHelper {
public:
static const double fov;
static double view_plane_distance_cm, v_px_per_cm, h_px_per_cm;
static double frame_offset;
static double distance_coefficient;
static double scale;
static CvRect straight_rect;
static BNU::vector<double> projectiveTransformationVector;
static double GetDirectDistance(CvPoint pt);
static double GetDirectDistanceInCM(double distanceValue);
static double GetDistanceOverGround(double distanceValue);
static double GetKinectHeight();
static double GetTilt();
static void CalibrateVanishingPoint(); static bool bVPCalibrated;
static void CalibrateAnglesAndViewport(); static bool bAandVCalibrated;
static void SetupProjectionVector();
static void SetupPlayingField(int sX, int sY);
static void DrawCalibrationData(CvArr* img);
static CvPoint GetAbsoluteX(CvPoint point);
static CvPoint GetAbsoluteCoordinates(double distanceValue, double xOnImage);
static CvPoint GetLeftFrameEdgeVector();
static CvPoint GetOnImageVector(double XOnImage);
static CvPoint GetToPosVector(double Distance);
static double In_px(double cm, Orientation o);
static double In_cm(double px, Orientation o);
static void Raster(CvPoint& point, double x, double y);
static void DrawProjectedPoint(CvArr* img, CvPoint point);
static CvPoint ProjectPoint(CvPoint point);
static void ProjectImage(CvArr* src, CvArr* dst);
static std::list<double> avg_values;
static double view_angle;
static int absolute_x, absolute_y;
static double add_depth_cm, add_depth_px;
static freenect_device* dev;
static CvArr* depthData;
static CvPoint VanishingPoint;
static std::vector<CvPoint> pointsUsedForCalibration;
};
bool operator>(CvScalar a, double max);
bool leftOf(const std::pair<int, cvb::CvBlob*>& point, const std::pair<int, cvb::CvBlob*>& of);
bool rightOf(const std::pair<int, cvb::CvBlob*>& point, const std::pair<int, cvb::CvBlob*>& of);
bool smallestIndex(const std::pair<int, cvb::CvBlob*>& a, const std::pair<int, cvb::CvBlob*>& b);
#endif /* KINECTHELPER_H */