Beispiel #1
0
                thickness = 2

                # fgs[view] = draw_polylines (fgs[view], b, color, thickness )

                # b = np.matrix (b)
                bottom_polylines = b

                # get blobs that contain this 
                is_found = False
                for bl in blobs : 
                    if is_contained (bl, middle_point) :
                        print ("Found middle")
                        is_found = True

                        # get top polylines
                        top_polylines = TSIUtil.get_top_polylines (b, bl)
                        # print (top_polylines)

                        """
                        max_cp_y = np.max (b[:, 1]) - 3 # small tradeoff
                        box_floor = []
                        (x,y,w,h) = cv2.boundingRect (bl)

                        for cp in b.tolist () : 
                            cp_h = list (cp)
                            # cp_h[1] -= abs (y - max_cp_y)
                            cp_h[1] -= HEIGHT

                            cv2.line (fgs[view], tuple (cp), tuple (cp_h), color, thickness=thickness) 

                            box_floor.append (cp_h)
Beispiel #2
0
fgs = {}
dsts = {}
prev_dsts = {}
fdiff_view = {}  # frame difference camera image
fdiff_tsi = {}  # frame difference tsi image
fdiff_epi = {}  # frame difference epi image
bm_epi = {}
tsi_object = {}
epi_object = {}
masks = {}

for view in VIEW:
    img = cv2.imread(img_path.format(ses_id, view), 1)

    points = GT['session{}'.format(ses_id)][view]
    corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                       points)

    # 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)

    # initialize tsi object
    tsi_object[view] = TSIUtil.TSI(M[view], VDL_IDX=0)
    # epi_object[view] = TSIUtil.EPI (M[view], VDL_IDX=75)

    # for 3 frame difference
    prev_img = [None, None]
    prev_tsi = [None, None]
    prev_epi = [None, None]
    for i in range(2):
Beispiel #3
0
tsi_object = {}
fdiff_tsi = {}

# miscelanous
empty = np.zeros((1000, 700)).astype('uint8')
random.seed(200)
unique_color = []
for i in range(100):
    unique_color.append((random.randrange(0, 255), random.randrange(0, 255),
                         random.randrange(0, 255)))

for view in VIEW:
    img = cv2.imread(img_path.format(ses_id, view), 1)

    points = GT['session{}'.format(ses_id)][view]
    corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                       points)

    # 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)
    M_inv[view] = cv2.getPerspectiveTransform(corner_wrap, corner_gt)

    # for epi object
    epi_object[view] = TSIUtil.EPI(
        M[view],
        size=(1000, 300),
        VDL_IDX=70,
        VDL_SIZE=3,
    )
Beispiel #4
0
M = {}  # matrix homography
M_inv = {}  # matrix homography
imgs_color = {}  # for saving image color each view
bm_dst = {}
fdiff_dst = {}
fdiff_view = {}
masks = {}
fgs = {}
prev_imgs_color = {}

for view in VIEW:
    img = cv2.imread(img_path.format(ses_id, view), 1)

    points = GT['session{}'.format(ses_id)][view]
    corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                       points)

    # 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)
    M_inv[view] = cv2.getPerspectiveTransform(corner_wrap, corner_gt)

    # 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)
    masks = {}

    for view in VIEW:
        img = cv2.imread(img_path.format(ses_id, view), 1)

        points = GT['session{}'.format(ses_id)][view]
        corner = get_corner_ground(vp[view]['vp1'], vp[view]['vp2'], points)

        # 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 initialization
        ts_img[view] = None  # np.zeros ((300, 1000, 3))
        tsi_object[view] = TSIUtil.TSI(M[view], VDL_IDX=0)

        # for 3 frame difference
        prev_img = [None, None]
        prev_tsi = [None, None]

        for i in range(2):
            img = next(fi[view])
            img_color = img.copy()
            img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

            # save background
            prev_img[i] = img
            prev_tsi[i] = tsi_object[view].apply(img)

        fdiff_tsi[view] = FrameDifference(*prev_tsi)
Beispiel #6
0
    # tsi
    tsi_object = {}
    fdiff_tsi = {}

    # miscelanous
    empty = np.zeros((300, 1000)).astype('uint8')
    random.seed(200)

    for view in VIEW:
        logger.info("-- Start {} view".format(view))

        # frame iterator
        logger.info("-- Crate FrameIterator object")
        fi[view] = FrameIterator(os.path.join(occlusion_clip_path, case, view))
        points = GT['session{}'.format(ses_id)][view]
        corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                           points)

        # 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)
        M_inv[view] = cv2.getPerspectiveTransform(corner_wrap, corner_gt)

        # for epi object
        logger.info("-- Create {} EPI object".format(tot_epi))
        epi_object[view] = []
        for idx in epi_line_idx:
            epi_object[view].append(
                TSIUtil.EPI(
                    M[view],
                    size=(1000, 300),
VP = VPLoader()
ses_id = 0
vp = VP.get_session(ses_id)
fi = FrameIteratorLoader.get_session(ses_id)

M = {}  # matrix homography
imgs_color = {}  # for saving image color each view
fgs = {}
fdiff_view = {}  # frame difference camera image
masks = {}

for view in VIEW:
    img = cv2.imread(img_path.format(ses_id, view), 1)

    points = GT['session{}'.format(ses_id)][view]
    corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                       points)

    # 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
dsts = {}
fgs = {}
fdiff_tsi = {}  # frame difference tsi image
fdiff_view = {}  # frame difference camera image
tsi_object = {}
posision_x_gt = [980, 758, 711]
posision_x_gt = posision_x_gt[::-1]
tsis = {}

for view in VIEW:
    img = cv2.imread(img_path.format(ses_id, view), 1)

    # fi[view] = FrameIterator ('/home/adib/My Git/traffic-monitoring/test/fusion/result/sync_25fps_paper/{}'.format (view))

    points = GT['session{}'.format(ses_id)][view]
    corner = TSIUtil.get_corner_ground(vp[view]['vp1'], vp[view]['vp2'],
                                       points)

    # 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)
    M_inv[view] = cv2.getPerspectiveTransform(corner_wrap, corner_gt)

    # initialize tsi object
    tsi_object[view] = TSIUtil.TSI(M[view], VDL_IDX=0)

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