Skip to content

Commit f47dcdf

Browse files
committed
Fixed script json communication example
1 parent f97cdc5 commit f47dcdf

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

depthai-core

examples/Script/script_json_communication.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@
1010
script = pipeline.create(dai.node.Script)
1111
xin.out.link(script.inputs['in'])
1212
script.setScript("""
13-
import json
13+
import json
1414
15-
# Recieve bytes from the host
16-
data = node.io['in'].get().getData()
17-
jsonStr = str(data, 'utf-8')
18-
dict = json.loads(jsonStr)
15+
# Recieve bytes from the host
16+
data = node.io['in'].get().getData()
17+
jsonStr = str(data, 'utf-8')
18+
dict = json.loads(jsonStr)
1919
20-
# Change initial dictionary a bit
21-
node.warn('Original: ' + str(dict))
22-
dict['one'] += 1
23-
dict['foo'] = "baz"
24-
node.warn('Changed: ' + str(dict))
20+
# Change initial dictionary a bit
21+
dict['one'] += 1
22+
dict['foo'] = "baz"
2523
26-
b = Buffer(30)
27-
b.setData(json.dumps(dict).encode('utf-8'))
28-
node.io['out'].send(b)
24+
b = Buffer(30)
25+
b.setData(json.dumps(dict).encode('utf-8'))
26+
node.io['out'].send(b)
2927
""")
3028

3129
xout = pipeline.create(dai.node.XLinkOut)

0 commit comments

Comments
 (0)