当前位置:网站首页>Face and eye recognition based on OpenCV's own model
Face and eye recognition based on OpenCV's own model
2022-07-06 14:53:00 【gmHappy】
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cv2
face_cascade = cv2.CascadeClassifier("D:/Open-cv/opencv/build/etc/haarcascades/haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier("D:/Open-cv/opencv/build/etc/haarcascades/haarcascade_eye.xml")
cap = cv2.VideoCapture(1)
while True:
ret, frame = cap.read()
i = frame
# print i.shape
gray = cv2.cvtColor(i, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
l = len(faces)
print (l)
for (x, y, w, h) in faces:
cv2.rectangle(i, (x, y), (x + w, y + h), (255, 0, 0), 2)
# cv2.putText(i,'face',(w/2+x,y-h/5),cv2.FONT_HERSHEY_PLAIN,2.0,(255,255,255),2,1)
roi_gray = gray[y:y + h, x:x + w]
roi_color = i[y:y + h, x:x + w]
eyes = eye_cascade.detectMultiScale(roi_gray)
for (ex, ey, ew, eh) in eyes:
cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)
cv2.putText(i, "face count", (20, 20), cv2.FONT_HERSHEY_PLAIN, 2.0, (255, 255, 255), 2, 1)
cv2.putText(i, str(l), (230, 20), cv2.FONT_HERSHEY_PLAIN, 2.0, (255, 255, 255), 2, 1)
cv2.imshow("rstp", i)
if cv2.waitKey(1) & 0xFF == ord('q'):
exit(0)
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
边栏推荐
- 函数:计算字符串中大写字母的个数
- 《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
- 后台登录系统,JDBC连接数据库,做小案例练习
- 《统计学》第八版贾俊平第一章课后习题及答案总结
- The four connection methods of JDBC are directly coded
- Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
- 《统计学》第八版贾俊平第四章总结及课后习题答案
- 数据库多表链接的查询方式
- Always of SystemVerilog usage_ comb 、always_ iff
- 数字电路基础(四) 数据分配器、数据选择器和数值比较器
猜你喜欢
150 common interview questions for software testing in large factories. Serious thinking is very valuable for your interview
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Quaternion -- basic concepts (Reprint)
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
Query method of database multi table link
Es full text index
Database monitoring SQL execution
数字电路基础(一)数制与码制
How to earn the first pot of gold in CSDN (we are all creators)
《統計學》第八版賈俊平第七章知識點總結及課後習題答案
随机推荐
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
Based on authorized access, cross host, and permission allocation under sqlserver
Fundamentals of digital circuits (I) number system and code system
Es full text index
[pointer] the array is stored in reverse order and output
How to transform functional testing into automated testing?
Cadence physical library lef file syntax learning [continuous update]
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
Using flask_ Whooshalchemyplus Jieba realizes global search of flask
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
数字电路基础(三)编码器和译码器
c语言学习总结(上)(更新中)
{1,2,3,2,5}查重问题
Login the system in the background, connect the database with JDBC, and do small case exercises
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
函数:计算字符串中大写字母的个数
王爽汇编语言学习详细笔记一:基础知识
Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
数字电路基础(一)数制与码制