I have a homgraphy matrix
[h1 h2 h3
h4 h5 h6
h7 h8 h9]
I have transformed a point
p1 to P1
using above homography matrix.
Similarly
p2 to P2
p3 to P3
p4 to P4
I know the diffence between
P1-P2 = D1
P2-P3 = D2
P3-P4 = D3
Due to error in homography There is small error in D1, D2, D3.
(I know the actual difference value)
Let the error be E1, E2, E3
(known values).
(E1 = D1 - Actual_Difference_between_P1_andP2)
Similarly E2, E3, and E4 are calculated.
Now I need to modify my homography matrix, such that my E1, E2, E3, E4 are minimized.
Introduction:
Homography can be obtained from 4 pair of points with 100% accuracy (real 0 reprojection-error). However, when number of pair of points are more than 4, you may not be able to get a 0-error homography. This is because the points may not be in one 3D-planer.
So, first you have to deal with the fact that in real word application, there may not be 100% accurate homography (due to matching errors) but there is one optimal (minimum reprojection error matrix).
Formulation:
Regarding your question, it seems that you have two set of pair of points. One that you have used to obtain the Homography and another one that you are validating your model based on it and then you want to use it for enhance your model.
How can I enhance the homography?
First, use both sets to obtain the homography using some robust estimation method (RANSAC for example). You may find further information here.
Second, iterate through your set and compute the reprojection error for each points as you described. Then, eliminate all points that have a reprojection error more than some threshold.
Third, apply fine tuning optimization techniques just on the inliers until you good homography in term of sum of errors among inliers.
How to do the third step?
You have 8 parameters to optimize:
h11 h12 h13
h21 h22 h23
h31 h32 1
The optimization function:
And you have already computed the Homography using RANSAC. So, you have a very good estimation which is near the global optimal. This means a nonlinear local optimization technique is enough for this case. many algorithm are exist. Pick one and start (Some suggestions: Hill Climbing, Simulated Annealing)
Edit after OP's comment that only distances betwen the second set are known:
The optimization function should be:
Where AD_ij
is the actual distance between Pi and Pj.
You may try to decrease the complexity by for example using the sequare of euclidean distance for both reference and query.