def next(self): assert self.m.width > 0 if self.channels == 1: shape = (self.m.height, self.m.width) else: shape = (self.m.height, self.m.width, self.channels) img = Frame(shape, 'B') assert img.__array_interface__['strides'] is None pixels = ffi.cast('uint8_t *', img.__array_interface__['data'][0]) while True: r = lib.decode_frame(self.p, self.frm, pixels, self.pts, self.channels == 1) if r >= 0: if lib.mkv_next(self.m, self.frm) == 0 and r == 0: raise StopIteration if r == 1: break else: raise DecodeError img.index = self.fcnt img.pts = self.pts[0] img.timestamp = float(img.pts) / 1000000.0 img.systime = float(img.pts + self.systime_offset) / 1000000.0 self.fcnt += 1 return img
def next(self): r = lib.mjpg_next_head(self.m) if r == lib.ERROR_EOF: raise StopIteration if r != lib.OK: raise UnsupportedFormatError if self.channels == 1: shape = (self.m.height, self.m.width) else: shape = (self.m.height, self.m.width, self.channels) img = Frame(shape, 'B') if img.__array_interface__['strides'] is not None: raise UnsupportedFormatError self.m.pixels = ffi.cast('unsigned char *', img.__array_interface__['data'][0]) r = lib.mjpg_next_data(self.m) if r == lib.ERROR_EOF: raise StopIteration if r != lib.OK: raise UnsupportedFormatError # img = img.reshape(shape).view(type=Frame) img.timestamp = self.m.timestamp_sec + self.m.timestamp_usec / 1000000.0 img.systime = img.timestamp img.index = self.fcnt self.fcnt += 1 return img
def next(self): assert self.m.width > 0 if self.channels == 1: shape = (self.m.height, self.m.width) else: shape = (self.m.height, self.m.width, self.channels) img = Frame(shape, 'B') assert img.__array_interface__['strides'] is None pixels = ffi.cast('uint8_t *', img.__array_interface__['data'][0]) while True: r = self.decoder.decode_frame(self.frm, pixels, self.pts, self.channels == 1) if r >= 0: if lib.mkv_next(self.m, self.frm) == 0 and r == 0: raise StopIteration if r == 1: break else: raise DecodeError img.index = self.fcnt img.pts = self.pts[0] img.timestamp = float(img.pts) / 1000000.0 img.systime = float(img.pts + self.systime_offset) / 1000000.0 self.fcnt += 1 return img
def next(self): r = lib.mjpg_next_head(self.m) if r != lib.OK: raise StopIteration if self.channels == 1: shape = (self.m.height, self.m.width) else: shape = (self.m.height, self.m.width, self.channels) img = Frame(shape, 'B') assert img.__array_interface__['strides'] is None self.m.pixels = ffi.cast('unsigned char *', img.__array_interface__['data'][0]) r = lib.mjpg_next_data(self.m) if r != lib.OK: raise StopIteration # img = img.reshape(shape).view(type=Frame) img.timestamp = self.m.timestamp_sec + self.m.timestamp_usec / 1000000.0 img.systime = img.timestamp img.index = self.fcnt self.fcnt += 1 return img