forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_nndata_example.py
More file actions
executable file
·33 lines (27 loc) · 918 Bytes
/
script_nndata_example.py
File metadata and controls
executable file
·33 lines (27 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import depthai as dai
import time
# Start defining a pipeline
pipeline = dai.Pipeline()
# Script node
script = pipeline.create(dai.node.Script)
script.setScript("""
buf = NNData(150)
buf.setLayer("fp16", [1.0, 1.2, 3.9, 5.5])
buf.setLayer("uint8", [6, 9, 4, 2, 0])
node.warn("Names of layers: " + str(buf.getAllLayerNames()))
node.io['host'].send(buf)
""")
# XLinkOut
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('host')
script.outputs['host'].link(xout.input)
# Connect to device with pipeline
with dai.Device(pipeline) as device:
device.setLogLevel(dai.LogLevel.WARN)
device.setLogOutputLevel(dai.LogLevel.WARN)
nndata = device.getOutputQueue("host").get()
time.sleep(0.5)
print(f"NNData size: {len(nndata.getData())}")
print("FP16 values:", nndata.getLayerFp16("fp16"))
print("UINT8 values:",nndata.getLayerUInt8("uint8"))