Hi all ,
I have this MRE that basically modifies the exposure time and iso sensitivity of the camera while displaying images.I want to be able to see the default values of the camera at the start of the camera or the current values at any time but I want to extract the values from the camera. Is that possible ? do I need to create another node for this ?
Thank you in advance
import depthai as dai
import cv2
from itertools import cycle
EXP_STEP = 500 # us
ISO_STEP = 50
def clamp(num, v0, v1):
return max(v0, min(num, v1))
# Create pipeline
pipeline = dai.Pipeline()
# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
controlIn = pipeline.create(dai.node.XLinkIn)
rgbOut = pipeline.create(dai.node.XLinkOut)
controlIn.setStreamName('control')
rgbOut.setStreamName('rgb')
# Properties
camRgb.setVideoSize(640,640)
camRgb.setPreviewSize(640,640)
# Linking
camRgb.preview.link(rgbOut.input)
controlIn.out.link(camRgb.inputControl)
with dai.Device(pipeline) as device:
# Get data queues
controlQueue = device.getInputQueue('control')
rgbQueue = device.getOutputQueue('rgb')
expTime = 20000
sensIso = 800
while True:
ispFrame = rgbQueue.get()
ispFrame = cv2.resize(ispFrame.getCvFrame() , (640,640))
cv2.imshow('isp', ispFrame)
key = cv2.waitKey(1)
if key in [ord('i'), ord('o'), ord('k'), ord('l')]:
if key == ord('i'): expTime -= EXP_STEP
if key == ord('o'): expTime += EXP_STEP
if key == ord('k'): sensIso -= ISO_STEP
if key == ord('l'): sensIso += ISO_STEP
expTime = clamp(expTime, 1, 33000)
sensIso = clamp(sensIso, 100, 1600)
print("Setting manual exposure, time: ", expTime, "iso: ", sensIso)
ctrl = dai.CameraControl()
ctrl.setManualExposure(expTime, sensIso)
controlQueue.send(ctrl)