In pharmaceutical encapsulation production, the existing positioning method of Penicillin bottle mouth are easily affected by the interference of bottle mouth edge. It leads to inaccurate positioning of the bottle mouth circle center. In this paper, a multi bottle mouth positioning algorithm based on DBSCAN random circle detection is proposed. Firstly, the canny edge detection algorithm is used to get all the contours in the image. The density based on DBSCAN clustering algorithm is used to segment the interested bottle mouth edge sets. Then, for each individual bottle mouth edge image, the least square method and radial scanning are used to obtain the outer edge points of the bottle mouth. Then, a large number of candidate center sets are obtained by repeated random circle detection. Finally, the truth is obtained by clustering based on DBSCAN algorithm. The mean center of the real circle center set is the center of the bottle mouth. Compared with four typical algorithms, the experimental results show that the average positioning error of the proposed circle positioning algorithm is 0. 553 pixels, which is better than other algorithms. And the average execution speed of the algorithm is 1. 359 ms. The algorithm meets the requirements of accuracy and real-time of the pharmaceutical potting production line.