Hi, I built an app that uses the object tracker class to monitor the position of certain objects. Now, I want to test how well the object tracker handles situations where the outputs of the detection network are delayed. In order to do so, I want to insert a script node that waits some time before handing over the image to the object detection network.

In the main script, I added a preprocessing node like this:

nndetprepr = pipeline.create(dai.node.Script)
nndetprepr.setProcessor(dai.ProcessorType.LEON_CSS)
nndet_image_manip.out.link(nndetprepr.inputs["nndet_image_preproc_in"])

with open("delay.py", "r") as f:   
    nndetprepr.setScript(f.read())

< Definition of the detection network … >
nndet_image_manip.out.link(nndet.input)

As outlined above, the delay script should hand over the image after some time:

while True:
    img = node.io["nndet_image_preproc_in"].tryGet()
    time.sleep(0.1)
    node.io["nndet_image_preproc_out"].send(img)

However. when starting the app, I get the following error:

SystemError: Exception escaped from default exception translator

Any ideas?

    Hi StefanWerner
    The error message "Exception escaped from default exception translator" is quite generic and does not give much information about the root cause of the error. It usually means that an exception was thrown but not caught in your script, which is probably in the delay.py file.

    Your main script looks correct, but there are a couple of things to consider in your delay.py script:

    tryGet() method: It's non-blocking and will return None if there is no available data. This means you will pass None to the send method, which might be causing the error.

    Sending the image back to the main script: You might not be sending the image back correctly. The send method should work with the data types that are expected.

    Here's an updated version of your delay.py script that checks for None before sending the image and also uses get method which is blocking:

    while True:
        img = node.io["nndet_image_preproc_in"].get()
        if img is not None:
            time.sleep(0.1)
            node.io["nndet_image_preproc_out"].send(img)

    Try this change and see if it helps.

    Thanks,
    Jaka