def test_cv_page_reader(): """test cv page reader using shard api""" reader = ShardSegment() reader.open(CV_FILE_NAME + "0") fields = reader.get_category_fields() logger.info("fields: {}".format(fields)) ret = reader.set_category_field("label") assert ret == SUCCESS, 'failed on setting category field.' info = reader.read_category_info() logger.info("category info: {}".format(info)) img1 = reader.read_at_page_by_id(0, 0, 1) logger.info("img1 len: {}, img1[0] len: {}".format(len(img1), len(img1[0]))) img2 = reader.read_at_page_by_name("822", 0, 1) logger.info("img2 len: {}, img2[0] len: {}".format(len(img2), len(img2[0]))) paths = [ "{}{}".format(CV_FILE_NAME, str(x).rjust(1, '0')) for x in range(FILES_NUM) ] for x in paths: os.remove("{}".format(x)) os.remove("{}.db".format(x))
def test_mkv_page_reader(): """test mkv page reader using shard api""" reader = ShardSegment() reader.open(MKV_FILE_NAME + "0") fields = reader.get_category_fields() logger.info("fields: {}".format(fields)) ret = reader.set_category_field("id") assert ret == SUCCESS, 'failed on setting category field.' info = reader.read_category_info() logger.info("category info: {}".format(info)) img1 = reader.read_at_page_by_id(0, 0, 1) logger.info("img1 len: {}, img1[0] len: {}, img1[0]: {}".format( len(img1), len(img1[0]), img1[0])) img2 = reader.read_at_page_by_name("2", 0, 1) logger.info("img2 len: {}, img2[0] len: {}, img2[0]: {}".format( len(img2), len(img2[0]), img2[0]))
def test_mkv_page_reader_random(): """test mkv page random reader using shard api""" reader = ShardSegment() reader.open(MKV_FILE_NAME + "0") fields = reader.get_category_fields() logger.info("fields: {}".format(fields)) ret = reader.set_category_field("id") assert ret == SUCCESS, 'failed on setting category field.' names = random.sample(range(1, 6), 5) for name in names: img2 = reader.read_at_page_by_name(str(name), 0, 2) logger.info("name: {}, img2[0] len: {}".format(str(name), len(img2[0]))) paths = [ "{}{}".format(MKV_FILE_NAME, str(x).rjust(1, '0')) for x in range(FILES_NUM) ] for x in paths: os.remove("{}".format(x)) os.remove("{}.db".format(x))