103 def make_my_graph() :
105 context = Context(
"vx_tutorial_graph_image_gradients_pytiovx_uc")
116 in_image = Image(width, height, DfImage.U8, name=
"input")
119 grad_x = Image(width, height, DfImage.S16, name=
"grad_x")
122 grad_y = Image(width, height, DfImage.S16, name=
"grad_y")
125 magnitude = Image(width, height, DfImage.S16, name=
"magnitude")
128 phase = Image(width, height, DfImage.U8, name=
"phase")
131 grad_x_img = Image(width, height, DfImage.U8, name=
"grad_x_img")
134 grad_y_img = Image(width, height, DfImage.U8, name=
"grad_y_img")
137 magnitude_img = Image(width, height, DfImage.U8, name=
"magnitude_img")
140 shift = Scalar(Type.INT32, 0, name=
"shift")
143 graph.add ( NodeSobel3x3(in_image, grad_x, grad_y, target=Target.DSP1) )
146 graph.add ( NodeMagnitude(grad_x, grad_y, magnitude, target=Target.DSP2) )
149 graph.add ( NodePhase(grad_x, grad_y, phase, target=Target.DSP1) )
152 graph.add ( NodeConvertDepth(magnitude, magnitude_img, Policy.SATURATE, shift, target=Target.DSP2) )
155 graph.add ( NodeConvertDepth(grad_x, grad_x_img, Policy.SATURATE, shift, target=Target.DSP2) )
158 graph.add ( NodeConvertDepth(grad_y, grad_y_img, Policy.SATURATE, shift, target=Target.DSP1) )
161 context.add ( graph )
164 ExportImage(context).export()
166 ExportCode(context).export()