Vehicle distance detection method based on machine learning

By constructing a multi-scale image segmentation model, the problem of the influence of lighting and weather factors in vehicle distance detection was solved, thereby improving the accuracy and precision of vehicle segmentation results.

CN122067249APending Publication Date: 2026-05-19GANSU PROVINCIAL INST OF METROLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GANSU PROVINCIAL INST OF METROLOGY
Filing Date
2025-12-18
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In existing technologies, image-based vehicle distance detection is easily affected by lighting and weather factors, leading to inaccurate vehicle recognition and segmentation.

Method used

A multi-scale image segmentation model is constructed, which acquires image features through a multi-scale feature extraction module and an attention mechanism, and compensates for contextual information through a feature fusion module to ensure the accuracy of vehicle segmentation results.

Benefits of technology

It effectively improves the accuracy of vehicle distance detection, reduces the impact of lighting and weather factors, and enhances the accuracy of image segmentation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122067249A_ABST
    Figure CN122067249A_ABST
Patent Text Reader

Abstract

The invention provides a vehicle distance detection method based on machine learning. The method comprises the following steps that S1, image information of vehicle passing is acquired by image acquisition equipment arranged on a target road; s2, constructing a multi-scale segmentation model for performing vehicle detection on the image information, and inputting the image information into the multi-scale segmentation model to train the multi-scale segmentation model; s3, real-time image information of vehicle passing on the target road is obtained, the real-time image information is input into the trained multi-scale segmentation model to obtain a vehicle segmentation result in a real-time image, and the vehicle segmentation result is a rectangular frame of the vehicle in the image; and S4, calculating the distance between the vehicles based on the central points of the rectangular frames of the vehicles in the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a vehicle distance detection method, and more particularly to a vehicle distance detection method based on machine learning. Background Technology

[0002] To ensure traffic safety, it is often necessary to detect the distance between vehicles in front and behind on the road in order to determine whether there is a safe distance between adjacent vehicles.

[0003] In existing technologies, distance detection between vehicles is generally based on images. Image acquisition devices are set up on the road to obtain image information, and then the actual distance between vehicles in front and behind on the road is inverted based on the relative positions of vehicles in the image. For vehicle recognition in images, existing technologies generally use neural networks. However, because image acquisition devices are easily affected by lighting and weather factors when acquiring images, vehicles cannot be accurately identified and segmented.

[0004] Therefore, in order to solve the above-mentioned technical problems, it is urgent to propose a new technical approach. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a vehicle distance detection method based on machine learning. By constructing a multi-scale image segmentation model and performing a multi-scale feature extraction module on image information, it is possible to extract image features with different receptive fields from complex backgrounds. Furthermore, it obtains accurate target boundaries through attention concentration, and the feature fusion module fuses the multi-scale features to achieve contextual information compensation, thereby effectively ensuring the accuracy of the final image segmentation result.

[0006] This invention provides a vehicle distance detection method based on machine learning, comprising the following steps:

[0007] S1. Image information of vehicle traffic is acquired by image acquisition equipment set up on the target road;

[0008] S2. Construct a multi-scale segmentation model for vehicle detection from image information, and train the multi-scale segmentation model by inputting the image information into the multi-scale segmentation model;

[0009] S3. Obtain real-time image information of vehicles traveling on the target road, and input the real-time image information into the trained multi-scale segmentation model to obtain the vehicle segmentation result in the real-time image. The vehicle segmentation result is the rectangular box of the vehicle in the image.

[0010] S4. Calculate the distance between vehicles based on the center point of the rectangular bounding box of each vehicle in the image; where:

[0011] The multi-scale segmentation model specifically includes an input convolutional layer, a multi-scale feature extraction module, an attention unit, an average pooling unit, a feature fusion module, an output convolutional layer, a fully connected layer, and a softmax module.

[0012] The input convolutional layer receives image information, and its output features are input to a multi-scale feature extraction module. The output features of the multi-scale feature extraction module are input to an attention unit, the output features of the attention unit are output to an average pooling unit, the output features of the average pooling unit are input to a feature fusion module, the output features of the feature fusion module are input to an output convolutional layer, the output features of the output convolutional layer are input to a fully connected layer, the output features of the fully connected layer are input to a softmax module, and the softmax module outputs the image segmentation result.

[0013] Furthermore, the multi-scale feature extraction module includes convolution module I, convolution module II, convolution module III, convolution module IV, convolution module V, and convolution module VI;

[0014] Convolutional module I and convolutional module II are both 1×1 convolutional modules with a stride of 1; convolutional module III and convolutional module IV are both 3×3 convolutional modules with a stride of 2; convolutional module V and convolutional module VI are both 5×5 convolutional modules with a stride of 2.

[0015] The input of convolution module I is connected to the input convolutional layer. The output features of convolution module I are processed by the ReLU activation function and then input into convolution module II. The output features of convolution module II are processed by the ReLU activation function and then used as FE1.

[0016] The input of convolutional module III is connected to the input convolutional layer. The output features of convolutional module III are processed by the ReLU activation function and then input into convolutional module IV. The output features of convolutional module IV are processed by the ReLU activation function and then used as FE2.

[0017] The input of convolutional module V is connected to the input convolutional layer. The output features of convolutional module V are processed by the ReLU activation function and then input into convolutional module VI. The output features of convolutional module VI are processed by the ReLU activation function and then used as FE3.

[0018] Furthermore, the attention unit includes attention module I, attention module II, and attention module III, which have identical structures;

[0019] Input features FE1 for attention module I, input features FE2 for attention module II, and input features FE3 for attention module III;

[0020] The attention module I includes a channel attention module and a spatial attention module;

[0021] The input terminal of the channel attention module serves as the input terminal of attention module I. The output feature of the channel attention module is multiplied element-wise with the input feature of the channel attention module and then input into the spatial attention module. The output feature of the spatial attention module is multiplied element-wise with the input feature of the spatial attention module and then used as the output feature of attention module I.

[0022] Furthermore, the average pooling unit includes average pooling layer I, average pooling layer II, and average pooling layer III;

[0023] The input terminals of the average pooling layer I, average pooling layer II, and average pooling layer III are respectively connected to the output terminals of attention module I, attention module II, and attention module III, and the output features of the average pooling layer I, average pooling layer II, and average pooling layer III are input into the feature fusion module.

[0024] Furthermore, the feature fusion module includes convolution module VII, convolution module VIII, convolution module IX, and convolution module X;

[0025] The input of convolution module VII is connected to the output of average pooling layer I; the input of convolution module VIII is connected to the output of average pooling layer II; and the input of convolution module IX is connected to the output of average pooling layer III.

[0026] The output features of convolutional modules VII and VIII are multiplied element-wise to obtain the feature FT, which is then multiplied element-wise with the output features of convolutional module IX. The output features of convolutional module IX and the feature FT are concatenated, and the result of the concatenation operation is then input into convolutional module X for convolution. The output of convolutional module X serves as the output of the feature fusion module.

[0027] Among them, the kernel size of convolutional modules VII, VIII, and IX is 1×1; the kernel size of convolutional module M4 is 3×3.

[0028] Furthermore, the output convolutional layer includes convolutional module O1, convolutional module O2, and convolutional module O3;

[0029] The input of convolutional module O1 is connected to the output of the feature fusion module. The output features of convolutional module O1 are input into convolutional module O2. The output features of convolutional module O2 and convolutional module O1 are added element by element and then input into convolutional module O3. The output features of convolutional module O3 are input into the fully connected layer. The convolution scale of convolutional modules O1, O2 and O3 is 1×1.

[0030] Furthermore, the input convolutional layer is a 1×1 convolutional layer.

[0031] The beneficial effects of this invention are as follows: By constructing a multi-scale image segmentation model and performing a multi-scale feature extraction module on image information, it is possible to extract image features with different receptive fields from complex backgrounds, obtain accurate target boundaries through attention focus, and fuse multi-scale features by a feature fusion module to achieve contextual information compensation, thereby effectively ensuring the accuracy of the final image segmentation result. Attached Figure Description

[0032] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0033] Figure 1 This is a schematic diagram of the process of the present invention.

[0034] Figure 2 This is a schematic diagram of the multi-scale segmentation model structure of the present invention.

[0035] Figure 3 This is a schematic diagram of the multi-scale feature extraction module of the present invention.

[0036] Figure 4 This is a schematic diagram of the attention module structure of the present invention.

[0037] Figure 5 This is a schematic diagram of the feature fusion module structure of the present invention.

[0038] Figure 6 This is a schematic diagram of the output convolutional layer structure of the present invention. Detailed Implementation

[0039] The present invention will be further described in detail below:

[0040] This invention provides a vehicle distance detection method based on machine learning, comprising the following steps:

[0041] S1. Image information of vehicle traffic is acquired by image acquisition equipment set up on the target road;

[0042] S2. Construct a multi-scale segmentation model for vehicle detection from image information, and train the multi-scale segmentation model by inputting the image information into the multi-scale segmentation model;

[0043] S3. Obtain real-time image information of vehicles traveling on the target road, and input the real-time image information into the trained multi-scale segmentation model to obtain the vehicle segmentation result in the real-time image. The vehicle segmentation result is the rectangular box of the vehicle in the image.

[0044] S4. Calculate the distance between vehicles based on the center point of the rectangular frame of the vehicle in the image; the specific calculation process in step S4 is existing technology and will not be described in detail here.

[0045] in:

[0046] The multi-scale segmentation model specifically includes an input convolutional layer, a multi-scale feature extraction module, an attention unit, an average pooling unit, a feature fusion module, an output convolutional layer, a fully connected layer, and a softmax module.

[0047] The input convolutional layer takes image information as input. The output features of the input convolutional layer are input to a multi-scale feature extraction module. The output features of the multi-scale feature extraction module are input to an attention unit. The output features of the attention unit are output to an average pooling unit. The output features of the average pooling unit are input to a feature fusion module. The output features of the feature fusion module are input to an output convolutional layer. The output features of the output convolutional layer are input to a fully connected layer. The output features of the fully connected layer are input to a softmax module. The softmax module outputs the image segmentation result. The input convolutional layer uses a 1×1 convolutional module for preliminary feature extraction of the input image. This invention constructs a multi-scale image segmentation model and uses a multi-scale feature extraction module to extract image features from complex backgrounds with different receptive fields. Accurate target boundaries are obtained through attention focus, and the feature fusion module fuses the multi-scale features to compensate for contextual information, effectively ensuring the accuracy of the final image segmentation result.

[0048] In this embodiment, the multi-scale feature extraction module includes convolution module I, convolution module II, convolution module III, convolution module IV, convolution module V, and convolution module VI;

[0049] Convolutional module I and convolutional module II are both 1×1 convolutional modules with a stride of 1; convolutional module III and convolutional module IV are both 3×3 convolutional modules with a stride of 2; convolutional module V and convolutional module VI are both 5×5 convolutional modules with a stride of 2.

[0050] The input of convolution module I is connected to the input convolutional layer. The output features of convolution module I are processed by the ReLU activation function and then input into convolution module II. The output features of convolution module II are processed by the ReLU activation function and then used as FE1.

[0051] The input of convolutional module III is connected to the input convolutional layer. The output features of convolutional module III are processed by the ReLU activation function and then input into convolutional module IV. The output features of convolutional module IV are processed by the ReLU activation function and then used as FE2.

[0052] The input of convolutional module V is connected to the input convolutional layer. The output features of convolutional module V are processed by the ReLU activation function and then input into convolutional module VI. The output features of convolutional module VI are processed by the ReLU activation function and then used as FE3. Through the above structure, by acquiring features from different receptive fields, key spatial feature information in the image, such as edge information and texture information, can be fully extracted, providing accurate feature information for subsequent accurate image segmentation.

[0053] In this embodiment, the attention unit includes attention module I, attention module II, and attention module III, which have the same structure;

[0054] Input features FE1 for attention module I, input features FE2 for attention module II, and input features FE3 for attention module III;

[0055] The attention module I includes a channel attention module and a spatial attention module;

[0056] The input of the channel attention module serves as the input of attention module I. The output features of the channel attention module are multiplied element-wise with its input features and then input into the spatial attention module. The output features of the spatial attention module are multiplied element-wise with its input features and then used as the output features of attention module I. Through these attention modules, key regions can be effectively highlighted and redundant information suppressed, thereby improving target recognition accuracy in complex backgrounds. Furthermore, the channel attention module processes data from both semantic and spatial dimensions, enhancing the overall model's responsiveness to targets at different scales. The channel and spatial attention modules can utilize existing structures.

[0057] In this embodiment, the average pooling unit includes average pooling layer I, average pooling layer II, and average pooling layer III;

[0058] The inputs of the average pooling layer I, average pooling layer II, and average pooling layer III are connected to the outputs of attention modules I, attention modules II, and attention modules III, respectively. The output features of the average pooling layer I, average pooling layer II, and average pooling layer III are input to the feature fusion module. Through the average pooling operation, the features are reduced in dimensionality, so that the features of three different scales are reduced to the same scale, which facilitates the subsequent feature fusion process.

[0059] In this embodiment, the feature fusion module includes convolution module VII, convolution module VIII, convolution module IX, and convolution module X;

[0060] The input of convolution module VII is connected to the output of average pooling layer I; the input of convolution module VIII is connected to the output of average pooling layer II; and the input of convolution module IX is connected to the output of average pooling layer III.

[0061] The output features of convolutional modules VII and VIII are multiplied element-wise to obtain the feature FT, which is then multiplied element-wise with the output features of convolutional module IX. The output features of convolutional module IX and the feature FT are concatenated, and the result of the concatenation operation is then input into convolutional module X for convolution. The output of convolutional module X serves as the output of the feature fusion module.

[0062] Specifically, convolutional modules VII, VIII, and IX have a kernel size of 1×1, while convolutional module M4 has a kernel size of 3×3. This structure enables the fusion of features at different scales, compensating for contextual information, avoiding feature loss between contexts, and ensuring the final segmentation accuracy.

[0063] In this embodiment, the output convolutional layer includes convolutional module O1, convolutional module O2, and convolutional module O3;

[0064] The input of convolutional module O1 is connected to the output of the feature fusion module. The output features of convolutional module O1 are input into convolutional module O2. The output features of convolutional modules O2 and O1 are added element-wise and then input into convolutional module O3. The output features of convolutional module O3 are input into the fully connected layer. The convolution scale of convolutional modules O1, O2, and O3 is 1×1. This allows the entire segmentation model to learn more complex feature pairs and improves the model's sensitivity to subtle features.

[0065] In the attached diagram, C represents feature concatenation operation, × represents element-wise multiplication, and + represents element-wise addition.

[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A vehicle distance detection method based on machine learning, characterized in that: Includes the following steps: S1. Image information of vehicle traffic is acquired by image acquisition equipment set up on the target road; S2. Construct a multi-scale segmentation model for vehicle detection from image information, and train the multi-scale segmentation model by inputting the image information into the multi-scale segmentation model; S3. Obtain real-time image information of vehicles traveling on the target road, and input the real-time image information into the trained multi-scale segmentation model to obtain the vehicle segmentation result in the real-time image. The vehicle segmentation result is the rectangular box of the vehicle in the image. S4. Calculate the distance between vehicles based on the center point of the rectangular bounding box of each vehicle in the image; where: The multi-scale segmentation model specifically includes an input convolutional layer, a multi-scale feature extraction module, an attention unit, an average pooling unit, a feature fusion module, an output convolutional layer, a fully connected layer, and a softmax module. The input convolutional layer receives image information, and its output features are input to a multi-scale feature extraction module. The output features of the multi-scale feature extraction module are input to an attention unit, the output features of the attention unit are output to an average pooling unit, the output features of the average pooling unit are input to a feature fusion module, the output features of the feature fusion module are input to an output convolutional layer, the output features of the output convolutional layer are input to a fully connected layer, the output features of the fully connected layer are input to a softmax module, and the softmax module outputs the image segmentation result.

2. The vehicle distance detection method based on machine learning according to claim 1, characterized in that: The multi-scale feature extraction module includes convolution module I, convolution module II, convolution module III, convolution module IV, convolution module V, and convolution module VI; Convolutional module I and convolutional module II are both 1×1 convolutional modules with a stride of 1; convolutional module III and convolutional module IV are both 3×3 convolutional modules with a stride of 2; convolutional module V and convolutional module VI are both 5×5 convolutional modules with a stride of 2. The input of convolution module I is connected to the input convolutional layer. The output features of convolution module I are processed by the ReLU activation function and then input into convolution module II. The output features of convolution module II are processed by the ReLU activation function and then used as FE1. The input of convolutional module III is connected to the input convolutional layer. The output features of convolutional module III are processed by the ReLU activation function and then input into convolutional module IV. The output features of convolutional module IV are processed by the ReLU activation function and then used as FE2. The input of convolutional module V is connected to the input convolutional layer. The output features of convolutional module V are processed by the ReLU activation function and then input into convolutional module VI. The output features of convolutional module VI are processed by the ReLU activation function and then used as FE3.

3. The vehicle distance detection method based on machine learning according to claim 2, characterized in that: The attention unit includes attention module I, attention module II, and attention module III, which have the same structure. Input features FE1 for attention module I, and input features FE2 for attention module II; Attention Module III input feature FE3; The attention module I includes a channel attention module and a spatial attention module; The input terminal of the channel attention module serves as the input terminal of attention module I. The output feature of the channel attention module is multiplied element-wise with the input feature of the channel attention module and then input into the spatial attention module. The output feature of the spatial attention module is multiplied element-wise with the input feature of the spatial attention module and then used as the output feature of attention module I.

4. The vehicle distance detection method based on machine learning according to claim 3, characterized in that: The average pooling unit includes average pooling layer I, average pooling layer II, and average pooling layer III; The input terminals of the average pooling layer I, average pooling layer II, and average pooling layer III are respectively connected to the output terminals of attention module I, attention module II, and attention module III, and the output features of the average pooling layer I, average pooling layer II, and average pooling layer III are input into the feature fusion module.

5. The vehicle distance detection method based on machine learning according to claim 4, characterized in that: The feature fusion module includes convolution module VII, convolution module VIII, convolution module IX, and convolution module X; The input of convolution module VII is connected to the output of average pooling layer I; the input of convolution module VIII is connected to the output of average pooling layer II; and the input of convolution module IX is connected to the output of average pooling layer III. The output features of convolutional modules VII and VIII are multiplied element-wise to obtain the feature FT, which is then multiplied element-wise with the output features of convolutional module IX. The output features of convolutional module IX and the feature FT are concatenated, and the result of the concatenation operation is then input into convolutional module X for convolution. The output of convolutional module X serves as the output of the feature fusion module. Among them, the kernel size of convolutional modules VII, VIII, and IX is 1×1; the kernel size of convolutional module M4 is 3×3.

6. The vehicle distance detection method based on machine learning according to claim 1, characterized in that: The output convolutional layer includes convolutional module O1, convolutional module O2, and convolutional module O3; The input of convolutional module O1 is connected to the output of the feature fusion module. The output features of convolutional module O1 are input into convolutional module O2. The output features of convolutional module O2 and convolutional module O1 are added element by element and then input into convolutional module O3. The output features of convolutional module O3 are input into the fully connected layer. The convolution scale of convolutional modules O1, O2 and O3 is 1×1.

7. The vehicle distance detection method based on machine learning according to claim 1, characterized in that: The input convolutional layer is a 1×1 convolutional layer.