Answer the question
In order to leave comments, you need to log in
How to replace the Mat.At(int x, int y) method?
I am reading Mastering OpenCV book. I'm trying to implement face recognition. Now I am at the stage of pre-processing the face image (rotation and scaling). Rewriting the example from the book in C# (Originally C++). I came across this code:
// Get the transformation matrix for the desired angle & size.
Mat rot_mat = getRotationMatrix2D(eyesCenter, angle, scale);
// Shift the center of the eyes to be the desired center.
double ex = DESIRED_FACE_WIDTH * 0.5f - eyesCenter.x;
double ey = DESIRED_FACE_HEIGHT * DESIRED_LEFT_EYE_Y –
eyesCenter.y;
rot_mat.at<double>(0, 2) += ex;
rot_mat.at<double>(1, 2) += ey;
// Transform the face image to the desired angle & size &
// position! Also clear the transformed image background to a
// default grey.
Mat warped = Mat(DESIRED_FACE_HEIGHT, DESIRED_FACE_WIDTH,
CV_8U, Scalar(128));
warpAffine(gray, warped, rot_mat, warped.size());
rot_mat.at<double>(0, 2) += ex;
rot_mat.at<double>(1, 2) += ey;
and what can be substituted for them. I tried to access the elements of the Mat array, but it didn't work out.
Answer the question
In order to leave comments, you need to log in
A method at()
is, in vectors, an index access method.
rot_mat[0][2] = rot_mat[0][2] + ex;
rot_mat[1][2] = rot_mat[1][2] + ey;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question