Method and system for measuring vehicle distance in lateral lane based on monocular camera

By establishing an association between the image and the vehicle coordinate system through a monocular camera and combining it with target detection and recognition algorithms, the lateral vehicle distance is calculated, solving the problem of large errors in measuring the distance between vehicles in the lateral lane, improving measurement accuracy and stability, and enhancing the safety of autonomous driving and assisted driving.

CN117781911BActive Publication Date: 2025-09-26TIANJIN QINGZHI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311743805.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2025-09-26
Estimated Expiration
2043-12-18

AI Technical Summary

Technical Problem

In the existing technology, the distance measurement error of the side lane is large, especially when the vehicle is bumpy and going up and downhill, the distance measurement error of the touchdown point is large, and the detection accuracy and stability of the rear width distance in the side lane are low.

Method used

A monocular camera is used to acquire road images, and the image coordinate system is associated with the vehicle coordinate system. Target detection and image recognition algorithms are used to obtain the vehicle's outer bounding box and type. Combined with the lateral distance calculation formula, the longitudinal coordinates of the vehicle model frame are calculated to measure the vehicle distance.

Benefits of technology

Improved accuracy and stability of vehicle-to-vehicle distance measurement, especially in side lane situations, enhances the safety of autonomous and assisted driving systems while reducing hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117781911B_ABST
    Figure CN117781911B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for lateral lane distance measurement based on a monocular camera. The method comprises: acquiring image information of the road ahead using a monocular camera, obtaining an outer bounding box of a target vehicle from the image information using a target detection algorithm; obtaining the lateral coordinate y of the right side of the target vehicle in the vehicle body coordinate system based on the coordinates of the outer bounding box in the image coordinate system using a conversion relationship from the image coordinate system to the vehicle body coordinate system; obtaining the type of the target vehicle from the image information using an image recognition algorithm; and calculating the longitudinal coordinate x of the rear end of the vehicle model frame using a lateral distance calculation formula, where the longitudinal coordinate x represents the distance from the target vehicle to the host vehicle. This invention can reduce the detection difficulty of the target detection module in assisted driving and achieve better distance measurement stability than existing solutions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent vehicles, and in particular to a method and system for measuring the distance between vehicles in a lateral lane based on a monocular camera. Background Art

[0002] With the development of autonomous driving technology, assisted driving has gradually become a standard feature of vehicles. In assisted driving vehicle driving scenarios, obstacle recognition and detection are essential. Vehicle collision warning requires stable visual measurement of the relative distance between the vehicle and the target.

[0003] To reduce costs, existing assisted driving solutions often use a single camera. However, current solutions primarily fall into two categories: touchdown ranging and rear-end width ranging. Touchdown ranging is a monocular ranging method that uses the contact point between the target and the road surface for distance measurement. However, the camera's pitch angle can cause errors, requiring more complex algorithms to estimate and compensate for this angle. Rear-end width ranging is a monocular ranging method that uses the relationship between the vehicle's rear width and the road surface for distance measurement. However, since rear-end width varies among vehicle models, it can be difficult to determine rear-end width during lane detection. Therefore, rear-end width ranging is primarily used to measure the distance to the vehicle directly ahead.

[0004] It can be seen from this that the touchdown distance measurement has a large measurement error due to vehicle bumps and ups and downslopes, while the rear width distance measurement has low rear frame detection accuracy and stability when the vehicle is in the side lane because the vehicle body is not a strict cubic configuration. Summary of the Invention

[0005] The embodiments of the present invention provide a method and system for measuring the distance between vehicles in a lateral lane based on a monocular camera, so as to solve the technical problem of large error in measuring the distance between vehicles in a lateral lane existing in the prior art.

[0006] According to an embodiment of the present invention, a method for calculating the lateral lane vehicle distance based on a monocular camera is provided, characterized in that the method includes: S10: obtaining image information of the front road through a monocular camera; S20: using a target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and recording the outer bounding box in the image coordinate system. Taking the projection point of the monocular camera perpendicular to the ground as the origin, the vehicle's horizontal front direction as the X-axis direction, and the vehicle's horizontal right direction as the Y-axis direction, a vehicle body coordinate system is established, and the association between the image coordinate system and the vehicle body coordinate system is established; S30: based on the coordinates of the outer bounding box in the image coordinate system, using the conversion relationship from the image coordinate system to the vehicle body coordinate system to obtain the lateral coordinate y of the right side of the target vehicle in the vehicle body coordinate system; S40: using an image recognition algorithm to obtain the type of the target vehicle in the image information, and constructing a vehicle model box based on the lateral coordinate y in the vehicle body coordinate system. The width of the vehicle model box is W, and the length of the vehicle model box is H; S50: using the lateral vehicle distance calculation formula to calculate the longitudinal coordinate x of the tail of the vehicle model box, and the longitudinal coordinate x is the vehicle distance from the target vehicle to the vehicle itself. The lateral vehicle distance calculation formula is:

[0007]

[0008] wherein, is the camera focal length, is the pixel width of the target vehicle in the image information.

[0009] Further, in S40, constructing a vehicle model box based on the lateral coordinate y in the vehicle body coordinate system according to the type of the target vehicle includes: finding out the model box information corresponding to the type of the target vehicle in the pre-constructed vehicle model library through a look-up table method. The model box information includes width information and length information, and constructing a vehicle model box based on the width information and length information.

[0010] Further, in S30, the coordinates of the outer bounding box in the image coordinate system are based on: the lower right corner coordinates of the outer bounding box.

[0011] Further, before using the lateral vehicle distance calculation formula to calculate the longitudinal coordinate x of the tail of the vehicle model box in S50, it further includes judging whether y is less than W; if y > W, then using the lateral vehicle distance calculation formula to calculate the longitudinal coordinate x of the tail of the vehicle model box; if y < W, then enter S60; the method further includes: S60: using the vehicle tail width ranging method to calculate the longitudinal coordinate x.

[0012] Further, the vehicle tail width ranging method includes: using the rear vehicle distance calculation formula to calculate the longitudinal coordinate x of the tail of the vehicle model box. The rear vehicle distance calculation formula is: x = .

[0013] Further, The coordinates of the outer bounding box are calculated in the image coordinate system.

[0014] Furthermore, the method also includes: S00: determining whether the road ahead is a straight lane, and determining whether the target vehicle is traveling in the same direction. If the road ahead is a straight lane and the target vehicle is traveling in the same direction, enter S10; otherwise, maintain S00.

[0015] According to another embodiment of the present invention, a system for measuring the distance between vehicles in a lateral lane based on a monocular camera is provided, characterized in that it includes a camera and a controller, wherein the monocular camera obtains image information of the road ahead; the controller uses a target detection algorithm to obtain an outer bounding box of a target vehicle in the image information, and records the outer bounding box in an image coordinate system, establishes a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and establishes an association between the image coordinate system and the vehicle body coordinate system; based on the outer bounding box in the image, the vehicle body coordinate system is calculated. The coordinates in the image coordinate system are converted from the image coordinate system to the vehicle body coordinate system to obtain the lateral coordinate y of the right side of the target vehicle in the vehicle body coordinate system; the type of the target vehicle is obtained from the image information using an image recognition algorithm; based on the type of the target vehicle, a vehicle model frame is constructed in the vehicle body coordinate system with the lateral coordinate y as a reference, where the width of the vehicle model frame is W and the length of the vehicle model frame is H; the longitudinal coordinate x of the tail of the vehicle model frame is calculated using a lateral distance calculation formula, where the longitudinal coordinate x is the distance from the target vehicle to the host vehicle, and the lateral distance calculation formula is:

[0016]

[0017] Among them, the is the camera focal length, is the pixel width of the target vehicle in the image information.

[0018] According to yet another embodiment of the present invention, a storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.

[0019] According to another embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments.

[0020] According to the present invention, in S10, a monocular camera first acquires image information of the road ahead. This step forms the visual foundation of the entire system. The camera captures real-time images of the road ahead, providing raw data for subsequent vehicle detection and distance calculation. In S20, an object detection algorithm is used to identify and calibrate the outer bounding box of the target vehicle in the image. This algorithm identifies the vehicle in the image and determines its position within the image, recording the coordinates of the outer bounding box in the image coordinate system. Simultaneously, a vehicle coordinate system is established, with the camera's perpendicular projection point on the ground as the origin, the front as the X-axis, and the right as the Y-axis, thereby linking the image coordinate system with the vehicle coordinate system. In S30, based on the position of the outer bounding box in the image coordinate system, it is converted to the vehicle coordinate system to obtain the lateral coordinate y of the right side of the target vehicle, converting the visual information in the image into the vehicle's actual spatial position information. In S40, the image recognition algorithm determines the type of the target vehicle, and a vehicle model box is constructed in the vehicle coordinate system based on the lateral coordinate y. The vehicle type information is used to estimate the vehicle's actual size, thereby more accurately calculating the distance. In S50, the lateral distance calculation formula is used to calculate the distance between the target vehicle and the host vehicle based on the rear longitudinal coordinate x of the vehicle model frame. The technical solution of the present invention improves the accuracy and stability of vehicle distance measurement. Through detailed image analysis and coordinate transformation, this method can more accurately measure the actual distance between vehicles, especially in lateral lanes. This precise measurement is crucial for autonomous driving and assisted driving systems and can effectively improve driving safety. Furthermore, the use of a monocular camera combined with an image processing algorithm reduces hardware costs while improving the practicality and popularity of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0022] Figure 1 1 is a flow chart of a method for calculating the distance between vehicles in a lateral lane based on a monocular camera according to an embodiment of the present invention;

[0023] Figure 2 yes Figure 1 Schematic diagram of using target detection algorithm to obtain the outer bounding box of the target vehicle in image information;

[0024] Figure 3 yes Figure 1 Schematic diagram of calculating the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance calculation formula;

[0025] Figure 42 is a schematic diagram of the hardware structure of a system for lateral lane distance measurement based on a monocular camera according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Example 1

[0029] The present invention provides a method for measuring the distance between vehicles in a lateral lane based on a monocular camera, the method comprising:

[0030] S10: Acquire image information of the road ahead through a monocular camera;

[0031] S20: Using the target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and recording the outer bounding box in the image coordinate system, establishing a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and establishing an association between the image coordinate system and the vehicle body coordinate system;

[0032] S30: Based on the coordinates of the outer bounding box in the image coordinate system, the lateral coordinate y of the right side of the target vehicle in the vehicle coordinate system is obtained using a conversion relationship from the image coordinate system to the vehicle coordinate system;

[0033] S40: using an image recognition algorithm to obtain the type of the target vehicle from the image information, and constructing a vehicle model frame based on the horizontal coordinate y in the vehicle body coordinate system based on the type of the target vehicle, where the width of the vehicle model frame is W and the length of the vehicle model frame is H;

[0034] S50: Calculate the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance calculation formula. The longitudinal coordinate x is the distance from the target vehicle to the host vehicle. The lateral distance calculation formula is:

[0035]

[0036] Among them, Camera focal length, is the pixel width of the target vehicle in the image information.

[0037] Applying the technical solution of the present invention, in S10, a monocular camera first acquires image information of the road ahead. This step forms the visual foundation of the entire system. The camera captures real-time images of the road ahead, providing raw data for subsequent vehicle detection and distance calculation. In S20, an object detection algorithm is used to identify and calibrate the outer bounding box of the target vehicle in the image. This step uses the algorithm to identify the vehicle in the image and determine its position within the image, recording the coordinates of the outer bounding box in the image coordinate system. Simultaneously, a vehicle coordinate system is established, with the camera's perpendicular projection point on the ground as the origin, the front as the X-axis, and the right as the Y-axis, thereby linking the image coordinate system with the vehicle coordinate system. In S30, based on the position of the outer bounding box in the image coordinate system, it is converted to the vehicle coordinate system to obtain the lateral coordinate y of the right side of the target vehicle, converting the visual information in the image into the vehicle's actual spatial position information. In S40, the image recognition algorithm determines the type of the target vehicle, and a vehicle model box is constructed in the vehicle coordinate system based on the lateral coordinate y. The vehicle type information is used to estimate the vehicle's actual size, thereby more accurately calculating the distance. In S50 , the distance between the target vehicle and the host vehicle is calculated based on the rear longitudinal coordinate x of the vehicle model frame using a lateral vehicle distance calculation formula.

[0038] The technical solution of this invention improves the accuracy and stability of vehicle-to-vehicle distance measurement. Through detailed image analysis and coordinate transformation, this method can more accurately measure the actual distance between vehicles, especially in lateral lanes. This precise measurement is crucial for autonomous driving and assisted driving systems, effectively improving driving safety. Furthermore, the use of a monocular camera combined with image processing algorithms reduces hardware costs while increasing the practicality and adoption of the system.

[0039] like Figure 2As shown, the target detection algorithm is used to obtain the outer bounding box of the target vehicle in the image information, and the outer bounding box is recorded in the image coordinate system, so that the car No. 1 and car No. 2 in front can be identified. Taking car No. 1 as an example, the outer bounding box of car No. 1 is recorded in the image coordinate system, and then "the vehicle body coordinate system is established with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and the image coordinate system and the body coordinate system are associated. Based on the coordinates of the outer bounding box in the image coordinate system, the conversion relationship from the image coordinate system to the body coordinate system is used to obtain the horizontal coordinate y of the right side of the target vehicle in the body coordinate system. The image recognition algorithm is used to obtain the type of the target vehicle in the image information. Based on the type of the target vehicle, a vehicle model frame with the horizontal coordinate y as the reference is constructed in the body coordinate system. The width of the vehicle model frame is W, and the length of the vehicle model frame is H". Figure 3 The correspondence between the vehicle model frame of vehicle No. 1 and the monocular camera in the vehicle body coordinate system.

[0040] The above lateral distance calculation formula is derived as follows:

[0041] pass Figure 2 The geometric relationship in can be obtained from the following formulas:

[0042]

[0043]

[0044]

[0045] in, is the width of the rear end of the car in pixels;

[0046] The formula is obtained using the camera imaging principle: where f is the focal length of the camera

[0047]

[0048] in are known parameters, is an unknown parameter;

[0049] Using the above four formulas, the equation is as follows:

[0050]

[0051] The current form of solution is The equation is:

[0052]

[0053]

[0054]

[0055]

[0056] Substituting a, b, and c into the formula for x yields the formula for calculating lateral vehicle distance.

[0057] It should be noted that the association between the image coordinate system and the vehicle coordinate system can be established based on the transformation relationship of "pixel coordinate system->image coordinate system->camera coordinate system->vehicle coordinate system".

[0058] Preferably, in the technical solution of this embodiment, in S40, constructing a vehicle model frame based on the target vehicle type in the vehicle body coordinate system with the lateral coordinate y as a reference includes: using a table lookup method to locate model frame information corresponding to the target vehicle type in a pre-built vehicle model library, the model frame information including width and length information, and constructing the vehicle model frame based on the width and length information. The technical solution of the present invention uses a table lookup method to select model frame information corresponding to the target vehicle type from the pre-built vehicle model library, thereby improving the accuracy and efficiency of vehicle identification. By quickly obtaining model frame information (including width and length information) that matches the target vehicle type through the table lookup method, the system can more accurately estimate the actual dimensions of the target vehicle, which is particularly important for calculating vehicle distance. The vehicle model library can contain dimensional data for a variety of vehicle models, enabling the system to adapt to different types of vehicles, whether small sedans, SUVs, or large trucks, and effectively identify and calculate them. This is particularly important in changing road environments, particularly in cities or on highways. The pre-built vehicle model library makes the system's calculation process more efficient. In real-world applications, this means faster response times and higher computing speeds, providing more reliable and timely vehicle distance information for assisted driving systems or autonomous driving systems, improving overall driving safety.

[0059] Additionally, feature matching algorithms or AI reasoning systems can be used to identify the model box information corresponding to the target vehicle type. Feature matching algorithms use algorithms such as SIFT (Scale-Invariant Feature Transform) or ORB (OrientedFAST and RotatedBRIEF) to extract key vehicle features and match them against a pre-existing database of vehicle model features to determine the vehicle type. AI reasoning systems combine multiple data sources and algorithms to comprehensively determine vehicle type. This may include image recognition, historical data analysis, and pattern recognition.

[0060] Optionally, in S30, the coordinates of the outer bounding box in the image coordinate system include: the coordinates of the lower right corner of the outer bounding box. Figure 2As shown, the coordinates of the upper left corner of Vehicle No. 1 are (u1, v1), and the coordinates of the lower right corner are (u2, v2). The horizontal coordinate y of the right side of the target vehicle in the vehicle body coordinate system can be directly obtained by using the conversion relationship between the image coordinate system and the vehicle body coordinate system with the coordinate v2 of the lower right corner of Vehicle No. 1.

[0061] Optionally, in the technical solution of this embodiment, before calculating the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance formula in S50, it further includes

[0062] judging whether y is less than W;

[0063] If y > W, then calculate the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance formula;

[0064] If y < W, then enter S60;

[0065] The method further includes:

[0066] S60: Calculate the longitudinal coordinate x using the vehicle tail width ranging method.

[0067] In a complex road traffic environment, vehicles may be in different relative positions. This method adapts the ranging strategy to different traffic situations, thereby providing more accurate and reliable distance data. By selecting the most appropriate calculation method, the ranging error caused by vehicle position changes can be effectively reduced, especially in the case of high-speed driving or frequent lane changes, ensuring the stability and reliability of the distance data.

[0068] Such as Figure 2 shown, after Vehicle No. 1 is recognized and it is judged that y > W, then calculate the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance formula. After Vehicle No. 2 is recognized and y < W, then calculate the longitudinal coordinate x using the vehicle tail width ranging method.

[0069] Preferably, the vehicle tail width ranging method includes: calculating the longitudinal coordinate x of the tail of the vehicle model frame using the backward distance formula, and the backward distance formula is: x = .

[0070] Where, x = The derivation process of the formula is as follows:

[0071] Using the principle of pinhole imaging, the formula W / = x / f can be obtained, and after transformation, x = .

[0072] Optionally, in the technical solution of this embodiment The coordinates of the outer bounding box in the image coordinate system are calculated. For example, as Figure 2As shown, the coordinates of the upper left corner of car No. 1 are (u1, v1), and the coordinates of the lower right corner are (u2, v2), then =u2-u1.

[0073] As a preferred implementation, in the technical solution of this embodiment, the method also includes: S00: judging whether the road ahead is a straight lane, and judging whether the target vehicle is traveling in the same direction. If the road ahead is a straight lane and the target vehicle is traveling in the same direction, enter S10; otherwise, maintain S00. By judging whether the road ahead is straight and whether the target vehicle is traveling in the same direction, it is possible to more accurately determine when to start the vehicle distance measurement process. In the case of non-straight sections or non-co-directional driving, the vehicle distance measurement may be inaccurate or inapplicable, so this judgment step ensures that the system is only activated under suitable conditions, thereby improving the overall distance measurement accuracy. Ensuring that vehicle distance measurement is performed in the most suitable environment can improve the safety and reliability of assisted driving or automatic driving systems. Especially on highways or other straight roads, accurate vehicle distance measurement is particularly critical for maintaining a safe distance and preventing collisions.

[0074] Whether a road is straight or not can be determined by the lane detection model. Images captured by the vehicle's cameras can be used to analyze the road's geometric features using image processing algorithms. For example, methods such as edge detection and line segment detection can be used to identify road boundaries and lane markings to determine whether the road is straight or not. Alternatively, the vehicle's GPS positioning information and pre-loaded map data can be combined to analyze the road characteristics at the vehicle's current location. Advanced maps contain information such as road shape and inclination, which helps determine road straightness. Furthermore, the inertial measurement unit (IMU) provides acceleration and inclination data, which can be analyzed to infer whether the vehicle is traveling on a straight road.

[0075] To determine whether a target vehicle is traveling in the same direction as the ego vehicle, the target tracking algorithm can determine the target vehicle's and the ego vehicle's direction of travel. By analyzing the target vehicle's trajectory and velocity vector, it can be determined whether it is traveling in the same direction as the ego vehicle. For example, if the target vehicle and the ego vehicle have roughly the same motion vector, they are likely traveling in the same direction.

[0076] Example 2

[0077] This embodiment also provides a system for lateral lane distance measurement based on a monocular camera, which is used to implement the above-mentioned embodiments and preferred embodiments. Details already described will not be repeated here. As used below, the term "controller" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.

[0078] The system includes a camera and a controller, wherein:

[0079] Monocular camera, to obtain image information of the road ahead;

[0080] The controller uses the target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and records the outer bounding box in the image coordinate system. The vehicle body coordinate system is established with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and the image coordinate system and the vehicle body coordinate system are associated; based on the coordinates of the outer bounding box in the image coordinate system, the horizontal coordinate y of the right side of the target vehicle in the vehicle body coordinate system is obtained by using the conversion relationship from the image coordinate system to the vehicle body coordinate system; the type of the target vehicle is obtained from the image information, and based on the type of the target vehicle, a vehicle model box is constructed in the vehicle body coordinate system with the horizontal coordinate y as the reference, the width of the vehicle model box is W, and the length of the vehicle model box is H; the longitudinal coordinate x of the tail of the vehicle model box is calculated using the lateral distance calculation formula, and the longitudinal coordinate x is the distance from the target vehicle to the vehicle. The lateral distance calculation formula is:

[0081]

[0082] in, is the camera focal length, is the pixel width of the target vehicle in the image information.

[0083] Example 3

[0084] An embodiment of the present invention further provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0085] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0086] S10: Acquire image information of the road ahead through a monocular camera;

[0087] S20: Using the target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and recording the outer bounding box in the image coordinate system, establishing a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and establishing an association between the image coordinate system and the vehicle body coordinate system;

[0088] S30: Based on the coordinates of the outer bounding box in the image coordinate system, the lateral coordinate y of the right side of the target vehicle in the vehicle coordinate system is obtained using a conversion relationship from the image coordinate system to the vehicle coordinate system;

[0089] S40: using an image recognition algorithm to obtain the type of the target vehicle from the image information, and constructing a vehicle model frame based on the horizontal coordinate y in the vehicle body coordinate system based on the type of the target vehicle, where the width of the vehicle model frame is W and the length of the vehicle model frame is H;

[0090] S50: Calculate the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance calculation formula. The longitudinal coordinate x is the distance from the target vehicle to the host vehicle. The lateral distance calculation formula is:

[0091]

[0092] in, is the camera focal length, is the pixel width of the target vehicle in the image information.

[0093] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.

[0094] Example 4

[0095] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0096] S10: Acquire image information of the road ahead through a monocular camera;

[0097] S20: Using the target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and recording the outer bounding box in the image coordinate system, establishing a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and establishing an association between the image coordinate system and the vehicle body coordinate system;

[0098] S30: Based on the coordinates of the outer bounding box in the image coordinate system, the lateral coordinate y of the right side of the target vehicle in the vehicle coordinate system is obtained using a conversion relationship from the image coordinate system to the vehicle coordinate system;

[0099] S40: using an image recognition algorithm to obtain the type of the target vehicle from the image information, and constructing a vehicle model frame based on the horizontal coordinate y in the vehicle body coordinate system based on the type of the target vehicle, where the width of the vehicle model frame is W and the length of the vehicle model frame is H;

[0100] S50: Calculate the longitudinal coordinate x of the tail of the vehicle model frame using the lateral distance calculation formula. The longitudinal coordinate x is the distance from the target vehicle to the host vehicle. The lateral distance calculation formula is:

[0101]

[0102] in, is the camera focal length, is the pixel width of the target vehicle in the image information.

[0103] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0104] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0105] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0106] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0107] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0108] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0109] If the integrated unit is implemented in the form of a software functional unit and 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 the present application, or the part that contributes to the existing technology, or all 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 a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program code.

[0110] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for measuring the distance between vehicles in a lateral lane based on a monocular camera, characterized in that: The method includes: S10: Obtain the image information of the road ahead through a monocular camera; S20: Use a target detection algorithm to obtain the outer bounding box of the target vehicle in the image information, and record the outer bounding box in the image coordinate system. Establish a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the vehicle's horizontal front direction as the X-axis direction, and the vehicle's horizontal right direction as the Y-axis direction, and establish the association between the image coordinate system and the vehicle body coordinate system; S30: Based on the coordinates of the outer bounding box in the image coordinate system, use the conversion relationship from the image coordinate system to the vehicle body coordinate system to obtain the lateral coordinate y of the right side of the target vehicle in the vehicle body coordinate system; S40: Use an image recognition algorithm to obtain the type of the target vehicle in the image information, and construct a vehicle model box based on the type of the target vehicle in the vehicle body coordinate system with the lateral coordinate y as the reference. The width of the vehicle model box is W, and the length of the vehicle model box is H; S50: Use a lateral distance formula to calculate the longitudinal coordinate x of the tail of the vehicle model box. The longitudinal coordinate x is the distance between the target vehicle and the vehicle itself. The lateral distance formula is: Among them, the is the camera focal length, is the pixel width of the target vehicle in the image information.

2. The method according to claim 1, characterized in that In S40, the constructing a vehicle model box based on the type of the target vehicle in the vehicle body coordinate system with the lateral coordinate y as the reference includes: finding the corresponding model box information in a pre-constructed vehicle model library through a look-up table method. The model box information includes width information and length information, and constructing the vehicle model box based on the width information and the length information.

3. The method according to claim 1, characterized in that In S30, based on the coordinates of the outer bounding box in the image coordinate system includes: based on the lower right corner coordinates of the outer bounding box.

4. The method according to claim 1, wherein In S50, before using the lateral distance formula to calculate the longitudinal coordinate x of the tail of the vehicle model box, it further includes judging whether y is less than W; If y > W, then use the lateral distance formula to calculate the longitudinal coordinate x of the tail of the vehicle model box; If y < W, then enter S60; The method further includes: S60: Use the vehicle tail width ranging method to calculate the longitudinal coordinate x.

5. The method according to claim 4, characterized in that The rear width measurement method includes: calculating the longitudinal coordinate x of the rear of the vehicle model frame using a rear distance calculation formula, wherein the rear distance calculation formula is: x= .

6. The method according to claim 1 or 5, characterized in that described It is calculated from the coordinates of the outer bounding box in the image coordinate system.

7. The method according to claim 1, characterized in that The method further includes: S00: Judge whether the road ahead is a straight lane, and judge whether the target vehicle is traveling in the same direction. If the road ahead is a straight lane and the target vehicle is traveling in the same direction, then enter S10; otherwise, maintain S00.

8. A system for measuring the distance between vehicles in a lateral lane based on a monocular camera, characterized in that: It includes a camera and a controller, where a monocular camera, which obtains the image information of the road ahead; The controller uses a target detection algorithm to obtain an outer bounding box of the target vehicle in the image information, and records the outer bounding box in an image coordinate system, establishes a vehicle body coordinate system with the projection point of the monocular camera perpendicular to the ground as the origin, the horizontal front of the vehicle as the X-axis direction, and the horizontal right direction of the vehicle as the Y-axis direction, and establishes an association between the image coordinate system and the vehicle body coordinate system; based on the coordinates of the outer bounding box in the image coordinate system, uses the conversion relationship from the image coordinate system to the vehicle body coordinate system to obtain the horizontal coordinate y of the right side of the target vehicle in the vehicle body coordinate system; uses an image recognition algorithm to obtain the type of the target vehicle in the image information, and constructs a vehicle model box based on the type of the target vehicle in the vehicle body coordinate system with the horizontal coordinate y as the reference, wherein the width of the vehicle model box is W and the length of the vehicle model box is H; calculates the longitudinal coordinate x of the tail of the vehicle model box using a lateral distance calculation formula, wherein the longitudinal coordinate x is the distance between the target vehicle and the host vehicle, and the lateral distance calculation formula is: Among them, the is the camera focal length, is the pixel width of the target vehicle in the image information.

9. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for measuring distance of front vehicle

    CN107290738A

  • Vehicle target three-dimensional information acquisition method based on PTZ pan-tilt camera

    CN110148169A