Overview

Underwater imagery differs from surface imagery due to several factors:

  1. Light Absorption: Water absorbs light, especially red wavelengths, much more quickly than air. As a result, underwater scenes tend to be dominated by blue and green hues, with reds appearing faded or absent at greater depths.
  2. Scattering: Water particles scatter light in all directions, reducing clarity and contrast. This scattering makes underwater images appear hazier and less sharp than those taken in air, particularly in murky waters.
  3. Color Shift: As depth increases, the color spectrum shifts. Reds and oranges are lost first, followed by yellows and greens. At deeper levels, everything appears bluish or greenish, with a significant loss of color variety.
  4. Reduced Visibility: Suspended particles, plankton, and other substances in water reduce visibility, leading to a foggy or cloudy appearance in images, particularly in coastal or murky waters.
  5. Limited Light Penetration: Unlike air, water significantly reduces the amount of light that penetrates, making deep underwater environments much darker and requiring artificial lighting for clear images.

These factors combine to create underwater imagery that is distinctively muted in color, lower in contrast, and often more challenging to capture with clarity compared to surface imagery.

Example Usage

  1. Create a camera sensor of type RGB-D and attach the plugin to the model.sdf file as shown below:

    <sensor name="underwater_camera" type="rgbd_camera">
      <update_rate>10</update_rate>
      <visualize>true</visualize>
      <always_on>1</always_on>
      <topic>underwater_camera</topic>
      <camera>
        <horizontal_fov>1.05</horizontal_fov>
        <image>
          <width>320</width>
          <height>240</height>
        </image>
        <clip>
          <near>0.1</near>
          <far>10.0</far>
        </clip>
      </camera>
      <plugin
        filename="UnderwaterCamera"
        name="dave_gz_sensor_plugins::UnderwaterCamera">
        <attenuationR>0.8</attenuationR>
        <attenuationG>0.5</attenuationG>
        <attenuationB>0.2</attenuationB>
        <!-- Murky Coastal Waters -->
        <backgroundR>85</backgroundR>
        <backgroundG>107</backgroundG>
        <backgroundB>47</backgroundB>
      </plugin>
    </sensor>
    

    Description of the UnderwaterCamera plugin arguments:

    Argument Description Default Value
    attenuationR This parameter represents the attenuation coefficient for the red color channel. 0.0
    attenuationG This parameter represents the attenuation coefficient for the green color channel. 0.0
    attenuationB This parameter represents the attenuation coefficient for the blue color channel. 0.0
    backgroundR This parameter sets the intensity of the red component of the background color. 0
    backgroundG This parameter sets the intensity of the green component of the background color. 0
    backgroundB This parameter sets the intensity of the blue component of the background color. 0
  2. Build and source the workspace:

    cd ~/dave_ws
    colcon build && source install/setup.bash
    
  3. Launch the camera in an underwater setting:

    ros2 launch dave_demos dave_sensor.launch.py namespace:=underwater_camera world_name:=camera_tutorial paused:=false x:=10 z:=-93.5 pitch:=0.3 yaw:=3.14
    

    <aside> ⚠️ Important launch arguments:

    Argument Name Description Default Value
    namespace Name of the sensor (select from the available sensors) “”
    world_name Gazebo world file to launch (use dvl_world to test the DVL functionality) empty.sdf
    paused Start the simulation paused true
    debug Enables verbose mode for Gazebo simulation false
    verbose Adjust level of console verbosity 0
    x Initial x position [m] 0.0
    y Initial y position [m] 0.0
    z Initial z position [m] 0.0
    roll Initial roll angle [rad] 0.0
    pitch Initial pitch angle [rad] 0.0
    yaw Initial yaw angle [rad] 0.0

    </aside>

    Screenshot 2024-09-01 at 3.15.18 AM.png

  4. Open another terminal, source the workspace and check for available ROS 2 topics:

    cd ~/dave_ws && source install/setup.bash
    ros2 topic list
    

    It should produce an output similar to:

    Screenshot 2024-09-01 at 3.16.17 AM.png

  5. Open another terminal, source the workspace and view the simulated image using image_view :

    cd ~/dave_ws && source install/setup.bash
    ros2 run image_view image_view --ros-args -r image:=/underwater_camera/simulated_image
    

    Example 1: No effects

    Argument Value
    attenuationR 0.0
    attenuationG 0.0
    attenuationB 0.0
    backgroundR 0
    backgroundG 0
    backgroundB 0

    Screenshot 2024-09-01 at 3.23.49 AM.png

Example 2: Murky coastal water condition

Argument Value
attenuationR 0.8
attenuationG 0.5
attenuationB 0.2
backgroundR 85
backgroundG 107
backgroundB 47

Screenshot 2024-09-01 at 3.24.43 AM.png