예제 #1
0
def get_im_names(start_index, end_index):
    imgset_path, jpg_dir, im_ext = io.get_ims_info()
    im_names = ld.get_im_names(imgset_path)  ##get all the im_names(always)
    im_names = im_names[start_index:end_index + 1]  ##trick2
    if debug_flag:
        print 'imgset_path:', imgset_path
        print 'jpgdir_path:', jpg_dir
        print 'im_ext:', im_ext
    return im_names
예제 #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
예제 #3
0
def generate_final_vis_imgs():
    ##vis_picked_mult_instances()  ## run this first, and then the following...\
    final_vis_dir = '/mnt/phoenix_fastdir/experiments/final_vis'
    final_vis_dir = os.path.join(final_vis_dir, set_name)
    org_mrcnn_dir = os.path.join(final_vis_dir, 'org_MRCNN')
    pickd_mrcnn_dir = os.path.join(final_vis_dir, 'picked_MRCNN')
    link_mrcnn_dir = os.path.join(final_vis_dir, 'link_MRCNN')

    ##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]
    # if debug_flag:
    #     print 'imgset_path:',imgset_path
    #     print 'jpg_dir:', jpg_dir
    #     print 'im_ext:', im_ext
    #     print 'im_names:', im_names
    vis_link_imgs(im_names, org_mrcnn_dir, pickd_mrcnn_dir, link_mrcnn_dir)
예제 #4
0
def test_vis_gt_boxes():
    imgset_path, jpg_dir, im_ext = io.get_ims_info()
    im_names = ld.get_im_names(imgset_path)
    ims = ld.load_color_images(jpg_dir, im_names, im_ext)
    data_dir = os.path.join(mcfg.DATA.DATA_DIR, set_name)
    tud_dets_gt_path = get_dets_annots_path(data_dir)
    if debug_flag:
        print 'imgset_path:', imgset_path
        print 'jpg_dir:', jpg_dir
        print 'im_ext:', im_ext
        print 'data_dir:', data_dir
        print 'tud_dets_gt_path:', tud_dets_gt_path

    tud_dets_arr = load_dets_annots(tud_dets_gt_path)

    frm_ids = tud_dets_arr[:, 0].astype(int)
    obj_ids = tud_dets_arr[:, -1].astype(int)

    # uniq_obj_ids=np.sort(np.unique(obj_ids))

    # for u_id in uniq_obj_ids:
    #     label_row_indexes=np.where(obj_ids==u_id)[0]
    #     label_frm_ids=frm_ids[label_row_indexes]
    #     print 'u_id:',u_id
    #     print 'label_frm_ids:', label_frm_ids
    # if debug_flag:
    #     print 'tud_dets_arr.shape:', tud_dets_arr.shape
    #     print 'frm_ids:', frm_ids
    #     print 'obj_ids:', obj_ids
    #     print 'uniq_obj_ids:', uniq_obj_ids
    coords = tud_dets_arr[:, 1:5]
    ##vis_arr=tud_dets_arr[:,5]/100.0   ##make vis range in [0, 1.0]
    boxes = coords_to_boxes(coords)  ## unnormal
    det_dir = mcfg.PROPOSAL.RES_DIR.replace('Continious', 'Discrete')
    gt_det_dir = os.path.join(det_dir, 'vis_gt_boxes')

    for n_id in xrange(len(im_names)):
        im = ims[n_id]
        im_name = im_names[n_id]
        frm_id = int(im_name.split('_')[1])
        row_indexes = np.where(frm_ids == frm_id)[0]
        frm_boxes = boxes[row_indexes]
        frm_obj_ids = obj_ids[row_indexes]
        vis_gt_bboxes(gt_det_dir, im, im_name, frm_boxes, frm_obj_ids)
예제 #5
0
def get_im_names():
    imgset_path, jpg_dir, im_ext = io.get_ims_info()
    im_names = ld.get_im_names(imgset_path)
    return im_names
예제 #6
0
def get_im_names():
    ##0> load image names
    imgset_path, jpg_dir, im_ext = io.get_ims_info()
    im_names = ld.get_im_names(imgset_path)
    return im_names