python opencv3 检测人
git:https://github.com/linyi0604/Computer-Vision
# coding:utf-8 import cv2 # 检测i方框 包含o方框
def is_inside(o, i):
ox, oy, ow, oh = o
ix, iy, iw, ih = i
return ox > ix and ox + ow < ix + iw and oy + oh < iy + ih # 将人外面的方框画出来
def draw_person(image, person):
x, y, w, h = person
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 255), 2) # 读入图片
img = cv2.imread("../data/people2.jpg")
# 获取hog检测器对象
hog = cv2.HOGDescriptor()
# 设置检测人的默认检测器
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
# 在图片中检测人,
# 返回found列表 每个元素是一个(x, y, w, h)的矩形,w是每一个矩形的置信度
found, w = hog.detectMultiScale(img)
found_filtered = []
# 如果方框有包含,只留下内部的小方块
for ri, r in enumerate(found):
for qi, q in enumerate(found):
if ri != qi and is_inside(r, q):
break
else:
found_filtered.append(r) # 将每一个方块画出来
for person in found_filtered:
draw_person(img, person) cv2.imshow("person detection", img)
cv2.waitKey()
cv2.destroyAllWindows()

python opencv3 检测人的更多相关文章
- Python智能检测编码并转码
#安装包工具 $pip3 install chardet #直接打开文件,中文显示乱码 >>> import chardet >>> f = open('test. ...
- Python IAQ中文版 - Python中少有人回答的问题
Python中少有人回答的问题 The Python IAQ: Infrequently Answered Questions 1 Q: 什么是"少有人回答的问题(Infrequently ...
- python opencv3 cornerHarris 角点检测
git:https://github.com/linyi0604/Computer-Vision 角点也是处在一个无论框框往哪边移动 框框内像素值都会变化很大的情况而定下来的点 如果框框水平方向上移动 ...
- python opencv3 摄像头人脸检测
git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 def detect(): # 创建人脸检测的对象 ...
- python opencv3 静态图片检测人脸
git:https://github.com/linyi0604/Computer-Vision # coding:utf-8 import cv2 filename = "../data/ ...
- python opencv3 圆检测
git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 import numpy as np img_ori ...
- python opencv3 直线检测
git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 import numpy as np # 读入图像 ...
- python opencv3 grabcut前景检测
git:https://github.com/linyi0604/Computer-Vision import numpy as np import cv2 import matplotlib.pyp ...
- python opencv3 轮廓检测
git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 import numpy as np # 创建一个2 ...
随机推荐
- 无需登录-悟空CRM 存储型XSS
无需登录-悟空CRM 存储型XSS 审计悟空的缘由是看见某云爆出CRM的getshell,于是就想着去挖出来瞅瞅!但可能自己把自己给局限了,就想着去挖那些无限制访问的文件. 故事的发生点 漏洞文件:/ ...
- numpy之ones,array,asarray
from:http://blog.csdn.net/gobsd/article/details/56485177 numpy.ones() 废话少说直接上代码 >>> np.ones ...
- Fiddler大师之路系列(一)
江湖传言,Fiddler是捕获客户端与服务器之间的所有HTTP(S) 请求的利器,但是在具体使用过程中,发现使用Fiddler进行抓包时有一部分请求总是没到,多方苦寻之下发现客户端使用WinINET这 ...
- setInterval做定时器
<script src="/js/jquery-1.8.3.min.js"></script> <script> $(function () { ...
- NuGet服务器搭建教程
本文主要来自网络,进行整理而成,相关文章如下: http://diaosbook.com/Post/2012/12/15/setup-private-nuget-server https://www. ...
- C# 序列化高级用法
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
- VirtualBox上安装CentOS-7(Minimal)
Windows 10家庭中文版,VirtualBox 5.2.12,CentOS 7(Minimal版), 因为听到大家在谈论CentOS,阿里云上也有CentOS,CentOS还是Red Hat出品 ...
- 深度解析eclipse控制台
第一个按钮:scroll lock 控制台在打印sql语句的时候会一直滚动,用这个按钮可以固定住控制台不乱跑; 第二个按钮:show console when standard out changes ...
- Java标记接口
写在前面的话:读书破万卷,编码如有神--------------------------------------------------------------------这篇博客主要来谈谈" ...
- HDU 1054 Strategic Game(最小路径覆盖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054 题目大意:给你一棵树,选取树上最少的节点使得可以覆盖整棵树. 解题思路: 首先树肯定是二分图,因 ...