@fredrik Your code looks good. I can reproduce the same type of failure, with the 10Hz 3.3V signal applied on pin 1 (AUX_GPIO_3V3). I just replaced the script content from this example luxonis/depthai-pythonblob/main/examples/Script/script_camera_control.py
with yours from above. Sometimes it runs for a few minutes, but eventually fails the same. Will debug this firmware problem.
An unrelated note is that AUX_GPIO_3V3
also has another GPIO to control the direction (of a 3.3V<->1.8V level shifter), but by default the 3.3V side is an input, so this code is optional:
AUX_GPIO_DIR_CTRL = 6
GPIO.setup(AUX_GPIO_DIR_CTRL, GPIO.OUT, GPIO.PULL_NONE)
GPIO.write(AUX_GPIO_DIR_CTRL, 0) # AUX_GPIO_3V3 (52) direction control: 0=input, 1=output
Mentioning just in case at some point is desired to set it as output. (We should also see about abstracting these in FW.)
However about the usage of .setCaptureStill
, internally this doesn't trigger a new frame capture, but just sets a flag for the new frame from the camera to be processed/sent on the ColorCamera .still
output. So by default the camera would stream at the 30fps rate, unsynced. I'm not exactly sure if this suits your needs, or you would rather want to change the cameras to fsync-input mode, for example editing in:
luxonis/depthai-pythonblob/main/utilities/cam_test.py
to uncomment cam[c].initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT)
and applying an e.g 12V 10Hz signal on FSYNC (M8 pin 2, with GND_ISO on pin 7), then run:
python3 utilities/cam_test.py -rs -cams rgb,c left,m right,m -fps 10
It's still possible to add a script to get events on FSYNC GPIO (which goes both to sensors and to an SoC pin), but currently it might suffer from the same issue that it might crash the app after some time:
script = pipeline.create(dai.node.Script)
script.setScript("""
import GPIO
import time
# Note: level gets inverted due to isolation circuitry
FSYNC_GPIO = 41
GPIO.setup(FSYNC_GPIO, GPIO.IN, GPIO.PULL_DOWN)
GPIO.setInterrupt(FSYNC_GPIO, GPIO.RISING, 128)
node.warn('Waiting for interrupts...')
while True:
ret = GPIO.waitInterruptEvent(FSYNC_GPIO)
node.warn(f'GPIO interrupt: {ret}')
""")
It seems to run longer (couldn't reproduce a crash yet) with interrupt priority set to 128 (range 0..255) instead of 1, but needs more debugging to understand the issue.
Instead, it should be possible to check the timestamps of the received frames, that are aligned to the host monotonic time (dai.Clock.now()
)
Adding in cam_test.py e.g before frame = pkt.getCvFrame()
:
print(c, pkt.getTimestamp().total_seconds(), pkt.getTimestampDevice().total_seconds())
The timestamps by default are aligned to end of exposure window: https://docs.luxonis.com/projects/hardware/en/latest/pages/guides/sync_frames/?highlight=fsin#frame-capture-graphs