import sensor_msgs.msg # Load camera calibration data from file with open('calibration.yaml', 'r') as f: calib_data = yaml.load(f) # Create CameraInfo message msg = sensor_msgs.msg.CameraInfo() msg.width = calib_data['image_width'] msg.height = calib_data['image_height'] msg.distortion_model = calib_data['distortion_model'] msg.K = calib_data['camera_matrix']['data'] msg.D = calib_data['distortion_coefficients']['data']
import rospy import sensor_msgs.msg # Initialize ROS node rospy.init_node('camera_publisher') # Create CameraInfo message msg = sensor_msgs.msg.CameraInfo() msg.width = 640 msg.height = 480 msg.distortion_model = 'plumb_bob' # Publish message to ROS topic pub = rospy.Publisher('/camera_info', sensor_msgs.msg.CameraInfo, queue_size=10) pub.publish(msg)In this example, we're creating a CameraInfo message with arbitrary dimensions and distortion model, and publishing it to a ROS topic using the rospy.Publisher class. Package/library: sensor_msgs is a ROS package that provides message types used in sensor data communication.