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

  <include file="$(find jsk_perception)/sample/sample_image_publisher.launch">
    <arg name="gui" value="false"/>
  </include>

  <node name="sample_manager"
        pkg="nodelet" type="nodelet"
        args="manager"
        output="screen"
        respawn="true"/>

  <node name="erode_mask_image"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/ErodeMaskImage sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <node name="dilate_mask_image"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/DilateMaskImage sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <!-- erode -> dilate -->
  <node name="opening"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/Opening sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <!-- dilate -> erode -->
  <node name="closing"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/Closing sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <!-- dilated image - eroded image -->
  <node name="morphological_gradient"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/MorphologicalGradient sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <!-- input image - opened image -->
  <node name="top_hat"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/TopHat sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <!-- input image - closed image -->
  <node name="black_hat"
        pkg="nodelet" type="nodelet"
        args="load jsk_perception/BlackHat sample_manager">
    <remap from="~input" to="mask_image/mask"/>
    <rosparam>
      size: 2
      iterations: 2
    </rosparam>
  </node>

  <group if="$(arg gui)">
    <node name="tile_image"
          pkg="jsk_perception" type="tile_image.py">
      <rosparam>
        input_topics:
          - /mask_image/mask
          - /erode_mask_image/output
          - /dilate_mask_image/output
          - /opening/output
          - /closing/output
          - /morphological_gradient/output
          - /top_hat/output
          - /black_hat/output
        draw_topic_name: true
        font_scale: 3.0
      </rosparam>
    </node>

    <node name="image_view"
          pkg="image_view" type="image_view">
      <remap from="image" to="tile_image/output"/>
    </node>
  </group>
</launch>
