Parking space detection method based on vehicle-mounted unmanned aerial vehicle data of YOLOv8n

By optimizing the YOLOv8n model and constructing a spatial channel dual-dimensional attention module and a Light ASPP module, the problem of low accuracy in recognizing small target features in vehicle-mounted drone parking space recognition models was solved, achieving higher precision parking space detection.

CN121708445BActive Publication Date: 2026-04-28AUTOLINK INFORMATION TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AUTOLINK INFORMATION TECHNOLOGY CO LTD
Filing Date
2026-02-11
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing vehicle-mounted drone parking space recognition models have low accuracy in recognizing small target features and are easily affected by noise and background elements. Furthermore, methods to improve recognition accuracy may increase drone operating time or costs.

Method used

A parking space detection method based on YOLOv8n is adopted. By constructing a spatial channel dual-dimensional attention module and a Light ASPP module to optimize the model, the feature extraction capability of the parking space detection model is enhanced. This includes channel attention branch and spatial attention branch. Combined with adaptive window and parking space shape constraints, background interference is filtered and multi-scale adaptability is improved.

Benefits of technology

It improves the accuracy of parking space detection in UAV aerial image data, reduces background interference, enhances the model's ability to recognize small target features, adapts to multi-scale parking space detection, and improves the accuracy of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121708445B_ABST
    Figure CN121708445B_ABST
Patent Text Reader

Abstract

The application provides a YOLOv8n-based vehicle parking space detection method for vehicle-mounted unmanned aerial vehicle data, which can improve the detection accuracy of parking spaces in unmanned aerial vehicle aerial image data and is more practical. The YOLOv8n model is optimized to construct a parking space detection model, the channel attention branch in the spatial channel double-dimension attention module is used to strengthen the channel with a high proportion of markings, the low-frequency interference channel of the background redundancy is inhibited, the subsequent network is more focused on the parking space related features, the spatial attention branch is used to locate the parking space area with a high edge density based on local contrast, the pixel response of the background area is further weakened, the interference of the non-parking space area on the detection result is reduced, and the accuracy of the final detection result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, specifically to a parking space detection method based on vehicle-mounted drone data using YOLOv8n. Background Technology

[0002] In real life, drivers spend an average of more than 15 minutes finding a parking space in large shopping malls, hospitals, and other similar locations, exceeding 30 minutes during peak hours. Traditional parking lots have a turnover rate of less than 60%. Vehicle-mounted drones, however, can achieve high-altitude, full-area scanning, significantly improving parking efficiency and space utilization. Extending the application of vehicle-mounted drones for parking space detection from daily private car parking to scenarios such as transportation hubs and logistics parks can solve the mismatch between the scarcity of parking spaces in older residential areas and the underutilization of parking spaces in commercial areas. It can also leverage 5G+V2X technology to achieve dynamic parking space sharing. Furthermore, it can drive technological iterations in areas such as lightweight drone design and vehicle-to-machine interaction protocols, promoting the formation of a "land-air integrated" intelligent transportation industry ecosystem.

[0003] Currently, some technicians are researching the application of vehicle-mounted drones in collaboration with unmanned or intelligent vehicles for parking space detection. For example, applications CN120469434A and CN121134094A disclose solutions for parking space detection based on drones. The drones have built-in parking space recognition algorithms. While flying at a low altitude of approximately 10-20 meters above the parking area, they collect video or images and then identify parking spaces within the coverage area of ​​the onboard camera based on the algorithm.

[0004] Taking a common commercial 640px×640px resolution camera as an example, when the drone flies at an altitude of 10m, the camera's coverage area, calculated at 92% effective coverage, is approximately 1018m. 2 At this point, the average physical size corresponding to one pixel in the image captured by the camera is approximately 0.052 m / px. When the drone flies at a height of 20 m, the camera covers an area of ​​approximately 2293 m². 2The average physical size of one pixel in an image is approximately 0.078 m / px. Taking a parking space of 6m*2.4m for a small vehicle as an example, the pixel size of the parking space in the image captured by the camera is approximately 32px×68px~48px×102px. This size range falls into the medium to small target category in image recognition technology. Parking space recognition methods primarily rely on the shape of rectangular or diagonally arranged parking lines to determine the boundaries and spatial extent of the parking space. Practical research has revealed that small parking lines are easily interfered with by noise or background elements, leading to problems such as being identified as non-target elements or as non-empty parking spaces. In other words, parking space recognition models based on standard YOLOv8 and other models suffer from problems such as loss of small target features, insufficient background interference suppression, and poor multi-scale adaptability when recognizing small target parking spaces. To improve recognition accuracy, more drone hovering points can be added above the parking area, but this will increase the drone's working time, resulting in low efficiency and high energy consumption. Alternatively, the onboard camera with higher resolution can be replaced, but this will increase the overall cost. Both approaches will affect the application scenarios of the solution. Summary of the Invention

[0005] To address the issue of low accuracy in recognizing small target features using existing drone parking space recognition models, this invention provides a parking space detection method based on YOLOv8n vehicle-mounted drone data. This method can improve the accuracy of parking space detection in drone aerial image data and is more practical.

[0006] The technical solution of this invention is as follows: a parking space detection method based on YOLOv8n vehicle-mounted drone data, characterized by comprising the following steps:

[0007] S1: Construct a spatial channel two-dimensional attention module;

[0008] The spatial channel dual-dimensional attention module includes two parallel branches: a channel attention branch and a spatial attention branch;

[0009] The input data is fed into two branches. The channel attention branch calculates the gradient magnitude of the datum lines in each channel, normalizes it to generate weights, and outputs the feature value F of the channel with the highest proportion of enhanced datum lines. ch Simultaneously, the output is fed into the spatial attention branch; the spatial attention branch calculates the local contrast of the channel attention output, and after normalization, generates the spatial attention normalized weight W. sp ;

[0010] Finally, the feature value F output by the channel attention branch is... ch Spatial attention normalized weight W spMultiplying these values ​​yields the output feature value F of the spatial channel dual-dimensional attention module. lscam ;

[0011] S2: Build the Light ASPP module;

[0012] The Light ASPP module includes: a pre-dimensionality reduction layer, four parallel detection branches, and a feature fusion layer;

[0013] The input data is fed into the pre-dimensionality reduction layer, and the number of channels is reduced in dimensionality and then fed into four parallel detection branches to extract small, medium, large and global feature information respectively. The outputs of the four parallel detection branches are fed into the feature fusion layer. In the feature fusion layer, the features extracted by the four branches are concatenated, and the number of channels is restored to be the same as the input data before being used as the output of the Light ASPP module.

[0014] S3: Construct a parking space detection model based on YOLOv8n;

[0015] The parking space detection model includes: a backbone network, a neck network, a head network, and a post-processing module connected in sequence;

[0016] The spatial channel dual-dimensional attention module is inserted after the third and fourth C2f modules in the backbone network of YOLOv8n to form the backbone network of the parking space detection model; the parking space detection model uses the Light ASPP module to replace the SPPF module in the neck network of the YOLOv8n model.

[0017] The parking space detection model takes as input the parking lot image captured by the airborne camera, and then sends it to the backbone network, the neck network and the head network for processing in sequence. The detection head in the head network sends the recognition result of the parking lot image to the post-processing module.

[0018] After the post-processing module filters out empty parking spaces based on the recognition results, it uses UAV RTK data and the camera intrinsic parameters of the onboard camera to convert pixel coordinates into ground geographic coordinates through a perspective projection model, and assigns an ordered number to each empty parking space as the final detection result.

[0019] S4: Construct a drone aerial photography dataset of parking spaces and divide the dataset into a training set, a validation set, and a test set;

[0020] The parking space detection model is trained using the training set to obtain the trained parking space detection model;

[0021] S5: Configure the trained parking space detection model into the vehicle-mounted drone, and use the vehicle-mounted drone to identify empty parking spaces within the scanning range.

[0022] Its further features are:

[0023] The output feature value F of the channel attention branch ch for:

[0024] F ch (c,i,j)=W ch (c)×F(c,i,j);

[0025] In the formula, F(c,i,j) represents the original features of the Backbone stage received by the spatial channel dual-dimensional attention module; (i,j) represents the pixel coordinates in the input feature map;

[0026] W ch (c) represents the normalized weight value of the c-th channel of the input feature map;

[0027] ;

[0028] In the formula, G c Let c' be the gradient magnitude of the c-th channel, c' be the index used to traverse the channels, and C be the total number of channels in the input feature map.

[0029] ;

[0030] In the formula, G cx Let G be the Sobel gradient in the X direction of the c-th channel. cy Let H be the Sobel gradient of the c-th channel in the Y direction, and H and W be the height and width of the input feature map.

[0031] The channel attention branch also includes a method for filtering channels c in the input feature map. Channels c that pass the filtering process participate in subsequent calculations, while channels c that do not pass the filtering process do not participate in subsequent calculations. Specifically, it includes the following steps:

[0032] a1: Set the dynamic threshold Tc:

[0033] ;

[0034] In the formula, For the gradient magnitude G of all channels c The mean value, std(G) is the channel gradient magnitude G. c The standard deviation of , where α and β are scene coefficients;

[0035] a2: Calculate the gradient magnitude G of each of the aforementioned calipers. c Compare with the dynamic threshold Tc;

[0036] When G c When Tc is greater than or equal to Tc, the corresponding channel c participates in subsequent calculations;

[0037] Otherwise, the gradient magnitude G of the corresponding channel c is... c The value is assigned a preset low-weight value;

[0038] The spatial attention normalization weight W output by the spatial attention branch sp for:

[0039] ;

[0040] In the formula, (i,j) are the coordinates of the target pixel in the input feature map; H and W are the height and width of the input feature map; (i',j') are the indices of the traversed pixels; C(i,j) is the local contrast value at pixel (i,j) in the input feature map; σ() is the Sigmoid function;

[0041] ;

[0042] In the formula, Ω(i,j) represents a local region window centered at (i,j); (x,y)∈Ω(i,j) represents traversing all pixels within the local window; and (x,y) are the coordinates of the pixels traversed within the local window Ω(i,j).

[0043] F ch (x,y) represents the feature value of pixel (x,y) within the window in the feature map output by the channel attention branch;

[0044] max (x,y)∈Ω(i,j) F ch (x,y) represents all F values ​​within the local window Ω(i,j). ch The maximum value of (x,y), the most significant characteristic response;

[0045] min (x,y)∈Ω(i,j) F ch (x,y) represents all F values ​​within the local window Ω(i,j). ch The minimum value of (x,y), the weakest characteristic response;

[0046] The spatial attention branch also includes: adaptive window constraints;

[0047] The adaptive window constraint dynamically adjusts the size of the local region window Ω(i,j) based on the drone's aerial photography altitude, setting the window size win_size to be linearly related to the height h.

[0048] win_size=3+2×floor((20-h) / 5);

[0049] In the formula, h is the actual altitude of the drone, and floor() is the floor function;

[0050] The spatial attention branch also includes: parking space shape constraint. This constraint involves calculating the local contrast C(i,j), then verifying the rectangle size and aspect ratio of high-contrast regions suspected of being parking spaces. Only pixels (i,j) within these verified high-contrast regions are included in the subsequent spatial attention normalization weight W. sp In the calculation, pixels (i,j) in regions that fail the verification are not included in subsequent calculations;

[0051] The steps for defining the shape of the parking space include:

[0052] b1: Compare the calculated local contrast C(i,j) with the dynamic threshold Tc;

[0053] If C(i,j) ≥ Tc, then the corresponding pixel (i,j) is determined to be a high-contrast pixel;

[0054] Otherwise, it is determined to be a non-high contrast pixel and will not be included in subsequent calculations;

[0055] b2: For all the high-contrast pixels, use an edge detection algorithm to extract the region contour, denoted as: suspected region contour;

[0056] b3: Extract the contour of each of the suspected regions one by one, and denot it as: the contour of the region to be processed;

[0057] The total number of pixels contained within the outline of the region to be processed is counted and denoted as: the actual area of ​​the suspected region;

[0058] b4: For the outline of the region to be processed, find the smallest bounding rectangle that can completely enclose the actual area of ​​the suspected region using a rotating rectangle fitting algorithm;

[0059] The minimum bounding rectangle is a rectangular region that ensures the smallest possible area and completely includes the outline of the region to be processed.

[0060] b5: Calculate the rectangularity of the minimum bounding rectangle;

[0061] Rectangularity = Actual area of ​​the suspected region / Area of ​​the minimum bounding rectangle;

[0062] b6: Compare the rectangle size with a preset rectangle size threshold;

[0063] When the rectangle degree is greater than or equal to the rectangle degree threshold, step b7 will be executed on the corresponding outline of the region to be processed.

[0064] Otherwise, the outline of the region to be processed will not be included in subsequent calculations;

[0065] b7: Obtain the minimum bounding rectangle corresponding to the outline of the region to be processed, extract the width W and height H, and calculate the aspect ratio;

[0066] Aspect ratio = Width W / Height H;

[0067] b8: When the aspect ratio meets the following filtering conditions, the outline of the area to be processed is determined to have passed the verification of the parking space shape constraint and is included in subsequent calculations; otherwise, it is determined to have failed the verification.

[0068] The filtering criteria are: ARmin ≤ aspect ratio ≤ ARmax;

[0069] Where ARmin is the preset minimum aspect ratio and ARmax is the preset maximum aspect ratio;

[0070] In the Light ASPP module, the pre-dimensionality reduction layer performs dimensionality reduction on the number of channels of the input data based on 1×1 convolution.

[0071] The detection branches include: small size detection branch, medium size detection branch, large size detection branch, and global information detection branch;

[0072] The small-size detection branch is implemented based on 1×1 convolution;

[0073] The mid-size detection branch is implemented based on a 3×3 dilated convolution with a dilation rate of 3.

[0074] The large-size detection branch is implemented based on a 3×3 dilated convolution with a dilation rate of 5.

[0075] The global information detection branch includes: a global average pooling, a 1×1 convolution, and an upsampling operation connected in sequence;

[0076] The feature fusion layer concatenates the features output from the four detection branches, restores them to the same dimension as the input data through a 1×1 convolution, and then outputs them.

[0077] The operations performed in the post-processing module include the following steps:

[0078] c1: Receives the parking space recognition result output by the head network;

[0079] The recognition results include: target bounding box, target category, and confidence score;

[0080] The target categories include: empty parking spaces, vehicles, obstacles, and pedestrians;

[0081] c2: Read the preset confidence threshold and retain the recognition results whose confidence scores are greater than or equal to the confidence threshold;

[0082] c3: Read the preset intersection-union ratio threshold, and perform non-maximum suppression on the target bounding box of the recognition result using the intersection-union ratio threshold to remove overlapping redundant boxes; in the remaining data, the recognition result of the target category being empty parking space is recorded as: empty parking space recognition result;

[0083] c4: For each of the above-mentioned empty parking space identification results, the pixel coordinates are converted into ground geographic coordinates using the UAV RTK data and the camera intrinsic parameters of the airborne camera through a perspective projection model;

[0084] c5: Sort all the empty parking space identification results based on ground geographic coordinates.

[0085] This application provides a parking space detection method based on YOLOv8n vehicle-mounted drone data. It optimizes the YOLOv8n model to construct a parking space detection model. A spatial channel dual-dimensional attention module is inserted after the third and fourth C2f modules in the backbone. The channel attention branch in the spatial channel dual-dimensional attention module strengthens channels with high marking proportions and suppresses redundant low-frequency interference channels in the background, allowing subsequent networks to focus more on parking space-related features. The spatial attention branch locates high-edge-density parking space regions based on local contrast, further weakening the pixel response of background regions and reducing the interference of non-parking space regions on the detection results. This lays a high-quality feature foundation for multi-scale feature fusion in the Neck stage and parking space localization in the Head stage. The Light ASPP module replaces the SPPF module in the Neck network to avoid the loss of small target features. The module incorporates four detection branches. First, it captures characteristic information for small, medium, and large targets. A fourth branch supplements this with global information, suppressing background redundancy and enabling multi-scale adaptability. This improves the accuracy of parking space detection in UAV aerial image data, making the solution more practical. Furthermore, a dynamic threshold Tc is designed in the channel attention branch, which only considers the gradient magnitude G of the feature point's markings. c Only channels with a value greater than or equal to the threshold Tc participate in the calculation. Channels with a value less than the threshold Tc are directly assigned a preset low weight, which can effectively filter out high-frequency noise channels in the background and improve the accuracy of the detection results. In this application, adaptive window size adjustment and parking space shape constraint filtering are also used in the spatial attention branch. The adaptive window size is dynamically adjusted according to the drone's aerial photography altitude to avoid missing parking space edges. The parking space shape constraint filtering operation reduces the spatial weight of non-parking space areas, improves the positioning accuracy of spatial attention, and thus improves the accuracy of the final detection results. Attached Figure Description

[0086] Figure 1 This is a schematic diagram of the backbone network structure of the parking space detection model in this application;

[0087] Figure 2 This is a schematic diagram of the spatial channel dual-dimensional attention module structure of the parking space detection model in this application;

[0088] Figure 3 This is a schematic diagram of the Light ASPP module in this application;

[0089] Figure 4 The diagram shows the detection effect of the parking space detection model; 4a shows the detection effect of small targets, 4b shows the detection effect of the oblique angle image, and 4c shows the detection effect of the oblique parking space. Detailed Implementation

[0090] The present invention includes a parking space detection method based on YOLOv8n vehicle-mounted drone data, which includes the following steps.

[0091] S1: Construct a lightweight spatial-channel attention module (LSCAM).

[0092] Aerial images possess two image features: parking space markings (high frequency) and background (low frequency interference). This solution optimizes the differences between these two types of image features by constructing a lightweight spatial-channel attention module (LSCAM-DGTSCW) with dynamic gradient threshold and adaptive shape-constrained window. Targeted optimization is performed in both the channel and spatial dimensions.

[0093] In the channel dimension, the intensity of the markings is quantified by gradient magnitude to enhance the channels containing marking features and suppress redundant background channels; in the spatial dimension, the high edge density parking space area is located by local contrast to reduce background interference such as grass and shadows.

[0094] like Figure 2 As shown, the spatial channel dual-dimensional attention module includes two parallel branches: the channel attention branch and the spatial attention branch;

[0095] The input data is fed into two branches. The channel attention branch calculates the gradient magnitude of the datum lines in each channel, normalizes it to generate weights, and outputs the feature value F of the channel with the highest proportion of enhanced datum lines. ch Simultaneously, the output is fed into the spatial attention branch; the spatial attention branch calculates the local contrast of the channel attention output, normalizes it to generate weights, and suppresses background interference. Specifically, after normalization, it generates spatial attention normalized weights W. sp Finally, the feature values ​​F output by the channel attention branch are... ch Spatial attention normalized weight W sp Multiplying these together yields the output feature value F of the spatial channel two-dimensional attention module. lscam .

[0096] F lscam (i,j)=W sp (i,j)×F ch (i,j);

[0097] In the formula, (i,j) are the pixel coordinates in the input feature map.

[0098] The output feature value F of the channel attention branch ch for:

[0099] F ch (c,i,j)=W ch (c)×F(c,i,j);

[0100] In the formula, F(c,i,j) represents the original features of the Backbone stage received by the spatial channel dual-dimensional attention module.

[0101] In this application, the two spatial channel dual-dimensional attention modules are set after the third and fourth C2f modules of the Backbone, respectively. Then F(c,i,j) corresponds to the output of the third C2f module and the output of the fourth C2f module, respectively.

[0102] W ch (c) represents the normalized weight value of the c-th channel of the input feature map, mapped using Softmax; and through W... ch (c) Give higher weight to channels with rich gradation features and strengthen effective feature channels.

[0103] ;

[0104] In the formula, G c Let c' be the gradient magnitude of the c-th channel, c' be the index used to traverse the channels, and C be the total number of channels in the input feature map.

[0105] Channel Marker Gradient Magnitude G c: Used to quantify the feature richness of each channel's gradation, G c The larger the value, the richer the edge features of the corresponding lane including parking space markings.

[0106] ;

[0107] In the formula, G cx Let G be the Sobel gradient in the X direction of the c-th channel. cy Let G be the Sobel gradient in the Y direction of the c-th channel. cx and G cy Calculated using the Sobel-X operator. (i,j) are the pixel coordinates in the input feature map; H and W are the height and width of the input feature map.

[0108] In existing technologies, channel attention is achieved by calculating the mean value G of the channel gradient magnitude. c This method is used to determine the richness of road markings, but when there is high-frequency noise in the background (such as a flooded road surface), it is easy to mistakenly identify the noise channel as a high-value channel. In order to filter out high-frequency noise channels in the background, the channel attention branch of this application also includes a method for filtering channels c in the input feature map. Channels c that pass the filtering participate in subsequent calculations, while channels c that do not pass the filtering do not participate in subsequent calculations; specifically, it includes the following steps.

[0109] a1: Set the dynamic threshold Tc:

[0110] ;

[0111] In the formula, For the gradient magnitude G of all channels c The mean value, std(G) is the channel gradient magnitude G. c The standard deviation of the standard deviation is given, where α and β are scene coefficients. In practice, α and β are adaptively adjusted through training set statistics. During the statistical analysis, it is ensured that the scene coefficients meet preset standards for both noise filtering rate and useful information retention rate under normal scenes, complex lighting scenes, and extreme interference scenes. In this embodiment, α is set to 1.3 and β is set to 0.4.

[0112] a2: Set the gradient magnitude G of each caliper line. c Compare with the dynamic threshold Tc;

[0113] When G c When Tc is greater than or equal to Tc, the corresponding channel c participates in subsequent calculations;

[0114] Otherwise, the gradient magnitude G of the corresponding channel c will be... c The value is assigned a preset low weight value to filter out high-frequency noise channels in the background. In this embodiment, the low weight value is set to 0.1.

[0115] Spatial attention normalized weight W of the spatial attention branch output sp The calculation method is shown below.

[0116] W sp (i,j) represents the spatial attention normalization weight at pixel (i,j) in the input feature map, W sp The larger the (i,j) value, the higher the weight, the higher the probability that the corresponding pixel belongs to the parking space area, and the stronger the contribution of the pixel in subsequent feature calculations.

[0117] The spatial attention weight normalization operation maps the spatial attention output to [0,1] using a sigmoid function:

[0118] ;

[0119] In the formula, (i,j) are the coordinates of the target pixel in the input feature map; H and W are the height and width of the input feature map;

[0120] i' and j' are the indices of the traversed pixels. (i',j') is distinct from the target pixel (i,j). Its function is to normalize the weights of all pixels to a range where the sum is 1, ensuring the comparability of the weights; σ() is the Sigmoid function.

[0121] C(i,j) is the local contrast value at pixel (i,j) in the input feature map. Because the lane lines have high contrast compared to the background, the lane lines are located and then the parking space area is located by the local contrast value C(i,j). The larger C(i,j) is, the more significant the parking space features in the area where the pixel is located, such as the gray difference between the parking space markings and the road surface. Conversely, it is likely to be the background area.

[0122] ;

[0123] In the formula, Ω(i,j) is a local region window centered at (i,j); (x,y)∈Ω(i,j) represents traversing all pixels within the local window Ω(i,j); and (x,y) are the coordinates of the traversed pixels within the local window Ω(i,j).

[0124] F ch (x,y) represents the feature value of pixel (x,y) within the window in the feature map output by the channel attention branch;

[0125] max (x,y)∈Ω(i,j) F ch (x,y) represents all F values ​​within the local window Ω(i,j). ch The maximum value of (x,y) corresponds to the most significant feature response;

[0126] min (x,y)∈Ω(i,j) Fch (x,y) represents all F values ​​within the local window Ω(i,j). ch The minimum value of (x,y) corresponds to the weakest characteristic response.

[0127] Existing spatial attention technologies mostly use a fixed 3×3 window to calculate local contrast, which has problems such as "small windows missing narrow parking space edges" and "large windows mistakenly merging adjacent parking spaces for judgment". In this method, the spatial attention branch is optimized in two aspects, taking into account the shape characteristics of the parking space "rectangular with a width-to-height ratio of ≈1:2.12": adaptive window constraint optimization and parking space shape constraint optimization.

[0128] Specifically, an adaptive window constraint is set in the spatial attention branch; the adaptive window constraint dynamically adjusts the size of the local region window Ω(i,j) according to the drone's aerial photography altitude, and sets the size of the local region window win_size to be linearly related to the height.

[0129] In this embodiment, when the drone altitude is 20m (parking space pixel size 32×68), a 5×5 window is used to cover the entire horizontal width of the parking space, avoiding missing the edges of the parking space; when the altitude is 10m (parking space pixel size 48×102), a 7×7 window is used to balance the vertical length of the parking space and the distinguishability of adjacent parking spaces; the altitude is obtained in real time through drone RTK (Real-Time Kinematic) data, and the window size win_size is linearly related to the altitude. For example, for every 5m decrease in altitude, the window side length increases by 2.

[0130] win_size=3+2×floor((20-h) / 5);

[0131] In the formula, h is the actual altitude of the drone, and floor() is the floor function.

[0132] In this embodiment, the drone flies at low altitude, so the value of h is: 10m≤h≤20m.

[0133] The spatial attention branch also includes: parking space shape constraints. After calculating the local contrast C(i,j), the rectangle and aspect ratio of high-contrast regions suspected of being parking spaces are checked. Only pixels (i,j) within these high-contrast regions that pass the check are included in the subsequent spatial attention normalization weight W. sp In the calculation, pixels (i,j) in regions that fail the verification are not included in subsequent calculations.

[0134] The steps for defining the shape of a parking space include:

[0135] b1: Obtain the dynamic threshold Tc calculated in step a1, and compare the calculated local contrast C(i,j) with the dynamic threshold Tc;

[0136] If C(i,j) ≥ Tc, then the corresponding pixel (i,j) is determined to be a high-contrast pixel;

[0137] Otherwise, it is determined to be a non-high contrast pixel and will not be included in subsequent calculations.

[0138] b2: For all high-contrast pixels, use an edge detection algorithm to extract the region contour, denoted as: suspected region contour;

[0139] There are many edge detection algorithms available in the prior art that can be used to extract region contours, such as the Prewitt operator, Laplacian of Gaussian, Canny edge detector, and Laplacian operator. In this embodiment, the classic Canny operator is used to extract the region contour.

[0140] b3: Extract the outline of each suspected region one by one, and denot it as: the outline of the region to be processed;

[0141] The total number of pixels contained within the outline of the region to be processed is recorded as: the actual area of ​​the suspected region.

[0142] b4: For the outline of the region to be processed, find the smallest bounding rectangle that can completely enclose the actual area of ​​the suspected region by using a rotating rectangle fitting algorithm;

[0143] The minimum bounding rectangle is a rectangular region that ensures the smallest possible area and completely includes the outline of the region to be processed.

[0144] b5: Calculate the rectangularity of the minimum bounding rectangle;

[0145] Rectangularity = Actual area of ​​the suspected region / Area of ​​the smallest bounding rectangle.

[0146] b6: Compare the rectangle size with the preset rectangle size threshold;

[0147] When the rectangle size is greater than or equal to the rectangle size threshold, the corresponding region to be processed will be processed in step b7.

[0148] Otherwise, the outline of the region to be processed will not participate in subsequent calculations. In this embodiment, the rectangularity threshold is set to 0.8.

[0149] This method calculates the rectangularity of suspected regions by contour fitting, and retains only regions with a rectangularity ≥ 0.8, thereby eliminating irregular background interference, such as tree projections and pedestrian shadows.

[0150] b7: Obtain the minimum bounding rectangle corresponding to the outline of the region to be processed, take the longer side as W and the shorter side as H, extract the width W and height H, and calculate the aspect ratio;

[0151] Aspect ratio = Width W / Height H;

[0152] b8: When the aspect ratio meets the following filtering conditions, the outline of the area to be processed is determined to have passed the parking space shape constraint verification and will be included in subsequent calculations; otherwise, it is determined to have failed the verification.

[0153] The filtering criteria are: ARmin ≤ aspect ratio ≤ ARmax;

[0154] Where ARmin is the preset minimum aspect ratio and ARmax is the preset maximum aspect ratio.

[0155] The specific filtering criteria are set according to the standard size of the parking space. For example, the most common standard size of parking space for small cars commonly used in urban spaces is 5.3m long × 2.4m or 2.5m wide, corresponding to a width-to-height ratio of 1:2.2 or 1:2.12. The filtering criteria are set as: 1.8 ≤ width-to-height ratio ≤ 2.4.

[0156] In this application, the shape constraint of the parking space is used to make the pixels in the area that passes the constraint verification participate in the spatial attention weight normalization calculation, which further reduces the spatial weight of the non-parking space area and improves the positioning accuracy of spatial attention.

[0157] like Figure 1 As shown, the input of the dual-dimensional lightweight attention enhancement module LSCAM in this application is the feature map output by a specific stage of the YOLOv8n model Backbone, specifically the feature map output by Stage 3 with dimensions of 80×80×256 feature channels and the feature map output by Stage 4 with dimensions of 40×40×512.

[0158] From the perspective of feature map characteristics, Stage 3 of the YOLOv8n model is a shallow feature output with a high resolution (80×80), preserving rich edge details of small targets. Parking spaces in drone aerial photography scenarios are small and medium targets (pixel size 32×68~48×102), and their marking edge features are clearer in the shallow feature map, which can directly provide accurate initial feature basis for subsequent attention calculation. Stage 4 is a medium feature output with a resolution reduced to 40×40, but the number of channels is increased to 512, resulting in stronger feature expression capabilities. While preserving the key features of the parking space, it can initially suppress some background noise, forming a complement to the Stage 3 feature map in terms of detail and semantics, and providing multi-level feature input for dual-dimensional attention enhancement.

[0159] The output of the LSCAM (Laser-Channel-Based Attention Enhancement) module is a feature map enhanced by LSCAM's two-dimensional attention, with dimensions identical to the input feature map: in Stage 3, the input and output feature maps of the spatial channel two-dimensional attention module have the same dimensions, 80×80×256; in Stage 4, the input and output feature maps of the spatial channel two-dimensional attention module have the same dimensions, 40×40×512. The spatial channel two-dimensional attention module added to Stages 3 and 4 of the YOLOv8n model in this application only redistributes pixel weights within the feature map, without changing the spatial and channel dimensions of the feature map. The core advantage of the feature map output by the spatial channel two-dimensional attention module is:

[0160] In terms of channel dimension, the channel weights of high-frequency features containing parking space markings were strengthened, while low-frequency interference channels such as background redundancy represented by grass and shadows were suppressed, making the subsequent network more focused on parking space-related features.

[0161] In the spatial dimension, the high edge density parking space area is located by local contrast, which further weakens the pixel response of the background area and reduces the interference of non-parking space areas on the detection results, laying a high-quality feature foundation for the multi-scale feature fusion in the subsequent Neck stage and parking space localization in the Head stage.

[0162] S2: Build the Light ASPP module;

[0163] like Figure 3 As shown, the Light ASPP module includes: a pre-dimensionality reduction layer, four parallel detection branches, and a feature fusion layer; the operations in the Light ASPP module follow the order of pre-dimensionality reduction, four-branch parallel processing, splicing and fusion, and dimension restoration.

[0164] The input data is fed into the pre-dimensionality reduction layer, which reduces the number of channels and then feeds them into four parallel detection branches to extract small, medium, large, and global feature information, respectively. The outputs of the four parallel detection branches are fed into the feature fusion layer, where the features extracted by the four branches are concatenated and the number of channels is restored to be the same as the input data before being used as the output of the Light ASPP module.

[0165] In this application, a lightweight ASPP module, or Light ASPP module, is constructed based on the existing ASPP (Atrous Spatial Pyramid Pooling) module. In the Light ASPP module of this application, the pre-reduction layer uses a 1×1 convolution to reduce the number of channels in the input data; in this embodiment, the pre-reduction layer reduces the number of channels in the input data from 512 to 128 using a 1×1 convolution. Compared with the existing ASPP module, the Light ASPP module adds a pre-reduction layer to reduce the dimensionality of the input data, which can significantly reduce the subsequent computational load.

[0166] The detection branches include: small size detection branch, medium size detection branch, large size detection branch, and global information detection branch;

[0167] The small-size detection branch is implemented based on 1×1 convolution to capture the core details of small-size parking spaces;

[0168] The mid-size detection branch is implemented based on a 3×3 dilated convolution with a dilation rate of 3, capturing the edge context of mid-size parking spaces;

[0169] The large-size detection branch is implemented based on 3×3 dilated convolution with a dilation rate of 5, capturing information about the boundary between large parking spaces and the background.

[0170] Compared to the five branches of the existing ASPP model, the Light ASPP module simplifies one branch with a large void ratio, reducing the number of parameters and making it more suitable for embedded platform applications on UAVs. Furthermore, based on the actual needs of parking space detection, the Light ASPP module customizes the void ratios of the medium-size and large-size detection branches to small void ratios of d=3 and d=5, respectively, making it more suitable for target detection in UAV aerial images. This also reduces computational load, better meeting the time-sensitive requirements of parking space detection.

[0171] The global information detection branch includes sequentially connected global average pooling, 1×1 convolution, and upsampling operations, which supplement global information while suppressing background redundancy.

[0172] The feature fusion layer concatenates the 40×40×128 features from the outputs of the four detection branches, restores them to the same dimension as the input data through a 1×1 convolution, and outputs them to the subsequent PAN-FPN.

[0173] The dilated convolution formula in this application is based on the standard formula. Taking a dilation rate of d=3 as an example, it is as follows:

[0174] ;

[0175] Among them, F d=3(i,j) is the output feature value, the final feature value at pixel (i,j) on the feature map after dilated convolution with a dilation rate of d=3; k and l are the kernel indices, the row and column indices of the 3×3 convolution kernel, with values ​​of -1, 0, and 1, respectively, to cover the 9 parameter positions of the 3×3 convolution kernel; W(k,l) is the 3×3 convolution kernel weight, the parameters obtained through adaptive learning based on the training process. The specific training method is based on existing technology, and AdamW is used as the optimizer in this embodiment; F in The input feature map is dimensionality reduced; (i+k×d,j+l×d) are the sampling coordinates, which are the actual sampling positions of the dilated convolution on the input feature map. The receptive field is expanded by interval sampling, rather than reducing the resolution.

[0176] This solution replaces the SPPF module in the original YOLOv8n Neck with the Light ASPP module. The input is a 40×40×512 feature map output from Stage4, while the output resolution remains 40×40, and the number of parameters is ≤0.2M.

[0177] The receptive field (RF) is calculated as follows: RF = (d × (k - 1)) + 1;

[0178] In the formula, d is the void ratio, and k is the basic convolution kernel;

[0179] In this embodiment, the convolution kernel k is set to 3, i.e., a 3×3 convolution kernel is used; thus, we can obtain: d=1, k=3, RF=3; d=3, k=3, RF=7; d=5, k=3, RF=11. In the Light ASPP module constructed in this application, the receptive field is expanded in the detection branch by the porosity d.

[0180] This solution uses global average pooling, 1×1 convolution, and upsampling operations in the global information detection branch of the Light ASPP module to capture scene-level global information. Combined with other multi-branch dilated convolutions, it accurately depicts the boundary between parking spaces and the background, further distinguishing the edges of parking spaces from the edges of the background, such as the boundary between parking space markings and grass, avoiding the background area being misjudged as a parking space, and thus avoiding the loss of small target features.

[0181] S3: In this application, a parking space detection model is constructed based on YOLOv8n. Specifically, the backbone of YOLOv8n is optimized through a spatial channel dual-dimensional attention module, and the neck network of YOLOv8n is optimized through a Light ASPP module. At the same time, a post-processing module is added after the head network of the YOLOv8n model to specifically process the unique output requirements of parking space detection. The other parts are the same as the structure of the standard YOLOv8n model.

[0182] The parking space detection model in this application includes: a backbone network, a neck network, a head network, and a post-processing module connected in sequence.

[0183] The structure of the backbone network of the parking space detection model is as follows: Figure 1 As shown, a spatial channel two-dimensional attention module is inserted after the third and fourth C2f modules in the YOLOv8n backbone network; the SPPF module in the YOLOv8n neck network is replaced with the Light ASPP module.

[0184] The third C2f module in the backbone network outputs shallow features of 80×80×128 containing small target edge details, and the fourth C2f module outputs feature information of 40×40×256. After inserting a spatial channel dual-dimensional attention module, the number of parameters is only about 2k.

[0185] The parking space detection model takes as input images of parking lots captured by an airborne camera. These images are then processed sequentially by the backbone network, the neck network, and the head network. The head network then sends the recognition results of the parking lot images to the post-processing module.

[0186] After the post-processing module filters out empty parking spaces based on the recognition results, it uses UAV RTK data and the camera intrinsics of the onboard camera to convert pixel coordinates into ground geographic coordinates through a perspective projection model. Each empty parking space is then assigned an ordered number as the final detection result. The UAV RTK data includes latitude, longitude, altitude, and attitude angles.

[0187] Images captured by the drone are processed sequentially through the backbone network, neck network, and head network. The head network's output stage generates a large number of candidate parking space bounding boxes (including empty parking spaces, non-empty parking spaces, overlapping boxes, and false positives). This application includes a post-processing module that uses confidence thresholding and non-maximum suppression (NMS) for multiple filtering to ensure that only true empty parking space bounding boxes are retained. The operations performed in the post-processing module include the following steps.

[0188] c1: Receives the parking space recognition result output by the head network;

[0189] The identification results include: target bounding box, target category, and confidence score;

[0190] Target categories include: empty parking spaces, vehicles, obstacles, and pedestrians.

[0191] c2: Read the preset confidence threshold and retain the recognition results with confidence scores greater than or equal to the confidence threshold.

[0192] The confidence threshold is used to balance recall and precision, and its specific value is determined based on statistical analysis of drone aerial photography samples. In this embodiment, after statistical verification using 10,000 drone aerial photography samples, the confidence threshold is set to 0.5; candidate boxes with a confidence score < 0.5 are directly filtered out. Based on the statistical analysis of actual collected sample data, it is known that candidate boxes with a confidence score < 0.5 are mostly misjudgments by the model of blurred backgrounds such as water reflections or accumulated leaves. Retaining them would significantly increase the unnecessary computational load of subsequent coordinate transformations, so they need to be removed.

[0193] c3: Read the preset Intersection over Union (IoU) threshold, and perform non-maximum suppression on the target bounding boxes of the recognition results using the IoU threshold to remove overlapping redundant boxes; then find all the recognition results of the target category as empty parking spaces in the remaining data and record them as: empty parking space recognition results;

[0194] Because the spacing between adjacent parking spaces is small from the drone's aerial perspective, with an average pixel spacing of 5-10px, an IoU threshold that is too high (e.g., >0.5) can easily lead to real adjacent parking spaces being misjudged as overlapping boxes and deleted; an IoU threshold that is too low (e.g., <0.2) cannot effectively remove duplicate predicted boxes for the same parking space. In this embodiment, the intersection-union ratio (IU) threshold is set to 0.3, which ensures that 98% of the real parking space boxes are retained while ≥92% of overlapping redundant boxes are removed.

[0195] c4: For each empty parking space identification result, using UAV RTK data and the camera intrinsics of the onboard camera, the pixel coordinates are converted into ground geographic coordinates through a perspective projection model. The specific method for converting pixel coordinates to ground geographic coordinates can be implemented based on existing technology. In this embodiment, the camera intrinsic matrix K is first obtained, and then the pixel coordinates are connected to the camera coordinate system;

[0196] ;

[0197] Among them, f x =f / dx, f y =f / dy, where f is the focal length, and dx and dy are the pixel dimensions;

[0198] c x and c y Principal point coordinates: In this embodiment, the principal point coordinates of a 640×640 image are (320, 320) by default.

[0199] Convert the camera coordinate system to the ground coordinate system to achieve latitude and longitude conversion:

[0200] ;

[0201] Where Lon is the ground longitude of the parking space, one of the final output geographic coordinates; Lat is the ground latitude of the parking space, one of the final output geographic coordinates. Lon0 is the longitude of the vehicle-mounted drone itself, serving as the reference starting point for coordinate transformation; Lat0 is the latitude of the vehicle-mounted drone itself, serving as the reference starting point for coordinate transformation; X g Y represents the eastward distance of the parking space relative to the drone (in meters); g 111319.9 is the northward distance of the parking space relative to the drone (in meters); 111319.9 is the conversion factor of the Earth's equatorial circumference (approximately 40076 km) divided by 360 degrees, representing "the number of meters corresponding to each degree of latitude / longitude", indicating an approximate value near the equator; π / 180 is the conversion factor for angles (degrees) to radians, used to meet the input requirements for calculating the trigonometric function cos.

[0202] In the post-processing module, the pixel coordinates of the parking spaces in the drone aerial image are converted into distances (X) in the camera coordinate system using camera intrinsic parameters. g Y g The pixel parking space is ultimately mapped to the geographic latitude and longitude coordinates in the real world, thus achieving a precise correspondence between the pixel parking space and the physical parking space, providing a spatial positioning basis for subsequent parking space numbering and navigation scheduling.

[0203] c5: Sort all the empty parking space identification results based on ground geographic coordinates.

[0204] The sorting method in this embodiment is as follows: unique numbers are assigned in ascending order from east (Lon) and north (Lat) to ensure that the numbers correspond one-to-one with the actual locations and to avoid interference from image distortion.

[0205] S4: Construct a drone aerial photography dataset of parking spaces and divide the dataset into a training set, a validation set, and a test set;

[0206] The parking space detection model is trained using the training set to obtain a well-trained parking space detection model.

[0207] S5: Configure the trained parking space detection model into the vehicle-mounted drone, and use the drone to identify empty parking spaces within the scanning range. The 640×640×3 image data (640px long, 640px wide, RGB format) collected by the drone's onboard camera is fed into the parking space detection model. After passing through the Backbone (CSPDarknet-8n + LSCAM), Neck (PAN-FPN + Light-ASPP), and Head of the parking space detection model, it is sent to the post-processing module. After empty parking space filtering, coordinate transformation, and numbering, the module outputs the empty parking space number, geographical coordinates, and confidence score.

[0208] like Figure 4The image shows an example of the detection results of the parking space detection model trained in this application on arbitrary drone aerial photography of parking lots. Empty parking spaces are marked with green boxes, and non-empty parking spaces with purple boxes. 4a shows the detection effect of small targets from a top-down view, 4b shows the detection effect of an angled image, 4a shows a row of parking spaces with a curved shape, 4b shows a matrix arrangement of parking spaces, and 4c shows the detection effect of diagonally arranged parking spaces. It can be seen that the solution in this application can achieve good detection results for common drone aerial photography of parking lots.

[0209] The parking space detection model in this application enhances key details of small targets through the lightweight spatial channel dual-dimensional attention module LSCAM and expands the scale receptive field through Light-ASPP, significantly improving the accuracy of small target detection while also taking into account detailed features. In LSCAM, a lightweight model is achieved by relying solely on gradient and contrast calculations without designing complex branch structures. In the pre-dimensionality reduction layer of Light-ASPP, the number of channels is reduced from 512 to 128 using 1×1 convolutions, effectively reducing computational cost. Simultaneously, the five branches of ASPP are simplified to four branches, and the hole ratio is set to 3 and 5 according to the characteristics of parking space detection, reducing the number of parameters in Light-ASPP to ≤0.2M, only 5% of the original ASPP, while maintaining the output resolution of 40×40 without increasing the computational burden of subsequent PAN-FPN. In the channel dimension of LSCAM, a dynamic threshold Tc for filtering is obtained through dynamic calculation, and the gradient magnitude G of the calibration line is adjusted accordingly. c The system filters out high-frequency noise channels in the background, such as those caused by high-frequency interference from water reflections, and retains only channels with a high proportion of marking features. In the spatial dimension, it uses "local contrast filtering + shape constraints" to exclude irregular background areas such as tree projections and non-rectangular areas of pedestrian shadows, and retains only high-contrast areas that conform to the shape of parking spaces. This reduces background interference from the source of features and effectively improves detection accuracy.

[0210] The performance of the parking space detection model constructed in this application is then verified. The training environment is as follows: PyTorch 2.1, RTX 4090, Batch Size=32, Epoch=250; the optimizer is AdamW, with cosine annealing learning rate scheduling, and the loss function uses a CIoU+Focal Loss scheme to solve the problem of sample imbalance.

[0211] The lightweight specifications are set as follows: total parameters ≤ 3.4M (3.1M for the original YOLOv8n); GPU (RTX 4090) FPS ≥ 110, Jetson Nano FPS ≥ 25.

[0212] The training samples consist of a self-developed vehicle-mounted drone aerial photography dataset of parking spaces and a publicly available dataset.

[0213] The self-developed vehicle-mounted drone aerial photography dataset for parking spaces has the following specific characteristics:

[0214] Data size: A total of 10,000 valid images, divided into training set (8,000 images), validation set (1,000 images), and test set (1,000 images) in an 8:1:1 ratio.

[0215] Data collection conditions: Covering 3 types of parking lots (open-air, underground, and multi-level), 4 types of weather (sunny, cloudy, rainy, and foggy), and 3 drone altitudes (10m, 15m, and 20m), including real-world scenarios such as blurred parking space markings, background interference (grass, shadows, and standing water), and partially obscured parking spaces;

[0216] Labeling specifications: Only label "vacant parking space" as the category, the label box must strictly fit the actual outline of the parking space, and the labeling format is compatible with COCO (to facilitate the reuse of evaluation indicators).

[0217] The publicly available dataset contains 10,000 valid images, selected from CARPK (Car Parking LotDataset), APKLOT (AerialParking Block Segmentation Dataset), and PKLot (ParkingLot Classification Dataset).

[0218] The proposed scheme (labeled YOLOv8n-LSCAM-LASPP in the table) was compared with the standard YOLOv8n model. The performance data obtained after the experiment are shown in Table 1 below.

[0219] Table 1: Comparison of Performance Indicators

[0220]

[0221] The detection accuracy indicators in this experiment are: AP, AP 50 and AP s The detection accuracy metric focuses on whether the model can accurately identify empty parking spaces. Based on the COCO dataset evaluation standard, it has been adapted and optimized for parking space detection scenarios. The higher the value, the better the detection accuracy.

[0222] AP (Average Precision).

[0223] AP (Area Under the Precision-Recall Curve) measures the area under the model's precision-recall curve for the single category of "empty parking spaces." It comprehensively reflects the model's ability to "not miss any real empty parking spaces (high recall)" and "not misclassify non-empty parking spaces (high precision)." Precision: The proportion of parking spaces predicted as "empty" by the model that are actually empty, preventing drivers from making wasted trips and misjudging parking spaces. Recall: The proportion of all real empty parking spaces that the model successfully detects, preventing the problem of "missing empty parking spaces leading to low utilization."

[0224] AP is a "comprehensive score" of detection accuracy. The original YOLOv8n has an AP of 36.1%, while the YOLOv8n-LSCAM-LASPP method improves it to 39.7% (+3.6 percentage points). This shows that by enhancing attention through LSCAM and capturing multi-scale data through Light-ASPP, the model's "accurate recognition ability" of empty parking spaces is significantly improved, especially in complex scenes (rain, fog, blurred lane markings).

[0225] AP 50 This represents the average accuracy when IoU = 0.5. When the Intersection over Union (IoU) ratio between the predicted parking space frame and the actual parking space frame is ≥ 50%, it is considered "correct detection," and the AP value is calculated based on this. IoU is an indicator that measures the degree of overlap between the predicted and actual frames (IoU = overlap area / total area of ​​both frames). AP 50 It is the "basic threshold" for detection accuracy.

[0226] AP 50 Emphasis is placed on the accuracy of parking space frame positioning. The original YOLOv8n AP... 50 The accuracy rate was 55.2%. The YOLOv8n-LSCAM-LASPP accuracy of this method was improved to 58.9% (+3.7 percentage points), indicating that the optimized model can more accurately locate the outline of empty parking spaces. For example, in the perspective of drone aerial photography, even if there is slight occlusion of the parking space (such as the edge of a pedestrian's temporary stop), the predicted box can fit the actual parking space boundary better, reducing misjudgments caused by selection offset.

[0227] AP s (Small AP, Small Target Average Accuracy) is the AP value calculated for parking spaces at a height of 15-20m for drones. It is a key indicator for evaluating the small target detection capability of a model.

[0228] AP s This directly determines the model's usability in "mid-to-high altitude aerial photography scenarios." The original YOLOv8n AP... sOnly 21.3%. The YOLOv8n-LSCAM-LASPP method improved to 25.5% (+4.2 percentage points). The significant improvement is due to the fact that LSCAM avoids the loss of small target features by "dynamic gradient threshold filtering of marking features" and "adaptive window capturing of narrow parking space edges"; Light-ASPP retains the detailed information of small parking spaces by "expanding the field with a small void ratio", which finally solves the core pain point of "missed detection and misjudgment of medium and high-altitude parking spaces" in traditional solutions.

[0229] The lightweighting and deployment adaptation metrics used in this experiment are: number of parameters, GPU FPS, and embedded FPS.

[0230] The lightweight and deployment compatibility metrics focus on whether the model can run efficiently on the UAV embedded platform, balancing "accuracy" and "resource consumption" to ensure that it meets the requirements of "real-time detection (FPS≥25)" and computing power constraints (such as the Jetson Nano computing module with limited computing power).

[0231] The number of parameters (M, mega) is the total number of all trainable parameters in the model (such as convolutional kernel weights and fully connected layer parameters), expressed in millions (M). It directly reflects the model's storage usage and computational complexity. The smaller the number of parameters, the lighter the model and the lower the memory requirements of the embedded platform.

[0232] The original YOLOv8n has 3.1M parameters, while the YOLOv8n-LSCAM-LASPP method only increases this to 3.4M (+0.3M), an increase of less than 10%. This is because both LSCAM (parameter count ≈ 2k) and Light-ASPP (parameter count ≤ 0.2M) employ lightweight designs: LSCAM has no complex branches and generates attention weights only through gradient and contrast calculations; Light-ASPP significantly compresses the number of parameters through pre-dimensionality reduction (from 512 to 128 channels) and branch simplification, ensuring that the model can adapt to the storage resources of UAV embedded platforms (such as the 4GB memory of the Jetson Nano).

[0233] GPU FPS (Frames Per Second) is the number of image frames a model can process per second on a high-performance GPU (such as the RTX 4090 in this example), reflecting the model's "computational efficiency." The higher the FPS, the better the real-time performance.

[0234] The original YOLOv8n has a GPU FPS of 125, while the YOLOv8n-LSCAM-LASPP method reduces it to 112 (-13 FPS), but still maintains extremely high real-time performance. The slight decrease in frame rate is due to the addition of the LSCAM and Light-ASPP modules, which increase computation slightly. However, the optimized model still meets the requirements for "fast training and testing on GPUs" and lays the foundation for real-time performance on embedded systems. The GPU frame rate serves as an "upper limit reference" for the embedded frame rate.

[0235] Embedded FPS: On commonly used embedded platforms for drones (such as the NVIDIA Jetson Nano, with a computing power of approximately 0.5 TFLOPS), the number of image frames per second that a model can process is a core indicator of whether a model can be practically deployed. In this embodiment, real-time performance is defined as: FPS ≥ 25. This is because the frame rate of aerial image acquisition by consumer-grade drones is typically 25~30 FPS, and the model needs to match the acquisition speed to achieve real-time detection and feedback.

[0236] The original YOLOv8n embedded FPS was 22 (not meeting the target), while this application's YOLOv8n-LSCAM-LASPP improves it to ≥25 (meeting the target). This key improvement stems from two points: first, the lightweight design of LSCAM and Light-ASPP does not significantly increase the computational burden; second, Light-ASPP avoids the increased computational load caused by feature map downsampling through "unpooled + dilated convolution," ultimately ensuring that the model can achieve real-time detection on low-computing embedded platforms, meeting the actual needs of "detecting while flying" for vehicle-mounted drones.

[0237] The technology of this invention can be applied to intelligent parking management, such as parking space navigation and vacancy rate statistics, and can also be applied to emergency rescue parking space scheduling. This solution is compatible with consumer-grade drones and can achieve automated detection and positioning of empty parking spaces at low cost.

Claims

1. A parking space detection method based on vehicle-mounted unmanned aerial vehicle data using YOLOv8n, characterized in that, It includes the following steps: S1: Construct a spatial channel two-dimensional attention module; The spatial channel dual-dimensional attention module includes two parallel branches: a channel attention branch and a spatial attention branch; The input data is fed into two branches. The channel attention branch calculates the gradient magnitude of the datum lines in each channel, normalizes it to generate weights, and outputs the feature value F of the channel with the highest proportion of enhanced datum lines. ch Simultaneously, the output is fed into the spatial attention branch; The spatial attention branch calculates the local contrast of the channel attention output and generates the spatial attention normalization weight W after normalization. sp ; Finally, the feature value F output by the channel attention branch is... ch Spatial attention normalized weight W sp Multiplying these values ​​yields the output feature value F of the spatial channel dual-dimensional attention module. lscam ; S2: Build the Light ASPP module; The Light ASPP module includes: a pre-dimensionality reduction layer, four parallel detection branches, and a feature fusion layer; The input data is fed into the pre-dimensionality reduction layer, and the number of channels is reduced in dimensionality and then fed into four parallel detection branches to extract small, medium, large and global feature information respectively. The outputs of the four parallel detection branches are fed into the feature fusion layer. In the feature fusion layer, the features extracted by the four branches are concatenated, and the number of channels is restored to be the same as the input data before being used as the output of the Light ASPP module. S3: Construct a parking space detection model based on YOLOv8n; The parking space detection model includes: a backbone network, a neck network, a head network, and a post-processing module connected in sequence; The spatial channel dual-dimensional attention module is inserted after the third and fourth C2f modules in the backbone network of YOLOv8n to form the backbone network of the parking space detection model; the parking space detection model uses the LightASPP module to replace the SPPF module in the neck network of the YOLOv8n model. The parking space detection model takes as input the parking lot image captured by the airborne camera, and then sends it to the backbone network, the neck network and the head network for processing in sequence. The detection head in the head network sends the recognition result of the parking lot image to the post-processing module. After the post-processing module filters out empty parking spaces based on the recognition results, it uses UAV RTK data and the camera intrinsic parameters of the onboard camera to convert pixel coordinates into ground geographic coordinates through a perspective projection model, and assigns an ordered number to each empty parking space as the final detection result. S4: Construct a drone aerial photography dataset of parking spaces and divide the dataset into a training set, a validation set, and a test set; The parking space detection model is trained using the training set to obtain the trained parking space detection model; S5: Configure the trained parking space detection model into the vehicle-mounted drone, and use the vehicle-mounted drone to identify empty parking spaces within the scanning range.

2. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 1, characterized in that: The output feature value F of the channel attention branch ch for: F ch (c,i,j)=W ch (c)×F(c,i,j); In the formula, F(c,i,j) represents the original features of the Backbone stage received by the spatial channel dual-dimensional attention module; (i,j) are the pixel coordinates in the input feature map; W ch (c) represents the normalized weight value of the c-th channel of the input feature map; ; In the formula, G c Let c' be the gradient magnitude of the c-th channel, c' be the index used to traverse the channels, and C be the total number of channels in the input feature map. ; In the formula, G cx Let G be the Sobel gradient in the X direction of the c-th channel. cy Let H be the Sobel gradient in the Y direction of the c-th channel, and H and W be the height and width of the input feature map.

3. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 2, characterized in that: The channel attention branch also includes a method for filtering channels c in the input feature map. Channels c that pass the filtering process participate in subsequent calculations, while channels c that do not pass the filtering process do not participate in subsequent calculations. Specifically, it includes the following steps: a1: Set the dynamic threshold Tc: ; In the formula, For the gradient magnitude G of all channels c The mean value, std(G) is the channel gradient magnitude G. c The standard deviation of , where α and β are scene coefficients; a2: Calculate the gradient magnitude G of each of the aforementioned calipers. c Compare with the dynamic threshold Tc; When G c When Tc is greater than or equal to Tc, the corresponding channel c participates in subsequent calculations; Otherwise, the gradient magnitude G of the corresponding channel c is... c The value is assigned a preset low-weight value.

4. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 3, characterized in that: The spatial attention normalization weight W output by the spatial attention branch sp for: ; In the formula, (i,j) are the coordinates of the target pixel in the input feature map; H and W are the height and width of the input feature map; (i',j') is the index of the traversed pixels; C(i,j) is the local contrast value at pixel (i,j) in the input feature map; σ() is the Sigmoid function; ; In the formula, Ω(i,j) represents a local region window centered at (i,j); (x,y)∈Ω(i,j) represents traversing all pixels within the local window; (x,y) are the coordinates of the pixels traversed within the local window Ω(i,j); F ch (x,y) represents the feature value of pixel (x,y) within the window in the feature map output by the channel attention branch; max (x,y)∈Ω(i,j) F ch (x,y) represents all F values ​​within the local window Ω(i,j). ch The maximum value of (x,y), the most significant characteristic response; min (x,y)∈Ω(i,j) F ch (x,y) represents all F values ​​within the local window Ω(i,j). ch The minimum value of (x,y), the weakest characteristic response.

5. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 4, characterized in that: The spatial attention branch also includes: adaptive window constraints; The adaptive window constraint dynamically adjusts the size of the local region window Ω(i,j) based on the drone's aerial photography altitude, setting the window size win_size to be linearly related to the height h. win_size=3+2×floor((20-h) / 5); In the formula, h is the actual altitude of the drone, and floor() is the floor function.

6. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 4, characterized in that: The spatial attention branch also includes: parking space shape constraint. This constraint involves calculating the local contrast C(i,j), then verifying the rectangle size and aspect ratio of high-contrast regions suspected of being parking spaces. Only pixels (i,j) within these verified high-contrast regions are included in the subsequent spatial attention normalization weight W. sp In the calculation, pixels (i,j) in regions that fail the verification are not included in subsequent calculations; The steps for defining the shape of the parking space include: b1: Compare the calculated local contrast C(i,j) with the dynamic threshold Tc; If C(i,j) ≥ Tc, then the corresponding pixel (i,j) is determined to be a high-contrast pixel; Otherwise, it is determined to be a non-high contrast pixel and will not be included in subsequent calculations; b2: For all the high-contrast pixels, use an edge detection algorithm to extract the region contour, denoted as: suspected region contour; b3: Extract the contour of each of the suspected regions one by one, and denot it as: the contour of the region to be processed; The total number of pixels contained within the outline of the region to be processed is counted and denoted as: the actual area of ​​the suspected region; b4: For the outline of the region to be processed, find the smallest bounding rectangle that can completely enclose the actual area of ​​the suspected region by using a rotating rectangle fitting algorithm; The minimum bounding rectangle is a rectangular region that ensures the smallest possible area and completely includes the outline of the region to be processed. b5: Calculate the rectangularity of the minimum bounding rectangle; Rectangularity = Actual area of ​​the suspected region / Area of ​​the minimum bounding rectangle; b6: Compare the rectangle size with a preset rectangle size threshold; When the rectangle degree is greater than or equal to the rectangle degree threshold, step b7 will be executed on the corresponding outline of the region to be processed. Otherwise, the outline of the region to be processed will not be included in subsequent calculations; b7: Obtain the minimum bounding rectangle corresponding to the outline of the region to be processed, extract the width W and height H, and calculate the aspect ratio; Aspect ratio = Width W / Height H; b8: When the aspect ratio meets the following filtering conditions, the outline of the area to be processed is determined to have passed the verification of the parking space shape constraint and is included in subsequent calculations; otherwise, it is determined to have failed the verification. The filtering criteria are: ARmin ≤ aspect ratio ≤ ARmax; ARmin is the preset minimum aspect ratio, and ARmax is the preset maximum aspect ratio.

7. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 1, characterized in that: In the Light ASPP module, the pre-dimensionality reduction layer performs dimensionality reduction on the number of channels of the input data based on 1×1 convolution. The detection branches include: small size detection branch, medium size detection branch, large size detection branch, and global information detection branch; The small-size detection branch is implemented based on 1×1 convolution; The mid-size detection branch is implemented based on a 3×3 dilated convolution with a dilation rate of 3. The large-size detection branch is implemented based on a 3×3 dilated convolution with a dilation rate of 5. The global information detection branch includes: a global average pooling, a 1×1 convolution, and an upsampling operation connected in sequence; The feature fusion layer concatenates the features output from the four detection branches, restores them to the same dimension as the input data through a 1×1 convolution, and then outputs them.

8. The parking space detection method based on YOLOv8n vehicle-mounted UAV data according to claim 1, characterized in that: The operations performed in the post-processing module include the following steps: c1: Receives the parking space recognition result output by the head network; The recognition results include: target bounding box, target category, and confidence score; The target categories include: empty parking spaces, vehicles, obstacles, and pedestrians; c2: Read the preset confidence threshold and retain the recognition results whose confidence scores are greater than or equal to the confidence threshold; c3: Read the preset intersection-union ratio threshold, and perform non-maximum suppression on the target bounding box of the recognition result using the intersection-union ratio threshold to remove overlapping redundant boxes; in the remaining data, the recognition result of the target category being empty parking space is recorded as: empty parking space recognition result; c4: For each of the above-mentioned empty parking space identification results, the pixel coordinates are converted into ground geographic coordinates using the UAV RTK data and the camera intrinsic parameters of the airborne camera through a perspective projection model; c5: Sort all the empty parking space identification results based on ground geographic coordinates.

Citation Information

Patent Citations

  • Unmanned aerial vehicle and unmanned vehicle cooperative control method and device

    CN120469434A

  • Unmanned aerial vehicle in-road berth shooting system with intelligent parking platform and method of unmanned aerial vehicle in-road berth shooting system

    CN121134094A

  • Unmanned aerial vehicle aerial image small target detection method and computer readable storage medium

    CN120913106A

  • Unmanned aerial vehicle image small target detection optimization method based on YOLOv8

    CN121392669A