OpenCV Python中视频帧的线性插值

时间:2017-07-19 15:40:06

标签: python opencv interpolation blending

我试图实现所谓的重影效果'从用于在OpenCV,Python中插入帧的LFI方法。

但是,输出似乎不会产生结果。我使用OpenCV的混合函数来计算它们之间的帧。

以下是代码:

from __future__ import division

import numpy as np
import cv2


cap = cv2.VideoCapture('test_vid.avi')

starting = True
prev_frame = np.uint8([250])

while(True):

    # Capture frame-by-frame
    ret, frame = cap.read()

    if starting==True:
        prev_frame = frame
        starting = False
    else:
        for i in range(1,10):
            weight = i/10
            #get the blended frames in between
            mid_frame = cv2.addWeighted(prev_frame,weight,frame,1-weight,0)     
            cv2.imshow('frame2',mid_frame)

        #cv2.imshow('frame',frame)     
        prev_frame = frame

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

结果似乎与当前帧的帧相同(没有任何实际混合的迹象)

0 个答案:

没有答案