-
Notifications
You must be signed in to change notification settings - Fork 4
/
KinectV1.h
110 lines (78 loc) · 2.58 KB
/
KinectV1.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
#pragma once
//
// デプスセンサ関連の処理
//
// Kinect V1 を使う
#if !defined(USE_KINECT_V1)
# define USE_KINECT_V1 1
# ifdef SENSOR
# undef SENSOR
# endif
# define SENSOR KinectV1
#endif
#if USE_KINECT_V1
// Kinect V1 関連
#include <Windows.h>
#include <NuiApi.h>
// デプスセンサ関連の基底クラス
#include "DepthCamera.h"
// デプス画像のサイズ
#define DEPTH_W 320
#define DEPTH_H 240
// カラー画像のサイズ
#define COLOR_W 640
#define COLOR_H 480
// NUI_IMAGE_RESOLUTION の設定
#define EXPAND_RESOLUTION(width, height) NUI_IMAGE_RESOLUTION_##width##x##height
#define RESOLUTION(width, height) EXPAND_RESOLUTION(width, height)
#define DEPTH_RESOLUTION RESOLUTION(DEPTH_W, DEPTH_H)
#define COLOR_RESOLUTION RESOLUTION(COLOR_W, COLOR_H)
class KinectV1 : public DepthCamera
{
// 接続しているセンサの数
static int connected;
// 使用しているセンサの数
static int activated;
// センサの識別子
INuiSensor *sensor;
// デプスデータのストリームハンドル
HANDLE depthStream;
// デプスデータのイベントハンドル
const HANDLE nextDepthFrameEvent;
// デプスデータの計測不能点を変換するために用いる一次メモリ
std::vector<GLushort> depth;
// デプスデータからカメラ座標を求めるときに用いる一時メモリ
std::vector<Point> point;
// カラーデータのストリームハンドル
HANDLE colorStream;
// カラーデータのイベントハンドル
const HANDLE nextColorFrameEvent;
// スクリーン座標からカメラ座標に変換する係数
GLfloat scale[2];
// カメラ座標を計算するシェーダ
static std::unique_ptr<Compute> shader;
// デプスデータのイメージユニットの uniform 変数 depth の場所
static GLint depthLoc;
// カメラ座標のイメージユニットの uniform 変数 point の場所
static GLint pointLoc;
// スクリーン座標からカメラ座標に変換する係数の uniform 変数 scale の場所
static GLint scaleLoc;
public:
// コンストラクタ
KinectV1();
// デストラクタ
virtual ~KinectV1();
// 奥行きの最大値 (mm)
static constexpr GLushort maxDepth = 10000;
// 疑似カラー処理の範囲
static constexpr GLfloat range[2] = { 0.8f, 4.0f };
// デプスデータを取得する
GLuint getDepth();
// カメラ座標を取得する
GLuint getPoint();
// カメラ座標を算出する
GLuint getPosition();
// カラーデータを取得する
GLuint getColor();
};
#endif