def imgset_fixture(request, tmpdir_factory, fname, images): filename = tmpdir_factory.mktemp('h5').join(fname).strpath img_shape = (IMG_SIZE, IMG_SIZE) imageset = ImageSet.create(filename, img_shape) extractor = RawFeatures(img_shape, img_shape) imageset.add_feature_set(extractor) for img in images: imageset._add_image(**img) imageset.fileh.flush() def fin(): imageset.close() request.addfinalizer(fin) return imageset
def add_webcam(self, webcam_id): """ Create the required files and directories for a new webcam """ logger.info("Creating webcam %s on file system", webcam_id) # create pytables files hdf5_path = self.dataset_path(webcam_id) w, h = settings.WEBCAM_SIZE img_shape = h, w, 3 w, h = settings.DEFAULT_FEATURES_SIZE feat_shape = h, w, 3 with ImageSet.create(hdf5_path, img_shape) as imageset: extractor = RawFeatures(feat_shape, img_shape) imageset.add_feature_set(extractor) DataSet.create(imageset).close() # create directories for pictures pics_path = self.fs.path(self.picture_path(webcam_id)) os.makedirs(pics_path)