opencv生成flow

def generate_flow(frame1, frame2, idx):

    frame1 = frame1.astype(np.uint8)
    frame2 = frame2.astype(np.uint8)
    prvs = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
    hsv = np.zeros_like(frame1)
    hsv[..., 1] = 255
    dis = cv2.optflow.createOptFlow_DeepFlow()
    next = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
    flow = dis.calc(prvs, next, None)
    warped = image_warp(frame2, flow)
    return warped

你可能感兴趣的:(opencv,计算机视觉,python)