Foxtail millet ear detection and counting are essential for the estimation of foxtail millet production and breeding. However, traditional foxtail millet ear counting approaches based on manual statistics are usually time-consuming and labor-intensive. In order to count the foxtail millet ears accurately and efficiently, an adaptive anchor box adjustment foxtail millet ear detection method was proposed in this research. Ear detection dataset was firstly established, including 784 images and 10,000 ear samples. Furthermore, a novel foxtail millet ear detection approach based on YOLOv4 (You Only Look Once) was developed to quickly and accurately detect the ear of foxtail millet in the specific box. For verifying the effectiveness of the proposed approach, several criteria, including the mean average Precision, F1-score,Recall and mAP were employed. Moreover, ablation studies were designed to validate the effectiveness of the proposed method, including (1) evaluating the performance of the proposed model through comparing with other models (YOLOv2, YOLOv3 and Faster-RCNN); (2) evaluating the model with different Intersection over Union (IOU) thresholds to achieve the optimal IOU thresholds; (3) evaluating the foxtail millet ear detection with or without anchor boxes adjustment to verify the effectiveness of the adjustment of anchor boxes;(4) evaluating the changing reasons of model criteria and (5) evaluating the foxtail millet ear detection with different input original image size respectively. Experimental results showed that YOLOv4 could obtain the superior ear detection performance. Specifically, mAP and F1-score of YOLOv4 achieved 78.99% and 83.00%, respectively. The Precision was 87% and the Recall was 79.00%, which was about 8% better than YOLOv2, YOLOv3 and Faster RCNN models, in terms of all criteria. Moreover, experimental results indicates that the proposed method is superior with promising accuracy and faster speed.