Through marine seismic surveying. The ship in picture can generate sound waves through the firing of airguns almost every six seconds. The waves travel down to the seafloor and through the different rock formations. The waves hit the formations, bounce back (reflected or refracted) and this reflected/refracted wave is recorded by streamers that are being towed behind the ship.
The streamers contain hydrophone which picks up the waves that return to the surface. Geologists then retrieve this data and from their interpretation, they can tell if hydrocarbons (oil and gas) are present and exactly where they are located.