Mat a = new Mat(3, 1, MatType.CV_8UC1);
Mat b = new Mat(1,3, MatType.CV_8UC1);
for( int i = 0; i < 3; i++ )
{
a.Set<byte>(i, 0, (byte)i);
b.Set<byte>(0, i, (byte)(i + 3));
}
var c = a * b;
mat = c.ToMat(); // error
a.Mul(b)的结果是MatExpr类
我想创建一个3x3矩阵。
我怎样才能上Mat班呢?
self answer: Opencv的矩阵乘法只支持double类型
如果您想以字节格式计算,请参阅此。
Mat a = new Mat(3, 1, MatType.CV_64FC1, new double[] { 1.0, 2.0, 3.0 });
Mat b = new Mat(1, 3, MatType.CV_64FC1, new double[] { 4.0, 5.0, 6.0 });
Mat c = new Mat(3, 3, MatType.CV_64FC1);
var c = (a * b).ToMat();
c.ConvertTo(c, MatType.CV_8UC1);
Trace.WriteLine(c.At<byte>(0,0)); // 4