A lane keeping system is designed and realized based on the second generation of Tsinghua active safety vehicle platform (THASV-II). The system integrates the lane detection and vehicle detection in the driving environment sensing module to improve the anti-disturbance ability of the lane detection. The image information captured by monocular vision and the obstacles data obtained by lidar are fused to recognize vehicles; a lane detection method based on the points set optimization is proposed. A preview PID controller is designed for the lateral control. Experiments of vehicle detection, lane detection and lane keeping are carried out on the THASV-II platform.