Ask Your Question

Revision history [back]

Yes, you're right, here's a version that works in 4.1

import cv2

if __name__ == '__main__':

    print('cv2 version: {}'.format(cv2.__version__))

    img1 = cv2.imread('test_1.png')
    img2 = cv2.imread('test_2.png')

    gray1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
    gray2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)

    # 3.4.4.19
    #inst = cv2.optflow.createOptFlow_DIS(cv2.optflow.DISOPTICAL_FLOW_PRESET_MEDIUM)

    # 4.1
    inst = cv2.DISOpticalFlow_create(cv2.DISOPTICAL_FLOW_PRESET_MEDIUM)

    flow = inst.calc(gray1, gray2, None)