This Python script utilizes the dlib library for face detection and facial landmarks to detect and crop a human head in an image. The detect_and_crop_head
function takes an input image file, detects the face using a pre-trained 5-point facial landmarks model, and crops the image to include the entire head with a 1:1 aspect ratio. The cropping is adjusted based on the roll and yaw angles calculated from the facial landmarks.
- Python 3
- OpenCV
- dlib
- NumPy