当前位置:网站首页>Opencv realizes simple face tracking
Opencv realizes simple face tracking
2022-07-25 09:06:00 【Liu#】
Face tracking is to let the computer find the position of the face in a picture and frame it . stay OpenCV Some classifiers are encapsulated in , These classifiers are cascaded together in a certain order to form a cascaded classifier . Can face 、 nose 、 Recognize some parts such as eyes .
Cascade classifier location

Install it on your own python Location find location
classifier

OpenCV There are two steps to realize face tracking , Load cascade classifiers and use classifiers for image recognition .
'''
Create cascading classifiers
cascade= cv2.CascadeClassifier(filename)
filename: Classifier address
cascade: Classifier object
'''
'''
Use cascaded classifiers to recognize images
objects = cascade.detectMultiScale(image,scaleFactor,minNeighors,flags,minSize,maxSize)
cascade: Created Cascading Classifier object
image: Images to be analyzed
scaleFactor: Optional parameters , Zoom ratio when scanning the image
minNeighors: Optional parameters , At least how many detection results can be reserved in each candidate area to determine the face , The greater the value , The smaller the analysis error
flags: Optional parameters , It is recommended to use the default value
minSize: Optional parameters , Minimum target size
maxSize: Optional parameters , Maximum target size
Return value :
objects: An array of capture areas ,x、y、w、h, Abscissa 、 Ordinate 、 wide 、 high
'''Code
import cv2
video = cv2.VideoCapture(r"C:\Users\Liu\Videos\videos\demo.mp4")
# Load cascade classifiers
cascade = cv2.CascadeClassifier(r"F:\python3\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml")
while video.isOpened():
retval,img = video.read()
# Use classifiers to analyze images
faces = cascade.detectMultiScale(img)
for x,y,w,h in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),3)
cv2.imshow("Video",img)
key = cv2.waitKey(25)
if key == 32:
cv2.waitKey()
continue
elif key == 27:
break
video.release()
cv2.destroyAllWindows()result

边栏推荐
- Software examination system architecture designer concise tutorial | software life cycle
- js弹出式城市筛选组件匹配手机移动端
- Why use MQ message oriented middleware? These questions must be taken down!
- 51单片机内部外设:定时器和计数器
- The development of art NFT
- unity客户端读取文本配置
- Graduation design of wechat small program ordering system of small program completion works (5) assignment
- How does Flink SQL persist?
- Learn about spark project on Nebula graph
- canvas动态图片头像晃动js特效
猜你喜欢

LeetCode·83双周赛·6129.全0子数组的数目·数学

sticksy.js页面滚动div固定位置插件

Django4.0 + Web + MySQL5.7 实现简单登录操作

The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference

js小游戏源码魔塔闯关下载

JMeter test plan cannot be saved solution

canvas很多圆圈组成的文本js特效

Graduation design of wechat small program ordering system of small program completion works (5) assignment

51 MCU internal peripherals: serial port communication

This ten-year content industry infrastructure company is actually an invisible Web3 pioneer
随机推荐
What is steel grating?
table表格展开内部行切换效果
This is the worst controller layer code I've ever seen
51 MCU peripherals: Motor
C语言实现二叉平衡树
这是我见过写得最烂的Controller层代码...
JMeter test plan cannot be saved solution
Intel apologized to the winners of Xe HPG treasure hunt game for product delay and announced the appearance of the prize
Leetcode · 83 biweekly race · 6129. Number of all 0 subarrays · mathematics
The development of art NFT
The simplest sklearn environment configuration tutorial in the whole network (100% success)
Es source code reading (I) "suggestions collection"
Disable module (attribute node) in LabVIEW
Technical aspect ② what are the index types in MySQL and briefly introduce them? When do I need to create an index? When is it not necessary to create an index? Why does the query speed increase after
(self drawn ugly picture) simple understanding tcp/ip three handshakes and four waves
Wechat reservation applet graduation design of applet completion works (2) applet function
Sina Weibo client (4) - set navigation bar theme
Additional: SQL statement area / county in the middle half (data table)
Unity ugui interaction (new ideas)
机器人跳跃问题