Exemple #1
0
def load_det_proposals(seq_name, start_frm_id, end_frm_id):
    prop_file_path, prop_file_ext = io.get_dets_info(seq_name)
    prop_arr = ld.load_det_proposals(
        prop_file_path)  ## load all the proposals(always)
    frm_ids = np.arange(start_frm_id, end_frm_id + 1)
    prop_arr, row_indexes = dets_filter_frms(prop_arr, frm_ids)
    if debug_flag:
        print 'prop_file_path:', prop_file_path
        print 'prop_file_ext:', prop_file_ext
    return prop_arr
Exemple #2
0
def vis_picked_mult_instances():
    print '=============================test vis_util================================='
    track_mask_dir = io.get_track_mask_info(set_name)
    prop_file_path, prop_file_ext = io.get_dets_info(set_name)
    prop_arr = ld.load_det_proposals(prop_file_path)

    if debug_flag:
        print 'track_mask_dir:', track_mask_dir
        print 'prop_file_path:', prop_file_path
        print 'prop_file_ext:', prop_file_ext
        print 'prop_arr.shape:', prop_arr.shape

    ##0> load image names
    imgset_path, jpg_dir, im_ext = io.get_ims_info()
    im_names = ld.get_im_names(imgset_path)

    im_names = im_names[:test_frm_num]

    ##1> load color images
    rgb_ims = ld.load_color_images(jpg_dir, im_names, im_ext)
    vis_proposals_dir = io.get_vis_dir_info(vis_mult_prop_folder)
    iter_name = 'iter' + str(4)

    ## draw bbox per person
    frm_ids = np.unique(prop_arr[:, 0]).astype(int)
    frm_num = len(frm_ids)

    ##for debug
    for n_id in xrange(
            frm_num):  ## label is obj_id  (42 has some problems, 56)
        frm_id = frm_ids[n_id]
        row_indexs = np.where(prop_arr[:, 0] == frm_id)[0]  ##frame indexes
        frm_prop_arr = prop_arr[row_indexs]
        frm_labels = frm_prop_arr[:, 1].astype(int)
        im = rgb_ims[n_id]
        im_name = set_name + '_' + str(frm_ids[n_id] + shift_num).zfill(6)
        if len(frm_labels) == 0:
            continue

        masks = load_frame_masks(track_mask_dir, frm_labels, iter_name,
                                 im_name)
        boxes = load_frame_boxes(track_mask_dir, frm_id, frm_labels, iter_name)
        if debug_flag:
            print 'frm_id:', frm_id
            print 'frm_labels:', frm_labels.shape
            print 'masks.shape:', len(masks)
            print 'boxes.shape:', boxes.shape
        vis_proposals_multi_instances(vis_proposals_dir, iter_name, im,
                                      im_name, boxes, masks, frm_labels)

    if debug_flag:
        print 'track_mask_dir:', track_mask_dir
        ##print 'im_names:', im_names
        print 'vis_proposals_dir:', vis_proposals_dir
def get_refine_dets():
    track_mask_dir = io.get_track_mask_info(set_name)
    prop_file_path, prop_file_ext = io.get_dets_info(set_name)
    prop_arr = ld.load_det_proposals(prop_file_path)
    if debug_flag:
        print 'track_mask_dir:', track_mask_dir
        print 'prop_file_path:', prop_file_path
        print 'prop_file_ext:', prop_file_ext
        print 'prop_arr.shape:', prop_arr.shape

    det_frm_ids = []
    det_obj_ids = []
    det_boxes = []
    det_masks = []

    frm_ids = np.sort(np.unique(prop_arr[:, 0]).astype(int))
    frm_num = len(frm_ids)

    ## calculate based on per-frame
    for n_id in xrange(frm_num):
        frm_id = frm_ids[n_id]
        row_indexs = np.where(prop_arr[:, 0] == frm_id)[0]  ##frame indexes
        frm_prop_arr = prop_arr[row_indexs]
        frm_labels = frm_prop_arr[:, 1].astype(int)

        im_name = set_name + '_' + str(frm_ids[n_id] + shift_num).zfill(
            6)  ##im_name

        boxes = load_frame_boxes(track_mask_dir, frm_id, frm_labels, iter_name)
        masks = load_frame_masks(track_mask_dir, frm_labels, iter_name,
                                 im_name)

        ##max_masks=get_max_masks(masks,boxes,img_box) ## not used
        det_frm_ids.append(frm_id)
        det_obj_ids.append(frm_labels)

        det_boxes.append(boxes)
        det_masks.append(masks)

        #if debug_flag:
        #     print 'frm_id:', frm_id
        #     print 'frm_labels:', frm_labels.shape
        #     print 'len(masks):', len(masks)
        #     print 'len(boxes):', len(boxes)
    return det_frm_ids, det_obj_ids, det_boxes, det_masks
def get_init_dets(cont_flag=False):
    det_boxes = []
    det_masks = []
    det_obj_ids = []
    det_frm_ids = []

    bin_mask_dir = mcfg.MASK.BIN_LAB_DIR
    init_mask_dir = os.path.join(bin_mask_dir, set_name)
    prop_file_path, prop_file_ext = io.get_dets_info(set_name)
    if not cont_flag:
        init_mask_dir = init_mask_dir.replace('Continious', 'Discrete')
        prop_file_path = prop_file_path.replace('Continious', 'Discrete')

    prop_arr = ld.load_det_proposals(prop_file_path)
    frm_ids = np.sort(np.unique(prop_arr[:, 0]).astype(int))
    frm_num = len(frm_ids)
    img_box = [0, 0, im_width - 1, im_height - 1]  ## not used

    ## calculate based on per-frame
    ##for n_id in xrange(1):
    for n_id in xrange(frm_num):
        frm_id = frm_ids[n_id]
        row_indexs = np.where(prop_arr[:, 0] == frm_id)[0]  ##frame indexes
        frm_prop_arr = prop_arr[row_indexs]
        frm_labels = frm_prop_arr[:, 1].astype(int)
        im_name = set_name + '_' + str(frm_ids[n_id] + shift_num).zfill(6)

        frm_coords = frm_prop_arr[:, 2:6]
        flt_frm_boxes = coords_to_boxes(frm_coords)
        frm_masks = load_frame_masks(init_mask_dir, frm_labels, '', im_name)
        int_frm_boxes = boxes_float_to_int(flt_frm_boxes, frm_masks)
        ##max_masks=get_max_masks(masks,boxes,img_box) ## not used
        det_frm_ids.append(frm_id)
        det_obj_ids.append(frm_labels)
        det_boxes.append(int_frm_boxes)
        det_masks.append(frm_masks)
    # if debug_flag:
    #     print 'cont_flag:', cont_flag
    #     print 'init_mask_dir:', init_mask_dir
    #     print 'prop_file_path:', prop_file_path
    #     print 'prop_arr.shape:', prop_arr.shape
    #     print 'frm_num:', frm_num
    return det_frm_ids, det_obj_ids, det_boxes, det_masks
Exemple #5
0
def get_pre_cont_dets():
    # print 'prop_file_path:', prop_file_path
    # print 'prop_file_ext:', prop_file_ext
    prop_file_path, prop_file_ext = io.get_dets_info(seq_name)
    prop_arr = ld.load_det_proposals(prop_file_path)
    return prop_arr