Real time detection of ship traffic flow in inland waterways is of great significance to maritime transportation management.In order to detect ship traffic flow in a real-time mode, a detection system based on virtual loop is presented in this paper.The virtual loop is a closed area within a video image, which can detect moving targets according to the change of the image in the regions.Firstly, a binary image is obtained by RGB three-channel background difference method, in which three segmentation thresholds are obtained by Otsu method.Secondly, the ships that traverse the virtual loops are detected and recorded by two paralleled virtual loops.Besides, the length and width of the ships can also be detected.Finally, the detected ships are further classified by BP neural network.The videos collected from Wuhan Yangtze River Bridge and Second Wuhan Yangtze River Bridge at different time periods are selected as a case study.The results of the case study show that the success rate of detecting the ships reaches 97.1%, the missing rate is 2.9%, and the false alarm rate is 0%.The accuracy of classification is 98.6%.In addition, the proposed method also reveals that the average time of processing one frame is 7 ms, which indicates a good performance in term of timeliness.