Ask Your Question
0

Trying to understand Mat::dot and 2d matrices, in OpenCV

asked 2014-05-26 17:55:19 -0600

joeish80829 gravatar image

Here is my code:

  uchar a[2][4] = {1,2,3,4,5,6,7,8};
  Mat b = Mat(2,4, 0, a);

  uchar c[2][4] = {1,2,3,4,5,6,7,8};
  Mat d = Mat(2,4, 0, c);

  cout<< b.dot(d);

The output is 204. Can someone show me presicly which elements have the dot product computed, and when. I didn't understand when the Documentation said "If the matrices are not single-column or single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D vectors."

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-26 19:19:25 -0600

Witek gravatar image

updated 2014-05-26 19:20:58 -0600

The result is correct. In your case the dot product is simply 1*1+2*2+3*3+4*4+5*5+6*6+7*7+8*8=204

Your 2-row, 4-column matrices are treated as 1D vectors like this: 1,2,3,4,5,6,7,8.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-05-26 17:55:19 -0600

Seen: 243 times

Last updated: May 26 '14