@@ -217,6 +217,11 @@ cdef class Frame:
217
217
frame_type : int, optional
218
218
Underlying frame type. Default is -1. Used by ``asarray`` method.
219
219
220
+ byte_data : byte_data, optional
221
+ Numpy array of depth or ir data in byte format,
222
+ that will be converted to a frame class.
223
+ Use byte_data = numpy_array.tobytes('C') for conversion to bytes.
224
+ Default is None.
220
225
See also
221
226
--------
222
227
@@ -228,7 +233,7 @@ cdef class Frame:
228
233
cdef int frame_type
229
234
230
235
def __cinit__ (self , width = None , height = None , bytes_per_pixel = None ,
231
- int frame_type = - 1 ):
236
+ int frame_type = - 1 , byte_data = None ):
232
237
w,h,b = width, height, bytes_per_pixel
233
238
all_none = (w is None ) and (h is None ) and (b is None )
234
239
all_not_none = (w is not None ) and (h is not None ) and (b is not None )
@@ -238,7 +243,11 @@ cdef class Frame:
238
243
239
244
if all_not_none:
240
245
self .take_ownership = True
241
- self .ptr = new libfreenect2.Frame(
246
+ if byte_data is not None :
247
+ self .ptr = new libfreenect2.Frame(
248
+ width, height, bytes_per_pixel, byte_data)
249
+ else :
250
+ self .ptr = new libfreenect2.Frame(
242
251
width, height, bytes_per_pixel, NULL )
243
252
else :
244
253
self .take_ownership = False
0 commit comments