def write_array(filename, array):
with open(filename, 'wb') as fp:
if array.dtype == np.float32:
typecode = cv2.CV_32F
elif array.dtype == np.float64:
typecode = cv2.CV_64F
else:
raise ValueError("type is not supported")
fp.write(np.array(typecode, dtype=np.int32).tostring())
fp.write(np.array(len(array.shape), dtype=np.int32).tostring())
fp.write(np.array(array.shape, dtype=np.int32).tostring())
fp.write(array.tostring())
评论列表
文章目录