Ask Your Question

dot product Mat matrices

asked 2013-02-14 11:02:20 -0500

ovaal gravatar image

I want to get the dot product from two Mat matrices using cvDotProduct. But this gives the error error: cannot convert ‘cv::Mat’ to ‘const CvArr* {aka const void*}’ for argument ‘1’ to ‘double

edit retag flag offensive close merge delete


Please give some code

krishna gravatar imagekrishna ( 2013-02-14 12:11:36 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2013-02-15 00:37:45 -0500

cvDotProduct is function from old C API. It does not work with Mat objects. Use Mat::dot method instead.

edit flag offensive delete link more


For me, dot for matrices is matrix multiplication (I may wrong). Mat::dot is for vector in a Mat. Is the OP asking for a matrix multiplication or a dot between 2 vectors ?

Seltymar gravatar imageSeltymar ( 2013-02-15 02:29:04 -0500 )edit

From the docs: The method computes a dot-product of two matrices. 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. The vectors must have the same size and type. If the matrices have more than one channel, the dot products from all the channels are summed together.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-02-15 04:47:57 -0500 )edit

Yes, you're right. Just I was confused that a dot product of matrices is a matrix multiplication which gives a matrix as output. And the dot product from openCV gives a scalar (as it treats matrices as vectors). But as OP is asking for cvDotProduct, there is no ambiguity.

Seltymar gravatar imageSeltymar ( 2013-02-18 03:06:28 -0500 )edit

Question Tools


Asked: 2013-02-14 11:02:20 -0500

Seen: 3,976 times

Last updated: Feb 15 '13