current position:Home>Python has been hidden for ten years, and once image recognition is heard all over the world
Python has been hidden for ten years, and once image recognition is heard all over the world
2022-01-30 16:49:51 【Java architects Alliance】
Preface
Face processing is a hot topic in artificial intelligence , Face processing can automatically extract a large amount of information from the face using computer vision algorithms , For example, identity 、 Intention and emotion . Face plays an important role in visual communication , This is because the face contains a lot of nonverbal information , Therefore, face processing has always been a very interesting topic for computer vision learners , Because it involves different professional fields , For example, object detection 、 Feature point detection and object tracking . In this paper , We will first introduce the common face processing libraries , Then it explains how to use these databases for face detection , Lay a foundation for further related processing .\
Introduction to face processing
In order to focus on face processing related topics , We will use OpenCV library , as well as dlib、face_recognition and cvlib etc. Python package . meanwhile , This paper will use different methods in face processing , To introduce different methods to solve specific face processing tasks , The introduction of different methods will help you choose different methods according to different application needs . The following figure shows the related topics of face processing , And the available Python package :\
As shown in the figure above , Face processing mainly includes the following topics :
Face detection : A special case of object detection , Its task is to find the position and size of all faces in the image . Facial feature point detection : A special case of feature point detection , Its task is to locate the main feature points in the face . Face tracking : A special case of object tracking , Its task is to use the additional information extracted in the continuous frames of the video , Find the location and size of all moving faces in the video . Face recognition : A special case of target recognition , Its task is to recognize or verify a person from an image or video using the information extracted from the face : Face recognition (1:N): Find the closest match to the detected face in the known face set, face verification (1:1): Check whether the detected face is the person it claims, as described above , Face processing mainly includes : Face detection 、 Facial feature point detection 、 Face tracking and Face recognition , And in the daily recognition process , Use the most OpenCV、dlib、face_recognition and cvlib Database for face detection , And today we'll talk about opencv Application , This is also the simplest way , Because many algorithm modules have been encapsulated
Other face processing topics will be introduced in a subsequent series .
Okay , Don't talk much , On the subject
setup script
First step : install opencv modular
use pip When the management tool installs library files , Default to use foreign source files , Therefore, the download speed in China will be relatively slow , Maybe it's just 50KB/s. fortunately , Some top scientific research institutions in China have prepared various images for us , Download up to 2MB/s
Can be used in pip When , Add parameters -i Image and address ( Such as
pypi.tuna.tsinghua.edu.cn/simple),
for example :
pip install -i pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python
After installation , The following content will appear in your installation path \
These are the opencv Its own algorithm model , Can be called directly
The following is the code implementation of the call
Start with the simple , First recognize the face in the picture \
# opencvimport cv2
face_detector = cv2.CascadeClassifier('./haarcascade_frontalface_alt.xml')
img = cv2.imread('./image.jpeg')
face_zones = face_detector.detectMultiScale(img)
for x,y,w,h in face_zones:
cv2.circle(img,center=(x+w//2,y+h//2),radius=w//2,color=[0,0,255],thickness=2)
cv2.imshow('face',img)
cv2.waitKey(0)cv2.destroyAllWindows()
Copy code
Execution results , Just change the address of the picture
When the picture is linked , What is formed is the recognition effect of video \
Code up \
''' Turn on the camera '''
import numpy as np
import cv2
face_detector = cv2.CascadeClassifier('./haarcascade_frontalface_alt.xml')
video = cv2.VideoCapture(0)# Turn on the camera
while True:
flag,frame = video.read()
if flag == False:
break
gray = cv2.cvtColor(frame,code = cv2.COLOR_BGR2GRAY)
face_zones = face_detector.detectMultiScale(gray)
for x,y,w,h in face_zones:
cv2.circle(frame,center = (x+w//2,y+h//2),radius = w//2,color = [0,0,255],thickness = 2)
cv2.imshow('ttnk',frame)
key = cv2.waitKey(41)
if key == ord('q'):# Exit conditions
break
cv2.destroyAllWindows()
video.release()
Copy code
Much of this is a dead cycle , Continuously update the obtained picture information in a circular way , Finally, integrate , Is the content of a video
And the acquisition of test images , You can see the crawler tutorial I wrote to you before , Code directly , Can pay attention to :Java After the alliance of architects , The background to reply 【 Reptiles 】 Get oh
copyright notice
author[Java architects Alliance],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201301649491791.html
The sidebar is recommended
- Python notes (6): definition and use of lists
- Python notes (V): string operation
- Python notes (IV): use of functions and modules
- Python notes (3): conditional statements and circular statements
- Python notes (II): lexical structure
- Notes on python (I): getting to know Python
- [Python data structure series] - tree and binary tree - basic knowledge - knowledge point explanation + code implementation
- [Python daily homework] Day7: how to combine two dictionaries in an expression?
- How to implement a custom list or dictionary in Python
- 15 advanced Python tips for experienced programmers
guess what you like
-
Python string method tutorial - how to use the find() and replace() functions on Python strings
-
Python computer network basics
-
Python crawler series: crawling global airport information
-
Python crawler series: crawling global port information
-
How to calculate unique values using pandas groupby
-
Application of built-in distribution of Monte Carlo simulation SciPy with Python
-
Gradient lifting method and its implementation in Python
-
Pandas: how to group and calculate by index
-
Can you create an empty pandas data frame and fill it in?
-
Python basic exercises teaching! can't? (practice makes perfect)
Random recommended
- Exploratory data analysis (EDA) in Python using SQL and Seaborn (SNS).
- Turn audio into shareable video with Python and ffmpeg
- Using rbind in python (equivalent to R)
- Pandas: how to create an empty data frame with column names
- Talk about quantifying investment using Python
- Python, image restoration in opencv - CV2 inpaint
- Python notes (14): advanced technologies such as object-oriented programming
- Python notes (13): operations such as object-oriented programming
- Python notes (12): inheritance such as object-oriented programming
- Chapter 2: Fundamentals of python-5 Boolean
- Python notes (11): encapsulation such as object-oriented programming
- Python notes (10): concepts such as object-oriented programming
- Gradient lifting method and its implementation in Python
- Van * Python | simple crawling of a site course
- Chapter 1 preliminary knowledge of pandas (list derivation and conditional assignment, anonymous function and map method, zip object and enumerate method, NP basis)
- Nanny tutorial! Build VIM into an IDE (Python)
- Fourier transform of Python OpenCV image processing, lesson 52
- Introduction to python (III) network request and analysis
- China Merchants Bank credit card number recognition project (Part I), python OpenCV image processing journey, Part 53
- Introduction to python (IV) dynamic web page analysis and capture
- Python practice - capture 58 rental information and store it in MySQL database
- leetcode 119. Pascal's Triangle II(python)
- leetcode 31. Next Permutation(python)
- [algorithm learning] 807 Maintain the city skyline (Java / C / C + + / Python / go / trust)
- The rich woman's best friend asked me to write her a Taobao double 11 rush purchase script in Python, which can only be arranged
- Glom module of Python data analysis module (1)
- Python crawler actual combat, requests module, python realizes the full set of skin to capture the glory of the king
- Summarize some common mistakes of novices in Python development
- Python libraries you may not know
- [Python crawler] detailed explanation of selenium from introduction to actual combat [2]
- This is what you should do to quickly create a list in Python
- On the 55th day of the journey, python opencv perspective transformation front knowledge contour coordinate points
- Python OpenCV image area contour mark, which can be used to frame various small notes
- How to set up an asgi Django application with Postgres, nginx and uvicorn on Ubuntu 20.04
- Initial Python tuple
- Introduction to Python urllib module
- Advanced Python Basics: from functions to advanced magic methods
- Python Foundation: data structure summary
- Python Basics: from variables to exception handling
- Python notes (22): time module and calendar module