The OpenVX Specification  a73e458
Object: Matrix

Detailed Description

Defines the Matrix Object Interface.

Modules

 The matrix attributes.
 The matrix attributes.
 

Typedefs

typedef struct _vx_matrix * vx_matrix
 The Matrix Object. An MxN matrix of some unit type.
 

Functions

vx_status VX_API_CALL vxCopyMatrix (vx_matrix matrix, void *user_ptr, vx_enum usage, vx_enum user_mem_type)
 Allows the application to copy from/into a matrix object [R01064]. More...
 
vx_matrix VX_API_CALL vxCreateMatrix (vx_context context, vx_enum data_type, vx_size columns, vx_size rows)
 Creates a reference to a matrix object [R01050]. More...
 
vx_matrix VX_API_CALL vxCreateMatrixFromPattern (vx_context context, vx_enum pattern, vx_size columns, vx_size rows)
 Creates a reference to a matrix object from a boolean pattern [R01074]. More...
 
vx_status VX_API_CALL vxQueryMatrix (vx_matrix mat, vx_enum attribute, void *ptr, vx_size size)
 Queries an attribute on the matrix object. More...
 
vx_status VX_API_CALL vxReleaseMatrix (vx_matrix *mat)
 Releases a reference to a matrix object [R01056]. The object may not be garbage collected until its total reference count is zero. More...
 

Function Documentation

◆ vxCreateMatrix()

vx_matrix VX_API_CALL vxCreateMatrix ( vx_context  context,
vx_enum  data_type,
vx_size  columns,
vx_size  rows 
)

Creates a reference to a matrix object [R01050].

Parameters
[in]contextThe reference to the overall context [R01051].
[in]data_typeThe unit format of the matrix: VX_TYPE_UINT8 or VX_TYPE_INT32 or VX_TYPE_FLOAT32 [R01052].
[in]columnsThe first dimensionality [R01053].
[in]rowsThe second dimensionality [R01054].
Returns
An matrix reference vx_matrix. Any possible errors preventing a successful creation should be checked using vxGetStatus [R01055].

◆ vxReleaseMatrix()

vx_status VX_API_CALL vxReleaseMatrix ( vx_matrix mat)

Releases a reference to a matrix object [R01056]. The object may not be garbage collected until its total reference count is zero.

Parameters
[in]matThe matrix reference to release [R01057].
Postcondition
After returning from this function the reference is zeroed.
Returns
A The vx_status Constants value.
Return values
VX_SUCCESSNo errors; any other value indicates failure [R01058].
VX_ERROR_INVALID_REFERENCEmat is not a valid vx_matrix reference.

◆ vxQueryMatrix()

vx_status VX_API_CALL vxQueryMatrix ( vx_matrix  mat,
vx_enum  attribute,
void *  ptr,
vx_size  size 
)

Queries an attribute on the matrix object.

Parameters
[in]matThe matrix object to set [R01059].
[in]attributeThe attribute to query. Use a The matrix attributes. value [R01060].
[out]ptrThe location at which to store the resulting value [R01061].
[in]sizeThe size in bytes of the container to which ptr points [R01062].
Returns
A The vx_status Constants value.
Return values
VX_SUCCESSNo errors; any other value indicates failure [R01063].
VX_ERROR_INVALID_REFERENCEmat is not a valid vx_matrix reference.

◆ vxCopyMatrix()

vx_status VX_API_CALL vxCopyMatrix ( vx_matrix  matrix,
void *  user_ptr,
vx_enum  usage,
vx_enum  user_mem_type 
)

Allows the application to copy from/into a matrix object [R01064].

Parameters
[in]matrixThe reference to the matrix object that is the source or the destination of the copy [R01065].
[in]user_ptrThe address of the memory location where to store the requested data if the copy was requested in read mode, or from where to get the data to store into the matrix object if the copy was requested in write mode [R01066]. In the user memory, the matrix is structured as a row-major 2D array with elements of the type corresponding to VX_MATRIX_TYPE, with a number of rows corresponding to VX_MATRIX_ROWS and a number of columns corresponding to VX_MATRIX_COLUMNS [R01067]. The accessible memory must be large enough to contain this 2D array: accessible memory in bytes >= sizeof(data_element) * rows * columns [R01068].
[in]usageThis declares the effect of the copy with regard to the matrix object using the The memory accessor hint flags. value. Only VX_READ_ONLY and VX_WRITE_ONLY are supported [R01069]:
  • VX_READ_ONLY means that data are copied from the matrix object into the user memory [R01070].
  • VX_WRITE_ONLY means that data are copied into the matrix object from the user memory [R01071].
[in]user_mem_typeA Memory import type constants. value that specifies the memory type of the memory referenced by the user_addr [R01072].
Returns
A The vx_status Constants value.
Return values
VX_SUCCESSNo errors; any other value indicates failure [R01073].
VX_ERROR_INVALID_REFERENCEmatrix is not a valid vx_matrix reference.
VX_ERROR_INVALID_PARAMETERSAn other parameter is incorrect.

◆ vxCreateMatrixFromPattern()

vx_matrix VX_API_CALL vxCreateMatrixFromPattern ( vx_context  context,
vx_enum  pattern,
vx_size  columns,
vx_size  rows 
)

Creates a reference to a matrix object from a boolean pattern [R01074].

The matrix created by this function is of type vx_uint8, with the value 0 representing False, and the value 255 representing True [R01075]. It supports patterns described below. See Matrix patterns.

  • VX_PATTERN_BOX is a matrix with dimensions equal to the given number of rows and columns, and all cells equal to 255 [R01076]. Dimensions of 3x3 and 5x5 must be supported [R01077].
  • VX_PATTERN_CROSS is a matrix with dimensions equal to the given number of rows and columns, which both must be odd numbers [R01078]. All cells in the center row and center column are equal to 255, and the rest are equal to zero [R01079]. Dimensions of 3x3 and 5x5 must be supported [R01080].
  • VX_PATTERN_DISK is an RxC matrix, where R and C are odd and cell (c, r) is 255 if:
    (r-R/2 + 0.5)^2 / (R/2)^2 + (c-C/2 + 0.5)^2/(C/2)^2 is less than or equal to 1,
    and 0 otherwise [R01081].
  • VX_PATTERN_OTHER is any other pattern than the above (matrix created is still binary, with a value of 0 or 255) [R01082].

If the matrix was created via vxCreateMatrixFromPattern, this attribute must be set to the appropriate pattern enum. Otherwise the attribute must be set to VX_PATTERN_OTHER. The vx_matrix objects returned by this function are read-only [R01083]. The behavior when attempting to modify such a matrix is implementation-dependent.

Parameters
[in]contextThe reference to the overall context [R01084].
[in]patternThe pattern of the matrix. See VX_MATRIX_PATTERN [R01085].
[in]columnsThe first dimensionality [R01086].
[in]rowsThe second dimensionality [R01087].
Returns
A matrix reference vx_matrix of type vx_uint8 [R01088]. Any possible errors preventing a successful creation should be checked using vxGetStatus [R01089].