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 ...
随机推荐
- 富文本存储型XSS的模糊测试之道
富文本存储型XSS的模糊测试之道 凭借黑吧安全网漏洞报告平台的公开案例数据,我们足以管中窥豹,跨站脚本漏洞(Cross-site Script)仍是不少企业在业务安全风险排查和修复过程中需要对抗的“大 ...
- 通过BurpSuite和sqlmap配合对dvwa进行sql注入测试和用户名密码暴力破解
0x1 工具和环境介绍 dvwa:渗透测试环境 BurpSuite:强大的WEB安全测试工具 sqlmap:强大的sql注入工具 以上工具和环境都在kali linux上安装和配置. 0x2 步骤说明 ...
- Centos6.5下搭建nagios详解
一.LAMP环境部署 1.安装php 1.安装yum源 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-releas ...
- Jenkins无法安装插件或首次安装插件界面提示Offline
一.首先点击系统管理 二.点击插件管理 三.选择高级管理 四.将升级站点中的https改成http即可
- HTTP之二 http 301 和 302的区别
1.什么是301转向?什么是301重定向? 301转向(或叫301重定向,301跳转)是当用户或搜索引擎向网站服务器发出浏览请求时,服务器返回的HTTP数据流中头信息(header)中的状态码的一种, ...
- 19 Error handling and Go go语言错误处理
Error handling and Go go语言错误处理 12 July 2011 Introduction If you have written any Go code you have pr ...
- redis持久化的两种方式
redis是一个内存型数据库.当redis服务器重启时,数据会丢失.我们可以将redis内存中的数据持久化保存到硬盘的文件中. redis持久化有两种机制.RDB与AOF.默认方式是RDB. 1.RD ...
- POJ 2516 Minimum Cost(拆点+KM完备匹配)
题目链接:http://poj.org/problem?id=2516 题目大意: 第一行是N,M,K 接下来N行:第i行有K个数字表示第i个卖场对K种商品的需求情况 接下来M行:第j行有K个数字表示 ...
- javascript数组元素的添加、删除与插入以及参数数组的使用
1.数组元素的添加 push方法在数组的尾部添加元素: var colorArray=new Array(); colorArray.push('red','black','yellow'); //这 ...
- python实现获取系统版本和mac信息上传到指定接口
import os,platform,uuid,urllib.parse,urllib.request,json def BeforeSystemRequests(): ''' the systemi ...