Vehicle positioning and tracking method based on image recognition

By employing an image recognition-based vehicle localization and tracking method, which utilizes convolutional neural networks and the Hungarian algorithm for vehicle detection and matching, the problem of vehicle matching difficulties in complex traffic scenarios is solved, detection accuracy and tracking efficiency are improved, data redundancy is reduced, and the burden of manual annotation is lowered.

CN119006519AInactive Publication Date: 2024-11-22JIANGSU ROBIN TECH SERVICE CO LTD

Patent Information

Application Number
CN202411026801.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing vehicle tracking technologies face challenges in complex traffic scenarios, including difficulties in vehicle matching, insufficient detection accuracy, low efficiency in processing massive amounts of video data, and the impact of image quality on tracking and recognition performance. Furthermore, manual data annotation is time-consuming and labor-intensive.

Method used

A vehicle localization and tracking method based on image recognition is adopted. By dividing traffic image features frame by frame, vehicle detection and feature extraction are performed using convolutional neural networks. Vehicle matching is combined with the Hungarian algorithm. Multi-scale pyramid and Gaussian filtering are used for preprocessing. Data augmentation and loss function optimization are introduced. The comprehensive similarity of vehicles is calculated and Hungarian algorithm matching is performed.

Benefits of technology

It improves the accuracy and robustness of vehicle matching, enhances the detection capability of vehicles of different sizes and angles, reduces data redundancy, reduces the burden of manual annotation, and improves tracking accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006519A_ABST
    Figure CN119006519A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of vehicle positioning, and discloses a vehicle positioning and tracking method based on image recognition. Comprises: acquiring a road traffic video; dividing a road traffic video into n frames of traffic image features frame by frame, and preprocessing the traffic image features; performing vehicle detection on the preprocessed traffic image features by using a pre-trained convolutional neural network, and extracting vehicle feature information to obtain m frames of vehicles and corresponding vehicle feature information; based on the m frames of vehicles and the corresponding vehicle feature information, the comprehensive similarity between the current frame of vehicle and the previous frame of vehicle is calculated, and the m frames of vehicles are matched by adopting a Hungary algorithm, so that the burden of manual marking is greatly reduced while the tracking precision and efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of vehicle positioning, and more specifically, to a vehicle positioning and tracking method based on image recognition. Background Art

[0002] The patent application with the publication number CN111127902A discloses a parking lot vehicle positioning system and method based on image recognition, including: a collection device, which is arranged on the vehicle to collect images or images in front of and / or behind the vehicle; a controller, which is arranged on the vehicle, the controller is connected to the collection device to extract parking space information from the images or images collected by the collection device, the controller includes an image processing module, an image processing module, an image recognition module, a vehicle status detection processing module, a parking space character determination module, a wireless communication module and a memory module; and a mobile terminal, which includes a receiving module to receive parking space information from the controller; without relying on other infrastructure, the parking space information can be automatically located and identified by the vehicle itself, and the identified parking space information can be automatically sent to the mobile terminal, without the user having to spend extra energy and time to actively record the parking space information.

[0003] However, existing vehicle tracking technologies often face many challenges in practical applications. In complex traffic scenes, vehicles are densely packed, blocked, and partially cut off from each other, making it difficult to match vehicles. Vehicle identities are easily lost or confused during the tracking process. In addition, traditional vehicle detection methods usually use feature extraction at a single scale, and it is difficult to ensure detection accuracy for vehicles of different sizes and angles. In busy road monitoring, the processing efficiency of massive video data is also a major bottleneck, and redundant data takes up a lot of storage space and computing resources. At the same time, the quality of vehicle images directly affects the performance of subsequent tracking and recognition. Due to factors such as noise interference and blur and loss of focus, the quality of vehicle images is often unsatisfactory, which brings difficulties to feature extraction and matching. Manually labeled data is an indispensable part of training and evaluating tracking algorithms, but in the face of vast amounts of video data, it is time-consuming and labor-intensive to annotate vehicle positions and attributes frame by frame, and the quality of annotations is difficult to ensure.

[0004] In view of this, the present invention proposes a vehicle positioning and tracking method based on image recognition to solve the above problems. Summary of the invention

[0005] In order to overcome the above-mentioned defects of the prior art and to achieve the above-mentioned purpose, the present invention provides the following technical solution: a vehicle positioning and tracking method based on image recognition, comprising: S1, collecting road traffic video; dividing the road traffic video frame by frame into n frames of traffic image features, and preprocessing the traffic image features; S2. Detect vehicles on the pre-processed traffic image features using the pre-trained convolutional neural network, and extract vehicle feature information to obtain m frames of vehicles and corresponding vehicle feature information; S3. Based on the m-frame vehicles and the corresponding vehicle feature information, the comprehensive similarity between the current frame vehicle and the previous frame vehicle is calculated, and the m-frame vehicles are matched using the Hungarian algorithm.

[0006] Furthermore, the road traffic video is collected by calling a high-definition camera installed above the road; The method of dividing the road traffic video frame by frame into n frames of traffic image features includes: Decode the road traffic video and convert it into a series of continuous frame sequences; use the inter-frame difference algorithm to calculate the difference between adjacent frames in the frame sequence; The calculation formula of the difference is: ;in, For the The pixel value of the frame; For the +1 frame pixel value; The adjacent frames in the frame sequence and The absolute value of the difference between the pixel values ​​is the difference degree; A difference threshold is preset, and frames with a difference greater than or equal to the difference threshold are marked as candidate key frames; the inter-frame similarity between the candidate key frames is calculated; the calculation formula is: ;in, For two candidate key frames and The inter-frame similarity between For the The pixel value of the frame; Preset a similarity threshold; merge or filter candidate key frames whose similarity is greater than the similarity threshold; obtain a key frame set; The key frame set is generated using the Gaussian pyramid algorithm Layered multi-scale pyramid; The multi-scale pyramid is Frame traffic image features.

[0007] Furthermore, the multi-scale pyramid is generated in the following manner: For each key frame image in the key frame set, a Gaussian pyramid is constructed. ,in, is the original key frame image, An image of a key frame at the smallest level; The methods for obtaining each layer of the Gaussian pyramid include: Step 1, perform Gaussian smoothing on the key frame image to obtain a smoothed image; The formula for Gaussian smoothing is: ;in, is the Gaussian pyramid after Gaussian smoothing Layer image; For the Gaussian pyramid Layer image; is a two-dimensional Gaussian kernel; is the convolution operation; Step 2: downsample the smoothed image; the downsampling formula is: ;in, is the Gaussian pyramid Layer images; To express Pixel coordinates on the image; Indicated in The coordinates on The pixel value is assigned to ; The size of each layer of the Gaussian pyramid is: , ;in, Indicates The width of the image in the Gaussian pyramid layer; Indicates The height of the image in the layer Gaussian pyramid; Represents the width of the topmost image of the Gaussian pyramid; Indicates the height of the topmost image of the Gaussian pyramid; the topmost layer of the Gaussian pyramid is the image of the original key frame; Define the number of layers of the multi-scale pyramid ;in, To take the smaller value of the original key frame image width and height; To round down.

[0008] Furthermore, the method of preprocessing the traffic image features includes: Perform layered processing on the multi-scale pyramid; define the top to n / 3 layers of the multi-scale pyramid as low-resolution layers, the n / 3 to 2n / 3 layers of the multi-scale pyramid as medium-resolution layers, and the 2n / 3 to bottom layers of the multi-scale pyramid as high-resolution layers; no preprocessing is performed on the high-resolution layers; The low-resolution layer is denoised using Gaussian filtering to obtain a denoised low-resolution image; the medium-resolution layer is subjected to operator enhancement texture processing to obtain a texture-enhanced image; the pre-processed traffic image features include a texture-enhanced image, a denoised low-resolution image, and an image corresponding to the high-resolution layer.

[0009] Furthermore, the denoising process includes: Define a Gaussian kernel size of 55 and a standard deviation ; According to the Gaussian kernel size and standard deviation Generate a two-dimensional Gaussian filter; use the two-dimensional Gaussian function to define the weight of the two-dimensional Gaussian filter. The formula of the two-dimensional Gaussian function is: ;in, is the coordinate inside the Gaussian kernel; is a Gaussian filter; Use the generated Gaussian filter to perform convolution operation with the image of the low-resolution layer to obtain a smoothed image; the formula for the convolution operation is: ;in, is the image before smoothing, is the coordinate of the pixel in the image, represents the convolution operation, is the smoothed image; and are the horizontal and vertical coordinates within the Gaussian kernel respectively.

[0010] Furthermore, the operator enhanced texture processing method includes: Step 101, respectively calculating the horizontal and vertical gradients of the image of the medium resolution layer; and using the operator to convolve the image to obtain the horizontal gradient and the vertical gradient; Horizontal Gradient ; Vertical Gradient ;in, is the image of the medium resolution layer; Step 102: Calculate the gradient amplitude based on the horizontal gradient and the vertical gradient , as a texture feature map; The calculation formula of gradient amplitude is: ; Step 103: Normalize the gradient amplitude to the range of [0, 1] to obtain a normalized texture feature map. ; Step 104: normalize the texture feature map and Perform weighted fusion to obtain a texture-enhanced image ; The calculation formula of weighted fusion is: ;in, is the weight of the texture feature map.

[0011] Furthermore, the training method of the convolutional neural network includes: The YOLO algorithm architecture is selected as the basic architecture of the convolutional neural network; the YOLO algorithm architecture includes an input layer, J convolutional layers, a downsampling layer, an upsampling layer, and an output layer; Each convolution layer consists of h convolution kernels, which slide on the traffic image features to extract local features. The size of the convolution kernel is set to 3x3 or 1x1, and the step size is 1 or 2. A downsampling layer is inserted between the convolution layers to downsample the preliminary feature map. The output layer is placed at the end of the convolutional neural network, and a convolutional layer is used to generate the final prediction result; the prediction result is a set of image bounding boxes and corresponding class probabilities; the coordinates and size of the image bounding box are obtained by regression, and the class probability is calculated by the softmax function; Collect vehicle images of group A and the corresponding annotation information of the vehicle images as a training data set; the annotation information includes vehicle position, vehicle category, vehicle orientation, vehicle occlusion, vehicle truncation and vehicle unique ID; The vehicle images in the training data set are randomly scaled, cropped, and flipped; the vehicle images in the training data set are input into the convolutional neural network to obtain the final prediction results; the function value of the loss function is calculated based on the prediction results and the actual annotation information; According to the gradient of the function value of the loss function, the Adam optimization algorithm is used to update the weights and biases of the convolutional neural network to minimize the function value of the loss function; Repeat iterative training of the vehicle images in the training data set until the convolutional neural network converges or reaches a preset number of iterations; and obtain a trained convolutional neural network.

[0012] Furthermore, the loss function ; ; ; ; in,( , ) is the bounding box of the annotation The center coordinates of Bounding box for annotation width; Bounding box for annotation The height;( , ) is the bounding box predicted by the network The center coordinates of Bounding box predicted by the network width; Bounding box predicted by the network of high; The index representing the bounding box; Represents the spatial position index of the feature map; is the weight coefficient of position loss; is the one-hot encoding of the labeled vehicle category, indicating the Is the vehicle category of the bounding box a category? ; To predict the probability of the vehicle category, the bounding box represented by the network prediction Belongs to category probability; is the index of the vehicle category; is the true confidence, indicating Whether a bounding box contains an object; is the confidence of the prediction, indicating the first The confidence that a bounding box contains an object.

[0013] Furthermore, the vehicle characteristic information includes vehicle position, vehicle type, vehicle orientation, vehicle obstruction, vehicle cutoff and vehicle unique ID; The calculation method of the comprehensive similarity between the current frame vehicle and the previous frame vehicle includes: For the current frame The car and the previous frame vehicles, and calculate their similarity in vehicle feature information, i.e., comprehensive similarity; Calculate the vehicle density d of the current frame, that is, the number of vehicles per unit area; Set the vehicle position similarity weight , vehicle category similarity weight , vehicle orientation similarity weight , similarity weight of vehicle occlusion Similarity weight with vehicle cutoff The baseline value of Preset vehicle density threshold interval [d low , d high ]; if the vehicle density d of the current frame is less than or equal to d low , indicating that the scene vehicles are sparse, and the vehicle position similarity weight is increased , reduce the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d in the current frame is greater than or equal to d high , indicating that the scene is densely populated with vehicles, and the vehicle position similarity weight is reduced. , improve the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d of the current frame is within the vehicle density threshold range, maintain - The baseline value remains unchanged; the adjusted - Applied to comprehensive similarity calculation; The calculation formula of the comprehensive similarity is: ;in, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle positions, Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle categories, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle orientation; Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle occlusion situations; Indicates the current frame The car and the previous frame The similarity of vehicles in terms of vehicle cutoff situations.

[0014] Furthermore, the method of matching the m-frame vehicles includes: Create a zero matrix of size n1×m1, where n1 represents the number of vehicles in the current frame and m1 represents the number of vehicles in the previous frame; use the comprehensive similarity as the matrix element of the zero matrix to construct a similarity matrix; The similarity matrix is ​​used as the input of the Hungarian algorithm, which optimizes the matching by continuously searching for augmenting paths in the similarity matrix. The augmenting path is a path that alternately passes through unmatched edges and matched edges in the similarity matrix, and the starting point and the end point of the augmenting path are both unmatched vertices; by finding the augmenting path, the Hungarian algorithm adjusts the current matching scheme until no augmenting path can be found; Assign a label value to each row and column of the similarity matrix; by adjusting the label value, change the selection of matching edges, and after iteration, obtain an optimal matching solution; The optimal matching solution is V vehicle pairs ( , ) matches successfully, where Indicates the current frame A car, Indicates the previous frame Vehicle; the corresponding relationship between vehicles in consecutive frames is established; For successfully matched vehicle pairs, their vehicle unique IDs are transferred; for vehicles that are not matched in the current frame, new vehicle unique IDs are assigned to them; for vehicles that are not matched in the previous frame, they are removed from the tracking targets; the current frame is used as the previous frame for the next match and the matching is repeated.

[0015] The technical effects and advantages of the vehicle positioning and tracking method based on image recognition of the present invention are as follows: The present invention improves the accuracy and robustness of vehicle matching and effectively maintains the consistency of vehicle identity by comprehensively considering various feature information; improves the detection capability of vehicles of different sizes and angles through multi-scale feature extraction and fusion; introduces data enhancement and loss function optimization to further improve detection accuracy; performs hierarchical preprocessing on input vehicle images, effectively improves image quality, and provides more reliable input for subsequent feature extraction and matching; extracts key frames of the video through inter-frame difference and similarity comparison, and reduces data redundancy; realizes multi-scale analysis, which not only compresses the data size but also retains important feature information; while improving tracking accuracy and efficiency, it also greatly reduces the burden of manual labeling. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A schematic diagram of a vehicle positioning and tracking method based on image recognition according to the present invention; Figure 2 A schematic diagram of a vehicle positioning and tracking system based on image recognition according to the present invention; Figure 3 It is a schematic diagram of an electronic device of the present invention. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0018] Example 1: Please refer to Figure 1 As shown, the vehicle positioning and tracking method based on image recognition described in this embodiment includes: S1, collecting road traffic videos; dividing the road traffic videos into n frames of traffic image features frame by frame, and preprocessing the traffic image features; S2. Detect vehicles on the pre-processed traffic image features using the pre-trained convolutional neural network, and extract vehicle feature information to obtain m frames of vehicles and corresponding vehicle feature information; S3. Based on the m-frame vehicles and the corresponding vehicle feature information, the comprehensive similarity between the current frame vehicle and the previous frame vehicle is calculated, and the m-frame vehicles are matched using the Hungarian algorithm to achieve cross-frame tracking.

[0019] Furthermore, the road traffic video is collected by calling a high-definition camera installed above the road; The method of dividing the road traffic video frame by frame into n frames of traffic image features includes: Decode the road traffic video and convert it into a series of continuous frame sequences; use the inter-frame difference algorithm to calculate the difference between adjacent frames in the frame sequence; The calculation formula of the difference is: ;in, For the The pixel value of the frame; For the +1 frame pixel value; The adjacent frames in the frame sequence and The absolute value of the difference between the pixel values ​​is the difference degree; A difference threshold is preset, and frames with a difference greater than or equal to the difference threshold are marked as candidate key frames; the method for presetting the difference threshold includes: collecting several groups of road traffic video samples, manually marking the expected key frames for each road traffic video sample, and calculating the average frame difference between these manually marked key frames as the initial difference threshold; trying multiple different difference thresholds near the initial difference threshold; for each difference threshold, extracting the key frames, and comparing the extracted results with the manually marked results; selecting the difference threshold that makes the extracted results most match the manually marked results as the final difference threshold.

[0020] Calculate the inter-frame similarity between candidate key frames; the calculation formula is: ;in, For two candidate key frames and The inter-frame similarity between For the The pixel value of the frame; Preset a similarity threshold; merge or filter candidate key frames whose similarity is greater than the similarity threshold; obtain a key frame set, each key frame in the key frame set represents a significant change and key information of the video content; The similarity threshold can be preset in the following ways: Select several pairs of similar keyframes, calculate the similarity values ​​between these keyframe pairs, and take the median or mean of these similarity values ​​as the initial similarity threshold; try multiple different similarity thresholds near the initial similarity threshold; for each similarity threshold, merge similar keyframes to obtain a merged result; compare the merged result with the manual expectation; select the similarity threshold that makes the merged result most match the manual expectation as the final similarity threshold; Through step-by-step experiments, we can avoid simple empirical settings and obtain the optimal difference and similarity threshold parameters. This data-driven parameter tuning method requires a certain amount of manually annotated data sets as a prerequisite. We can also combine domain knowledge and experience to roughly preset and fine-tune the threshold parameters.

[0021] The key frame set is applied with Gaussian pyramid algorithm to generate a multi-scale pyramid; each layer is obtained by Gaussian smoothing and downsampling the image in the previous layer, and the size is halved successively; each layer of the pyramid corresponds to a different image size and resolution; The number of layers of the multi-scale pyramid is determined according to the video content and analysis requirements, and usually 3-5 layers are sufficient to cover the scene.

[0022] The multi-scale pyramid generation method includes: For each key frame image in the key frame set, a Gaussian pyramid is constructed. ,in, is the original key frame image, An image of a key frame at the smallest level; The methods for obtaining each layer of the Gaussian pyramid include: Step 1, perform Gaussian smoothing on the key frame image to obtain a smoothed image; The formula for Gaussian smoothing is: ;in, is the Gaussian pyramid after Gaussian smoothing Layer image; For the Gaussian pyramid Layer image; is a two-dimensional Gaussian kernel; It is a convolution operation; Gaussian smoothing can reduce noise and smooth details; Step 2: downsample the smoothed image, that is, remove half of the pixels in each row and column of the image to obtain an image with half the size in the next layer; The formula for downsampling is: ;in, is the Gaussian pyramid Layer images; To express Pixel coordinates on the image; Indicated in The coordinates on The pixel value is assigned to ; The size of each layer of the Gaussian pyramid is: , ;in, Indicates The width of the image in the Gaussian pyramid layer; Indicates The height of the image in the layer Gaussian pyramid; Represents the width of the topmost image of the Gaussian pyramid; Indicates the height of the topmost image of the Gaussian pyramid; the topmost layer of the Gaussian pyramid is the image of the original key frame; Define the number of layers of the multi-scale pyramid ;in, To take the smaller value of the original key frame image width and height; To round down; The multi-scale pyramid is Frame traffic image features.

[0023] The method of preprocessing the traffic image features includes: The multi-scale pyramid is processed in layers; the top layer to the n / 3 layer (rounded up) of the multi-scale pyramid are defined as low-resolution layers, the n / 3 layer (rounded up) to the 2n / 3 layer of the multi-scale pyramid are defined as medium-resolution layers, and the 2n / 3 layer (rounded up) to the bottom layer (0 layer) of the multi-scale pyramid are defined as high-resolution layers; no preprocessing is performed on the high-resolution layers; The low-resolution layer is subjected to denoising by using Gaussian filtering to obtain a denoised low-resolution image; The denoising process includes: Define a Gaussian kernel size of 55 and a standard deviation ; According to the Gaussian kernel size and standard deviation Generate a two-dimensional Gaussian filter; use the two-dimensional Gaussian function to define the weight of the two-dimensional Gaussian filter. The formula of the two-dimensional Gaussian function is: ;in, is the coordinate inside the Gaussian kernel; is a Gaussian filter; Use the generated Gaussian filter to perform convolution operation with the image of the low-resolution layer to obtain a smoothed image; the formula for the convolution operation is: ;in, is the image before smoothing, is the coordinate of the pixel in the image, represents the convolution operation, is the smoothed image; and are the horizontal and vertical coordinates within the Gaussian kernel respectively; in this process, the Gaussian kernel size and standard deviation are adjusted to find the optimal parameter combination.

[0024] Perform operator enhancement texture processing on the medium resolution layer to obtain a texture-enhanced image; The operator enhanced texture processing method includes: Step 101, respectively calculating the horizontal and vertical gradients of the image of the medium resolution layer; and using the operator to convolve the image to obtain the horizontal gradient and the vertical gradient; Horizontal Gradient ; Vertical Gradient ;in, is the image of the medium resolution layer; Step 102: Calculate the gradient amplitude based on the horizontal gradient and the vertical gradient , as a texture feature map; The calculation formula of gradient amplitude is: ; Step 103: Normalize the gradient amplitude to the range of [0, 1] to obtain a normalized texture feature map. ; Step 104: normalize the texture feature map and Perform weighted fusion to obtain a texture-enhanced image ; The calculation formula of weighted fusion is: ;in, is the weight of the texture feature map; the weight of the texture feature map can be adjusted according to the strength of texture enhancement; The preprocessed traffic image features include texture enhanced images, denoised low-resolution images, and high-resolution layer corresponding images.

[0025] Furthermore, the training method of the convolutional neural network includes: The YOLO algorithm architecture is selected as the basic architecture of the convolutional neural network; the YOLO algorithm architecture includes an input layer, J convolutional layers, a downsampling layer, an upsampling layer, and an output layer; The input layer is used to take the preprocessed traffic image features as network input; the convolution layer is used to extract multi-scale features of the image; each convolution layer is composed of h convolution kernels, which slide on the traffic image features to extract local features; the size of the convolution kernel is set to 3x3 or 1x1, and the step size is 1 or 2; the output of the convolution layer is nonlinearly transformed through the LeakyReLU activation function to obtain a preliminary feature map; A downsampling layer is inserted between the convolutional layers to downsample the preliminary feature map to reduce its size while retaining important features; the downsampling layer uses a pooling layer; the size of the pooling layer is 2x2, and the stride is 2; Use the upsampling layer to upsample the last preliminary feature map and restore its size; the upsampling layer can fuse features of different scales to improve detection accuracy; The output layer is placed at the end of the convolutional neural network, and a convolutional layer is used to generate the final prediction result; the prediction result is a set of image bounding boxes and corresponding category probabilities; the coordinates and size of the image bounding boxes are obtained through regression, and the category probability is calculated by the softmax function; the number of image bounding boxes in a set of image bounding boxes is usually 5.

[0026] It should be explained that the regression is a supervised learning method used to predict continuous value outputs; in target detection, regression is used to predict the bounding box coordinates and size of objects in the image; specifically, the output layer of the convolutional neural network generates a set of values ​​related to the bounding box, usually four parameters, the offset of the x-coordinate of the center point of the predicted bounding box, the offset of the y-coordinate of the center point of the predicted bounding box, the scaling factor of the predicted bounding box width, and the scaling factor of the predicted bounding box height; these parameters are relative to a preset default bounding box; by regressing these parameters, the actual coordinates and size of the predicted bounding box are obtained.

[0027] Collect vehicle images of group A and the corresponding annotation information of the vehicle images as a training data set; the annotation information includes vehicle position, vehicle category, vehicle orientation, vehicle occlusion, vehicle truncation and vehicle unique ID; The position of the vehicle in the image is marked by a bounding box, which is the vehicle position. The bounding box is represented by the coordinates of the upper left corner and the lower right corner, or by the coordinates of the center point and the width and height. It should be noted that the bounding box needs to surround the vehicle as tightly as possible and should not contain too much background area. Label the category to which the vehicle belongs, i.e., the vehicle category, for example, cars, trucks, buses, motorcycles, etc. Each category is represented by a unique integer ID; in order to train the convolutional neural network for classification, it is necessary to assign a corresponding category label to each vehicle instance; The vehicle orientation includes but is not limited to the front, back, and side. The vehicle orientation can help the network better understand the posture and motion state of the vehicle. The vehicle orientation is represented by discrete categories or continuous angle values. Vehicle occlusion is to mark whether the vehicle is partially or completely blocked by other objects (such as other vehicles, trees, buildings, etc.); the occlusion is represented by a binary label (blocked / unblocked) or occlusion ratio (0%, 25%, 50%, 75%, 100%); The vehicle truncation condition refers to whether the vehicle is truncated by the image boundary, that is, part of the vehicle is outside the image; the vehicle truncation condition is represented by a binary label (truncated / untruncated); Each vehicle instance is assigned a unique ID, namely the vehicle unique ID, which is used to track and match the same vehicle in different images. The vehicle's unique ID helps to establish the correspondence between vehicles at different time steps, thereby realizing vehicle tracking and trajectory analysis.

[0028] It should be noted that the annotation information is stored in XML or JSON format, and each vehicle image corresponds to a annotation file corresponding to the annotation information; the annotation file contains the meta information of the vehicle image and the annotation information of each vehicle instance; the meta information includes the file name and size.

[0029] The vehicle images in the training data set are randomly scaled, cropped, and flipped; the vehicle images in the training data set are input into the convolutional neural network to obtain the final prediction results; the function value of the loss function is calculated based on the prediction results and the actual annotation information; Loss Function ; ; ; ; in,( , ) is the bounding box of the annotation The center coordinates of Bounding box for annotation width; Bounding box for annotation The height;( , ) is the bounding box predicted by the network The center coordinates of Bounding box predicted by the network width; Bounding box predicted by the network of high; Represents the index of the bounding box, used to traverse each bounding box; Represents the spatial position index of the feature map, which is used to traverse each pixel position in the feature map; is the weight coefficient of position loss; is the one-hot encoding of the labeled vehicle category, indicating the Is the vehicle category of the bounding box a category? ; To predict the probability of the vehicle category, the bounding box represented by the network prediction Belongs to category probability; is the index of the vehicle category; is the true confidence, indicating Whether a bounding box contains an object; is the confidence of the prediction, indicating the first The confidence that a bounding box contains an object; it needs to be explained that the confidence indicates the probability that the target object is contained in the predicted bounding box; the true confidence is obtained through manual annotation, that is, it is determined according to the degree of overlap between the annotated bounding box and the predicted bounding box; if the degree of overlap between the predicted bounding box and the annotated bounding box is greater than a certain threshold (such as 0.5), the predicted bounding box is considered to contain the target object, and its true confidence is 1; otherwise it is 0; and the predicted confidence is output by the convolutional neural network, indicating the possibility that the bounding box predicted by the network contains the target object; specifically, the output layer of the network will generate a set of prediction values ​​related to the bounding box, including the position coordinates, size and confidence of the bounding box; the predicted confidence is usually a real value between 0 and 1, and the closer it is to 1, the more confident the network is that there is a target object in the bounding box.

[0030] According to the gradient of the function value of the loss function, the Adam optimization algorithm is used to update the weights and biases of the convolutional neural network to minimize the function value of the loss function; Repeat iterative training of the vehicle images in the training data set until the convolutional neural network converges or reaches a preset number of iterations; and obtain a trained convolutional neural network.

[0031] The vehicle characteristic information includes vehicle position, vehicle type, vehicle orientation, vehicle obstruction, vehicle cutoff and vehicle unique ID; The calculation method of the comprehensive similarity between the current frame vehicle and the previous frame vehicle includes: For the current frame The car and the previous frame vehicles, and calculate their similarity in vehicle feature information, i.e., comprehensive similarity; Calculate the vehicle density d of the current frame, that is, the number of vehicles per unit area; Set the vehicle position similarity weight , vehicle category similarity weight , vehicle orientation similarity weight , similarity weight of vehicle occlusion Similarity weight with vehicle cutoff The baseline value of Preset vehicle density threshold interval [d low , d high ]; if the vehicle density d of the current frame is less than or equal to d low , indicating that the scene vehicles are sparse, and the vehicle position similarity weight is increased , reduce the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d in the current frame is greater than or equal to d high , indicating that the scene is densely populated with vehicles, and the vehicle position similarity weight is reduced. , improve the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d of the current frame is within the vehicle density threshold range, maintain - The baseline value remains unchanged; The adjusted weights are applied to the comprehensive similarity calculation; the calculation formula of the comprehensive similarity is: ;in, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle positions, Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle categories, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle orientation; Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle occlusion situations; Indicates the current frame The car and the previous frame The similarity of vehicles in terms of vehicle cutoff conditions; The similarity in vehicle position is measured using the Euclidean distance of the center of the bounding box of the detected vehicle; The similarity of the vehicle category is obtained by The car and the previous frame If the vehicles belong to the same category, the similarity in vehicle category is 1; otherwise, it is 0; ;in, Indicates the current frame The vehicle's heading angle, Indicates the previous frame The direction angle of the vehicle, the range of the direction angle is [0, 360); the greater the direction similarity, the closer the directions of the two vehicles are; ;in, Indicates the current frame The occlusion ratio of the vehicle; Indicates the previous frame The occlusion ratio of the vehicle; Indicates the maximum value of the occlusion ratio, usually 1; ;in, Indicates the current frame The cut-off level of the vehicle; Indicates the previous frame The cut-off level of the vehicle; Indicates the maximum value of the cutoff level; The truncation level is a discrete level, including no truncation, slight truncation, sub-moderate truncation, moderate truncation and severe truncation; 1-5 is used as the level for calculation.

[0032] The method of matching the m-frame vehicles includes: Create a zero matrix of size n1×m1, where n1 represents the number of vehicles in the current frame and m1 represents the number of vehicles in the previous frame; use the comprehensive similarity as the matrix element of the zero matrix to construct a similarity matrix; it should be noted that the process of filling in the matrix elements can be realized by looping through Python calling functions; The similarity matrix is ​​used as the input of the Hungarian algorithm. The Hungarian algorithm optimizes the matching by continuously searching for augmenting paths in the similarity matrix. The augmenting path is a path that alternately passes through unmatched edges and matched edges in the similarity matrix, and the starting point and the end point of the augmenting path are both unmatched vertices. By searching for augmenting paths, the Hungarian algorithm adjusts the current matching scheme until no augmenting paths can be found. Assign a tag value to each row and column of the similarity matrix, and the tag value satisfies that the sum of the weight of the matching edge and the tag value is equal to the matrix element; by adjusting the tag value, the selection of the matching edge is changed to find a better matching solution; after iteration, an optimal matching solution is obtained; the optimal matching solution maximizes the sum of the weights of all matching edges, that is, the maximum weight perfect matching is achieved; The optimal matching solution is V vehicle pairs ( , ) matches successfully, where Indicates the current frame A car, Indicates the previous frame The corresponding relationship between vehicles in consecutive frames is established, and the cross-frame tracking of vehicles is realized; For successfully matched vehicle pairs, their unique vehicle IDs are transmitted to achieve vehicle identity preservation across frames; For vehicles that are not matched in the current frame, it means that they are new vehicles, and new vehicle unique IDs are assigned to them; for vehicles that are not matched in the previous frame, it means that they have left the field of view, and they are removed from the tracking target; the current frame is used as the previous frame of the next match, and the matching is repeated to achieve continuous vehicle tracking; It should be noted that in the similarity matrix, unmatched edges refer to those edges that have not been selected into the current matching scheme; the two vertices connected by these edges (i.e., the vehicle in the current frame and the vehicle in the previous frame) have not been matched; matched edges refer to those edges that have been selected into the current matching scheme; the two vertices connected by these edges have been matched, that is, a certain vehicle in the current frame has established a matching relationship with a certain vehicle in the previous frame; unmatched vertices: Unmatched vertices refer to those vertices that have not been matched, that is, vehicles that have not been matched in the current frame or the previous frame; the weight of the matching edge refers to the weight of the current frame. The car and the previous frame The overall similarity of the vehicles.

[0033] This embodiment improves the accuracy and robustness of vehicle matching and effectively maintains the consistency of vehicle identity by comprehensively considering various feature information; improves the detection capability of vehicles of different sizes and angles through multi-scale feature extraction and fusion; introduces data enhancement and loss function optimization to further improve detection accuracy; performs hierarchical preprocessing on the input vehicle image, effectively improves the image quality, and provides more reliable input for subsequent feature extraction and matching; extracts key frames of the video through inter-frame difference and similarity comparison, and reduces data redundancy; implements multi-scale analysis, which not only compresses the data size but also retains important feature information; while improving tracking accuracy and efficiency, it also greatly reduces the burden of manual labeling.

[0034] Example 2: Please refer to Figure 2 As shown, the part not described in detail in this embodiment is described in Example 1, which provides a vehicle positioning and tracking system based on image recognition, including: The data acquisition and processing module is used to collect road traffic videos; divide the road traffic videos into n frames of traffic image features frame by frame, and pre-process the traffic image features; The vehicle feature detection module is used to detect vehicles based on the pre-processed traffic image features using a pre-trained convolutional neural network, and extract vehicle feature information to obtain m frames of vehicles and corresponding vehicle feature information; The vehicle matching module calculates the comprehensive similarity between the vehicle in the current frame and the vehicle in the previous frame based on the m-frame vehicles and the corresponding vehicle feature information, and uses the Hungarian algorithm to match the m-frame vehicles; each module is connected by wired and / or wireless means to realize data transmission between modules.

[0035] Example 3: Please refer to Figure 3 As shown, this embodiment discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the operation mode of the vehicle positioning and tracking method based on image recognition provided above is implemented.

[0036] Since the electronic device introduced in this embodiment is an electronic device used to implement a vehicle positioning and tracking method based on image recognition in the embodiment of the present application, based on the vehicle positioning and tracking method based on image recognition introduced in the embodiment of the present application, a person skilled in the art can understand the specific implementation of the electronic device of the present embodiment and its various variations, so how the electronic device implements the method in the embodiment of the present application is not described in detail here. As long as a person skilled in the art implements an electronic device used in a vehicle positioning and tracking method based on image recognition in the embodiment of the present application, it belongs to the scope of protection of the present application.

[0037] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters and thresholds in the formula are set by technicians in this field according to actual conditions.

[0038] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technical users in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A vehicle positioning and tracking method based on image recognition, characterized in that: include: S1, collecting road traffic videos; Divide the road traffic video into n frames of traffic image features frame by frame, and preprocess the traffic image features; S2. Detect vehicles on the pre-processed traffic image features using the pre-trained convolutional neural network, and extract vehicle feature information to obtain m frames of vehicles and corresponding vehicle feature information; S3. Based on the m-frame vehicles and the corresponding vehicle feature information, the comprehensive similarity between the current frame vehicle and the previous frame vehicle is calculated, and the m-frame vehicles are matched using the Hungarian algorithm.

2. A vehicle positioning and tracking method based on image recognition according to claim 1, characterized in that: The road traffic video is collected by calling a high-definition camera installed above the road; The method of dividing the road traffic video frame by frame into n frames of traffic image features includes: Decode the road traffic video and convert it into a series of continuous frame sequences; use the inter-frame difference algorithm to calculate the difference between adjacent frames in the frame sequence; The calculation formula of the difference is: ;in, For the The pixel value of the frame; For the +1 frame pixel value; The adjacent frames in the frame sequence and The absolute value of the difference between the pixel values ​​is the difference degree; A difference threshold is preset, and frames with a difference greater than or equal to the difference threshold are marked as candidate key frames; the inter-frame similarity between the candidate key frames is calculated; the calculation formula is: ;in, For two candidate key frames and The inter-frame similarity between For the The pixel value of the frame; Preset a similarity threshold; merge or filter candidate key frames whose similarity is greater than the similarity threshold; obtain a key frame set; The key frame set is generated using the Gaussian pyramid algorithm Layered multi-scale pyramid; The multi-scale pyramid is Frame traffic image features.

3. The vehicle positioning and tracking method based on image recognition according to claim 2 is characterized in that: The multi-scale pyramid generation method includes: For each key frame image in the key frame set, a Gaussian pyramid is constructed. ,in, is the original key frame image, An image of a key frame at the smallest level; The methods for obtaining each layer of the Gaussian pyramid include: Step 1, perform Gaussian smoothing on the key frame image to obtain a smoothed image; The formula for Gaussian smoothing is: ;in, is the Gaussian pyramid after Gaussian smoothing Layer image; For the Gaussian pyramid Layer image; is a two-dimensional Gaussian kernel; is the convolution operation; Step 2: downsample the smoothed image; the downsampling formula is: ;in, is the Gaussian pyramid Layer images; To express Pixel coordinates on the image; Indicated in The coordinates on The pixel value is assigned to ; The size of each layer of the Gaussian pyramid is: , ;in, Indicates The width of the image in the Gaussian pyramid layer; Indicates The height of the image in the layer Gaussian pyramid; Represents the width of the topmost image of the Gaussian pyramid; Indicates the height of the topmost image of the Gaussian pyramid; the topmost layer of the Gaussian pyramid is the image of the original key frame; Define the number of layers of the multi-scale pyramid ;in, To take the smaller value of the original key frame image width and height; To round down.

4. The vehicle positioning and tracking method based on image recognition according to claim 3 is characterized in that: The method of preprocessing the traffic image features includes: Perform layered processing on the multi-scale pyramid; define the top to n / 3 layers of the multi-scale pyramid as low-resolution layers, the n / 3 to 2n / 3 layers of the multi-scale pyramid as medium-resolution layers, and the 2n / 3 to bottom layers of the multi-scale pyramid as high-resolution layers; no preprocessing is performed on the high-resolution layers; The low-resolution layer is denoised using Gaussian filtering to obtain a denoised low-resolution image; the medium-resolution layer is subjected to operator enhancement texture processing to obtain a texture-enhanced image; the pre-processed traffic image features include a texture-enhanced image, a denoised low-resolution image, and an image corresponding to the high-resolution layer.

5. The vehicle positioning and tracking method based on image recognition according to claim 4 is characterized in that: The denoising process includes: Define a Gaussian kernel size of 55 and a standard deviation ; According to the Gaussian kernel size and standard deviation Generate a two-dimensional Gaussian filter; use the two-dimensional Gaussian function to define the weight of the two-dimensional Gaussian filter. The formula of the two-dimensional Gaussian function is: ;in, is the coordinate inside the Gaussian kernel; is a Gaussian filter; Use the generated Gaussian filter to perform convolution operation with the image of the low-resolution layer to obtain a smoothed image; the formula for the convolution operation is: ;in, is the image before smoothing, is the coordinate of the pixel in the image, represents the convolution operation, is the smoothed image; and are the horizontal and vertical coordinates within the Gaussian kernel respectively.

6. The vehicle positioning and tracking method based on image recognition according to claim 5, characterized in that: The operator enhanced texture processing method includes: Step 101, respectively calculating the horizontal and vertical gradients of the image of the medium resolution layer; and using the operator to convolve the image to obtain the horizontal gradient and the vertical gradient; Horizontal Gradient ; Vertical Gradient ;in, is the image of the medium resolution layer; Step 102: Calculate the gradient amplitude based on the horizontal gradient and the vertical gradient , as a texture feature map; The calculation formula of gradient amplitude is: ; Step 103: Normalize the gradient amplitude to the range of [0, 1] to obtain a normalized texture feature map. ; Step 104: normalize the texture feature map and Perform weighted fusion to obtain a texture-enhanced image ; The calculation formula of weighted fusion is: ;in, is the weight of the texture feature map.

7. A vehicle positioning and tracking method based on image recognition according to claim 6, characterized in that: The training method of the convolutional neural network includes: The YOLO algorithm architecture is selected as the basic architecture of the convolutional neural network; the YOLO algorithm architecture includes an input layer, J convolutional layers, a downsampling layer, an upsampling layer, and an output layer; Each convolution layer consists of h convolution kernels, which slide on the traffic image features to extract local features. The size of the convolution kernel is set to 3x3 or 1x1, and the step size is 1 or 2. A downsampling layer is inserted between the convolution layers to downsample the preliminary feature map. The output layer is placed at the end of the convolutional neural network, and a convolutional layer is used to generate the final prediction result; the prediction result is a set of image bounding boxes and corresponding class probabilities; the coordinates and size of the image bounding box are obtained by regression, and the class probability is calculated by the softmax function; Collect vehicle images of group A and the corresponding annotation information of the vehicle images as a training data set; the annotation information includes vehicle position, vehicle category, vehicle orientation, vehicle occlusion, vehicle truncation and vehicle unique ID; The vehicle images in the training data set are randomly scaled, cropped, and flipped; the vehicle images in the training data set are input into the convolutional neural network to obtain the final prediction results; the function value of the loss function is calculated based on the prediction results and the actual annotation information; According to the gradient of the function value of the loss function, the Adam optimization algorithm is used to update the weights and biases of the convolutional neural network to minimize the function value of the loss function; Repeat iterative training of the vehicle images in the training data set until the convolutional neural network converges or reaches a preset number of iterations; and obtain a trained convolutional neural network.

8. The vehicle positioning and tracking method based on image recognition according to claim 7, characterized in that: The loss function ; ; ; ; in,( , ) is the bounding box of the annotation The center coordinates of Bounding box for annotation width; Bounding box for annotation The height;( , ) is the bounding box predicted by the network The center coordinates of Bounding box predicted by the network width; Bounding box predicted by the network of high; The index representing the bounding box; Represents the spatial position index of the feature map; is the weight coefficient of position loss; is the one-hot encoding of the labeled vehicle category, indicating the Is the vehicle category of the bounding box a category? ; To predict the probability of the vehicle category, the bounding box represented by the network prediction Belongs to category The probability of is the index of the vehicle category; is the true confidence, indicating Whether a bounding box contains an object; is the confidence of the prediction, indicating the first The confidence that a bounding box contains an object.

9. The vehicle positioning and tracking method based on image recognition according to claim 8, characterized in that: The vehicle characteristic information includes vehicle position, vehicle type, vehicle orientation, vehicle obstruction, vehicle cutoff and vehicle unique ID; The calculation method of the comprehensive similarity between the current frame vehicle and the previous frame vehicle includes: For the current frame The car and the previous frame vehicles, and calculate their similarity in vehicle feature information, i.e., comprehensive similarity; Calculate the vehicle density d of the current frame, that is, the number of vehicles per unit area; Set the vehicle position similarity weight , vehicle category similarity weight , vehicle orientation similarity weight , similarity weight of vehicle occlusion Similarity weight with vehicle cutoff The baseline value of Preset vehicle density threshold interval [d low , d high ]; if the vehicle density d of the current frame is less than or equal to d low , indicating that the scene vehicles are sparse, and the vehicle position similarity weight is increased , reduce the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d in the current frame is greater than or equal to d high , indicating that the scene is densely populated with vehicles, and the vehicle position similarity weight is reduced. , improve the similarity weight of vehicle occlusion Similarity weight with vehicle cutoff ; If the vehicle density d of the current frame is within the vehicle density threshold range, maintain - The baseline value remains unchanged; the adjusted - Applied to comprehensive similarity calculation; The calculation formula of the comprehensive similarity is: ;in, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle positions, Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle categories, Indicates the current frame The car and the previous frame The similarity of the vehicles in terms of vehicle orientation; Indicates the current frame The car and the previous frame The similarity of vehicles in vehicle occlusion situations; Indicates the current frame The car and the previous frame The similarity of vehicles in terms of vehicle cutoff situations.

10. The vehicle positioning and tracking method based on image recognition according to claim 9, characterized in that: The method of matching the m-frame vehicles includes: Create a zero matrix of size n1×m1, where n1 represents the number of vehicles in the current frame and m1 represents the number of vehicles in the previous frame; use the comprehensive similarity as the matrix element of the zero matrix to construct a similarity matrix; The similarity matrix is ​​used as the input of the Hungarian algorithm, which optimizes the matching by continuously searching for augmenting paths in the similarity matrix. The augmenting path is a path that alternately passes through unmatched edges and matched edges in the similarity matrix, and the starting point and the end point of the augmenting path are both unmatched vertices; by finding the augmenting path, the Hungarian algorithm adjusts the current matching scheme until no augmenting path can be found; Assign a label value to each row and column of the similarity matrix; by adjusting the label value, change the selection of matching edges, and after iteration, obtain an optimal matching solution; The optimal matching solution is V vehicle pairs ( , ) matches successfully, where Indicates the current frame A car, Indicates the previous frame Vehicle; the corresponding relationship between vehicles in consecutive frames is established; For successfully matched vehicle pairs, their vehicle unique IDs are transferred; for vehicles that are not matched in the current frame, new vehicle unique IDs are assigned to them; for vehicles that are not matched in the previous frame, they are removed from the tracking targets; the current frame is used as the previous frame for the next match and the matching is repeated.

Citation Information

Patent Citations

  • Intelligent arithmetic question marking system based on MixNet-YOLOv3 and convolutional recurrent neural network CRNN

    CN112528963A

  • Vehicle tracking method based on unmanned aerial vehicle

    CN112907634A

  • Multi-target tracking method based on Mask R-CNN and apparent feature fusion

    CN113506317A

  • Auxiliary intelligent driving target detection method based on improved YOLOV4

    CN115761697A

  • Multi-target tracking method based on fusion information association and camera motion compensation

    CN117036397A

Cited By

  • AI-based common road traffic OD investigation optimization method

    CN121075117A