# Reprojection Error too High in Visual Odometry

Hi everyone! I’m workin on my Mono Visual Odometry project. During the triangulation step, i’m trying to compute the reprojection error. However, the value is too high and I don’t know why.
This is my function for reprojection error:

``````vector<double> reproject_error(Mat world_points, Mat R, Mat t, Mat cameraMatrix, vector<Point2f> img_points)
{

/************************REPROJECT ERROR*********************************
* world_points: Punti 3D in coordinate {W} da proiettare in {C}.       *
* R e t: Trasformazione omogenea che trasforma da {W} a {C}            *
* cameraMatrix                                                         *
* img_points: Punti con cui confrontare i world_points riproiettati.   *
************************************************************************/

//Reproject world_points (3D) in 2D image plan, using projectPoints
Mat reproject_points;
Mat Rvec;
Rodrigues(R, Rvec);

projectPoints(world_points, Rvec, t, cameraMatrix, noArray(), reproject_points);

//Compute reproject error
vector<double> reproject_err(img_points.size());

for(int i = 0; i < reproject_point.rows; i++)
{
ROS_INFO("Keypoint 2D: [%f, %f] \t Reprojected World Point: [%f, %f]", img_points[i].x, img_points[i].y, reproject_points.at<double>(i, 0), reproject_points.at<double>(i, 1));
reproject_err[i] = sqrt(pow(img_points[i].x - reproject_point.at<double>(i, 0), 2.0) + pow(img_points[i].y - reproject_points.at<double>(i, 1), 2.0));
}
ROS_INFO("----------------------");

return reproject_err;
}
``````

Code seems fine. I see you don’t provide distortion coefficients, why?
Remember, errors are in pixel units.
It is a common mistake to provide the wrong R and t, from camera to world transformation.

1 Like