depthai
depthai copied to clipboard
[Feature-Request] Add ability to pass extra arguments to callbacks
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.