透過Dlib的臉部81個關鍵點去抓取額頭、臉頰、人中ROI區塊各自劃分22個區域
採用程式語言: python3.11 套件: dlib-bin 20.0.1 opencv-python4.11.0.86 numpy2.2.6 81個關鍵點下載網址 https://github.com/codeniko/shape_predictor_81_face_landmarks/blob/master/shape_predictor_81_face_landmarks.dat 除了原來的 68 個臉部標誌外,作者還額外添加了 13 個標誌來覆蓋前額區域。 第一階段測試程式 from pathlib import Path import cv2 import dlib import numpy as np VIDEO_PATH = R"F:\DeepfakeTIMIT.tar\DeepfakeTIMIT\higher_quality\fjem0\sa1-video-fkms0.avi" MODEL_PATH = R"C:\img\shape_predictor_81_face_landmarks.dat" #將一個大矩形切成多個小矩形 def split_rectangle (box, rows, cols, region_name): """ box: (x1, y1, x2, y2) rows: 垂直方向切幾列 cols: 水平方向切幾欄 """ x1, y1, x2, y2 = box # 防止座標順序顛倒 x1, x2 = sorted (( int (x1), int (x2))) y1, y2 = sorted (( int (y1), int (y2))) # 無效矩形不處理 if x2 <= x1 or y2 <= y1: return [] xs = np.linspace(x1, x2, cols + 1 , dtype= int ) ys = np.linspace(y1, y2, rows + 1 , dtype= int ) small...