python 人体检测技术_OpenCV 3 Python – 部分人体检测?

我正在使用Python使用OpenCV进行人体检测程序 . 我看到了this very good example,我把它放在它的样品上 . 它可以检测人员,无论他们面对的是什么,并且具有适当的重叠检测以及运动模糊 .

然而,当我在一些图像上运行它时(大多数是膝盖向上,腰部以及胸部照片的人),我发现该软件并不能完全发现人 .

# import the necessary packages

from __future__ import print_function

from imutils.object_detection import non_max_suppression

from imutils import paths

import numpy as np

import argparse

import imutils

import cv2

ap = argparse.ArgumentParser()

ap.add_argument(“-i”, “–images”, required=True, help=”path to images directory”)

args = vars(ap.parse_args())

# initialize the HOG descriptor/person detector

hog = cv2.HOGDescriptor()

hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())

# loop over the image paths

imagePaths = list(paths.list_images(args[“images”]))

for imagePath in imagePaths:

# load the image and resize it to (1) reduce detection time

# and (2) improve detection accuracy

image = cv2.imread(imagePath)

image = imutils.resize(image, width=min(400, image.shape[1]))

orig = image.copy()

# detect people in the image

(rects, weights) = hog.detectMultiScale(image, winStride=(4, 4),

padding=(8, 8), scale=1.05)

# draw the original bounding boxes

for (x, y, w, h) in rects:

cv2.rectangle(orig, (x, y), (x + w, y + h), (0, 0, 255), 2)

# apply non-maxima suppression to the bounding boxes using a

# fairly large overlap threshold to try to maintain overlapping

# boxes that are still people

rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])

pick = non_max_suppression(rects, probs=None, overlapThresh=0.65)

# draw the final bounding boxes

for (xA, yA, xB, yB) in pick:

cv2.rectangle(image, (xA, yA), (xB, yB), (0, 255, 0), 2)

# show some information on the number of bounding boxes

filename = imagePath[imagePath.rfind(“/”) + 1:]

print(“[INFO] {}: {} original boxes, {} after suppression”.format(

filename, len(rects), len(pick)))

# show the output images

cv2.imshow(“Before NMS”, orig)

cv2.imshow(“After NMS”, image)

cv2.waitKey(0)

这很简单 . 它遍历图像,找到其中的人,然后绘制边界矩形 . 如果矩形重叠,它们将连接在一起以防止误 并在一个人中检测到超过1个人 .

但是,正如我上面提到的,如果他们的脚部不存在,代码就无法识别人 .

有没有办法让OpenCV识别出可能只有部分身体(膝盖向上,腰部向上,胸部向上)出现在视频中的人的用例场景中,我不认为寻找手臂和腿是至关重要的,只要躯干和头部存在,我应该能够看到它 .

文章知识点与官方知识档案匹配,可进一步学习相关知识Python入门技能树首页概览215503 人正在系统学习中 相关资源:Eclipse 三角形程序_eclipse等腰三角形Java文档类资源

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年1月25日
下一篇 2021年1月25日

相关推荐