I have a similar issue as discussed in this topic.
I simply want a hardware triggered TOF image and I am attempting it using this warkaround.
- TOF at 60FPS streaming continuously (OAK runs out of memory if 80FPS and if RGB camera is also 60FPS)
- RGB cam_c with .initialControl.setExternalTrigger(1,0)
- To trigger, short pin 2 to pin 8
The plan:
- Read TOF queue continuously and write to host-side FIFO queue, this should prevent any issues with device-side buffers/queues.
- Try to read RGB queue.
- When a packet is found in the RGB queue, this is the result of a trigger. Get the RGB timestamp with color_packet.getTimestamp()
- Collect some more TOF packets such that there are TOF packets before and after the trigger, guaranteeing an optimal TOF frame has been collected
- Compare RGB timestamp with TOF timestamps in the host-side FIFO queue, find one with shortest time difference.
My simplified code to reproduce the main issue:
trigger_received = False
while pipeline.isRunning():
time.sleep(1) # delay to allow new packets to arrive, delay increased to 1 sec for better logs in minimal code.
color_packet: dai.ADatatype = output_queues_dict["color"].tryGet()
if isinstance(color_packet, dai.ImgFrame) and not trigger_received: # skip color packet processing if trigger already received
color_timestamp: datetime.timedelta = color_packet.getTimestamp()
time_of_trigger = time.time()
print(f"Received color packet at time {time_of_trigger}")
print(f"Timestamp color: {color_timestamp}")
trigger_received = True
tof_packets: list[dai.ADatatype] = output_queues_dict["tof"].tryGetAll()
print(f"Retrieved {len(tof_packets)} new tof packets from device")
for tof_packet in tof_packets:
tof_packets_queue_hostside.append(tof_packet)
...
...
- As can be seen in the code, both RGB and TOF packets should always be read out
My strange problem(s):
- After boot, the TOF first does not start streaming. Only after an initial trigger, the TOF streams at ~30FPS
- Main issue: When a trigger is received, some TOF packets come in but only until the color trigger. After that, no TOF packets arrive for serveral seconds.
- The last TOF packet that is received is right before the RGB trigger
logs of the main issue:
Retrieved 36 new tof packets from device
Retrieved 29 new tof packets from device
Retrieved 28 new tof packets from device
Received color packet at time 1768380198.2891834
Timestamp color: 2:00:53.587175
Retrieved 18 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 0 new tof packets from device
Retrieved 23 new tof packets from device
Retrieved 35 new tof packets from device
Retrieved 37 new tof packets from device
What causes this strange behaviour? Is the TOF somehow dependent on the RGB stream?