Code ported onto Linux. Contour detection.