Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue classes missing method 'addCallback' in on-device interpreter (Script node) #585

Open
filiphhh opened this issue May 22, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@filiphhh
Copy link

Hello!

I am trying to use queue callbacks for simpler message handling when passing data between my OAK-D and host and noticed it seems to be missing from the on-device depthai module.

Sample code:

import depthai
import time

pipeline = depthai.Pipeline()

xin = pipeline.create(depthai.node.XLinkIn)
xin.setStreamName('in')

script = pipeline.create(depthai.node.Script)
xin.out.link(script.inputs['in'])
script.setScript("""
    import time

    def test(frame):
        node.warn("Test")

    node.io['in'].addCallback(test)

    while True:
        time.sleep(1)
""")

xout = pipeline.create(depthai.node.XLinkOut)
xout.setStreamName('script')
script.outputs['out'].link(xout.input)

with depthai.Device(pipeline) as device:
    while True:
        buffer = depthai.Buffer()
        device.getInputQueue('in').send(buffer)
        time.sleep(1)

Output:

[Script(2)] [critical] AttributeError: 'lpb.DataOutputQueue' object has no attribute 'addCallback'

Expected output:

[Script(2)] [warning] Test
[Script(2)] [warning] Test
[Script(2)] [warning] Test
...

I would like to avoid using a series tryGets within the script node while loop like in the gen2-age-gender experiment just to be able to match inputs with their respective functions and outputs.

@themarpe themarpe added the enhancement New feature or request label May 24, 2022
@themarpe
Copy link
Collaborator

@filiphhh
Thanks for the request for the enhancement. We'lll have to implement that over at device side.

For the time being, you may circumvent this by creating a thread that uses get on a queue in question and afterwards notifies / callbacks a certain function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants