当前位置:网站首页>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.
边栏推荐
- 【指针】数组逆序重新存放后并输出
- Always of SystemVerilog usage_ comb 、always_ iff
- [pointer] find the largest string
- Wu Enda's latest interview! Data centric reasons
- DVWA exercise 05 file upload file upload
- 关于超星脚本出现乱码问题
- Fundamentals of digital circuits (I) number system and code system
- Binary search tree concept
- “人生若只如初见”——RISC-V
- 指针--剔除字符串中的所有数字
猜你喜欢
Statistics 8th Edition Jia Junping Chapter 4 Summary and after class exercise answers
Wang Shuang's detailed learning notes of assembly language II: registers
5 minutes to master machine learning iris logical regression classification
后台登录系统,JDBC连接数据库,做小案例练习
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
数字电路基础(三)编码器和译码器
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
《统计学》第八版贾俊平第五章概率与概率分布
5分钟掌握机器学习鸢尾花逻辑回归分类
随机推荐
Binary search tree concept
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
函数:计算字符串中大写字母的个数
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
"If life is just like the first sight" -- risc-v
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Pointer -- output all characters in the string in reverse order
【指针】求二维数组中最大元素的值
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
1. Payment system
DVWA exercise 05 file upload file upload
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
Always of SystemVerilog usage_ comb 、always_ iff
1.支付系统
Fundamentals of digital circuits (III) encoder and decoder