TIOVX User Guide
attribute.py
1 #
2 # Copyright (c) 2017 Texas Instruments Incorporated
3 #
4 # All rights reserved not granted herein.
5 #
6 # Limited License.
7 #
8 # Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
9 # license under copyrights and patents it now or hereafter owns or controls to make,
10 # have made, use, import, offer to sell and sell ("Utilize") this software subject to the
11 # terms herein. With respect to the foregoing patent license, such license is granted
12 # solely to the extent that any such patent is necessary to Utilize the software alone.
13 # The patent license shall not apply to any combinations which include this software,
14 # other than combinations with devices manufactured by or for TI ("TI Devices").
15 # No hardware patent is licensed hereunder.
16 #
17 # Redistributions must preserve existing copyright notices and reproduce this license
18 # (including the above copyright notice and the disclaimer and (if applicable) source
19 # code license limitations below) in the documentation and/or other materials provided
20 # with the distribution
21 #
22 # Redistribution and use in binary form, without modification, are permitted provided
23 # that the following conditions are met:
24 #
25 # No reverse engineering, decompilation, or disassembly of this software is
26 # permitted with respect to any software provided in binary form.
27 #
28 # any redistribution and use are licensed by TI for use only with TI Devices.
29 #
30 # Nothing shall obligate TI to provide you with source code for the software
31 # licensed and provided to you in object code.
32 #
33 # If software source code is provided to you, modification and redistribution of the
34 # source code are permitted provided that the following conditions are met:
35 #
36 # any redistribution and use of the source code, including any resulting derivative
37 # works, are licensed by TI for use only with TI Devices.
38 #
39 # any redistribution and use of any object code compiled from the source code
40 # and any resulting derivative works, are licensed by TI for use only with TI Devices.
41 #
42 # Neither the name of Texas Instruments Incorporated nor the names of its suppliers
43 #
44 # may be used to endorse or promote products derived from this software without
45 # specific prior written permission.
46 #
47 # DISCLAIMER.
48 #
49 # THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
50 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52 # IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
56 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
57 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58 # OF THE POSSIBILITY OF SUCH DAMAGE.
59 #
60 #
61 
62 from enum import Enum
63 from . import *
64 
65 
74 class ImageAttribute(Enum) :
75 
76  WIDTH = ('w', 'vx_uint32')
77 
78  HEIGHT = ('h', 'vx_uint32')
79 
80  FORMAT = ('fmt', 'vx_df_image')
81 
82  PLANES = ('planes', 'vx_size')
83 
84  SPACE = ('space', 'vx_enum')
85 
86  RANGE = ('range', 'vx_enum')
87 
88  SIZE = ('size', 'vx_size')
89 
90  MEMORY_TYPE = ('memory_type', 'vx_enum')
91 
92  def vx_enum_name(attr) :
93  return "VX_IMAGE_" + attr.name
94 
95  def object_type() :
96  return Type.IMAGE
97 
98 
107 class PyramidAttribute(Enum) :
108 
109  LEVELS = ('levels', 'vx_size')
110 
111  SCALE = ('scale', 'vx_float32')
112 
113  WIDTH = ('w', 'vx_uint32')
114 
115  HEIGHT = ('h', 'vx_uint32')
116 
117  FORMAT = ('fmt', 'vx_df_image')
118 
119  def vx_enum_name(attr) :
120  return "VX_PYRAMID_" + attr.name
121 
122  def object_type() :
123  return Type.PYRAMID
124 
125 
134 class ArrayAttribute(Enum) :
135 
136  ITEMTYPE = ('item_type', 'vx_enum')
137 
138  NUMITEMS = ('num_items', 'vx_size')
139 
140  CAPACITY = ('capacity', 'vx_size')
141 
142  ITEMSIZE = ('item_size', 'vx_size')
143 
144  def vx_enum_name(attr) :
145  return "VX_ARRAY_" + attr.name
146 
147  def object_type() :
148  return Type.ARRAY
149 
150 
158 class ScalarAttribute(Enum) :
159 
160  TYPE = ('scalar_type', 'vx_enum')
161 
162  def vx_enum_name(attr) :
163  return "VX_SCALAR_" + attr.name
164 
165  def object_type() :
166  return Type.SCALAR
167 
168 
177 class ConvolutionAttribute(Enum) :
178 
179  ROWS = ('row', 'vx_size')
180 
181  COLUMNS = ('col', 'vx_size')
182 
183  SCALE = ('scale', 'vx_uint32')
184 
185  SIZE = ('size', 'vx_size')
186 
187  def vx_enum_name(attr) :
188  return "VX_CONVOLUTION_" + attr.name
189 
190  def object_type() :
191  return Type.CONVOLUTION
192 
193 
202 class MatrixAttribute(Enum) :
203 
204  TYPE = ('type', 'vx_enum')
205 
206  ROWS = ('h', 'vx_size')
207 
208  COLUMNS = ('w', 'vx_size')
209 
210  SIZE = ('size', 'vx_size')
211 
212  ORIGIN = ('origin', 'vx_coordinates2d_t')
213 
214  PATTERN = ('pattern', 'vx_enum')
215 
216  def vx_enum_name(attr) :
217  return "VX_MATRIX_" + attr.name
218 
219  def object_type() :
220  return Type.MATRIX
221 
222 
231 class LutAttribute(Enum) :
232 
233  TYPE = ('type', 'vx_enum')
234 
235  COUNT = ('count', 'vx_size')
236 
237  SIZE = ('size', 'vx_size')
238 
239  OFFSET = ('offset', 'vx_uint32')
240 
241  def vx_enum_name(attr) :
242  return "VX_LUT_" + attr.name
243 
244  def object_type() :
245  return Type.LUT
246 
247 
257 
258  DIMENSIONS = ('dims', 'vx_size')
259 
260  OFFSET = ('offset', 'vx_int32')
261 
262  RANGE = ('range', 'vx_uint32')
263 
264  BINS = ('bins', 'vx_size')
265 
266  WINDOW = ('win', 'vx_uint32')
267 
268  SIZE = ('size', 'vx_size')
269 
270  def vx_enum_name(attr) :
271  return "VX_DISTRIBUTION_" + attr.name
272 
273  def object_type() :
274  return Type.DISTRIBUTION
275 
276 
285 class ThresholdAttribute(Enum) :
286 
287  TYPE = ('threshold_type', 'vx_enum')
288 
289  THRESHOLD_VALUE = ('value', 'vx_int32')
290 
291  THRESHOLD_LOWER = ('lower', 'vx_int32')
292 
293  THRESHOLD_UPPER = ('upper', 'vx_int32')
294 
295  TRUE_VALUE = ('true_value', 'vx_int32')
296 
297  FALSE_VALUE = ('false_value', 'vx_int32')
298 
299  DATA_TYPE = ('threshold_data_type', 'vx_enum')
300 
301  def vx_enum_name(attr) :
302  return "VX_THRESHOLD_" + attr.name
303 
304  def object_type() :
305  return Type.THRESHOLD
306 
307 
316 class RemapAttribute(Enum) :
317 
318  SOURCE_WIDTH = ('src_w', 'vx_uint32')
319 
320  SOURCE_HEIGHT = ('src_h', 'vx_uint32')
321 
322  DESTINATION_WIDTH = ('dst_w', 'vx_uint32')
323 
324  DESTINATION_HEIGHT = ('dst_h', 'vx_uint32')
325 
326  def vx_enum_name(attr) :
327  return "VX_REMAP_" + attr.name
328 
329  def object_type() :
330  return Type.REMAP
331 
332 
341 class ObjectArrayAttribute(Enum) :
342 
343  ITEMTYPE = ('type', 'vx_enum')
344 
345  NUMITEMS = ('num_items', 'vx_size')
346 
347  def vx_enum_name(attr) :
348  return "VX_OBJECT_ARRAY_" + attr.name
349 
350  def object_type() :
351  return Type.OBJECT_ARRAY
352 
353 
363 
364  NAME = ('name', 'vx_char')
365 
366  SIZE = ('size', 'vx_size')
367 
368  def vx_enum_name(attr) :
369  return "VX_USER_DATA_OBJECT_" + attr.name
370 
371  def object_type() :
372  return Type.USER_DATA_OBJECT
373 
374 
383 class RawImageAttribute(Enum) :
384 
385  WIDTH = ('w', 'vx_uint32')
386 
387  HEIGHT = ('h', 'vx_uint32')
388 
389  MUM_EXPOSURES = ('num_exposures', 'vx_uint32')
390 
391  LINE_INTERLEAVED = ('line_interleaved', 'vx_bool')
392 
393  FORMAT = ('format', 'tivx_raw_image_format_t')
394 
395  META_HEIGHT_BEFORE = ('meta_height_before', 'vx_uint32')
396 
397  META_HEIGHT_AFTER = ('meta_height_after', 'vx_uint32')
398 
399  def vx_enum_name(attr) :
400  return "TIVX_RAW_IMAGE_" + attr.name
401 
402  def object_type() :
403  return Type.RAW_IMAGE
404 
405 
418 class TensorAttribute(Enum) :
419 
420  NUMBER_OF_DIMS = ('number_of_dims', 'vx_size')
421 
422  DIMS = ('dims', 'vx_size')
423 
424  DATA_TYPE = ('data_type', 'vx_enum')
425 
426  FIXED_POINT_POSITION = ('fixed_point_position', 'vx_int8')
427 
428  SCALING_DIVISOR = ('scaling_divisor', 'vx_int8')
429 
430  SCALING_DIVISOR_FIXED_POINT_POSITION = ('scaling_divisor_fixed_point_position', 'vx_int8')
431 
432  def vx_enum_name(attr) :
433  return "VX_TENSOR_" + attr.name
434 
435  def object_type() :
436  return Type.TENSOR
437 
438 
447 class Attribute :
448  Image = ImageAttribute
449  Pyramid = PyramidAttribute
450  Array = ArrayAttribute
451  Scalar = ScalarAttribute
452  Convolution = ConvolutionAttribute
453  Matrix = MatrixAttribute
454  Lut = LutAttribute
455  Distribution = DistributionAttribute
456  Threshold = ThresholdAttribute
457  Remap = RemapAttribute
458  ObjectArray = ObjectArrayAttribute
459  UserDataObject = UserDataObjectAttribute
460  RawImage = RawImageAttribute
461  Tensor = TensorAttribute
462 
463  def from_type(type) :
464  if type == Type.IMAGE :
465  return Attribute.Image
466  if type == Type.PYRAMID :
467  return Attribute.Pyramid
468  if type == Type.ARRAY :
469  return Attribute.Array
470  if type == Type.SCALAR :
471  return Attribute.Scalar
472  if type == Type.CONVOLUTION :
473  return Attribute.Convolution
474  if type == Type.MATRIX :
475  return Attribute.Matrix
476  if type == Type.LUT :
477  return Attribute.Lut
478  if type == Type.DISTRIBUTION :
479  return Attribute.Distribution
480  if type == Type.THRESHOLD :
481  return Attribute.Threshold
482  if type == Type.REMAP :
483  return Attribute.Remap
484  if type == Type.OBJECT_ARRAY :
485  return Attribute.ObjectArray
486  if type == Type.USER_DATA_OBJECT :
487  return Attribute.UserDataObject
488  if type == Type.RAW_IMAGE :
489  return Attribute.RawImage
490  if type == Type.TENSOR :
491  return Attribute.Tensor
492  return "INVALID"
Object/Data type (OpenVX equivalent = vx_object_array_attribute_e)
Definition: attribute.py:341
Object/Data type (OpenVX equivalent = vx_matrix_attribute_e)
Definition: attribute.py:202
Object/Data type (OpenVX equivalent = vx_array_attribute_e)
Definition: attribute.py:134
Object/Data type (OpenVX equivalent = vx_scalar_attribute_e)
Definition: attribute.py:158
Object/Data type (OpenVX equivalent = vx_remap_attribute_e)
Definition: attribute.py:316
Object/Data type (OpenVX equivalent = vx_lut_attribute_e)
Definition: attribute.py:231
Object/Data type (OpenVX equivalent = vx_convolution_attribute_e)
Definition: attribute.py:177
Object/Data type (OpenVX equivalent = vx_user_data_object_attribute_e)
Definition: attribute.py:362
Object/Data type (OpenVX equivalent = vx_pyramid_attribute_e)
Definition: attribute.py:107
Object/Data type (OpenVX equivalent = tivx_raw_image_attribute_e)
Definition: attribute.py:383
Object/Data type (OpenVX equivalent = vx_distribution_attribute_e)
Definition: attribute.py:256
Object/Data type (OpenVX equivalent = vx_image_attribute_e)
Definition: attribute.py:74
Object/Data type (OpenVX equivalent = vx_threshold_attribute_e)
Definition: attribute.py:285
Object/Data type (OpenVX equivalent = vx_tensor_attribute_e)
Definition: attribute.py:418
Object/Data type (OpenVX equivalent = none ...
Definition: attribute.py:447