import numpy as np import cv2 from pylepton import Lepton with Lepton() as l: a,_ = l.capture() cv2.normalize(a, a, 0, 65535, cv2.NORM_MINMAX) # extend contrast np.right_shift(a, 8, a) # fit data into 8 bits cv2.imwrite("output.jpg", np.uint8(a)) # write it!
Note that the image data returned from capture() is 14-bit and non-normalized (it's raw sensor data). You probably want to contrast extend this as demonstrated above, since the signal bandwidth is typically narrow over that range. Subsequently fitting this data into 8 bits is not strictly necessary to save the image with OpenCV but just shown here for demonstration purposes.
The capture() function includes a tuple that includes a pixel sum to be used for identifying unique frames (frames can update at ~27 Hz, but only unique ones are returned at ~9 Hz). Pylepton will be extended in the future to return a real frame ID here once support for frame telemetry is added.