OPENCV: Calibratecamera 2 reprojection error and custom computed one not agree

后端 未结 1 403
面向向阳花
面向向阳花 2020-12-30 14:56

I have a python script that uses the calibratecamera2 method to calibrate a camera from a few views of a checker board. After a successful calibration I go after all origina

相关标签:
1条回答
  • 2020-12-30 15:30

    I was computing it wrong/differently. I was using this kind of formula:

    formula

    But opencv uses this one:

    fomrula_opencv

    So, if anyone is interested the code looks now like:

    #Compute mean of reprojection error
    tot_error=0
    total_points=0
    for i in xrange(len(obj_points)):
        reprojected_points, _ = cv2.projectPoints(obj_points[i], rvecs[i], tvecs[i], camera_matrix, dist_coeffs)
        reprojected_points=reprojected_points.reshape(-1,2)
        tot_error+=np.sum(np.abs(img_points[i]-reprojected_points)**2)
        total_points+=len(obj_points[i])
    
    mean_error=np.sqrt(tot_error/total_points)
    print "Mean reprojection error: ", mean_error
    

    Final reprojection error opencv: 0.571030279037

    Mean reprojection error:0.571030718956

    0 讨论(0)
提交回复
热议问题