5.3.4.11. Function _motion_compute¶
Defined in File motion_compute.h
5.3.4.11.1. Function Documentation¶
-
void _motion_compute(const float *RoIs0_x, const float *RoIs0_y, const float *RoIs1_x, const float *RoIs1_y, float *RoIs1_dx, float *RoIs1_dy, float *RoIs1_error, const uint32_t *RoIs1_prev_id, uint8_t *RoIs1_is_moving, const size_t n_RoIs1, motion_t *motion_est1, motion_t *motion_est2)¶
Compute the global motion estimation and, after global motion compensation, compute the movement of each RoI. In order to compute the motion estimation, the translation vector \((Tx, Ty)\) and the angle of rotation \(\theta\) must be calculated as follows:
\[ \theta = \tan^{-1}\left(\frac{ \sum_{i=1}^N [(y_i'-\bar{y})(x_i-\bar{x}) - (x_i'-\bar{x})(y_i-\bar{y})]}{\sum_{i=1}^N[(x_i'-\bar{x})(x_i-\bar{x}) + (y_i'-\bar{y})(y_i-\bar{y})]} \right), \]\[\begin{split} T = \begin{bmatrix} T_x \\ T_y \\ \end{bmatrix} = \begin{bmatrix} x' - x \cdot cos(\theta) + y \cdot sin(\theta)\\ y' - x \cdot sin(\theta) - y \cdot cos(\theta) \end{bmatrix}, \end{split}\]where \(N\) is the number of RoIs, \((x,y)\) and \((x',y')\) are the centroids of RoIs at \(t -1\) and \(t\), respectively, and\[ \bar{x} = \sum_{i=1}^N x_i ~~~~~ \bar{y} = \sum_{i=1}^N y_i ~~~~~ \bar{x}' = \sum_{i=1}^N x'_i ~~~~~ \bar{y}' = \sum_{i=1}^N y'_i . \]For the first global motion estimation, all the associated RoIs are considered. For the second global motion estimation, only the RoIs considered as “not moving” are considered. To be considered in movement the motion norm of the RoI has to be higher that de motion standard deviation.- Parameters
RoIs0_x – Array of centroids abscissa (at \(t -1\)).
RoIs0_y – Array of centroids ordinate (at \(t -1\)).
RoIs1_x – Array of centroids abscissa (at \(t\)).
RoIs1_y – Array of centroids abscissa (at \(t\)).
RoIs1_dx – Array of \(x\) components of the distance between centroids at \(t - 1\) and \(t\).
RoIs1_dy – Array of \(y\) components of the distance between centroids at \(t - 1\) and \(t\).
RoIs1_error – Array of velocity norms (if
is_moving== 1) or errors (ifis_moving== 0).RoIs1_prev_id – Array of previous corresponding RoI identifiers ( \(RoI_{t - 1} \leftrightarrow RoI_{t}\)).
RoIs1_is_moving – Array of booleans that defines if the RoI is moving (
is_moving== 1) or not (is_moving== 0).n_RoIs1 – Number of connected-components (= number of RoIs) (at \(t\)).
motion_est1 – First global motion estimation.
motion_est2 – Second global motion estimation.