Precision weed detection and mapping in vegetable crops are beneficial for improving the effectiveness of weed control. This study proposes a novel method for indirect weed detection and mapping using a detection network based on the You-Only-Look-Once-v8 (YOLOv8) architecture. This approach detects weeds by first identifying vegetables and then segmenting weeds from the background using image processing techniques. Subsequently, weed mapping was established and innovative path planning algorithms were implemented to optimize actuator trajectories along the shortest possible path. Experimental results demonstrated significant improvements in both precision and computational efficiency compared with the original YOLOv8 network. The mean average precision at 0.5 (mAP50) increased by 0.2, while the number of parameters, giga floating-point operations per second (GFLOPS), and model size decreased by 0.57 million, 1.8 GFLOPS, and 1.1 MB, respectively, highlighting enhanced accuracy and reduced computational costs. Among the analyzed path planning algorithms, including Christofides, Dijkstra, and dynamic programming (DP), the Dijkstra algorithm was the most efficient, producing the shortest path for guiding the weeding system. This method enhances the robustness and adaptability of weed detection by eliminating the need to detect diverse weed species. By integrating precision weed mapping and efficient path planning, mechanical actuators can target weed-infested areas with optimal precision. This approach offers a scalable solution that can be adapted to other precision weeding applications.