TIOVX User Guide
vx_tutorial_graph_user_kernel_pytiovx_uc.py
Go to the documentation of this file.
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 
78 
79 from tiovx import *
80 
81 
84 class NodePhaseRgb (Node) :
85 
91  def __init__(self, image_in, image_out, name="default", target=Target.DEFAULT) :
92  Node.__init__(self, "vx_tutorial_graph.phase_rgb", image_in, image_out)
93  self.setParams(1, 1, Type.IMAGE, Type.IMAGE)
94  self.setTarget(target)
95  self.setKernelEnumName("VX_USER_KERNEL")
96 
97 
103  def checkParams(self, *param_type_args) :
104  # invoke base class checker function
105  Node.checkParams(self, *param_type_args)
106  # additional error conditions over the basic ones
107  assert ( self.ref[0].width == self.ref[1].width ), "Input and Output width MUST match"
108  assert ( self.ref[0].height == self.ref[1].height ), "Input and Output height MUST match"
109  assert ( self.ref[0].df_image == DfImage.U8 ), "Input data format must be U8"
110  assert ( self.ref[1].df_image == DfImage.RGB ), "Output data format must be RGB"
111 
112 
113 def make_my_graph() :
114 
115  context = Context("vx_tutorial_graph_user_kernel_pytiovx_uc")
116 
117 
118  graph = Graph()
119 
120 
121  width = 640
122 
123  height = 480
124 
125 
126  in_image = Image(width, height, DfImage.U8, name="input")
127 
128 
129  grad_x = Image(width, height, DfImage.S16, name="grad_x")
130 
131 
132  grad_y = Image(width, height, DfImage.S16, name="grad_y")
133 
134 
135  phase = Image(width, height, DfImage.U8, name="phase")
136 
137 
138  phase_rgb = Image(width, height, DfImage.RGB, name="phase_rgb")
139 
140 
141  graph.add ( NodeSobel3x3(in_image, grad_x, grad_y, target=Target.DSP1) )
142 
143 
144  graph.add ( NodePhase(grad_x, grad_y, phase, target=Target.DSP1) )
145 
146 
147  graph.add ( NodePhaseRgb(phase, phase_rgb, target=Target.DSP1) )
148 
149 
150  context.add ( graph )
151 
152 
153  ExportImage(context).export()
154 
155  ExportCode(context).export()
156 
157 make_my_graph()
def __init__(self, image_in, image_out, name="default", target=Target.DEFAULT)
Constructor for user/target kernel class.
Export objects from context to JPG image file.
Definition: export_image.py:83
Graph object (OpenVX equivalent = vx_graph)
Definition: graph.py:85
def setTarget(self, target)
Specify target on which to run this node.
Definition: node.py:339
Image object (OpenVX equivalent = vx_image, specifically returned from vxCreateImage) ...
Definition: image.py:104
Node object used to generate a Sobel3x3 node.
Definition: node.py:1592
def setKernelEnumName(self, kernel_enum_name)
Specify kernel enum name to use.
Definition: node.py:354
Context object (OpenVX equivalent = vx_context)
Definition: context.py:80
Export objects from context to C source code.
Definition: export_code.py:102
def setParams(self, num_in, num_out, param_type_args)
Specify number of input/output parameters and data object type for each.
Definition: node.py:327
Node object used to generate a Phase node.
Definition: node.py:1438
def checkParams(self, param_type_args)
Parameter checking function.
Node object (OpenVX equivalent = vx_node)
Definition: node.py:290