Ask Your Question

Revision history [back]

What about this solution?

/** rotate points based on rot_mat */
void get_rotated_points(const std::vector<cv::Point2d> &points, std::vector<cv::Point2d> &dst_points, const cv::Mat &rot_mat){

for (int i = 0; i<points.size(); i++){
    Mat point_original(3, 1, CV_64FC1);
    point_original.at<double>(0, 0) = points[i].x;
    point_original.at<double>(1, 0) = points[i].y;
    point_original.at<double>(2, 0) = 1;

    Mat result(2, 1, CV_64FC1);

    gemm(rot_mat, point_original, 1.0, cv::Mat(), 0.0, result);

    Point point_result(cvRound(result.at<double>(0, 0)), cvRound(result.at<double>(1, 0)));

    dst_points.push_back(point_result);
 }
}


//rotate landmarks
get_rotated_points(landmarks, dst_landmarks, rot_mat);