@l4es I added an example here: luxonis/depthai-python883, also pasted below
Modified cam_test.py:
https://github.com/luxonis/depthai-python/compare/main...alex-luxonis:depthai-python:fsync_gpio_ffc_4p
(alex-luxonis/depthai-pythonedc5666
)
Mainly added a new Script node with the content:
import time
import GPIO
# Script static arguments
fps = %f
calib = Device.readCalibration2().getEepromData()
prodName = calib.productName
boardName = calib.boardName
boardRev = calib.boardRev
node.warn(f'Product name : {prodName}')
node.warn(f'Board name : {boardName}')
node.warn(f'Board revision: {boardRev}')
revision = -1
# Very basic parsing here, TODO improve
if len(boardRev) >= 2 and boardRev[0] == 'R':
revision = int(boardRev[1])
node.warn(f'Parsed revision number: {revision}')
# Defaults for OAK-FFC-4P older revisions (<= R5)
GPIO_FSIN_2LANE = 41 # COM_AUX_IO2
GPIO_FSIN_4LANE = 40
GPIO_FSIN_MODE_SELECT = 6 # Drive 1 to tie together FSIN_2LANE and FSIN_4LANE
if revision >= 6:
GPIO_FSIN_2LANE = 41 # still COM_AUX_IO2, no PWM capable
GPIO_FSIN_4LANE = 42 # also not PWM capable
GPIO_FSIN_MODE_SELECT = 38 # Drive 1 to tie together FSIN_2LANE and FSIN_4LANE
# Note: on R7 GPIO_FSIN_MODE_SELECT is pulled up, driving high isn't necessary (but fine to do)
# GPIO initialization
GPIO.setup(GPIO_FSIN_2LANE, GPIO.OUT)
GPIO.write(GPIO_FSIN_2LANE, 0)
GPIO.setup(GPIO_FSIN_4LANE, GPIO.IN)
GPIO.setup(GPIO_FSIN_MODE_SELECT, GPIO.OUT)
GPIO.write(GPIO_FSIN_MODE_SELECT, 1)
period = 1 / fps
active = 0.001
node.warn(f'FPS: {fps} Period: {period}')
withInterrupts = False
if withInterrupts:
node.critical(f'[TODO] FSYNC with timer interrupts (more precise) not implemented')
else:
overhead = 0.003 # Empirical, TODO add thread priority option!
while True:
GPIO.write(GPIO_FSIN_2LANE, 1)
time.sleep(active)
GPIO.write(GPIO_FSIN_2LANE, 0)
time.sleep(period - active - overhead)
And configured the enabled cameras in sync mode:
# Num frames to capture on trigger, with first to be discarded (due to degraded quality)
# Note: Only OV9282/9782 supports dropping frames. For AR0234 the arguments passed here have no effect
# Note2: in this mode it's best to set sensor FPS as max supported (e.g 60) to avoid missed triggers,
# as exposure starts immediately after trigger and is not overlapped with previous frame MIPI readout
#cam[c].initialControl.setExternalTrigger(1, 0)
# Note: setFrameSyncMode takes priority over setExternalTrigger (if both are set)
cam[c].initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT)
Getting with 3 AR0234 attached on A,B,C ports and cable FSIN soldered to TRIGGER pin of Arducam module
python3 utilities/cam_test.py -cams cama,c camb,c camc,c -cres 1200 -ds 2 -fps 30 -show
[mxid] [3.1] [4.141] [Script(8)] [warning] Product name : OAK-FFC 4P
[mxid] [3.1] [4.141] [Script(8)] [warning] Board name : DD2090
[mxid] [3.1] [4.141] [Script(8)] [warning] Board revision: R5M1E5
[mxid] [3.1] [4.141] [Script(8)] [warning] Parsed revision number: 5
[mxid] [3.1] [4.142] [Script(8)] [warning] FPS: 30.0 Period: 0.03333333333333333
...
FPS: 28.10| 28.30 28.30| 28.30 28.29| 28.30
[cama , 100, 1159028.071043] Exp: 30.000 ms, ISO: 198, Lens pos: -1, Color temp: 5386 K
[camb , 100, 1159028.071054] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
[camc , 99, 1159028.071063] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
FPS: 28.43| 28.38 28.43| 28.38 28.43| 28.38
[cama , 101, 1159028.104990] Exp: 30.000 ms, ISO: 198, Lens pos: -1, Color temp: 5380 K
[camb , 101, 1159028.105001] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
[camc , 100, 1159028.105012] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
FPS: 28.35| 28.38 28.40| 28.38 28.48| 28.38
[cama , 102, 1159028.139839] Exp: 30.000 ms, ISO: 198, Lens pos: -1, Color temp: 5374 K
[camb , 102, 1159028.139851] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
[camc , 101, 1159028.139862] Exp: 30.000 ms, ISO: 177, Lens pos: -1, Color temp: 5351 K
FPS: 28.54| 28.38 28.36| 28.38 28.37| 28.38