-
Notifications
You must be signed in to change notification settings - Fork 235
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
Scripting Support on DepthAI #207
Comments
As an update, we do have microPython now compiled and printing "hello world" from DepthAI. |
Will you also be including a numpy-like library to help manipulate data between pipeline stages, e.g. https://github.com/v923z/micropython-ulab? |
Good idea. CC: @jonngai |
So @rychardeh - we will be supporting ulab. Great idea and thanks for bringing this up. |
Status update: To summarize, here’s what we have: |
As another update on this, when trying to get microPython to thread so that it can be used in any number of nodes arbitrarily placed in a pipeline, we ran into many multithreading issues. We tracked down and fixed many of them, and then found a micropython bug causing reliable periodic crashing. We narrowed it down to specifically when the GC ran and we started more than 1 thread using the python exec() method. We found the best way to deal with it is just to not use exec in threads... But, in parallel, we investigated using CPython instead of microPython altogether, and it seems to be a better solution to what we are trying to enable here. So the upside is that with CPython this will actually be more powerful. The downside is some our microPython work to date won't be used. But it was useful in learning and getting to a better/more-robust final solution with CPython. And a lot of the intefacing mechanisms we made (which were a lot of the time) are directly reusable, as microPython and CPython are very similar, with micropython just quite stripped down. So the status now is that we're currently adding bindings for all of our message types (Buffer, ImgFrame, NNData, ImageManipConfig, CameraControl, ImgDetections, SystemInformation) to CPython. We'll keep everyone updated as we make it further to getting this out as a capability as a node in the Gen2 pipeline builder. |
This CPython implementation is now available for anyone who'd like to play with it: See the And an example script is here: In a nutshell, onboard the device a CPython3.9 implementation is running with many modules removed to not bloat FW size too much. Each node gets its own subinterpreter and starts executing the given script once the pipeline starts. There are 2 special global variables:
These hold current node object and pipeline object. These give you access to eg assets of current node or pipeline node and loggers For
IO match host Right now there are Feel free to play around and break stuff - we haven't done much stability testing yet :) You can call node.trace, Outside of existing messages ( There is also (Note, python library might not be prebuilt - feel free to compile locally) Next up in the works is HW access (GPIO, SPI & I2C), while SDCard and other device access should be accessible with standard Python language features. |
It looks like the |
Hello @nemccarthy , we have already merged the |
This is now implemented and documented here. |
…tions Add ImageManipConfig helper functions
Start with the
why
:When running DephtAI in an embedded use-case where there is no other processor involved (like here), it is necessary to have custom code run directly on DepthAI for many applications, like implementing rulesets and filtering of meta-data to determine when regions of interest to pass between stages of inference as in #136, or to talk directly with actuators, or implement custom SPI, UART, or I2C communication with sensors or other devices.
Move to the
how
:We are now sponsors of microPython!We have initially compiled it for DepthAI (running directly on the platform), and we will be implementing the capability for microPython to run in nodes in Pipeline Builder Gen2 (#136).In implementing microPython (see comments in this issue) we discovered that supporting the
why
here would actually be better served by CPython bindings directly on DepthAI. So we hard-pivoted from microPython to CPython. And this actually allows more functionality, accessible with standard Python language features.Move to the
what
:Implement the capability for
microPythonCPython to run directly on DepthAI as nodes in the Gen2 Pipeline Builer.The text was updated successfully, but these errors were encountered: