Face Detection and Marking with Python and OpenCV — (Beginners)

Mertcan Arguç
4 min readJul 23, 2023

Introduction

Hello young followers! Today’s topic is an immersive journey into the magical world of computer image processing: Face Recognition and Landmarking! If you’re scratching your head, don’t worry. I’ll explain this impressive and seemingly complex piece of code, written in Python language, to you step-by-step and in a fun way.

Our companions on this journey will be OpenCV and Dlib! These two significant libraries developed for Python are some of the most valuable tools in the world of computer vision and machine learning. But today, we’re going to know them through their abilities in face recognition and landmarking.

Introducing the Libraries

First, we import our libraries.

pip install opencv-python
pip install dlib

The cv2 library is actually the Python version of OpenCV and contains many image processing functions. dlib is a machine learning library usually used for functions like face recognition and landmarking.

Face Detector and Predictor

detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

--

--

No responses yet