Ranging method and device, vehicle and readable storage medium

By identifying the vehicle category and calculating the equivalent pixel size, combined with the internal parameters of the camera, the problem of low accuracy in vehicle ranging is solved, and efficient and accurate distance measurement is achieved, which is suitable for low-configuration hardware on the vehicle end.

CN118837863APending Publication Date: 2024-10-25CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410849096.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-25

AI Technical Summary

Technical Problem

In vehicle ranging, the existing monocular camera ranging technology has various types of vehicles and different feature sizes, resulting in low measurement accuracy and complex calculations, making it difficult to meet the low-configuration calculation requirements of the vehicle end.

Method used

By identifying the vehicle category in the target image, determine the equivalent pixel length and width of the vehicle, combine the camera internal parameters and the universal dimensions related to the vehicle category, calculate the distance between the vehicle and the target, and use the weighted sum of multiple distances to eliminate the size Fluctuation effects, simplifying the calculation process.

Benefits of technology

It achieves efficient and accurate distance measurement in vehicle ranging, reduces computational complexity, and is suitable for low-configuration hardware environments on the vehicle side.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118837863A_ABST
    Figure CN118837863A_ABST
Patent Text Reader

Abstract

The invention provides a distance measurement method and device, a vehicle and a readable storage medium, and the method is applied to a first vehicle, and comprises the steps: recognizing the vehicle type of a second vehicle in a target image; determining the projection pixel length, the projection pixel width and the projection pixel height of the width, the length and the height of the second vehicle in the target image; the equivalent pixel length and the equivalent pixel width of the second vehicle in the target image are determined according to the projection pixel length, the projection pixel width and the general size of the second vehicle, and the general size is related to the vehicle category of the second vehicle; according to the equivalent pixel length and / or the equivalent pixel width and / or the projection pixel height, the general size and the camera internal reference of the first vehicle, the distance between the first vehicle and the second vehicle is determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of distance measurement, and in particular to a distance measurement method and device, a vehicle and a readable storage medium. Background Art

[0002] In a vehicle driving assistance system, the vehicle is required to accurately measure the distance between it and a target object, especially the distance between the vehicle and pedestrians and between vehicles.

[0003] With the development of deep learning technology, ranging solutions based on image recognition technology have become increasingly mature. Among them, the solution using a monocular camera for ranging has been widely used due to its simple system structure and low cost. However, in the existing monocular ranging technology solution, it is necessary to use prior information such as the characteristic size of the target object and the camera internal parameters to determine the distance to the target object. When applied to vehicle ranging, due to the variety of vehicle types, their characteristic sizes are not the same, which increases the uncertainty and leads to low measurement accuracy. Summary of the invention

[0004] The present application provides a distance measurement method and device, a vehicle and a readable storage medium. The technical solution adopted in the present application is as follows:

[0005] In a first aspect, a ranging method is provided, which is applied to a first vehicle, and the method includes: identifying a vehicle category of a second vehicle in a target image; determining the width, length and height of the second vehicle by projecting pixel length, projecting pixel width and projecting pixel height in the target image; determining an equivalent pixel length and an equivalent pixel width of the second vehicle in the target image according to the projected pixel length, the projected pixel width and a universal size of the second vehicle, wherein the universal size is related to the vehicle category of the second vehicle; determining a distance to the second vehicle according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size and a camera intrinsic parameter of the first vehicle.

[0006] According to the above technical means, fast ranging is achieved based on the projection size of the second vehicle in the target image and the general size corresponding to the vehicle category of the second vehicle and the camera intrinsic parameters. This technical solution ignores rare factors and the influence of perspective, has a small amount of calculation, and can meet the calculation requirements of lower configuration on the vehicle side.

[0007] Further, determining the distance between the first vehicle and the second vehicle includes: determining a first distance, a second distance and a third distance from the second vehicle according to the equivalent pixel length, the equivalent pixel width and the projection pixel height, respectively; taking a weighted sum of the first distance, the second distance and the third distance to determine the distance between the first vehicle and the second vehicle; wherein a first weight, a second weight and a third weight corresponding to the first distance, the second distance and the third distance are related to the vehicle category of the second vehicle.

[0008] According to the above technical means, after determining multiple distances using the projection sizes of the second vehicle in different dimensions, the multiple distances are weighted and summed according to the vehicle category of the second vehicle, thereby eliminating the influence of fluctuations between the actual size of the vehicle and the universal size on the ranging accuracy.

[0009] Further, determining the width, length and height of the second vehicle by projecting pixel length, pixel width and pixel height in the target image includes: using a first target detection model to determine a first detection frame and a second detection frame in the second image, wherein a boundary of the first detection frame coincides with a boundary of the rear end of the second vehicle, and a boundary of the second detection frame coincides with a boundary of the second vehicle; determining the projected pixel length, pixel width and pixel height according to sizes of the first detection frame and the second detection frame.

[0010] According to the above technical means, the target detection model deployed on the first vehicle is used to identify the second vehicle in the target image, and the projection pixel size of the second vehicle is determined based on the first detection frame and the second detection frame detected by the model, which has high efficiency and accuracy.

[0011] Furthermore, determining the projection pixel length, the projection pixel width and the projection pixel height according to the sizes of the first detection frame and the second detection frame includes: stretching the first detection frame into a third detection frame, wherein the upper and lower boundaries of the third detection frame coincide with the boundaries of the second detection frame; constructing a coordinate system based on the third detection frame and the second detection frame, wherein the coordinate system includes an x-axis and a y-axis that are in the same horizontal plane as the camera plane, and a z-axis that is vertically upward; determining that the projection length of the length of the second vehicle in the target image on the x-axis is the projection pixel length, the projection length of the width of the second vehicle in the target image on the y-axis is the projection pixel width, and the projection length of the second vehicle in the target image on the z-axis is the projection pixel height.

[0012] According to the above technical means, a coordinate system is constructed using the second detection frame and the stretched third detection frame, and the length, width and height of the second vehicle in the target image are projected on each coordinate axis. The projection pixel size can be determined by directly measuring the projection size, thereby achieving the purpose of simplifying the operation.

[0013] Furthermore, the method also includes: collecting multiple sample vehicle images of the same type of sample vehicle; determining a first predicted distance, a second predicted distance, and a third predicted distance corresponding to each sample vehicle image according to the projection dimensions of the sample vehicle in the length, width, and height directions in each sample vehicle image, and the general dimensions of the sample vehicle; determining optimal values ​​of the first weight, the second weight, and the third weight according to the first predicted distance, the second predicted distance, the third predicted distance corresponding to each sample vehicle image, and the actual distance of the sample vehicle; wherein the general dimensions of the sample vehicle are associated with the vehicle type of the sample vehicle.

[0014] According to the above technical means, the weights of the distance prediction values ​​are fitted according to the distance prediction values ​​and actual distance values ​​of multiple sample images of the same type of vehicles to obtain the optimal value of each weight, thereby eliminating the influence of the fluctuation between the actual size of some dimensions and the general size for distance prediction of vehicles of the same type on the prediction results.

[0015] Furthermore, a second target detection model is deployed on the first vehicle to identify the vehicle category of the second vehicle in the target image.

[0016] According to the above technical means, the target detection model deployed on the first vehicle for vehicle category detection is lightweight, requires less computing resources, and can achieve rapid identification of vehicle categories.

[0017] Further, the identifying the vehicle category of the second vehicle in the target image includes: using the first target detection model to identify the vehicle category of the second vehicle in the target image.

[0018] According to the above technical means, using the same target detection model to identify the vehicle category and the rear of the vehicle and the boundary of the vehicle body can simplify the model training process and save computing resources.

[0019] In a second aspect, a ranging device is provided, which is applied to a first vehicle, and the device includes: an identification unit, which is used to identify the vehicle category of a second vehicle in a target image; a first determination unit, which is used to determine the width, length and height of the second vehicle in the target image, namely, the projected pixel length, the projected pixel width and the projected pixel height; a second determination unit, which is used to determine the equivalent pixel length and the equivalent pixel width of the second vehicle in the target image according to the projected pixel length, the projected pixel width and the universal size of the second vehicle, wherein the universal size is related to the vehicle category of the second vehicle; and a third determination unit, which is used to determine the distance to the second vehicle according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size and the camera intrinsic parameters of the first vehicle.

[0020] In a third aspect, a vehicle is provided, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the method described in the first aspect.

[0021] According to a fourth aspect, a computer-readable storage medium is provided, wherein the storage medium is used to store a computer program, and when the computer program is executed, the method according to the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a schematic diagram of the principle of monocular ranging;

[0023] Figure 2 A schematic flow chart of a distance measurement method provided in an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of a target image in an embodiment of the present application;

[0025] Figure 4 for Figure 3 A schematic diagram of the direction angle of the second vehicle in FIG.

[0026] Figure 5 A schematic flow chart of a method for determining distance in a distance measurement method provided in an embodiment of the present application;

[0027] Figure 6 A schematic flow chart of a method for determining the size of each projection pixel in the distance measurement method provided in an embodiment of the present application;

[0028] Figure 7 is a schematic diagram of a first detection frame and a second detection frame in a target image;

[0029] Figure 8 A schematic flow chart of a method for determining a projection pixel size according to a first detection frame and a second detection frame;

[0030] Fig. 9 is a schematic diagram of a third detection frame in the target image;

[0031] Fig.10 A flowchart of the suitability of the method for determining the values ​​of each weight;

[0032] Fig.11 A schematic structural diagram of a distance measuring device provided in an embodiment of the present application;

[0033] Fig.12 A schematic structural diagram of a vehicle provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.

[0035] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.

[0036] In the vehicle driving assistance system, the vehicle needs to be able to use the information obtained by the sensor to perceive the surrounding environment. In addition to accurately detecting targets such as vehicles, pedestrians and obstacles, it is also necessary to accurately measure the distance between targets, especially the distance between vehicles and pedestrians and between vehicles. At present, it is relatively easy to measure the distance of pedestrians, but it is relatively difficult to measure the distance of vehicles due to their size and orientation.

[0037] At present, the commonly used distance measurement methods are mainly implemented by millimeter wave radar, laser radar, binocular camera and monocular camera, etc. Among them, the radar speed measurement (including millimeter wave radar and laser radar) is based on the principle of electromagnetic wave reflection. The distance to the front vehicle is determined according to the time difference between the electromagnetic wave emitted by the radar and the echo reflected by the obstacle or the front vehicle. This method has high accuracy, but due to the high cost of radar hardware, the cost of the whole vehicle increases.

[0038] With the development of deep learning technology, ranging solutions based on image recognition technology have become increasingly mature. For example, in the binocular camera ranging solution, two cameras set at different positions are used to collect images in front, and the depth information is obtained by using the difference in viewing angles of the images collected by the two cameras to determine the distance to the vehicle in front or the obstacle. The basic principle of binocular ranging is similar to that of the human eye. The farther away from the object, the smaller the parallax. On the contrary, the closer to the object, the greater the parallax. Therefore, the distance can be determined based on the parallax of the two images. This method is less expensive than radar speed measurement. However, in practical applications, the two cameras need to be accurately calibrated to accurately determine the geometric relationship between the two cameras. At the same time, the binocular vision system needs to process two images at different angles at the same time and perform complex calculations and matching, which leads to a high demand for computing resources. When applied to the vehicle side, it may be slow to process due to hardware performance limitations.

[0039] Another solution in the related art is to use a monocular camera for ranging. Monocular ranging is to achieve target recognition through image matching, and then estimate the target distance by the size of the target in the image. It has low cost, simple system structure, and low computational requirements.

[0040] Figure 1 This is a schematic diagram of the monocular ranging principle. Figure 1 The principle of camera imaging is simplified to pinhole imaging. The target object 11 is on the focal plane 13 of the camera through the pinhole 12. The distance between the focal plane 13 of the camera and the pinhole 12 is the focal length f. The length of the target object is w, and the pixel length of its projection on the focal plane 13 of the camera is p. Based on the above parameters, the distance between the target object 11 and the focal plane 13 of the camera can be determined according to the following formula:

[0041]

[0042] According to the above method, in order to determine the distance of the target object, it is necessary to know the prior information such as the characteristic size of the target object. When applied to vehicle ranging, due to the variety of vehicle types, their characteristic sizes are not the same, which increases the uncertainty of ranging.

[0043] Therefore, there is an urgent need to provide a fast ranging solution that can ensure measurement accuracy and is low-cost.

[0044] In view of the above problems, an embodiment of the present application provides a ranging method and device, a vehicle and a readable storage medium. The technical solution of the present application is described in detail below.

[0045] Figure 2 is a schematic flow chart of a ranging method provided in an embodiment of the present application, Figure 2 The method includes steps S210-S240.

[0046] In step S210 , the vehicle category of the second vehicle in the target image is identified.

[0047] The target image is an image in front of the first vehicle, which at least includes a complete outer contour of a second vehicle in front of the first vehicle.

[0048] The target image can be acquired in real time by an image acquisition unit such as a camera set in the first vehicle. The camera can be set on the front bumper of the first vehicle, or the camera can also be set on the roof of the first vehicle. The embodiment of the present application does not make specific limitations on this.

[0049] The vehicle category in the embodiment of the present application can also be understood as the model of the second vehicle. The second vehicle can be, for example, any of a variety of types such as a sedan, a sport utility vehicle (SUV), a multi-purpose vehicle (MPV), a bus, and a truck.

[0050] The identification of the vehicle category of the second vehicle can be performed by relying on the target detection model deployed on the first vehicle. The target detection model is lightweight and fast, usually requires small computing resources, and can perform fast identification.

[0051] In step S220, the width, length and height of the second vehicle are determined in the target image as projected pixel length, projected pixel width and projected pixel height.

[0052] It is understandable that in the process of camera imaging, objects in three-dimensional space are projected onto the camera's photosensitive element to form a two-dimensional image. By measuring the image of the second vehicle in the target image, the projected pixel size of the length, width and height of the second vehicle in the target image is obtained. The projected length is related to the intrinsic parameters of the camera that captures the target image (resolution of the photosensitive element, size of the photosensitive element and focal length of the camera) and the actual size of the second vehicle. By determining the above multiple projected pixel sizes, combined with the camera's intrinsic parameters and parameters such as the general size of the vehicle, the distance between the camera lens and the second vehicle can be determined.

[0053] Figure 3 An example of a target image is shown. Figure 3 As shown, the projected pixel length, projected pixel width and projected pixel height of the second vehicle are x1, y1 and z1 shown in the figure respectively.

[0054] In step S230, the equivalent pixel length and equivalent pixel width of the second vehicle in the target image are determined according to the projected pixel length, the projected pixel width, and the general size corresponding to the vehicle category of the second vehicle.

[0055] It is understandable that, since the position between the first vehicle and the second vehicle is in a state of real-time change, the second vehicle may not be directly in front of the first vehicle. Figure 3 The horizontal lines of the rear and side of the second vehicle in the target image shown in the figure are not parallel to the horizontal line of the camera, that is, the second vehicle has a direction angle. At this time, if the distance is directly measured using the projected pixel length or the projected pixel width, it will inevitably cause errors. Therefore, it is necessary to perform an equivalent calculation on the projected pixel size of the second vehicle. In the vehicle height direction, the above problem does not exist. This is because the cameras of the second vehicle and the first vehicle are basically on the same horizontal plane. In this process, the upper and lower surfaces of the front vehicle are not visible, and its projected pixel height on the camera focal plane is equal to its actual pixel height.

[0056] The equivalent pixel size of the second vehicle is related to the measured projected pixel size and the general size of the vehicle.

[0057] The general dimensions of the above-mentioned vehicles are related to the vehicle type of the second vehicle, and the general dimensions include the length, width, height and aspect ratio of the vehicle of this type.

[0058] Taking the aspect ratio as an example, it is understandable that for vehicles of different categories, their aspect ratios are usually quite different, while for vehicles of the same type, their aspect ratios are usually close. For example, the aspect ratio of trucks is usually large, while that of SUVs is usually small; for sedans, although compact sedans and large sedans have large size differences, their aspect ratios are usually close. For example, the length and width of a compact sedan are 4650mm and 1800mm respectively, and the length and width of a medium and large sedan are 5200mm and 2120mm respectively, and their aspect ratios are all around 2.5.

[0059] Therefore, the azimuth angle of the second vehicle can be determined according to the aspect ratio of the vehicle, the projected pixel length of the vehicle, and the projected pixel width; and then the equivalent pixel length and the equivalent pixel width are determined based on the azimuth angle of the second vehicle.

[0060] It is also necessary to explain that in the technical solution of the present application, the universal dimensions are only related to the vehicle type of the second vehicle, that is, for vehicles of the same type, the universal dimensions are the same.

[0061] The above equivalent pixel length and equivalent pixel width can be understood as follows: according to the azimuth angle of the second vehicle, the photosensitive element of the camera is rotated to be parallel to the rear or side of the second vehicle. At this time, the pixel size of the projection of the length or width of the second vehicle on the photosensitive element is the above equivalent pixel length or equivalent pixel width. In this case, the distance from any point on the horizontal line of the side of the second vehicle to the corresponding point in the projection is the same.

[0062] Combine the following Figure 3 and Figure 4 , the method of determining equivalent pixel length and equivalent pixel width is described in detail:

[0063] The length and width of the second vehicle are recorded as l and w respectively, the aspect ratio of the vehicle is A, the projected pixel length and the projected pixel width are x1 and y1 respectively, and the azimuth angle of the second vehicle is α, then the following geometric relationship exists:

[0064] l=Aw (2)

[0065] x1=l cosα (3)

[0066] y1=w sinα (4)

[0067] Among them, the aspect ratio A is a known quantity, which is related to the vehicle type of the second vehicle. x1 and y1 are measured from the target image, so the equivalent pixel length and equivalent pixel width of the vehicle can be calculated respectively:

[0068]

[0069] In step S240, the distance to the second vehicle is determined according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size, and the camera intrinsic parameters of the first vehicle.

[0070] The distance between the first vehicle and the second vehicle can be determined according to the above formula (1). For example, the distance can be determined according to any one of the parameters of equivalent pixel length, equivalent pixel width or projected pixel, combined with the general size corresponding to the vehicle type of the second vehicle and the intrinsic parameters of the camera.

[0071] Alternatively, any two projection sizes among the above-mentioned multiple projection sizes may be used in combination with the general size of the vehicle and the camera intrinsic parameters to determine two distances from two dimensions respectively, and then determine the distance between the first vehicle and the second vehicle based on the two distances.

[0072] Alternatively, the above-mentioned multiple projection sizes may be used to determine three distances from the length, width and height of the vehicle respectively, and the distance between the first vehicle and the second vehicle may be determined based on the three distances.

[0073] Determining the distance between the first vehicle and the second vehicle using the multiple distances determined by the above-mentioned multiple dimensions may, for example, be taking the average of the multiple distance values, taking the median of the multiple distances, or performing a weighted summation thereof, and this embodiment of the present application does not specifically limit this.

[0074] According to the above-mentioned ranging method provided in the embodiment of the present application, fast ranging is achieved based on the projection size of the second vehicle in the target image and the general size (or general real size) corresponding to the vehicle category of the second vehicle and the camera intrinsic parameters. This technical solution ignores rare factors and the influence of perspective, has a small amount of calculation, and can meet the calculation requirements of lower configuration on the vehicle side.

[0075] In some embodiments, Figure 5 As shown, the above step S240 determines the distance between the first vehicle and the second vehicle according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size and the camera intrinsic parameters of the first vehicle, and further includes step S241 and step S242.

[0076] In step S241, a first distance d from the second vehicle is determined according to the equivalent pixel length, the equivalent pixel width and the projected pixel height. l , the second distance d w and the third distance d h .

[0077] The method for determining the distance based on the projection pixel size has been described in detail above and will not be repeated here. It should be noted that the actual size of the vehicle used in determining the distance is the general size corresponding to the vehicle type of the second vehicle, that is, the first distance, the second distance and the third distance are determined based on the general length size, the general width size and the general height size of the vehicle of this type.

[0078] In step S242, for the first distance d l , the second distance d w and the third distance d h Perform a weighted sum to determine the distance between the first vehicle and the second vehicle, namely:

[0079] d=a l d l +a w d w +a h d h (7)

[0080] Among them, a l 、a w and a h The first distance d l , the second distance d w and the third distance d hThe corresponding first weight, second weight and third weight.

[0081] It can be understood that the first distance d l , the second distance d w and the third distance d h can all represent the distance between the first vehicle and the second vehicle. The three distances are theoretically equal, but they are affected by various factors. For example, the actual length-to-width ratio of the vehicle is different from the length-to-width ratio in the preset universal size; or the actual height of the vehicle is different from the universal height size, which will cause the first distance d l , the second distance d w and the third distance d h are not equal, so they need to be weighted summed.

[0082] The values ​​of the above-mentioned multiple weights are related to the vehicle type of the second vehicle. For example, for trucks, especially trailers, the heights of the trucks usually vary greatly depending on the types of goods loaded thereon. If the distance is determined according to the general height size of the trucks, it may result in a large error. Therefore, the third weight a may be used. h In the width direction, due to the limitation of factors such as lane width, the width dimension of this type of vehicle usually fluctuates slightly, and the error of the distance determined based on the universal width dimension is relatively small, so the second weight a can be set to w Set to Larger.

[0083] It should be understood that for different types of vehicle models, the degree of size fluctuation in different dimensions is usually different. Therefore, in practical applications, it is necessary to select a combination of weights that matches the specific type of the second vehicle.

[0084] According to the above technical means, after determining the distance according to the projection size of the second vehicle in different dimensions, a plurality of distances are weightedly summed according to the vehicle category of the second vehicle, thereby eliminating the influence of fluctuations between the real size and the universal size of the vehicle in different dimensions on the ranging accuracy.

[0085] In some embodiments, Figure 6 As shown, the aforementioned step S220, determining the width, length and height of the second vehicle in the target image as projected pixel length, projected pixel width and projected pixel height, further includes step S221 and step S222.

[0086] In step S221, a first detection box and a second detection box are determined in the second image using a first object detection model.

[0087] Figure 7 The first detection frame and the second detection frame in the target image are shown. Figure 7As shown, the boundary of the first detection frame 71 coincides with the boundary of the rear end of the second vehicle, and the boundary of the second detection frame 72 coincides with the boundary of the second vehicle.

[0088] The first target detection model is deployed in the first vehicle, and can recognize the front image collected by the first vehicle in real time, detect the vehicle in the image, and mark the rear and body of the vehicle. The first target detection model can be, for example, a YOLO model, an RCNN model, an SSD model, etc.

[0089] It is understandable that the first target detection model is a pre-trained model. The training of the target detection model includes data collection, data annotation, model training and model evaluation. Data collection is the basis of model training, and images of multiple vehicles can be collected to form a training set and a validation set. The training set is used to train the parameters of the model, and the validation set is used to evaluate the performance of the model. After the training set is determined, the images in the training set are pre-processed, including image size adjustment, data enhancement, etc., and the body and rear of the vehicle are marked in the images of the training set. Next, the training set is input into the model for training, and the parameters of the model are updated by calculating the loss function, thereby completing the training of the model and obtaining the trained first target detection model.

[0090] In step S222, the projection pixel length, the projection pixel width and the projection pixel height are determined according to the sizes of the first detection frame and the second detection frame.

[0091] As mentioned above, the first detection frame 71 and the second detection frame 72 overlap with the rear boundary and the body boundary of the second vehicle, respectively. Therefore, the projection pixel size can be determined according to the sizes of the above two detection frames. For example, the projection pixel width and the projection pixel height can be determined according to the width and height of the first detection frame, respectively, and the projection pixel length can be determined according to the difference between the widths of the second detection frame and the first detection frame.

[0092] According to the above technical means, the target detection model deployed on the first vehicle is used to identify the second vehicle in the target image, and the projection pixel size of the second vehicle is determined based on the first detection frame and the second detection frame detected by the model, which has high efficiency and accuracy.

[0093] In some embodiments, Figure 8 As shown, the aforementioned step S222, determining the projection pixel length, the projection pixel width and the projection pixel height according to the sizes of the first detection frame and the second detection frame, further includes steps S2221-S2223.

[0094] In step S2221, the first detection frame is stretched into a third detection frame so that the upper and lower connections of the third detection frame coincide with the boundary of the second detection frame. Fig. 9shows the third detection box in the target image, combined with Figure 7 and Fig. 9 Before the first detection frame is stretched, the left boundary of the first detection frame 71 overlaps with the left boundary of the second detection frame 72, and there is a gap between the upper and lower boundaries. This is because the top of the vehicle usually has an arc, and the camera will capture a part of the top of the vehicle near the rear when collecting the target image. This part does not belong to the rear of the vehicle, so it will not be included in the first detection frame 71. After the first detection frame 71 is stretched to the third detection frame 73 shown in the figure, at this time, the boundaries of the second detection frame 72 on three sides completely overlap with the third detection frame 73.

[0095] In step S2222, a coordinate system is constructed based on the third detection frame and the second detection frame. The coordinate system includes an x-axis and a y-axis that are in the same horizontal plane as the camera plane, and a z-axis that is vertically upward.

[0096] See again Fig. 9 , take the intersection of the right boundary of the third detection frame and the lower boundary of the second detection frame as the coordinate origin, extend to the left and right sides along the direction parallel to the camera plane to form the x-axis and y-axis; extend upward along the direction perpendicular to the x-axis or y-axis to form the z-axis.

[0097] In step S2223, the length of the projection of the length of the second vehicle in the target image on the x-axis is determined as the projection pixel length, the length of the projection of the width of the second vehicle on the y-axis is determined as the projection pixel width, and the length of the projection of the second vehicle on the z-axis is determined as the projection pixel height.

[0098] According to the above technical means, a coordinate system is constructed using the second detection frame and the stretched third detection frame, and the length, width and height of the second vehicle in the target image are projected on each coordinate axis. The projection pixel size can be determined by directly measuring the projection size, thereby achieving the purpose of simplifying the operation.

[0099] According to the above description, when determining the distance to the second vehicle, the first distance d l , the second distance d w and the third distance d h A weighted sum is performed, and the weight corresponding to each distance is related to the vehicle type of the second vehicle. Therefore, the method provided in the embodiment of the present application also includes determining each weight.

[0100] Fig.10 A schematic flowchart of a method for determining each weight value provided in an embodiment of the present application, Fig.10 The method includes steps S101-S103.

[0101] In step S101, a plurality of sample vehicle images of the same type of sample vehicles are collected.

[0102] In step S102, the first predicted distance d1, the second predicted distance d2 and the third predicted distance d3 corresponding to each sample vehicle image are determined according to the projection dimensions of the sample vehicle in each sample vehicle image in the length, width and height directions and the general dimensions of the sample vehicle.

[0103] The method for determining the projection sizes in various directions of multiple sample vehicle images, and determining the first predicted distance d1, the second predicted distance d2 and the third predicted distance d3 according to the projection sizes is the same as the method described in steps S220-S240 in the previous text, and will not be repeated here.

[0104] In step S103, the optimal values ​​of the first weight, the second weight and the third weight are determined according to the first predicted distance d1, the second predicted distance d2, the third predicted distance d3 corresponding to each sample vehicle image and the actual distance of the sample vehicle.

[0105] The method for determining the optimal values ​​of the first weight, the second weight and the third weight may be, for example, to perform data fitting on the prediction results of the plurality of sample vehicle images and the actual distance values ​​based on the least squares method to obtain the optimal value of each weight.

[0106] For different types of vehicles, the above steps S101-S103 are performed respectively to obtain multiple combinations of the best values ​​of the above multiple weights. In practical applications, according to the vehicle category of the second vehicle in the identified target image, a combination of weights corresponding to it can be selected and brought into the above formula (7) to calculate the distance of the vehicle of this type.

[0107] According to the above technical means, the weights of the distance prediction values ​​are fitted according to the distance prediction values ​​and actual distance values ​​of multiple sample images of the same type of vehicles to obtain the optimal value of each weight, thereby eliminating the influence of the fluctuation between the actual size of some dimensions and the general size for distance prediction of vehicles of the same type on the prediction results.

[0108] In some embodiments, a second target detection model is deployed on the first vehicle, and the second detection model is used to identify the vehicle category of the second vehicle in the target image.

[0109] The second target detection model is a pre-trained model. The training of the second target detection model includes data collection, data annotation, model training, and model evaluation. Data collection is the basis of model training. Images of multiple vehicles can be collected to form a training set and a validation set. The training set is used to train the parameters of the model, and the validation set is used to evaluate the performance of the model.

[0110] After the training set is determined, the images in the training set are preprocessed, including image size adjustment, data enhancement, etc., and the category of the vehicle in each image in the training set is marked. Next, the training set is input into the model for training, and the parameters of the model are updated by calculating the loss function, thereby completing the model training and obtaining the trained second target detection model.

[0111] The second target detection model can be a lightweight model that can be deployed on the vehicle side, such as a YOLO model, an RCNN model, an SSD model, etc. The second target detection model is specifically used to detect the vehicle category in the image. The target detection model is lightweight and fast, and the computing resources required are usually small, which can perform fast recognition.

[0112] In some embodiments, identifying the vehicle category of the second vehicle in the target image may also be performed using the first target detection model described above, that is, the first target detection model detects the vehicle category while identifying the rear of the vehicle and the boundary of the vehicle body.

[0113] According to the above technical means, using the same target detection model to identify the vehicle category and the rear of the vehicle and the boundary of the vehicle body can simplify the model training process and save computing resources.

[0114] Combined with the previous article Figure 1-Figure 10 , the method embodiment of the present application is described in detail, and the following is combined with Figure 11-12 , the device embodiment of the present application is described in detail. It should be noted that the description of the device embodiment corresponds to the method embodiment in the foregoing text, so the part not described in detail can refer to the method embodiment in the foregoing text.

[0115] Fig.11 is a schematic structural diagram of a distance measuring device provided in an embodiment of the present application, wherein the speed measuring device is applied to a first vehicle, Fig.11 The distance measuring device 1100 in the embodiment includes:

[0116] The identification unit 1110 is used to identify the vehicle category of the second vehicle in the target image.

[0117] The first determining unit 1120 is used to determine the projected pixel length, projected pixel width and projected pixel height of the width, length and height of the second vehicle in the target image.

[0118] The second determining unit 1130 is used to determine the equivalent pixel length and equivalent pixel width of the second vehicle in the target image according to the projected pixel length, the projected pixel width and the general size of the second vehicle, where the general size is related to the vehicle category of the second vehicle.

[0119] The third determination unit 1140 is used to determine the distance between the first vehicle and the second vehicle according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size, and the camera intrinsic parameters of the first vehicle.

[0120] In some embodiments, the third determination unit 1140 is also used to: determine the first distance, the second distance and the third distance to the second vehicle based on the equivalent pixel length, the equivalent pixel width and the projected pixel height, respectively; take the weighted sum of the first distance, the second distance and the third distance to determine the distance between the first vehicle and the second vehicle; wherein the first weight, the second weight and the third weight corresponding to the first distance, the second distance and the third distance are related to the vehicle category of the second vehicle.

[0121] In some embodiments, the first determination unit 1120 is also used to: determine a first detection box and a second detection box in the second image using a first target detection model, wherein a boundary of the first detection box coincides with a boundary of the rear of the second vehicle, and a boundary of the second detection box coincides with a boundary of the second vehicle; and determine a projection pixel length, a projection pixel width, and a projection pixel height based on the sizes of the first detection box and the second detection box.

[0122] In some embodiments, the first determination unit 1120 is also used to: stretch the first detection frame into a third detection frame, and the upper and lower boundaries of the third detection frame coincide with the boundaries of the second detection frame; construct a coordinate system based on the third detection frame and the second detection frame, and the coordinate system includes an x-axis and a y-axis that are in the same horizontal plane as the camera plane, and a z-axis that is vertically upward; determine that the projection length of the length of the second vehicle in the target image on the x-axis is the projection pixel length, the projection length of the width of the second vehicle in the target image on the y-axis is the projection pixel width, and the projection length of the second vehicle in the target image on the z-axis is the projection pixel height.

[0123] In some embodiments, the speed measuring device 1100 also includes: an acquisition unit, used to acquire multiple sample vehicle images of the same type of sample vehicles; a fourth determination unit, used to determine the first predicted distance, the second predicted distance and the third predicted distance corresponding to each sample vehicle image according to the projection dimensions of the sample vehicle in each sample vehicle image in the length, width and height directions, and the general dimensions of the sample vehicle; a fifth determination unit, used to determine the optimal values ​​of the first weight, the second weight and the third weight according to the first predicted distance, the second predicted distance, the third predicted distance corresponding to each sample vehicle image and the actual distance of the sample vehicle; wherein the general dimensions of the sample vehicle are associated with the vehicle type of the sample vehicle.

[0124] In some embodiments, a second target detection model is deployed on the first vehicle to identify the vehicle category of the second vehicle in the target image.

[0125] In some embodiments, identifying the vehicle category of the second vehicle in the target image includes: identifying the vehicle category of the second vehicle in the target image using a first target detection model.

[0126] Fig.12 It is a schematic structural diagram of a vehicle provided in an embodiment of the present application, wherein the vehicle 1200 includes a memory 1210 and a processor 1220, wherein the memory 1210 is used to store a computer program, and the processor 1220 is used to execute the computer program to execute the method described in any of the foregoing embodiments.

[0127] In the embodiment of the present application, the processor 1220 may be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor function may also be other, and the embodiment of the present application does not specifically limit it.

[0128] An embodiment of the present application provides a computer-readable storage medium storing a computer program for implementing the method described in any of the foregoing embodiments when executed by a processor.

[0129] Each functional module in the embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional modules.

[0130] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for the vehicle or processor to execute all or part of the steps of the method of this embodiment. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0131] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0132] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0133] Those skilled in the art will appreciate that all or part of the steps of the above method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a computer-readable storage medium, which, when executed, executes the steps of the above method embodiments; and the aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROM), magnetic disks or optical disks.

[0134] The methods disclosed in several method embodiments provided in the embodiments of the present application can be arbitrarily combined without conflict to obtain new method embodiments.

[0135] The features disclosed in several product embodiments provided in the embodiments of the present application can be arbitrarily combined without conflict to obtain new product embodiments.

[0136] The features disclosed in several method or device embodiments provided in the embodiments of the present application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0137] The above embodiments are only preferred embodiments for fully illustrating the present application, and the protection scope of the present application is not limited thereto. Any equivalent substitution or change made by a person skilled in the art based on the present application is within the protection scope of the present application.

Claims

1. A distance measurement method, applied to a first vehicle, characterized in that: The method comprises: identifying a vehicle category of a second vehicle in the target image; Determine the width, length and height of the second vehicle as projected pixel length, projected pixel width and projected pixel height in the target image; determining an equivalent pixel length and an equivalent pixel width of the second vehicle in the target image according to the projected pixel length, the projected pixel width, and a general size of the second vehicle, wherein the general size is related to a vehicle category of the second vehicle; The distance between the first vehicle and the second vehicle is determined according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size, and the camera intrinsic parameters of the first vehicle.

2. The method according to claim 1, characterized in that The determining the distance between the vehicle and the second vehicle comprises: determining a first distance, a second distance, and a third distance to the second vehicle according to the equivalent pixel length, the equivalent pixel width, and the projected pixel height, respectively; Taking a weighted sum of the first distance, the second distance and the third distance to determine a distance between the first vehicle and the second vehicle; The first weight, the second weight and the third weight corresponding to the first distance, the second distance and the third distance are related to the vehicle category of the second vehicle.

3. The method according to claim 1, characterized in that Determining the width, length and height of the second vehicle as projected pixel length, projected pixel width and projected pixel height in the target image includes: Determine a first detection frame and a second detection frame in the second image using the first object detection model, wherein a boundary of the first detection frame coincides with a boundary of the rear end of the second vehicle, and a boundary of the second detection frame coincides with a boundary of the second vehicle; The projection pixel length, the projection pixel width, and the projection pixel height are determined according to the sizes of the first detection frame and the second detection frame.

4. The method according to claim 3, characterized in that The determining the projection pixel length, the projection pixel width, and the projection pixel height according to the sizes of the first detection frame and the second detection frame includes: stretching the first detection frame into a third detection frame, wherein the upper and lower boundaries of the third detection frame coincide with the boundaries of the second detection frame; Constructing a coordinate system based on the third detection frame and the second detection frame, the coordinate system including an x-axis and a y-axis in the same horizontal plane as the camera plane, and a z-axis pointing vertically upward; Determine that the projection length of the length of the second vehicle in the target image on the x-axis is the projection pixel length, the projection length of the width of the second vehicle in the target image on the y-axis is the projection pixel width, and the projection length of the second vehicle in the target image on the z-axis is the projection pixel height.

5. The method according to claim 2, characterized in that: The method further comprises: Collect multiple sample vehicle images of the same type of sample vehicle; Determine a first predicted distance, a second predicted distance, and a third predicted distance corresponding to each of the sample vehicle images according to the projection dimensions of the sample vehicle in the length, width, and height directions in each of the sample vehicle images, and the general dimensions of the sample vehicle; Determine optimal values ​​of the first weight, the second weight, and the third weight according to the first predicted distance, the second predicted distance, the third predicted distance corresponding to each of the sample vehicle images, and the actual distance of the sample vehicle; The general dimensions of the sample vehicle are associated with the vehicle type of the sample vehicle.

6. The method according to claim 1, characterized in that A second target detection model is deployed on the first vehicle and is used to identify the vehicle category of the second vehicle in the target image.

7. The method according to claim 3, characterized in that The identifying the vehicle category of the second vehicle in the target image includes: using the first target detection model to identify the vehicle category of the second vehicle in the target image.

8. A distance measuring device, applied to a first vehicle, characterized in that: The device comprises: an identification unit, configured to identify a vehicle category of a second vehicle in the target image; A first determining unit, used to determine the width, length and height of the second vehicle as projected pixel length, projected pixel width and projected pixel height in the target image; a second determining unit, configured to determine an equivalent pixel length and an equivalent pixel width of the second vehicle in the target image according to the projected pixel length, the projected pixel width, and a general size of the second vehicle, wherein the general size is related to a vehicle category of the second vehicle; The third determination unit is used to determine the distance between the first vehicle and the second vehicle according to the equivalent pixel length and / or the equivalent pixel width and / or the projected pixel height, the universal size and the camera intrinsic parameters of the first vehicle.

9. A vehicle, characterized in that: The device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium is used to store a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Vehicle distance measurement method and device, vehicle, medium and program

    CN120008549A

  • Ranging method and apparatus, and device, vehicle, storage medium and program product

    WO2026157115A1