def read_array(filename):
with open(filename, 'rb') as fp:
type_code = np.fromstring(fp.read(4), dtype=np.int32)
shape_size = np.fromstring(fp.read(4), dtype=np.int32)
shape = np.fromstring(fp.read(4 * shape_size), dtype=np.int32)
if type_code == cv2.CV_32F:
dtype = np.float32
if type_code == cv2.CV_64F:
dtype = np.float64
return np.fromstring(fp.read(), dtype=dtype).reshape(shape)
评论列表
文章目录