TIOVX User Guide
enums.py
1 #
2 # Copyright (c) 2017-2019 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 
66 
75 class Type(Enum):
76 
77  INVALID = 1
78 
79  CHAR = 2
80 
81  INT8 = 3
82 
83  UINT8 = 4
84 
85  INT16 = 5
86 
87  UINT16 = 6
88 
89  INT32 = 7
90 
91  UINT32 = 8
92 
93  INT64 = 9
94 
95  UINT64 = 10
96 
97  FLOAT32 = 11
98 
99  FLOAT64 = 12
100 
101  ENUM = 13
102 
103  SIZE = 14
104 
105  DF_IMAGE= 15
106 
107  BOOL = 16
108 
109  REFERENCE = 17
110 
111  CONTEXT = 18
112 
113  GRAPH = 19
114 
115  NODE = 20
116 
117  KERNEL = 21
118 
119  PARAMETER = 22
120 
121  DELAY = 23
122 
123  LUT = 24
124 
125  DISTRIBUTION = 25
126 
127  PYRAMID = 26
128 
129  THRESHOLD = 27
130 
131  MATRIX = 28
132 
133  CONVOLUTION = 29
134 
135  SCALAR = 30
136 
137  ARRAY = 31
138 
139  IMAGE = 32
140 
141  REMAP = 33
142 
143  ERROR = 34
144 
145  META_FORMAT = 35
146 
147  OBJECT_ARRAY = 36
148 
149  RECTANGLE = 37
150 
151  KEYPOINT = 38
152 
153  COORDINATES2D = 39
154 
155  COORDINATES3D = 40
156 
157  USER_DATA_OBJECT = 41
158 
159  RAW_IMAGE = 42
160 
161  TENSOR = 43
162 
163  NULL = 44
164 
165  def __lt__(self, other):
166  if self.__class__ is other.__class__:
167  return self.value < other.value
168  return NotImplemented
169 
170  def __gt__(self, other):
171  if self.__class__ is other.__class__:
172  return self.value > other.value
173  return NotImplemented
174 
175  def __eq__(self, other):
176  if self.__class__ is other.__class__:
177  return self.value == other.value
178  return NotImplemented
179 
180  def get_vx_enum_name(type) :
181  if type == Type.NULL :
182  return NULL
183  elif type == Type.RAW_IMAGE :
184  return "TIVX_TYPE_" + type.name
185  else :
186  return "VX_TYPE_" + type.name
187 
188  def get_vx_name(type) :
189  if type == Type.RAW_IMAGE :
190  return "tivx_" + type.name.lower()
191  else :
192  return "vx_" + type.name.lower()
193 
194  def is_scalar_type(type) :
195  if type > Type.INVALID and type < Type.REFERENCE :
196  return True
197  if type == Type.SCALAR :
198  return True
199  return False
200 
201  def is_array_type(type) :
202  if type > Type.INVALID and type < Type.REFERENCE :
203  return True
204  if type == Type.RECTANGLE :
205  return True
206  if type == Type.KEYPOINT :
207  return True
208  if type == Type.COORDINATES2D :
209  return True
210  if type == Type.COORDINATES3D :
211  return True
212  return False
213 
214  def get_obj_desc_name(type):
215  if Type.is_scalar_type(type) :
216  type = Type.SCALAR
217  return "tivx_obj_desc_" + type.name.lower() + "_t"
218 
219  def get_scalar_obj_desc_data_name(type) :
220  if Type.is_scalar_type(type) :
221  if type is Type.CHAR :
222  return "chr"
223  if type is Type.INT8 :
224  return "s08"
225  if type is Type.UINT8 :
226  return "u08"
227  if type is Type.INT16:
228  return "s16"
229  if type is Type.UINT16:
230  return "u16"
231  if type is Type.INT32:
232  return "s32"
233  if type is Type.UINT32:
234  return "u32"
235  if type is Type.INT64:
236  return "s64"
237  if type is Type.UINT64:
238  return "u64"
239  if type is Type.FLOAT32:
240  return "f32"
241  if type is Type.FLOAT64:
242  return "f64"
243  if type is Type.ENUM :
244  return "enm"
245  if type is Type.SIZE :
246  return "size"
247  if type is Type.DF_IMAGE:
248  return "fcc"
249  if type is Type.BOOL :
250  return "boolean"
251  return "invalid"
252  return "invalid"
253 
254 
263 class DfImage(Enum) :
264 
265  INVALID = 0
266 
267  VIRT = 1
268 
269  RGB = 2
270 
271  RGBX = 3
272 
273  NV12 = 4
274 
275  NV21 = 5
276 
277  UYVY = 6
278 
279  YUYV = 7
280 
281  IYUV = 8
282 
283  YUV4 = 9
284 
285  U8 = 10
286 
287  U16 = 11
288 
289  S16 = 12
290 
291  U32 = 13
292 
293  S32 = 14
294 
295  P12 = 15
296 
297  NV12_P12 = 16
298 
299  RGB565 = 17
300 
301  BGRX = 18
302 
303  def get_vx_enum_name(df_format) :
304  if df_format == DfImage.P12 or df_format == DfImage.NV12_P12 or df_format == DfImage.RGB565 or df_format == DfImage.BGRX :
305  return "TIVX_DF_IMAGE_" + df_format.name
306  else :
307  return "VX_DF_IMAGE_" + df_format.name
308 
309  def get_vx_name(df_format) :
310  if df_format == DfImage.P12 or df_format == DfImage.NV12_P12 or df_format == DfImage.RGB565 or df_format == DfImage.BGRX :
311  return "tivx_df_image_e"
312  else :
313  return "vx_df_image_e"
314 
315  def get_df_enum_from_string(full_df_name) :
316  index = full_df_name.find("VX_DF_IMAGE_")
317  if index == 0 :
318  newstr = full_df_name.replace("VX_DF_IMAGE_", "")
319  if newstr in DfImage.__members__ :
320  return DfImage[newstr]
321  elif index == 2 :
322  newstr = full_df_name.replace("TIVX_DF_IMAGE_", "")
323  if newstr in DfImage.__members__ :
324  return DfImage[newstr]
325  return DfImage.INVALID
326 
327  def get_num_planes(df_format) :
328  if df_format == DfImage.NV12 or df_format == DfImage.NV21 or df_format == DfImage.NV12_P12 :
329  return 2
330  if df_format == DfImage.IYUV or df_format == DfImage.YUV4 :
331  return 3
332  return 1
333 
334 
343 class Channel(Enum) :
344 
345  C0 = 1
346 
347  C1 = 2
348 
349  C2 = 3
350 
351  C3 = 4
352 
353  R = 5
354 
355  G = 6
356 
357  B = 7
358 
359  A = 8
360 
361  Y = 9
362 
363  U = 10
364 
365  V = 11
366 
367  def get_vx_enum_name(type) :
368  if type == Channel.C0 :
369  return "VX_CHANNEL_0"
370  if type == Channel.C1 :
371  return "VX_CHANNEL_1"
372  if type == Channel.C2 :
373  return "VX_CHANNEL_2"
374  if type == Channel.C3 :
375  return "VX_CHANNEL_3"
376  return "VX_CHANNEL_" + type.name
377 
378  def get_vx_name(type) :
379  return "vx_channel_e"
380 
381 class Cpu(Enum) :
382  INVALID = 1
383  DSP1 = 2
384  DSP2 = 3
385  EVE1 = 4
386  EVE2 = 5
387  EVE3 = 6
388  EVE4 = 7
389  A15_0 = 8
390  IPU1_0 = 9
391  IPU1_1 = 10
392  IPU2 = 11
393  DSP_C7_1 = 12
394  A72_0 = 13
395 
396  def get_vx_enum_name(type) :
397  if type.name == "IPU2" :
398  return "TIVX_CPU_ID_IPU2_0"
399  else :
400  return "TIVX_CPU_ID_" + type.name
401 
402 
403 
414 class Target(Enum) :
415 
416  INVALID = 1
417 
418  DSP1 = 2
419 
420  DSP2 = 3
421 
422  EVE1 = 4
423 
424  EVE2 = 5
425 
426  EVE3 = 6
427 
428  EVE4 = 7
429 
430  A15_0 = 8
431 
432  IPU1_0 = 9
433 
434  IPU1_1 = 10
435 
436  IPU2 = 11
437 
439  VPAC_NF = 12
440 
441  VPAC_LDC1 = 13
442 
443  VPAC_LDC2 = 14
444 
445  VPAC_MSC1 = 15
446 
447  VPAC_MSC2 = 16
448 
449  DMPAC_SDE = 17
450 
451  DMPAC_DOF = 18
452 
453  VPAC_VISS1 = 19
454 
455  VDEC1 = 20
456 
457  VDEC2 = 21
458 
459  VENC1 = 22
460 
461  VENC2 = 23
462 
463  DSP_C7_1 = 24
464 
465  A72_0 = 25
466 
468  DEFAULT = DSP1
469 
470  def get_vx_enum_name(type) :
471  return "TIVX_TARGET_" + type.name
472 
473  def get_target_folder_name(type) :
474  if target == Target.DSP1 :
475  return c66
476  if target == Target.DSP2 :
477  return c66
478  if target == Target.EVE1 :
479  return eve
480  if target == Target.EVE2 :
481  return eve
482  if target == Target.EVE3 :
483  return eve
484  if target == Target.EVE4 :
485  return eve
486  if target == Target.A15_0 :
487  return a15
488  if target == Target.IPU1_0 :
489  return ipu
490  if target == Target.IPU1_1 :
491  return ipu
492  if target == Target.IPU2 :
493  return ipu
494  if target == Target.VPAC_NF :
495  return "vpac_nf"
496  if target == Target.VPAC_LDC1 :
497  return "vpac_ldc"
498  if target == Target.VPAC_LDC2 :
499  return "vpac_ldc"
500  if target == Target.VPAC_MSC1 :
501  return "vpac_msc"
502  if target == Target.VPAC_MSC2 :
503  return "vpac_msc"
504  if target == Target.DMPAC_SDE :
505  return "dmpac_sde"
506  if target == Target.DMPAC_DOF :
507  return "dmpac_sde"
508  if target == Target.VPAC_VISS1 :
509  return "vpac_viss"
510  if target == Target.VDEC1 :
511  return "vdec"
512  if target == Target.VDEC2 :
513  return "vdec"
514  if target == Target.VENC1 :
515  return "venc"
516  if target == Target.VENC2 :
517  return "venc"
518  if target == Target.DSP_C7_1 :
519  return "c7x"
520  if target == Target.A72_0 :
521  return "a72"
522  return None
523 
524  def is_j6_target(target) :
525  if target == Target.DSP1 :
526  return True
527  if target == Target.DSP2 :
528  return True
529  if target == Target.EVE1 :
530  return True
531  if target == Target.EVE2 :
532  return True
533  if target == Target.EVE3 :
534  return True
535  if target == Target.EVE4 :
536  return True
537  if target == Target.A15_0 :
538  return True
539  if target == Target.IPU1_0 :
540  return True
541  if target == Target.IPU1_1 :
542  return True
543  if target == Target.IPU2 :
544  return True
545 
546  return False
547 
548  def get_cpu(target) :
549  if target == Target.DSP1 :
550  return Cpu.DSP1
551  if target == Target.DSP2 :
552  return Cpu.DSP2
553  if target == Target.EVE1 :
554  return Cpu.EVE1
555  if target == Target.EVE2 :
556  return Cpu.EVE2
557  if target == Target.EVE3 :
558  return Cpu.EVE3
559  if target == Target.EVE4 :
560  return Cpu.EVE4
561  if target == Target.A15_0 :
562  return Cpu.A15_0
563  if target == Target.IPU1_0 :
564  return Cpu.IPU1_0
565  if target == Target.IPU1_1 :
566  return Cpu.IPU1_1
567  if target == Target.IPU2 :
568  return Cpu.IPU2
569  if target == Target.VPAC_NF :
570  return Cpu.IPU1_0
571  if target == Target.VPAC_LDC1 :
572  return Cpu.IPU1_0
573  if target == Target.VPAC_LDC2 :
574  return Cpu.IPU1_0
575  if target == Target.VPAC_MSC1 :
576  return Cpu.IPU1_0
577  if target == Target.VPAC_MSC2 :
578  return Cpu.IPU1_0
579  if target == Target.DMPAC_SDE :
580  return Cpu.IPU1_0
581  if target == Target.DMPAC_DOF :
582  return Cpu.IPU1_0
583  if target == Target.VPAC_VISS1 :
584  return Cpu.IPU1_0
585  if target == Target.VDEC1 :
586  return Cpu.IPU1_0
587  if target == Target.VDEC2 :
588  return Cpu.IPU1_0
589  if target == Target.VENC1 :
590  return Cpu.IPU1_0
591  if target == Target.VENC2 :
592  return Cpu.IPU1_0
593  if target == Target.DSP_C7_1 :
594  return Cpu.DSP_C7_1
595  if target == Target.A72_0 :
596  return Cpu.A72_0
597  return Cpu.INVALID
598 
599 
608 class Policy(Enum) :
609 
610  WRAP = 1
611 
612  SATURATE = 2
613 
614  def get_vx_enum_name(type) :
615  return "VX_CONVERT_POLICY_" + type.name
616 
617  def get_vx_name(type) :
618  return "vx_convert_policy_e"
619 
620 
629 class Round(Enum) :
630 
631  TO_ZERO = 1
632 
633  TO_NEAREST_EVEN = 2
634 
635  def get_vx_enum_name(type) :
636  return "VX_ROUND_POLICY_" + type.name
637 
638  def get_vx_name(type) :
639  return "vx_round_policy_e"
640 
641 
650 class NonLinearFilter(Enum) :
651 
652  MEDIAN = 1
653 
654  MIN = 2
655 
656  MAX = 3
657 
658  def get_vx_enum_name(type) :
659  return "VX_NONLINEAR_FILTER_" + type.name
660 
661  def get_vx_name(type) :
662  return "vx_non_linear_filter_e"
663 
664 
673 class Pattern(Enum) :
674 
675  BOX = 1
676 
677  CROSS = 2
678 
679  DISK = 3
680 
681  OTHER = 4
682 
683  def get_vx_enum_name(type) :
684  return "VX_PATTERN_" + type.name
685 
686  def get_vx_name(type) :
687  return "vx_pattern_e"
688 
689 
698 class InterpolationType(Enum) :
699 
700  NEAREST_NEIGHBOR = 1
701 
702  BILINEAR = 2
703 
704  AREA = 3
705 
706  def get_vx_enum_name(type) :
707  return "VX_INTERPOLATION_" + type.name
708 
709  def get_vx_name(type) :
710  return "vx_interpolation_type_e"
711 
712 
721 class Bool(Enum) :
722 
723  FALSE = 0
724 
725  TRUE = 1
726 
727  def get_vx_enum_name(type) :
728  return "vx_" + type.name.lower() + "_e"
729 
730  def get_vx_name(type) :
731  return "vx_bool"
732 
733 
742 class Norm(Enum):
743 
744  L1 = 1
745 
746  L2 = 2
747 
748  def get_vx_enum_name(type) :
749  return "VX_NORM_" + type.name
750 
751  def get_vx_name(type) :
752  return "vx_norm_e"
753 
754 
763 class Direction(Enum):
764 
765  INPUT = 1
766 
767  OUTPUT = 2
768 
769  BIDIRECTIONAL = 3
770 
771  def get_vx_enum_name(type) :
772  return "VX_" + type.name
773 
774  def get_vx_name(type) :
775  return "vx_direction_e"
776 
777  def get_access_type(type) :
778  if type == Direction.INPUT:
779  return "VX_READ_ONLY"
780  if type == Direction.OUTPUT:
781  return "VX_WRITE_ONLY"
782  if type == Direction.BIDIRECTIONAL:
783  return "VX_READ_WRITE"
784  return "INVALID"
785 
786  def get_doxygen_name(type) :
787  if type == Direction.INPUT:
788  return "in"
789  if type == Direction.OUTPUT:
790  return "out"
791  if type == Direction.BIDIRECTIONAL:
792  return "in,out"
793  return "INVALID"
794 
795 
796 
805 class ParamState(Enum):
806 
807  REQUIRED = 1
808 
809  OPTIONAL = 2
810 
811  def get_vx_enum_name(type) :
812  return "VX_PARAMETER_STATE_" + type.name
813 
814  def get_vx_name(type) :
815  return "vx_parameter_state_e"
816 
817 
826 class PyramidScale(Enum):
827 
828  HALF = 1
829 
830  ORB = 2
831 
832  def get_vx_enum_name(type) :
833  return "VX_SCALE_PYRAMID_" + type.name
834 
835 
844 class ThresholdType(Enum):
845 
846  BINARY = 1
847 
848  RANGE = 2
849 
850  def get_vx_enum_name(type) :
851  return "VX_THRESHOLD_TYPE_" + type.name
852 
853  def get_vx_name(type) :
854  return "vx_threshold_type_e"
855 
856 
866 class TermCriteria(Enum):
867 
868  ITERATIONS = 1
869 
870  EPSILON = 2
871 
872  BOTH = 3
873 
874  def get_vx_enum_name(type) :
875  return "VX_TERM_CRITERIA_" + type.name
876 
877  def get_vx_name(type) :
878  return "vx_termination_criteria_e"
Image channel (OpenVX equivalent = vx_channel_e)
Definition: enums.py:343
Parameter state (OpenVX equivalent = vx_parameter_state_e)
Definition: enums.py:805
Interpolation type (OpenVX equivalent = vx_interpolation_type_e)
Definition: enums.py:698
Target on which to execute a node (TIOVX equivalent = TIVX_TARGET_xxxx)
Definition: enums.py:414
Image data format (OpenVX equivalent = vx_df_image_e)
Definition: enums.py:263
Termination Criteria (OpenVX equivalent = vx_termination_criteria_e)
Definition: enums.py:866
Threshold Type (OpenVX equivalent = vx_threshold_type_e)
Definition: enums.py:844
Boolean type (OpenVX equivalent = vx_bool)
Definition: enums.py:721
Pyramid Scale (OpenVX equivalent = VX_SCALE_PYRAMID_xxx)
Definition: enums.py:826
Normalization type (OpenVX equivalent = vx_norm_type_e)
Definition: enums.py:742
Non linear filter type (OpenVX equivalent = vx_non_linear_filter_e)
Definition: enums.py:650
Object/Data type (OpenVX equivalent = vx_type_e)
Definition: enums.py:75
Conversion Policy (OpenVX equivalent = vx_convert_policy_e)
Definition: enums.py:608
Parameter direction (OpenVX equivalent = vx_direction_e)
Definition: enums.py:763
Round Policy (OpenVX equivalent = vx_round_policy_e)
Definition: enums.py:629
Matrix Patterns (OpenVX equivalent = vx_pattern_e)
Definition: enums.py:673