[英]How to convert byte array to OpenCV Mat in Python
如何在Python
中将字节数组转换为Mat对象。
import numpy as np
mat = np.asarray(0, 0, data)
print 'Cols n Row ' + str(mat.cols) + " " + str(mat.rows)
但这是行不通的。 可以帮个忙。
这样尝试一下呢? 可能需要定义矩阵的数据类型,否则如何将字节数组划分为将存储在一个单元格中的“块”并不明显。
mat = np.asarray(data, dtype=np.uint8)
print 'Cols n Row ' + str(mat.shape[1]) + " " + str(mat.shape[0])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.