def parse_array(array):
type_code = np.asscalar(np.fromstring(array[0:4], dtype=np.int32))
shape_size = np.asscalar(np.fromstring(array[4:8], dtype=np.int32))
shape = np.fromstring(array[8: 8+4 * shape_size], dtype=np.int32)
if type_code == 5:#cv2.CV_32F:
dtype = np.float32
if type_code == 6:#cv2.CV_64F:
dtype = np.float64
return np.fromstring(array[8+4 * shape_size:], dtype=dtype).reshape(shape)
评论列表
文章目录