VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IME : Create Motion Field

Detailed Description

Creates initial motion field from a current image into reference image.

This function calculates a sum-of-absolute-difference (SAD) value for each block position inside a search window and using a cost formulation, it picks the best two motion vectors to represent the displacement of the specified block into the reference image.

In addition to the motion vectors, this primitive also stores calculated SAD values for all \( B \times B \) pixel positions in the search window into a table; the values in the table then can be looked up instead of recomputed in refinement steps of the Iterative Motion Estimation algorithm.

For each \( B \times B \) block on the reference image, the primitive checks all pixels in \( SW \times SH \) search window on current image and calculates the cost value ( \( MV \) - motion vector between the \( B \times B \) block and current position in search window):

\[ cost(MV) = SAD(MV) + biasWeight * dist(MV, bias) \]

create_motion_field_cost.png

Then finds best motion vectors with minimum cost value in each subregions \( (0), (1,2), (3), (4, 8), (5, 6, 9, 10), (7, 11), (12), (13, 14), (15) \) of the search window:

create_motion_field_regions.png

Finally, selects two best motion vectors from different subregions, so that

\[ dist(MV0, MV1) >= mvDivFactor \]

Functions

vx_node nvxCreateMotionFieldNode (vx_graph graph, vx_image ref_image, vx_image cur_image, vx_image anchor, vx_image bias, vx_image best_mv0, vx_image best_mv1, vx_image sad_table, vx_int32 blockSize, vx_int32 searchWindowWidth, vx_int32 searchWindowHeight, vx_float32 biasWeight, vx_int32 mvDivFactor)
 [Graph] Creates initial motion field from a current image into reference image. More...
 
vx_status nvxuCreateMotionField (vx_context context, vx_image ref_image, vx_image cur_image, vx_image anchor, vx_image bias, vx_image best_mv0, vx_image best_mv1, vx_image sad_table, vx_int32 blockSize, vx_int32 searchWindowWidth, vx_int32 searchWindowHeight, vx_float32 biasWeight, vx_int32 mvDivFactor)
 [Immediate] Creates initial motion field from a current image into reference image. More...
 

Function Documentation

vx_node nvxCreateMotionFieldNode ( vx_graph  graph,
vx_image  ref_image,
vx_image  cur_image,
vx_image  anchor,
vx_image  bias,
vx_image  best_mv0,
vx_image  best_mv1,
vx_image  sad_table,
vx_int32  blockSize,
vx_int32  searchWindowWidth,
vx_int32  searchWindowHeight,
vx_float32  biasWeight,
vx_int32  mvDivFactor 
)

[Graph] Creates initial motion field from a current image into reference image.

Parameters
[in]graphSpecifies the graph.
[in]ref_imageSpecifies the reference image (8-bit grayscale).
[in]cur_imageSpecifies the current image (8-bit grayscale). It must have the same size as ref_image.
[in]anchorSpecifies the optional anchor field. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. For each \( B \times B \) block on ref_image the anchor image contains an offset of search window on cur_image in Q14.2 format (NVX_DF_IMAGE_2S16). If the anchor parameter is missed, it is assumed that the offset is zero for all blocks.
[in]biasSpecifies the optional bias field. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. For each \( B \times B \) block on ref_image the bias image contains a bias vector for cost calculation in Q14.2 format (NVX_DF_IMAGE_2S16). If the bias parameter is missed, it is assumed that the bias vector is zero for all blocks.
[out]best_mv0Specifies the output image of the best motion vectors. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. The motion vectors will be stored in Q14.2 format (NVX_DF_IMAGE_2S16). Can be NULL if the primitive is used for SAD table calculation only.
[out]best_mv1Specifies the output image of the second best motion vectors. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. The motion vectors will be stored in Q14.2 format (NVX_DF_IMAGE_2S16). Can be NULL if the primitive is used for SAD table calculation only.
[out]sad_tableSpecifies the optional output image with SAD table. It must have \( [W / B * SW * SH, H / B] \) size, where \( W \times H \) - ref_image size, \( SW \times SH \) - search window size, and \( B \) - block size. For each \( B \times B \) block on ref_image and for each position in search window the sad_table image contains SAD (sum of absolute diferences) value for corresponding blocks in U32 format (VX_DF_IMAGE_U32). The values are stored contiguously, i.e., first \( SW * SH \) values corresponds to the first block. Search window is treated in row major order started from top left corner.
[in]blockSizeSpecifies the block size.
[in]searchWindowWidthSpecifies the search window width.
[in]searchWindowHeightSpecifies the search window height. Supported search window sizes: 16x16, 32x32, 64x64, 64x32, 32x16 and 48x32.
[in]biasWeightSpecifies the weight of bias term in cost formula.
[in]mvDivFactorSpecifies the best motion vectors diversity factor.
Returns
A valid node reference or an error object (use vxGetStatus).
vx_status nvxuCreateMotionField ( vx_context  context,
vx_image  ref_image,
vx_image  cur_image,
vx_image  anchor,
vx_image  bias,
vx_image  best_mv0,
vx_image  best_mv1,
vx_image  sad_table,
vx_int32  blockSize,
vx_int32  searchWindowWidth,
vx_int32  searchWindowHeight,
vx_float32  biasWeight,
vx_int32  mvDivFactor 
)

[Immediate] Creates initial motion field from a current image into reference image.

Parameters
[in]contextSpecifies the context.
[in]ref_imageSpecifies the reference image (8-bit grayscale).
[in]cur_imageSpecifies the current image (8-bit grayscale). It must have the same size as ref_image.
[in]anchorSpecifies the optional anchor field. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. For each \( B \times B \) block on ref_image the anchor image contains an offset of search window on cur_image in Q14.2 format (NVX_DF_IMAGE_2S16). If the anchor parameter is missed, it is assumed that the offset is zero for all blocks.
[in]biasSpecifies the optional bias field. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. For each \( B \times B \) block on ref_image the bias image contains a bias vector for cost calculation in Q14.2 format (NVX_DF_IMAGE_2S16). If the bias parameter is missed, it is assumed that the bias vector is zero for all blocks.
[out]best_mv0Specifies the output image of the best motion vectors. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. The motion vectors will be stored in Q14.2 format (NVX_DF_IMAGE_2S16). Can be NULL if the primitive is used for SAD table calculation only.
[out]best_mv1Specifies the output image of the second best motion vectors. It must have \( [W / B, H / B] \) size, where \( W \times H \) - ref_image size and \( B \) - block size. The motion vectors will be stored in Q14.2 format (NVX_DF_IMAGE_2S16). Can be NULL if the primitive is used for SAD table calculation only.
[out]sad_tableSpecifies the optional output image with SAD table. It must have \( [W / B * SW * SH, H / B] \) size, where \( W \times H \) - ref_image size, \( SW \times SH \) - search window size, and \( B \) - block size. For each \( B \times B \) block on ref_image and for each position in search window the sad_table image contains SAD (sum of absolute diferences) value for corresponding blocks in U32 format (VX_DF_IMAGE_U32). The values are stored contiguously, i.e., first \( SW * SH \) values corresponds to the first block. Search window is treated in row major order started from top left corner.
[in]blockSizeSpecifies the block size.
[in]searchWindowWidthSpecifies the search window width.
[in]searchWindowHeightSpecifies the search window height. Supported search window sizes: 16x16, 32x32, 64x64, 64x32, 32x16 and 48x32.
[in]biasWeightSpecifies the weight of bias term in cost formula.
[in]mvDivFactorSpecifies the best motion vectors diversity factor.
Returns
A vx_status enumerator.
Return values
VX_SUCCESSNo errors.
VX_ERROR_INVALID_REFERENCESupplied parameters are not a valid reference.
VX_ERROR_INVALID_PARAMETERSSupplied parameters are not valid.
VX_ERROR_INVALID_SCOPESupplied parameters are virtual objects that cannot be used in immediate mode.
VX_FAILUREInternal error in primitive implementation, check log for detailed information (Framework: Log).