Welcome to DOGZILLA-Lite repository
11. Face effects
Face effects
1. Purpose of the experiment
Realize the robot dog's face recognition and draw the corresponding face effects
2. Experimental path source code
Enter the robot dog system, end the robot dog program, enter "ip (ip is the robot dog's ip):8888" in the browser, enter the password "yahboom" and log in. Enter the path of cd ~/DOGZILLA_Lite_class/5.AI Visual Recognition Course/11. Facial special effects and run Face_effects.ipynb .
Or enter the command in the terminal to directly start the Python script
xxxxxxxxxxcd ~/DOGZILLA_Lite_class/5.AI Visual Recognition Course/11. Facial special effectspython3 FaceLandmarks_USB.py
3. Experimental Phenomenon
After running the source code, you can see that the robot dog can detect human faces and add corresponding special effects to the faces.

4. Main program source code analysis
xxxxxxxxxxif __name__ == '__main__': capture = cv.VideoCapture(0) capture.set(6, cv.VideoWriter.fourcc('M', 'J', 'P', 'G')) capture.set(cv.CAP_PROP_FRAME_WIDTH, 320) capture.set(cv.CAP_PROP_FRAME_HEIGHT, 240) print("capture get FPS : ", capture.get(cv.CAP_PROP_FPS)) pTime, cTime = 0, 0 dat_file = "./file/shape_predictor_68_face_landmarks.dat" landmarks = FaceLandmarks(dat_file) while capture.isOpened(): ret, frame = capture.read() # frame = cv.flip(frame, 1) frame = landmarks.get_face(frame, draw=False) frame = landmarks.prettify_face(frame, eye=True, lips=True, eyebrow=True, draw=True) if cv.waitKey(1) & 0xFF == ord('q'): break cTime = time.time() fps = 1 / (cTime - pTime) pTime = cTime text = "FPS : " + str(int(fps)) cv.putText(frame, text, (20, 30), cv.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 1) cv.imshow('frame', frame) #把画面显示在lcd屏上 Display the image on the LCD screen b, g, r = cv.split(frame) image = cv.merge((r, g, b)) imgok = Image.fromarray(image) display.ShowImage(imgok) capture.release() cv.destroyAllWindows()The robot dog calls the detected face model and uses special effects to display the recognized face on the computer screen and the robot dog's screen.