def capture(): nivision.IMAQdxGrab(id, img, 1) picture = nivision.imaqImageToArray(img) data = struct.unpack(fmt, picture[0]) data = np.asarray(data) data = np.reshape(data, (cam_y, cam_x)) return data
def _decode_image_data(self, img): img_array = nv.imaqImageToArray(img) img_array_shape = (img_array[2], img_array[1]) # bitdepth in bytes bitdepth = len(img_array[0]) // (img_array[1] * img_array[2]) dtype = {1: np.uint8, 2: np.uint16, 4: np.uint32}[bitdepth] data = np.frombuffer(img_array[0], dtype=dtype).reshape(img_array_shape) return data.copy()
def _decode_image_data(self, img): img_array = nv.imaqImageToArray(img) img_array_shape = (img_array[2], img_array[1]) # bitdepth in bytes bitdepth = len(img_array[0]) // (img_array[1] * img_array[2]) # print(bitdepth) if bitdepth == 1: dtype = np.uint8 elif bitdepth == 2: dtype = np.uint16 elif bitdepth == 4: dtype = np.uint32 else: raise ValueError(dtype) data = np.frombuffer(img_array[0], dtype=dtype).reshape(img_array_shape) return data.copy()