Stereo matching method and system based on dual feature extractor and gated attention
Through the combination of dual feature extractors and gated attention, the problem of difficulty in balancing efficiency and accuracy in stereo matching is solved, high-precision disparity prediction of small objects and edge areas is achieved, and robustness and matching accuracy are improved.
Patent Information
- Application Number
- CN202410418797.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-09
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-04-09
AI Technical Summary
In stereo matching, existing deep learning-based methods struggle to strike a balance between efficiency and accuracy, resulting in reduced disparity prediction accuracy for small objects, thin structures, and edge areas.
A stereo matching method based on dual feature extractors and gated attention is adopted. A dual feature extractor is constructed through instance normalization and batch normalization algorithms. Combined with the gated attention mechanism, a variety of information features are extracted and upsampled. Generate dense disparity maps.
Improved feature robustness and matching accuracy, reduced error rates, and achieved competitive performance on multiple datasets, especially efficient and accurate disparity prediction in challenging domains.
Smart Images

Figure CN118314181B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of stereo matching technology, and in particular to a stereo matching method and system based on dual feature extractors and gated attention. Background Art
[0002] Stereo matching is a key aspect of computer understanding of 3D scene information, and has applications in 3D reconstruction, autonomous driving, robot navigation, drones, medical imaging, and more. The main goal of stereo matching is to generate a dense disparity map by establishing correspondences between all pixels in a pair of rectified left and right images. This disparity map is then used to recover depth information through triangulation. Although deep learning-based stereo matching methods have made significant progress in recent years, achieving both high efficiency and high accuracy in stereo matching remains a challenging task.
[0003] Mainstream deep learning-based methods often use downsampling strategies to achieve higher computational efficiency, but this compromises the network's ability to capture fine details. The loss of detail information can lead to incorrect disparity predictions for small objects, thin structures, and edge regions, resulting in a significant reduction in accuracy. Summary of the invention
[0004] To solve the above problems, the present invention aims to propose a stereo matching method and system based on dual feature extractors and gated attention, providing a solution for achieving a balance between efficiency and accuracy.
[0005] To achieve the above object, the present invention provides a stereo matching method based on dual feature extractors and gated attention, the steps comprising:
[0006] Obtain the view image information required for binocular stereo matching;
[0007] Extracting features from the view image information to obtain relevant body features;
[0008] Based on the related volume features, a sparse disparity map is obtained;
[0009] The sparse disparity map is upsampled to obtain a dense disparity map to complete stereo matching.
[0010] Preferably, the view image information includes: a left view image and a right view image; and the related body features include: features with inter-batch information and features with individual instance information.
[0011] Preferably, the method for obtaining the related body features includes: constructing a dual feature extractor based on a convolutional neural network, and using the dual feature extractor to perform feature extraction to obtain the related body features; the method for constructing the dual feature extractor includes: using an instance normalization algorithm and a batch normalization algorithm to respectively construct an instance encoder and a batch encoder, which together constitute a dual feature extractor.
[0012] Preferably, the difference between the instance encoder and the batch encoder is that the normalization method is different, and the instance encoder and the batch encoder have the same structure, including:
[0013] A two-dimensional convolution layer with a convolution kernel size of 7×7, a stride of 2, and a padding of 3 is used to obtain the initial feature information of the image;
[0014] A three-layer residual block is used to downsample the initial feature information of the image to obtain the related body features; wherein the residual block is composed of two layers of two-dimensional convolution layers with a convolution kernel size of 3×3, a step size of 1, and a padding of 1, and one layer of two-dimensional convolution layer with a convolution kernel size of 1×1, and the output channels of the residual block each time are 64, 96, and 128 respectively.
[0015] Preferably, the method for obtaining the sparse disparity map comprises the following two parallel steps:
[0016] The instance encoder is used to construct a global correlation body with the features having the individual instance information in a global receptive field; and the global correlation body is subjected to disparity regression to obtain an initial disparity map;
[0017] The batch encoder is used to construct a gated attention module to enhance the features with inter-batch information to obtain enhanced features; the enhanced features are scanned with a 9×9 fixed-size window to construct a local correlation body.
[0018] Preferably, the method for obtaining the sparse disparity map further comprises: performing six iterative updates on the initial disparity map using an iterative optimization module based on ConvGRU and a local correlation body to obtain the sparse disparity map.
[0019] Preferably, the method for obtaining the global correlation body includes: using a global receptive field to calculate the cosine similarity of the features having the individual instance information to obtain the global correlation body.
[0020] Preferably, the method for obtaining the enhanced features includes: using a gated attention module in combination with a gating mechanism and a scaled dot product mechanism to enhance the features with inter-batch information to obtain the enhanced features.
[0021] Preferably, the constructed gated attention module includes: 6 attention blocks, each of which includes a self-attention layer and a cross-attention layer.
[0022] The present invention also provides a stereo matching system based on dual feature extractors and gated attention, the system is used to implement the above method, including: a collection module, an extraction module, an acquisition module and an upsampling module;
[0023] The acquisition module is used to obtain the view image information required for binocular stereo matching;
[0024] The extraction module is used to extract features from the view image information to obtain relevant body features;
[0025] The acquisition module is used to obtain a sparse disparity map based on the relevant volume features;
[0026] The upsampling module is used to upsample the sparse disparity map to obtain a dense disparity map to complete stereo matching.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] (1) The present invention provides a stereo matching algorithm based on dual feature extractors and gated attention. By combining dual feature extractors based on instance normalization and batch normalization, multiple information features are extracted for constructing a correlation body. This makes it possible to fully extract and utilize context information, making features more robust and information-rich, enhancing the effects of subsequent modules, and reducing the stereo matching error rate. By introducing dual feature extractors and gated attention mechanisms, the correlation between image features can be better captured, improving matching accuracy and efficiency.
[0029] (2) The scheme proposes a gated attention mechanism that can effectively capture long-range feature dependencies, greatly reducing the number of parameters and computing requirements, ensuring operational efficiency while also improving prediction accuracy. This innovative mechanism not only has significant advantages in network design, but also performs well in practical applications, providing a more efficient and reliable solution for solving complex problems. By introducing a gating mechanism, the model can better understand and utilize the correlation between input data, thereby achieving more accurate prediction and reasoning, bringing new ideas and possibilities to research and application in related fields.
[0030] (3) The present invention fully extracts and utilizes the global information and local details in the image to achieve highly accurate prediction while maintaining excellent efficiency, and exhibits competitive performance on multiple datasets, especially in challenging areas including thin structures, transparent objects, and occluded areas. It is able to achieve accurate disparity prediction while maintaining high efficiency, thereby further demonstrating its robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0032] Figure 1 A schematic diagram of a method flow of an embodiment of the present invention;
[0033] Figure 2 It is a schematic diagram of the main framework of an embodiment of the present invention;
[0034] Figure 3 Schematic diagram of the dual feature extractor structure of an embodiment of the present invention; Figure 3 (a) is a schematic diagram of feature changes in a single encoder such as an instance encoder in a dual feature extractor; Figure 3 (b) is a schematic diagram of the specific structure of the residual block;
[0035] Figure 4 is a schematic diagram of a gated attention module according to an embodiment of the present invention;
[0036] Figure 5 Schematic diagram of gated attention according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] 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.
[0038] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0039] Embodiment 1
[0040] like Figure 1 As shown, it is a schematic diagram of the method flow of this embodiment, and the steps include: obtaining the view image information required for binocular stereo matching; performing feature extraction on the view image information to obtain relevant body features; obtaining a sparse disparity map based on the relevant body features; upsampling the sparse disparity map to obtain a dense disparity map, and completing stereo matching.
[0041] The view image information includes: a left view image and a right view image; the related body features include: features with inter-batch information and features with individual instance information. The method for obtaining the related body features includes: constructing a dual feature extractor based on a convolutional neural network, extracting features using the dual feature extractor, and obtaining the related body features; the method for constructing the dual feature extractor includes: constructing an instance encoder and a batch encoder using an instance normalization algorithm and a batch normalization algorithm, respectively, to form a dual feature extractor together.
[0042] The difference between the instance encoder and the batch encoder lies in the different normalization methods. The instance encoder and the batch encoder have the same structure, including: a two-dimensional convolution layer with a convolution kernel size of 7×7, a step size of 2, and a padding of 3, which is used to obtain the initial feature information of the image; three layers of residual blocks, which are used to downsample the initial feature information of the image and obtain related body features; among them, the residual block consists of two layers of two-dimensional convolution layers with a convolution kernel size of 3×3, a step size of 1, and a padding of 1, and one layer of two-dimensional convolution layer with a convolution kernel size of 1×1. The output channels of each residual block are 64, 96, and 128 respectively.
[0043] The method for obtaining a sparse disparity map includes the following two parallel steps:
[0044] An instance encoder is used to construct a global correlation body with features with individual instance information using a global receptive field; and a disparity regression is performed on the global correlation body to obtain an initial disparity map;
[0045] A batch encoder is used to construct a gated attention module to enhance the features with inter-batch information to obtain enhanced features; the enhanced features are scanned with a 9×9 fixed-size window to construct a local correlation body.
[0046] Finally, the initial disparity map is iteratively updated 6 times using the ConvGRU-based iterative optimization module and the local correlation volume to obtain a sparse disparity map.
[0047] The method for obtaining the global correlation body includes: using the global receptive field to calculate the cosine similarity of the features with individual instance information to obtain the global correlation body. The method for obtaining the enhanced features includes: using the gated attention module in combination with the gated mechanism and the scaled dot product mechanism to enhance the features with inter-batch information to obtain the enhanced features. The constructed gated attention module includes: 6 attention blocks, each of which includes a self-attention layer and a cross-attention layer.
[0048] Finally, the sparse disparity map is upsampled to obtain a dense disparity map to complete stereo matching.
[0049] Embodiment 2
[0050] The following will combine this embodiment and Figure 2, and explain in detail how the present invention solves technical problems in actual work.
[0051] First, obtain the left view image and right view image required for binocular stereo matching. This embodiment uses the mainstream standard data set in the field of stereo matching. Specifically, you can download and obtain it by visiting the official website of commonly used public data sets such as SceneFlow, KITTI, ETH3D, Middlebury, etc. These data sets are widely used in this field and can provide important support for the development and evaluation of binocular stereo matching methods.
[0052] Afterwards, a dual feature extractor is constructed based on the convolutional neural network.
[0053] Based on the convolutional neural network, a dual feature extractor is constructed; specifically, an instance encoder and a batch encoder are constructed respectively using the instance normalization algorithm and the batch normalization algorithm, which together constitute the dual feature extractor. The instance encoder and the batch encoder in the dual feature extractor have the same network structure, and only the normalization method is different. The dual feature extractor also includes:
[0054] The first is a two-dimensional convolution layer with a convolution kernel size of 7×7, a stride of 2, and a padding of 3 to obtain the initial feature information of the image.
[0055] Then, the three-layer residual block further downsamples the image features to extract 1 / 8H and 1 / 8W left and right view features.
[0056] like Figure 3 (a) The variation of feature size in a single encoder is shown.
[0057] The residual block consists of two layers of 3×3 convolution kernels, 1 stride, and 1 padding 2D convolution layers, and one layer of 1×1 convolution kernels. The number of output channels of each residual block is 64, 96, and 128, respectively. The specific design is as follows: Figure 3 (b) as shown.
[0058] The dual feature extractor is used to extract features from the left and right view images to obtain left and right view features (specifically, features with inter-batch information and features with individual instance information). The dual feature extractor uses the InstanceNormalization algorithm (instance encoder) and the Batch Normalization algorithm (batch encoder) to process different data in different ranges, and extracts features with inter-batch information and features with specific individual instance information.
[0059] Instance Normalization operates independently of batches and channels, preserving rich and detailed information in a single sample. In contrast, Batch Normalization performs normalization based on batch-wide statistics, reducing the absolute differences between samples and taking into account relative differences. By exploiting the difference between these two features, this embodiment can extract more comprehensive contextual information compared to a single feature extractor structure.
[0060] After that, the left and right view features with separate instance information are used to construct a global correlation volume with a global receptive field. Specifically, matrix multiplication is used to calculate the dot product similarity between all pixels in the entire image. Then, the obtained global correlation is used to derive the matching probability distribution M through the Softmax function. The initial disparity map is obtained by calculating the weighted average of the matching distribution M for all possible horizontal positions G. The value range of the horizontal position G is [0, W-1], where W is the width of the view feature, where:
[0061] G=[0,1,2,3,…,W-1].
[0062] The process can be summarized as follows:
[0063]
[0064] D init =MG-G'
[0065] Among them, I1 and I2 are the left view features and right view features respectively, C is the channel dimension of the feature, and D init is the initial disparity map;
[0066] Afterwards, disparity regression is performed on the global correlation body to obtain an initial disparity map; since the global correlation body is obtained by calculating the matching distribution and thus taking the weighted average of all possible horizontal positions to obtain the initial disparity map, there are no matching areas, so the present invention adopts self-attention calculation to achieve disparity prediction of no matching areas.
[0067] After obtaining the initial disparity map, gated attention is used to enhance the left and right view features with inter-batch information. Specifically, a gated attention module is constructed to calculate the attention of the features and add them to the input features to obtain the attention-weighted result, thereby improving the accuracy of subsequent steps and reducing the error rate of stereo matching.
[0068] Before the features are input into the gated attention module, this embodiment uses absolute position encoding to add position encoding to the features to improve the accuracy of subsequent steps and reduce the error rate.
[0069] like Figure 4, which is a schematic diagram of the gated attention module of this embodiment, where N is the number of attention blocks, which is set to 6 in this embodiment. The gated attention module includes a total of 6 attention blocks, each of which includes a self-attention layer and a cross-attention layer, all of which are constructed by gated attention.
[0070] like Figure 5 As shown in the figure, the gated attention combines the gate mechanism and the scaled dot product attention mechanism. First, the layer normalization (LayerNorm) operation is performed, and then the linear layer is used to map the left and right features to obtain Gate, Query, Key, and Value. First, the scaled dot product attention is calculated, and the Query, Key, and Value are involved in the scaled dot product attention calculation. After the calculation is completed, the calculated attention result is Hadamard-producted with the Gate, and finally the multi-layer perceptron is used to map the attention result and add it to the residual to obtain the output.
[0071] The normalized source feature X source Perform a linear transformation and then pass it through the SigmoidLinearUnit (SiLU) function to obtain Gate and Query. The specific operations are as follows:
[0072] Gate=SiLU(W α *X source +a),
[0073] Query = SiLU(V α *X source +b),
[0074] Where W α and V α is a linear transformation matrix, and α indicates that they are derived from the same linear layer α based on the channel dimension block results. In addition, a and b are learnable biases.
[0075] Similarly, the normalized target feature X target It is linearly mapped and the Key and Value are obtained through the SiLU function, as shown below:
[0076] Key=SiLU(W β *X target +c),
[0077] Value = SiLU(V β *X target +d),
[0078] Where W β and V βis the linear transformation matrix, β indicates that they originate from the same linear layer β based on the channel dimension block results. In addition, c and d are learnable biases.
[0079] The attention scores are calculated by matrix product and normalization of the Query and Key matrices. These scores are then passed to the Softmax function and multiplied by the Value matrix to obtain the attention weights. The final gated attention score is obtained by element-wise multiplying the attention weights with the Gate matrix. Then, this embodiment uses a multi-layer perceptron (MLP) to map the gated attention scores. The MLP in the model of this embodiment consists of two linear layers and a SiLU activation function layer. Due to the existence of the Gate matrix, the hidden layer has the same dimension as the input layer. Finally, the attention score is added to the residual of the source feature. The formula can be expressed as:
[0080]
[0081] Output=MLP(Attention⊙Gate)+Xsource,
[0082] Wherein, L represents the product of the image height and width; C represents the number of channel dimensions of the feature; Output represents the attention weighted output obtained by the Hadamard product; when calculating the attention, this embodiment normalizes the product of Query and Key by the number of channel dimensions C of the feature and the sequence length L to eliminate the influence of the dimension and the sequence length.
[0083] It is worth noting that the linear layer of the gated attention feature map should be twice the number of input feature channels, and the number of channels of the two linear layers in the multi-layer perceptron is equivalent to the number of input feature channels. In this embodiment, the left and right view features with inter-batch information are scanned with a fixed-size window to construct a local correlation body; specifically, the window size is fixed to 9×9. Finally, the initial disparity map is iteratively updated a fixed number of times using the ConvGRU-based iterative optimization module and the local correlation body to obtain a sparse disparity map; specifically, the number of iterations is set to 6 times.
[0084] In this embodiment, the number of iterative updates is set to 6 times, but it is not a fixed number; if the technician needs to obtain faster computing efficiency, the number can be appropriately reduced; conversely, if a more accurate stereo matching prediction is needed, the number of iterative updates can be appropriately adjusted to more.
[0085] After obtaining the sparse disparity map, the bilinear interpolation algorithm is used to upsample the sparse disparity map to obtain a dense disparity map, obtain the disparity, and complete the stereo matching.
[0086] Embodiment 3
[0087] This embodiment also provides a stereo matching system based on a dual feature extractor and gated attention, including: an acquisition module, an extraction module, an acquisition module and an upsampling module; the acquisition module is used to acquire view image information required for binocular stereo matching; the extraction module is used to perform feature extraction on the view image information to obtain relevant body features; the acquisition module is used to obtain a sparse disparity map based on the relevant body features; the upsampling module is used to upsample the sparse disparity map to obtain a dense disparity map to complete stereo matching.
[0088] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A stereo matching method based on dual feature extractors and gated attention, characterized in that: The steps include: Obtain the view image information required for binocular stereo matching; The view image information includes: a left view image and a right view image; Feature extraction is performed on the view image information to obtain related body features; the related body features include: features with batch information and features with individual instance information; a method for obtaining the related body features includes: constructing a dual feature extractor based on a convolutional neural network, and extracting features using the dual feature extractor to obtain the related body features; a method for constructing the dual feature extractor includes: constructing an instance encoder and a batch encoder using an instance normalization algorithm and a batch normalization algorithm respectively, and forming a dual feature extractor together; the instance encoder and the batch encoder are The difference lies in the normalization method. The instance encoder and the batch encoder have the same structure, including: a two-dimensional convolution layer with a convolution kernel size of 7×7, a step size of 2, and a padding of 3, for obtaining the initial feature information of the image; three layers of residual blocks, for downsampling the initial feature information of the image to obtain the related body features; wherein the residual block is composed of two layers of two-dimensional convolution layers with a convolution kernel size of 3×3, a step size of 1, and a padding of 1, and one layer of two-dimensional convolution layer with a convolution kernel size of 1×1, and the output channels of the residual block each time are 64, 96, and 128 respectively; Based on the correlation body features, a sparse disparity map is obtained; the method for obtaining the sparse disparity map includes the following two parallel steps: using the instance encoder to construct a global correlation body with the features having the individual instance information using a global receptive field; and performing disparity regression on the global correlation body to obtain an initial disparity map. The method for obtaining the global correlation body includes: using a global receptive field to calculate the cosine similarity of the features having the individual instance information to obtain the global correlation body; using the batch encoder to construct a gated attention module to perform feature enhancement on the features having inter-batch information to obtain enhanced features. The specific method includes: using a gated attention module in combination with a gating mechanism and a scaled dot product mechanism to enhance the features with inter-batch information to obtain the enhanced features; wherein the constructed gated attention module includes: 6 attention blocks, each of which includes a self-attention layer and a cross-attention layer; scanning the enhanced features with a 9×9 fixed-size window to construct a local correlation body; the method for obtaining the sparse disparity map also includes: using a ConvGRU-based iterative optimization module and a local correlation body to iteratively update the initial disparity map 6 times to obtain the sparse disparity map; The sparse disparity map is upsampled to obtain a dense disparity map, and stereo matching is completed. Specifically, after obtaining the sparse disparity map, a bilinear difference algorithm is used to upsample the sparse disparity map to obtain the dense disparity map, and the disparity is obtained to complete stereo matching.
2. A stereo matching system based on dual feature extractors and gated attention, the system being used to implement the method of claim 1, characterized in that: include: Acquisition module, extraction module, acquisition module and upsampling module; The acquisition module is used to obtain the view image information required for binocular stereo matching; The view image information includes: a left view image and a right view image; The extraction module is used to extract features from the view image information to obtain related body features; the related body features include: features with batch information and features with individual instance information; the method for obtaining the related body features includes: constructing a dual feature extractor based on a convolutional neural network, and extracting features using the dual feature extractor to obtain the related body features; the method for constructing the dual feature extractor includes: constructing an instance encoder and a batch encoder using an instance normalization algorithm and a batch normalization algorithm respectively, and forming a dual feature extractor together; the instance encoder and the batch The difference between the encoders lies in the different normalization methods. The instance encoder and the batch encoder have the same structure, including: a two-dimensional convolution layer with a convolution kernel size of 7×7, a step size of 2, and a padding of 3, for obtaining the initial feature information of the image; three layers of residual blocks, for downsampling the initial feature information of the image to obtain the related body features; wherein the residual block is composed of two layers of two-dimensional convolution layers with a convolution kernel size of 3×3, a step size of 1, and a padding of 1, and one layer of two-dimensional convolution layer with a convolution kernel size of 1×1, and the output channels of the residual block each time are 64, 96, and 128 respectively; The acquisition module is used to obtain a sparse disparity map based on the correlation body features; the method for obtaining the sparse disparity map includes the following two parallel steps: using the instance encoder to construct a global correlation body with the features having the individual instance information using a global receptive field; and performing disparity regression on the global correlation body to obtain an initial disparity map. The method for obtaining the global correlation body includes: using a global receptive field to calculate the cosine similarity of the features having the individual instance information to obtain the global correlation body; using the batch encoder to construct a gated attention module to perform feature enhancement on the features having inter-batch information to obtain an enhanced The specific method includes: using a gated attention module combined with a gating mechanism and a scaled dot product mechanism to enhance the features with inter-batch information to obtain the enhanced features; wherein the constructed gated attention module includes: 6 attention blocks, each of which includes a self-attention layer and a cross-attention layer; scanning the enhanced features with a 9×9 fixed-size window to construct a local correlation body; the method for obtaining the sparse disparity map also includes: using a ConvGRU-based iterative optimization module and a local correlation body to iteratively update the initial disparity map 6 times to obtain the sparse disparity map; The upsampling module is used to upsample the sparse disparity map to obtain a dense disparity map to complete stereo matching. Specifically, after obtaining the sparse disparity map, a bilinear difference algorithm is used to upsample the sparse disparity map to obtain the dense disparity map, obtain disparity, and complete stereo matching.
Citation Information
Patent Citations
Binocular stereo matching method
CN115719424A
Stereo matching method, device and equipment and computer readable storage medium
CN116342530A
