How to allocate the existing medical resources reasonably, alleviate hospital congestion and improve the patient experience are problems faced by all hospitals. At present, the combination of artificial intelligence and the medical field is mainly in the field of disease diagnosis, but lacks successful application in medical management. We distinguish each area of the emergency department by the division of medical links. In the spatial dimension, in this study, the waitlist number in real-time is got by processing videos using image recognition via a convolutional neural network. The congestion rate based on psychology and architecture is defined for measuring crowdedness. In the time dimension, diagnosis time and time-consuming after diagnosis are calculated from visit records. Factors related to congestion are analyzed. A total of 4717 visit records from the emergency department and 1130 videos from five areas are collected in the study. Of these, the waiting list of the pediatric waiting area is the largest, including 10,436 (person-time) people, and its average congestion rate is 2.75, which is the highest in all areas. The utilization rate of pharmacy is low, with an average of only 3.8 people using it at the one time. Its average congestion rate is only 0.16, and there is obvious space waste. It has been found that the length of diagnosis time and the length of time after diagnosis are related to age, the number of diagnoses and disease type. The most common disease type comes from respiratory problems, accounting for 54.3%. This emergency department has congestion and waste of medical resources. People can use artificial intelligence to investigate the congestion in hospitals effectively. Using artificial intelligence methods and traditional statistics methods can lead to better research on healthcare resource allocation issues in hospitals.