Indoor camera relocation method based on composite attention guidance
Through a composite attention-guided indoor camera relocalization method, combined with multi-network level feature fusion and three-dimensional scene encoding, the problem of insufficient fusion of high-level features and low-level features in the existing technology is solved, and decoupling from sparse textures and repeated scenes is achieved. Features improve the accuracy and stability of visual positioning.
Patent Information
- Application Number
- CN202410801363.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-17
AI Technical Summary
Existing scene coordinate regression methods only use a single path architecture, resulting in a lack of fusion between high-level features and low-level features, inability to effectively distinguish similar image patches, and difficulty in decoupling features from sparse textures and repeated scenes.
An indoor camera relocalization method based on composite attention guidance is adopted, through multi-network level feature fusion, three-dimensional scene coding reconstruction, backbone network feature extraction, semantic feature fusion, image detail restoration and neural network training optimization, combined with Transformer and channel attention Mechanism to realize the integration and feature expression of multi-level contextual information.
It achieves stable fusion of multi-level features, enhances the spatial details and channel information of low-level features, can decouple features from sparse textures and repeated scenes, and improves the accuracy and stability of visual positioning.
Smart Images

Figure CN118657832A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and deep learning methods, and in particular to an indoor camera relocalization method based on composite attention guidance. Background Art
[0002] In recent years, with the rapid development of computer vision technology in the fields of autonomous navigation, path planning, and virtual reality, camera pose estimation has also made great progress. Existing scene coordinate regression methods only use a single path architecture for regression, resulting in a lack of fusion between high-level features and low-level features. Low-level features that retain rich structural information and spatial details help distinguish similar image blocks. In order to enhance feature expression, it is a good idea to directly fuse features at different levels. Summary of the invention
[0003] The purpose of this invention is to provide a composite attention-guided indoor camera relocalization method that enables multi-level context fusion to decouple features from sparse textures and repetitive scenes.
[0004] The technical solution adopted by the present invention is as follows:
[0005] The indoor camera relocalization method based on composite attention guidance is implemented in the following steps:
[0006] Step 1, image feature extraction;
[0007] Step 2: Multi-network level feature fusion;
[0008] Step 3: 3D scene coding and reconstruction;
[0009] Step 4, the backbone network performs feature extraction;
[0010] Step 5: semantic feature fusion;
[0011] Step 6, image detail restoration;
[0012] Step 7, neural network training optimization;
[0013] Step 8: Model strategy training and optimization.
[0014] The present invention is characterized in that:
[0015] Specifically:
[0016] Step 1: Use the Transformer-based hierarchical encoder-decoder structure to perform in-depth feature extraction on RGB images;
[0017] Step 2: Multi-network level feature fusion: The deep features extracted from Transformer are fused with the features extracted from other networks to obtain a more comprehensive and rich feature representation.
[0018] Step 3, 3D scene coding and reconstruction: Based on the fused feature representation, the scene is 3D encoded and reconstructed to generate a more accurate description and understanding of the scene;
[0019] Step 4: Feature extraction using the backbone network: Use the backbone network to continue extracting features to capture higher-level semantic and structural information;
[0020] Step 5, semantic feature fusion: The semantic features from different networks and steps are fused to obtain a more representative and robust feature representation;
[0021] Step 6, image detail restoration: based on feature fusion, image details are restored and enhanced to improve image quality and detail information;
[0022] Step 7, neural network training optimization: design appropriate loss functions, training strategies and optimization methods to train the neural network and optimize its parameters;
[0023] Step 8: Model strategy training optimization: Further optimize the model's training strategy, including learning rate adjustment, regularization method, etc., to improve the model's generalization ability and performance.
[0024] Step 1 is implemented as follows:
[0025] Step 1.1, input image segmentation, input RGB image Split into non-overlapping patches of size P×P, each patch is considered as a token;
[0026] Step 1.2, linear projection, linearly project each token and map it to a higher dimensional feature space
[0027] Step 1.3, feature merging, use the Patch Merging module to merge adjacent patch features to achieve downsampling of the feature map. In this process, the number of tokens is reduced by 4 times, and the channel dimension is expanded by 2 times through linear transformation;
[0028] Step 1.4, multi-stage feature extraction, build 4 Transformer Blocks, the output of each stage is used as the input of the next stage, and 4 feature maps with different resolutions are generated
[0029] Step 1.5, feature map upsampling and concatenation, restore the low-resolution feature map to high resolution by upsampling, and concatenate it with the high-resolution features in the decoder through jump connections to aggregate high-level and low-level feature information. The resolution of the final output feature map X is
[0030] Step 2 is implemented as follows:
[0031] Step 2.1, multi-scale feature extraction network: design feature extraction networks of multiple scales, which are responsible for extracting feature representations at different levels;
[0032] Step 2.2, feature pyramid fusion: Through the feature pyramid structure, features from different network levels are fused to comprehensively utilize multi-scale information at different resolutions;
[0033] Step 2.3, channel attention mechanism: Introduce the channel attention mechanism to model the importance of different feature channels, thereby achieving more effective feature fusion and selection.
[0034] Step 3 is implemented as follows:
[0035] Step 3.1, 3D feature extraction, select a network structure suitable for 3D scene data, use the indoor camera relocalization method based on multi-level composite attention to encode and reconstruct the 3D scene through deep learning technology, and obtain a scene coordinate prediction map corresponding to the input image; through the 2D-3D correspondence between the coordinate map and the scene; through the camera projection matrix P, the pixel coordinates (u, v) in the image are converted into the 3D coordinates (X w ,Y w ,Z w ), the camera projection matrix P can be expressed as:
[0036] P=K·H (1)
[0037] Where K is the camera intrinsic parameter matrix, and H is the current camera pose matrix. The scene coordinates can be expressed as:
[0038]
[0039] Where P -1 is the inverse of the projection matrix.
[0040] Step 3.2, scene coding compression, encodes the extracted 3D feature representation into a more compact high-dimensional vector, uses attention blocks to fuse multi-level context information, and improves positioning performance by refining feature maps at different levels;
[0041] In step 3.3, the relative features between image patches are considered and the similarities between image patches are processed.
[0042] Step 4 is implemented as follows:
[0043] Step 4.1, feature map segmentation, the input multi-scale feature map Split into N patches of equal size Each patch is a specific area in the feature map, where
[0044] Step 4.2, backbone network selection, select the backbone network structure suitable for the task;
[0045] Step 4.3, apply spatial attention to the result p of channel attention i ′Apply spatial attention, the formula is as follows:
[0046]
[0047] In the formula, Represents channel attention, and the spatial attention function βi acts on pi′ to generate a spatial weight map This weight map reflects the importance of different spatial positions. Subsequently, the spatial weight map is nonlinearly transformed by the activation function δ(·).
[0048] Step 4.4, feature aggregation and refinement, the result of spatial attention p″ i With the original patch p i Splicing is performed in the channel dimension; the spliced features are refined through spatial global average pooling to obtain a fine The formula is as follows:
[0049] z i =ρ([p″ i ,p i ]),i=1,2,…,N (4)
[0050] Where ρ(·) represents global spatial average pooling, and [·] represents feature concatenation operation;
[0051] Step 4.5: Feature reorganization: repeat the above steps for all patches and rearrange all the obtained fine tokens to form an ordered feature sequence. One-dimensional convolution is used to reduce the dimension of the channels of the token sequence Z to meet the input requirements of the subsequent network layers.
[0052] Step 5 is implemented as follows:
[0053] Step 5.1, apply 1×1 convolution to complete the information interaction between channels, and use parallel branches and add an additional layer of 1×1 convolution operation to balance the information flow between branches. The output of this stage can be expressed as:
[0054]
[0055] In the formula, f l is the low-level input feature map, f h is a high-level semantic feature, P global (·) is global average pooling; C 1×1 is a 1×1 convolution; δ is a sigmoid function; is element-wise addition, is element-wise multiplication; f o1 is the output feature map; it should be noted that the feature map output by CR3 after EAM is both the high-level feature f h , and as the low-level feature f l Participate in calculations.
[0056] Finally, Concat(·) is used to process the feature map f o1 , f o2 Perform channel connection operation to obtain a powerful discriminant feature f res :
[0057] f res =Concat(f o1 , f o2 ) (6)
[0058] Step 5.2: Apply a feedforward network to the output of the multi-head attention to further extract features. The formula is as follows:
[0059] FFN(E i ′) = ReLU(E i ′·W1+b1)·W2+b2 (7)
[0060] Where W1 and W2 are learnable weight matrices, b1 and b2 are the corresponding bias terms, and ReLU(·) is the activation function used to introduce nonlinearity;
[0061] Step 5.3, layer normalization and residual connection, the output of the feedforward network is normalized, and residual connections are added to enhance the learning ability and stability of the model. The formula is as follows:
[0062] E″ i =LN(E′ i +FFN(E′ i )) (8)
[0063] Where LN(·) is the layer normalization operation, which normalizes each feature channel.
[0064] Step 6 is implemented as follows:
[0065] Step 6.1, detail enhancement network: Design a detail enhancement network to recover and enhance image detail information from feature maps, improve image quality and detail clarity;
[0066] Step 6.2, deconvolution operation, through deconvolution and other operations, the feature map is restored to the same size as the original image and more detailed information is retained;
[0067] Step 6.3, the embedded attention module is applied to adjust the low-level features according to the rich semantic information contained in the high-level features, reducing the problem of information loss during feature transmission;
[0068] Step 6.4, dynamic adjustment of feature maps, enhances the representation ability of the model and improves the performance and generalization ability of the model in various visual tasks;
[0069] The output of this stage can be expressed as:
[0070]
[0071] In the formula, the given input feature map x l , x m , x h ∈R C×H×W , x l is the low-level feature map, x h is a high-level semantic feature map, A(·) is an attention module, and 1-A(·) represents the dotted part of the figure; the attention fusion weights A(·) and 1-A(·) are both real numbers between 0 and 1, which enables the network to perform weighted averaging or dynamic selection between feature maps at different levels;
[0072] Then, the output feature y of the EAM module is obtained by connecting the attention fusion feature maps y1 and y2 of two adjacent levels. out , which can be expressed as:
[0073] y out =Concat(y1,y2) (10).
[0074] Step 7 is implemented as follows:
[0075] Step 7.1, pose loss function design and introduction, design a loss function suitable for the task, introduce the reprojection error as an additional loss function for better adjustment of the model, its expression is as follows:
[0076]
[0077] The pose loss function can be expressed as:
[0078] L pose (h,h * )=‖xx * ‖+β(θ,θ * ) (12)
[0079] Where, L pose (h,h * ) represents the pose loss function, which is used to evaluate the difference between the camera pose h and the true pose h*. x and x* represent the pose features corresponding to the pose, θ and θ * Represent the rotation angles of the camera pose and the true pose respectively, and β is the coefficient of the angle loss function; β is set to 100 to balance the weight of the rotation angle loss in the entire loss function. In addition, in order to optimize the loss in Equation 3-15, it is necessary to ensure that each of its components is differentiable;
[0080] Step 7.2, training strategy, the model is gradually refined from coarse to fine strategy during model training; in the initial stage, the model is preliminarily trained based on the reprojection error; then, in order to further improve the performance of the model, the pose loss constraint is introduced as an adjustment method, thereby obtaining a more optimized final model.
[0081] Step 8 is implemented as follows:
[0082] Step 8.1, learning rate adjustment, design learning rate scheduling strategy;
[0083] Step 8.2, regularization method: introduce the regularization method;
[0084] Step 8.3, model evaluation: evaluate and compare model performance through methods such as cross-validation, adjust model parameters and hyperparameters, and improve model performance;
[0085] Step 8.4, calculate the image reprojection error, the formula is as follows:
[0086] L r (I t ,I t→t′ )=μ·L p (I t ,I t′ ) (13).
[0087] The beneficial effects of the present invention are:
[0088] The present invention is based on the indoor camera relocalization method guided by composite attention. The feature information of different levels is integrated through a multi-level feature fusion module, and an embedded attention module (EAM) is embedded to improve the feature maps of different levels and enhance the spatial details and channel information of low-level feature maps. The method decouples features from sparse textures and repeated scenes through multi-level context fusion, so that the network can achieve stable and accurate visual localization. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] Figure 1 is the backbone network model of the present invention;
[0090] Figure 2 It is the scene coordinate visualization of the present invention;
[0091] Figure 3 It is the MFF module structure diagram of the present invention;
[0092] Figure 4 is the embedded attention module of the present invention;
[0093] Figure 5 It is the visualized error output of the present invention for the selected image under complex conditions. DETAILED DESCRIPTION
[0094] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments;
[0095] Example 1
[0096] The overall framework of the indoor camera relocalization method based on composite attention guidance is as follows: Figure 1 As shown, the specific implementation steps are as follows:
[0097] Step 1, image feature extraction;
[0098] Step 2: Multi-network level feature fusion;
[0099] Step 3: 3D scene coding and reconstruction;
[0100] Step 4, the backbone network performs feature extraction;
[0101] Step 5: semantic feature fusion;
[0102] Step 6, image detail restoration;
[0103] Step 7, neural network training optimization;
[0104] Step 8: Model strategy training and optimization.
[0105] Example 2
[0106] The indoor camera relocalization method based on composite attention guidance of the present invention is specifically implemented according to the following steps:
[0107] Step 1: Use the Transformer-based hierarchical encoder-decoder structure to perform in-depth feature extraction on RGB images;
[0108] Step 2: Multi-network level feature fusion: The deep features extracted from Transformer are fused with the features extracted from other networks to obtain a more comprehensive and rich feature representation.
[0109] Step 3, 3D scene coding and reconstruction: Based on the fused feature representation, the scene is 3D encoded and reconstructed to generate a more accurate description and understanding of the scene;
[0110] Step 4: Feature extraction using the backbone network: Use the backbone network to continue extracting features to capture higher-level semantic and structural information;
[0111] Step 5, semantic feature fusion: The semantic features from different networks and steps are fused to obtain a more representative and robust feature representation;
[0112] Step 6, image detail restoration: based on feature fusion, image details are restored and enhanced to improve image quality and detail information;
[0113] Step 7, neural network training optimization: design appropriate loss functions, training strategies and optimization methods to train the neural network and optimize its parameters;
[0114] Step 8: Model strategy training optimization: Further optimize the model's training strategy, including learning rate adjustment, regularization method, etc., to improve the model's generalization ability and performance.
[0115] Example 3
[0116] The indoor camera relocalization method based on composite attention guidance of the present invention is specifically implemented according to the following steps:
[0117] Step 1 is the feature extraction module of the input image. The hierarchical Transformer module is used to extract features from the input image. The specific steps are as follows:
[0118] Step 1.1, input image segmentation, input RGB image Split into non-overlapping patches of size P×P, each patch is considered as a token;
[0119] Step 1.2, linear projection, linearly project each token and map it to a higher dimensional feature space
[0120] Step 1.3, feature merging, use the Patch Merging module to merge adjacent patch features to achieve downsampling of the feature map. In this process, the number of tokens is reduced by 4 times, and the channel dimension is expanded by 2 times through linear transformation;
[0121] Step 1.4, multi-stage feature extraction, build 4 Transformer Blocks, the output of each stage is used as the input of the next stage, and 4 feature maps with different resolutions are generated
[0122] Step 1.5, feature map upsampling and concatenation, restore the low-resolution feature map to high resolution by upsampling, and concatenate it with the high-resolution features in the decoder through jump connections to aggregate high-level and low-level feature information. The resolution of the final output feature map X is
[0123] Step 2 is to fuse the multi-network level features, and integrate the feature information of different levels through the multi-level feature fusion (MFF) module. The specific steps are as follows:
[0124] Step 2.1, multi-scale feature extraction network: design feature extraction networks of multiple scales, which are responsible for extracting feature representations at different levels;
[0125] Step 2.2, feature pyramid fusion: Through the feature pyramid structure, features from different network levels are fused to comprehensively utilize multi-scale information at different resolutions;
[0126] Step 2.3, channel attention mechanism: Introduce the channel attention mechanism to model the importance of different feature channels, thereby achieving more effective feature fusion and selection.
[0127] Step 3 is the 3D scene coding and reconstruction module, and the specific steps are as follows:
[0128] Step 3.1, 3D feature extraction, select a network structure suitable for 3D scene data, use the indoor camera relocalization method based on multi-level composite attention to encode and reconstruct the 3D scene through deep learning technology, and obtain a scene coordinate prediction map corresponding to the input image, such as Figure 2 As shown in the figure. Through the 2D-3D correspondence between the coordinate graph and the scene, the cumbersome feature matching steps in the traditional method are eliminated, and the accuracy of scene modeling is effectively improved. This method converts the pixel coordinates (u, v) in the image into the three-dimensional coordinates (X w ,Y w ,Z w). The camera projection matrix P can be expressed as:
[0129] P=K·H (1)
[0130] Where K is the camera intrinsic parameter matrix, and H is the current camera pose matrix. The scene coordinates can be expressed as:
[0131]
[0132] Where P -1 is the inverse of the projection matrix.
[0133] Step 3.2, scene coding compression, encodes the extracted 3D feature representation into a more compact high-dimensional vector, uses attention blocks to fuse multi-level context information, and improves positioning performance by refining feature maps at different levels;
[0134] Step 3.3, considering the relative features between image blocks and processing the similarities between image blocks, thereby improving the accuracy of camera positioning;
[0135] Step 4 is to perform feature extraction on the backbone network. The specific steps are as follows:
[0136] Step 4.1, feature map segmentation, the input multi-scale feature map Split into N patches of equal size Each patch is a specific area in the feature map, where
[0137] Step 4.2, backbone network selection, select a backbone network structure suitable for the task, such as ResNet, VGG, etc., to efficiently extract the feature representation of the input data;
[0138] Step 4.3, such as Figure 3 As shown, applying spatial attention to the result of channel attention p i ′Apply spatial attention, the formula is as follows:
[0139]
[0140] In the formula, Represents channel attention, spatial attention function β i Acting on p i ′, generate a spatial weight map This weight map reflects the importance of different spatial positions. Subsequently, the spatial weight map is nonlinearly transformed by the activation function δ(·).
[0141] Step 4.4, feature aggregation and refinement, the result of spatial attention p″ i With the original patch pi Splicing is performed in the channel dimension; the spliced features are refined through spatial global average pooling to obtain a fine The formula is as follows:
[0142] z i =ρ([p″ i ,p i ]),i=1,2,…,N (4)
[0143] Where ρ(·) represents global spatial average pooling, and [·] represents feature concatenation operation;
[0144] Step 4.5: Feature reorganization: repeat the above steps for all patches and rearrange all the obtained fine tokens to form an ordered feature sequence. And use one-dimensional convolution to reduce the dimension of the channel of token sequence Z to meet the input requirements of subsequent network layers;
[0145] Step 5 is to build a semantic feature fusion module to fuse the semantic features from different networks and steps. The specific steps are as follows:
[0146] Step 5.1, such as Figure 4 As shown, 1×1 convolution is applied to complete the information interaction between channels. At the same time, parallel branches are used and an additional layer of 1×1 convolution operation is added to balance the information flow between its branches. The output of this stage can be expressed as:
[0147]
[0148] Where f l is the low-level input feature map, f h is a high-level semantic feature, P global (·) is global average pooling; C 1×1 is a 1×1 convolution; δ is a sigmoid function; is element-wise addition, is element-wise multiplication; f o1 is the output feature map. It should be noted that the feature map output by CR3 after EAM is both the high-level feature f h , and as the low-level feature f l Participate in calculations.
[0149] Finally, Concat(·) is used to process the feature map f o1 , f o2 Perform channel connection operation to obtain a powerful discriminant feature f res :
[0150] f res =Concat(fo1 , f o2 ) (6)
[0151] Step 5.2: Apply a feedforward network to the output of the multi-head attention to further extract features. The formula is as follows:
[0152] FFN(E i ′) = ReLU(E i ′·W1+b1)·W2+b2 (7)
[0153] Where W1 and W2 are learnable weight matrices, b1 and b2 are the corresponding bias terms, and ReLU(·) is the activation function used to introduce nonlinearity;
[0154] Step 5.3, layer normalization and residual connection, the output of the feedforward network is normalized, and residual connections are added to enhance the learning ability and stability of the model. The formula is as follows:
[0155] E″ i =LN(E′ i +FFN(E′ i )) (8)
[0156] Where LN(·) is the layer normalization operation, which normalizes each feature channel;
[0157] Step 6 is to construct an image detail recovery module, and the specific steps are as follows:
[0158] Step 6.1, detail enhancement network: Design a detail enhancement network to recover and enhance image detail information from feature maps, improve image quality and detail clarity;
[0159] Step 6.2, deconvolution operation, through deconvolution and other operations, the feature map is restored to the same size as the original image and more detailed information is retained;
[0160] Step 6.3, the embedded attention module is applied to adjust the low-level features according to the rich semantic information contained in the high-level features, reducing the problem of information loss during the feature transmission process. This dynamic selection mechanism helps the network to better focus on important features, thereby improving the feature representation ability and model performance. ;
[0161] Step 6.4, dynamic adjustment of feature maps, enhances the representation ability of the model and improves the performance and generalization ability of the model in various visual tasks;
[0162] The output of this stage can be expressed as:
[0163]
[0164] In the formula, the given input feature map x l , x m , x h ∈R C×H×W , x l is the low-level feature map, x h is a high-level semantic feature map, A(·) is an attention module, and 1-A(·) represents the dotted line part in the figure. The attention fusion weights A(·) and 1-A(·) here are both real numbers between 0 and 1, which enables the network to perform weighted averaging or dynamic selection between feature maps at different levels.
[0165] Then, the output feature y of the EAM module is obtained by connecting the attention fusion feature maps y1 and y2 of two adjacent levels. out , which can be expressed as:
[0166] y out =Concat(y1,y2) (10)
[0167] EAM helps the network to more accurately capture and integrate feature information by adaptively reorganizing the channel and spatial dimensions, thereby alleviating the problem of feature loss. While retaining high-level semantic information, it also captures low-level structural information that is critical for positioning, providing a strong guarantee for subsequent scene coordinate regression.
[0168] Step 7 is the neural network training optimization module, which is implemented in the following steps:
[0169] Step 7.1, introduce the pose loss function design, design a loss function suitable for the task, and introduce the reprojection error as an additional loss function to better adjust the model. Its expression is as follows:
[0170]
[0171] The pose loss function can be expressed as:
[0172] L pose (h,h * )=||xx * ||+β(θ,θ * ) (12)
[0173] Where, L pose (h,h * ) represents the pose loss function, which is used to evaluate the difference between the camera pose h and the true pose h*. x and x* represent the pose features corresponding to the pose, θ and θ *Represent the rotation angles of the camera pose and the true pose, respectively, and β is the coefficient of the angle loss function. In this chapter, β is set to 100 to balance the weight of the rotation angle loss in the entire loss function. In addition, in order to optimize the loss in Equation 3-15, it is necessary to ensure that each of its components is differentiable.
[0174] Step 7.2, training strategy, the model is gradually refined by adopting a coarse-to-fine strategy during model training. In the initial stage, the model is initially trained based on the reprojection error, such as Figure 5 Subsequently, in order to further improve the performance of the model, the pose loss constraint was introduced as an adjustment method, thereby obtaining a more optimized final model.
[0175] Step 8 is model strategy training optimization, which further optimizes the model's training strategy. The specific steps are as follows:
[0176] Step 8.1, learning rate adjustment, design learning rate scheduling strategies, such as learning rate decay, dynamic adjustment and other methods, to balance the convergence speed and performance of the model;
[0177] Step 8.2, Regularization method: Introduce regularization methods, such as L1 / L2 regularization, Dropout, etc., to prevent overfitting and improve the generalization ability of the model;
[0178] Step 8.3, model evaluation: Evaluate and compare model performance through cross-validation and other methods, adjust model parameters and hyperparameters, and improve model performance
[0179] Step 8.4, calculate the image reprojection error, the formula is as follows:
[0180] L r (I t ,I t→t′ )=μ·L p (I t ,I t′ ) (13).
[0181] The present invention is based on a composite attention-guided indoor camera relocalization method, which generates a powerful feature representation for visual positioning by adaptively coupling multi-level context features. The embedded attention module (EAM) uses channel attention and spatial attention mechanisms to enable the network to more flexibly adjust weights during feature extraction and representation, thereby effectively avoiding the transmission of redundant features and enabling the network to more accurately capture key information and structural features in the image, thereby reducing the negative impact of viewpoint changes and motion blur. Multi-level context fusion is used to decouple features from sparse textures and repeated scenes, so that the network can achieve stable and accurate visual positioning.
Claims
1. An indoor camera relocalization method based on composite attention guidance, characterized in that: Please follow the steps below to implement: Step 1, image feature extraction; Step 2: Multi-network level feature fusion; Step 3: 3D scene coding and reconstruction; Step 4, the backbone network performs feature extraction; Step 5: semantic feature fusion; Step 6, image detail restoration; Step 7, neural network training optimization; Step 8: Model strategy training and optimization.
2. The indoor camera relocalization method based on composite attention guidance according to claim 1, characterized in that: Specifically: Step 1: Use the Transformer-based hierarchical encoder-decoder structure to perform in-depth feature extraction on RGB images; Step 2: Multi-network level feature fusion: The deep features extracted from Transformer are fused with the features extracted from other networks to obtain a more comprehensive and rich feature representation. Step 3, 3D scene coding and reconstruction: Based on the fused feature representation, the scene is 3D encoded and reconstructed to generate a more accurate description and understanding of the scene; Step 4: Feature extraction using the backbone network: Use the backbone network to continue extracting features to capture higher-level semantic and structural information; Step 5, semantic feature fusion: The semantic features from different networks and steps are fused to obtain a more representative and robust feature representation; Step 6, image detail restoration: based on feature fusion, image details are restored and enhanced to improve image quality and detail information; Step 7, neural network training optimization: design appropriate loss functions, training strategies and optimization methods to train the neural network and optimize its parameters; Step 8: Model strategy training optimization: Further optimize the model's training strategy, including learning rate adjustment, regularization method, etc., to improve the model's generalization ability and performance.
3. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 1 is specifically implemented according to the following steps: Step 1.1, input image segmentation, input RGB image Split into non-overlapping patches of size P×P, each patch is considered as a token; Step 1.2, linear projection, linearly project each token and map it to a higher dimensional feature space Step 1.3, feature merging, using the Patch Merging module to merge adjacent patch features to achieve downsampling of the feature map; in this process, the number of tokens is reduced by 4 times, and the channel dimension is expanded by 2 times through linear transformation; Step 1.4, multi-stage feature extraction, build 4 Transformer Blocks, the output of each stage is used as the input of the next stage, and 4 feature maps with different resolutions are generated Step 1.5, feature map upsampling and concatenation, restore the low-resolution feature map to high resolution by upsampling, and concatenate it with the high-resolution features in the decoder through jump connections to aggregate high-level and low-level feature information. The resolution of the final output feature map X is 4. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 2 is specifically implemented according to the following steps: Step 2.1, multi-scale feature extraction network: design feature extraction networks of multiple scales, which are responsible for extracting feature representations at different levels; Step 2.2, feature pyramid fusion: Through the feature pyramid structure, features from different network levels are fused to comprehensively utilize multi-scale information at different resolutions; Step 2.3, channel attention mechanism: Introduce the channel attention mechanism to model the importance of different feature channels, thereby achieving more effective feature fusion and selection.
5. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 3 is specifically implemented according to the following steps: Step 3.1, 3D feature extraction, select a network structure suitable for 3D scene data, use the indoor camera relocalization method based on multi-level composite attention to encode and reconstruct the 3D scene through deep learning technology, and obtain a scene coordinate prediction map corresponding to the input image; through the 2D-3D correspondence between the coordinate map and the scene; through the camera projection matrix P, the pixel coordinates (u, v) in the image are converted into the 3D coordinates (X w ,Y w ,Z w ), the camera projection matrix P can be expressed as: P = K·H (1) where K is the camera intrinsic parameter matrix, H is the current camera pose matrix, and the scene coordinates can be expressed as: Where P -1 is the inverse matrix of the projection matrix; Step 3.2, scene coding compression, encodes the extracted 3D feature representation into a more compact high-dimensional vector, uses attention blocks to fuse multi-level context information, and improves positioning performance by refining feature maps at different levels; In step 3.3, the relative features between image patches are considered and the similarities between image patches are processed.
6. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 4 is specifically implemented according to the following steps: Step 4.1, feature map segmentation, the input multi-scale feature map Split into N equal sized Each patch is a specific area in the feature map, where and Step 4.2, backbone network selection, select the backbone network structure suitable for the task; Step 4.3, apply spatial attention to the result p′ of channel attention i Applying spatial attention, the formula is as follows: In the formula, Represents channel attention, spatial attention function β i Acting on p′ i , generating a spatial weight map This weight map reflects the importance of different spatial positions. Subsequently, the spatial weight map is nonlinearly transformed by the activation function δ(·). Step 4.4, feature aggregation and refinement, the result of spatial attention p″ i With the original patch p i Splicing is performed in the channel dimension; the spliced features are refined through spatial global average pooling to obtain a fine The formula is as follows: z i =ρ([p″ i ,p i ]),i=1,2,…,N (4) Where ρ(·) represents global spatial average pooling, and [·] represents feature concatenation operation; Step 4.5: Feature reorganization: repeat the above steps for all patches and rearrange all the obtained fine tokens to form an ordered feature sequence. One-dimensional convolution is used to reduce the dimension of the channels of the token sequence Z to meet the input requirements of the subsequent network layers.
7. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 5 is specifically implemented according to the following steps: Step 5.1, apply 1×1 convolution to complete the information interaction between channels, and use parallel branches and add an additional layer of 1×1 convolution operation to balance the information flow between branches. The output of this stage can be expressed as: In the formula, f l is the low-level input feature map, f h is a high-level semantic feature, P global (·) is global average pooling; c 1×1 is a 1×1 convolution; δ is a sigmoid function; is element-wise addition, is element-wise multiplication; f o1 is the output feature map; it should be noted that the feature map output by CR3 after EAM is both the high-level feature f h , and as the low-level feature f l Participate in calculations; Finally, Concat(·) is used to process the feature map f o1 , f o2 Perform channel connection operation to obtain a powerful discriminant feature f res : f res =Concat(f o1 ,f o2 ) (6) Step 5.2: Apply a feedforward network to the output of the multi-head attention to further extract features. The formula is as follows: FFN(E i ′)=ReLU(E i ′·W1+b1)·W2+b2 (7) Where W1 and W2 are learnable weight matrices, b1 and b2 are the corresponding bias terms, and ReLU(·) is the activation function used to introduce nonlinearity; Step 5.3, layer normalization and residual connection, the output of the feedforward network is normalized, and residual connections are added to enhance the learning ability and stability of the model. The formula is as follows: HAVE BEEN" i =LN(E′ i +FFN(E′ i )) (8) Where LN(·) is the layer normalization operation, which normalizes each feature channel.
8. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 6 is specifically implemented according to the following steps: Step 6.1, detail enhancement network: Design a detail enhancement network to recover and enhance image detail information from feature maps, improve image quality and detail clarity; Step 6.2, deconvolution operation, through deconvolution and other operations, the feature map is restored to the same size as the original image and more detailed information is retained; Step 6.3, the embedded attention module is applied to adjust the low-level features according to the rich semantic information contained in the high-level features, reducing the problem of information loss during feature transmission; Step 6.4, dynamic adjustment of feature maps, enhances the representation ability of the model and improves the performance and generalization ability of the model in various visual tasks; The output of this stage can be expressed as: In the formula, the given input feature map x l , x m , x h ∈R C×H×W , x l is the low-level feature map, x h is a high-level semantic feature map, A(·) is an attention module, and 1-A(·) represents the dotted part of the figure; the attention fusion weights A(·) and 1-A(·) are both real numbers between 0 and 1, which enables the network to perform weighted averaging or dynamic selection between feature maps at different levels; Then, the output feature y of the EAM module is obtained by connecting the attention fusion feature maps y1 and y2 of two adjacent levels. out , which can be expressed as: y out =Concat(y1,y2) (10)。 9. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 7 is specifically implemented according to the following steps: Step 7.1, pose loss function design and introduction, design a loss function suitable for the task, introduce the reprojection error as an additional loss function for better adjustment of the model, its expression is as follows: The pose loss function can be expressed as: L pose (h,h * )=‖xx * ‖+β(θ,θ * ) (12) Where, L pose (h,h * ) represents the pose loss function, which is used to evaluate the difference between the camera pose h and the true pose h*. x and x* represent the pose features corresponding to the pose, θ and θ * Represent the rotation angles of the camera pose and the true pose respectively, and β is the coefficient of the angle loss function; β is set to 100 to balance the weight of the rotation angle loss in the entire loss function. In addition, in order to optimize the loss in Equation 3-15, it is necessary to ensure that each of its components is differentiable; Step 7.2, training strategy, the model is gradually refined from coarse to fine strategy during model training; in the initial stage, the model is preliminarily trained based on the reprojection error; then, in order to further improve the performance of the model, the pose loss constraint is introduced as an adjustment method, thereby obtaining a more optimized final model.
10. The indoor camera relocalization method based on composite attention guidance according to claim 2, characterized in that: The step 8 is specifically implemented according to the following steps: Step 8.1, learning rate adjustment, design learning rate scheduling strategy; Step 8.2, regularization method: introduce the regularization method; Step 8.3, model evaluation: evaluate and compare model performance through cross-validation, adjust model parameters and hyperparameters, and improve model performance; Step 8.4, calculate the image reprojection error, the formula is as follows: L r (AND t ,AND t→t′ )=μ·L p (AND t ,AND t′ ) (13)。
Citation Information
Cited By
Visual relocation method combining graph attention and region classification
CN119399550A
Deep learning camera pose estimation method, system and device and storage medium
CN119810192A
