-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.py
executable file
·148 lines (117 loc) · 3.75 KB
/
header.py
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
#! /usr/bin/python
# Python ctypes bindings for OpenNI
#
# Copyright (C) 2011 Olivier Aubert
#
# Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
#
# 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
# (at your option) 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
"""This module provides bindings for the OpenNI C API.
"""
import ctypes
import sys
build_date = '' # build time stamp and __version__, see generate.py
# Used on win32 and MacOS in override.py
plugin_path = None
if sys.platform.startswith('linux'):
dll = ctypes.CDLL('libOpenNI.so')
elif sys.platform.startswith('win'):
import ctypes.util as u
p = u.find_library('libopenni.dll')
if p is None:
dll = ctypes.CDLL('libvlc.dll')
else:
dll = ctypes.CDLL(p)
del p
elif sys.platform.startswith('darwin'):
dll = ctypes.CDLL('libOpenNI.dylib')
else:
raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform))
try:
_Ints = (int, long)
except NameError: # no long in Python 3+
_Ints = int
_Seqs = (list, tuple)
_Cfunctions = {} # from LibVLC __version__
def _Cfunction(name, flags, *types):
"""(INTERNAL) New ctypes function binding.
"""
if hasattr(dll, name):
p = ctypes.CFUNCTYPE(*types)
f = p((name, dll), flags)
_Cfunctions[name] = f
return f
raise NameError('no function %r' % (name,))
def _Cobject(cls, ctype):
"""(INTERNAL) New instance from ctypes.
"""
o = object.__new__(cls)
o._as_parameter_ = ctype
return o
def _Constructor(cls, ptr):
"""(INTERNAL) New wrapper from ctypes.
"""
if ptr is None:
raise Exception('(INTERNAL) ctypes class.')
if ptr == 0:
return None
if not isinstance(ptr, ctypes.c_void_p):
ptr = ctypes.c_void_p
return _Cobject(cls, ptr)
class _Ctype(object):
"""(INTERNAL) Base class for ctypes.
"""
@staticmethod
def from_param(this): # not self
"""(INTERNAL) ctypes parameter conversion method.
"""
return this._as_parameter_
class ListPOINTER(object):
"""Just like a POINTER but accept a list of ctype as an argument.
"""
def __init__(self, etype):
self.etype = etype
def from_param(self, param):
if isinstance(param, _Seqs):
return (self.etype * len(param))(*param)
class EnumerationErrorsIterator(ctypes.c_void_p):
pass
class FPSData(ctypes.c_void_p):
pass
class NodeHandleReference(ctypes.c_void_p):
def dereference(self):
return NodeHandle(self)
class ContextReference(ctypes.c_void_p):
def dereference(self):
return Context(self)
class NodeInfoListReference(ctypes.c_void_p):
def dereference(self):
return NodeInfoList(self)
class NodeInfoListNode(ctypes.c_void_p):
pass
class XnProductionNodeType(ctypes.c_int32):
pass
# From defines
XN_CAPABILITY_ANTI_FLICKER = "AntiFlicker"
# Generated wrapper classes #
# GENERATED_WRAPPERS
# End of generated wrapper classes #
# Generated enum types #
# GENERATED_ENUMS go here # see generate.py
# End of generated enum types #
# Generated structs #
# GENERATED_STRUCTS go here # see generate.py
# End of generated structs #
# End of header.py #