In my previous tutorial I showed you how to calibrate a camera with ROS. In this tutorial, I’m gonna show you how to rectify the images from coming from your camera.
First, open your text editor and paste the following text into it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<!-- Example of run: roslaunch usb_cam_stream_publisher.launch video_device:=/dev/video0 image_width:=640 image_height:=480 --> <launch> <arg name="video_device" default="/dev/video0" /> <arg name="image_width" default="640" /> <arg name="image_height" default="480" /> <arg name="image_topic_name" default="/usb_cam/image_raw" /> <arg name="camera_info_topic_name" default="/usb_cam/camera_info" /> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="$(arg video_device)" /> <param name="image_width" value="$(arg image_width)" /> <param name="image_height" value="$(arg image_height)"/> <param name="pixel_format" value="mjpeg" /> <param name="io_method" value="mmap"/> <!-- update these line accroding to your setting, here are some examples:--> <!-- <param name="camera_info_url" value="package://your_cameras/info/camera.yaml"/> --> <!-- <param name="camera_info_url" value="file:///home/behnam/.ros/camera_info/head_camera.yaml"/> --> <param name="camera_info_url" value="file://${ROS_HOME}/camera_info/head_camera.yaml"/> <remap from="/usb_cam/camera_info" to="$(arg camera_info_topic_name)"/> <remap from="/usb_cam/image_raw" to="$(arg image_topic_name)"/> </node> </launch> |
make the necessary changes and save it under usb_cam_stream_publisher.launch
Now run it:
1 |
roslaunch usb_cam_stream_publisher.launch |
Open another text document and paste the following into it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<launch> <arg name="name_space" default="usb_cam" /> <!-- this line is for: ROS_NAMESPACE=usb_cam rosrun image_proc image_proc --> <node name="image_proc" pkg="image_proc" type="image_proc" ns="$(arg name_space)"/> <!-- this line is for: rosrun image_view image_view image:=usb_cam/image_rect_color --> <node name="image_rect_color" pkg="image_view" type="image_view" > <remap from="image" to="$(arg name_space)/image_rect_color" /> </node> <node name="image_raw" pkg="image_view" type="image_view" > <remap from="image" to="$(arg name_space)/image_raw" /> </node> </launch> |
save it under image_proc.launch. Now run it:
1 |
roslaunch image_proc.launch |
The codes are available on my Github
Thank you very much!
Can you upload the code of your usb_cam node?
Dear Manar,
You can install it from here:
http://wiki.ros.org/usb_cam