I am using a Flir BlackflyS (BFS-U3-51S5) which is acquiring in Mono12p with a 12bit ADC. Looking at the FLIR docs (link below) I see how the bits are packed into bytes. We are looking to Unpack them into 16bit. I have made an unpacking script (below) which outputs what looks like a correct image but the min value is 5. We have taken the same images and converted them with the Flir SDK and see that the min value should be about 2 or 3, so there appears to be something wrong with how we are converting.
raw = np.array(tree["camera"]["frames"][str(i+1)]) first8, mid8, last8 = np.reshape(raw, (raw.shape // 3, 3)).astype(np.uint16).T first12 = first8 + ((mid8 & 0b1111) << 8) last12 = (mid8 >> 4) + (last8 << 4) out = np.reshape(np.concatenate((first12[:, None], last12[:, None]), axis=1), [cam.attrs["frame_height"], cam.attrs["frame_width"]])
Any assistance would be much appreciated.