With the increasing use of drones, the increasing number of drones in the sky makes collisions between drones an issue that cannot be ignored. At present, the relative positioning between drones mostly relies on GNSS and wireless communication, which is difficult to reliably meet the needs of a large number of drones in complex environments such as cities. Therefore, a strong anti-interference method is needed to supplement or replace it. Monocular ranging is a low-cost, low-power, compact, and electromagnetic interference resistant ranging and positioning method, which is very suitable for use on unmanned aerial vehicles with limited carrying capacity. We have studied and analyzed relevant literature on monocular ranging and selected a suitable technical path for drone scenarios. Our method is to add a distance regression branch to YOLOv8, enabling it to estimate the distance of the target drones while detecting them, thereby achieving relative positioning of drones. This method does not rely on GNSS and wireless communication methods, and can help drones locate each other in scenarios where GNSS and communication are affected, avoiding collisions. As a comparison, we compared the distance estimation results with the method of first detecting reference points through YOLOv8 and then calculating distance through PnP, and the results showed that the direct regression distance method is more accurate. Finally, we validated the effectiveness of our method on actual flight data.