Abstract: A method for autonomously operating an unmanned aerial vehicle (UAV) that includes one or more imaging devices is provided. The imaging devices are pointed away from a direction in which the UAV is flying, and subsequently, an upcoming portion of a current flight path of the UAV is imaged, using the imaging devices. In response to the imaging, an obstacle on the current flight path is detected, and an alternate flight path is planned in response thereto. The UAV is then flown along the alternate flight path, instead of the current flight path. Other embodiments are also described.