#Get exif data in order to get focal length.
exif_img = PIL.Image.open(calibration_paths[0])
exif_data = {
PIL.ExifTags.TAGS[k]:v
for k, v in exif_img._getexif().items()
if k in PIL.ExifTags.TAGS}
#Get focal length in tuple form
focal_length_exif = exif_data['FocalLength']
#Get focal length in decimal form
focal_length = focal_length_exif[0]/focal_length_exif[1]
#Save focal length
np.save("D:/VS2019/object/3DReconstruction-master/Reconstruction/NewFolder/FocalLength", focal_length)
#Calculate projection error.
mean_error = 0
for i in range(len(obj_points)):
img_points2, _ = cv2.projectPoints(obj_points[i],rvecs[i],tvecs[i], K, dist)
error = cv2.norm(img_points[i], img_points2, cv2.NORM_L2)/len(img_points2)
mean_error += error
total_error = mean_error/len(obj_points)
print (total_error)
focal_length = focal_length_exif[0]/focal_length_exif[1] 这一行有问题,我的相机焦距得到的值为3.95
即:focal_length_exif = exif_data['FocalLength']=3.95