## 2 Materials and Methods
### The Overview of the Applied Optical Flow Methods
The Farneback (F) method assumes the generation of an image pyramid in which each level has a lower resolution compared to the previous level. Selecting a pyramid level greater than \(1\), the algorithm can track points at multiple levels of resolution, starting from the lowest level. An increase in the number of levels in the pyramid allows the algorithm to detect larger displacements of points between frames, however, increasing the number of necessary computations in this case. This is an example of a dense method that operates in the HSV color space (after the conversion from RGB). The flow vectors are also visualizedin the HSV space, where the angle (hue) corresponds to the direction of the vector and the magnitude of the flow represented by the length of the vector is reflected by the value (V) component. Motion tracking starts at the lowest resolution level and continues until the convergence is achieved. Point locations detected at this level are propagated as key points for the next level. Therefore, the Farneback method makes it possible to increase the tracking accuracy at each successive level. The decomposition of the pyramid enables the algorithm to detect large pixel movements for distances greater than the size of the neighborhood under consideration. The default number of levels in the pyramid is 3 with the scale factor 0.5 (split into 4 parts). By default, three iterations of the solution search are performed for each level with the default neighborhood area of 5 pixels. The convolutional Gaussian filter with the default \(15\times 15\) pixels mask is used as the averaging (smoothing) filter. The most popular Lucas-Kanade (LK) method belongs to the group of sparse methods; hence, full calculations are performed only for selected points of the image. In this method, the image is divided into fragments in which a constant flow velocity is assumed. To find a solution, a weighted least-squares fit of the optical flow limitation equation to the constant model \([u\ v]^{T}\) for each \(\Omega\) section is performed by minimizing the expression:  
\[\sum_{x\in\Omega}W^{2}\big{(}I_{x}u+I_{y}v+I_{t}\big{)}^{2} \tag{5}\]  
where \(W\) denotes a centrally weighted window function. The solution has the following form:  
\[\left[ \begin{array}{cc}\sum\left(W^{2}I_{x}^{2}\right)&\sum\left(W^{2}I_{x }I_{y}\right)\\ \sum\left(W^{2}I_{x}I_{y}\right)&\sum\left(W^{2}I_{y}^{2}\right)\end{array}  \right]\cdot\left[ \begin{array}{c}u\\ v\end{array} \right]=-\left[ \begin{array}{c}\sum\left(W^{2}I_{x}I_{t}\right) \\ \sum\left(W^{2}I_{y}I_{t}\right)\end{array} \right]\,. \tag{6}\]  
Similarly to in the HS method, the \(I_{t}\) value is determined between video frames using the \([-1\ 1]\) mask. To determine the values of flows \(u\) and \(v\), the following actions are performed:  
* Determining the values of the directional gradients \(I_{x}\) and \(I_{y}\) using the convolutional filter with the mask \([-1/12\ 2/3\ 0\ -2/3\ 1/12]\) and its transposed version, respectively;
* Calculation of the differential \(I_{t}\) value between the frames;
* Smoothing the gradients \(I_{x}\ I_{y}\) and \(I_{t}\) using the \(5\times 5\) pixels convolutional filter with the mask type \([1/16\ \ 1/4\ \ 3/8\ \ 1/4\ \ 1/16]\);
* Solving the system of two linear equations for each pixel: \[A=\left[ \begin{array}{cc}a&b\\ c&d\end{array} \right]=\left[ \begin{array}{cc}\sum\left(W^{2}I_{x}^{2} \right)&\sum\left(W^{2}I_{x}I_{y}\right)\\ \sum\left(W^{2}I_{x}I_{y}\right)&\sum\left(W^{2}I_{y}^{2}\right)\end{array} \right]\] (7)  
using the eigenvalues of the matrix \(A\) determined as \(\lambda_{1}=\frac{a+c}{2}+\frac{\sqrt{4b^{2}+(a-c)^{2}}}{2}\) and \(\lambda_{2}=\frac{a+c}{2}-\frac{\sqrt{4b^{2}+(a-c)^{2}}}{2}\). Both those values are compared to the threshold \(\tau\) applied for the reduction in the noise effect. If at least the threshold value \(\tau\) is obtained by both eigenvalues, the system of equations can be solved by [PERSON]'s method.