Skip to content

Commit

Permalink
Fixed script json communication example
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Jan 4, 2022
1 parent f97cdc5 commit f47dcdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion depthai-core
24 changes: 11 additions & 13 deletions examples/Script/script_json_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@
script = pipeline.create(dai.node.Script)
xin.out.link(script.inputs['in'])
script.setScript("""
import json
import json
# Recieve bytes from the host
data = node.io['in'].get().getData()
jsonStr = str(data, 'utf-8')
dict = json.loads(jsonStr)
# Recieve bytes from the host
data = node.io['in'].get().getData()
jsonStr = str(data, 'utf-8')
dict = json.loads(jsonStr)
# Change initial dictionary a bit
node.warn('Original: ' + str(dict))
dict['one'] += 1
dict['foo'] = "baz"
node.warn('Changed: ' + str(dict))
# Change initial dictionary a bit
dict['one'] += 1
dict['foo'] = "baz"
b = Buffer(30)
b.setData(json.dumps(dict).encode('utf-8'))
node.io['out'].send(b)
b = Buffer(30)
b.setData(json.dumps(dict).encode('utf-8'))
node.io['out'].send(b)
""")

xout = pipeline.create(dai.node.XLinkOut)
Expand Down

0 comments on commit f47dcdf

Please sign in to comment.