A traffic light shape detection method and apparatus
By introducing size adaptive processing and Fourier descriptor analysis into traffic light detection, combined with a multi-stage judgment strategy, the accuracy and robustness issues of small-sized traffic light shape recognition are solved, achieving efficient and accurate traffic light shape detection, which is suitable for vehicle-mounted embedded devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BLACK SESAME TECH (SHANGHAI) CO LTD
- Filing Date
- 2026-04-02
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies struggle to accurately identify the shape of small traffic lights, especially in poor lighting conditions, shadows, or when traffic lights are aging. They exhibit poor robustness and consume significant computing resources, making real-time deployment on in-vehicle embedded devices difficult.
By acquiring color and position information from the image to determine the initial boundary region, adaptive scaling is performed, shape features are calculated using Fourier descriptors, and multi-stage judgment is made in conjunction with geometric features to improve recognition accuracy.
It improves the recognition accuracy and robustness of small-sized traffic lights, reduces computing resource requirements, and is suitable for real-time deployment on in-vehicle embedded devices.
Smart Images

Figure CN122336401A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent transportation technology, and in particular to a method and apparatus for detecting the shape of traffic lights. Background Technology
[0002] Traffic light recognition and detection technology is widely used in fields such as autonomous driving, intelligent traffic monitoring, traffic flow management, and driver assistance systems, and is crucial for improving traffic safety and efficiency. Accurately identifying the shape of traffic lights (such as circles, arrows, U-shaped arrows, etc.) is a key step in understanding traffic instructions.
[0003] Current traffic light recognition methods primarily rely on techniques such as color recognition, template matching, or deep learning. While color recognition-based methods are simple and efficient, they are prone to misidentification under conditions of strong lighting, shadows, inclement weather, or color distortion caused by aging traffic lights. Template matching methods require the pre-establishment of a large number of accurate traffic light templates, but the wide variation in the size, angle, and position of traffic lights makes it extremely difficult to create universal templates, resulting in poor robustness. Deep learning methods, especially convolutional neural networks (CNNs), while offering good performance, typically require massive amounts of labeled data for training and consume significant computational resources, making real-time deployment difficult on resource-constrained platforms such as automotive embedded devices.
[0004] Furthermore, in real-world road scenarios, when traffic lights are far from the camera, they appear small in the image. At this time, the pixel information of the traffic lights is sparse, and the contour differences between different shapes (such as circles and U-shaped arrows) become extremely subtle. Existing technologies struggle to capture these subtle shape features, leading to a significant reduction in detection accuracy, which is a major challenge currently facing the field of traffic light recognition.
[0005] Therefore, there is an urgent need for a detection method that is efficient, accurate, robust, and especially capable of improving the recognition accuracy of traffic lights that are small in size and have inconspicuous shape differences. Summary of the Invention
[0006] The purpose of this invention is to provide a method and apparatus for detecting the shape of traffic lights, aiming to solve the technical problems of low accuracy and poor robustness in the detection of small-sized traffic light shapes in the prior art.
[0007] To achieve the above objectives, the present invention provides a method for traffic light shape detection, comprising:
[0008] Acquire the image to be detected, and determine the preliminary boundary region of the traffic light based on the color and position information in the image to be detected;
[0009] Determine whether the dimensions of the preliminary boundary region meet the preset size conditions;
[0010] If the size of the initial boundary region does not meet the preset size condition, the initial boundary region is subjected to size adaptive enlargement processing to obtain the enlarged target region;
[0011] If the size of the preliminary boundary region meets the preset size condition, then the preliminary boundary region is taken as the target region;
[0012] Extract the outline of the traffic lights from the target area;
[0013] Fourier descriptors are calculated for the outline of the traffic light, resulting in multiple Fourier descriptor coefficients;
[0014] The preliminary shape type of the traffic light is determined based on the plurality of Fourier descriptor coefficients;
[0015] By combining the geometric features of the target area, the preliminary shape type is confirmed a second time to obtain the final traffic light shape detection result.
[0016] Optionally, determining the preliminary boundary region of the traffic light based on the color and position information in the image to be detected includes:
[0017] Get the bounding box containing the traffic lights;
[0018] Within the bounding box, a binarized mask is generated based on a preset color threshold range or saturation threshold of the traffic light.
[0019] A position weight is set based on the position information of the traffic light in the image to be detected, and the position weight is used to filter the binarized mask to eliminate interference areas; wherein, the position weight is determined by the distance of the pixel from the center line of the image;
[0020] Calculate the minimum bounding rectangle for the region marked as the foreground in the filtered binarized mask, and use the minimum bounding rectangle as the initial boundary region.
[0021] Optionally, before generating the binarized mask, the method further includes:
[0022] Within the bounding box, pixel values in low-to-medium brightness areas are compressed to zero using gamma mapping or line segment mapping functions to eliminate background information and reduce color distortion caused by overexposure.
[0023] Optionally, determining whether the size of the preliminary boundary region meets the preset size condition includes:
[0024] Determine whether the maximum side length of the preliminary boundary region is greater than a first preset pixel threshold;
[0025] If the maximum side length of the initial boundary region is not greater than the first preset pixel threshold, then it is determined that the size of the initial boundary region does not meet the preset size condition.
[0026] The step of adaptively enlarging the size of the initial boundary region includes:
[0027] The preliminary boundary region is globally magnified using bilinear interpolation or bicubic interpolation methods.
[0028] Optionally, determining whether the size of the preliminary boundary region meets the preset size condition further includes:
[0029] If the maximum side length of the initial boundary region is greater than the first preset pixel threshold, then determine whether the ratio of the maximum side length to the minimum side length of the initial boundary region is greater than a preset ratio threshold.
[0030] If the ratio is greater than the preset ratio threshold, then it is determined that the size of the preliminary boundary region does not meet the preset size condition;
[0031] The step of adaptively enlarging the size of the initial boundary region includes:
[0032] The initial boundary region is magnified unidirectionally along the direction of minimum side length to alleviate visual distortion.
[0033] Optionally, extracting the outline of the traffic light from the target area includes converting the target area into a grayscale image, applying an edge detection algorithm to the grayscale image, and selecting the outline with the largest radius as the outline of the traffic light.
[0034] The Fourier descriptor of the traffic light's profile is calculated, resulting in multiple Fourier descriptor coefficients, including:
[0035] The outline of the traffic light is represented as a complex sequence;
[0036] Perform a discrete Fourier transform on the complex sequence to obtain the Fourier coefficients;
[0037] The amplitude spectrum of the Fourier coefficients is normalized to achieve scaling invariance, thereby obtaining the plurality of Fourier descriptor coefficients.
[0038] Optionally, determining the preliminary shape type of the traffic light based on the plurality of Fourier descriptor coefficients includes:
[0039] The first N low-frequency Fourier descriptor coefficients after normalization are selected as the shape feature vector, where N is an integer greater than or equal to 3;
[0040] Determine the magnitude of the values of each Fourier descriptor coefficient in the shape feature vector;
[0041] If the value of the first Fourier descriptor coefficient FD1 is the largest in the shape feature vector, then the preliminary shape type is determined to be circular.
[0042] If the value of the second-order Fourier descriptor coefficient FD2 is the largest in the shape feature vector, then the preliminary shape type is determined to be a U-shaped arrow.
[0043] If the value of the third-order Fourier descriptor coefficient FD3 is the largest in the shape feature vector, then the preliminary shape type is determined to be a directional arrow.
[0044] Optionally, the step of combining the geometric features of the target region to perform a secondary confirmation of the preliminary shape type includes:
[0045] The overall proportion of valid pixels within the target area is statistically analyzed.
[0046] If the initial shape type is circular and the overall proportion of the effective pixels is greater than a preset proportion threshold, then the final traffic light shape detection result is confirmed to be circular.
[0047] Optionally, the step of combining the geometric features of the target region to perform a secondary confirmation of the preliminary shape type further includes:
[0048] The proportion of effective pixels in the central region of the target area is statistically analyzed.
[0049] The hollowness ratio is determined based on the effective pixel ratio of the central region to distinguish between circular traffic lights and digital lights;
[0050] In addition, the effective pixel ratio of the vertex region of the target area and the preset specific region is statistically analyzed to distinguish U-shaped arrow traffic lights, directional arrow traffic lights and other shapes of traffic lights.
[0051] The present invention also provides a traffic light shape detection device for performing any of the traffic light shape detection methods described above.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] This technology improves the recognition accuracy of small traffic lights. By introducing size adaptive processing, conditional magnification is applied to small or deformed traffic light samples, effectively compensating for insufficient feature information caused by low resolution or deformation. This allows subsequent Fourier descriptor calculations to obtain more accurate shape details, significantly solving the problem of small target recognition in existing technologies.
[0054] The robustness of shape detection is enhanced. By utilizing the invariance of Fourier descriptors to shape rotation, translation, and scaling, the contour features of traffic lights can be captured accurately and stably, effectively overcoming the challenges posed by changes in the pose and size of traffic lights.
[0055] This improves the accuracy and reliability of detection. A multi-stage judgment strategy is employed. First, a preliminary shape judgment is made by analyzing Fourier descriptor coefficients. Then, a secondary verification is performed by combining geometric features such as the effective pixel ratio. This progressive approach significantly improves the reliability of recognizing various shapes and effectively distinguishes interfering targets (such as digital lights).
[0056] It is computationally efficient and easy to deploy. Compared with deep learning methods, this method requires fewer training samples and consumes fewer computational resources, making it suitable for implementation on resource-constrained platforms such as automotive embedded devices (e.g., ISP firmware).
[0057] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.
[0058] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0060] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0061] Figure 1 This is a flowchart of a traffic light shape detection method according to an embodiment of the present invention;
[0062] Figure 2 This is a schematic diagram of traffic lights in an embodiment of the present invention, showing the preliminary boundary area.
[0063] Figure 3 This is a schematic diagram of a small-sized traffic light sample that requires size adaptive processing in an embodiment of the present invention;
[0064] Figure 4 This is a schematic diagram of region division and pixel statistics used for secondary confirmation of geometric features in an embodiment of the present invention. Detailed Implementation
[0065] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0066] This invention provides a highly efficient and accurate method for traffic light shape detection. By introducing the Fourier descriptor, a powerful shape analysis tool, and combining it with size adaptive processing and a multi-stage judgment strategy, it effectively solves the shortcomings of existing technologies in recognizing small-sized traffic lights. This method can be implemented in the firmware of an ISP (Image Signal Processor).
[0067] This invention provides a method for detecting the shape of a traffic light, such as... Figure 1 As shown, it includes the following steps:
[0068] Step S101: Determine the preliminary boundary area of the traffic lights.
[0069] This step aims to quickly and effectively locate potential traffic light areas from complex image backgrounds.
[0070] First, the image to be detected is acquired. Typically, the traffic light detection module at the front end of the system provides the bounding box (bbox) of the traffic light, which provides an initial region of interest (ROI).
[0071] After obtaining the bounding box (bbox), it's necessary to further determine the boundaries of the traffic lights within the bbox. Since the brightness of the traffic lights within the bbox is typically much higher than the background brightness, preprocessing steps can be used to eliminate background information and reduce color distortion caused by overexposure of traffic lights in nighttime scenes. For example, gamma mapping or line segment mapping functions can be used to compress pixel values in low-to-medium brightness areas to 0.
[0072] Next, segmentation is performed using color information. Based on the preset threshold range of the typical colors of traffic lights (red, yellow, and green) in the HSV (hue, saturation, and brightness) color space, a pixel-by-pixel threshold comparison is performed on the H, S, and V channels. Alternatively, taking advantage of the fact that traffic lights typically have high saturation, pixels with a saturation S greater than a certain threshold are marked as foreground (e.g., white), and those that do not meet the threshold are marked as background (e.g., black), thus obtaining a binarized mask.
[0073] To prevent the influence of adjacent traffic lights from infiltrating the boundary region and improve the accuracy of ROI boundaries, positional weights can be set based on the typical location information of traffic lights in the image. For example, the weight of each point can be determined by its distance from the image center line, with greater weight for points closer to the center line. Filtering with a binarized mask combined with these positional weights can effectively eliminate interference from the bottom or sides of the image.
[0074] Finally, the minimum bounding rectangle of the filtered region marked as foreground is calculated. This rectangle serves as the initial boundary region of the potential traffic light.
[0075] like Figure 2 The diagram shown is a preliminary boundary region of a traffic light determined according to an embodiment of the present invention. After the above preprocessing, color segmentation, and position weight filtering, the minimum bounding rectangle boundary containing the main body of the traffic light (as shown by the green arrow in the figure) can be clearly obtained, removing most of the background interference.
[0076] Step S102: Perform size adaptation processing.
[0077] This step is one of the core aspects of this invention, aiming to solve the problem of insufficient feature information caused by low resolution in small-sized traffic lights.
[0078] First, determine whether the dimensions of the initial boundary region meet the preset size conditions.
[0079] In one implementation, it is determined whether the maximum side length of the initial boundary region is less than or equal to a first preset pixel threshold (e.g., it can be set to 16 pixels or 30 pixels, and the specific value can be adjusted according to the actual image resolution and application requirements). If the maximum side length is less than the threshold, the traffic light is considered to have low resolution in the image, and its outline information may be blurred due to insufficient pixels, thus it is determined that the preset size condition is not met.
[0080] For samples deemed small, the image region within their initial boundary area is globally magnified. The magnification factor is typically 2x, 3x, or higher. In the specific pixel interpolation process, this embodiment dynamically selects the interpolation algorithm based on the system's hardware resources and computational requirements: when system computing power is limited or real-time performance is extremely high, bilinear interpolation is used, employing linear interpolation in two directions using the gray values of the four surrounding pixels to achieve image magnification with low computational overhead; when system computing power is sufficient and contour smoothness is critical, bicubic interpolation is used, performing cubic polynomial fitting using the gray values of the sixteen surrounding pixels to obtain smoother, less jagged edge contours. This magnification process enhances the contour details of small targets, enabling subsequent processing to obtain richer and more accurate shape information.
[0081] In another implementation, even if the maximum side length of the initial boundary region is greater than the first preset pixel threshold, the traffic light shape may be stretched or compressed due to lens viewing angle distortion. In this case, it is necessary to determine whether the ratio of the maximum side length to the minimum side length (aspect ratio) is greater than a preset ratio threshold (e.g., set to 2). If the ratio is greater than this threshold, it indicates that the deformation is more severe and is also determined to be not meeting the preset size condition.
[0082] In this case, a one-way magnification process can be used on the shorter side to alleviate the distortion of contour information caused by deformation.
[0083] If the size of the initial boundary region meets the preset size conditions (i.e., the maximum side length is greater than the threshold and the aspect ratio is within the normal range), then there is no need to enlarge it, and the initial boundary region can be directly used as the target region for subsequent processing.
[0084] After size adaptation processing, regardless of the original traffic light size, a target area with sufficient resolution and appropriate proportion is obtained.
[0085] like Figure 3 As shown, this illustrates small or blurry traffic light samples that may exist in the image to be detected. These samples exhibit subtle shape differences, such as between circles and rounded squares, due to sparse pixel information. [The text then abruptly shifts to a different topic:] For this type of sample... Figure 3 For areas that do not meet the preset size conditions, this embodiment will perform subsequent adaptive size enlargement processing (such as bilinear interpolation enlargement) to enhance the contour details.
[0086] Step S103: Extract the outline of the traffic light.
[0087] This step aims to accurately extract the geometric contours of the target area in preparation for shape analysis.
[0088] First, the target region obtained in step S102 is extracted. Next, the target region is converted to grayscale. A weighted average method is typically used to convert it to grayscale; for example, Gray = 0.299R + 0.587G + 0.114*B, where R, G, and B represent the red, green, and blue component values of the pixels within the target region in the RGB color space, respectively.
[0089] Then, an edge detection algorithm, such as the Canny operator, is applied to the grayscale image. The Canny operator effectively suppresses noise and can detect real and continuous edges in the image. The edge image output by the Canny operator is binarized to obtain a binary image containing only the edge contours.
[0090] Finally, a contour-finding algorithm is used to identify all interconnected pixel chains in the image. In practical applications, multiple contours may be detected. In this case, the contour with the largest radius can be selected as the contour of the traffic light for subsequent Fourier descriptor calculations.
[0091] Step S104: Calculate the Fourier descriptor and perform initial shape determination.
[0092] This step is another core aspect of the invention: using Fourier descriptors (FD) to quantify the contour and perform preliminary shape classification accordingly. FD possesses rotation, translation, and scaling invariance.
[0093] First, Fourier descriptor calculation is performed. The traffic light contour extracted in step S103 is converted into a complex sequence. If the contour consists of N points (x... k , y k If the expression is composed of z(k), then it can be represented as z(k) = x(k) + j*y(k), where j is the imaginary unit and k = 0, 1, …, N-1.
[0094] Next, the complex sequence is subjected to a Discrete Fourier Transform (DFT) to obtain the Fourier coefficients. The specific formula for the Discrete Fourier Transform is as follows:
[0095]
[0096] in, Represents a frequency domain variable (or frequency index); This represents the total number of contour points; It is the imaginary unit.
[0097] Calculated Fourier coefficients It is a complex value, and its amplitude and phase encode the shape information of the contour. Since the amplitude spectrum is invariant to the translation and rotation of the contour, this step first takes the amplitude spectrum of the Fourier coefficients. As a preliminary feature.
[0098] Subsequently, to further achieve feature scaling invariance with target size, a normalization operation needs to be performed on the amplitude spectrum. Specifically, this can be achieved by... or Normalization calculations are performed. Through this normalization process, even traffic lights that appear to be different sizes in the image but have the same actual shape can be mapped to Fourier descriptor coefficients with similar values, thereby greatly improving the robustness of subsequent initial shape judgment.
[0099] Next, feature vectors are selected. Unlike traditional machine learning methods (which typically extract a large number of Fourier descriptors to construct high-dimensional feature vectors and rely on classifiers such as SVMs for model training that requires a large number of samples and computational power), this method, for the sake of lightweight design and ease of deployment in automotive embedded devices, selects only the first few low-frequency Fourier descriptor coefficients as shape feature vectors. This is because low-frequency descriptors contain the overall macroscopic shape information of the contour, while high-frequency descriptors capture the details and noise of the contour.
[0100] Subsequently, a preliminary judgment is made on the shape of the traffic light based on the maximum value of the Fourier descriptor coefficients. This judgment is based on the energy distribution characteristics of different shape profiles in the Fourier spectrum:
[0101] Circle: Because a circle is the simplest closed contour, the first coefficient in its Fourier descriptor (corresponding to the fundamental period of the circle) has the highest energy proportion, while the energy of other higher-order coefficients decays rapidly. Therefore, if the value of FD1 (the amplitude of the first-order Fourier descriptor) is the largest in the shape feature vector, it is initially judged to be a circle.
[0102] U-shaped arrow: The outline of a U-shaped arrow has specific symmetry and curvature characteristics. Due to the variation in the frequency of its outline undulations, these characteristics exhibit strong energy in the second coefficient of the Fourier descriptor. Therefore, if the value of FD2 is the largest in the shape feature vector, it is initially identified as a U-shaped arrow.
[0103] Directional arrows: These typically refer to arrows pointing straight, left, or right. The outline of an arrow has a more complex geometric structure, containing prominent sharp angles and straight line segments. These features exhibit strong energy in the third coefficient of the Fourier descriptor. Therefore, if the value of FD3 is the largest in the shape feature vector, it is initially identified as a directional arrow.
[0104] Step S105: Secondary verification using geometric features. This step aims to further improve the accuracy of shape judgment. Geometric features such as the effective pixel ratio within the initial boundary are introduced to specifically verify the preliminary judgment results, avoiding the limitations and misjudgments associated with single-feature judgments. The specific verification logic is as follows:
[0105] (1) Secondary confirmation for lights initially identified as circular: First, the overall proportion of valid pixels within the target area (minimum bounding rectangle) determined in step S101 is statistically analyzed. For a standard circular traffic light, its interior is usually filled with a uniform color, so the proportion of valid pixels within the boundary should be very high (e.g., a threshold greater than 90%). Second, the proportion of valid pixels in the central area is statistically analyzed. For "digital lights" identified as circular (such as countdown digit 0), since their centers are mostly hollow, calculating the hollowness rate (i.e., the proportion of invalid pixels) in the central area can effectively distinguish them from true circular lights.
[0106] (2) For secondary confirmation of the initial judgment of U-shaped arrow or directional arrow: the target area is divided into vertex area and other preset specific areas. For example, the pixel ratio of U-shaped lights is very high in the S3 area (preset specific area) compared with circular lights and ordinary arrow lights. At the same time, combined with the effective pixel ratio of vertex area, U-shaped arrows can be accurately distinguished from other shapes.
[0107] By combining the global shape information provided by the Fourier descriptor and the local filling information provided by the geometric features, this method can achieve high-precision and high-reliability traffic light shape detection.
[0108] The method of this invention effectively solves the problem of small target recognition through size adaptive processing, ensures the robustness of detection by utilizing the invariance of Fourier descriptors, and ensures the accuracy of the final result through a multi-stage judgment strategy.
[0109] like Figure 4 The diagram shown illustrates the region division for secondary verification in an embodiment of the present invention. To distinguish shapes (e.g., between solid circles and hollow digital lights, or between U-shaped arrows and ordinary arrows), the system divides the target region into different statistical sub-regions (such as the Smid center region, S0 and S3 vertex regions as indicated in the diagram). By statistically analyzing the proportion of effective pixels within these specific regions, the preliminary shape classification results can be accurately verified.
[0110] To further verify the technical effectiveness of the present invention, a sample test was conducted on the detection method of the present invention. The test selected 5000 traffic light samples (including circular lights, arrow lights, U-shaped arrow lights, and easily confused digital lights) for classification and identification. The confusion matrix and recognition accuracy after the test are shown in the table below:
[0111] Circle Data Arrow U_turn Arrow recall Circle 980 0 0 20 0.98 Data 0 1000 0 0 1.00 Arrow 10 0 1990 0 0.99 U_turn Arrow 40 10 10 940 0.94 Precision 0.9514 0.9900 0.9900 0.9791
[0112] Test results show that this method can maintain extremely high precision and recall when faced with various traffic light shapes, effectively solving the problem of low recognition accuracy caused by small size and slight shape differences, and has extremely high practical application value.
[0113] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for detecting the shape of a traffic light, characterized in that, include: Acquire the image to be detected, and determine the preliminary boundary region of the traffic light based on the color and position information in the image to be detected; Determine whether the dimensions of the preliminary boundary region meet the preset size conditions; If the size of the initial boundary region does not meet the preset size condition, the initial boundary region is subjected to size adaptive enlargement processing to obtain the enlarged target region; If the size of the preliminary boundary region meets the preset size condition, then the preliminary boundary region is taken as the target region; Extract the outline of the traffic lights from the target area; Fourier descriptors are calculated for the outline of the traffic light, resulting in multiple Fourier descriptor coefficients; The preliminary shape type of the traffic light is determined based on the plurality of Fourier descriptor coefficients; By combining the geometric features of the target area, the preliminary shape type is confirmed a second time to obtain the final traffic light shape detection result.
2. The method according to claim 1, characterized in that, The step of determining the preliminary boundary region of the traffic light based on the color and position information in the image to be detected includes: Get the bounding box containing the traffic lights; Within the bounding box, a binarized mask is generated based on a preset color threshold range or saturation threshold of the traffic light. A position weight is set based on the position information of the traffic light in the image to be detected, and the position weight is used to filter the binarized mask to eliminate interference areas; wherein, the position weight is determined by the distance of the pixel from the center line of the image; Calculate the minimum bounding rectangle for the region marked as the foreground in the filtered binarized mask, and use the minimum bounding rectangle as the initial boundary region.
3. The method according to claim 2, characterized in that, Before generating the binarized mask, the process also includes: Within the bounding box, pixel values in low-to-medium brightness areas are compressed to zero using gamma mapping or line segment mapping functions to eliminate background information and reduce color distortion caused by overexposure.
4. The method according to claim 1, characterized in that, The step of determining whether the size of the preliminary boundary region meets the preset size condition includes: Determine whether the maximum side length of the preliminary boundary region is greater than a first preset pixel threshold; If the maximum side length of the initial boundary region is not greater than the first preset pixel threshold, then it is determined that the size of the initial boundary region does not meet the preset size condition. The step of adaptively enlarging the size of the initial boundary region includes: The preliminary boundary region is globally magnified using bilinear interpolation or bicubic interpolation methods.
5. The method according to claim 4, characterized in that, The step of using bilinear interpolation or bicubic interpolation to perform global magnification processing on the preliminary boundary region includes: Assess the current system's computing resource allocation status and real-time requirements; If the system's computing resources are lower than a preset resource threshold, a bilinear interpolation algorithm is used to enlarge the preliminary boundary region. If the system's computing resources are higher than or equal to a preset resource threshold, then a bicubic interpolation algorithm is used to amplify the preliminary boundary region.
6. The method according to claim 1, characterized in that, The step of determining whether the size of the preliminary boundary region meets the preset size condition further includes: If the maximum side length of the initial boundary region is greater than the first preset pixel threshold, then determine whether the ratio of the maximum side length to the minimum side length of the initial boundary region is greater than a preset ratio threshold. If the ratio is greater than the preset ratio threshold, then it is determined that the size of the preliminary boundary region does not meet the preset size condition; The step of adaptively enlarging the size of the initial boundary region includes: The initial boundary region is magnified unidirectionally along the direction of minimum side length to alleviate visual distortion.
7. The method according to claim 1, characterized in that, Extracting the outline of the traffic light from the target area includes converting the target area into a grayscale image, applying an edge detection algorithm to the grayscale image, and selecting the outline with the largest radius as the outline of the traffic light. The Fourier descriptor of the traffic light's profile is calculated, resulting in multiple Fourier descriptor coefficients, including: The outline of the traffic light is represented as a complex sequence; Perform a discrete Fourier transform on the complex sequence to obtain the Fourier coefficients; The amplitude spectrum of the Fourier coefficients is normalized to achieve scaling invariance, thereby obtaining the plurality of Fourier descriptor coefficients.
8. The method according to claim 7, characterized in that, The step of determining the preliminary shape type of the traffic light based on the plurality of Fourier descriptor coefficients includes: Extract the low-frequency descriptor coefficients from the multiple Fourier descriptor coefficients to construct a shape feature vector; Based on the energy distribution characteristics of traffic light outlines of different shapes on the Fourier spectrum, the amplitudes of the low-frequency descriptor coefficients in the shape feature vector are compared to determine the preliminary shape type of the traffic light.
9. The method according to claim 8, characterized in that, The step of determining the preliminary shape type of the traffic light based on the plurality of Fourier descriptor coefficients includes: The first N low-frequency Fourier descriptor coefficients after normalization are selected as the shape feature vector, where N is an integer greater than or equal to 3; Determine the magnitude of the values of each Fourier descriptor coefficient in the shape feature vector; If the value of the first Fourier descriptor coefficient FD1 is the largest in the shape feature vector, then the preliminary shape type is determined to be circular. If the value of the second-order Fourier descriptor coefficient FD2 is the largest in the shape feature vector, then the preliminary shape type is determined to be a U-shaped arrow. If the value of the third-order Fourier descriptor coefficient FD3 is the largest in the shape feature vector, then the preliminary shape type is determined to be a directional arrow.
10. The method according to claim 1, characterized in that, The step of combining the geometric features of the target region to perform a secondary confirmation of the preliminary shape type includes: The overall proportion of valid pixels within the target area is statistically analyzed. If the initial shape type is circular and the overall proportion of the effective pixels is greater than a preset proportion threshold, then the final traffic light shape detection result is confirmed to be circular.
11. The method according to claim 10, characterized in that, The step of combining the geometric features of the target region to perform a secondary confirmation of the preliminary shape type also includes: The proportion of effective pixels in the central region of the target area is statistically analyzed. The hollowness ratio is determined based on the effective pixel ratio of the central region to distinguish between circular traffic lights and digital lights; In addition, the effective pixel ratio of the vertex region of the target area and the preset specific region is statistically analyzed to distinguish U-shaped arrow traffic lights, directional arrow traffic lights and other shapes of traffic lights.
12. A traffic light shape detection device, characterized in that, include: The region determination module is used to acquire the image to be detected and determine the preliminary boundary region of the traffic light based on the color information and position information in the image to be detected. The size processing module is used to determine whether the size of the preliminary boundary region meets the preset size conditions; If the size of the initial boundary region does not meet the preset size condition, the initial boundary region is subjected to size adaptive enlargement processing to obtain the enlarged target region; If the size of the preliminary boundary region meets the preset size condition, then the preliminary boundary region is taken as the target region; A contour extraction module is used to extract the contour of traffic lights from the target area; The initial shape determination module is used to calculate the Fourier descriptor of the traffic light's outline to obtain multiple Fourier descriptor coefficients; and to determine the initial shape type of the traffic light based on the multiple Fourier descriptor coefficients. The secondary confirmation module is used to perform secondary confirmation of the preliminary shape type based on the geometric features of the target area, so as to obtain the final traffic light shape detection result.