Automatic eye localization (EL) and eye state (open or closed) recognition (ESR) are still open challenges due to various difficulties, such as low resolution, lighting interference and changing appearance of eye. This paper proposes an automatic EL and ESR system as a solution. Given a frontal face, the face-region and two rough eye windows are successively detected using Viola Jones method. Within rough eye window, accurate position of eye center is found by a new projection function, Selective Projection Function, which selectively picks low-intensity pixels from nearby rows or columns to produce the response. To decide open/closed state, a novel descriptor is first designed based on grayscale correlogram, which expresses spatial correlations of grayscale pairs. Then pattern classification techniques, including subspace-based methods (PCA and LDA), SVM and AdaBoost algorithm are examined to train the binary eye state classifier using the descriptor. Experimental results show the proposed EL and ESR algorithms demonstrate encouraging performance on static images with large variations. Furthermore, the automatic system also displays high speed and accuracy in real time video.