loc = 1
I = cv.imread(testing_list[1], Clr_flag)
s = np.shape(I)

fscore_tot = []
iou_tot = []
map_tot = []
bboxTP_tot = []
bboxFN_tot = []
bboxFP_tot = []

bboxTP_tot = 0
bboxFN_tot = 0
bboxFP_tot = 0

Bbox = ut.get_bboxes_from_MOTChallenge(gt_file)  #Ground truth Bboxes

for loc, filename in enumerate(testing_list):

    I = ut.getImg_D(filename,
                    D=d,
                    color_space=COLOR_SPACE,
                    color_channels=COLOR_CHANNELS)
    if d == 1:
        I = np.squeeze(I, axis=2)
        I = np.squeeze(I, axis=2)

    frm = ut.frameIdfrom_filename(
        testing_list[loc])  # Get the number of the frame from filename

    print(frm)
        ax2.imshow(std_bg, vmin=0, vmax=255)
    else:
        ax1.imshow(mu_bg, cmap='gray')
        ax2.imshow(std_bg, cmap='gray')
    ax1.set_title("Mean background model over {} frames".format(
        len(train_frames)))
    ax2.set_title("Standard noise backgrond model")
    plt.savefig(os.path.join(results_dir, 'mean_std_testing.png'))

    # Threshold to create different masks
    ths = [2, 2.5, 3, 3.5]

    # Get image size of the frames
    frame_img = cv.imread(test_frames[1], color_flag)
    # Get bounding boxes from ground truth
    bboxes_gt = ut.get_bboxes_from_MOTChallenge(gt_file)

    # Iterate over testing frames to choose one with bounding boxes
    for test_frame in test_frames:
        # Get frame ID from frame filename
        frm = ut.frameIdfrom_filename(test_frame)
        # TODO: VER
        # Get mask and list of bounding boxes from the
        fore_mask, cbbox = ut.getbboxmask(bboxes_gt, frm, frame_img.shape[:2])

        # If there are bounding boxes in the ground truth
        if any(cbbox):
            frame_img = cv.imread(test_frame, color_flag)
            break

    # Plot different thresholds
Esempio n. 3
0
# Directory in the root directory where the results will be saved
# Useful directories
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TRAIN_DIR = os.path.join('dataset', 'train')
TRAIN_DIR_GT = os.path.join(TRAIN_DIR, 'gt')
OUTPUT_DIR = os.path.join(ROOT_DIR, 'output')
FIGURES_DIR = os.path.join(OUTPUT_DIR, 'figures')

IMG_SHAPE = (1080, 1920)
threshold = 0.5 # IoU Threshold


if __name__ == '__main__':
    # List of DataFrames

    df = u.get_bboxes_from_MOTChallenge(TRAIN_DIR_GT)   # CHECK IF THIS IS THE CORRECT FUCTION!
    df_grouped = df.groupby('frame')

    vals = list()
    # iterate over each group

    for group_name, df_group in df_grouped:
        frame = df_group['frame'].values[0]
        df_gt = df_group[['ymin', 'xmin', 'ymax', 'xmax']].values.tolist()

        # Correct order: tly, tlx, bry, brx

        frame_vals = [frame]


        fscore, iou, map = uBG.compute_metrics_general(df_gt, BBOX!!!