## 2 Materials and Methods
### Optical Flow Detection and Regression Modeling
#### 2.2.1 Pyramid L-K Optical Flow Feature Extraction
In the gas-liquid flow data acquisition setup, a 3-layer pyramid structure was employed, with the top layer (L = 3) having an image size of 240 \(\times\) 135 pixels, derived from the original image size of 1920 \(\times\) 1080 p. Optical flow calculations were conducted using the top-layer image, and the results were then enlarged by a factor of two to use as initial optical flow estimates for calculations in the lower layers. \[g^{L-1}=2(g^{L}+d^{L}) \tag{5}\]  
where \(L\) is the pyramid layer number, \(g\) is the initial optical flow estimate, and \(d\) is the calculated optical flow. The optical flow \(d^{0}\) of the original image is obtained through iteration, during which the sum of pixel-matching errors within the window used is calculated and minimized to compute the optical flow. This process can be mathematically expressed as follows:  
\[\varepsilon(v)=\varepsilon(dx,dy)=\sum\
olimits_{u_{x}-u_{y}}^{u_{x}+u_{y}} \sum\
olimits_{u_{y}-u_{y}}^{u_{y}+u_{y}}\left[I(x,y)-I(x+dx,y+dy)\right] \tag{6}\]  
where \(\varepsilon\) is the grayscale change within the window, \(u_{x}\) and \(u_{y}\) represent the coordinates of the tracked point, \(w_{x}\) and \(w_{y}\) are the neighborhood window, and \(v\) is the optical flow. The derivation of the above equation involves setting the derivative at the optimal solution to zero. This can be achieved by performing a first-order Taylor expansion and neglecting the high-order terms. \[\frac{1}{2}\frac{\partial\varepsilon(d)}{\partial d}=\sum\
olimits_{x=u_{x}- w_{x}}^{u_{x}+u_{x}}\sum\
olimits_{y=u_{y}-u_{y}}^{u_{y}+u_{y}}\left[ \begin{array}{c}{f_{x}}^{2},{f_{y}}{f_{y}}\\ {f_{x}}{f_{y}},{f_{y}}^{2}\end{array} \right]v-\sum\
olimits_{x=u_{x}  
\[v=G^{-1}b \tag{8}\]  
where \(v\) is the optical flow. In this process, the image \(J\) is shifted by the previously calculated optical flow v distance to form a new window. The optical flow is then iteratively computed. A threshold of 0.01 is set for iteration, and the maximum number of iterations is set to 150. The optical flow obtained after \(k\) iterations is denoted as \(\eta_{k}\). \[v_{k}=v_{k-1}+\eta_{k} \tag{9}\]  
where \(v_{k}\) is the optical flow obtained from the \(k\)th iteration, \(v_{k-1}\) is the optical flow obtained from the \((k-1)\)th iteration, \(\eta_{k}\) is the optical flow obtained from the current calculation. The data obtained from the optical flow acquisition of 187 gas-liquid two-phase flow videos using the pyramid L-K optical flow method were considerable. To simplify the calculations, one gas-liquid two-phase flow video was randomly selected for analysis in this section. The first 30 frames of this video were utilized for optical flow computation, and corner points exhibiting minimal movement were extracted with a threshold set to 100. Subsequently, a significant number of displacements of corner points from the optical flow were obtained from the experiment. For each corner point, the initial position obtained from the optical flow algorithm in this video was recorded, along with the position of optical flow computation, the displacement \(d_{i}\), and the displacement components \(d_{\mathrm{ix}}\) and \(d_{\mathrm{iy}}\) in the \(x\) and \(y\) directions, respectively, were computed using the following equations:  
\[d_{ix}=x_{i2}-x_{i1} \tag{10}\]  
\[d_{iy}=y_{i2}-y_{i1} \tag{11}\]  
\[d_{i}=\sqrt{{d_{ix}}^{2}-{d_{iy}}^{2}} \tag{12}\]  
where \(x_{i1}\) represents the position of the current \(i\)-th corner point in the previous frame; \(x_{i2}\) represents the position of the current \(i\)-th corner point in the next frame; \(d_{ix}\) represents the displacement of the current \(i\)-th corner point in the \(x\)-direction, measured in pixels; \(d_{iy}\) represents the displacement of the current \(i\)-th corner point in the \(y\)-direction, measured in pixels; \(d_{i}\) represents the magnitude of the optical flow for the current \(i\)-th corner point, measured in pixels.