
Nice gist from @rossbar https://gist.github.com/rossbar/ebb282c3b73c41c1404123de6cea4771
# Load data from file
with open(yaml_fname, "r") as file_handle:
calib_data = yaml.load(file_handle)
# Parse
camera_info_msg = CameraInfo()
camera_info_msg.width = calib_data["image_width"]
camera_info_msg.height = calib_data["image_height"]
camera_info_msg.K = calib_data["camera_matrix"]["data"]
camera_info_msg.D = calib_data["distortion_coefficients"]["data"]
camera_info_msg.R = calib_data["rectification_matrix"]["data"]
camera_info_msg.P = calib_data["projection_matrix"]["data"]
camera_info_msg.distortion_model = calib_data["distortion_model"]
return camera_info_msg
Originally posted by ckirksey with karma: 203 on 2017-08-29
This answer was NOT ACCEPTED on the original site
Post score: 2
Original comments
Comment by fjp on 2021-08-29:
Is this still the best method to create the CameraInfo messages from a yaml calibrationf file? Or is there an official ros package to do this?