• DepthAI-v2
  • How to setup Script node to be a function of values sent from host

Hi, I would like to run a custom script on my camera (via a Script node) but change its behavior based on values sent over from the host computer. For example, I can use a CameraControl node to adjust the exposure time on the camera. I would like to have this same functionality but be able to adjust values in my custom script based on messages sent from the host. Ultimately, my goal is to essentially add the ability to adjust the ISP scaling on the fly by instead using the resize() function from OpenCV. The amount of ISP scaling needed will be sent over from the host.

More specifically, would I use a Buffer object to send my data from the host to the camera? How do I identify and unpackage that data within the script defined in the Script node? Could you also point me to an example where an ImgFrame object is modified in a Script node and then sent to and received by the host? Thanks!

    Hey @erik, this is exactly what I am looking for, thanks!

    Is there another example that shows how to modify an ImgFrame object in the Script Node script and then send that to the host? Also, am I able to use OpenCV functions in my script? Are there constraints on the python imports the camera will support?

    • erik replied to this.

      Ok great, thanks for the help! So if I call tryGetAll() in the Script Node and then modify that image, is it this new image that gets sent over to the host when I call tryGetAll() on the host side?

      Also, is there any current method to change the ISP scaling on the fly while the camera is running? From what I can tell, it looks like this needs to be set in the ColorCamera node before the device is initialized.

        Hi jjc999
        Should be yes, but keep in mind that tryGetAll() will get all frames in the queue if the queue has them. For a single frame, use tryGet() or get().

        No way to change the isp downscale or sensor resolution as far as I'm aware.

        Thanks,
        Jaka