Tutorial

In this tutorial, we will quickly learn the basics of writing your own scripts for the purpose of using the code.

Before starting, you will will need to verify that all the Requirements for the desired version are already installed. First, it is mandatory to create an .py file. The main function that computes the displacement was implemented in compute_flow module and has the same name.

Therefore, we have to specify the path of Compute flow. To do this, it’s mandatory to use sys:

import sys
sys.path.append('Your/Path/Cucim/Src/')
from compute_flow import *

You can use imread function of OpenCV to read the image sequence:

import cv2
Im1 = cv2.imread('im1_path/Im1.extension', 0)
Im2 = cv2.imread('im2_path/Im2.extension', 0)

Note

imread can be used also to read the mask image.

compute_flow function takes as input many parameters as how it was described in Compute flow, it returns \(u\), \(v\) the horizontal and vertical optical flow field respectively. Before computing the displacements many variable must be adjusted.

u, v = compute_flow(Im1, Im2,pyram_levels, factor, ordre_inter,lmbda,
        size_median_filter, max_linear_iter,max_iter, lambda2, lambda3,Mask, LO_filter)