gpt4 book ai didi

python - 用名字python进行人脸识别

转载 作者:太空宇宙 更新时间:2023-11-03 21:52:29 24 4
gpt4 key购买 nike

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30),
flags=cv2.cv.CV_HAAR_SCALE_IMAGE
)

# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)

# Display the resulting frame
cv2.imshow('Video', frame)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

我有一个从网络摄像头检测人脸的基本算法 > 当他们出现在网络摄像头中时,我应该怎么做才能显示他们各自的名字?

请帮忙!

最佳答案

你可以用它的文本声明字体并指定它的位置。在我的示例中,它将位于矩形下方

font = cv2.FONT_HERSHEY_SIMPLEX(
thickness = 1,
white = (255,) * 3,
size = 1,
left = (x, y+h+12))

# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.putText(frame, 'Identity Unknown', left, font, size, white, thickness) #this line displays the text

关于python - 用名字python进行人脸识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36299754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com