OpenCV Distance Calculator with Image Segmentation