【问题标题】:detecting full body instead of face with opencv in python [closed]在python中使用opencv检测全身而不是面部[关闭]
【发布时间】:2019-11-24 10:45:01
【问题描述】:

我有一个检测我的脸的代码。但我想检测整个身体而不仅仅是面部。

import numpy as np
import cv2

detector= cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)

while(True):
    ret, img = cap.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    faces = detector.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in faces:
        cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)

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

cap.release()
cv2.destroyAllWindows()

我想检测全身

【问题讨论】:

  • OpenCV 的 CascadeClassifier 并不是一个真正强大的人体检测器(即使使用适当的数据进行训练)。您可能应该进行谷歌搜索以查看选项是什么。例如,YOLO 将是一个非常好的候选者。
  • 你可能不应该使用名为 ...frontalface...xml 的东西。

标签: python python-3.x opencv face-detection face-recognition


【解决方案1】:

只需将其更改为:

detector= cv2.CascadeClassifier('haarcascade_fullbody.xml')

您可能可以在 cv2/data/haarcascades 中找到这个 xml 文件。 也可以下载here (右键单击并选择另存为...)

【讨论】:

    猜你喜欢
    • 2019-05-06
    • 1970-01-01
    • 2016-04-24
    • 1970-01-01
    • 2017-01-15
    • 1970-01-01
    • 2016-05-02
    • 2016-06-25
    • 2019-08-18
    相关资源
    最近更新 更多