forked from grandchild/gspca-kinect2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kinect2.h
170 lines (141 loc) · 4.38 KB
/
kinect2.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* Kinect2-related constans and structures
*
* Copyright (C) 2015 Hiromasa Yoshimoto <[email protected]>
*
* This code is based on the OpenKinect project and libfreenect2
* See the following URLs for details;
* - http://openkinect.org/wiki/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _UAPI__LINUX_KINECT2_H
#define _UAPI__LINUX_KINECT2_H
#include <linux/types.h> /* __u8 etc */
struct kinect2_color_camera_param {
/* unknown, always seen as 1 so far */
__u8 table_id;
/* color -> depth mapping parameters */
float f;
float cx;
float cy;
float shift_d;
float shift_m;
float mx_x3y0; /* xxx */
float mx_x0y3; /* yyy */
float mx_x2y1; /* xxy */
float mx_x1y2; /* yyx */
float mx_x2y0; /* xx */
float mx_x0y2; /* yy */
float mx_x1y1; /* xy */
float mx_x1y0; /* x */
float mx_x0y1; /* y */
float mx_x0y0; /* 1 */
float my_x3y0; /* xxx */
float my_x0y3; /* yyy */
float my_x2y1; /* xxy */
float my_x1y2; /* yyx */
float my_x2y0; /* xx */
float my_x0y2; /* yy */
float my_x1y1; /* xy */
float my_x1y0; /* x */
float my_x0y1; /* y */
float my_x0y0; /* 1 */
/* perhaps related to xtable/ztable in the deconvolution code. */
/* data seems to be arranged into two tables of 28*23, which */
/* matches the depth image aspect ratio of 512*424 very closely */
float table1[28 * 23 * 4];
float table2[28 * 23];
} __packed;
/* Depth camera's intrinsic & distortion parameters */
struct kinect2_depth_camera_param {
/* intrinsics (this is pretty certain) */
float fx;
float fy;
float unknown0; /* assumed to be always zero */
float cx;
float cy;
/* radial distortion (educated guess based on */
/* calibration data from Kinect SDK) */
float k1;
float k2;
float p1; /* always seen as zero so far, so purely a guess */
float p2; /* always seen as zero so far, so purely a guess */
float k3;
float unknown1[13]; /* assumed to be always zero */
} __packed;
/* "P0" coefficient tables, input to the deconvolution code */
struct kinect2_p0table {
__u32 headersize;
__u32 unknown1;
__u32 unknown2;
__u32 tablesize;
__u32 unknown3;
__u32 unknown4;
__u32 unknown5;
__u32 unknown6;
__u16 unknown7;
__u16 p0table0[512*424]; /* row[0] == row[511] == 0x2c9a */
__u16 unknown8;
__u16 unknown9;
__u16 p0table1[512*424]; /* row[0] == row[511] == 0x08ec */
__u16 unknownA;
__u16 unknownB;
__u16 p0table2[512*424]; /* row[0] == row[511] == 0x42e8 */
__u16 unknownC;
__u8 unknownD[];
} __packed;
struct kinect2_depth_footer {
__u32 magic0;
__u32 magic1;
__u32 timestamp;
__u32 sequence;
__u32 subsequence;
__u32 length;
__u32 fields[32];
} __packed;
struct kinect2_color_header {
__u32 sequence;
__u32 magic; /* 0x42424242 */
__u8 image[];
} __packed;
struct kinect2_color_footer {
__u32 sequence;
__u32 unknownA[3];
__u32 timestamp;
__u32 unknownB[2];
__u32 magic; /* 0x42424242 */
__u32 length;
__u32 unknownC[4];
} __packed;
#define KINECT2_DEPTH_IMAGE_SIZE (512*424*11/8)
#define KINECT2_DEPTH_FRAME_SIZE \
(KINECT2_DEPTH_IMAGE_SIZE + sizeof(struct kinect2_depth_footer))
#define KINECT2_GET_DEPTH_FOOTER(p) \
((struct kinect2_depth_footer *)((char *)(p) + KINECT2_DEPTH_FRAME_SIZE*10 - sizeof(struct kinect2_depth_footer)))
#define KINECT2_GET_COLOR_FOOTER(ptr, len) \
((struct kinect2_color_footer *)((char *)(ptr) + (len) - sizeof(struct kinect2_color_footer)))
#include <linux/videodev2.h>
struct kinect2_ioctl_req {
int len;
void *ptr;
} __packed;
#define VIDIOC_KINECT2_COLOR_PARAM _IOWR('V', BASE_VIDIOC_PRIVATE + 0,\
struct kinect2_ioctl_req)
#define VIDIOC_KINECT2_DEPTH_PARAM _IOWR('V', BASE_VIDIOC_PRIVATE + 1,\
struct kinect2_ioctl_req)
#define VIDIOC_KINECT2_P0TABLE _IOWR('V', BASE_VIDIOC_PRIVATE + 2,\
struct kinect2_ioctl_req)
#endif /* _UAPI__LINUX_KINECT2_H */