'Return the database of regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.'

def region_proposal_roidb(self):

    cache_file = os.path.join(self.cache_path, (((((self.name + '_') + cfg.SUBCLS_NAME) + '_') + cfg.REGION_PROPOSAL) + '_region_proposal_roidb.pkl'))
    if os.path.exists(cache_file):
        with open(cache_file, 'rb') as fid:
            roidb = cPickle.load(fid)
        print '{}    roidb    loaded    from    {}'.format(self.name, cache_file)
        return roidb
    if (self._image_set != 'test'):
        gt_roidb = self.gt_roidb()
        print 'Loading    region    proposal    network    boxes...'
        if (self._image_set == 'trainval'):
            model = (cfg.REGION_PROPOSAL + '_227/')
        else:
            model = (cfg.REGION_PROPOSAL + '_125/')
        rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
        print 'Region    proposal    network    boxes    loaded'
        roidb = datasets.imdb.merge_roidbs(rpn_roidb, gt_roidb)
    else:
        print 'Loading    region    proposal    network    boxes...'
        model = (cfg.REGION_PROPOSAL + '_227/')
        roidb = self._load_rpn_roidb(None, model)
        print 'Region    proposal    network    boxes    loaded'
    print '{}    region    proposals    per    image'.format((self._num_boxes_proposal / len(self.image_index)))
    with open(cache_file, 'wb') as fid:
        cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
    print 'wrote    roidb    to    {}'.format(cache_file)
    return roidb
