dkogan / mrcal

Next-generation camera-modeling toolkit

Home Page:http://mrcal.secretsauce.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Additional Statistics for the Reprojection Error

DanielSimsTOA opened this issue · comments

Hi!

First, I want to express my appreciation for mrcal—it's been an invaluable tool for my projects.

I have a feature request concerning the reprojection error statistics provided by mrcal. Currently, I'm trying to obtain detailed statistics like the minimum, maximum, mean, and standard deviation of the reprojection errors directly through the Python API. While mrcal-calibrate-cameras provides some of this data, I've noticed discrepancies when attempting to calculate these statistics manually using the API. I'm pretty sure I am doing something wrong.

Here is the code snippet I've been working with:

import mrcal
import numpy as np

# Load the camera model and obtain optimization inputs
model = mrcal.cameramodel("camera-0.cameramodel")
optimization_inputs = model.optimization_inputs()

# Calculate reprojection error statistics from existing camera model. 
x_chessboard = mrcal.residuals_chessboard(optimization_inputs=optimization_inputs).ravel()

print("Standard deviation of reprojection errors:", np.std(x_chessboard))
print("Mean of reprojection errors:", np.mean(x_chessboard))
print("Root mean square of reprojection errors:", np.sqrt(np.mean(x_chessboard**2)))
print("Maximum reprojection error:", np.max(x_chessboard))
print("Minimum reprojection error:", np.min(x_chessboard))

Is it possible to enhance mrcal to natively support these statistical computations? Am I missing something with the Python API?

Having these directly available would be beneficial to my project.

Thanks for considering this enhancement. Please let me know if you need any more details or if there's a workaround I might have missed.

Best Regards,
Daniel Sims