Distance measurement method, device and electronic equipment based on target width

By collecting images in real time in autonomous driving and updating the target width using small hole imaging principle and Kalman filtering, the problem of large measurement errors on non-flat roads is solved, and a higher precision between-works distance measurement is achieved.

CN120233349BActive Publication Date: 2025-08-08ZHIZI AUTOMOTIVE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510708666.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-08-08
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

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 accuracy requirements of autonomous driving.

Method used

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 width is updated and the distance measurement is integrated, which is separated from the horizon assumption and improves the measurement accuracy.

Benefits of technology

It improves the accuracy of measuring between workshop distances when the vehicle is not on the same plane, and enhances the safety and decision-making basis of autonomous driving.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120233349B_ABST
    Figure CN120233349B_ABST
Patent Text Reader

Abstract

The present invention discloses a distance measurement method, device, and electronic device based on target width, relating to the field of autonomous driving. The method includes: capturing an image in front of a vehicle and identifying a target in the image; determining a first target distance corresponding to the image; when the first target distance is less than a distance threshold, determining the first target distance as the estimated distance corresponding to each frame image, and determining the target measurement width corresponding to each frame image based on the first target distance, focal length, and pixel width of the rear of the vehicle; fusing and updating the target measurement widths corresponding to the current frame image and the previous frame image to obtain an updated target measurement width; when the number of updates is greater than a number threshold and the first target distance corresponding to the subsequent frame image is greater than a distance threshold, determining a second target distance corresponding to the subsequent frame image; and fusing the first and second target distances corresponding to the subsequent frame image to obtain an estimated distance corresponding to the target in the subsequent frame image. The above method improves the accuracy of vehicle-to-vehicle distance measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of autonomous driving, and in particular to a distance measurement method, device and electronic equipment based on target width. Background Art

[0002] Vehicle distance detection algorithms are a crucial component of autonomous driving. They are crucial for ensuring safe driving and avoiding collisions, and they also provide a basis for autonomous driving decision-making. Existing technologies generally use monocular ranging methods to measure vehicle distance while the vehicle is in motion. Specifically, they use the optical pinhole imaging principle to calculate the longitudinal distance of the target using the current frame information and camera parameters. The current frame information includes the target frame position determined by 2D target detection, and the camera parameters include information such as the camera's internal and external parameters and distortion coefficients. This method assumes that the ground is flat, assuming that the road surface is a strict plane. However, in actual driving, cars do not always travel on flat roads, and the vehicle and the target vehicle may not be on the same plane. In this case, using a monocular ranging method based on the pinhole imaging model will result in large errors in the measured longitudinal distance. Summary of the Invention

[0003] The present invention aims to at least solve the technical problems existing in the prior art. To this end, the present invention provides a distance measurement method based on target width in a first aspect, the method comprising:

[0004] The camera collects the image in front of the vehicle in real time, identifies the target in the image, and marks the rear of the target vehicle; the target is a vehicle;

[0005] Using 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 continuous frame image, the camera focal length, the camera pitch angle, and the camera installation height; the first target distance is the measured distance of the target;

[0006] When the first target distance is less than a preset distance threshold, the first target distance is determined to be the estimated distance of the target corresponding to each frame of the image, and the target measurement width corresponding to each frame of the image is determined by using the pinhole imaging principle according to the first target distance, the camera focal length, and the pixel width of the target vehicle rear end;

[0007] The target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image are fused and updated through Kalman filtering to obtain an updated target measurement width;

[0008] When the number of target measurement width updates exceeds a preset number threshold, and the first target distance corresponding to the subsequent frame image exceeds a preset distance threshold, the second target distance corresponding to the subsequent frame image is determined based on the target measurement width determined in the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined in the last update is the estimated width of the target;

[0009] The first target distance and the second target distance corresponding to the subsequent frame images are fused based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images.

[0010] Optionally, fusing and updating 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 an updated target measurement width includes:

[0011] A first Kalman gain is obtained according to a preset first width variance and a second width variance; the first width variance is the target measurement width variance corresponding to the current frame image; the second width variance is the updated target measurement width variance corresponding to the previous frame image; the second width variance is determined by fusion using a Kalman filter;

[0012] An updated target measurement width is obtained 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, determining a second target distance corresponding to a subsequent frame image based on the target measurement width, camera focal length, and pixel coordinates of the vehicle rear boundary determined by the last update includes:

[0014]

[0015] in, is the second target distance corresponding to the subsequent frame image, The measured width of the target determined for the last update, i.e. the estimated width of the target, is the focal length of the camera in the u direction of the image, with 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 frame in the u direction of the image.

[0016] Optionally, fusing the first target distance and the second target distance corresponding to the subsequent frame images based on Kalman filtering to obtain an estimated distance of the target corresponding to the subsequent frame images includes:

[0017] Determine 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 preset second target distance variance;

[0018] Obtaining a distance difference according to the first target distance and the second target distance corresponding to subsequent frame images;

[0019] An estimated distance of the target corresponding to the subsequent frame image is determined according to the second Kalman gain, the distance difference, and a second target distance corresponding to the subsequent frame image.

[0020] Optionally, after collecting the image in front of the vehicle in real time by the camera, the method further includes:

[0021] Perform distortion correction on the collected image in front of the vehicle.

[0022] Optionally, identifying a target in an image includes:

[0023] The first YOLO model is used to identify all objects in the image, and the target box and target type of each object are obtained.

[0024] Optionally, marking the rear end of the target vehicle includes:

[0025] The first YOLO model is used to identify the rear end of each target in the image to obtain a corresponding bounding box; the first YOLO model is a multi-output model.

[0026] Optionally, after marking the rear end of the target vehicle, the method further includes:

[0027] The ByteTrack algorithm is used to track targets in consecutive frame images to obtain the corresponding relationship between the target in the current frame image and the previous frame image.

[0028] A second aspect of the present invention provides a distance measurement device based on target width, the device comprising:

[0029] An image acquisition module is used to capture images in front of the vehicle in real time through a camera, identify targets in the image, and mark the rear of the target vehicle; the target is a vehicle;

[0030] A first data processing module is configured to determine a first target distance corresponding to each frame of the image based on the pixel coordinates of the target boundary in each frame of the continuous frame image, the camera focal length, the camera pitch angle, and the camera installation height using the pinhole imaging principle; 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 the first target distance as the estimated distance of the target corresponding to each frame of the image, and determine the target measurement width corresponding to each frame of the image based on the first target distance, the camera focal length, and the pixel width of the target vehicle rear end using the pinhole imaging principle;

[0032] A data updating module is used 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 an updated target measurement width;

[0033] a second data processing module configured to determine, when the number of target measurement width updates exceeds a preset number threshold and the first target distance corresponding to the subsequent frame image exceeds a preset distance threshold, a second target distance corresponding to the subsequent frame image based on the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined by the last update being the estimated target width;

[0034] The third data processing module is used to fuse the first target distance and the second target distance corresponding to the subsequent frame images based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images.

[0035] A third aspect of the present invention proposes an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, 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 target width as proposed in the first aspect.

[0036] A distance measurement method, device and electronic device based on target width have the following beneficial effects: the present invention performs width measurement based on a pinhole imaging model, presets a distance threshold, and when the first target distance is less than the preset distance threshold, uses historical frame information to update the width and continuously uses Kalman filtering iteration to improve the measurement accuracy of the width; the present invention calculates the longitudinal distance between vehicles based on pixel width and estimated width, deviates from the original traditional pinhole imaging model, makes the horizontal ground assumption no longer necessary for calculating the distance, improves the distance measurement accuracy when vehicles are not in the same plane, and uses Kalman filtering when updating the target distance, combines the calculation results of the traditional model and the calculation results based on width measurement, corrects the calculation results of the traditional model, and improves the measurement accuracy of the distance between vehicles during vehicle driving, especially the measurement accuracy of the distance between vehicles when vehicles are not in the same plane. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A flow chart of a distance measurement method based on target width provided by an embodiment of the present invention;

[0038] Figure 2 This is a schematic diagram of pinhole imaging when the pitch angle is assumed to be 0;

[0039] Figure 3 Width measurement diagram. DETAILED DESCRIPTION

[0040] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0041] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, the use of "based on" or "according to" means openness and inclusiveness, because the process, steps, calculations or other actions "based on" or "according to" one or more of the conditions or values may be based on additional conditions or values beyond the stated in practice.

[0042] The embodiment of the present invention provides a distance measurement method based on target width, such as Figure 1 As shown, the method may include the following steps:

[0043] Step 101: Use a camera to capture a real-time image of the front of a vehicle, identify a target in the image, and mark the rear of the target vehicle; the target is a vehicle.

[0044] Specifically, the camera in the embodiment of the present invention is set in front of the vehicle, and only the vehicle distance corresponding to the vehicle traveling in the same direction as the vehicle is considered, that is, the longitudinal distance.

[0045] In a possible implementation, after collecting the image in front of the vehicle in real time by the camera, the method further includes:

[0046] Perform distortion correction on the collected image in front of the vehicle.

[0047] Distortion correction in this embodiment involves correcting image distortion and rotating the image based on the camera's extrinsic parameters to ensure that the image is level with the road surface. Specifically, the image is rotated based on the camera's extrinsic parameters, i.e., corrected based on the camera's roll angle, to ensure that the image is level with the road surface, thereby reducing errors in subsequent measurements.

[0048] In one possible implementation, identifying a target in an image includes:

[0049] The first YOLO model is used to identify all objects in the image, and the target box and target type of each object are obtained.

[0050] Specifically, the processed image is fed into a trained YOLO model, such as the YOLOv5 model, to identify all vehicle targets in each frame, obtaining target boxes and the target type corresponding to each target box. For example, the target type can be a truck, a car, or other types.

[0051] In a possible implementation, marking the rear end of the target vehicle includes:

[0052] The first YOLO model is used to identify the rear end of each target in the image to obtain a corresponding bounding box; the first YOLO model is a multi-output model.

[0053] Specifically, the image is input into the previously trained YOLO model, i.e., the first YOLO model. The first YOLO model outputs a target frame corresponding to the rear of the vehicle. It should be noted that the YOLO model in this embodiment is an improvement over the existing model. It can achieve multiple outputs, outputting not only the vehicle frame but also the rear frame. The vehicle frame, i.e., the target frame, and the rear frame share the same coordinate system.

[0054] In a possible implementation, after marking the rear end of the target vehicle, the method further includes:

[0055] The ByteTrack algorithm is used to track targets in consecutive frame images to obtain the corresponding relationship between the target in the current frame image and the previous frame image.

[0056] Specifically, the ByteTrack algorithm tracks targets in successive frames, determining the corresponding position of targets in the previous frame in the current frame. This allows the number of each target in the current frame to be determined by the vehicle number in the previous frame, aligning the target information in the current frame with that in the previous frame. Using the ByteTrack algorithm for target tracking improves tracking accuracy and reduces the algorithm's time complexity.

[0057] Step 102: Determine the first target distance corresponding to each frame of the image using the pinhole imaging principle based on the pixel coordinates of the target boundary in each frame of the continuous frame image, the camera focal length, the camera pitch angle, and the camera installation 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, that is, the pixel coordinate value of the target ground point, is used. For each target in the image, Figure 2 This is a schematic diagram of pinhole imaging when the pitch angle is 0. Figure 2 , the first target distance is determined by the following expression:

[0059]

[0060]

[0061] Among them, A represents the angle between the bottom edge of the target and the optical axis of the camera. The upper left corner of the image is 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 target's 2D detection box in the image v direction, 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 image v direction, H is the camera installation height. In existing monocular ranging, based on the assumption that the road surface is flat, the camera installation height is the height difference between the camera and the target ground 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, the first target distance is determined to be the estimated distance of the target corresponding to each frame of the image, and the pinhole imaging principle is used to determine the target measurement width corresponding to each frame of the image based on the first target distance, the camera focal length, and the pixel width of the target vehicle rear end.

[0063] Engineering practice has shown that the farther the target is, the greater the data error in the measurement. This is due to multiple factors, such as calibration error, road slope, and inaccurate 2D detection frames determined during target detection. However, the closer the target is to the camera, the less impact these factors have on the final measurement result. Therefore, through continuous practice, a distance threshold is set, and different distance measurement methods are used based on the relationship between the first target distance and the distance threshold. For example, 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 pinhole imaging principle. The pixel coordinates of the left and right boundaries of the rear frame can be obtained through the aforementioned first YOLO model, thereby obtaining the pixel width of the rear of the target vehicle in the image. On this basis, the width of the target can be determined according to the first target distance and the camera focal length, that is, the target measurement width. Figure 3 , the expression is as follows:

[0065]

[0066] in, is the target measurement width corresponding to the current frame image, L1 is the first target distance, is the focal length of the camera in the image u direction, and are the pixel coordinates of the left and right boundaries of the rear frame in the u direction of the image.

[0067] Step 104 : A Kalman filter is used 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 to obtain an updated target measurement width.

[0068] In a possible implementation, fusing and updating 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 an updated target measurement width includes:

[0069] A first Kalman gain is obtained according to a preset first width variance and a second width variance; the first width variance is the target measurement width variance corresponding to the current frame image; the second width variance is the updated target measurement width variance corresponding to the previous frame image; the second width variance is determined by fusion using a Kalman filter;

[0070] An updated target measurement width is obtained 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 of image is the width after fusion through Kalman filtering, that is, the updated target measurement width corresponding to the previous frame of image. After determining the target measurement width based on the information of each frame of image, the fusion is performed using the information of the previous frame of image, and the fused and updated width is used as the final target measurement width corresponding to the current frame. The expression for the updated target measurement width is as follows:

[0072]

[0073]

[0074]

[0075]

[0076] in, The target measurement width corresponding to the current frame image, The target measurement width after the current frame image is updated, The target measured width after updating the previous frame image, The width difference between the target measurement width after updating the previous frame image and the target measurement width corresponding to the current frame image, is the Kalman gain of width fusion, that is, the first Kalman gain, The updated target measurement width variance corresponding to the previous frame image, that is, the second width variance, is determined by fusion using Kalman filtering. is the target measurement width variance corresponding to the current frame image, i.e., the first width variance. In this embodiment, this is assigned a value based on experience in combination with the target measurement width corresponding to the current frame image. P is the updated target measurement width variance of the current frame image, i.e., the width fusion variance corresponding to the current frame image.

[0077] Step 105: When the number of target measurement width updates exceeds a preset number threshold and the first target distance corresponding to the subsequent frame image is greater than a preset distance threshold, a second target distance corresponding to the subsequent frame image is determined based on the target measurement width determined in the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined in the last update is the estimated target width.

[0078] Specifically, the number threshold can be set to 10 times. The number threshold is set to improve the accuracy of the estimated width, thereby improving the accuracy of subsequent distance measurements. This embodiment only provides a suggested value, and the specific value can be set by the implementer according to the situation.

[0079] In a possible implementation, determining a second target distance corresponding to a subsequent frame image based on the target measurement width, camera focal length, and pixel coordinates of the vehicle rear boundary determined by the last update includes:

[0080]

[0081] in, 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, with 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 frame in the u direction of the image.

[0082] Step 106 : Based on the Kalman filter, the first target distance and the second target distance corresponding to the subsequent frame image are fused to obtain the estimated distance of the target corresponding to the subsequent frame image.

[0083] In a possible implementation, fusing the first target distance and the second target distance corresponding to subsequent frame images based on Kalman filtering to obtain an estimated distance of the target corresponding to the subsequent frame images includes:

[0084] Determine 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 preset second target distance variance;

[0085] Obtaining a distance difference according to the first target distance and the second target distance corresponding to subsequent frame images;

[0086] An estimated distance of the target corresponding to the subsequent frame image is determined according to the second Kalman gain, the distance difference, and a second target distance corresponding to the subsequent frame image.

[0087] The estimated distance expression of the target in subsequent frame images is as follows:

[0088]

[0089]

[0090]

[0091] in, 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 second target distance variance corresponding to the subsequent frame image, that is, the target distance variance determined by the width, is the first target distance variance corresponding to the subsequent frame image, that is, the target distance variance determined by the traditional pinhole imaging model, and L is the fused distance, that is, the estimated distance of the target corresponding to the subsequent frame image.

[0092] Specifically, the target distance variance cannot generally be calculated directly, but is assigned through experience. In the embodiment of the present invention, the distance variance obtained by the traditional pinhole imaging model will be greater than the distance variance determined by the width. In this way, when fused through the Kalman filter, the result will be more biased towards the target distance obtained by the width.

[0093] In summary, in an embodiment of the present invention, width measurement is performed based on a 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 used for iteration, thereby improving the measurement accuracy of the width; the present invention calculates the longitudinal distance between vehicles based on the pixel width and the estimated width, deviating from the original traditional pinhole imaging model, so that the horizontal assumption is no longer necessary for calculating the distance, thereby improving the distance measurement accuracy when the vehicles are not in the same plane, and at the same time using the Kalman filter when updating the target distance, combining the calculation results of the traditional model and the calculation results based on the width measurement, correcting the calculation results of the traditional model, and improving the vehicle distance measurement accuracy during vehicle driving, especially the vehicle distance measurement accuracy when the vehicles are not in the same plane.

[0094] An embodiment of the present invention further provides a distance measurement device based on target width, the device comprising:

[0095] An image acquisition module is used to capture images in front of the vehicle in real time through a camera, identify targets in the image, and mark the rear of the target vehicle; the target is a vehicle;

[0096] A first data processing module is configured to determine a first target distance corresponding to each frame of the image based on the pixel coordinates of the target boundary in each frame of the continuous frame image, the camera focal length, the camera pitch angle, and the camera installation height using the pinhole imaging principle; 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 the first target distance as the estimated distance of the target corresponding to each frame of the image, and determine the target measurement width corresponding to each frame of the image based on the first target distance, the camera focal length, and the pixel width of the target vehicle rear end using the pinhole imaging principle;

[0098] A data updating module is used 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 an updated target measurement width;

[0099] a second data processing module configured to determine, when the number of target measurement width updates exceeds a preset number threshold and the first target distance corresponding to the subsequent frame image exceeds a preset distance threshold, a second target distance corresponding to the subsequent frame image based on the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined by the last update being the estimated target width;

[0100] The third data processing module is used to fuse the first target distance and the second target distance corresponding to the subsequent frame images based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images.

[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 aforementioned method embodiment, and will not be repeated here.

[0102] In another embodiment provided by the present invention, an electronic device is also provided, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, 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 target width proposed in an embodiment of the present invention.

[0103] The above mainly introduces the solution provided by the embodiment of the present invention from the perspective of the device. It can be understood that in order to realize the above functions, the device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the algorithm steps of each example described in the embodiments disclosed herein, the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0104] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention shall be covered by the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A distance measurement method based on target width, characterized in that: include: The camera collects the front image of the vehicle in real time, identifies the target in the image, and marks the rear of the target vehicle; The target is a vehicle; The target in the identified image includes: Using the first YOLO model to identify all objects in the image, and obtain the target box and target type of each object; The marking of the target vehicle rear end includes: Using the first YOLO model to identify the rear end of each target in the image and obtain a corresponding bounding box; the first YOLO model is a multi-output model; Using 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 continuous frame image, the camera focal length, the camera pitch angle, and the camera installation height; the first target distance is the measured distance of the target; When the first target distance is less than a preset distance threshold, the first target distance is determined to be the estimated distance of the target corresponding to each frame of the image, and the target measurement width corresponding to each frame of the image is determined by using the pinhole imaging principle according to the first target distance, the camera focal length, and the pixel width of the target vehicle rear end; The target measurement width corresponding to the current frame image and the target measurement width corresponding to the previous frame image are fused and updated through Kalman filtering to obtain an updated target measurement width; When the number of target measurement width updates exceeds a preset number threshold, and the first target distance corresponding to the subsequent frame image exceeds a preset distance threshold, the second target distance corresponding to the subsequent frame image is determined based on the target measurement width determined in the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined in the last update is the estimated width of the target; The first target distance and the second target distance corresponding to the subsequent frame images are fused based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images.

2. The distance measurement method based on target width according to claim 1, characterized in that: The step of fusing and updating 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 an updated target measurement width includes: A first Kalman gain is obtained according to a preset first width variance and a second width variance; the first width variance is the target measurement width variance corresponding to the current frame image; the second width variance is the updated target measurement width variance corresponding to the previous frame image; the second width variance is determined by fusion using a Kalman filter; An updated target measurement width is obtained 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.

3. The distance measurement method based on target width according to claim 1, characterized in that: Determining a second target distance corresponding to a subsequent frame image based on the target measurement width, the camera focal length, and the pixel coordinates of the vehicle rear boundary determined by the last update includes: Where L2 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, and f u is the focal length of the camera in the u direction of the image, with the upper left corner of the image as the origin, the horizontal right direction is the u direction, the vertical downward direction is the v direction, and p l and p r are the pixel coordinates of the left and right boundaries of the rear frame in the u direction of the image.

4. The distance measurement method based on target width according to claim 1, characterized in that: The method of fusing the first target distance and the second target distance corresponding to the subsequent frame images based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images includes: Determine 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 preset second target distance variance; Obtaining a distance difference according to the first target distance and the second target distance corresponding to subsequent frame images; An estimated distance of the target corresponding to the subsequent frame image is determined according to the second Kalman gain, the distance difference, and a second target distance corresponding to the subsequent frame image.

5. The distance measurement method based on target width according to claim 1, characterized in that: After the camera collects the image in front of the vehicle in real time, the method further includes: Perform distortion correction on the collected image in front of the vehicle.

6. The distance measurement method based on target width according to claim 1, characterized in that: After marking the rear end of the target vehicle, the method further includes: The ByteTrack algorithm is used to track targets in consecutive frame images to obtain the corresponding relationship between the target in the current frame image and the previous frame image.

7. A distance measurement device based on target width, characterized in that: The device comprises: An image acquisition module is used to capture images in front of the vehicle in real time through a camera, identify targets in the image, and mark the rear of the target vehicle; the target is a vehicle; A first data processing module is configured to determine a first target distance corresponding to each frame of the image based on the pixel coordinates of the target boundary in each frame of the continuous frame image, the camera focal length, the camera pitch angle, and the camera installation height using the pinhole imaging principle; the first target distance is the measured distance of the target; A judgment module is configured to, when the first target distance is less than a preset distance threshold, determine that the first target distance is an estimated distance of the target corresponding to each frame of the image, and determine the target measurement width corresponding to each frame of the image based on the first target distance, the camera focal length, and the pixel width of the target vehicle rear end using the pinhole imaging principle; the target in the identified image includes: Using the first YOLO model to identify all objects in the image, and obtain the target box and target type of each object; The marking of the target vehicle rear end includes: Using the first YOLO model to identify the rear end of each target in the image and obtain a corresponding bounding box; the first YOLO model is a multi-output model; A data updating module is used 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 an updated target measurement width; a second data processing module configured to determine, when the number of target measurement width updates exceeds a preset number threshold and the first target distance corresponding to the subsequent frame image exceeds a preset distance threshold, a second target distance corresponding to the subsequent frame image based on the target measurement width determined by the last update, the camera focal length, and the pixel coordinates of the vehicle rear boundary; the target measurement width determined by the last update being the estimated target width; The third data processing module is used to fuse the first target distance and the second target distance corresponding to the subsequent frame images based on Kalman filtering to obtain the estimated distance of the target corresponding to the subsequent frame images.

8. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, 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 target width according to any one of claims 1 to 6.

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