1 | initial version |
in general, you multiply a Mat by a row-vector, and receive a transformed col-vector.
vc = M * vr;
you could setup your Mat in the usual way, Mat m(4,4,CV32F);
and assign one element after the other, but in this case you might want to profit from the ease of Mat_:
Mat m = (Mat_<float>(4,4) << 1,0,0,3,
0,1,0,3,
0,0,1,3,
0,0,0,1 );
// opencv can only multiply Mat's, so make one for the input vec (1,2,3):
Mat v = (Mat_<float>(4,1) << 1,2,3,1); // note: 1 as last element
Mat r = m*v;
cerr << r << endl;
[4; 5; 6; 1]