IntroductionThe primary focus of this paper is to assess urban ecological environments by employing object detection on spatial-temporal data images within a city, in conjunction with other relevant information through data mining.MethodsFirstly, an improved YOLOv7 algorithm is applied to conduct object detection, particularly counting vehicles and pedestrians within the urban spatial-temporal data. Subsequently, the k-means superpixel segmentation algorithm is utilized to calculate vegetation coverage within the urban spatial-temporal data, allowing for the quantification of vegetation area. This approach involves the segmentation of vegetation areas based on color characteristics, providing the vegetation area’s measurements. Lastly, an ecological assessment of the current urban environment is conducted based on the gathered data on human and vehicle density, along with vegetation coverage.ResultsThe enhanced YOLOv7 algorithm employed in this study yields a one-percent improvement in mean AP (average precision) compared to the original YOLOv7 algorithm. Furthermore, the AP values for key categories of interest, namely, individuals and vehicles, have also improved in this ecological assessment.DiscussionSpecifically, the AP values for the ‘person’ and ‘pedestrian’ categories have increased by 13.9% and 9.3%, respectively, while ‘car’ and ‘van’ categories have seen AP improvements of 6.7% and 4.9%. The enhanced YOLOv7 algorithm contributes to more accurate data collection regarding individuals and vehicles in subsequent research. In the conclusion of this paper, we further validate the reliability of the urban environmental assessment results by employing the Recall-Precision curve.