With the widespread application of LiDAR and camera, the integration of LiDAR and camera has become an urgent issue. In this study, we proposed a optimal layout method for roadside LiDAR and camera. Firstly, the experimental design phase took into consideration various application scenarios, such as curved road sections and gradient road sections. Secondly, the video data and point cloud data collected from different experimental setups were subjected to object detection and recognition using YOLOv5s weights and PointPillars weights, respectively. These weights are applied to the video data under different layout schemes to output the mAP value of each scheme. By comparing the mAP values under different layout schemes, the optimal layout scheme for the road scene is determined. Thirdly, the four road scene parameters and six installation parameters from all scenarios were collected into a database. Furthermore, five machine learning algorithms were employed for optimal selection. Finally, the three regression algorithms with the highest accuracy are selected for the final prediction model based on different control groups. Through the field experiment, the results show that the optimized layout method can significantly reduce blind spot detection and vehicle occlusion problems for camera and LiDAR. The optimal deployment method can increase the Mean Average Precision (MAP) by over 4% through adjusting the installation parameters. The regression algorithm used can predict the optimal deployment scheme for roadside LiDAR and cameras in unknown scenarios with over 95% accuracy. This optimal deployment method improves the detection accuracy of roadside devices for road vehicles by changing the installation parameters and provides guidance for the future installation of roadside LiDAR and camera.