@santelelle Sorry for the late reply — I didn’t have a ToF device on hand to test. The ToF node does expose .confidence
, but the internal depth-confidence filter hasn’t been implemented yet, so that queue remains empty.
As a workaround, you can create a ToFDepthConfidenceFilter
yourself and link the raw depth + amplitude outputs before reading from the queues. Once you add those lines, both confidence and filtered depth should start streaming as expected. This worked for me:
import time
import depthai as dai
GET_CONFIDENCE = True
pipeline = dai.Pipeline()
socket = dai.CameraBoardSocket.AUTO
preset = dai.ImageFiltersPresetMode.TOF_MID_RANGE
tof = pipeline.create(dai.node.ToF).build(socket, preset)
queues = []
if GET_CONFIDENCE:
conf_filter = pipeline.create(dai.node.ToFDepthConfidenceFilter)
conf_filter.build(tof.rawDepth, tof.amplitude, preset)
queues += [
("confidence", conf_filter.confidence.createOutputQueue(maxSize=4, blocking=False)),
("depth (confidence filtered)", conf_filter.filteredDepth.createOutputQueue(maxSize=4, blocking=False)),
]
queues += [
("amplitude", tof.amplitude.createOutputQueue(maxSize=4, blocking=False)),
("depth", tof.depth.createOutputQueue(maxSize=4, blocking=False)),
]
def print_if_available(label, queue):
if (msg := queue.tryGet()) is not None:
frame = msg.getFrame()
print(f"{label}: {frame.shape} {frame.dtype}")
with pipeline as p:
print("Starting pipeline...")
p.start()
print("Pipeline started!")
try:
while p.isRunning():
for label, queue in queues:
print_if_available(label, queue)
time.sleep(0.01)
except KeyboardInterrupt:
pass