Car detection on the road through computer vision is crucial for improving safety, as it plays an essential role in spotting nearby vehicles and preventing fatal accidents. Additionally, car detection significantly contributes to the advancement of autonomous vehicles. Previous explorations of car detection using YOLOv5 have revealed weaknesses regarding its resulting mean average precision (mAP). This scenario led to the development of a more advanced version of you only look once (YOLO), namely YOLOv8. Consequently, this study aimed to adopt YOLOv8 for automatic car detection on the road. YOLOv8 is proven to perform better than the previous version. A dataset comprising video frame images was captured on the highway in Semarang, Indonesia. The experiment results indicated that the proposed approach achieved impressive precision, recall, and mAP values, reaching 94.1%, 98.2%, and 98.8%, respectively. The proposed approach enhanced mAP and training time when compared with YOLOv5. Therefore, it was concluded that the proposed method was better suited for real-time car detection.