Mat and Vec_ types multiplication

左心房为你撑大大i 提交于 2019-12-23 09:27:03

问题


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 //?

Maybe there is some easy method of creating row (or col) Mat based on Vec3?


回答1:


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);

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.

Hope that it helps.



来源:https://stackoverflow.com/questions/24863982/mat-and-vec-types-multiplication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!