How to realize Animation face Detection by python
This article mainly explains the "python how to achieve animation face detection", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "python how to achieve animation face detection" bar!
1. Project profile
The animation face detection is realized by using opecv's python library and the trained cascade classifier.
two。 Project address 3. Depending on the module pip install opencv-python4. Complete code import cv2def face_detect (file_name, cascade_name): img = cv2.imread (file_name) # read picture img_gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY) # picture graying img_gray = cv2.equalizeHist (img_gray) # histogram equalization face_cascade = cv2.CascadeClassifier (cascade_name) # load cascade classifier faces = face_cascade.detectMultiScale (img) # Multiscale detection for (x, y, w H) in faces: # iterate through all detected animated faces img = cv2.rectangle (img, (x, y), (XQuW, YFH), (255,0,255), (255,0,255), 5) # draw a rectangle cv2.imshow ('Face detection', img) # Preview cv2.waitKey (0) # keep the window showing if _ name__ = "_ main__": face_detect (' test.jpg', 'lbpcascade_animeface.xml') 5. Necessary components
Opencv officially does not provide cascading classification files for animation faces. The classifier used here is provided by nagadomi: lbpcascade_animeface.xml
6. Results show 6.1. Test sample 1
6.2. Test sample 2
6.3. Test sample 3
7. Comparison and analysis
From the test results, although it is based on lbp cascade feature detection, but the detection accuracy is still very high, and the time is also short.
Thank you for your reading, the above is the content of "how to achieve animation face detection in python". After the study of this article, I believe you have a deeper understanding of how to achieve animation face detection in python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!