TIOVX User Guide
vx_tutorial_image_query.c File Reference
#include <stdio.h>
#include <VX/vx.h>
#include <utility.h>

Go to the source code of this file.

Macros

#define IN_FILE_NAME   "${VX_TEST_DATA_PATH}/colors.bmp"
 Input file name.
 

Functions

void vx_tutorial_image_query ()
 Tutorial Entry Point. More...
 
void show_image_attributes (vx_image image)
 Show attributes of previously created image. More...
 

Detailed Description

Query image for attributes such as width, height and format

In this tutorial we learn the below concepts,

  • How to create OpenVX context and OpenVX image data object
  • How to read a BMP file and load the pixel values into the image data object
  • How to query the image data object for attributes like width, height
  • How to cleanup all created resources and exit the OpenVX application

To include OpenVX interfaces include below file

#include <VX/vx.h>

Follow the comments in the function vx_tutorial_image_query() to understand this tutorial

As part of this tutorial, we create few utility functions as listed below. These functions will be used in subsequent tutorials to display node and graph attributes.

Utility function Description
show_image_attributes() Displays attributes of a previously created image. NOTE: This function though listed in this tutorial is used in later tutorials

Definition in file vx_tutorial_image_query.c.

Function Documentation

◆ vx_tutorial_image_query()

void vx_tutorial_image_query ( )

Tutorial Entry Point.







- Define objects that we wish to create in the OpenVX application.

A vx_context object is defined which is used as input parameter for all subesquent OpenVX object create APIs

/
vx_context context;
vx_image image;











- Create OpenVX context.

This MUST be done first before any OpenVX API call. The context that is returned is used as input for subsequent OpenVX APIs

/
context = vxCreateContext();









- Create image object.

Follow the comments in tivx_utils_create_vximage_from_bmpfile() to see how a vx_image object is created and filled with RGB data from BMP file IN_FILE_NAME







- Show image attributes.

Follow the comments in show_image_attributes() to see how image attributes are queried and displayed.





- Release image object.

Since we are done with using this image object, release it

/



- Release context object.

Since we are done using OpenVX context, release it. No further OpenVX API calls should be done, until a context is again created using vxCreateContext()

/
vxReleaseContext(&context);

Definition at line 110 of file vx_tutorial_image_query.c.

◆ show_image_attributes()

void show_image_attributes ( vx_image  image)

Show attributes of previously created image.

This function queries the vx_image image for its number of nodes, number of parameters, state, performance, reference name and reference count then prints this information.

Parameters
image[in] Previouly created image object
  • Query image attributes.

Queries image for width, height, format, planes, size, space, range, range and memory type.

/
vxQueryImage(image, (vx_enum)VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
vxQueryImage(image, (vx_enum)VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
vxQueryImage(image, (vx_enum)VX_IMAGE_PLANES, &num_planes, sizeof(vx_size));
vxQueryImage(image, (vx_enum)VX_IMAGE_SIZE, &size, sizeof(vx_size));
vxQueryImage(image, (vx_enum)VX_IMAGE_SPACE, &color_space, sizeof(vx_enum));
vxQueryImage(image, (vx_enum)VX_IMAGE_RANGE, &channel_range, sizeof(vx_enum));
vxQueryImage(image, (vx_enum)VX_IMAGE_MEMORY_TYPE, &memory_type, sizeof(vx_enum));

Definition at line 194 of file vx_tutorial_image_query.c.