<launch>

  <arg name="gui" default="true" />

  <node name="image_publisher"
        pkg="jsk_perception" type="image_publisher.py">
    <rosparam subst_value="true">
      file_name: $(find jsk_perception)/sample/image/lena.jpg
      encoding: bgr8
      publish_info: false
    </rosparam>
  </node>
  <arg name="INPUT_IMAGE" default="image_publisher/output" />

  <!-- create label -->
  <node name="grid_label"
        pkg="jsk_perception" type="grid_label">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <rosparam>
      label_size: 128
    </rosparam>
  </node>

  <node name="label_image_decomposer"
        pkg="jsk_perception" type="label_image_decomposer.py">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <remap from="~input/label" to="grid_label/output" />
    <rosparam>
      queue_size: 30
    </rosparam>
  </node>

  <node name="label_image_decomposer_with_names"
        pkg="jsk_perception" type="label_image_decomposer.py">
    <remap from="~input" to="$(arg INPUT_IMAGE)" />
    <remap from="~input/label" to="grid_label/output" />
    <rosparam>
      queue_size: 30
      label_names:
        - background
        - upper_left
        - upper_right
        - lower_left
        - lower_right
    </rosparam>
  </node>

  <node name="label_image_decomposer_only_label"
        pkg="jsk_perception" type="label_image_decomposer.py">
    <remap from="~input/label" to="grid_label/output" />
    <rosparam>
      only_label: true
      label_names:
        - background
        - upper_left
        - upper_right
        - lower_left
        - lower_right
    </rosparam>
  </node>

  <group if="$(arg gui)">
    <node name="image_view0"
          pkg="image_view" type="image_view">
      <remap from="image" to="label_image_decomposer/output" />
    </node>
    <node name="image_view1"
          pkg="image_view" type="image_view">
      <remap from="image" to="label_image_decomposer/output/label_viz" />
    </node>
    <node name="image_view2"
          pkg="image_view" type="image_view">
      <remap from="image" to="label_image_decomposer_with_names/output/label_viz" />
    </node>
    <node name="image_view3"
          pkg="image_view" type="image_view">
      <remap from="image" to="label_image_decomposer_only_label/output/label_viz" />
    </node>
  </group>

</launch>
