Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projection error calculated correctly? #217

Open
BenPrae opened this issue Dec 16, 2019 · 0 comments
Open

projection error calculated correctly? #217

BenPrae opened this issue Dec 16, 2019 · 0 comments

Comments

@BenPrae
Copy link

BenPrae commented Dec 16, 2019

Hello, I was checking the calculation of the projection errors. And I dont get my head around how it is calculated. I think it is not correct. Please correct me if I'm wrong I'm new to this topic.

mean_error = 0
for i in xrange(len(objpoints)):
    imgpoints2, _ = cv.projectPoints(objpoints[i], rvecs[i], tvecs[i], mtx, dist)
    error = cv.norm(imgpoints[i], imgpoints2, cv.NORM_L2)/len(imgpoints2)
    mean_error += error
print( "total error: {}".format(mean_error/len(objpoints)) )

What we want is the euclidean distance of imgpoint1 to the reprojected imgpoint2 in each point of the pattern over all images.

You loop over the len of Objectpoints and calc the error of imagepoints in respect to reprojected imagepoints. If i understood the cv.norm fct correctly the error is calculated by

error =sqrt( [(imgpoints[i][0,1,1] -imgpoints2[0,1,1])^2 +(imgpoints[i][0,1,2] -imgpoints2[0,1,2])^2] +[(imgpoints[i][0,2,1] -imgpoints2[0,2,1])^2 +(imgpoints[i][0,2,2] -imgpoints2[0,2,2])^2] + .... ) / len(imgpoints)

but what we really want is the distance for each edge point of the frame in each image:
error =sqrt( [(imgpoints[i][0,1,1] -imgpoints2[0,1,1])^2 +(imgpoints[i][0,1,2] -imgpoints2[0,1,2])^2] +sqrt([(imgpoints[i][0,2,1] -imgpoints2[0,2,1])^2 +(imgpoints[i][0,2,2] -imgpoints2[0,2,2])^2]) + sqrt(...) +.... )/len(imgpoints)

So you need to add another loop to calc the L2 norm for each point not as a n-dim array vector.

Am I completley off?

Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant