mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Correct snavely reprojection error in code and doc.
The snavely reprojection error is wrong both in the sample code and in the documentation. It should not multiply by the focal length before calculating the distortion. Change-Id: I292af962e634506a7cc57af9ce72b08f81ce3425
This commit is contained in:
@@ -37,9 +37,8 @@ struct SnavelyReprojectionError {
|
||||
// Compute the center of distortion. The sign change comes from
|
||||
// the camera model that Noah Snavely's Bundler assumes, whereby
|
||||
// the camera coordinate system has a negative z axis.
|
||||
const T& focal = camera[6];
|
||||
T xp = - focal * p[0] / p[2];
|
||||
T yp = - focal * p[1] / p[2];
|
||||
T xp = - p[0] / p[2];
|
||||
T yp = - p[1] / p[2];
|
||||
|
||||
// Apply second and fourth order radial distortion.
|
||||
const T& l1 = camera[7];
|
||||
@@ -48,8 +47,9 @@ struct SnavelyReprojectionError {
|
||||
T distortion = T(1.0) + r2 * (l1 + l2 * r2);
|
||||
|
||||
// Compute final projected point position.
|
||||
T predicted_x = distortion * xp;
|
||||
T predicted_y = distortion * yp;
|
||||
const T& focal = camera[6];
|
||||
T predicted_x = focal * distortion * xp;
|
||||
T predicted_y = focal * distortion * yp;
|
||||
|
||||
// The error is the difference between the predicted and observed position.
|
||||
residuals[0] = predicted_x - T(observed_x);
|
||||
@@ -98,4 +98,5 @@ ceres::Solve(options, &problem, &summary);
|
||||
std::cout << summary.FullReport() << "\n";
|
||||
\end{minted}
|
||||
|
||||
For a more sophisticated bundle adjustment example which demonstrates the use of Ceres' more advanced features including its various linear solvers, robust loss functions and local parameterizations see \texttt{examples/bundle\_adjuster.cc}.
|
||||
For a more sophisticated bundle adjustment example which demonstrates the use of Ceres' more advanced features including its various linear solvers, robust loss functions and local parameterizations see \texttt{examples/bundle\_adjuster.cc}.
|
||||
|
||||
|
||||
@@ -139,9 +139,8 @@ struct SnavelyReprojectionError {
|
||||
// Compute the center of distortion. The sign change comes from
|
||||
// the camera model that Noah Snavely's Bundler assumes, whereby
|
||||
// the camera coordinate system has a negative z axis.
|
||||
const T& focal = camera[6];
|
||||
T xp = - focal * p[0] / p[2];
|
||||
T yp = - focal * p[1] / p[2];
|
||||
T xp = - p[0] / p[2];
|
||||
T yp = - p[1] / p[2];
|
||||
|
||||
// Apply second and fourth order radial distortion.
|
||||
const T& l1 = camera[7];
|
||||
@@ -150,8 +149,9 @@ struct SnavelyReprojectionError {
|
||||
T distortion = T(1.0) + r2 * (l1 + l2 * r2);
|
||||
|
||||
// Compute final projected point position.
|
||||
T predicted_x = distortion * xp;
|
||||
T predicted_y = distortion * yp;
|
||||
const T& focal = camera[6];
|
||||
T predicted_x = focal * distortion * xp;
|
||||
T predicted_y = focal * distortion * yp;
|
||||
|
||||
// The error is the difference between the predicted and observed position.
|
||||
residuals[0] = predicted_x - T(observed_x);
|
||||
|
||||
@@ -71,8 +71,8 @@ struct SnavelyReprojectionError {
|
||||
// the camera model that Noah Snavely's Bundler assumes, whereby
|
||||
// the camera coordinate system has a negative z axis.
|
||||
const T& focal = camera[6];
|
||||
T xp = - focal * p[0] / p[2];
|
||||
T yp = - focal * p[1] / p[2];
|
||||
T xp = - p[0] / p[2];
|
||||
T yp = - p[1] / p[2];
|
||||
|
||||
// Apply second and fourth order radial distortion.
|
||||
const T& l1 = camera[7];
|
||||
@@ -81,8 +81,8 @@ struct SnavelyReprojectionError {
|
||||
T distortion = T(1.0) + r2 * (l1 + l2 * r2);
|
||||
|
||||
// Compute final projected point position.
|
||||
T predicted_x = distortion * xp;
|
||||
T predicted_y = distortion * yp;
|
||||
T predicted_x = focal * distortion * xp;
|
||||
T predicted_y = focal * distortion * yp;
|
||||
|
||||
// The error is the difference between the predicted and observed position.
|
||||
residuals[0] = predicted_x - T(observed_x);
|
||||
@@ -128,16 +128,16 @@ struct SnavelyReprojectionErrorWithQuaternions {
|
||||
// Compute the center of distortion. The sign change comes from
|
||||
// the camera model that Noah Snavely's Bundler assumes, whereby
|
||||
// the camera coordinate system has a negative z axis.
|
||||
T xp = - focal * p[0] / p[2];
|
||||
T yp = - focal * p[1] / p[2];
|
||||
T xp = - p[0] / p[2];
|
||||
T yp = - p[1] / p[2];
|
||||
|
||||
// Apply second and fourth order radial distortion.
|
||||
T r2 = xp*xp + yp*yp;
|
||||
T distortion = T(1.0) + r2 * (l1 + l2 * r2);
|
||||
|
||||
// Compute final projected point position.
|
||||
T predicted_x = distortion * xp;
|
||||
T predicted_y = distortion * yp;
|
||||
T predicted_x = focal * distortion * xp;
|
||||
T predicted_y = focal * distortion * yp;
|
||||
|
||||
// The error is the difference between the predicted and observed position.
|
||||
residuals[0] = predicted_x - T(observed_x);
|
||||
|
||||
Reference in New Issue
Block a user