Find object with color filtering


In this tutorial, we show a sample of finding object by color.

Step by step

First, you need image topic, so please run tutorial_image_publisher.launch in previous tutorial, and below rostopic list output is expected:

$ rostopic list

For color filtering, you can use hsv_color_filter:

$ rosrun opencv_apps hsv_color_filter image:=/image_publisher/output \
    _use_camera_info:=false __name:=hsv_color_filter
$ rosrun image_view image_view image:=/hsv_color_filter/image

You can reconfigure rosparam using rqt_reconfigure.

rosrun rqt_reconfigure rqt_reconfigure

You can set parameters as below:


The result is like below:

../_images/sample_image_publisher.jpg ../_images/result_hsv_color_filter.jpg

A single command

You can run upper programs in a single command with writing file:

$ vim tutorial_color_filtering.launch

Or you can download the file from:


  <node name="hsv_color_filter"
        pkg="opencv_apps" type="hsv_color_filter">
    <remap from="image" to="image_publisher/output" />
      use_camera_info: false
      h_limit_max: 360
      h_limit_min: 340
      s_limit_max: 220
      s_limit_min: 170
      v_limit_max: 130
      v_limit_min: 80

  <node name="image_view_color_filtering"
        pkg="image_view" type="image_view">
    <remap from="image" to="hsv_color_filter/image" />

  <node name="rqt_reconfigure"
        pkg="rqt_reconfigure" type="rqt_reconfigure"


You can launch the roslaunch file by:

$ roslaunch ./tutorial_color_filtering.launch