TIOVX User Guide
vx_tutorial_image_load_save.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.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.
 
#define OUT_FILE_NAME   "${VX_TEST_DATA_PATH}/vx_tutorial_image_load_save_out.bmp"
 Output file name.
 

Functions

void vx_tutorial_image_load_save ()
 Tutorial Entry Point. More...
 

Detailed Description

Load and save data from OpenVX image objects

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 read pixel values from an image data object and save it as a BMP file
  • How to cleanup all created resources and exit the OpenVX application

To include OpenVX interfaces include below file

#include <VX/vx.h>

To include utility APIs to read and write BMP file include below file

#include <bmp_rd_wr.h>

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

Definition in file vx_tutorial_image_load_save.c.

Function Documentation

◆ vx_tutorial_image_load_save()

void vx_tutorial_image_load_save ( )

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









- Query image object.

Here we print the image dimensions.

/
vxQueryImage(image, (vx_enum)VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
vxQueryImage(image, (vx_enum)VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));







- Save image object to bitmap file OUT_FILE_NAME.

Follow the comments in tivx_utils_save_vximage_to_bmpfile() to see how data in vx_image object is accessed to store pixel values from the image object to BMP file OUT_FILE_NAME





- 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_load_save.c.