Search⌘ K
AI Features

Face Matching Using the Manhattan Distance Algorithm

Explore how to implement face matching by comparing facial encodings using the Manhattan distance algorithm in Python. This lesson guides you through building a utility that compares a test face against a database of stored faces, explains essential functions, and tests the matching process with example images. By the end, you will understand how to apply Manhattan distance metrics for effective facial recognition matching.

Introduction

Face recognition identifies human faces based on visual appearance. Facial recognition systems mostly make their decisions based on distance measures. Distance metrics play a key role in matching images.

What is the Manhattan distance metric?

In short, the Manhattan distance, also known as city block distance or L1 distance, represents the distance necessary to get from one data point to another. The Manhattan distance between two points represents the sum of the absolute differences between their Cartesian coordinates.

The following figure is a visual illustration of the Manhattan distance metric:

In this 2-D space, the Manhattan distance between these two points is the sum of the differences in their corresponding components:

dist=p1q1+p2q2dist = |p_1 - q_1| + |p_2 - q_2| ...