-
Notifications
You must be signed in to change notification settings - Fork 11
/
capture.c
118 lines (86 loc) · 2.79 KB
/
capture.c
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
#include <Python.h>
#include <structmember.h>
#include <k4a/k4a.h>
#include "types.h"
PyObject* device_get_capture(PyObject* self, PyObject* args)
{
DeviceObject *obj;
CaptureObject *capture;
int timeout_ms;
PyArg_ParseTuple(args, "OOi", &obj, &capture, &timeout_ms);
k4a_wait_result_t res = k4a_device_get_capture(obj->device, &(capture->capture), timeout_ms);
return PyLong_FromUnsignedLong(res);
}
PyObject* py_capture_get_depth_image(PyObject* self, PyObject* args)
{
CaptureObject* obj;
PyArg_ParseTuple(args, "O", &obj);
ImageObject* imgObj = newImageObject();
imgObj->image = k4a_capture_get_depth_image(obj->capture);
if (imgObj->image == NULL) {
return Py_None;
}
return (PyObject*) imgObj;
}
PyObject* py_capture_get_color_image(PyObject* self, PyObject* args)
{
CaptureObject* obj;
PyArg_ParseTuple(args, "O", &obj);
ImageObject* imgObj = newImageObject();
imgObj->image = k4a_capture_get_color_image(obj->capture);
if (imgObj->image == NULL) {
return Py_None;
}
return (PyObject*) imgObj;
}
PyObject* py_capture_get_ir_image(PyObject* self, PyObject* args)
{
CaptureObject* obj;
PyArg_ParseTuple(args, "O", &obj);
ImageObject* imgObj = newImageObject();
imgObj->image = k4a_capture_get_ir_image(obj->capture);
if (imgObj->image == NULL) {
return Py_None;
}
return (PyObject*) imgObj;
}
PyObject* py_image_get_buffer(PyObject* self, PyObject* args)
{
ImageObject* obj;
PyArg_ParseTuple(args, "O", &obj);
uint8_t* buffer = k4a_image_get_buffer(obj->image);
size_t size = k4a_image_get_size(obj->image);
return PyByteArray_FromStringAndSize((const char*) buffer, size);
}
PyObject* py_image_get_width_pixels(PyObject* self, PyObject* args)
{
ImageObject* obj;
PyArg_ParseTuple(args, "O", &obj);
return PyLong_FromLong(k4a_image_get_width_pixels(obj->image));
}
PyObject* py_image_get_height_pixels(PyObject* self, PyObject* args)
{
ImageObject* obj;
PyArg_ParseTuple(args, "O", &obj);
return PyLong_FromLong(k4a_image_get_height_pixels(obj->image));
}
PyObject* py_image_get_stride_bytes(PyObject* self, PyObject* args)
{
ImageObject* obj;
PyArg_ParseTuple(args, "O", &obj);
return PyLong_FromLong(k4a_image_get_stride_bytes(obj->image));
}
PyObject* py_image_release(PyObject* self, PyObject* args)
{
ImageObject* obj;
PyArg_ParseTuple(args, "O", &obj);
k4a_image_release(obj->image);
return Py_None;
}
PyObject* py_capture_release(PyObject* self, PyObject* args)
{
CaptureObject* obj;
PyArg_ParseTuple(args, "O", &obj);
k4a_capture_release(obj->capture);
return Py_None;
}