findHomography objective function for Levenberg-Marquardt

In findHomography documentation it is stated:
“Regardless of the method, robust or not, the computed homography matrix is refined further (using inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the re-projection error even more.”

The computation of the initial estimate for the H matrix is well documented.

However, it is not clearly stated what the objective function for the non-linear optimization is. Is it basically the same least-squares definition, but for the re-projected x and y? I know in the literature some have used a sum of errors from the projected and re-projected coordinates.

I’d be really grateful if someone could clarify this, I’m not getting much from the source code.