Countermeasures againstlow and small movingUAVs have become an important tool for low altitude airspace security defense, but real-time detection and accurate identification are the prerequisite and key foundation for effective countermeasures. Aiming at the urban low-altitude environment, the target detection algorithm has low accuracy in detecting small-scale UAV targets in different backgrounds, is prone to omission and misdetection, and is susceptible to interference from external factors, etc., alow and small movingUAV target detection method based on the improved YOLOv7 is proposed. Firstly, a large number of UAV samples from different environments and backgrounds are collected to build a data set and are pre-processed by ViBe (visual background extractor) algorithm. Secondly, the coordinate attention mechanism and SPDConv (space-to-depth convolution) module are introduced to improve and optimize the network structure of YOLOv7. Finally, a secondary detection architecture is proposed to fuse ViBe and improved YOLOv7, and the improved YOLOv7 is used as the network model to detect the images processed by ViBe. Based on the position size relationship between the original image and the processed image, the detected target coordinates are mapped back to the original image, so as to complete the target detection and extraction. The experimental results show that the detection accuracy of the proposed target detection method reaches 96.5%, which is 15.8 percentage points higher than that of the original YOLOv7 method, significantly improving the detection accuracy oflow and small movingtargets and meeting the demand for real-time accurate detection of low-altitude UAVs. © 2024 Journal of Computer Engineering and Applications Beijing Co., Ltd.; Science Press. All rights reserved.