ESP32 motion
|
Functions | |
uint8_t * | motionComp (const uint8_t *imgI, const MotionVector16_t *motionVect, size_t w, size_t h, size_t mbSize) |
Compute motion compensated image's PSNR . More... | |
Variables | |
int16_t | x |
int16_t | y |
int16_t | vx |
int16_t | vy |
uint16_t | mag2 |
int8_t | vx |
int8_t | vy |
int | mvs [10][2] |
int | nb |
char | name [20] |
uint8_t * | data_cur |
current image More... | |
uint8_t * | data_ref |
prev image More... | |
int | method |
motion estimation method (LK_OPTICAL_FLOW, BLOCK_MATCHING_ARPS, ...) More... | |
int | max |
max motion vector magĀ² More... | |
int | width |
images width More... | |
int | height |
images height More... | |
uint64_t(* | get_cost )(struct MotionEstContext *self, int x_mb, int y_mb, int x_mv, int y_mv) |
pointer to motion estimation function More... | |
bool(* | motion_func )(struct MotionEstContext *self) |
Algorithm methods | |
bool | LK_optical_flow (MotionEstContext *) |
Implement LK optical flow source from wiki and matlab : https://en.wikipedia.org/wiki/Lucas%E2%80%93Kanade_method . More... | |
bool | LK_optical_flow8 (const uint8_t *src1, const uint8_t *src2, uint8_t *v, int w, int h) |
Lucas Kanade optical 8 bit version. More... | |
bool | motionEstARPS (MotionEstContext *) |
Perform Adaptive Rood Pattern Search algorithm. More... | |
bool | motionEstEPZS (MotionEstContext *) |
Enhance Predictive Zonal Search block matching algo. More... | |
Block Matching (EPZS, ARPS) element related | |
b_width | |
blocks width More... | |
b_height | |
blocks height More... | |
b_count | |
nb of blocks More... | |
int | mbSize |
macro block size More... | |
int | log2_mbSize |
log2 of macro block size More... | |
int | search_param |
parameter p in ARPS More... | |
int | pred_x |
median predictor x in Set A More... | |
int | pred_y |
median predictor y in Set A More... | |
MotionEstPredictor | preds [2] |
predictor for EPZS ([1] : Set B, [2] : Set C) More... | |
MotionVector16_t * | mv_table [3] |
motion vectors of current & prev More... | |
bool LK_optical_flow | ( | MotionEstContext * | ) |
Implement LK optical flow source from wiki and matlab : https://en.wikipedia.org/wiki/Lucas%E2%80%93Kanade_method
.
This method is based on Taylor series resolution:
\[ I(x+\Delta x,y+\Delta y,t+\Delta t) = I(x,y,t) + \frac{\partial I}{\partial x}\,\Delta x+\frac{\partial I}{\partial y}\,\Delta y+\frac{\partial I}{\partial t} \, \Delta t+{} \]
Which can be rewritten:
\[ \frac{\partial I}{\partial x}V_x+\frac{\partial I}{\partial y}V_y+\frac{\partial I}{\partial t} = 0 \]
Lucas Kanade reorder this equation as matrix such as:
\[ A = \begin{bmatrix} I_x(q_1) & I_y(q_1) \\[10pt] I_x(q_2) & I_y(q_2) \\[10pt] \vdots & \vdots \\[10pt] I_x(q_n) & I_y(q_n) \end{bmatrix} \quad\quad\quad v = \begin{bmatrix} V_x\\[10pt] V_y \end{bmatrix} \quad\quad\quad b = \begin{bmatrix} -I_t(q_1) \\[10pt] -I_t(q_2) \\[10pt] \vdots \\[10pt] -I_t(q_n) \end{bmatrix} \]
Then the solution can be reduced as : \( A^T A v=A^T b \) or \( \mathrm{v}=(A^T A)^{-1}A^T b \)
me_ctx | Motion estimation context with me_ctx->method = 'LK_OPTICAL_FLOW' |
Lucas Kanade optical 8 bit version.
Same as LK_optical_flow except the output is a uint8 table instead of vector16. Then only the squared magnitude will be saved (no vx, vy) and normalize to [0..255]
[in] | src1 | pointer to grayscale buffer image instant t. |
[in] | src2 | pointer to grayscale buffer image instant t+1. |
[in] | w | width |
[in] | h | height |
[out] | v | image 8bit depth output of squared magnitude |
uint8_t* motionComp | ( | const uint8_t * | imgI, |
const MotionVector16_t * | motionVect, | ||
size_t | w, | ||
size_t | h, | ||
size_t | mbSize | ||
) |
Compute motion compensated image's PSNR
.
\[ \text{PSNR} = 10 \log_{10}\frac {(\text{peak to peak value of original data})^2}{\text{MSE}} \]
imgP | : original image of size w * h |
imgComp | : compensated image of size w * h |
w | : width of image |
h | : height of image |
n | : the peak value of possible of any pixel in the img |
bool motionEstARPS | ( | MotionEstContext * | ) |
Perform Adaptive Rood Pattern Search algorithm.
me_ctx | Motion estimation context with me_ctx->method = 'BLOCK_MATCHING_ARPS' |
bool motionEstEPZS | ( | MotionEstContext * | ) |
Enhance Predictive Zonal Search block matching algo.
Implemented from article DOI: 10.15406/oajs.2017.01.00002
me_search_epzs
function is taken from ffmpeg libavfilter and rearrange accordingly ffmpeg version of EPZS perform better than the one from the paper. The difference is related to the definition of predictors set A,B and C. More details in me_search_eps
note.me_ctx | Motion estimation context with me_ctx->method = 'BLOCK_MATCHING_EPZS' |
b_count |
nb of blocks
b_height |
blocks height
b_width |
blocks width
uint8_t* data_cur |
current image
uint8_t * data_ref |
prev image
uint64_t(* get_cost(struct MotionEstContext *self, int x_mb, int y_mb, int x_mv, int y_mv) |
pointer to motion estimation function
int height |
images height
int log2_mbSize |
log2 of macro block size
uint16_t mag2 |
Squared magnitude $mag2 = vx^2 + vy^2$
int max |
max motion vector magĀ²
int mbSize |
macro block size
int method |
motion estimation method (LK_OPTICAL_FLOW, BLOCK_MATCHING_ARPS, ...)
bool(* motion_func(struct MotionEstContext *self) |
MotionVector16_t* mv_table[3] |
motion vectors of current & prev
int mvs[10][2] |
table of mv predictor
char name[20] |
int nb |
number of predictor added
int pred_x |
median predictor x in Set A
int pred_y |
median predictor y in Set A
MotionEstPredictor preds[2] |
predictor for EPZS ([1] : Set B, [2] : Set C)
int search_param |
parameter p in ARPS
int16_t vx |
guess..
int8_t vx |
guess..
int16_t vy |
guess..
int8_t vy |
guess..
int width |
images width
int16_t x |
int16_t y |