当前位置:网站首页>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.
边栏推荐
- Wu Enda's latest interview! Data centric reasons
- c语言学习总结(上)(更新中)
- [pointer] find the largest string
- Wang Shuang's detailed notes on assembly language learning I: basic knowledge
- 【指针】数组逆序重新存放后并输出
- [pointer] use the insertion sorting method to arrange n numbers from small to large
- How does SQLite count the data that meets another condition under the data that has been classified once
- Always of SystemVerilog usage_ comb 、always_ iff
- [pointer] octal to decimal
- 《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
猜你喜欢

数据库多表链接的查询方式
![New version of postman flows [introductory teaching chapter 01 send request]](/img/0f/a41a39093a1170cc3f62075fd76182.jpg)
New version of postman flows [introductory teaching chapter 01 send request]

Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator

How to transform functional testing into automated testing?

《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案

《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案

The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?

关于交换a和b的值的四种方法

《统计学》第八版贾俊平第四章总结及课后习题答案

数字电路基础(一)数制与码制
随机推荐
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
Pointers: maximum, minimum, and average
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
ES全文索引
Numpy快速上手指南
数字电路基础(三)编码器和译码器
What level do 18K test engineers want? Take a look at the interview experience of a 26 year old test engineer
【指针】使用插入排序法将n个数从小到大进行排列
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
Using flask_ Whooshalchemyplus Jieba realizes global search of flask
"If life is just like the first sight" -- risc-v
Function: find the root of the equation by Newton iterative method
How to use Moment. JS to check whether the current time is between 2 times
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
Keil5-MDK的格式化代码工具及添加快捷方式
后台登录系统,JDBC连接数据库,做小案例练习
Summary of thread implementation
Intranet information collection of Intranet penetration (3)