Abstract Technical advances have led to an increase in the use of the endoscope in neurosurgery in recent years, particularly for intraventricular procedures and pituitary and anterior skull base surgery. Recently stereoscopic three-dimensional (3D) endoscopes have become available and may over time replace traditional two-dimensional (2D) imagery. An alternative strategy would be to use computer software algorithms to give monocular 2D endoscopes 3D capabilities. In this study our objective was to recover depth information from 2D endoscopic images using optical flow techniques. Digital images were recorded using a 2D endoscope and a hierarchical structure from motion algorithm was applied to the motion of the endoscope in order to calculate depth information for the generation of 3D anatomical structure. We demonstrate that 3D data can be recovered from 2D endoscopic images taken during endoventricular surgery where there is a mix of rapid camera motion and periods where the camera is nearly stationary. These algorithms may have the potential to give 3D visualization capabilities to 2D endoscopic hardware.