【问题标题】:face recognition with names python人脸识别名字python
【发布时间】:2016-07-17 22:05:53
【问题描述】:
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

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

请帮忙!

【问题讨论】:

    标签: python opencv opencv3.0


    【解决方案1】:

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

    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
    

    【讨论】:

    • 您可以随意调整文本的位置,例如我找到了最理想的左侧位置 = (x, y+h+20)
    猜你喜欢
    • 2023-03-06
    • 1970-01-01
    • 2018-06-14
    • 2019-08-10
    • 2019-01-21
    • 2017-02-26
    • 2017-02-03
    • 2019-05-10
    • 2013-12-24
    相关资源
    最近更新 更多