The lying time of cows is a key indicator of their health and comfort. The ability to automatically recognize the lying posture of cows while simultaneously realizing individual cow identification can play an important role in improving cow welfare, increasing milk yield, detecting cow diseases in a timely manner and enabling precision dairy farming management. In this paper, a method of individual identification for lying dairy cows in a barn based on YOLOX and a feature extraction network named CowbodyNet is proposed. When new cows join the herd, there is no need to collect a large number of images to retrain the model. It is very convenient to collect several images of newly added cows lying and store them in the database. First, the low-light images collected at night are enhanced by the multiscale retinex with chromaticity preservation (MSRCP) algorithm to improve the image quality. Then, the YOLOX target detection algorithm is applied to detect and segment cows in the lying posture. Following this, the segmented images of lying cows are input into CowbodyNet to generate feature vectors, which are used to construct a feature vector database. Subsequently, the Euclidean distances between the feature vector of a cow to be identified and the feature vectors in the database are calculated to determine the identification result. The proposed method achieves 94.43% lying cow identification accuracy on a data set containing top-view images of 72 cows. Finally, the individual cow detection and identification model is successfully deployed on the Jetson Xavier NX embedded platform. The results demonstrate the effectiveness and practicability of the proposed cow identification method. This study provides effective technical support for the application of identifying individual lying cows.