in source/calibration/GeometricCalibration.cpp [708:780]
std::string getCameraRmseReport(
const std::vector<Camera>& cameras,
const std::vector<Camera>& groundTruth) {
Camera::Real position = 0;
Camera::Real rotation = 0;
Camera::Real principal = 0;
Camera::Real distortion = 0;
Camera::Real focal = 0;
for (int i = 0; i < int(cameras.size()); ++i) {
{
auto before = groundTruth[i].position;
auto after = cameras[i].position;
position += (after - before).squaredNorm();
}
for (int v = 0; v < 3; ++v) {
auto before = groundTruth[i].rotation.row(v);
auto after = cameras[i].rotation.row(v);
rotation += (after - before).squaredNorm();
}
{
auto before = groundTruth[i].principal;
auto after = cameras[i].principal;
principal += (after - before).squaredNorm();
}
{
auto before = groundTruth[i].getDistortion();
auto after = cameras[i].getDistortion();
distortion += (after - before).squaredNorm();
}
{
auto before = groundTruth[i].focal;
auto after = cameras[i].focal;
focal += (after - before).squaredNorm();
}
}
Camera::Real angle = 0;
int angleCount = 0;
for (int i = 0; i < int(cameras.size()); ++i) {
for (int j = 0; j < i; ++j) {
for (int v = 2; v < 3; ++v) {
// angle between camera i and j
auto before = acosClamp(groundTruth[i].rotation.row(v).dot(groundTruth[j].rotation.row(v)));
if (before > 1) {
continue; // only count angles less than a radian
}
auto after = acosClamp(cameras[i].rotation.row(v).dot(cameras[j].rotation.row(v)));
angle += (after - before) * (after - before);
++angleCount;
}
}
}
// average
position /= cameras.size();
rotation /= 3 * cameras.size();
principal /= cameras.size();
distortion /= cameras.size();
focal /= cameras.size();
angle /= angleCount;
std::ostringstream result;
result << "RMSEs: "
<< "Pos " << sqrt(position) << " "
<< "Rot " << sqrt(rotation) << " "
<< "Principal " << sqrt(principal) << " "
<< "Distortion " << sqrt(distortion) << " "
<< "Focal " << sqrt(focal) << " "
<< "Angle " << sqrt(angle) << " ";
return result.str();
}