Welcome to Rider Pi Robot repository
12. Face effects
Face special effects
1. Experimental purpose
Realize the car's face detection and draw the corresponding face special effects
2. Experimental path source code
Enter the car's system, end the car program, enter "ip (ip is the car's ip): 8888" in the browser, enter the password "yahboom" Then log in Enter the path Rider-pi_class/5.AI Visual Recognition Course/12. Facial special effects and run 13_Face_effects.ipynb.
Or enter the command in the terminal and start the python script directly
cd /home/pi/Rider-pi_class/5.AI Visual Recognition Course/12. Facial special effectspython3 FaceLandmarks_USB.py3. Experimental phenomenon
After running the source code, you can see that the car will detect faces and add corresponding special effects to faces.

4. Analysis of the main program source code
xif __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) #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 car calls the detected face model and uses special effects to display the recognized face on the computer screen and the car's screen.