コード例 #1
0
    # for tsi object
    tsi_object[view] = TSIUtil.TSI(M[view])

    # for 3 frame difference
    prev_epi = [None, None]
    prev_tsi = [None, None]
    for i in range(2):
        img_color = img = next(fi[view])
        prev_imgs_color[view] = img
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        dst = cv2.warpPerspective(img, M[view], (1000, 300))
        prev_epi[i] = epi_object[view].apply(dst)
        prev_tsi[i] = tsi_object[view].apply(dst)

    fdiff_epi[view] = FrameDifference(*prev_epi)
    fdiff_tsi[view] = FrameDifference(*prev_tsi)

    mask_path = '../../data/gt/2016-ITS-BrnoCompSpeed/dataset/session{}_{}/video_mask.png'.format(
        ses_id, view)
    masks[view] = cv2.imread(mask_path, 0)
"""
-------------------------------------------------------------------------------
Main Program
-------------------------------------------------------------------------------
"""
ctr = 0
while True:
    ctr += 1

    intersection = None
コード例 #2
0
    # for 3 frame difference
    prev_dst = [None, None]
    prev_view = [None, None]
    for i in range(2):
        img = next(fi[view])
        prev_imgs_color[view] = img
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        dst = cv2.warpPerspective(img, M[view], (1000, 300))
        prev_dst[i] = dst
        prev_view[i] = img

    # bm_dst[view] = BackgroundModel (iter (prev_dst), detectShadows=False)
    # bm_dst[view].learn (tot_frame_init=2)
    fdiff_dst[view] = FrameDifference(*prev_dst)
    fdiff_view[view] = FrameDifference(*prev_view)

    mask_path = '../../data/gt/2016-ITS-BrnoCompSpeed/dataset/session{}_{}/video_mask.png'.format(
        ses_id, view)
    masks[view] = cv2.imread(mask_path, 0)
"""
-------------------------------------------------------------------------------
Main Program
-------------------------------------------------------------------------------
"""
ctr = 0
while True:
    ctr += 1

    intersection = None
コード例 #3
0
    # get rectangular homography mapping
    corner_gt = np.float32(corner)
    corner_wrap = np.float32([[0, 300], [0, 0], [1000, 0], [1000, 300]])
    M[view] = cv2.getPerspectiveTransform(corner_gt, corner_wrap)

    # for 3 frame difference
    prev_img = [None, None]
    for i in range(2):
        img = next(fi[view])
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        # save background
        prev_img[i] = img

    fdiff_view[view] = FrameDifference(*prev_img)

    mask_path = '../../data/gt/2016-ITS-BrnoCompSpeed/dataset/session{}_{}/video_mask.png'.format(
        ses_id, view)
    masks[view] = cv2.imread(mask_path, 0)

ss = list(prev_img[0].shape)
ss.append(int(3))
ss = tuple(ss)
print(ss)
print(type(prev_img[0].shape))

fourcc = cv2.VideoWriter_fourcc(*'XVID')
video = cv2.VideoWriter('video.avi', fourcc, 25.0, prev_img[0].shape)
"""
-------------------------------------------------------------------------------
コード例 #4
0
        logger.info("-- Generate prev_epi and tsi")
        for i in range(2):
            img_color = img = next(fi[view])
            prev_imgs_color[view] = img
            img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

            dst = cv2.warpPerspective(img, M[view], (1000, 300))
            for j in range(tot_epi):
                prev_epi[j][i] = epi_object[view][j].apply(dst)
            prev_tsi[i] = tsi_object[view].apply(dst)

        logger.info("-- Initialize EPI FrameDifference")
        fdiff_epi[view] = []
        for i in range(tot_epi):
            fdiff_epi[view].append(FrameDifference(*prev_epi[i]))

        logger.info("-- Initialize TSI FrameDifference")
        fdiff_tsi[view] = FrameDifference(*prev_tsi)

        mask_path = '../../data/gt/2016-ITS-BrnoCompSpeed/dataset/session{}_{}/video_mask.png'.format(
            ses_id, view)
        masks[view] = cv2.imread(mask_path, 0)

    flag_prev_object = False
    list_height = []

    logger.info("Done initializing")
    logger.info("Start counting")
    """
    -------------------------------------------------------------------------------
コード例 #5
0
                    else:
                        tsi_multi = np.hstack((tsi_multi, strip))
                    cv2.line(new_dst, (j * tsi_const['xrange'], 0),
                             (j * tsi_const['xrange'], 300),
                             color=(255, 255, 0),
                             thickness=3)

                # prev_tsi[i] = tsi_object[view].apply (dst)
                prev_view[i] = dst
                prev_tsi_multi[i] = tsi_multi

            logger.info("-- Initialize TSI FrameDifference")
            # fdiff_tsi[view] = FrameDifference (*prev_tsi)
            # fdiff_view[view] = BackgroundModel (iter (prev_view), detectShadows=False)
            # fdiff_view[view].learn (tot_frame_init=2)
            fdiff_view[view] = FrameDifference(*prev_view)

            # fdiff_tsi_multi[view] = BackgroundModel (iter (prev_tsi_multi), detectShadows=False)
            # fdiff_tsi_multi[view].learn (tot_frame_init=2)
            fdiff_tsi_multi[view] = FrameDifference(*prev_tsi_multi)

            mask_path = '../../data/gt/2016-ITS-BrnoCompSpeed/dataset/session{}_{}/video_mask.png'.format(
                ses_id, view)
            masks[view] = cv2.imread(mask_path, 0)

        # flag_prev_object = False
        # list_height = []
        # logger.info ("Creating tsi_multi")

        logger.info("Done initializing")
        logger.info("Start counting")