Skip to content

Commit 74f0144

Browse files
committed
FW: IMX678 binning option (1080p, 60fps), IMX582 HDR:
- better config for 10fps HDR - runtime configurable hdr-exposure-ratio (1,2,4,8), hdr-local-tone-weight (0..1, float normalized) cam_test.py `R` and `G` keys to select HDR controls, then change with `-_` `+=`
1 parent 2d8fabc commit 74f0144

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

depthai-core

utilities/cam_test.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from pathlib import Path
5050
import sys
5151
import signal
52-
52+
import math
5353

5454
def socket_type_pair(arg):
5555
socket, type = arg.split(',')
@@ -409,6 +409,12 @@ def exit_cleanly(signum, frame):
409409
control = 'none'
410410
show = args.show_meta
411411
high_conversion_gain = 1
412+
print(args.misc_controls)
413+
args_misc_dict = dict(args.misc_controls)
414+
415+
hdr_exp_ratio = int(math.log2(float(args_misc_dict.get('hdr-exposure-ratio', 1))))
416+
hdr_local_tone_weight = int(32 * float(args_misc_dict.get('hdr-local-tone-weight', 0.75)))
417+
hdr_on = (hdr_exp_ratio > 0)
412418

413419
jet_custom = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_JET)
414420
jet_custom[0] = [0, 0, 0]
@@ -505,11 +511,18 @@ def exit_cleanly(signum, frame):
505511
elif key == ord('c'):
506512
capture_list = streams.copy()
507513
capture_time = time.strftime('%Y%m%d_%H%M%S')
508-
elif key == ord('g') and tof:
509-
f_mod = dai.RawToFConfig.DepthParams.TypeFMod.MAX if tofConfig.depthParams.freqModUsed == dai.RawToFConfig.DepthParams.TypeFMod.MIN else dai.RawToFConfig.DepthParams.TypeFMod.MIN
510-
print("ToF toggling f_mod value to:", f_mod)
511-
tofConfig.depthParams.freqModUsed = f_mod
512-
tofCfgQueue.send(tofConfig)
514+
elif key == ord('g'):
515+
if tof:
516+
f_mod = dai.RawToFConfig.DepthParams.TypeFMod.MAX if tofConfig.depthParams.freqModUsed == dai.RawToFConfig.DepthParams.TypeFMod.MIN else dai.RawToFConfig.DepthParams.TypeFMod.MIN
517+
print("ToF toggling f_mod value to:", f_mod)
518+
tofConfig.depthParams.freqModUsed = f_mod
519+
tofCfgQueue.send(tofConfig)
520+
else:
521+
if hdr_on:
522+
control = 'hdr_local_tone_weight'
523+
print("Selected control:", control)
524+
else:
525+
print("HDR was not enabled, start with `-misc hdr-exposure-ratio=2` or higher to enable")
513526
elif key == ord('h'):
514527
if tof:
515528
tofConfig.depthParams.avgPhaseShuffle = not tofConfig.depthParams.avgPhaseShuffle
@@ -599,7 +612,7 @@ def exit_cleanly(signum, frame):
599612
floodIntensity = 0
600613
device.setIrFloodLightIntensity(floodIntensity)
601614
print(f'IR Flood intensity:', floodIntensity)
602-
elif key >= 0 and chr(key) in '34567890[]p\\;\'':
615+
elif key >= 0 and chr(key) in '34567890[]p\\;\'r':
603616
if key == ord('3'):
604617
control = 'awb_mode'
605618
elif key == ord('4'):
@@ -628,6 +641,11 @@ def exit_cleanly(signum, frame):
628641
control = 'chroma_denoise'
629642
elif key == ord('p'):
630643
control = 'tof_amplitude_min'
644+
elif key == ord('r'):
645+
if hdr_on:
646+
control = 'hdr_exp_ratio'
647+
else:
648+
print("HDR was not enabled, start with `-misc hdr-exposure-ratio=2` or higher to enable")
631649
print("Selected control:", control)
632650
elif key in [ord('-'), ord('_'), ord('+'), ord('=')]:
633651
change = 0
@@ -637,7 +655,7 @@ def exit_cleanly(signum, frame):
637655
change = 1
638656
ctrl = dai.CameraControl()
639657
if control == 'none':
640-
print("Please select a control first using keys 3..9 0 [ ] \\ ; \'")
658+
print("Please select a control first using keys 3..9 0 [ ] \\ ; \' r g p")
641659
elif control == 'ae_comp':
642660
ae_comp = clamp(ae_comp + change, -9, 9)
643661
print("Auto exposure compensation:", ae_comp)
@@ -690,6 +708,16 @@ def exit_cleanly(signum, frame):
690708
chroma_denoise = clamp(chroma_denoise + change, 0, 4)
691709
print("Chroma denoise:", chroma_denoise)
692710
ctrl.setChromaDenoise(chroma_denoise)
711+
elif control == 'hdr_exp_ratio':
712+
hdr_exp_ratio = clamp(hdr_exp_ratio + change, 0, 3)
713+
value = pow(2, hdr_exp_ratio)
714+
print("HDR exposure ratio:", value)
715+
ctrl.setMisc("hdr-exposure-ratio", value)
716+
elif control == 'hdr_local_tone_weight':
717+
hdr_local_tone_weight = clamp(hdr_local_tone_weight + change, 0, 32)
718+
value = hdr_local_tone_weight / 32
719+
print(f"HDR local tone weight (normalized): {value:.2f}")
720+
ctrl.setMisc("hdr-local-tone-weight", value)
693721
elif control == 'tof_amplitude_min' and tof:
694722
amp_min = clamp(tofConfig.depthParams.minimumAmplitude + change, 0, 50)
695723
print("Setting min amplitude(confidence) to:", amp_min)

0 commit comments

Comments
 (0)