Mat和Vec_类型乘法 [英] Mat and Vec_ types multiplication
本文介绍了Mat和Vec_类型乘法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有简单的方法可以将Mat和Vec_相乘? (提供了它们的尺寸,例如:
Is there any easy way to multiplicate Mat and Vec_? (Provided, that they have proper sizes, e.g.:
Mat_<double> M = Mat(3,3,CV_32F);
Vec3f V=(1,2,3);
result = M*V //?
也许有一些简单的方法可以基于Vec3创建行(或列)Mat?
Maybe there is some easy method of creating row (or col) Mat based on Vec3?
推荐答案
您不能只将Mat
和Vec
(或更常见的是Matx_
)元素相乘. 将Vec
对象投射到Mat
:
You can't just multiply Mat
and Vec
(or, more generally, Matx_
) elements. Cast the Vec
object to Mat
:
Mat_<float> M = Mat::eye(3,3,CV_32F);
Vec3f V=(1,2,3);
Mat result = M*Mat(V);
此外,我注意到您的代码中有一个错误:构造M
时,类型CV_32F
对应于float
元素,而不是double
.我的代码示例中也对此进行了纠正.
Also, I noticed an error in your code: when constructing M
, the type CV_32F
corresponds to float
elements, not double
. This is also corrected in my code example.
希望有帮助.
这篇关于Mat和Vec_类型乘法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文