Stereoscopic cameras (a class of depth cameras) are increasingly present in robotics navigation and 3D scene reconstruction. Normally, off-the-shelf depth cameras are not suited for underwater environments and exhibit considerable distortions in the provided 3D images when operating underwater. This is mainly due to the large difference in the refractive coefficients of air and water. This issue prevents their use in subsea applications such as the inspection of oil pipelines, valves and manifolds, where these devices could be used for odometry during ultrasonic inspections as well as for 3D scanning. Aiming to allow for such applications, we present a data-driven method for the correction of distortions caused by unaccounted diffractions in depth cameras. First, the distortion is modelled via a series of detections of control points from a standard target at known underwater positions, and an approximation of the inverse distortion is obtained. Then, at runtime, a procedure takes as input the (distorted) point cloud given by the camera at each frame, applies the inverse distortion, and yields a corrected point cloud. We apply the method to data provided by a RealSense D405 camera encased in a sealed acrylic container underwater. The correction made it possible to use the camera for 3D imaging underwater with root mean square error (RMSE) below 10 mm in the worst case tested. The method clears the path for the use of off-the-shelf depth cameras in a wide range of subsea applications.