tool/video_completion.py
def extrapolation(args, video_ori, corrFlowF_ori, corrFlowB_ori, corrFlowNLF_ori, corrFlowNLB_ori):
    """Prepares the data for video extrapolation.
    """
    imgH, imgW, _, nFrame = video_ori.shape

    # Defines new FOV.
    imgH_extr = int(args.H_scale * imgH)
    imgW_extr = int(args.W_scale * imgW)
    H_start = int((imgH_extr - imgH) / 2)
    W_start = int((imgW_extr - imgW) / 2)

    # Generates the mask for missing region.
    flow_mask = np.ones(((imgH_extr, imgW_extr)), dtype=bool)
    flow_mask[H_start : H_start + imgH, W_start : W_start + imgW] = 0

    mask_dilated = gradient_mask(flow_mask)

    # Extrapolates the FOV for video.
    video = np.zeros(((imgH_extr, imgW_extr, 3, nFrame)), dtype=np.float32)
    video[H_start : H_start + imgH, W_start : W_start + imgW, :, :] = video_ori

    for i in range(nFrame):
        print("Preparing frame {0}".format(i), '\r', end='')
        video[:, :, :, i] = cv2.inpaint((video[:, :, :, i] * 255).astype(np.uint8), flow_mask.astype(np.uint8), 3, cv2.INPAINT_TELEA).astype(np.float32)  / 255.

    # Extrapolates the FOV for flow.
    corrFlowF = np.zeros(((imgH_extr, imgW_extr, 2, nFrame - 1)), dtype=np.float32)
    corrFlowB = np.zeros(((imgH_extr, imgW_extr, 2, nFrame - 1)), dtype=np.float32)

    corrFlowF[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowF_ori
    corrFlowB[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowB_ori

    if args.Nonlocal:
        corrFlowNLF = np.zeros(((imgH_extr, imgW_extr, 2, 3, nFrame)), dtype=np.float32)
        corrFlowNLB = np.zeros(((imgH_extr, imgW_extr, 2, 3, nFrame)), dtype=np.float32)

        corrFlowNLF[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowNLF_ori
        corrFlowNLB[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowNLB_ori
    else:
        corrFlowNLF = None
        corrFlowNLB = None

    return video, corrFlowF, corrFlowB, corrFlowNLF, corrFlowNLB, flow_mask, mask_dilated, (W_start, H_start), (W_start + imgW, H_start + imgH)
Prepares the data for video extrapolation.
    
Prepares the data for video extrapolation.
Prepares the data for video extrapolation .
def extrapolation(args, video_ori, corrFlowF_ori, corrFlowB_ori, corrFlowNLF_ori, corrFlowNLB_ori):
    imgH, imgW, _, nFrame = video_ori.shape
    imgH_extr = int(args.H_scale * imgH)
    imgW_extr = int(args.W_scale * imgW)
    H_start = int((imgH_extr - imgH) / 2)
    W_start = int((imgW_extr - imgW) / 2)
    flow_mask = np.ones(((imgH_extr, imgW_extr)), dtype=bool)
    flow_mask[H_start : H_start + imgH, W_start : W_start + imgW] = 0
    mask_dilated = gradient_mask(flow_mask)
    video = np.zeros(((imgH_extr, imgW_extr, 3, nFrame)), dtype=np.float32)
    video[H_start : H_start + imgH, W_start : W_start + imgW, :, :] = video_ori
    for i in range(nFrame):
        print("Preparing frame {0}".format(i), '\r', end='')
        video[:, :, :, i] = cv2.inpaint((video[:, :, :, i] * 255).astype(np.uint8), flow_mask.astype(np.uint8), 3, cv2.INPAINT_TELEA).astype(np.float32)  / 255.
    corrFlowF = np.zeros(((imgH_extr, imgW_extr, 2, nFrame - 1)), dtype=np.float32)
    corrFlowB = np.zeros(((imgH_extr, imgW_extr, 2, nFrame - 1)), dtype=np.float32)
    corrFlowF[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowF_ori
    corrFlowB[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowB_ori
    if args.Nonlocal:
        corrFlowNLF = np.zeros(((imgH_extr, imgW_extr, 2, 3, nFrame)), dtype=np.float32)
        corrFlowNLB = np.zeros(((imgH_extr, imgW_extr, 2, 3, nFrame)), dtype=np.float32)
        corrFlowNLF[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowNLF_ori
        corrFlowNLB[H_start : H_start + imgH, W_start : W_start + imgW] = corrFlowNLB_ori
    else:
        corrFlowNLF = None
        corrFlowNLB = None
    return video, corrFlowF, corrFlowB, corrFlowNLF, corrFlowNLB, flow_mask, mask_dilated, (W_start, H_start), (W_start + imgW, H_start + imgH)
def extrapolation ( args , video_ori , corrFlowF_ori , corrFlowB_ori , corrFlowNLF_ori , corrFlowNLB_ori ) : imgH , imgW , _ , nFrame = video_ori . shape imgH_extr = int ( args . H_scale * imgH ) imgW_extr = int ( args . W_scale * imgW ) H_start = int ( ( imgH_extr - imgH ) / 2 ) W_start = int ( ( imgW_extr - imgW ) / 2 ) flow_mask = np . ones ( ( ( imgH_extr , imgW_extr ) ) , dtype = bool ) flow_mask [ H_start : H_start + imgH , W_start : W_start + imgW ] = 0 mask_dilated = gradient_mask ( flow_mask ) video = np . zeros ( ( ( imgH_extr , imgW_extr , 3 , nFrame ) ) , dtype = np . float32 ) video [ H_start : H_start + imgH , W_start : W_start + imgW , : , : ] = video_ori for i in range ( nFrame ) : print ( "Preparing frame {0}" . format ( i ) , '\r' , end = '' ) video [ : , : , : , i ] = cv2 . inpaint ( ( video [ : , : , : , i ] * 255 ) . astype ( np . uint8 ) , flow_mask . astype ( np . uint8 ) , 3 , cv2 . INPAINT_TELEA ) . astype ( np . float32 ) / 255. corrFlowF = np . zeros ( ( ( imgH_extr , imgW_extr , 2 , nFrame - 1 ) ) , dtype = np . float32 ) corrFlowB = np . zeros ( ( ( imgH_extr , imgW_extr , 2 , nFrame - 1 ) ) , dtype = np . float32 ) corrFlowF [ H_start : H_start + imgH , W_start : W_start + imgW ] = corrFlowF_ori corrFlowB [ H_start : H_start + imgH , W_start : W_start + imgW ] = corrFlowB_ori if args . Nonlocal : corrFlowNLF = np . zeros ( ( ( imgH_extr , imgW_extr , 2 , 3 , nFrame ) ) , dtype = np . float32 ) corrFlowNLB = np . zeros ( ( ( imgH_extr , imgW_extr , 2 , 3 , nFrame ) ) , dtype = np . float32 ) corrFlowNLF [ H_start : H_start + imgH , W_start : W_start + imgW ] = corrFlowNLF_ori corrFlowNLB [ H_start : H_start + imgH , W_start : W_start + imgW ] = corrFlowNLB_ori else : corrFlowNLF = None corrFlowNLB = None return video , corrFlowF , corrFlowB , corrFlowNLF , corrFlowNLB , flow_mask , mask_dilated , ( W_start , H_start ) , ( W_start + imgW , H_start + imgH )
Prepares the data for video extrapolation.
Prepares the data for video extrapolation .
"""Prepares the data for video extrapolation.
    """ # Defines new FOV. # Generates the mask for missing region. # Extrapolates the FOV for video. # Extrapolates the FOV for flow.
args
video_ori
corrFlowF_ori
corrFlowB_ori
corrFlowNLF_ori
corrFlowNLB_ori