depthai icon indicating copy to clipboard operation
depthai copied to clipboard

[Feature-Request] Add ability to pass extra arguments to callbacks

Open zrezke opened this issue 1 year ago • 0 comments

Start with the why:

In depthai_sdk there is currently no way to pass extra args to callbacks. This makes the callbacks have a fixed function and there is no (non hacky) way to decide what to do in the callback based on some parameters.

Move to the what:

When registering a callback with oak.callback(), you should be able to pass in extra parameters like this:

def callback(packet):
    pass

with OakCamera(device) as oak:
    color = oak.create_camera("color")
    kwarg1 = "kwarg1"
    oak.callback(color, callback, kwarg1=kwarg1)

Move to the how:

Add **kwargs to the callback function and pass those to the callback.

zrezke avatar May 23 '23 19:05 zrezke