API Reference >> skvideo.motion.blockComp
Fork me on GitHub

skvideo.motion.blockComp

skvideo.motion.blockComp(videodata, motionVect, mbSize=8)[source]

Block-based motion compensation

Using the given motion vectors, this function returns the motion-compensated video data.

Parameters:
videodatandarray

an input frame sequence, shape (T, M, N, C), (T, M, N), (M, N, C) or (M, N)

motionVectndarray

ndarray representing block motion vectors. Expects ndarray, shape (T-1, M/mbSize, N/mbSize) or (M/mbSize, N/mbSize).

mbSizeint

Size of macroblock in pixels.

Returns:
compImgndarray

ndarray holding the motion compensated frames, shape (T, M, N, C) and dtype float64. A single input frame returns shape (1, M, N, C).

Notes

motionVect’s grid must match the macroblock grid (M // mbSize by N // mbSize); a mismatch raises ValueError. When M or N is not a multiple of mbSize, the uncovered bottom/right border is copied through from the input frame unchanged (it cannot be motion-compensated). A motion vector that points outside the frame leaves that block as the original (uncompensated) pixels.