Ask Your Question

Multiply cv::Mat and std::vector<cv::Point2f>

asked 2012-11-19 13:24:35 -0600

David_Lavy gravatar image


So I have a matrix cv::Mat M (NxN) and a vector of Points std::vector< cv::Point2f > Vec (Nx2).

How can I perform a multiplication between these two elements: M x Vec = P, and have a final vector std::vector< cv::Point2f > P (Nx2)??

Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-11-19 17:22:37 -0600

SR gravatar image

Without testing, but this should do it:

std::vector< cv::Point2f > Vec = ... ;
std::vector< cv::Point2f > P;
cv::Mat V = M * cv::Mat(Vec, false) /* Vec is just wrapped, no copying is performed */;
V.copyTo( cv::Mat(P, false) );
// P now contains the result
edit flag offensive delete link more

Question Tools


Asked: 2012-11-19 13:24:35 -0600

Seen: 8,379 times

Last updated: Nov 19 '12