A matlab monocular camera calibration is stored in the format of a cameraParameters object.
In ROS, the calibration parameters are usually stored in a yaml file, and then they are loaded into a sensor_msgs/CameraInfo Message (read this documentation for more info). The format
A calibration yaml file for a monocular camera in ROS requires the following:
- height in pixels
- width in pixels
- camera_name which should correspond to a link name in your URDF.
- distortion_model which is always just "plumb_bob"
- The distortion parameters D, size depending on the distortion model. For "plumb_bob", the 5 parameters are: (k1, k2, t1, t2, k3). Also known as the distortion_coefficients
- Intrinsic camera_matrix K for the raw (distorted) images.
- A 3x3 rectification_matrix which for monocular cameras is just an identity matrix.
- A 3x4 projection_matrix which specifies the intrinsic matrix of the processed image
I tried loading your .mat file into matlab to get the parameters out if it but unfortunately I couldn't get a any real numbers out of it (everything was either 0's or 1's) and also I don't think it uses the same distortion model. I'm sorry but I wasn't able to convert your file!
Also once I have the yaml file, how
can this file be accepted by
camera_info so that image_proc can
subscribe and read the parameters?
The way this works in ROS is that you pass in the location of the yaml file to the driver node you use to load your camera. In ROS there are bunch of camera drivers depending on what type of camera it is. If it is a UVC compliant camera you would use libuvc_camera. You pass in the following parameter with the location of the yaml file:
<param name="camera_info_url" value="file:///tmp/cam.yaml"/>
That driver node then publishes BOTH the images from your camera along with the calibration information. Stereo_image_proc can then subscribe to those images and calibration and use them to give you the point cloud if you are doing stereo. Hope this helps!
PS. The easiest way to do this is just to calibrate your camera using the ros calibration utility and a checkerboard.
Follow this tutorial for a monocular camera: http://wiki.ros.org/camera_calibratio...
Here is a sample camera calibration yaml for the left camera of a stereo pair:
image_width: 640
image_height: 480
camera_name: stereo0_link
camera_matrix:
rows: 3
cols: 3
data: [734.889420, 0.000000, 317.706196, 0.000000, 732.082689, 239.033655, 0.000000, 0.000000, 1.000000]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [0.100896, 0.019699, 0.004179, -0.004728, 0.000000]
rectification_matrix:
rows: 3
cols: 3
data: [0.997520, -0.005830, 0.070143, 0.005907, 0.999982, -0.000881, -0.070137, 0.001293, 0.997537]
projection_matrix:
rows: 3
cols: 4
data: [801.287930, 0.000000, 255.724689, 0.000000, 0.000000, 801.287930, 235.533001, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000]
Seeing as Mathworks has quite good ROS support these days (Robotics System Toolbox), you might be able to ask them about this. I can imagine you're not the only one who tries to do this.
Can you post a sample .mat cal file? A .yaml camera calibration file is nothing special, and simply contains the same information as your matlab file but in a different format. If you post a .mat file i can do a quick conv for you and show you how to do it.
@psammut thank you for your kind reply. https://drive.google.com/open?id=0B2X... This is a link to my parameters. I think the most important parameter is the camera intrinsic matrix: [7.0832e+03 0 0] [0 7.0783e+03 0] [2.4454e+03 1.6328e+03 1]