Distance measurement method and device based on target width and electronic equipment
Through the fusion of real-time image acquisition and Kalman filtering, the distance measurement error problem of the monocular distance measurement method under different plane conditions is solved, and a higher accuracy of vehicle distance measurement is achieved to meet the safety needs of autonomous driving.
Patent Information
- Application Number
- CN202510708666.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-05-29
AI Technical Summary
In the prior art, the monocular distance measurement method based on the small hole imaging model results in a large error in longitudinal distance measurement when the vehicle is not in the same plane, which cannot meet the needs of vehicle safety driving and autonomous driving decisions.
By collecting the front images of the vehicle in real time, identifying the target and marking the rear of the vehicle, using the small hole imaging principle combined with Kalman filtering, the target measurement width and distance are integrated, and the target measurement width and distance are broken away from the horizon assumption, the target measurement width and distance are updated, and the measurement accuracy is improved.
Improve the accuracy of distance measurement of vehicles under different plane conditions, especially when the vehicle is not in the same plane, and enhances the accuracy and safety of process-to-works distance measurement.
Smart Images

Figure CN120233349A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of autonomous driving, and in particular, to a distance measurement method, apparatus, and electronic device based on target width. Background Art
[0002] The vehicle distance detection algorithm is an important part of the field of autonomous driving. It is crucial for ensuring the safe driving of vehicles, avoiding collision accidents, and also providing a basis for the decision-making of autonomous driving. During vehicle driving, the prior art generally uses a monocular ranging method to measure the vehicle distance. Specifically, based on the information of the current frame and camera parameters, the longitudinal distance of the target is calculated using the principle of small hole imaging in optics. The information of the current frame includes the position of the target box determined by 2D target detection, and the camera parameters include the internal and external parameters of the camera and distortion coefficients, etc. Since the premise of this method for measuring distance is to make a flat ground assumption, that is, assuming that the road surface is a strictly flat plane. However, during the actual driving process of the vehicle, it will not always drive on a flat road surface, and there will be a situation where the own vehicle and the target vehicle are not on the same plane. In this case, if the monocular ranging method based on the small hole imaging model is used, the measured longitudinal distance error will be relatively large. Summary of the Invention
[0003] The present invention aims to at least solve the technical problems existing in the prior art. To this end, in the first aspect of the present invention, a distance measurement method based on target width is proposed. The method includes:
[0004] Real-time collect an image in front of the vehicle through a camera, identify the target in the image, and label the rear of the target; the target is a vehicle;
[0005] According to the pixel coordinates of the target boundary, camera focal length, camera pitch angle, and camera mounting height in each frame of the continuous frame image, use the principle of small hole imaging to determine the first target distance corresponding to each frame of the image; the first target distance is the measured distance of the target;
[0006] When the first target distance is less than a preset distance threshold, determine the first target distance as the estimated distance corresponding to the target in each frame of the image, and use the principle of small hole imaging to determine the target measurement width corresponding to each frame of the image according to the first target distance, camera focal length, and pixel width of the rear of the target;
[0007] Perform fusion update on the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width;
[0008] When the number of updates of the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame image is greater than a preset distance threshold, determine the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear vehicle boundary; the target measurement width determined by the last update is the estimated width of the target.
[0009] Based on Kalman filtering, fuse the first target distance and the second target distance corresponding to the subsequent frame image to obtain the estimated distance of the target corresponding to the subsequent frame image.
[0010] Optionally, the fusion update of the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width includes:
[0011] Obtain the first Kalman gain according to the preset first width variance and second width variance; the first width variance is the variance of the target measurement width corresponding to the current frame image; the second width variance is the variance of the updated target measurement width corresponding to the previous frame image; the second width variance is determined by fusion using Kalman filtering.
[0012] Obtain the updated target measurement width according to the first Kalman gain, the target measurement width corresponding to the current frame image, and the target measurement width corresponding to the previous frame image.
[0013] Optionally, the determination of the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear vehicle boundary includes:
[0014]
[0015] Wherein, is the second target distance corresponding to the subsequent frame image, is the target measurement width determined by the last update, that is, the estimated width of the target, is the focal length of the camera in the u direction of the image. Taking the upper left corner of the image as the origin, the horizontal right direction is the u direction, and the vertical downward direction is the v direction, and are the pixel coordinates of the left and right boundaries of the rear vehicle frame in the u direction of the image respectively.
[0016] Optionally, the fusion of the first target distance and the second target distance corresponding to the subsequent frame image based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame image includes:
[0017] Determine the second Kalman gain for the fusion of the first target distance and the second target distance based on the preset first target distance variance and second target distance variance;
[0018] Obtain the distance difference based on the first target distance and the second target distance corresponding to the subsequent frame image;
[0019] Determine the estimated distance of the target corresponding to the subsequent frame image according to the second Kalman gain, the distance difference, and the second target distance corresponding to the subsequent frame image.
[0020] Optionally, after the vehicle front image is collected in real time by the camera, it further includes:
[0021] Perform distortion correction on the collected vehicle front image.
[0022] Optionally, the identifying the target in the image includes:
[0023] Use the first YOLO model to identify all targets in the image and obtain the target box and target type of each target.
[0024] Optionally, the labeling of the target vehicle tail includes:
[0025] Use the first YOLO model to identify the vehicle tail of each target in the image and obtain the corresponding bounding box; the first YOLO model is a multi-output model.
[0026] Optionally, after the labeling of the target vehicle tail, it further includes:
[0027] Use the bytetrack algorithm to perform target tracking on the targets in consecutive frame images and obtain the target correspondence between the current frame image and the previous frame image.
[0028] The second aspect of the present invention proposes a distance measurement device based on the target width, and the device includes:
[0029] An image acquisition module, configured to collect a vehicle front image in real time through a camera, identify the target in the image, and label the target vehicle tail; the target is a vehicle;
[0030] A first data processing module, configured to use the principle of pinhole imaging to determine the first target distance corresponding to each frame image according to the pixel coordinates of the target boundary, the camera focal length, the camera pitch angle, and the camera mounting height in each frame of consecutive frame images; the first target distance is the measured distance of the target;
[0031] A judgment module, configured to, when the first target distance is less than a preset distance threshold, judge that the first target distance is the estimated distance of the target corresponding to each frame image, and use the principle of pinhole imaging to determine the target measurement width corresponding to each frame image according to the first target distance, the camera focal length, and the pixel width of the target vehicle tail;
[0032] A data update module, configured to fuse and update the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width;
[0033] A second data processing module, configured to, when the number of times of updating the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame image is greater than a preset distance threshold, determine the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear vehicle boundary; the target measurement width determined by the last update is the estimated width of the target;
[0034] A third data processing module, configured to fuse the first target distance and the second target distance corresponding to the subsequent frame image based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame image.
[0035] A third aspect of the present invention proposes an electronic device, which includes a processor and a memory. At least one instruction or at least one program segment is stored in the memory, and the at least one instruction or at least one program segment is loaded and executed by the processor to implement the distance measurement method based on the target width proposed in the first aspect.
[0036] The beneficial effects of a distance measurement method, device, and electronic device based on the target width are as follows: The present invention measures the width based on the pinhole imaging model, presets a distance threshold, and when the first target distance is less than the preset distance threshold, uses the historical frame information to update the width and continuously iterates using Kalman filtering, improving the measurement accuracy of the width; The present invention calculates the longitudinal distance between vehicles according to the pixel width and the estimated width, breaking away from the original traditional pinhole imaging model, making the horizon assumption no longer necessary for calculating the distance, improving the distance measurement accuracy when the vehicles are not on the same plane, and at the same time using Kalman filtering when updating the target distance, integrating the calculation results of the traditional model and the calculation results based on width measurement, correcting the calculation results of the traditional model, and improving the measurement accuracy of the distance between vehicles during vehicle driving, especially the measurement accuracy of the distance between vehicles when they are not on the same plane. Description of the Drawings
[0037] Figure 1 It is a flowchart of a distance measurement method based on the target width provided by an embodiment of the present invention;
[0038] Figure 2 It is a schematic diagram of pinhole imaging when the pitch angle is assumed to be 0;
[0039] Figure 3 It is a schematic diagram of width measurement. Detailed Embodiments
[0040] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts belong to the scope of protection of the present invention.
[0041] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present disclosure, unless otherwise stated, the meaning of "a plurality" is two or more. Additionally, the use of "based on" or "in accordance with" means open and inclusive, because a process, step, calculation, or other action "based on" or "in accordance with" one or more of the stated conditions or values may in practice be based on additional conditions or values beyond those stated.
[0042] An embodiment of the present invention provides a distance measurement method based on a target width, as Figure 1 shown, the method may include the following steps:
[0043] Step 101, collect an image in front of the vehicle in real time through a camera, identify the target in the image, and label the rear of the target; the target is a vehicle.
[0044] Specifically, the camera in the embodiment of the present invention is set at the front position of the vehicle, and only the measurement of the inter-vehicle distance corresponding to the vehicle traveling in the same direction as the vehicle is considered, that is, the measurement of the longitudinal distance.
[0045] In a possible implementation manner, after collecting the image in front of the vehicle in real time through the camera, it further includes:
[0046] Perform distortion correction on the collected image in front of the vehicle.
[0047] The distortion correction in this embodiment includes correcting the distortion of the image and rotating the image according to the external parameters of the camera to ensure that the image is horizontal with the road surface. Specifically, rotating the image according to the external parameters of the camera means correcting according to the roll angle of the camera so that the image is horizontal with the road surface to reduce the error in subsequent measurements.
[0048] In a possible implementation manner, the identifying the target in the image includes:
[0049] Use a first YOLO model to identify all targets in the image and obtain the target box and target type of each target.
[0050] Specifically, the processed image is input into the trained YOLO model. For example, the YOLOv5 model can be used to identify all vehicle targets in each frame of the image, obtaining the target bounding boxes and the target types corresponding to each target bounding box. Exemplarily, the target types can be trucks, sedans, and other types.
[0051] In a possible implementation manner, the annotation of the target vehicle rear includes:
[0052] The first YOLO model is used to identify the rear of each target in the image, obtaining the corresponding bounding boxes; the first YOLO model is a multi-output model.
[0053] Specifically, the image is input into the previously trained YOLO model, that is, the first YOLO model. The target bounding box corresponding to the vehicle rear is output through the first YOLO model. It should be noted that the YOLO model in this embodiment is an improvement over the existing model. It can achieve multi-output, and can not only output the vehicle bounding box, but also output the vehicle rear bounding box. Among them, the vehicle bounding box and the vehicle rear bounding box share the same coordinate system.
[0054] In a possible implementation manner, after the annotation of the target vehicle rear, it further includes:
[0055] The bytetrack algorithm is used to perform target tracking on the targets in consecutive frame images, obtaining the corresponding relationship of the targets in the current frame image and the previous frame image.
[0056] Specifically, the bytetrack algorithm is used to track the targets in consecutive frame images, determining the corresponding positions of the targets in the previous frame image in the current frame image. Thus, the numbers of each target in the current frame image can be obtained through the numbers of each vehicle in the historical frame images, aligning the target information of the current frame with the target information of the historical frame. Using the bytetrack algorithm for target tracking improves the tracking accuracy and reduces the time complexity of the algorithm.
[0057] Step 102: According to the pinhole imaging principle, the first target distance corresponding to each frame of the image is determined based on the pixel coordinates of the target boundary in each frame of the consecutive frame images, the camera focal length, the camera pitch angle, and the camera mounting height; the first target distance is the measured distance of the target.
[0058] Specifically, the camera pitch angle can be obtained through an IMU device or other means. When calculating the first target distance, the pixel coordinate value of the target bottom edge is used, that is, the pixel coordinate value of the target grounding point. For each target in the image, Figure 2 is the pinhole imaging schematic diagram when the pitch angle is assumed to be 0. Refer to Figure 2 , the first target distance is determined by the following expression for all:
[0059]
[0060]
[0061] Among them, A represents the angle between the target bottom edge and the camera optical axis. Taking the upper left corner of the image as the origin, the horizontal right direction is the u direction, and the vertical downward direction is the v direction. is the pixel coordinate value of the bottom edge of the 2D detection frame of the target in the v direction of the image. is the pixel coordinate value of the optical center in the v direction of the image. is the focal length of the camera in the v direction of the image, H is the camera mounting height. In the existing monocular ranging, based on the assumption of a flat road surface, the camera mounting height is the height difference between the camera and the target grounding point. P is the camera pitch angle, and L1 is the first target distance.
[0062] Step 103: When the first target distance is less than a preset distance threshold, determine the first target distance as the estimated distance of the target corresponding to each frame of the image, and use the principle of pinhole imaging to determine the target measurement width corresponding to each frame of the image according to the first target distance, the camera focal length, and the pixel width of the target vehicle tail.
[0063] It is known from engineering practice that the measurement data error of a target is greater when the distance is farther, which includes multiple factors, such as calibration error, road surface slope, and inaccuracy of the 2D detection frame determined in the target detection link. However, when the distance between the target and the camera is closer, the influence of the above factors on the final measurement result is smaller. Therefore, through continuous practice, a distance threshold is set, and different distance measurement methods are adopted according to the size relationship between the first target distance and the distance threshold. Exemplarily, the distance threshold can be set to 30 meters.
[0064] When the first target distance is less than the preset distance threshold, the width of the target is calculated based on the principle of pinhole imaging. The pixel coordinates of the left and right boundaries of the vehicle tail frame can be obtained through the aforementioned first YOLO model, and thus the pixel width of the target vehicle in the image is obtained. On this basis, the width of the target, that is, the target measurement width, can be determined according to the first target distance and the camera focal length. Refer to Figure 3 , the expression is as follows:
[0065]
[0066] Among them, is the target measurement width corresponding to the current frame of the image, L1 is the first target distance, is the focal length of the camera in the u direction of the image, and are the pixel coordinates of the left and right boundaries of the vehicle tail frame in the u direction of the image respectively.
[0067] Step 104: Update and fuse the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width.
[0068] In a possible implementation, the step of updating and fusing the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width includes:
[0069] Obtain the first Kalman gain according to the preset first width variance and second width variance; the first width variance is the variance of the target measurement width corresponding to the current frame image; the second width variance is the variance of the updated target measurement width corresponding to the previous frame image; the second width variance is determined by fusion using Kalman filtering;
[0070] Obtain the updated target measurement width according to the first Kalman gain, the target measurement width corresponding to the current frame image, and the target measurement width corresponding to the previous frame image.
[0071] Specifically, in this embodiment, the target measurement width corresponding to the previous frame image is the width after fusion through Kalman filtering, that is, the updated target measurement width corresponding to the previous frame image. After determining the target measurement width according to each frame of image information, the information of the previous frame image is used for fusion, and the width after fusion update is used as the final target measurement width corresponding to the current frame. The expression of the updated target measurement width is as follows:
[0072]
[0073]
[0074]
[0075]
[0076] Where is the target measurement width corresponding to the current frame image, is the updated target measurement width of the current frame image, is the updated target measurement width of the previous frame image, is the width difference between the updated target measurement width of the previous frame image and the target measurement width corresponding to the current frame image, is the Kalman gain for width fusion, that is, the first Kalman gain, is the variance of the updated target measurement width corresponding to the previous frame image, that is, the second width variance, and the second width variance is determined by fusion using Kalman filtering, is the variance of the target measurement width corresponding to the current frame image, i.e., the first width variance. In this embodiment, it is assigned based on experience in combination with the target measurement width corresponding to the current frame image. P is the variance of the target measurement width after the update of the current frame image, that is, the width fusion variance corresponding to the current frame image.
[0077] Step 105: When the number of updates of the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame image is greater than a preset distance threshold, determine the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear vehicle boundary; the target measurement width determined by the last update is the estimated width of the target.
[0078] Specifically, the number threshold can be set to 10 times. The setting of the number threshold is to improve the accuracy of the determined estimated width, thereby improving the accuracy of the subsequent distance measurement. This embodiment only gives a suggested value, and the specific value can be set by the implementer according to the situation.
[0079] In a possible implementation manner, the determining the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear vehicle boundary includes:
[0080]
[0081] where, is the second target distance corresponding to the subsequent frame image, W is the target measurement width determined by the last update, that is, the estimated width of the target, is the focal length of the camera in the u direction of the image. Taking the upper left corner of the image as the origin, the horizontal right direction is the u direction, and the vertical downward direction is the v direction, and are the pixel coordinates of the left and right boundaries of the rear vehicle frame in the u direction of the image, respectively.
[0082] Step 106: Based on the Kalman filter, fuse the first target distance and the second target distance corresponding to the subsequent frame image to obtain the estimated distance of the target corresponding to the subsequent frame image.
[0083] In a possible implementation manner, the fusing the first target distance and the second target distance corresponding to the subsequent frame image based on the Kalman filter to obtain the estimated distance of the target corresponding to the subsequent frame image includes:
[0084] Determine the second Kalman gain for fusing the first target distance and the second target distance based on the preset first target distance variance and second target distance variance;
[0085] Obtain the distance difference according to the first target distance and the second target distance corresponding to the subsequent frame image;
[0086] Determine the estimated distance of the target in the subsequent frame image according to the second Kalman gain, the distance difference, and the second target distance corresponding to the subsequent frame image.
[0087] The expression for the estimated distance of the target in the subsequent frame image is as follows:
[0088]
[0089]
[0090]
[0091] Wherein, is the difference between the second target distance and the first target distance corresponding to the subsequent frame image, is the second target distance corresponding to the subsequent frame image, that is, the target distance corresponding to the subsequent frame image determined by the width, is the first target distance corresponding to the subsequent frame image, that is, the target distance determined by the traditional pinhole imaging model, is the Kalman gain of distance fusion, that is, the second Kalman gain, is the variance of the second target distance corresponding to the subsequent frame image, that is, the variance of the target distance determined by the width, is the variance of the first target distance corresponding to the subsequent frame image, that is, the variance of the target distance determined by the traditional pinhole imaging model, and L is the fused distance, that is, the estimated distance of the target in the subsequent frame image.
[0092] Specifically, the target distance variance generally cannot be directly calculated, but is assigned a value through experience. In the embodiments of the present invention, the distance variance obtained by the traditional pinhole imaging model is made greater than the distance variance determined by the width, so that when fused by the Kalman filter, the result will be more biased towards the target distance obtained by the width.
[0093] In summary, in the embodiments of the present invention, width measurement is performed based on the pinhole imaging model, a distance threshold is preset, and when the first target distance is less than the preset distance threshold, the width is updated using historical frame information and the Kalman filter is continuously iterated, improving the measurement accuracy of the width; the present invention calculates the longitudinal distance of the workshop according to the pixel width and the estimated width, breaking away from the original traditional pinhole imaging model, making the horizontal plane assumption no longer necessary for calculating the distance, improving the distance measurement accuracy when the vehicles are not on the same plane, and at the same time using the Kalman filter when updating the target distance, integrating the calculation results of the traditional model and the calculation results based on width measurement, correcting the calculation results of the traditional model, and improving the workshop distance measurement accuracy during vehicle driving, especially the workshop distance measurement accuracy when the vehicles are not on the same plane.
[0094] An embodiment of the present invention further provides a distance measurement device based on a target width. The device includes:
[0095] An image acquisition module, configured to collect an image in front of the vehicle in real time through a camera, identify a target in the image, and label the rear of the target; the target is a vehicle.
[0096] A first data processing module, configured to determine a first target distance corresponding to each frame of image according to the pixel coordinates of the target boundary, the camera focal length, the camera pitch angle, and the camera mounting height in each frame of continuous frame image by using the principle of pinhole imaging; the first target distance is the measured distance of the target.
[0097] A judgment module, configured to, when the first target distance is less than a preset distance threshold, judge that the first target distance is the estimated distance corresponding to the target in each frame of image, and determine the target measurement width corresponding to each frame of image according to the first target distance, the camera focal length, and the pixel width of the target rear by using the principle of pinhole imaging.
[0098] A data update module, configured to fuse and update the target measurement width corresponding to the current frame of image and the target measurement width corresponding to the previous frame of image through Kalman filtering to obtain the updated target measurement width.
[0099] A second data processing module, configured to, when the number of times of updating the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame of image is greater than the preset distance threshold, determine the second target distance corresponding to the subsequent frame of image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear boundary; the target measurement width determined by the last update is the estimated width of the target.
[0100] A third data processing module, configured to fuse the first target distance and the second target distance corresponding to the subsequent frame of image based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame of image.
[0101] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the foregoing method embodiment, and will not be elaborated here.
[0102] In another embodiment provided by the present invention, an electronic device is further provided. The electronic device includes a processor and a memory. At least one instruction or at least one program segment is stored in the memory. The at least one instruction or at least one program segment is loaded and executed by the processor to implement the distance measurement method based on the target width proposed in the embodiment of the present invention.
[0103] The above mainly introduces the solution provided by the embodiments of the present invention from the perspective of the device. It can be understood that in order for the device to implement the above functions, it includes the corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that in combination with the algorithm steps of each example described in the embodiments disclosed in this article, the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0104] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A distance measurement method based on the target width, characterized in that, Including: Real-time collecting an image in front of a vehicle by a camera, identifying a target in the image, and marking the rear of the target; The target is a vehicle; According to the principle of pinhole imaging, determining a first target distance corresponding to each frame of image based on the pixel coordinates of the target boundary, the camera focal length, the camera pitch angle, and the camera mounting height in each frame of continuous frame images; the first target distance is the measured distance of the target; When the first target distance is less than a preset distance threshold, determining the first target distance as the estimated distance corresponding to the target in each frame of image, and determining the target measurement width corresponding to each frame of image according to the first target distance, the camera focal length, and the pixel width of the target rear based on the principle of pinhole imaging; Fusing and updating the target measurement width corresponding to the current frame of image and the target measurement width corresponding to the previous frame of image through Kalman filtering to obtain an updated target measurement width; When the number of times of updating the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame of image is greater than the preset distance threshold, determining a second target distance corresponding to the subsequent frame of image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear boundary; the target measurement width determined by the last update is the estimated width of the target; Fusing the first target distance and the second target distance corresponding to the subsequent frame of image based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame of image.
2. The distance measurement method based on a target width according to claim 1, wherein The step of fusing and updating the target measurement width corresponding to the current frame of image and the target measurement width corresponding to the previous frame of image through Kalman filtering to obtain an updated target measurement width includes: Obtaining a first Kalman gain according to a preset first width variance and a second width variance; the first width variance is the variance of the target measurement width corresponding to the current frame of image; the second width variance is the variance of the updated target measurement width corresponding to the previous frame of image; the second width variance is determined by fusing through Kalman filtering; Obtaining an updated target measurement width according to the first Kalman gain, the target measurement width corresponding to the current frame of image, and the target measurement width corresponding to the previous frame of image.
3. The distance measurement method based on the target width according to claim 1, characterized in that The step of determining a second target distance corresponding to the subsequent frame of image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear boundary includes: Among them, is the second target distance corresponding to the subsequent frame image, is the target measurement width determined by the last update, that is, the estimated width of the target, is the focal length of the camera in the u direction of the image. Taking the upper left corner of the image as the origin, the horizontal right direction is the u direction, and the vertical downward direction is the v direction, and are the pixel coordinates of the left and right boundaries of the rear vehicle frame in the u direction of the image respectively.
4. The distance measurement method based on the target width according to claim 1, wherein The step of fusing the first target distance and the second target distance corresponding to the subsequent frame of image based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame of image includes: Determining a second Kalman gain for fusing the first target distance and the second target distance based on a preset first target distance variance and a second target distance variance; Obtaining a distance difference according to the first target distance and the second target distance corresponding to the subsequent frame of image; Determining the estimated distance of the target corresponding to the subsequent frame of image according to the second Kalman gain, the distance difference, and the second target distance corresponding to the subsequent frame of image.
5. The distance measurement method based on the target width according to claim 1, characterized in that After real-time collecting an image in front of a vehicle by the camera, further including: Performing distortion correction on the collected image in front of the vehicle.
6. The distance measurement method based on a target width according to claim 1, wherein The step of identifying a target in the image includes: Use the first YOLO model to identify all objects in the image, and obtain the bounding box and object type of each object.
7. The distance measurement method based on the target width according to claim 6, characterized in that, The labeling of the rear of the object includes: Use the first YOLO model to identify the rear of each object in the image, and obtain the corresponding bounding box; the first YOLO model is a multi-output model.
8. The distance measurement method based on a target width according to claim 1, wherein After the labeling of the rear of the object, it further includes: Use the bytetrack algorithm to perform object tracking on the objects in consecutive frame images, and obtain the corresponding relationship of the objects in the current frame image and the previous frame image.
9. A distance measurement device based on the target width, characterized in that, The device includes: An image acquisition module, configured to collect the image in front of the vehicle in real time through a camera, identify the objects in the image, and label the rear of the object; the object is a vehicle; A first data processing module, configured to determine the first target distance corresponding to each frame image according to the pixel coordinates of the object boundary, the camera focal length, the camera pitch angle, and the camera mounting height in each frame of consecutive frame images by using the principle of pinhole imaging; the first target distance is the measured distance of the object. A judgment module, configured to, when the first target distance is less than a preset distance threshold, judge that the first target distance is the estimated distance corresponding to the object in each frame image, and determine the target measurement width corresponding to each frame image according to the first target distance, the camera focal length, and the pixel width of the rear of the object by using the principle of pinhole imaging. A data update module, configured to fuse and update the target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image through Kalman filtering to obtain the updated target measurement width. A second data processing module, configured to, when the number of updates of the target measurement width is greater than a preset number threshold and the first target distance corresponding to the subsequent frame image is greater than the preset distance threshold, determine the second target distance corresponding to the subsequent frame image according to the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the rear boundary; the target measurement width determined by the last update is the estimated width of the object. A third data processing module, configured to fuse the first target distance and the second target distance corresponding to the subsequent frame image based on Kalman filtering to obtain the estimated distance of the object corresponding to the subsequent frame image.
10. An electronic device, characterized in that, The electronic device includes a processor and a memory, and at least one instruction or at least one program is stored in the memory, and the at least one instruction or at least one program is loaded and executed by the processor to implement the distance measurement method based on the object width according to any one of claims 1-8.
Citation Information
Patent Citations
Vehicle distance detection method based on tail detection
CN105046225A
Pedestrian-vehicle distance estimation method based on YOLO and RGB images
CN112699748A
Method, system, medium, equipment and terminal for inland vessel identification and depth estimation for smart maritime
US20240013505A1
Work vehicle detection and tracking method and system
WO2023065395A1
Monocular ranging method and apparatus for intelligent driving of vehicle, and device, medium and vehicle
WO2024198171A1
Cited By
Multi-target distance measurement method and device, electronic equipment and storage medium
CN120431133A
Multi-target detection and distance measurement integrated system based on YOLOv5
CN120928329A