TIOVX User Guide

Detailed Description

Utility APIs available for the application running on the host.

Functions

vx_status tivx_utils_expand_file_path (const char *inFilePath, char *outFilePath)
 Conditionally returns the absolute path of the 'inFilePath'. More...
 
uint32_t tivx_utils_simple_image_checksum (vx_image image, uint8_t plane_id, vx_rectangle_t rect)
 Returns a uint32_t of the sum of all words within a rect of an image's buffer. More...
 
uint32_t tivx_utils_user_data_object_checksum (vx_user_data_object user_data_object, uint32_t offset_byte, uint32_t num_bytes)
 Returns a uint32_t of the sum of all words within a range of the user data object buffer. More...
 
uint32_t tivx_utils_tensor_checksum (vx_tensor tensor_object, vx_size number_of_dimensions, vx_size *view_start, vx_size *view_end, vx_size *user_stride)
 Returns a uint32_t of the sum of all words within a range of the tensor buffer. More...
 
vx_status tivx_utils_png_file_read (char *filename, vx_bool convert_to_gray_scale, uint32_t *width, uint32_t *height, uint32_t *stride, vx_df_image *df, void **data_ptr, void **png_file_context)
 Read data from PNG file. More...
 
void tivx_utils_png_file_read_release (void *png_file_context)
 Free memory allocated during png_file_read. More...
 
int32_t tivx_utils_png_file_write (char *filename, uint32_t width, uint32_t height, uint32_t stride, vx_df_image df, void *data_ptr)
 Write data into PNG file. More...
 
vx_image tivx_utils_create_vximage_from_pngfile (vx_context context, char *filename, vx_bool convert_to_gray_scale)
 Create a image data object given PNG filename as input. More...
 
vx_status tivx_utils_save_vximage_to_pngfile (char *filename, vx_image image)
 Save data from image object to PNG file. More...
 
vx_status tivx_utils_load_vximage_from_pngfile (vx_image image, char *filename, vx_bool convert_to_gray_scale)
 Load data from PNG file into a previously created vx_image object. More...
 
vx_status tivx_utils_bmp_file_read (const char *filename, vx_bool convert_to_gray_scale, tivx_utils_bmp_image_params_t *imageParams)
 Read data from BMP file. More...
 
vx_status tivx_utils_bmp_file_read_from_memory (const void *buf, uint32_t buf_size, vx_bool convert_to_gray_scale, tivx_utils_bmp_image_params_t *imageParams)
 Read data from BMP file. More...
 
void tivx_utils_bmp_file_read_release (void *png_file_context)
 Free memory allocated during bmp file read. More...
 
int32_t tivx_utils_bmp_file_write (const char *filename, uint32_t width, uint32_t height, uint32_t stride, vx_df_image df, void *data_ptr)
 Write data into BMP file. More...
 
vx_image tivx_utils_create_vximage_from_bmpfile (vx_context context, const char *filename, vx_bool convert_to_gray_scale)
 Create a image data object given BMP filename as input. More...
 
vx_status tivx_utils_save_vximage_to_bmpfile (const char *filename, vx_image image)
 Save data from image object to PNG file. More...
 
vx_status tivx_utils_load_vximage_from_bmpfile (vx_image image, char *filename, vx_bool convert_to_gray_scale)
 Load data from BMP file into a previously created vx_image object. More...
 
vx_status tivx_utils_graph_perf_print (vx_graph graph)
 Print graph performance information to stdout via 'printf'. More...
 
vx_status tivx_utils_graph_perf_export (FILE *fp, vx_graph graph)
 Writes graph information to .md file for integration into user guide. More...
 
vx_status tivx_utils_node_perf_print (vx_node node)
 Print node performance information to stdout via 'printf'. More...
 
vx_status tivx_utils_export_ref_for_ipc_xfer (const vx_reference ref, tivx_utils_ref_ipc_msg_t *ipcMsg)
 Export the internal handle information of a valid reference as a buffer descriptor along with meta information so that the information could be transferred over Linux/QNX IPC mechanism to a remote process. Only the following reference types are supported. More...
 
vx_status tivx_utils_import_ref_from_ipc_xfer (vx_context context, tivx_utils_ref_ipc_msg_t *ipcMsg, vx_reference *ref)
 Import the external handle information of a valid reference as a buffer descriptor along with meta information exchanged via Linux/ QNX IPC mechanism. Only the following reference types are supported. More...
 
vx_bool tivx_utils_compare_refs_from_ipc_xfer (tivx_utils_ref_ipc_msg_t *ipcMsg1, tivx_utils_ref_ipc_msg_t *ipcMsg2)
 Compare the external handle information of a valid reference with another external handle. More...
 

Function Documentation

◆ tivx_utils_expand_file_path()

vx_status tivx_utils_expand_file_path ( const char *  inFilePath,
char *  outFilePath 
)

Conditionally returns the absolute path of the 'inFilePath'.

Parameters
inFilePath[in] inFilePath
outFilePath[out] This shall contain the path to the inFilePath as follows:
  • If the 'inFilePath' contains reference to environment variable then it shall be expanded and an absolute file path is returned. If the environment variable is not defined then VX_FAILURE is returned. The content of 'outFilePath' will be undefined.
  • Otherwise, the 'inFilePath' is copied to 'outFilePath' as is. ex:- 1)- ${ENV_NAME} maps to /home/someone/test_dir inFilePath = "${ENV_NAME}/colors.bmp" outFilePath = "/home/someone/test_dir/colors.bmp" return VX_SUCCESS 2)- ${ENV_NAME} not defined inFilePath = "${ENV_NAME}/colors.bmp" outFilePath = not defined return VX_FAILURE 2)- inFilePath = "/some/dir/name/colors.bmp" outFilePath = "/some/dir/name/colors.bmp" return VX_SUCCESS NOTE: The length of 'outFilePath' will be truncated to TIOVX_UTILS_MAXPATHLENGTH-1;
Returns
- VX_SUCCESS and the content of 'outFilePath' will be valid
  • VX_FAILURE and the content of 'outFilePath' will be undefined

◆ tivx_utils_simple_image_checksum()

uint32_t tivx_utils_simple_image_checksum ( vx_image  image,
uint8_t  plane_id,
vx_rectangle_t  rect 
)

Returns a uint32_t of the sum of all words within a rect of an image's buffer.

If the buffer size contains a number of bytes not divisible by 4, the last 1, 2, or 3 bytes are rightshifted so that the last byte aligns with the LSB.

Parameters
image[in] input image
plane_id[in] plane number for multi plane image format
rect[in] rectangular region to generate the checksum for
Returns
sum of words in the specified region

◆ tivx_utils_user_data_object_checksum()

uint32_t tivx_utils_user_data_object_checksum ( vx_user_data_object  user_data_object,
uint32_t  offset_byte,
uint32_t  num_bytes 
)

Returns a uint32_t of the sum of all words within a range of the user data object buffer.

If the buffer size contains a number of bytes not divisible by 4, the last 1, 2, or 3 bytes are rightshifted so that the last byte aligns with the LSB.

Parameters
user_data_object[in] input user data object
offset_byte[in] starting offset (in bytes)
num_bytes[in] number of bytes to generate the checksum for
Returns
sum of words in the specified range

◆ tivx_utils_tensor_checksum()

uint32_t tivx_utils_tensor_checksum ( vx_tensor  tensor_object,
vx_size  number_of_dimensions,
vx_size view_start,
vx_size view_end,
vx_size user_stride 
)

Returns a uint32_t of the sum of all words within a range of the tensor buffer.

If the buffer size contains a number of bytes not divisible by 4, the last 1, 2, or 3 bytes are rightshifted so that the last byte aligns with the LSB.

Parameters
tensor_object[in] input tensor object
number_of_dimensions[in] number of tensor dimensions
view_start[in] starting offset for each dimension (in elements)
view_end[in] ending offset for each dimension (in elements)
user_stride[in] stride for each dimension (in bytes)
Returns
sum of words in the specified range

◆ tivx_utils_png_file_read()

vx_status tivx_utils_png_file_read ( char *  filename,
vx_bool  convert_to_gray_scale,
uint32_t *  width,
uint32_t *  height,
uint32_t *  stride,
vx_df_image df,
void **  data_ptr,
void **  png_file_context 
)

Read data from PNG file.

'png_file_context' holds the PNG file context including internally allcoated memory/resource information

When data from 'data_ptr' is copied by the user application, the 'png_file_context' MUST be released via png_file_read_release() in order to free any memory/resources allocated during png_file_read()

Parameters
filename[in] PNG file name. MUST have .png or .PNG extension
convert_to_gray_scale[in] TRUE: convert to gray scale after reading, FALSE: keep RGB format after reading
df[out] Data format of PNG file, will be VX_DF_IMAGE_U8 or VX_DF_IMAGE_RGB
width[out] Width of image in pixels
height[out] Height of image in lines
stride[out] Horizontal stride of image in units of bytes
data_ptr[in/out] Data buffer into which the PNG dara is read. Allocated by this API internally when data_ptr = NULL, else memory is allocated by user
png_file_context[out] PNG file context for this file
Returns
VX_SUCCESS if file could be opened, parsed and read successfully

◆ tivx_utils_png_file_read_release()

void tivx_utils_png_file_read_release ( void *  png_file_context)

Free memory allocated during png_file_read.

MUST be called by application after its done using the pixel data returned png_file_read() The 'png_file_context' returned by the function png_file_read() must be used as input to this API.

'data_ptr' returned by png_file_read() MUST not be used after png_file_read_release() is called.

Parameters
png_file_context[in] PNG file context returned during png_file_read()

◆ tivx_utils_png_file_write()

int32_t tivx_utils_png_file_write ( char *  filename,
uint32_t  width,
uint32_t  height,
uint32_t  stride,
vx_df_image  df,
void *  data_ptr 
)

Write data into PNG file.

Parameters
filename[in] PNG file name. MUST have .png or .PNG extension
width[in] Width of image in pixels
height[in] Height of image in lines
stride[in] Stride of image in units of bytes
df[in] Data format of data written into PNG file, MUST be VX_DF_IMAGE_U8 or VX_DF_IMAGE_RGB
data_ptr[in] Data buffer from where the data is to written to PNG file
Returns
VX_SUCCESS if file could be opened, and written successfully

◆ tivx_utils_create_vximage_from_pngfile()

vx_image tivx_utils_create_vximage_from_pngfile ( vx_context  context,
char *  filename,
vx_bool  convert_to_gray_scale 
)

Create a image data object given PNG filename as input.

Parameters
context[in] OpenVX context within which the image object will get created
filename[in] filename, MUST have extension of .png
convert_to_gray_scale[in] vx_true_e: Converts RGB values in BMP file to 8b grayscale value and copies them to image object
vx_false_e: Retains RGB values from BMP file and copies them to image object
NOTE: convert_to_gray_scale NOT supported as of NOW
Returns
Image data object.
Image data format is VX_DF_IMAGE_RGB when 'convert_to_gray_scale' is vx_false_e
Image data format is VX_DF_IMAGE_U8 when 'convert_to_gray_scale' is vx_true_e

◆ tivx_utils_save_vximage_to_pngfile()

vx_status tivx_utils_save_vximage_to_pngfile ( char *  filename,
vx_image  image 
)

Save data from image object to PNG file.

Parameters
filename[in] filename, MUST have extension of .png
image[in] Image data object. Image data format MUST be VX_DF_IMAGE_RGB or VX_DF_IMAGE_U8
Returns
VX_SUCCESS if PNG could be created and saved with data from image object

◆ tivx_utils_load_vximage_from_pngfile()

vx_status tivx_utils_load_vximage_from_pngfile ( vx_image  image,
char *  filename,
vx_bool  convert_to_gray_scale 
)

Load data from PNG file into a previously created vx_image object.

This function is same as create_vximage_from_pngfile(). Only difference is that the vx_image object is created outside this function.

This function queries the vx_image object to make sure its attributes match the attributes of the PNG file from which data needs to be loaded into the image object. In case of mismatch data is not loaded and error is returned.

Parameters
image[in] Previouly created image object
filename[in] filename, MUST have extension of .png
convert_to_gray_scale[in] vx_true_e: Converts RGB values in BMP file to 8b grayscale value and copies them to image object
vx_false_e: Retains RGB values from BMP file and copies them to image object
NOTE: convert_to_gray_scale NOT supported as of NOW
Returns
VX_SUCCESS if BMP file data could be loaded into the vx_image object.

◆ tivx_utils_bmp_file_read()

vx_status tivx_utils_bmp_file_read ( const char *  filename,
vx_bool  convert_to_gray_scale,
tivx_utils_bmp_image_params_t *  imageParams 
)

Read data from BMP file.

Same as tivx_utils_png_file_read() but with .bmp file

◆ tivx_utils_bmp_file_read_from_memory()

vx_status tivx_utils_bmp_file_read_from_memory ( const void *  buf,
uint32_t  buf_size,
vx_bool  convert_to_gray_scale,
tivx_utils_bmp_image_params_t *  imageParams 
)

Read data from BMP file.

Same as tivx_utils_png_file_read() but with .bmp file

◆ tivx_utils_bmp_file_read_release()

void tivx_utils_bmp_file_read_release ( void *  png_file_context)

Free memory allocated during bmp file read.

Same as tivx_utils_png_file_read_release() but with .bmp file

◆ tivx_utils_bmp_file_write()

int32_t tivx_utils_bmp_file_write ( const char *  filename,
uint32_t  width,
uint32_t  height,
uint32_t  stride,
vx_df_image  df,
void *  data_ptr 
)

Write data into BMP file.

Same as tivx_utils_png_file_write() but with .bmp file

◆ tivx_utils_create_vximage_from_bmpfile()

vx_image tivx_utils_create_vximage_from_bmpfile ( vx_context  context,
const char *  filename,
vx_bool  convert_to_gray_scale 
)

Create a image data object given BMP filename as input.

Same as tivx_utils_create_vximage_from_pngfile() but with .bmp file

◆ tivx_utils_save_vximage_to_bmpfile()

vx_status tivx_utils_save_vximage_to_bmpfile ( const char *  filename,
vx_image  image 
)

Save data from image object to PNG file.

Same as tivx_utils_save_vximage_to_pngfile() but with .bmp file

◆ tivx_utils_load_vximage_from_bmpfile()

vx_status tivx_utils_load_vximage_from_bmpfile ( vx_image  image,
char *  filename,
vx_bool  convert_to_gray_scale 
)

Load data from BMP file into a previously created vx_image object.

Same as tivx_utils_load_vximage_from_pngfile() but with .bmp file

◆ tivx_utils_graph_perf_print()

vx_status tivx_utils_graph_perf_print ( vx_graph  graph)

Print graph performance information to stdout via 'printf'.

This also prints information of all nodes present within the graph

Parameters
[in]graphgraph handle
Returns
VX_SUCCESS on success, else failure

◆ tivx_utils_graph_perf_export()

vx_status tivx_utils_graph_perf_export ( FILE *  fp,
vx_graph  graph 
)

Writes graph information to .md file for integration into user guide.

Requires the file to be opened using appPerfStatsExportOpenFile and closed using appPerfStatsExportCloseFile

Parameters
[in]fpfile handle
[in]graphgraph handle
Returns
VX_SUCCESS on success, else failure

◆ tivx_utils_node_perf_print()

vx_status tivx_utils_node_perf_print ( vx_node  node)

Print node performance information to stdout via 'printf'.

Parameters
[in]nodenode handle
Returns
VX_SUCCESS on success, else failure

◆ tivx_utils_export_ref_for_ipc_xfer()

vx_status tivx_utils_export_ref_for_ipc_xfer ( const vx_reference  ref,
tivx_utils_ref_ipc_msg_t *  ipcMsg 
)

Export the internal handle information of a valid reference as a buffer descriptor along with meta information so that the information could be transferred over Linux/QNX IPC mechanism to a remote process. Only the following reference types are supported.

  • VX_TYPE_IMAGE
  • VX_TYPE_TENSOR
  • VX_TYPE_USER_DATA_OBJECT
  • VX_TYPE_ARRAY
  • VX_TYPE_DISTRIBUTION
  • VX_TYPE_MATRIX
  • VX_TYPE_CONVOLUTION
  • TIVX_TYPE_RAW_IMAGE
  • TIVX_TYPE_PYRAMID
Parameters
[in]refA valid openVX reference whose information will be exported
[out]ipcMsgExported object information
Returns
VX_SUCCESS on success, else failure

◆ tivx_utils_import_ref_from_ipc_xfer()

vx_status tivx_utils_import_ref_from_ipc_xfer ( vx_context  context,
tivx_utils_ref_ipc_msg_t *  ipcMsg,
vx_reference ref 
)

Import the external handle information of a valid reference as a buffer descriptor along with meta information exchanged via Linux/ QNX IPC mechanism. Only the following reference types are supported.

  • VX_TYPE_IMAGE
  • VX_TYPE_TENSOR
  • VX_TYPE_USER_DATA_OBJECT
  • VX_TYPE_ARRAY
  • VX_TYPE_DISTRIBUTION
  • VX_TYPE_MATRIX
  • VX_TYPE_CONVOLUTION
  • TIVX_TYPE_RAW_IMAGE
  • TIVX_TYPE_PYRAMID
Parameters
[in]contextA valid openVX context
[in,out]ipcMsgExported object information
[in,out]refA valid openVX reference to import. If *ref is NULL, then a new object will be allocated with the imported handles and returned. If *ref is not NULL then the object will be used to import the handles.
Returns
VX_SUCCESS on success, else failure

◆ tivx_utils_compare_refs_from_ipc_xfer()

vx_bool tivx_utils_compare_refs_from_ipc_xfer ( tivx_utils_ref_ipc_msg_t *  ipcMsg1,
tivx_utils_ref_ipc_msg_t *  ipcMsg2 
)

Compare the external handle information of a valid reference with another external handle.

Parameters
[in,out]ipcMsg1Exported object information of the first reference
[in,out]ipcMsg1Exported object information of the second reference
Returns
vx_true_e if ipcMsg1 points to the same buffer as ipcMsg2, vx_false_e if it does not