TIOVX User Guide
vx_tutorial_image_query.c
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2017 Texas Instruments Incorporated
4 *
5 * All rights reserved not granted herein.
6 *
7 * Limited License.
8 *
9 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10 * license under copyrights and patents it now or hereafter owns or controls to make,
11 * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12 * terms herein. With respect to the foregoing patent license, such license is granted
13 * solely to the extent that any such patent is necessary to Utilize the software alone.
14 * The patent license shall not apply to any combinations which include this software,
15 * other than combinations with devices manufactured by or for TI ("TI Devices").
16 * No hardware patent is licensed hereunder.
17 *
18 * Redistributions must preserve existing copyright notices and reproduce this license
19 * (including the above copyright notice and the disclaimer and (if applicable) source
20 * code license limitations below) in the documentation and/or other materials provided
21 * with the distribution
22 *
23 * Redistribution and use in binary form, without modification, are permitted provided
24 * that the following conditions are met:
25 *
26 * * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 *
29 * * any redistribution and use are licensed by TI for use only with TI Devices.
30 *
31 * * Nothing shall obligate TI to provide you with source code for the software
32 * licensed and provided to you in object code.
33 *
34 * If software source code is provided to you, modification and redistribution of the
35 * source code are permitted provided that the following conditions are met:
36 *
37 * * any redistribution and use of the source code, including any resulting derivative
38 * works, are licensed by TI for use only with TI Devices.
39 *
40 * * any redistribution and use of any object code compiled from the source code
41 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42 *
43 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44 *
45 * may be used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * DISCLAIMER.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 */
62 
63 
64 
100 #include <stdio.h>
101 #include <VX/vx.h>
102 #include <utility.h>
103 
105 #define IN_FILE_NAME "${VX_TEST_DATA_PATH}/colors.bmp"
106 
111 {
119  vx_context context;
120  vx_image image;
123  printf(" vx_tutorial_image_query: Tutorial Started !!! \n");
124 
132  context = vxCreateContext();
135  printf(" Loading file %s ...\n", IN_FILE_NAME);
136 
147  vxSetReferenceName((vx_reference)image, "MY_IMAGE");
148 
156  show_image_attributes(image);
165  vxReleaseImage(&image);
176  vxReleaseContext(&context);
179  printf(" vx_tutorial_image_query: Tutorial Done !!! \n");
180  printf(" \n");
181 }
182 
183 #define MAX_ATTRIBUTE_NAME (32u)
184 
195 {
196  vx_uint32 width=0, height=0, ref_count=0;
197  vx_df_image df=0;
198  vx_size num_planes=0, size=0;
199  vx_enum color_space=0, channel_range=0, memory_type=0;
200  vx_char *ref_name=NULL;
201  char df_name[MAX_ATTRIBUTE_NAME];
202  char color_space_name[MAX_ATTRIBUTE_NAME];
203  char channel_range_name[MAX_ATTRIBUTE_NAME];
204  char memory_type_name[MAX_ATTRIBUTE_NAME];
205  char ref_name_invalid[MAX_ATTRIBUTE_NAME];
206 
214  vxQueryImage(image, (vx_enum)VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
215  vxQueryImage(image, (vx_enum)VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
216  vxQueryImage(image, (vx_enum)VX_IMAGE_FORMAT, &df, sizeof(vx_df_image));
217  vxQueryImage(image, (vx_enum)VX_IMAGE_PLANES, &num_planes, sizeof(vx_size));
218  vxQueryImage(image, (vx_enum)VX_IMAGE_SIZE, &size, sizeof(vx_size));
219  vxQueryImage(image, (vx_enum)VX_IMAGE_SPACE, &color_space, sizeof(vx_enum));
220  vxQueryImage(image, (vx_enum)VX_IMAGE_RANGE, &channel_range, sizeof(vx_enum));
221  vxQueryImage(image, (vx_enum)VX_IMAGE_MEMORY_TYPE, &memory_type, sizeof(vx_enum));
224  vxQueryReference((vx_reference)image, (vx_enum)VX_REFERENCE_NAME, &ref_name, sizeof(vx_char*));
225  vxQueryReference((vx_reference)image, (vx_enum)VX_REFERENCE_COUNT, &ref_count, sizeof(vx_uint32));
226 
227  switch(df)
228  {
230  strncpy(df_name, "VX_DF_IMAGE_VIRT", MAX_ATTRIBUTE_NAME);
231  break;
233  strncpy(df_name, "VX_DF_IMAGE_RGB", MAX_ATTRIBUTE_NAME);
234  break;
236  strncpy(df_name, "VX_DF_IMAGE_RGBX", MAX_ATTRIBUTE_NAME);
237  break;
239  strncpy(df_name, "VX_DF_IMAGE_NV12", MAX_ATTRIBUTE_NAME);
240  break;
242  strncpy(df_name, "VX_DF_IMAGE_NV21", MAX_ATTRIBUTE_NAME);
243  break;
245  strncpy(df_name, "VX_DF_IMAGE_UYVY", MAX_ATTRIBUTE_NAME);
246  break;
248  strncpy(df_name, "VX_DF_IMAGE_YUYV", MAX_ATTRIBUTE_NAME);
249  break;
251  strncpy(df_name, "VX_DF_IMAGE_IYUV", MAX_ATTRIBUTE_NAME);
252  break;
254  strncpy(df_name, "VX_DF_IMAGE_YUV4", MAX_ATTRIBUTE_NAME);
255  break;
257  strncpy(df_name, "VX_DF_IMAGE_U8", MAX_ATTRIBUTE_NAME);
258  break;
260  strncpy(df_name, "VX_DF_IMAGE_U16", MAX_ATTRIBUTE_NAME);
261  break;
263  strncpy(df_name, "VX_DF_IMAGE_S16", MAX_ATTRIBUTE_NAME);
264  break;
266  strncpy(df_name, "VX_DF_IMAGE_U32", MAX_ATTRIBUTE_NAME);
267  break;
269  strncpy(df_name, "VX_DF_IMAGE_S32", MAX_ATTRIBUTE_NAME);
270  break;
271  default:
272  strncpy(df_name, "VX_DF_IMAGE_UNKNOWN", MAX_ATTRIBUTE_NAME);
273  break;
274  }
275 
276  switch(color_space)
277  {
279  strncpy(color_space_name, "VX_COLOR_SPACE_NONE", MAX_ATTRIBUTE_NAME);
280  break;
282  strncpy(color_space_name, "VX_COLOR_SPACE_BT601_525", MAX_ATTRIBUTE_NAME);
283  break;
285  strncpy(color_space_name, "VX_COLOR_SPACE_BT601_625", MAX_ATTRIBUTE_NAME);
286  break;
288  strncpy(color_space_name, "VX_COLOR_SPACE_BT709", MAX_ATTRIBUTE_NAME);
289  break;
290  default:
291  strncpy(color_space_name, "VX_COLOR_SPACE_UNKNOWN", MAX_ATTRIBUTE_NAME);
292  break;
293  }
294 
295  switch(channel_range)
296  {
298  strncpy(channel_range_name, "VX_CHANNEL_RANGE_FULL", MAX_ATTRIBUTE_NAME);
299  break;
301  strncpy(channel_range_name, "VX_CHANNEL_RANGE_RESTRICTED", MAX_ATTRIBUTE_NAME);
302  break;
303  default:
304  strncpy(channel_range_name, "VX_CHANNEL_RANGE_UNKNOWN", MAX_ATTRIBUTE_NAME);
305  break;
306  }
307 
308  switch(memory_type)
309  {
311  strncpy(memory_type_name, "VX_MEMORY_TYPE_NONE", MAX_ATTRIBUTE_NAME);
312  break;
314  strncpy(memory_type_name, "VX_MEMORY_TYPE_HOST", MAX_ATTRIBUTE_NAME);
315  break;
316  default:
317  strncpy(memory_type_name, "VX_MEMORY_TYPE_UNKNOWN", MAX_ATTRIBUTE_NAME);
318  break;
319  }
320 
321  if(ref_name==NULL)
322  {
323  strncpy(ref_name_invalid, "INVALID_REF_NAME", MAX_ATTRIBUTE_NAME);
324  ref_name = &ref_name_invalid[0];
325  }
326 
327  printf(" VX_TYPE_IMAGE: %s, %d x %d, %d plane(s), %d B, %s %s %s %s, %d refs\n",
328  ref_name,
329  width,
330  height,
331  (uint32_t)num_planes,
332  (uint32_t)size,
333  df_name,
334  color_space_name,
335  channel_range_name,
336  memory_type_name,
337  ref_count
338  );
339 }
struct _vx_image * vx_image
vx_bool
vx_false_e
void show_image_attributes(vx_image image)
Show attributes of previously created image.
vx_status VX_API_CALL vxQueryImage(vx_image image, vx_enum attribute, void *ptr, vx_size size)
VX_COLOR_SPACE_BT601_625
VX_MEMORY_TYPE_HOST
VX_IMAGE_SIZE
VX_IMAGE_SPACE
VX_IMAGE_MEMORY_TYPE
size_t vx_size
VX_DF_IMAGE_NV21
int32_t vx_enum
VX_CHANNEL_RANGE_FULL
vx_status VX_API_CALL vxQueryReference(vx_reference ref, vx_enum attribute, void *ptr, vx_size size)
#define IN_FILE_NAME
Input file name.
VX_DF_IMAGE_U32
char vx_char
VX_DF_IMAGE_U8
vx_status VX_API_CALL vxReleaseContext(vx_context *context)
VX_COLOR_SPACE_BT601_525
struct _vx_context * vx_context
struct _vx_reference * vx_reference
VX_DF_IMAGE_YUYV
VX_IMAGE_RANGE
uint32_t vx_df_image
VX_DF_IMAGE_RGB
VX_DF_IMAGE_VIRT
VX_IMAGE_WIDTH
VX_DF_IMAGE_RGBX
vx_status VX_API_CALL vxSetReferenceName(vx_reference ref, const vx_char *name)
VX_IMAGE_FORMAT
VX_IMAGE_PLANES
VX_COLOR_SPACE_BT709
VX_DF_IMAGE_UYVY
VX_DF_IMAGE_YUV4
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.
void vx_tutorial_image_query()
Tutorial Entry Point.
VX_COLOR_SPACE_NONE
VX_DF_IMAGE_S16
uint32_t vx_uint32
VX_DF_IMAGE_NV12
vx_context VX_API_CALL vxCreateContext()
VX_MEMORY_TYPE_NONE
VX_DF_IMAGE_IYUV
VX_CHANNEL_RANGE_RESTRICTED
vx_status VX_API_CALL vxReleaseImage(vx_image *image)
VX_DF_IMAGE_U16
VX_DF_IMAGE_S32
VX_IMAGE_HEIGHT