Road surface vehicle length measurement method and device, electronic equipment and storage medium
By identifying vehicle and tire regions in road scene images and using tire feature point distribution data to determine vehicle orientation lines, the problem of vehicle length measurement deviation in visual inspection is solved, achieving high accuracy and low cost in vehicle length measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GRG INTELLIGENT TECH SOLUTION CO LTD
- Filing Date
- 2026-03-27
- Publication Date
- 2026-06-23
AI Technical Summary
In existing technologies, vehicle length calculation methods based on vision detection suffer from length calculation errors under multiple shooting perspectives, resulting in insufficient accuracy and high cost.
By acquiring road scene images, the vehicle area and tire area are determined. The vehicle orientation line is determined using tire feature point distribution data. The vehicle length is calculated based on the transformation relationship between the pixel coordinate system and the world coordinate system, avoiding complex hardware modifications.
It improves the accuracy and robustness of vehicle length measurement, reduces hardware costs, adapts to complex road scenarios, and eliminates directional judgment errors caused by shooting angle.
Smart Images

Figure CN122265983A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image processing technology, and in particular relates to a method, device, electronic device and storage medium for calculating the length of vehicles on the road. Background Technology
[0002] In the field of road traffic, vehicle length is a key vehicle characteristic parameter. Accurate data on the actual vehicle length is crucial for scenarios such as vehicle type classification, overload detection, and road traffic control. Currently, vehicle length is typically calculated using technologies such as LiDAR or sensors, which are costly. While visual detection-based solutions exist, they generally suffer from drawbacks, failing to eliminate length measurement errors caused by multiple shooting angles such as overhead and side views, resulting in insufficient accuracy in length detection results. Summary of the Invention
[0003] This application aims to address at least one of the technical problems existing in the related art. To this end, this application proposes a method, device, electronic device, and storage medium for calculating the length of vehicles on the road surface, thereby improving the accuracy of vehicle length calculation in visual inspection scenarios.
[0004] Firstly, this application provides a method for calculating the length of vehicles on a road surface, the method comprising: Acquire road surface scene images of the target road surface; Determine the vehicle region corresponding to at least one target vehicle in the road scene image, and determine the tire region corresponding to the tires of each target vehicle in each vehicle region; For each of the target vehicles, based on the feature point distribution data of each tire region corresponding to the tires of the target vehicle in the pixel coordinate system, a vehicle orientation line representing the body length direction of the target vehicle is determined, and the pixel coordinate system is set based on the road scene image. Based on the vehicle orientation line, two length calculation endpoints corresponding to the body length of the target vehicle are determined in the vehicle region corresponding to the target vehicle. Based on the transformation relationship between the pixel coordinate system and the world coordinate system, the body length of the target vehicle is determined according to the two length measurement endpoints.
[0005] In the above technical solution, road scene images are collected as the basis for measurement data, eliminating the need for complex hardware modifications such as LiDAR and dedicated sensors, significantly reducing the hardware cost and deployment difficulty of vehicle length measurement. By performing layer-by-layer filtering of vehicle and tire regions in the road scene images and conducting vehicle length measurement based on the tire characteristics of the target vehicle, various interference factors can be eliminated, improving the robustness and scene adaptability of the measurement method in complex road scenes. Based on the feature point distribution data of each tire region of the target vehicle in the pixel coordinate system corresponding to the road scene image, the vehicle orientation line representing the vehicle body length direction is determined. The vehicle orientation line is used to determine the two length measurement endpoints corresponding to the vehicle body length, and the vehicle body length is determined based on the transformation relationship and the two measurement endpoints. Even if the vehicle appears visually skewed in the image due to side or top-down shooting, the inherent law of linear arrangement of vehicle tires along the body length is not affected. The orientation line determined based on this law can accurately restore the true length direction of the vehicle body, effectively solving the problem of direction judgment deviation caused by shooting angle and improving the accuracy of vehicle length measurement in visual inspection scenarios.
[0006] In some embodiments, the step of performing vehicle detection on the road scene image to obtain vehicle regions corresponding to each target vehicle in the road scene image, and performing tire detection on each vehicle region to obtain tire regions corresponding to each tire in each vehicle region, includes: The target vehicles in the road scene image are identified and located by a pre-trained vehicle detection model, and the vehicle regions corresponding to each target vehicle are obtained. For each of the vehicle regions, each tire in the vehicle region is identified and located using a pre-trained tire detection model, thus obtaining the tire region corresponding to each tire.
[0007] In some embodiments, the vehicle region and the tire region have edges; determining the vehicle orientation line representing the body length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system includes: For each of the tire regions, the center point of the edge corresponding to the tire region and the road surface is taken as a feature point, and the pixel coordinates of the feature point in the pixel coordinate system are determined. Based on the pixel coordinates of each feature point, determine the relative distance from each feature point to the edge of the vehicle area corresponding to the road surface; Based on the relative distances between the feature points, select the valid feature points that meet the tire layout constraints of the vehicle. The two effective feature points with the largest and smallest relative distances among the effective feature points are taken as two end feature points, and the line connecting the two end feature points is taken as the vehicle orientation line.
[0008] In some embodiments, the step of filtering valid feature points that meet the tire layout constraints of the vehicle based on the pixel coordinates of each feature point includes: The feature points are sorted according to their relative distances. For each of the sorted feature points, determine the angle between the line connecting the feature point and the previous feature point and the coordinate axis of the pixel coordinate system, and use the angle as the angle to be verified for the feature point. If the difference between the angle to be tested and the reference angle satisfies the first angle constraint, the feature point is determined to be a valid feature point. The reference angle is the angle between the line connecting the first two sorted feature points and the coordinate axis of the pixel coordinate system.
[0009] The method further includes: If the reference angle does not meet the second angle constraint, the vehicle area is determined to be an invalid vehicle area. Stop calculating the vehicle body length of the vehicles corresponding to the invalid vehicle area.
[0010] In some embodiments, determining two length measurement endpoints corresponding to the vehicle's body length in the vehicle region based on the vehicle orientation line includes: Extend the vehicle orientation line in both directions until both ends of the vehicle orientation line intersect with the edge of the vehicle area to obtain the first intersection point and the second intersection point. The first intersection point and the second intersection point are used as the two endpoints for the length measurement.
[0011] In some embodiments, the transformation relationship between the pixel coordinate system and the world coordinate system includes the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, and the length scaling factor between the bird's-eye view coordinate system and the world coordinate system; determining the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints, includes: Based on the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, the pixel coordinates of the two length measurement endpoints in the pixel coordinate system are mapped to the bird's-eye view coordinate system to obtain the bird's-eye view pixel coordinates of the two length measurement endpoints. The bird's-eye view pixel spacing between the two length measurement endpoints is determined based on their bird's-eye view pixel coordinates. Based on the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system, the bird's-eye pixel spacing is converted into physical distance in the world coordinate system, and the physical distance is taken as the body length of the target vehicle.
[0012] In some embodiments, before determining the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system according to the two length measurement endpoints, the method further includes: In the road surface scene image, a calibration area is selected based on the lane lines; Obtain the bird's-eye view pixel length of the calibration region in the bird's-eye view coordinate system, and the physical length of the calibration region in the world coordinate system; Obtain the pixel coordinates of the corner points of the calibration area in the pixel coordinate system, and the bird's-eye view pixel coordinates of the corner points in the bird's-eye view coordinate system; Based on the pixel coordinates of the corner points and the bird's-eye view pixel coordinates, determine the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system; Based on the bird's-eye view pixel length and physical length of the calibration area, determine the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system.
[0013] Secondly, this application provides a road vehicle length measuring device, the device comprising: The image acquisition module is used to acquire images of the target road surface. The detection module is used to determine the vehicle region corresponding to at least one target vehicle in the road scene image, and to determine the tire region corresponding to the tire of each target vehicle in each vehicle region; The orientation line determination module is used to determine, for each of the target vehicles, a vehicle orientation line representing the body length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system, wherein the pixel coordinate system is set based on the road scene image. The endpoint determination module is used to determine, based on the vehicle orientation line, two length calculation endpoints corresponding to the body length of the target vehicle in the vehicle region corresponding to the target vehicle. The length determination module is used to determine the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints.
[0014] Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the road vehicle length calculation method as described in the first aspect above.
[0015] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the road vehicle length calculation method as described in the first aspect above.
[0016] Fifthly, this application provides a chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the road vehicle length calculation method as described in the first aspect.
[0017] In a sixth aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the road vehicle length calculation method as described in the first aspect above.
[0018] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0019] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart illustrating a method for calculating the length of vehicles on the road surface provided in some embodiments of this application; Figure 2 This is a schematic diagram of determining the vehicle orientation line provided in some embodiments of this application; Figure 3 This is a schematic diagram of the structure of a road vehicle length measuring device provided in some embodiments of this application; Figure 4 These are schematic diagrams of the structure of electronic devices provided in some embodiments of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0021] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0022] The method, apparatus, electronic device, and storage medium for calculating the length of road vehicles provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0023] The method for calculating the length of vehicles on the road can be applied to the terminal, specifically executed by the hardware or software within the terminal.
[0024] The road vehicle length measurement method provided in this application embodiment can be executed by an electronic device or a functional module or entity in an electronic device that can implement the road vehicle length measurement method. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras and wearable devices. The road vehicle length measurement method provided in this application embodiment is described below using an electronic device as the execution subject.
[0025] Figure 1 This is a flowchart illustrating a method for calculating the length of vehicles on the road surface provided in some embodiments of this application. For example... Figure 1 As shown, the method for calculating the length of vehicles on the road includes steps 110, 120, 130, 140, and 150.
[0026] Step 110: Acquire road surface scene images of the target road surface.
[0027] Road scene images can include road surface, lane lines, and passing vehicles. For example, road scene images can be collected by monocular color cameras, traffic capture cameras, roadside monitoring terminals, etc., installed on road gantries or poles, and serve as the data basis for subsequent vehicle detection, tire detection, and vehicle length calculation.
[0028] In some embodiments, the road surface scene image of the target road surface is acquired by a fixed monocular camera positioned above the fixed road surface. Before acquiring the image, the fixed monocular camera can be calibrated to determine the transformation relationship between the pixel coordinate system and the world coordinate system corresponding to the image acquired by the fixed monocular camera.
[0029] It is understandable that the vehicle length calculation in this embodiment is based on vehicle tire features. In practical applications, the tires on the side of the vehicle can only be clearly captured when the camera is shooting from the side. If the vehicle angle is too upright, the camera can only capture the front / rear of the vehicle and cannot extract effective tire features. Consequently, there is no valid data to support the subsequent orientation determination and length calculation process. Therefore, when collecting road scene images, it is necessary to adapt to the fixed deployment posture of the roadside monocular camera for side and top shots, and prioritize the collection of road scene images that can show the side outline of the vehicle and clearly expose the tires, so as to avoid invalid images with too upright angles or without effective tire features from entering the calculation process.
[0030] Step 120: Determine the vehicle region corresponding to at least one target vehicle in the road scene image, and determine the tire region corresponding to the tires of each target vehicle in each vehicle region.
[0031] A vehicle region refers to an image region containing only the target vehicle, selected or segmented from a road scene image; a tire region refers to a local image region corresponding to the vehicle's tires, obtained by further detection and localization within the detected vehicle region. It is understood that a road scene image typically includes one or more vehicle regions, and a single vehicle region may also include one or more tire regions.
[0032] Determining the vehicle region corresponding to the target vehicle, or the tire regions corresponding to each tire of the vehicle within the vehicle region, can be achieved through deep learning-based object detection, such as using object detection models like YOLO (You Only Look Once) or Faster R-CNN, trained on vehicle and tire sample datasets to directly detect and locate vehicle and tire regions from the image. Alternatively, semantic segmentation models can be used to perform pixel-level classification of the road scene image, segmenting different regions such as vehicles, tires, and road surface. For example, in some embodiments, the YOLOv11 object detection model is used to infer the road scene image, detect all vehicles in the image, and obtain the detection box for each vehicle; then, the image region of the vehicle is cropped from the original image based on the vehicle's detection box; finally, the YOLOv6 object detection model is used to perform tire detection on the cropped vehicle image, identifying and locating all visible tires of the vehicle, and obtaining the detection box for each tire.
[0033] Step 130: For each target vehicle, based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system, determine the vehicle orientation line representing the body length direction of the target vehicle, wherein the pixel coordinate system is set based on the road scene image.
[0034] A pixel coordinate system is a two-dimensional coordinate system established based on a road scene image. Typically, the upper left corner of the image is the origin, the horizontal axis is the X-axis, and the vertical axis is the Y-axis. All points in the image are located using pixel coordinates. This application does not specify how the pixel coordinate system should be set.
[0035] Feature point distribution data is a set of pixel coordinates of representative points (such as the center point of the edge of the tire area near the road surface, the geometric center point of the tire area) extracted from each tire area, reflecting the actual arrangement of the tires in the image.
[0036] The vehicle orientation line is a straight line determined based on the arrangement of tire feature points. It extends along the length of the vehicle body and is used to characterize the overall orientation of the vehicle. The orientation line, determined using vehicle coordinates and tire coordinates, allows for the location of the vehicle's front and rear coordinates, providing a precise reference for subsequent length calculations and endpoint positioning.
[0037] Compared to directly using the vehicle's diagonal or visually longer side as a length reference, this embodiment determines the orientation line based on tire distribution characteristics. This helps solve the problem of image distortion caused by camera shooting angle and inaccurate determination of the vehicle's length direction. Specifically, the vehicle's tires are naturally arranged linearly along the vehicle's length direction. This is an inherent structural feature of the vehicle and is not affected by the camera's shooting angle. Even if the vehicle appears skewed in the image due to side or top-down shooting, the linear arrangement of the tires still exists. The orientation line determined based on this rule can restore the true length direction of the vehicle, rather than the visually skewed direction in the image.
[0038] For example, the extreme points at both ends of the feature points can be selected based on the feature point distribution data, and the straight line connecting the two points is the vehicle orientation line; or the optimal vehicle orientation line can be obtained by fitting a straight line using the least squares method based on the distribution trend of effective feature points.
[0039] Step 140: Based on the vehicle orientation line, determine the two length calculation endpoints corresponding to the body length of the target vehicle in the vehicle region corresponding to the target vehicle.
[0040] For example, the vehicle orientation line can be extended bidirectionally along the length of the vehicle body, and the two intersections of the extended line with the edge of the vehicle area are the length measurement endpoints; or the vehicle orientation line can be projected onto the boundary of the vehicle area, and the two farthest boundary points within the projection range can be selected as the measurement endpoints, etc.
[0041] By selecting two points on the vehicle's edge under the constraint of the vehicle's orientation line, the two length measurement endpoints can be made to fall exactly at the two ends of the actual vehicle length, and the pixel distance between the two points can truly reflect the vehicle length. This effectively avoids selecting points in the vehicle width direction or skew direction, which would cause the measured distance to be much greater or less than the actual vehicle length.
[0042] Step 150: Based on the transformation relationship between the pixel coordinate system and the world coordinate system, determine the body length of the target vehicle according to the two length measurement endpoints.
[0043] The world coordinate system is a coordinate system established to correspond to the physical space of the real road surface, used to reflect the actual size and position of the vehicle in the real world.
[0044] Determining the physical distance between two length measurement endpoints in the world coordinate system can be achieved by, for example, substituting the pixel coordinates of the two measurement endpoints into the perspective transformation matrix between the pixel coordinate system and the world coordinate system, mapping them to the world coordinate system to obtain the physical coordinates, and then calculating the Euclidean distance between the two points to obtain the actual vehicle body length; alternatively, it can be based on the calibrated pixel-physical coordinate mapping relationship, directly converting the pixel distance of the measurement endpoints into the physical distance; this application does not specifically limit this.
[0045] The road vehicle length measurement method provided in this application collects road scene images as measurement data, eliminating the need for complex hardware modifications such as LiDAR and dedicated sensors, significantly reducing the hardware cost and deployment difficulty of vehicle length measurement. By performing layer-by-layer filtering of vehicle and tire regions in the road scene image and conducting the vehicle length measurement process based on the tire characteristics of the target vehicle, various interference factors can be eliminated, improving the robustness and scene adaptability of the measurement method in complex road scenes. Based on the feature point distribution data of each tire region of the target vehicle in the pixel coordinate system corresponding to the road scene image, a vehicle orientation line representing the vehicle body length direction is determined. The vehicle orientation line is used to determine the two length measurement endpoints corresponding to the vehicle body length, and the vehicle body length is determined based on the transformation relationship and the two measurement endpoints. Even if the vehicle appears visually skewed in the image due to side or top-down shooting, the inherent law of linear arrangement of vehicle tires along the body length is not affected. The orientation line determined based on this law can accurately restore the true length direction of the vehicle body, effectively solving the problem of direction judgment deviation caused by shooting angle and improving the accuracy of vehicle length measurement in visual inspection scenarios.
[0046] In some embodiments of this application, the step of performing vehicle detection on the road scene image to obtain vehicle regions corresponding to each target vehicle in the road scene image, and performing tire detection on each vehicle region to obtain tire regions corresponding to each tire in each vehicle region, includes: The target vehicles in the road scene image are identified and located by a pre-trained vehicle detection model, and the vehicle regions corresponding to each target vehicle are obtained. For each of the vehicle regions, each tire in the vehicle region is identified and located using a pre-trained tire detection model, thus obtaining the tire region corresponding to each tire.
[0047] In some embodiments, the vehicle detection model includes a visual detection model trained on a machine learning or deep learning architecture, typically using road vehicle images as training samples, and has the ability to automatically identify vehicle targets from road scene images and output vehicle position coordinates and bounding boxes.
[0048] For example, a YOLO (You Only Look Once) model, such as the YOLOv11 object detection model or a lightweight YOLOv5s model, can be selected as the vehicle detection model. Pre-training can be performed using a vehicle image dataset containing different vehicle models, lighting conditions, and road surface scenarios. The collected road scene images are then input into the pre-trained model. The model performs feature extraction, object classification, and bounding box regression, outputting the bounding box coordinates of all target vehicles within the image. Each set of bounding boxes corresponds to an independent vehicle region. In some embodiments, a Faster R-CNN two-stage object detection model can also be used to identify and locate target vehicles in the road scene image. Pre-training can be performed using a large-scale, complex vehicle dataset to optimize the model's ability to recognize distant vehicles and partially occluded vehicles.
[0049] In some embodiments, the tire detection model is used to perform detailed tire detection on a vehicle. By using images of local areas of the vehicle as training samples, it can filter out interference information such as the vehicle body and background road surface, identify each tire target corresponding to a single vehicle, and output the bounding box and position information of the corresponding tire.
[0050] For example, the YOLOv6 object detection model can be selected as the tire detection model. Using cropped images of the vehicle region as training samples, the contours and center points of tires for various vehicle models are labeled to complete pre-training. In some embodiments, the tire detection model can first perform initial tire target identification, and then, combined with grayscale thresholding and edge detection algorithms, interference items such as vehicle bumpers, headlights, and body trim strips are filtered out to accurately locate all tires within the vehicle region, with each tire corresponding to an independent tire region.
[0051] The method for calculating the length of vehicles on the road surface provided in this application adopts a layered detection approach. First, a vehicle detection model is used to establish a one-to-one association between the target vehicle and the vehicle region in the road scene image. Then, for each vehicle region, a tire detection model is used to establish a one-to-one association between the tire and the tire region. The image processing range is narrowed down by first identifying and locating the vehicle region, and then the tire detection model is used to achieve refined identification and location of the tire region. This ensures that all tires in the vehicle region can be matched with the accurate tire region, providing reliable data support for subsequent fitting of the vehicle orientation line based on tire feature points, and avoiding errors in vehicle orientation judgment due to missed tire detection or positioning deviation.
[0052] In some embodiments of this application, the vehicle region and the tire region have edges; determining the vehicle orientation line representing the body length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system includes: For each of the tire regions, the center point of the edge corresponding to the tire region and the road surface is taken as a feature point, and the pixel coordinates of the feature point in the pixel coordinate system are determined. Based on the pixel coordinates of each feature point, determine the relative distance from each feature point to the edge of the vehicle area corresponding to the road surface; Based on the relative distances between the feature points, select the valid feature points that meet the tire layout constraints of the vehicle. The two effective feature points with the largest and smallest relative distances among the effective feature points are taken as two end feature points, and the line connecting the two end feature points is taken as the vehicle orientation line.
[0053] It is understandable that the edges of the vehicle area and the tire area refer to the outline boundary lines of the vehicle area and the tire area, which are the defining references for the area range. The edge corresponding to the road surface is in contact with the actual ground position of the vehicle, which can reflect the contact state between the tire, the body and the road surface.
[0054] Figure 2 This is a schematic diagram illustrating the determination of vehicle orientation lines according to some embodiments of this application. For example... Figure 2 As shown, the center point of the tire area's edge corresponding to the road surface refers to the midpoint of the edge segment of the tire area closer to the road surface. The line connecting the two end feature points is the vehicle's orientation line. Using the midpoint of the edge segment of the tire area closer to the road surface as the feature point can match the actual physical position of the vehicle's tire contact with the ground, and compared to points such as the tire center or the upper edge center point, it can better reflect the vehicle's actual body layout and orientation.
[0055] Determining the relative distance from each effective feature point to the edge of the vehicle area corresponding to the road surface can be achieved by vertically projecting each effective feature point onto the edge of the road surface in the vehicle area and calculating the pixel length between the projected point and the feature point; or by using the edge of the road surface in the vehicle area as a baseline, extracting the vertical pixel coordinate difference of each effective feature point, and using the absolute value of the difference as the relative distance, etc.
[0056] Understandably, by quantifying the relative distance between effective feature points and the edge of the vehicle road surface, the abstract feature point arrangement position is transformed into a specific value, realizing the digital differentiation of feature point positions and clearly defining the front and rear arrangement positions of each tire feature in the length direction of the vehicle body; the quantitative relative distance value can accurately locate the extreme points at both ends of the vehicle body length, providing accurate numerical basis for the subsequent selection of end feature points.
[0057] Tire layout constraints refer to the inherent tire layout rules of a vehicle. For example, tires on the same side of the vehicle may be arranged in a linear and regular manner along the length of the vehicle body, the spacing between adjacent tires may be relatively stable, or the direction of the connecting lines may be consistent.
[0058] Based on the relative distances between each feature point, valid feature points that conform to the vehicle's tire layout constraints are selected. For example, this can be based on the linear tire layout constraints: first, two initial adjacent feature points are selected, and the reference angle connecting them is calculated. Then, the angles of the connecting lines between each of the remaining feature points and the previous feature point are checked one by one. Abnormal feature points whose angle differences exceed a preset threshold are eliminated, while valid feature points with matching angles and regular arrangement are retained. Alternatively, selection can be based on spacing constraints: the pixel spacing between adjacent feature points is calculated, and abnormal feature points with excessively large or small spacing, or those that do not conform to the normal tire spacing of a vehicle, are eliminated. In some embodiments, clustering algorithms can also be used to cluster the tire feature points, eliminating discrete, isolated feature points (spare tire, adjacent vehicle tires, background interference points), and retaining regular feature points within the clusters as valid feature points.
[0059] By using tire layout constraints to filter effective feature points, invalid feature points caused by the vehicle's spare tire, adjacent vehicle tires, road debris interference points, detection errors, etc., are specifically eliminated to avoid invalid features interfering with the determination of vehicle orientation. Only the real tire features of the target vehicle are retained so that the feature points involved in subsequent distance calculations and end-point positioning are all valid data. This not only improves the computational efficiency of subsequent processes but also helps to improve the accuracy and robustness of vehicle orientation line determination.
[0060] End feature points refer to the two points corresponding to the extreme values of relative distance among the effective feature points. It can be considered that the two end feature points correspond to the front and rear tire feature points in the length direction of the vehicle body, respectively.
[0061] The road vehicle length calculation method provided in this application selects the center point of the road edge in the tire area as a feature point, which can better match the actual physical position of the vehicle tires and eliminate feature point positioning deviations caused by perspective interference as much as possible. Based on the relative distances corresponding to each feature point, effective feature points that meet the tire layout constraints of the vehicle are selected, thus eliminating various invalid interference features and improving the scene adaptability and robustness of vehicle length calculation for complex road and traffic scenarios. By quantifying the relative distances from each effective feature point to the edge of the vehicle area and the corresponding edge of the road, and determining the extreme points among the effective feature points as end feature points, the end feature points can correspond to the frontmost and rearmost tire positions in the length direction of the vehicle body, respectively. This allows the vehicle orientation line generated by connecting the two points to match the true length direction of the vehicle body as closely as possible, reducing the impact of image visual distortion and shooting perspective distortion, which helps to improve the accuracy of determining the vehicle direction in subsequent length calculations, thereby improving the accuracy of vehicle length calculation.
[0062] In some embodiments of this application, the step of filtering valid feature points that meet the tire layout constraints of the vehicle based on the relative distances corresponding to each feature point includes: The feature points are sorted according to the relative distances they correspond to. For each of the sorted feature points, determine the angle between the line connecting the feature point and the previous feature point and the coordinate axis of the pixel coordinate system, and use the angle as the angle to be verified for the feature point. If the difference between the angle to be tested and the reference angle satisfies the first angle constraint, the feature point is determined to be a valid feature point. The reference angle is the angle between the line connecting the first two sorted feature points and the coordinate axis of the pixel coordinate system.
[0063] In this embodiment, the feature points are arranged in ascending or descending order according to the relative distance values corresponding to each tire feature point, thereby sorting out the arrangement order of feature points along the length of the vehicle body and providing an orderly data foundation for subsequent determination of the reference angle and verification of the angle to be verified.
[0064] The coordinate axes of the pixel coordinate system, i.e., the X-axis or Y-axis of the two-dimensional pixel coordinate system corresponding to the road scene image, serve as the reference for angle calculation, so as to unify the standard for calculating various angles (the angle to be verified and the reference angle). The angle to be verified refers to the angle between a single feature point after sorting and the line connecting it to its preceding adjacent feature point, and the coordinate axis of the pixel coordinate system. This angle is used as the angle data to be verified. By comparing it with the reference angle, it is determined whether the feature point conforms to the tire layout pattern. For example, the pixel coordinates of the first two feature points after sorting can be extracted, substituted into the vector angle formula, and the angle between the line connecting the two points and the coordinate axis of the pixel coordinate system can be calculated to obtain the reference angle; alternatively, the angle between the line connecting the two feature points and the Y-axis can be calculated based on the difference in the pixel coordinates of the two feature points.
[0065] The reference angle refers to the angle between the line connecting the first two sorted feature points and the coordinate axis of the pixel coordinate system, which is used as the reference angle for verifying the angles of all subsequent feature points; that is, the reference angle serves as the initial orientation of the tires on the same side of the vehicle.
[0066] If the difference between the angle to be tested and the reference angle meets the first angle constraint, the feature point is determined to be valid; otherwise, it is determined to be abnormal and invalid, so as to select the valid feature points of the linear layout of the vehicle tires from each feature point.
[0067] For example, the first angle constraint can be a pre-set angle difference threshold range, such as 15 degrees. If the curvature change between adjacent tire feature points is too drastic (the difference between the angle to be tested and the reference angle does not meet the first angle constraint), then the feature point can be considered not a valid feature point of this vehicle. By quantifying the angle difference, the effective feature points are accurately screened, ensuring that the final selected effective feature points conform to the layout constraint of linear arrangement of tires on the same side of the vehicle along the length of the vehicle body and the connecting angle tending to be consistent. Invalid features that do not conform to the tire layout rules are filtered out. The features used in the subsequent end feature point positioning and vehicle orientation line determination are all real tire features of the target vehicle, minimizing the orientation determination error caused by angle deviation.
[0068] The method for calculating the length of a vehicle on the road provided in this application sorts the feature points according to their relative distances, determines the reference angle based on the top two feature points, and determines the initial orientation of the vehicle tires. It then calculates the angle to be verified for each feature point, enabling independent angle verification for each subsequent feature point and providing accurate quantitative data for determining subsequent valid feature points. If the difference between the angle to be verified and the reference angle satisfies the first angle constraint, the feature point is determined as a valid feature point. This method achieves the determination of truly valid feature points that conform to the vehicle tire layout pattern based on angle difference constraints. Compared to contour filtering or spacing filtering, angle constraint filtering better matches the natural structural features of the vehicle tires. Even in road scenes with dense traffic and complex backgrounds, it can accurately filter out the valid features of the vehicle, avoiding invalid features interfering with the determination of subsequent orientation lines. This helps improve the accuracy of determining the vehicle direction in subsequent length calculations, thereby improving the accuracy of vehicle length calculation.
[0069] In some embodiments of this application, the method further includes: If the reference angle does not meet the second angle constraint, the vehicle area is determined to be an invalid vehicle area. Stop calculating the vehicle body length of the vehicles corresponding to the invalid vehicle area.
[0070] The second angle constraint is used to determine whether the vehicle area meets the measurement conditions. Specifically, in this embodiment, length measurement is based on vehicle tire features. Only when the camera is shooting from the side can it capture a clear view of the vehicle's side tires. If the vehicle angle is too straight, the camera can only capture the front / rear of the vehicle, making it impossible to extract valid tire features. Subsequent orientation determination and length measurement processes lack valid data support. The second angle constraint identifies such invalid areas in advance to avoid performing invalid processes later.
[0071] The second angle constraint is usually determined based on the installation angle of the camera that acquires road scene images, thereby retaining the vehicle area that can clearly capture the side tires of the vehicle and can carry out tire feature detection normally, and eliminating abnormal vehicle areas that are too upright and cannot acquire effective tire images.
[0072] The reference angle is the angle between the line connecting the first two tire feature points after sorting and the coordinate axis of the pixel coordinate system. It directly reflects the orientation of the vehicle relative to the camera's shooting angle. If the reference angle exceeds the range of the second angle constraint, the vehicle will appear to be in an overcorrected state in the road scene image. The camera will not be able to capture a clear image of the vehicle's side tires, and thus will not be able to extract effective tire features, determine the vehicle's orientation line, or have the basic conditions for length calculation.
[0073] The road vehicle length calculation method provided in this application uses a second angle constraint to filter vehicle regions, eliminating invalid vehicle regions with excessively positive vehicle angles or where effective side tire images cannot be obtained, and directly terminating the subsequent calculation process for such regions. This ensures that all vehicle regions entering the subsequent calculation process can provide effective tire features, reducing computational waste during the calculation process and guaranteeing the effectiveness of subsequent vehicle orientation line determination and vehicle length calculation.
[0074] In some embodiments of this application, determining two length measurement endpoints corresponding to the vehicle body length in the vehicle region based on the vehicle orientation line includes: Extend the vehicle orientation line in both directions until both ends of the vehicle orientation line intersect with the edge of the vehicle area to obtain the first intersection point and the second intersection point. The first intersection point and the second intersection point are used as the two endpoints for the length measurement.
[0075] In this embodiment, the vehicle orientation line is used as a reference, and the vehicle orientation line is extended in opposite directions (front and rear) along the actual extension direction of the vehicle body length until the extreme boundary points at both ends of the vehicle body length are determined. The edge of the vehicle area serves as the contour closure boundary of the vehicle area, including the entire contour range of the vehicle, providing a contour basis for calculating the endpoint positioning.
[0076] The extended vehicle orientation line intersects the vehicle area edge at the first intersection point and the second intersection point, respectively. Since the vehicle orientation line can restore the true length direction of the vehicle body, the first intersection point and the second intersection point can be considered to correspond to the front end of the vehicle body and the rear end of the vehicle body length, respectively.
[0077] In this embodiment, the boundary of the vehicle body length is determined by extending a straight line to intersect with the edge of the vehicle area. Since the true vehicle orientation line without angular distortion has been determined by tire features, the method of taking points based on the extension of the vehicle orientation line in this embodiment can reduce the image distortion caused by side or top-down shooting. Compared with randomly selecting endpoints, this method can fit the actual structure of the vehicle and the orientation line reference, so that the intersection points correspond to the front and rear ends of the vehicle body.
[0078] In some embodiments of this application, the transformation relationship between the pixel coordinate system and the world coordinate system includes the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, as well as the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system; The step of determining the vehicle body length in the world coordinate system based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints, includes: Based on the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, the pixel coordinates of the two length measurement endpoints in the pixel coordinate system are mapped to the bird's-eye view coordinate system to obtain the bird's-eye view pixel coordinates of the two length measurement endpoints. The bird's-eye view pixel spacing between the two length measurement endpoints is determined based on their bird's-eye view pixel coordinates. Based on the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system, the bird's-eye pixel spacing is converted into physical distance in the world coordinate system, and the physical distance is taken as the body length of the target vehicle.
[0079] The Bird's Eye View (BEV) coordinate system can be considered as a two-dimensional pixel coordinate system after the road scene image is corrected. It eliminates the perspective distortion and near-to-far shrinkage effect of the original road scene image through perspective transformation and other methods, and simulates the perspective of looking down vertically from directly above the road. The coordinate unit is still pixels, which is used to connect the pixel coordinate system and the world coordinate system so that the pixel spacing is linearly proportional to the real physical distance.
[0080] The transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system is a mapping transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system. It is usually expressed as a perspective transformation matrix, which can correct the projection distortion caused by the side / overhead shooting of the camera and realize the accurate conversion from pixel coordinates to bird's-eye view pixel coordinates.
[0081] This application's embodiments map the pixel coordinates of the two length measurement endpoints in the pixel coordinate system to the bird's-eye view coordinate system, which can eliminate perspective distortion and near-to-far problems caused by the tilt of the shooting angle in the original image, and avoid measurement errors caused by the non-linear correspondence between the original pixel spacing and the actual physical distance.
[0082] Based on the bird's-eye view pixel coordinates of the two length measurement endpoints, the bird's-eye view pixel spacing between the two length measurement endpoints can be determined. For example, the bird's-eye view pixel coordinates corresponding to the two length measurement endpoints can be substituted into the two-dimensional plane Euclidean distance formula to calculate the straight-line distance between the two points and obtain the bird's-eye view pixel spacing.
[0083] The length scaling factor is used to linearly convert the pixel spacing in the bird's-eye view into the actual physical distance in the world coordinate system. It is usually the actual physical length corresponding to a unit pixel in the bird's-eye view coordinate system, and is used to realize the conversion from image size to physical size.
[0084] Here is a specific example: For the length measurement endpoint, the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system is used. The pixel coordinates of the length measurement endpoint in the pixel coordinate system Mapping to the bird's-eye view coordinate system yields the bird's-eye view pixel coordinates of the length measurement endpoint. ;
[0085] by and For two bird's-eye view pixels after the endpoints of the two length measurements are transformed, calculate... and European distance Based on the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system, the bird's-eye view pixel spacing is converted into physical distance in the world coordinate system. :
[0086] in, The actual physical length in the known world coordinate system. Given the known bird's-eye view pixel spacing in the bird's-eye view coordinate system, the quotient of the two is the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system.
[0087] The method for calculating the length of vehicles on the road provided in this application first completes the distortion correction transformation from the original pixel coordinates to the bird's-eye view coordinates through a perspective transformation matrix. Then, through a preset length ratio coefficient, the distortion-free bird's-eye view pixel spacing is linearly converted into the real physical length. By connecting the pixel coordinate system, the bird's-eye view coordinate system, and the world coordinate system, the accuracy of physical distance calculation is improved, so that the physical distance can match the real length of the vehicle, thus solving the problem of low accuracy in traditional monocular vision ranging.
[0088] In some embodiments of this application, before determining the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system according to the two length measurement endpoints, the method further includes: In the road surface scene image, a calibration area is selected based on the lane lines; Obtain the bird's-eye view pixel length of the calibration region in the bird's-eye view coordinate system, and the physical length of the calibration region in the world coordinate system; Obtain the pixel coordinates of the corner points of the calibration area in the pixel coordinate system, and the bird's-eye view pixel coordinates of the corner points in the bird's-eye view coordinate system; Based on the pixel coordinates of the corner points and the bird's-eye view pixel coordinates, determine the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system; Based on the bird's-eye view pixel length and physical length of the calibration area, determine the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system.
[0089] The calibration region refers to a regular road surface area with known dimensions, selected based on the lane lines, serving as a reference area for calibrating transformation relationships and length scaling factors. Typically, a straight, unobstructed section within the lane is selected, such as a deformation area formed by lane lines. Corner points are the vertices of the calibration region; usually, the four corner points of a rectangular calibration region are selected as reference points for establishing the mapping relationship between pixel coordinates and physical coordinates.
[0090] For example, road lane lines can be extracted using image segmentation or edge detection algorithms, and a rectangular area enclosed by two parallel lane lines and a virtual transverse road marking can be selected as the calibration area. Since the lane lines are inherent road markings, no additional calibration plates or other hardware are required, and the road surface does not need to be modified, resulting in low calibration costs.
[0091] For example, the physical length of the calibration area composed of lane lines is usually a known fixed value, and the accurate value can be obtained through on-site measurement; the bird's-eye view pixel length can be obtained by first performing an inverse perspective transformation on the calibration area to convert it to the bird's-eye view coordinate system, extracting the coordinates of the corresponding endpoints of the calibration area in the bird's-eye view, and calculating the distance between the two points using the two-dimensional Euclidean distance formula.
[0092] For the corner points in the calibration area, the pixel coordinates of the corner points in the pixel coordinate system are located in the road scene image; the standard coordinates of each corner point in the calibration area in the bird's-eye view coordinate system can be manually marked or automatically generated according to the preset bird's-eye view size and angle, so that they correspond one-to-one with the corner points.
[0093] Select at least four sets of corner pixel coordinates and bird's-eye view pixel coordinates in the calibration area, substitute them into the linear equations of perspective transformation, solve for the perspective transformation matrix, and store the solved matrix as a fixed perspective transformation relationship for subsequent coordinate transformations.
[0094] The road vehicle length measurement method provided in this application utilizes existing lane lines to select a calibration area, eliminating the need for road surface modifications or new equipment, thus reducing calibration costs. The calibration area, selected based on lane lines, overlaps with the road surface area used for vehicle traffic and length measurement, further mitigating conversion errors caused by the disconnect between the calibration scenario and the actual scenario. By sequentially solving the coordinate system transformation relationship and length scaling factor, a complete transformation mapping link between the pixel coordinate system, bird's-eye view coordinate system, and world coordinate system is pre-built. Subsequent measurements can directly call the matrix to complete the coordinate transformation without repeated calibration, ensuring both coordinate transformation accuracy and the practicality of the calibration process.
[0095] The method for calculating the length of road vehicles provided in this application can be executed by a road vehicle length calculating device. This application uses the road vehicle length calculating device executing the method as an example to illustrate the road vehicle length calculating device provided in this application.
[0096] Figure 3 This is a schematic diagram of the structure of a road vehicle length measuring device provided in some embodiments of this application. For example... Figure 3 As shown, the road vehicle length measuring device 300 includes: Image acquisition module 301 is used to acquire road scene images of the target road surface; The detection module 302 is used to determine the vehicle area corresponding to at least one target vehicle in the road scene image, and to determine the tire area corresponding to the tire of each target vehicle in each vehicle area; The orientation line determination module 303 is used to determine, for each of the target vehicles, a vehicle orientation line representing the body length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system, wherein the pixel coordinate system is set based on the road scene image. The endpoint determination module 304 is used to determine two length calculation endpoints corresponding to the body length of the target vehicle in the vehicle region corresponding to the target vehicle, based on the vehicle orientation line. The length determination module 305 is used to determine the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints.
[0097] In some embodiments, the detection module 302 is used for: By using a pre-trained vehicle detection model, each target vehicle in the road scene image is identified and located, and the vehicle region corresponding to each target vehicle is obtained. For each target vehicle, a pre-trained tire detection model is used to identify and locate each tire in the vehicle region corresponding to the target vehicle, thereby obtaining the tire region corresponding to each tire of the target vehicle.
[0098] In some embodiments, the vehicle area and the tire area have edges; Orientation line determination module 303 is used for: For each of the tire regions, the center point of the edge corresponding to the tire region and the road surface is taken as a feature point, and the pixel coordinates of the feature point in the pixel coordinate system are determined. Based on the pixel coordinates of each feature point, determine the relative distance from each feature point to the edge of the vehicle area corresponding to the road surface; Based on the relative distances between the feature points, select the valid feature points that meet the tire layout constraints of the vehicle. The two effective feature points with the largest and smallest relative distances among the effective feature points are taken as two end feature points, and the line connecting the two end feature points is taken as the vehicle orientation line.
[0099] In some embodiments, the step of filtering valid feature points that meet the tire layout constraints of the vehicle based on the relative distances corresponding to each feature point includes: The feature points are sorted according to the relative distances they correspond to. For each of the sorted feature points, determine the angle between the line connecting the feature point and the previous feature point and the coordinate axis of the pixel coordinate system, and use the angle as the angle to be verified for the feature point. If the difference between the angle to be tested and the reference angle satisfies the first angle constraint, the feature point is determined to be a valid feature point. The reference angle is the angle between the line connecting the first two sorted feature points and the coordinate axis of the pixel coordinate system.
[0100] In some embodiments, the road vehicle length measuring device 300 further includes a verification module, which is used for: If the reference angle does not meet the second angle constraint, the vehicle area is determined to be an invalid vehicle area. Stop calculating the vehicle body length of the vehicles corresponding to the invalid vehicle area.
[0101] In some embodiments, the endpoint determination module 304 is used to: Extend the vehicle orientation line in both directions until both ends of the vehicle orientation line intersect with the edge of the vehicle area to obtain the first intersection point and the second intersection point. The first intersection point and the second intersection point are used as the two endpoints for the length measurement.
[0102] In some embodiments, the length determination module 305 is used for: Based on the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, the pixel coordinates of the two length measurement endpoints in the pixel coordinate system are mapped to the bird's-eye view coordinate system to obtain the bird's-eye view pixel coordinates of the two length measurement endpoints. The bird's-eye view pixel spacing between the two length measurement endpoints is determined based on their bird's-eye view pixel coordinates. Based on the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system, the bird's-eye pixel spacing is converted into physical distance in the world coordinate system, and the physical distance is taken as the body length of the target vehicle.
[0103] In some embodiments, the transformation relationship between the pixel coordinate system and the world coordinate system includes the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, as well as the length scaling factor between the bird's-eye view coordinate system and the world coordinate system. The road vehicle length measuring device 300 also includes a calibration module, which is used for: In the road surface scene image, a calibration area is selected based on the lane lines; Obtain the bird's-eye view pixel length of the calibration region in the bird's-eye view coordinate system, and the physical length of the calibration region in the world coordinate system; Obtain the pixel coordinates of the corner points of the calibration area in the pixel coordinate system, and the bird's-eye view pixel coordinates of the corner points in the bird's-eye view coordinate system; Based on the pixel coordinates of the corner points and the bird's-eye view pixel coordinates, determine the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system; Based on the bird's-eye view pixel length and physical length of the calibration area, determine the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system.
[0104] The road vehicle length measuring device in this application embodiment can be an electronic device or a component of an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.
[0105] The road vehicle length measuring device in this application embodiment can be a device with an operating system. This operating system can be a Microsoft (Windows) operating system, an Android operating system, an iOS operating system, or other possible operating systems; this application embodiment does not specifically limit it.
[0106] The road vehicle length measuring device provided in this application embodiment can realize all the processes implemented in the above-described road vehicle length measuring method embodiment and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0107] Figure 4 These are schematic diagrams of the structure of electronic devices provided in some embodiments of this application. In some embodiments, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. When the program is executed by the processor 401, it implements the various processes of the above-described road vehicle length calculation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0108] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0109] This application also provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described road vehicle length measurement method embodiment and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0110] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0111] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for calculating the length of road vehicles.
[0112] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0113] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled. The processor is used to run programs or instructions to implement the various processes of the above-described road vehicle length calculation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0114] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0115] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as road scene images, vehicle areas, and tire areas, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive user personal information, separate user permission or consent is obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.
[0116] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0117] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0118] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0119] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0120] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for calculating the length of vehicles on a road surface, characterized in that, include: Acquire road surface scene images of the target road surface; Determine the vehicle region corresponding to at least one target vehicle in the road scene image, and determine the tire region corresponding to the tires of each target vehicle in each vehicle region; For each of the target vehicles, based on the feature point distribution data of each tire region corresponding to the tires of the target vehicle in the pixel coordinate system, a vehicle orientation line representing the body length direction of the target vehicle is determined, and the pixel coordinate system is set based on the road scene image. Based on the vehicle orientation line, two length calculation endpoints corresponding to the body length of the target vehicle are determined in the vehicle region corresponding to the target vehicle. Based on the transformation relationship between the pixel coordinate system and the world coordinate system, the body length of the target vehicle is determined according to the two length measurement endpoints.
2. The method of claim 1, wherein, The step of determining the vehicle region corresponding to at least one target vehicle in the road scene image, and determining the tire region corresponding to the tires of each target vehicle in each vehicle region, includes: By using a pre-trained vehicle detection model, each target vehicle in the road scene image is identified and located, and the vehicle region corresponding to each target vehicle is obtained. For each target vehicle, a pre-trained tire detection model is used to identify and locate each tire in the vehicle region corresponding to the target vehicle, thereby obtaining the tire region corresponding to each tire of the target vehicle.
3. The method of claim 1, wherein, The vehicle region and the tire region have edges; determining the vehicle orientation line representing the length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system includes: For each of the tire regions, the center point of the edge corresponding to the tire region and the road surface is taken as a feature point, and the pixel coordinates of the feature point in the pixel coordinate system are determined. Based on the pixel coordinates of each feature point, determine the relative distance from each feature point to the edge of the vehicle area corresponding to the road surface; Based on the relative distances between the feature points, select the valid feature points that meet the tire layout constraints of the vehicle. The two effective feature points with the largest and smallest relative distances among the effective feature points are taken as two end feature points, and the line connecting the two end feature points is taken as the vehicle orientation line.
4. The method of claim 3, wherein, The step of filtering valid feature points that meet the tire layout constraints of the vehicle based on the relative distances between the feature points includes: The feature points are sorted according to the relative distances they correspond to. For each of the sorted feature points, determine the angle between the line connecting the feature point and the previous feature point and the coordinate axis of the pixel coordinate system, and use the angle as the angle to be verified for the feature point. If the difference between the angle to be tested and the reference angle satisfies the first angle constraint, the feature point is determined to be a valid feature point. The reference angle is the angle between the line connecting the first two sorted feature points and the coordinate axis of the pixel coordinate system.
5. The method according to claim 4, characterized in that, The method further includes: If the reference angle does not meet the second angle constraint, the vehicle area is determined to be an invalid vehicle area. Stop calculating the vehicle body length of the vehicles corresponding to the invalid vehicle area.
6. The method according to any one of claims 1 to 5, characterized in that, The step of determining two length calculation endpoints corresponding to the body length of the target vehicle in the vehicle region corresponding to the target vehicle based on the vehicle orientation line includes: Extend the vehicle orientation line in both directions until both ends of the vehicle orientation line intersect with the edge of the vehicle area to obtain the first intersection point and the second intersection point. The first intersection point and the second intersection point are used as the two endpoints for the length measurement.
7. The method according to any one of claims 1 to 5, characterized in that, The transformation relationship between the pixel coordinate system and the world coordinate system includes the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, as well as the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system. The step of determining the vehicle body length based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints, includes: Based on the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system, the pixel coordinates of the two length measurement endpoints in the pixel coordinate system are mapped to the bird's-eye view coordinate system to obtain the bird's-eye view pixel coordinates of the two length measurement endpoints. The bird's-eye view pixel spacing between the two length measurement endpoints is determined based on their bird's-eye view pixel coordinates. Based on the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system, the bird's-eye pixel spacing is converted into physical distance in the world coordinate system, and the physical distance is taken as the body length of the target vehicle.
8. The method according to claim 7, characterized in that, Before determining the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system and according to the two length measurement endpoints, the method further includes: In the road surface scene image, a calibration area is selected based on the lane lines; Obtain the bird's-eye view pixel length of the calibration region in the bird's-eye view coordinate system, and the physical length of the calibration region in the world coordinate system; Obtain the pixel coordinates of the corner points of the calibration area in the pixel coordinate system, and the bird's-eye view pixel coordinates of the corner points in the bird's-eye view coordinate system; Based on the pixel coordinates of the corner points and the bird's-eye view pixel coordinates, determine the transformation relationship between the pixel coordinate system and the bird's-eye view coordinate system; Based on the bird's-eye view pixel length and physical length of the calibration area, determine the length ratio coefficient between the bird's-eye view coordinate system and the world coordinate system.
9. A road vehicle length measuring device, characterized in that, The image acquisition module is used to acquire images of the target road surface. The detection module is used to determine the vehicle region corresponding to at least one target vehicle in the road scene image, and to determine the tire region corresponding to the tire of each target vehicle in each vehicle region; The orientation line determination module is used to determine, for each of the target vehicles, a vehicle orientation line representing the body length direction of the target vehicle based on the feature point distribution data of each tire region corresponding to the tire of the target vehicle in the pixel coordinate system, wherein the pixel coordinate system is set based on the road scene image. The endpoint determination module is used to determine, based on the vehicle orientation line, two length calculation endpoints corresponding to the body length of the target vehicle in the vehicle region corresponding to the target vehicle. The length determination module is used to determine the body length of the target vehicle based on the transformation relationship between the pixel coordinate system and the world coordinate system, according to the two length measurement endpoints.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method for calculating the length of road vehicles as described in any one of claims 1 to 8.