Go to the documentation of this file.00001 """
00002 roidb
00003 basic format [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped']
00004 extended ['image', 'max_classes', 'max_overlaps', 'bbox_targets']
00005 """
00006
00007 import cv2
00008 import numpy as np
00009
00010 from bbox.bbox_regression import compute_bbox_regression_targets
00011
00012
00013 def prepare_roidb(imdb, roidb, cfg):
00014 """
00015 add image path, max_classes, max_overlaps to roidb
00016 :param imdb: image database, provide path
00017 :param roidb: roidb
00018 :return: None
00019 """
00020 print 'prepare roidb'
00021 for i in range(len(roidb)):
00022 roidb[i]['image'] = imdb.image_path_from_index(imdb.image_set_index[i])
00023 if cfg.TRAIN.ASPECT_GROUPING:
00024 size = cv2.imread(roidb[i]['image']).shape
00025 roidb[i]['height'] = size[0]
00026 roidb[i]['width'] = size[1]
00027 gt_overlaps = roidb[i]['gt_overlaps'].toarray()
00028 max_overlaps = gt_overlaps.max(axis=1)
00029 max_classes = gt_overlaps.argmax(axis=1)
00030 roidb[i]['max_overlaps'] = max_overlaps
00031 roidb[i]['max_classes'] = max_classes
00032
00033
00034 zero_indexes = np.where(max_overlaps == 0)[0]
00035 assert all(max_classes[zero_indexes] == 0)
00036
00037 nonzero_indexes = np.where(max_overlaps > 0)[0]
00038 assert all(max_classes[nonzero_indexes] != 0)