# create cursor to iterate through the database # we need to open the database to read images from it Super(LmdbLoader, self)._init_(path, **kwargs) –output argument should be a directory where LMDB will be created –path argument should contain the path to your collected images folder There is a python script which creates an LMDB environment with images:
Map_size = num_images * cv2.imread(images_list).nbytes * 10Įnv = lmdb.open(save_path, map_size=map_size) We can use one simple function to read an image from the disk – cv2.imread.ĭef store_many_lmdb(images_list, save_path):įile_sizes = Now we can inherit new classes from the base class and use them for our task. In case you want to know the fun reason why OpenCV uses BGR format, click on this link. In our case, we use BGR color mode as default, but it always can be converted into the required format.
Image decoding functions in different libraries can return images in different formats – RGB or BGR.
), f'Unsupportable extension, please, use one of Self.dataset = self.parse_input(self.path)