A gesture recognition method, named HD-YOLOv5s, is proposed, facing the problem of low recognition rates of gesture detection algorithms in complex environments due to uneven lighting, near-skin color backgrounds and small gesture scales. Firstly, an adaptive Gamma image enhancement pre-processing method based on Retinex theory is used to reduce the effect of illumination changes on gesture recognition. Secondly, a feature extraction network with adaptive convolutional attention mechanism(SKNet)is constructed to improve the feature extraction capability of the network and reduce the problem of background interference in complex environments. Finally, a novel bi-directional feature pyramid network is constructed in the feature fusion network to make full use of low-level features to reduce the loss of shallow semantic information and improve the detection accuracy of small-scale gestures, while cross-level cascading is used to further improve the detection efficiency of the model. The effectiveness of the improved method is verified on a homemade dataset with rich light intensity contrast and a public dataset NUS-II with complex backgrounds, the recognition rates are 99.5% and 98.9% respectively, and the detection time for a single frame is only 0.01 s to 0.02 s. © 2024 Chinese Journal of Animal Science and Veterinary Medicine Co., Ltd.. All rights reserved.