@@ -1,3 +1,35 @@
# dlib
-面部识别
+面部识别
+
+```
+import dlib
+import cv2
+import numpy as np
+# 加载 dlib 的人脸检测器
+detector = dlib.get_frontal_face_detector()
+# 加载输入图像
+image = cv2.imread('input_image.jpg')
+# 将图像转换为灰度图像
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+# 使用人脸检测器检测图像中的人脸
+faces = detector(gray)
+# 遍历检测到的人脸
+for face in faces:
+ x, y, w, h = face.left(), face.top(), face.width(), face.height()
+ # 在图像中标记人脸位置
+ cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
+# 显示标记后的图像
+cv2.imshow('Detected Faces', image)
+cv2.waitKey(0)
+cv2.destroyAllWindows()