Hi criclabs
No, mono cameras do not have a still
output. There is an option to use the external trigger (explained here).
I found a better example, essentially using the GPIO pins to take mono still images when pressing "c":
#!/usr/bin/env python3
import depthai as dai
import cv2
import time
pipeline = dai.Pipeline()
monoLeft = pipeline.create(dai.node.MonoCamera)
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
monoLeft.initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT)
monoLeft.initialControl.setExternalTrigger(4,3)
xoutLeft = pipeline.create(dai.node.XLinkOut)
xoutLeft.setStreamName("left")
monoLeft.out.link(xoutLeft.input)
monoRight = pipeline.createMonoCamera()
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT)
monoRight.initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT)
monoRight.initialControl.setExternalTrigger(4,3)
xoutRight = pipeline.create(dai.node.XLinkOut)
xoutRight.setStreamName("right")
monoRight.out.link(xoutRight.input)
xin = pipeline.create(dai.node.XLinkIn)
xin.setStreamName('in')
script = pipeline.create(dai.node.Script)
xin.out.link(script.inputs['in'])
script.setScript("""
import GPIO
import time
GPIO_PIN=41 # Trigger
GPIO.setup(GPIO_PIN, GPIO.OUT, GPIO.PULL_DOWN)
def capture():
GPIO.write(GPIO_PIN, True)
time.sleep(0.001) # 1ms pulse is enough
GPIO.write(GPIO_PIN, False)
while True:
wait_for_trigger = node.io['in'].get()
capture()
node.warn('Trigger successful')
""")
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('out')
script.outputs['out'].link(xout.input)
# Connect to device with pipeline
with dai.Device(pipeline) as device:
inQ = device.getInputQueue("in")
arr = ['left', 'right']
queues = {}
frames = {}
for name in arr:
queues[name] = device.getOutputQueue(name)
def trigger():
buffer = dai.Buffer()
buffer.setData([1])
inQ.send(buffer)
time.sleep(1)
trigger() # Inital trigger
while True:
for name in arr:
if queues[name].has():
frames[name]=queues[name].get().getCvFrame()
for name, frame in frames.items():
cv2.imshow(name, frame)
key = cv2.waitKey(1)
if key == ord('q'):
break
elif key == ord('c'):
trigger()
Hope this solves your issue.
Thanks,
Jaka