Face detection and tracking technology is used in transportation, security, military fields. In view of the traditional face detection and tracking technology is easy to be affected by light, which leads to low detection accuracy, this paper uses Retinaface and Camshift algorithm to face detection, and realizes real time face detection and tracking by P control steering gear in PID control. Through tests in different environments, the detection accuracy of the Retinaface algorithm and the Camshift algorithm is above 99%. The camera is rotated through P to ensure that the face can be captured by the camera, and the camera response time can reach 0.1s.