Python
Below a simple python example can be found.
It demonstrates error handling, usage of tof.Data
as a NumPy array and manual deletion of the frame data object.
import chronoptics.tof as tof
import numpy as np
# Errors are communicated through exceptions
try:
cam = tof.KeaCamera(serial="2020004")
cam.setOutputFrameTypes([tof.FrameType.Z])
cam.start()
for _ in range(100):
frames = cam.getFrames()
# The tof.Data structure can be interpreted by numpy as a numpy array
z = np.asarray(frames[0])
# Manually delete frames. The garbage collector might take a long
# time cleaning these frames up, which can be a serious memory hog
del frames
cam.stop()
except Exception as e:
print(f"An error occurred: {e}")