Traffic text detection method, device, equipment and medium
Through a combination of low-light image enhancement, ResNet50 network feature extraction, Lanczos interpolation and deformable convolution kernel feature fusion, variable region candidate network and CBAM module, the accuracy and stability of traffic text detection in low-light environments are solved. problem, achieving efficient traffic text positioning and detection.
Patent Information
- Application Number
- CN202210503666.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-05-10
AI Technical Summary
The existing traffic text detection technology has low detection accuracy in low illumination environments, and the high-frequency components of the image are seriously lost. The traditional convolution kernel cannot adapt to the scale and receptive field size, and the ordinary area candidate network and area of interest pooling cannot effectively handle large areas. For text with an aspect ratio, non-maximum value suppression is not effective.
The low-light image enhancement algorithm is used to process the original image, the ResNet50 network is used to extract features and feature enhancement is based on the attention mechanism, the two-dimensional Lanczos interpolation algorithm is used for upsampling, and the preset horizontal and vertical convolution kernels are combined for feature extraction and Fusion, using a variable region candidate network and anchor boxes for target proposal frame processing, and non-maximum suppression through deformable region of interest pooling and CBAM modules.
It improves the accuracy and stability of traffic text detection, reduces the loss of high-frequency components of images, enhances feature expression, achieves effective processing and precise positioning of low-illumination images, and saves detection time.
Smart Images

Figure CN114882471B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a traffic text detection method, device, equipment and medium. Background Art
[0002] At present, traffic text detection is mostly used in the visual perception link of unmanned driving systems. A large amount of noise in the environment will affect the judgment of the unmanned driving system on the target detection object, thereby affecting the system's control of the unmanned vehicle. In addition, traffic text contains different languages. In my country, each piece of traffic text includes Chinese and English (including pinyin), and these two languages contain text types of varying sizes. Each piece of traffic text has huge differences in visual features between different languages or different text types of the same language, and the image may also contain some complex environmental factors. Therefore, fine positioning of traffic text is a problem that needs to be solved in this field.
[0003] Although many effective methods have emerged, the detection of traffic texts is still under study, and the rapid development of the unmanned driving industry has made it more necessary for traffic text detection technology to keep pace with the times. First, due to the large-scale variation characteristics of traffic texts, if only the image features in a single direction are considered, the detection accuracy of the detector based on bounding box regression will be greatly reduced. Secondly, most of the upsampling technologies for traffic text detection currently choose bilinear interpolation as the image interpolation algorithm, but the bilinear interpolation method only considers the influence of the grayscale values of the four direct neighboring points around the sample point to be tested, which leads to the loss of high-frequency components of the scaled image, making the image edge more blurred to a certain extent. When the image acquisition environment is weak light, the acquired image lacks a certain degree of clarity, and there is currently a lack of enhancement operations for the features of traffic text information in the image, which will cause too much computing resources to be wasted on the processing of useless information. In addition, most detection algorithms choose traditional convolution kernels to convolve the target object, but traditional convolution units can only sample at fixed positions on the N×N input feature map grid, and cannot adapt to the scale or receptive field size. Furthermore, each anchor point of the general region proposal network (RPN) will only generate candidate boxes with nine fixed aspect ratios, while traffic texts are mostly texts with large aspect ratios, which will affect the accuracy. In addition, the general region of interest pooling (ROI Pooling) reduces the spatial resolution at a fixed ratio and lacks an internal mechanism to handle geometric transformations. Moreover, the traditional non-maximum suppression can no longer meet the requirements of text box screening. Although a large number of non-maximum algorithms have been proposed, most of them are based on a single method such as overlapping areas and border positions.
[0004] Therefore, avoiding the above-mentioned defects in the traffic text detection process is an urgent problem to be solved in this field. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a traffic text detection method, device, equipment and medium, which can enhance low-light images, enhance feature expression, reduce the loss of high-frequency components of scaled images, enhance detection accuracy, obtain more accurate target positioning and produce more stable detection results. The specific scheme is as follows:
[0006] In a first aspect, the present application discloses a traffic text detection method, comprising:
[0007] The collected original image is enhanced by using a low-light image enhancement algorithm to obtain a target image, and features of the target image are extracted by using a ResNet50 network. Then, feature enhancement operations are performed on the extracted feature map based on an attention mechanism to obtain an enhanced feature map.
[0008] The enhanced feature map is upsampled by a two-dimensional Lanczos interpolation algorithm, and feature extraction is performed on the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then feature fusion is performed on the horizontal feature map and the vertical feature map obtained after the extraction;
[0009] The fused feature map is processed based on the preset variable region candidate network and the preset anchor frames with different aspect ratios to obtain the target proposal frame;
[0010] The target proposal box is pooled using deformable region of interest pooling, and the corresponding processing result is input into a fully connected layer for regression processing to obtain a regressed proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text;
[0011] The channel attention feature map and the spatial attention feature map of the regressed proposal box are extracted through the CBAM module, and a non-maximum suppression operation is performed on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
[0012] Optionally, the step of performing image enhancement processing on the collected original image using a low-light image enhancement algorithm to obtain a target image includes:
[0013] The LIME algorithm is used to perform image enhancement processing on the collected original image to obtain the target image.
[0014] Optionally, performing a feature enhancement operation on the extracted feature map based on the attention mechanism to obtain an enhanced feature map includes:
[0015] The extracted feature map is processed based on the attention mechanism to obtain a first feature map;
[0016] Performing a product operation on the first feature map and the feature map obtained after extraction to obtain a second feature map;
[0017] The second feature map is subjected to feature fusion with the feature map obtained after the extraction to obtain an enhanced feature map.
[0018] Optionally, the processing of the fused feature map based on the preset variable region candidate network and the preset anchor frames with different aspect ratios to obtain the target proposal frame includes:
[0019] The feature map obtained by feature fusion of the extracted horizontal feature map and the vertical feature map is divided into different sub-regions, and a preset anchor frame with different aspect ratios is set for each sub-region;
[0020] Based on a preset variable region candidate network and based on the fused feature map provided with the anchor frame, a target proposal frame is determined.
[0021] Optionally, the determining the target proposal frame based on the preset variable region candidate network and the fused feature map provided with the anchor frame includes:
[0022] Using the deformable convolution unit in the preset variable region candidate network, a deformable convolution operation is performed on the fused feature map provided with the anchor frame to obtain a first operation result;
[0023] Performing an operation on the first operation result by using a bilinear interpolation algorithm to obtain a second operation result;
[0024] The convolution unit in the preset variable region candidate network is used to perform a convolution operation on the second operation result to obtain a proposal frame, and then the target proposal frame is determined based on the proposal frame.
[0025] Optionally, determining the target proposal frame based on the proposal frame includes:
[0026] The proposal box is mapped to the target image to obtain a corresponding mapping result, and a preset number of the proposal boxes are screened out from the proposal box as the target proposal box according to the mapping result.
[0027] Optionally, the filtering out a preset number of the proposal frames from the proposal frames as the target proposal frames according to the mapping result includes:
[0028] According to the mapping result, the proposal boxes whose parts after mapping exceed the boundary of the target image and reach a preset size are eliminated, and the remaining proposal boxes after the elimination are used as the first filtered proposal boxes;
[0029] The non-maximum suppression operation is performed on the first filtered proposal frame, and a preset number of proposal frames are filtered out from the second filtered proposal frame obtained after the operation as the target proposal frame.
[0030] In a second aspect, the present application discloses a traffic text detection device, comprising:
[0031] An image enhancement module is used to perform image enhancement processing on the collected original image using a low-light image enhancement algorithm to obtain a target image;
[0032] A first feature extraction module is used to extract features of the target image using a ResNet50 network, and then perform a feature enhancement operation on the feature map obtained after the extraction based on an attention mechanism to obtain an enhanced feature map;
[0033] A second feature extraction module is used to upsample the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extract features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then perform feature fusion on the horizontal feature map and the vertical feature map obtained after extraction;
[0034] A target proposal frame determination module is used to process the fused feature map based on a preset variable region candidate network and preset anchor frames of different aspect ratios to obtain a target proposal frame;
[0035] A post-regression proposal box determination module is used to perform pooling processing on the target proposal box using deformable region of interest pooling, and input the corresponding processing result into the fully connected layer for regression processing to obtain a post-regression proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text;
[0036] The target prediction box determination module is used to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform a non-maximum suppression operation on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
[0037] In a third aspect, the present application discloses an electronic device, comprising:
[0038] Memory, used to store computer programs;
[0039] The processor is used to execute the computer program to implement the aforementioned disclosed traffic text detection method.
[0040] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed traffic text detection method is implemented.
[0041] It can be seen that the present application proposes a traffic text detection method, including: using a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and using a ResNet50 network to extract features of the target image, and then performing feature enhancement operation on the feature map obtained after extraction based on an attention mechanism to obtain an enhanced feature map; upsampling the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extracting features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then performing feature fusion on the extracted horizontal feature map and the vertical feature map; based on a preset variable region candidate network and a preset The anchor frames of different aspect ratios are set to process the feature map obtained after fusion to obtain a target proposal frame; the target proposal frame is pooled using deformable region of interest pooling, and the corresponding processing results are input into the fully connected layer for regression processing to obtain a regressed proposal frame and a corresponding classification result, and the classification result is used to indicate whether the text in the target image is the target traffic text; the channel attention feature map and the spatial attention feature map of the regressed proposal frame are extracted through the CBAM module, and the extracted feature map is subjected to non-maximum suppression operation to obtain a target prediction frame; wherein, the target prediction frame is used to predict the regional position of the target traffic text on the target image. It can be seen that the present application first uses a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and uses a ResNet50 network to extract features of the target image, and then performs a feature enhancement operation on the feature map obtained after extraction based on the attention mechanism, thereby being able to perform image enhancement on the low-light image and enhance the feature expression; then the enhanced feature map is upsampled by a two-dimensional Lanczos interpolation algorithm, thereby reducing the loss of high-frequency components of the image after scaling, making the image edge smoother to a certain extent, and being able to better complete the extraction and interpolation of two-dimensional image data; in addition, the present application is based on the shape and width of traffic text The invention takes advantage of the aspect ratio of traffic text and proposes to extract features in the vertical and horizontal directions, and proposes several anchor boxes with different aspect ratios, thereby improving the detection accuracy. Moreover, the invention uses deformable convolution to adapt the scale or receptive field size of irregular objects corresponding to different positions, thereby obtaining a more accurate positioning target. In addition, the use of deformable region of interest pooling is conducive to processing dense traffic text in a simple and efficient form. Finally, it is proposed to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform non-maximum suppression operation on the spatial and channel information, thereby saving detection time and facilitating the generation of more stable detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0043] Figure 1 A flow chart of a traffic text detection method disclosed in this application;
[0044] Figure 2 A flow chart of a specific traffic text detection method disclosed in this application;
[0045] Figure 3 A sub-flow chart of a specific traffic text detection method disclosed in this application;
[0046] Figure 4 A flow chart of a specific traffic text detection method disclosed in this application;
[0047] Figure 5 A schematic diagram of a variable region candidate network structure disclosed in this application;
[0048] Figure 6 Schematic diagram of a deformable convolutional layer structure;
[0049] Figure 7 A schematic diagram of a deformable region of interest pooling structure;
[0050] Figure 8 This is a schematic diagram of the structure of a traffic text detection device disclosed in this application;
[0051] Fig. 9 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] Due to the large-scale variation characteristics of traffic text, if only the image features in a single direction are considered, the detection accuracy of the detector based on bounding box regression will be greatly reduced. Secondly, most of the upsampling technologies for traffic text detection currently choose bilinear interpolation as the image interpolation algorithm, which will make the image edge blurry to a certain extent. When the image acquisition environment is weak light, the acquired image lacks a certain clarity, and there is currently a lack of enhancement operations for the features of traffic text information in the image, which will cause too many computing resources to be wasted on the processing of useless information. In addition, the traditional convolution unit can only sample at a fixed position on the N×N input feature map grid, so it cannot adapt to the scale or receptive field size. Furthermore, each anchor point of the ordinary region candidate network will only generate candidate boxes with nine fixed aspect ratios, while most traffic texts are large aspect ratio texts, so it will affect the accuracy. In addition, the ordinary region of interest pooling reduces the spatial resolution at a fixed ratio and lacks an internal mechanism for processing geometric transformations. Moreover, traditional non-maximum suppression can no longer meet the requirements of text box screening. Although a large number of non-maximum algorithms have been proposed, most of them are based on a single method such as overlapping areas and border positions.
[0054] To this end, an embodiment of the present application proposes a traffic text detection solution that can perform image enhancement on low-light images, enhance feature expression, reduce the loss of high-frequency components of images after scaling, improve detection accuracy, obtain more precise target positioning, and produce more stable detection results.
[0055] The present application embodiment discloses a traffic text detection method, see Figure 1 As shown, the method includes:
[0056] Step S11: Use a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and use a ResNet50 network to extract features of the target image, and then perform feature enhancement operations on the extracted feature map based on the attention mechanism to obtain an enhanced feature map.
[0057] In this embodiment, it is first necessary to use a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image. The low-light image enhancement algorithm includes but is not limited to the LIME algorithm. In this way, subsequent feature extraction can be performed after obtaining a bright image. It should be noted that the method of collecting images in this embodiment includes but is not limited to collecting through a vehicle-mounted camera.
[0058] In this embodiment, the ResNet50 network is used to extract features of the target image, and the feature enhancement operation is performed on the feature map obtained after extraction based on the attention mechanism, thereby enhancing the feature expression.
[0059] It should be pointed out that the specific process of performing feature enhancement operation on the extracted feature map based on the attention mechanism to obtain the enhanced feature map is: processing the extracted feature map based on the attention mechanism to obtain a first feature map; multiplying the first feature map with the extracted feature map to obtain a second feature map; and performing feature fusion on the second feature map and the extracted feature map to obtain an enhanced feature map.
[0060] Step S12: upsampling the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extracting features from the upsampled feature map based on preset horizontal convolution kernels and vertical convolution kernels, and then performing feature fusion on the extracted horizontal feature map and vertical feature map.
[0061] In this embodiment, the Lanczos interpolation algorithm is used to replace the bilinear interpolation algorithm fixedly used in most upsampling layers. Since the bilinear interpolation method only considers the influence of the grayscale values of the four direct neighboring points around the sample point to be measured, it leads to the loss of high-frequency components of the scaled image, making the image edge blurred to a certain extent. The two-dimensional Lanczos interpolation algorithm interpolates the eight adjacent points in the direction of the target point. Therefore, this embodiment makes the image edge smoother to a certain extent, and can better complete the extraction and interpolation of two-dimensional image data.
[0062] Step S13: Based on the preset variable region candidate network and the preset anchor frames with different aspect ratios, the fused feature map is processed to obtain a target proposal frame.
[0063] It is understandable that each anchor point of an ordinary region candidate network will only generate candidate boxes with nine fixed aspect ratios, and traffic texts are mostly texts with large aspect ratios, so it will affect the accuracy. This embodiment proposes several anchor boxes with different aspect ratios based on the large aspect ratio characteristics of traffic texts, thereby improving the accuracy of traffic text detection.
[0064] Step S14: The target proposal box is pooled using deformable region of interest pooling, and the corresponding processing result is input into the fully connected layer for regression processing to obtain a regressed proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text.
[0065] It should be pointed out that ordinary ROI Pooling reduces the spatial resolution at a fixed ratio and lacks an internal mechanism for processing geometric transformations. Therefore, this embodiment uses deformable ROI Pooling to pool the target proposal box, which is conducive to processing dense traffic text in a simple and efficient form.
[0066] Step S15: extracting the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and performing a non-maximum suppression operation on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
[0067] In this embodiment, the channel attention feature map and the spatial attention feature map are extracted from the regressed proposal box through the CBAM module, and the feature map obtained after extraction is subjected to non-maximum suppression operation to obtain the target prediction box. It should be pointed out that the non-maximum suppression operation (SC NMS) based on spatial and channel information can take less time and is conducive to producing more stable detection results.
[0068] It can be seen that the present application proposes a traffic text detection method, including: using a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and using a ResNet50 network to extract features of the target image, and then performing feature enhancement operation on the feature map obtained after extraction based on an attention mechanism to obtain an enhanced feature map; upsampling the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extracting features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then performing feature fusion on the extracted horizontal feature map and the vertical feature map; based on a preset variable region candidate network and a preset The anchor frames of different aspect ratios are set to process the feature map obtained after fusion to obtain a target proposal frame; the target proposal frame is pooled using deformable region of interest pooling, and the corresponding processing results are input into the fully connected layer for regression processing to obtain a regressed proposal frame and a corresponding classification result, and the classification result is used to indicate whether the text in the target image is the target traffic text; the channel attention feature map and the spatial attention feature map of the regressed proposal frame are extracted through the CBAM module, and the extracted feature map is subjected to non-maximum suppression operation to obtain a target prediction frame; wherein, the target prediction frame is used to predict the regional position of the target traffic text on the target image. It can be seen that the present application first uses a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and uses a ResNet50 network to extract features of the target image, and then performs a feature enhancement operation on the feature map obtained after extraction based on the attention mechanism, thereby being able to perform image enhancement on the low-light image and enhance the feature expression; then the enhanced feature map is upsampled by a two-dimensional Lanczos interpolation algorithm, thereby reducing the loss of high-frequency components of the image after scaling, making the image edge smoother to a certain extent, and being able to better complete the extraction and interpolation of two-dimensional image data; in addition, the present application is based on the shape and width of traffic text The invention takes advantage of the aspect ratio of traffic text and proposes to extract features in the vertical and horizontal directions, and proposes several anchor boxes with different aspect ratios, thereby improving the detection accuracy. Moreover, the invention uses deformable convolution to adapt the scale or receptive field size of irregular objects corresponding to different positions, thereby obtaining a more accurate positioning target. In addition, the use of deformable region of interest pooling is conducive to processing dense traffic text in a simple and efficient form. Finally, it is proposed to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform non-maximum suppression operation on the spatial and channel information, thereby saving detection time and facilitating the generation of more stable detection results.
[0069] The embodiment of the present application discloses a specific method for detecting traffic text. Compared with the previous embodiment, the present embodiment further explains and optimizes the technical solution. Figure 2 As shown, specifically including:
[0070] Step S21: Use a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and use a ResNet50 network to extract features of the target image, and then perform feature enhancement operations on the extracted feature map based on the attention mechanism to obtain an enhanced feature map.
[0071] Step S22: upsampling the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extracting features from the upsampled feature map based on preset horizontal convolution kernels and vertical convolution kernels, and then performing feature fusion on the extracted horizontal feature map and vertical feature map.
[0072] Step S23: dividing the feature map obtained by feature fusion of the horizontal feature map and the vertical feature map obtained after extraction into different sub-regions, and setting a preset anchor frame with a different aspect ratio for each of the sub-regions.
[0073] It should be noted that, compared to the common region proposal network (RPN) in which each anchor point only generates candidate boxes with fixed nine aspect ratios, this embodiment designs anchor boxes with different aspect ratios based on the shape of the traffic text. In a specific implementation, the preset anchor boxes with different aspect ratios in this embodiment can be specifically: {1, 2, 3, 5, 1 / 2, 1 / 3, 1 / 5}.
[0074] Step S24: determining a target proposal frame based on a preset variable region candidate network and based on the fused feature map provided with the anchor frame.
[0075] In this embodiment, based on a preset variable region candidate network and based on the fused feature map provided with the anchor frame, a target proposal frame is determined, thereby improving detection accuracy.
[0076] Step S25: The target proposal box is pooled using deformable region of interest pooling, and the corresponding processing result is input into the fully connected layer for regression processing to obtain a regressed proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text.
[0077] Step S26: extracting the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and performing a non-maximum suppression operation on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
[0078] Among them, the more specific working process of step S21, step S22, step S25 and step S26 can be found in the aforementioned disclosed embodiment, and will not be described in detail here.
[0079] It can be seen that the present application proposes to divide the feature map obtained after feature fusion of the horizontal feature map obtained after extraction and the vertical feature map into different sub-regions, and set a preset anchor frame with a different aspect ratio for each sub-region, and determine the target proposal frame based on the preset variable region candidate network and the fused feature map with the anchor frame, thereby improving the detection accuracy.
[0080] The present application embodiment is a further refinement of step S24, see Figure 3 As shown, the embodiment of the present application specifically includes:
[0081] Step S241: using the deformable convolution unit in the preset variable region candidate network, performing a deformable convolution operation on the fused feature map provided with the anchor frame to obtain a first operation result.
[0082] Step S242: performing an operation on the first operation result by using a bilinear interpolation algorithm to obtain a second operation result.
[0083] Step S243: using the convolution unit in the preset variable region candidate network, performing a convolution operation on the second operation result, and then determining the target proposal frame based on the proposal frame to obtain a proposal frame.
[0084] In this embodiment, determining the target proposal frame based on the proposal frame to obtain the proposal frame includes: mapping the proposal frame to the target image to obtain a corresponding mapping result, and filtering a preset number of the proposal frames from the proposal frame as the target proposal frame according to the mapping result.
[0085] Specifically, according to the mapping result, the proposal boxes whose parts exceed the boundary of the target image and reach a preset size after mapping are eliminated, and the remaining proposal boxes after elimination are used as the first filtered proposal boxes; the non-maximum suppression operation is performed on the first filtered proposal boxes, and a preset number of proposal boxes are filtered out from the second filtered proposal boxes obtained after the operation as the target proposal boxes.
[0086] That is, in this embodiment, the scale or receptive field size of irregular objects corresponding to different positions is adapted through deformable convolution, so as to obtain a more accurate positioning of the target.
[0087] Based on the traffic text detection method, the specific process of this application can be found in Figure 4 As shown:
[0088] S1. Preprocess the original image
[0089] The original image is preprocessed for image enhancement based on a low illumination enhancement algorithm. It should be noted that the low illumination enhancement algorithm may be a LIME algorithm. Specifically, the algorithm first estimates the illumination of each pixel individually by finding the maximum value in the R, G, and B channels, then sets a structural prior on the initial illumination map for refinement to obtain a final illumination map, and finally generates an enhanced image based on the final illumination map.
[0090] S2. Send the enhanced image to the feature extraction network
[0091] This application uses a deep residual network, such as ResNet50, as the backbone network for extracting features, and gives the feature map X∈R extracted from the ResNet50 network H×W×D , which is then used as the input of the attention module and outputs the spatially normalized attention weight map A∈R through a 1×1 convolutional layer H×W Then multiply the attention weight map A by X to obtain the attention feature X a ∈R H×W×D , X a The features are fused with X to obtain an enhanced feature map, which is then provided to the subsequent modules.
[0092] S3. Upsampling the enhanced feature map
[0093] Two-dimensional Lanczos interpolation is to interpolate eight adjacent points in the x and y directions of the target point. The weights of these points are calculated by the high-order function L(x), which is defined as follows:
[0094]
[0095] L(x,y)=L(x)·L(y);
[0096]
[0097] In the formula, r = 3, L(x)·L(y) is the weight obtained in the x and y axis directions, and L(x, y) is calculated from this, and then the pixel value of the unknown point is obtained by weighted average through the interpolation function S(x, y).
[0098] S4. Further feature extraction of the upsampled feature map
[0099] After obtaining the feature map with up-sampled resolution, convolution is performed using 1×k and k×1 horizontal and vertical convolution kernels to obtain a feature map that is more suitable for the text characteristics of traffic text. After obtaining the feature maps in two directions, their features are fused.
[0100] S5. Send the fused features to the Deformable RPN module
[0101] The receptive field of traditional convolutional layers is the same for all activation units, which makes it unable to adapt to objects of different sizes or deformations. In order to alleviate the impact of this defect, this application introduces deformable convolution into the region proposal network and replaces the first 3×3 standard convolution of the region proposal network with 3×3 deformable convolution to adapt to input features. Figure 5 Schematic diagram of the candidate network structure of the variable region. Figure 6 Schematic diagram of the deformable convolutional layer structure.
[0102] In the variable convolutional layer, a regular 3×3 grid R is used to sample the input feature map, which is offset by {Δp n |n=1,...,N} gradually increases, and N=|R|, for each position p0 on the output feature map λ:
[0103]
[0104] Where w is the weight of the deformable convolution, p n is an enumeration of the positions listed in the grid R. Δp n It is obtained by applying an additional 3×3 convolutional layer on the input features, namely:
[0105] Δp n =Conv(x(p0));
[0106] At this time, sampling is done at irregular and offset positions p n +Δp n Due to the offset Δp n It is usually a decimal, so the formula x(p) can be obtained by bilinear interpolation:
[0107]
[0108] In the formula, p represents any position p=p0+p n +Δp n, q enumerates all the global spatial locations in the feature map x, and G(·,·) is the kernel of bilinear interpolation, which is divided into two one-dimensional kernels:
[0109] G(q,p)=g(q x ,p x )·g(q y ,p y );
[0110] g(u,v)=max(0,1-|uv|);
[0111] After calculating the value of x(p) through bilinear interpolation, the ordinary 3×3 convolution calculation formula λ(p0) is performed to obtain the final output mapping, followed by the next convolution operation of the region candidate network.
[0112] Finally, the anchor boxes in the proposals preliminarily determined by the variable region candidate network are mapped back to the original image to determine whether the preliminarily determined proposals exceed the boundary to a large extent. The anchor boxes that seriously exceed the boundary are removed and sorted from large to small according to the scores. The top 2000 preliminarily determined proposals are extracted, non-maximum suppression is performed on these 2000 proposals, the obtained candidate boxes are sorted again, and the top 300 proposals are output.
[0113] S6: Input the proposal generated after the variable region candidate network into the deformable region of interest pool
[0114] In this application, deformable ROI pooling is used to replace traditional ROI pooling, which can process dense modules such as traffic text in a simple, efficient, and end-to-end manner. The schematic diagram of the deformable ROI pooling structure can be found in Figure 7 shown.
[0115] S7. After the deformable region of interest is pooled, the results are respectively sent to two fully connected layers (FC), one to obtain a classification result and the other to obtain a regression box result. The classification result is used to indicate the probability that the final result is a traffic text.
[0116] S8. The regression box result output by the fully connected layer is represented by the CBAM module (the attention module of the convolutional block) to express the spatial and channel sensitive maps on the left, right, top and bottom sides, so as to combine the channel information and spatial information to perform SC non-maximum suppression to complete the final bounding box prediction;
[0117] A new non-maximum suppression method is proposed using the channel attention feature map Mc and the spatial attention feature map Ms of the CBAM module branch, which acts on the weights of the upper, lower, left, and right boundaries of the text instance in the fusion stage. Given two boxes a and b, indexes 1, 2, 3, and 4 correspond to the upper left, upper right, lower right, and lower left vertices of the box. The spatial sensitive map is labeled L_s, R_s, U_s, and D_s in the order of left, right, upper, and lower. The channel sensitive map is similarly labeled L_c, R_c, U_c, and D_c. Therefore, the channel-space perception box fusion function can be expressed as:
[0118] m i (x) = (L_s(a)·a i (x)+L_s(b)·b i (x)+L_c(a)·a i (x)+L_c(b)·b i (x)) / L(m),i=1,4;
[0119] m j (x) = (R_s(a)·a j (x)+R_s(b)·b j (x)+R_c(a)·a j (x)+R_c(b)·b j (x)) / R(m),j=2,3;
[0120] m z (y)=(U_s(a)·a z (y)+U_s(b)·b z (y)+U_c(a)·a z (y)+U_c(b)·b z (y)) / U(m),z=1,2;
[0121] m k (y) = (D_s(a)·a k (y)+D_s(b)·b k (y)+D_c(a)·a k (y)+D_c(b)·b k (y)) / D(m), k=3,4;
[0122] ψ(m)=ψ_s(a)+ψ_s(b)+ψ_c(a)+ψ_c(b);
[0123] ψ(m)∈{L,R,U,D},ψ_s∈{L_s,R_s,U_s,D_s},ψ_c∈{L_c,R_c,U_c,D_c};
[0124] In the formula, m is the fusion frame, mi (x) and m z (y) are the x-coordinate of the i-th vertex and the y-coordinate of the z-th vertex of box m respectively (same for a and b), L_s(·) represents the value in the left sensitive map corresponding to the box space (same for R_s, U_s, and D_s), and L_c(·) represents the value in the left sensitive map corresponding to the box channel (same for R_c, U_c, and D_c).
[0125] Correspondingly, the present application embodiment also discloses a traffic text detection device, see Figure 8 As shown, the device comprises:
[0126] The image enhancement module 11 is used to perform image enhancement processing on the collected original image using a low-light image enhancement algorithm to obtain a target image;
[0127] A first feature extraction module 12 is used to extract features of the target image using a ResNet50 network, and then perform a feature enhancement operation on the feature map obtained after the extraction based on an attention mechanism to obtain an enhanced feature map;
[0128] The second feature extraction module 13 is used to upsample the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extract features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then perform feature fusion on the horizontal feature map and the vertical feature map obtained after extraction;
[0129] A target proposal frame determination module 14 is used to process the fused feature map based on a preset variable region candidate network and preset anchor frames with different aspect ratios to obtain a target proposal frame;
[0130] A post-regression proposal frame determination module 15 is used to perform pooling processing on the target proposal frame using deformable region of interest pooling, and input the corresponding processing result into the fully connected layer for regression processing to obtain a post-regression proposal frame and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is a target traffic text;
[0131] The target prediction box determination module 16 is used to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform a non-maximum suppression operation on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
[0132] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0133] It can be seen that the present application proposes a traffic text detection method, including: using a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and using a ResNet50 network to extract features of the target image, and then performing feature enhancement operation on the feature map obtained after extraction based on an attention mechanism to obtain an enhanced feature map; upsampling the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extracting features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then performing feature fusion on the extracted horizontal feature map and the vertical feature map; based on a preset variable region candidate network and a preset The anchor frames of different aspect ratios are set to process the feature map obtained after fusion to obtain a target proposal frame; the target proposal frame is pooled using deformable region of interest pooling, and the corresponding processing results are input into the fully connected layer for regression processing to obtain a regressed proposal frame and a corresponding classification result, and the classification result is used to indicate whether the text in the target image is the target traffic text; the channel attention feature map and the spatial attention feature map of the regressed proposal frame are extracted through the CBAM module, and the extracted feature map is subjected to non-maximum suppression operation to obtain a target prediction frame; wherein, the target prediction frame is used to predict the regional position of the target traffic text on the target image. It can be seen that the present application first uses a low-light image enhancement algorithm to perform image enhancement processing on the collected original image to obtain a target image, and uses a ResNet50 network to extract features of the target image, and then performs a feature enhancement operation on the feature map obtained after extraction based on the attention mechanism, thereby being able to perform image enhancement on the low-light image and enhance the feature expression; then the enhanced feature map is upsampled by a two-dimensional Lanczos interpolation algorithm, thereby reducing the loss of high-frequency components of the image after scaling, making the image edge smoother to a certain extent, and being able to better complete the extraction and interpolation of two-dimensional image data; in addition, the present application is based on the shape and width of traffic text The invention takes advantage of the aspect ratio of traffic text and proposes to extract features in the vertical and horizontal directions, and proposes several anchor boxes with different aspect ratios, thereby improving the detection accuracy. Moreover, the invention uses deformable convolution to adapt the scale or receptive field size of irregular objects corresponding to different positions, thereby obtaining a more accurate positioning target. In addition, the use of deformable region of interest pooling is conducive to processing dense traffic text in a simple and efficient form. Finally, it is proposed to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform non-maximum suppression operation on the spatial and channel information, thereby saving detection time and facilitating the generation of more stable detection results.
[0134] Furthermore, an embodiment of the present application also provides an electronic device. Fig. 9This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0135] Fig. 9 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the traffic text detection method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0136] In this embodiment, the power supply 26 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0137] In addition, the memory 22, as a carrier for storing resources, may be a read-only memory, a random access memory, a disk or an optical disk, etc., and the resources stored thereon may include a computer program 221, and the storage method may be temporary storage or permanent storage. In addition to including a computer program that can be used to complete the traffic text detection method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 221 may further include a computer program that can be used to complete other specific tasks.
[0138] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed traffic text detection method is implemented.
[0139] For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0140] The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0141] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0142] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0143] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0144] The above is a detailed introduction to a traffic text detection method, device, equipment, and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A traffic text detection method, characterized in that: include: The collected original image is enhanced by using a low-light image enhancement algorithm to obtain a target image, and features of the target image are extracted by using a ResNet50 network. Then, feature enhancement operations are performed on the extracted feature map based on an attention mechanism to obtain an enhanced feature map. The enhanced feature map is upsampled by a two-dimensional Lanczos interpolation algorithm, and feature extraction is performed on the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then feature fusion is performed on the horizontal feature map and the vertical feature map obtained after the extraction; The fused feature map is processed based on the preset variable region candidate network and the preset anchor frames with different aspect ratios to obtain the target proposal frame; The target proposal box is pooled using deformable region of interest pooling, and the corresponding processing result is input into a fully connected layer for regression processing to obtain a regressed proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text; The channel attention feature map and the spatial attention feature map of the regressed proposal box are extracted through the CBAM module, and a non-maximum suppression operation is performed on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
2. The traffic text detection method according to claim 1, characterized in that: The method of performing image enhancement processing on the collected original image using a low-light image enhancement algorithm to obtain a target image includes: The LIME algorithm is used to perform image enhancement processing on the collected original image to obtain the target image.
3. The traffic text detection method according to claim 1, characterized in that: The feature enhancement operation is performed on the feature map obtained after extraction based on the attention mechanism to obtain the enhanced feature map, including: The extracted feature map is processed based on the attention mechanism to obtain a first feature map; Performing a product operation on the first feature map and the feature map obtained after extraction to obtain a second feature map; The second feature map is subjected to feature fusion with the feature map obtained after the extraction to obtain an enhanced feature map.
4. The traffic text detection method according to any one of claims 1 to 3, characterized in that: The method processes the fused feature map based on the preset variable region candidate network and the preset anchor frames with different aspect ratios to obtain a target proposal frame, including: The feature map obtained by feature fusion of the extracted horizontal feature map and the vertical feature map is divided into different sub-regions, and a preset anchor frame with a different aspect ratio is set for each sub-region; Based on a preset variable region candidate network and based on the fused feature map provided with the anchor frame, a target proposal frame is determined.
5. The traffic text detection method according to claim 4, characterized in that: The method of determining a target proposal frame based on a preset variable region candidate network and on the fused feature map provided with the anchor frame includes: Using the deformable convolution unit in the preset variable region candidate network, a deformable convolution operation is performed on the fused feature map provided with the anchor frame to obtain a first operation result; Performing an operation on the first operation result by using a bilinear interpolation algorithm to obtain a second operation result; The convolution unit in the preset variable region candidate network is used to perform a convolution operation on the second operation result to obtain a proposal frame, and then the target proposal frame is determined based on the proposal frame.
6. The traffic text detection method according to claim 5, characterized in that: The determining the target proposal frame based on the proposal frame includes: The proposal box is mapped to the target image to obtain a corresponding mapping result, and a preset number of the proposal boxes are screened out from the proposal box as the target proposal box according to the mapping result.
7. The traffic text detection method according to claim 6, characterized in that: The step of selecting a preset number of the proposal frames from the proposal frames as the target proposal frames according to the mapping result includes: According to the mapping result, the proposal boxes whose parts after mapping exceed the boundary of the target image and reach a preset size are eliminated, and the remaining proposal boxes after the elimination are used as the first filtered proposal boxes; The non-maximum suppression operation is performed on the first filtered proposal frame, and a preset number of proposal frames are filtered out from the second filtered proposal frame obtained after the operation as the target proposal frame.
8. A traffic text detection device, characterized in that: include: An image enhancement module is used to perform image enhancement processing on the collected original image using a low-light image enhancement algorithm to obtain a target image; A first feature extraction module is used to extract features of the target image using a ResNet50 network, and then perform a feature enhancement operation on the feature map obtained after the extraction based on an attention mechanism to obtain an enhanced feature map; A second feature extraction module is used to upsample the enhanced feature map through a two-dimensional Lanczos interpolation algorithm, and extract features from the feature map obtained after upsampling based on a preset horizontal convolution kernel and a vertical convolution kernel, and then perform feature fusion on the horizontal feature map and the vertical feature map obtained after extraction; A target proposal frame determination module is used to process the fused feature map based on a preset variable region candidate network and preset anchor frames of different aspect ratios to obtain a target proposal frame; A post-regression proposal box determination module is used to perform pooling processing on the target proposal box using deformable region of interest pooling, and input the corresponding processing result into the fully connected layer for regression processing to obtain a post-regression proposal box and a corresponding classification result, wherein the classification result is used to indicate whether the text in the target image is the target traffic text; The target prediction box determination module is used to extract the channel attention feature map and the spatial attention feature map of the regressed proposal box through the CBAM module, and perform a non-maximum suppression operation on the extracted feature map to obtain a target prediction box; wherein the target prediction box is used to predict the regional position of the target traffic text on the target image.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the traffic text detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the traffic text detection method according to any one of claims 1 to 7 is implemented.
