jakaskerl
I'm already using depthai 2.25.0.0. I've entered the same config I got from ISP but the resulting images are quite different. I updated the code above a bit and performed the following to test. I expected image 2 to be the same as image 1; my understanding is that ISO, exposure time, and temperature are pretty much the parameters that change how the image would look.
- press "\" to print current ISP frame temperature, ISO, exposure time
- press "m" to set white balance temperature, press "l" to set iso and exposure
- press "\" to print updated ISP frame temperature, ISO, exposure to ensure it is the same as step 1
Please let me know if other settings need to be changed because I've already entered the same parameters as the reference image but the image I obtained differs.
#!/usr/bin/env python3
import depthai as dai
import cv2
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)
camRgb.setIspScale(2,3) # 1080P -> 720P
controlIn = pipeline.create(dai.node.XLinkIn)
ispOut = pipeline.create(dai.node.XLinkOut)
controlIn.setStreamName('control')
ispOut.setStreamName('isp')
# Properties
camRgb.setVideoSize(640,360)
# Linking
camRgb.isp.link(ispOut.input)
controlIn.out.link(camRgb.inputControl)
frame_info = {
"seqNum": 0,
"exp": 0,
"iso": 0,
"lenspos": 0,
"color_temp": 0
}
# Connect to device and start pipeline
with dai.Device(pipeline) as device:
# Get data queues
controlQueue = device.getInputQueue('control')
ispQueue = device.getOutputQueue('isp')
# Defaults and limits for manual focus/exposure controls
expTime = 20000
sensIso = 800
wbManual = 4000
show = False
while True:
ispFrames = ispQueue.tryGetAll()
for ispFrame in ispFrames:
if show:
frame_info['seqNum'] = ispFrame.getSequenceNum()
frame_info['exp'] = ispFrame.getExposureTime().total_seconds()*1000
frame_info['iso'] = ispFrame.getSensitivity()
frame_info['lenspos'] = ispFrame.getLensPosition()
frame_info['color_temp'] = ispFrame.getColorTemperature()
txt = f"[{frame_info['seqNum']}] "
txt += f"Exposure: {frame_info['exp']:.3f} ms, "
txt += f"ISO: {frame_info['iso']}, "
txt += f"Lens position: {frame_info['lenspos']}, "
txt += f"Color temp: {frame_info['color_temp']} K"
print(txt)
cv2.imshow('isp', ispFrame.getCvFrame())
# Update screen (1ms pooling rate)
key = cv2.waitKey(1)
if key == ord('q'):
break
elif key == ord('/'):
show = not show
if not show: print("Printing camera settings: OFF")
elif key == ord('f'):
print("Autofocus enable, continuous")
ctrl = dai.CameraControl()
ctrl.setAutoFocusMode(dai.CameraControl.AutoFocusMode.CONTINUOUS_VIDEO)
controlQueue.send(ctrl)
elif key == ord('b'):
print("Auto white-balance enable")
ctrl = dai.CameraControl()
ctrl.setAutoWhiteBalanceMode(dai.CameraControl.AutoWhiteBalanceMode.AUTO)
controlQueue.send(ctrl)
elif key in [ord('i'), ord('k'), ord('l')]:
if key == ord('i'): expTime -= EXP_STEP
if key == ord('k'): sensIso -= ISO_STEP
if key == ord('l'):
sensIso = frame_info['iso']
expTime = frame_info['exp']
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)
elif key in [ord('n'), ord('m')]:
if key == ord('n'): wbManual = 1000
if key == ord('m'): wbManual = frame_info['color_temp']
wbManual = clamp(wbManual, 1000, 12000)
print("Setting manual white balance, temperature: ", wbManual, "K")
ctrl = dai.CameraControl()
ctrl.setManualWhiteBalance(wbManual)
controlQueue.send(ctrl)