The OpenVX Specification  dba1aa3
Object: Matrix

## Detailed Description

Defines the Matrix Object Interface.

## Typedefs

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

## Enumerations

enum  vx_matrix_attribute_e {
VX_MATRIX_TYPE = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x0,
VX_MATRIX_ROWS = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x1,
VX_MATRIX_COLUMNS = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x2,
VX_MATRIX_SIZE = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x3,
VX_MATRIX_ORIGIN = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x4,
VX_MATRIX_PATTERN = ((( VX_ID_KHRONOS ) << 20) | ( VX_TYPE_MATRIX << 8)) + 0x5
}
The matrix attributes. More...

## 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. More...

vx_matrix VX_API_CALL vxCreateMatrix (vx_context c, vx_enum data_type, vx_size columns, vx_size rows)
Creates a reference to a matrix object. 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. More...

vx_matrix VX_API_CALL vxCreateMatrixFromPatternAndOrigin (vx_context context, vx_enum pattern, vx_size columns, vx_size rows, vx_size origin_col, vx_size origin_row)
Creates a reference to a matrix object from a boolean pattern, with a user-specified origin. More...

vx_matrix VX_API_CALL vxCreateVirtualMatrix (vx_graph graph, vx_enum data_type, vx_size columns, vx_size rows)
Creates an opaque reference to a matrix object without direct user access. 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. The object may not be garbage collected until its total reference count is zero. More...

## Enumeration Type Documentation

The matrix attributes.

Enumerator
VX_MATRIX_TYPE

The value type of the matrix. Read-only. Use a vx_enum parameter.

VX_MATRIX_ROWS

The M dimension of the matrix. Read-only. Use a vx_size parameter.

VX_MATRIX_COLUMNS

The N dimension of the matrix. Read-only. Use a vx_size parameter.

VX_MATRIX_SIZE

The total size of the matrix in bytes. Read-only. Use a vx_size parameter.

VX_MATRIX_ORIGIN

The origin of the matrix with a default value of [floor(VX_MATRIX_COLUMNS/2), floor(VX_MATRIX_ROWS/2)]. Read-only. Use a vx_coordinates2d_t parameter.

VX_MATRIX_PATTERN

The pattern of the matrix. See vx_pattern_e . Read-only. Use a vx_enum parameter. If the matrix was created via vxCreateMatrixFromPattern or vxCreateMatrixFromPatternAndOrigin, the attribute corresponds to the given pattern. Otherwise the attribute is VX_PATTERN_OTHER.

Definition at line 1075 of file vx_types.h.

## Function Documentation

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

Creates a reference to a matrix object.

Parameters
 [in] c The reference to the overall context. [in] data_type The unit format of the matrix. VX_TYPE_UINT8 or VX_TYPE_INT32 or VX_TYPE_FLOAT32. [in] columns The first dimensionality. [in] rows The second dimensionality.
Returns
An matrix reference vx_matrix. Any possible errors preventing a successful creation should be checked using vxGetStatus.
 vx_matrix VX_API_CALL vxCreateVirtualMatrix ( vx_graph graph, vx_enum data_type, vx_size columns, vx_size rows )

Creates an opaque reference to a matrix object without direct user access.

Parameters
 [in] graph The reference to the parent graph. [in] data_type The unit format of the matrix. VX_TYPE_UINT8 or VX_TYPE_INT32 or VX_TYPE_FLOAT32. [in] columns The first dimensionality. [in] rows The second dimensionality.
vxCreateMatrix
Returns
An matrix reference vx_matrix. Any possible errors preventing a successful creation should be checked using vxGetStatus.
 vx_status VX_API_CALL vxReleaseMatrix ( vx_matrix * mat )

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

Parameters
 [in] mat The matrix reference to release.
Postcondition
After returning from this function the reference is zeroed.
Returns
A vx_status_e enumeration.
Return values
 VX_SUCCESS No errors; any other value indicates failure. VX_ERROR_INVALID_REFERENCE mat is not a valid vx_matrix reference.
 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] mat The matrix object to set. [in] attribute The attribute to query. Use a vx_matrix_attribute_e enumeration. [out] ptr The location at which to store the resulting value. [in] size The size in bytes of the container to which ptr points.
Returns
A vx_status_e enumeration.
Return values
 VX_SUCCESS No errors; any other value indicates failure. VX_ERROR_INVALID_REFERENCE mat is not a valid vx_matrix reference.
 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.

Parameters
 [in] matrix The reference to the matrix object that is the source or the destination of the copy. [in] user_ptr The 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. 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. The accessible memory must be large enough to contain this 2D array: accessible memory in bytes >= sizeof(data_element) * rows * columns. [in] usage This declares the effect of the copy with regard to the matrix object using the vx_accessor_e enumeration. Only VX_READ_ONLY and VX_WRITE_ONLY are supported: VX_READ_ONLY means that data are copied from the matrix object into the user memory. VX_WRITE_ONLY means that data are copied into the matrix object from the user memory. [in] user_mem_type A vx_memory_type_e enumeration that specifies the memory type of the memory referenced by the user_addr.
Returns
A vx_status_e enumeration.
Return values
 VX_SUCCESS No errors; any other value indicates failure. VX_ERROR_INVALID_REFERENCE matrix is not a valid vx_matrix reference. VX_ERROR_INVALID_PARAMETERS An other parameter is incorrect.
 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.

vxCreateMatrixFromPatternAndOrigin for a description of the matrix patterns.
Parameters
 [in] context The reference to the overall context. [in] pattern The pattern of the matrix. See VX_MATRIX_PATTERN. [in] columns The first dimensionality. [in] rows The second dimensionality.
Returns
A matrix reference vx_matrix of type VX_TYPE_UINT8. Any possible errors preventing a successful creation should be checked using vxGetStatus.
 vx_matrix VX_API_CALL vxCreateMatrixFromPatternAndOrigin ( vx_context context, vx_enum pattern, vx_size columns, vx_size rows, vx_size origin_col, vx_size origin_row )

Creates a reference to a matrix object from a boolean pattern, with a user-specified origin.

The matrix created by this function is of type VX_TYPE_UINT8, with the value 0 representing False, and the value 255 representing True. It supports the patterns as described below:

• VX_PATTERN_BOX is a matrix with dimensions equal to the given number of rows and columns, and all cells equal to 255. Dimensions of 3x3 and 5x5 must be supported.
• VX_PATTERN_CROSS is a matrix with dimensions equal to the given number of rows and columns, which both must be odd numbers. All cells in the center row and center column are equal to 255, and the rest are equal to zero. Dimensions of 3x3 and 5x5 must be supported.
• VX_PATTERN_DISK is a matrix with dimensions equal to the given number of rows (R) and columns (C), 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.

A matrix created from pattern is read-only. The behavior when attempting to modify such a matrix is undefined.

Parameters
 [in] context The reference to the overall context. [in] pattern The pattern of the matrix. See VX_MATRIX_PATTERN. [in] columns The first dimensionality. [in] rows The second dimensionality. [in] origin_col The origin (first dimensionality). [in] origin_row The origin (second dimensionality).
Returns
A matrix reference vx_matrix of type VX_TYPE_UINT8. Any possible errors preventing a successful creation should be checked using vxGetStatus.