error: declaration of 'cv::Mat R ' shadows a parameter

变量被覆盖。

例:

void pose_estimation_2d2d::_pose_estimation_2d2d(const vector<KeyPoint> &v_keypoints_1, const vector<KeyPoint> &v_keypoints_2, const vector<DMatch> v_goodmatches, const Mat &K, Mat &R, Mat &t)
{
  ......
  cv::Mat_<double> R = svd.u * W * svd.vt;
  ......
}

函数的参数列表中已经有变量R了,在函数体内新定义一个R就会覆盖原有变量,因而报错。

原文地址:https://www.cnblogs.com/defe-learn/p/6839368.html