Suppose I have a transformation matrix Mat
tr
that I got from getAffineTransform()
and a Point2d
p
. I want the p
cv::transform is used for transforming points with a transformation matrix.
Every element of the N -channel array src is interpreted as N -element vector that is transformed using the M x N or M x (N+1) matrix m to M-element vector - the corresponding element of the output array dst .
The function may be used for geometrical transformation of N -dimensional points, arbitrary linear color space transformation (such as various kinds of RGB to YUV transforms), shuffling the image channels, and so forth.
There's a concise example in the InputArray documentation (otherwise not relevant):
std::vector<Point2f> vec;
// points or a circle
for( int i = 0; i < 30; i++ )
vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)),
(float)(100 - 30*sin(i*CV_PI*2/5))));
cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20));
Or you can likely just convert the Point2f
into a Mat
and multiply by the matrix.