Video Analysis for Improving Transportation Safety: Obstacles and Collision Detection Applied to Railways and Roads