Monocular distance measurement method for target in front of vehicle based on edgecam-depth network
By integrating multiple attention and edge perception modules through the EdgeCAM-Depth network, the problem of insufficient prediction accuracy and scale uncertainty in monocular depth ranging in complex scenes is solved, achieving high-precision and robust depth ranging, which is suitable for ranging of targets in front of autonomous vehicles.
Patent Information
- Application Number
- CN202511362259.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-23
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2045-09-23
AI Technical Summary
Existing monocular depth ranging technology suffers from problems such as insufficient prediction accuracy, blurred object edges, and scale uncertainty in complex road scenarios, making it difficult to meet the high-precision requirements of autonomous vehicles for ranging targets ahead.
The EdgeCAM-Depth network is adopted, which integrates the Channel and Spatial Attention Module (CBAM), the Edge Awareness Module, the Skip Connection Attention Module, and the Multi-Scale Depth Prediction Head. Through multi-layer feature extraction and loss function optimization, the accuracy and robustness of depth prediction are improved.
It significantly improves the accuracy and robustness of monocular depth ranging, and can generate clear and sharp depth maps in complex environments, meeting the high-precision ranging requirements of autonomous vehicles.
Smart Images

Figure CN121170739B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a monocular ranging method for targets in front of vehicles based on EdgeCAM-Depth networks, belonging to the fields of image recognition and monocular ranging technology. Background Technology
[0002] Monocular depth ranging technology is an important research direction in the field of computer vision. Its core advantage lies in its ability to perceive the distance of objects in a scene using only a single ordinary camera. Compared with solutions that require expensive LiDAR or binocular cameras, monocular solutions are characterized by low cost, ease of deployment, and low hardware requirements. Therefore, they show broad application prospects in the field of vehicle perception, especially in autonomous driving and advanced driver assistance systems (ADAS).
[0003] In the operation of autonomous vehicles, distance measurement of targets ahead is crucial. Vehicles need to identify and measure the distances of pedestrians, motor vehicles, non-motorized vehicles, and road obstacles in real time to achieve the following:
[0004] Collision warning and active obstacle avoidance: By accurately measuring the distance ahead, it can predict the risk of collision in advance and take braking or steering measures.
[0005] Adaptive Cruise Control (ACC): Automatically adjusts vehicle speed based on the distance to the vehicle in front to ensure safety and comfort when following the vehicle ahead.
[0006] Lane keeping and lane change assist: Enables safe lane keeping and lane change operations by measuring distances to the road edge and vehicles ahead.
[0007] Despite the rapid development of monocular ranging technology, its performance and robustness still have shortcomings under certain conditions. These challenges mainly stem from the inherent limitations of inferring three-dimensional information from two-dimensional images.
[0008] Despite the promising future of monocular ranging, its inherent limitations also present significant challenges, affecting its performance and robustness in complex environments.
[0009] I. Challenges and difficulties faced:
[0010] 1. Inherent scale ambiguity
[0011] Scale ambiguity is the most fundamental challenge in monocular depth estimation. A single 2D image cannot directly provide absolute depth information, making it difficult for models to distinguish between "large objects in the distance" and "small objects nearby." Traditional methods typically rely on multi-frame motion information (structure-from-motion) or prior dimensions of known objects for compensation, but this information is often unavailable in dynamic driving scenarios. Although deep learning models can learn partial mapping relationships through large-scale data, their predicted depth values are mostly relative depths, lacking a unified absolute scale. In autonomous driving scenarios requiring centimeter-level accuracy, this problem leads to systematic biases in the estimation of distances to obstacles ahead, directly impacting vehicle safety.
[0012] 2. Insufficient robustness in complex scenarios
[0013] In real-world road environments, factors such as lighting, weather, and scene structure are complex and variable, which significantly reduces the prediction accuracy of existing methods.
[0014] Low-light and low-texture scenes: At night, in tunnels, or in rainy weather, the image texture is sparse, making it difficult to extract depth features and significantly increasing the prediction error.
[0015] Limited generalization ability: When new targets or scenarios not covered in the training set (such as special vehicle models or construction areas) appear, the model's prediction results are prone to deviating from the true depth.
[0016] Occlusion and reflection interference: Occlusion by targets such as pedestrians and vehicles can lead to the loss of local information, while reflective areas such as glass and water surfaces can introduce incorrect visual cues, seriously interfering with depth inference.
[0017] 3. Inaccurate object edge prediction
[0018] Object edges are critical regions where depth changes abruptly, such as the outline of a vehicle ahead or the boundary of a road guardrail. However, convolutional networks often lose high-frequency details during multi-layer downsampling, leading to blurred edge region predictions and even "step-like" or "jagged" artifacts. This deficiency weakens the reliability of obstacle detection and vehicle decision-making, becoming a major obstacle to its practical application in autonomous driving.
[0019] 4. Limited computational efficiency and real-time performance
[0020] While monocular methods are less expensive at the hardware level, the underlying deep learning networks often involve a large number of parameters and computational operations. In automotive embedded platforms or real-time driving scenarios, this computational overhead becomes a bottleneck, making it difficult to guarantee millisecond-level inference speeds. How to reduce model complexity while maintaining high accuracy and achieving real-time inference is a pressing challenge that monocular ranging technology urgently needs to overcome.
[0021] The core challenge in deploying such systems on a large scale to mobile devices or embedded systems is to effectively reduce the number of model parameters and computational complexity while ensuring prediction accuracy, and to achieve real-time or near-real-time inference speed.
[0022] The EdgeCAM-Depth network architecture is meticulously designed to address these challenges. By integrating multiple modules, it fundamentally improves the performance and robustness of monocular depth ranging. Summary of the Invention
[0023] The technical problem solved by this invention is that it provides a monocular ranging method for targets in front of vehicles based on the EdgeCAM-Depth network, which solves the problems of insufficient prediction accuracy, blurred object edges and scale uncertainty in existing monocular depth ranging methods in complex road scenarios. This invention significantly improves the accuracy and robustness of monocular depth ranging, meeting the high-precision requirements of target ranging in front of autonomous vehicles.
[0024] The technical solution of this invention is: a monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network, the method comprising:
[0025] Step 1: Data Acquisition and Preprocessing
[0026] The system reads and preprocesses the raw image data captured by the vehicle's front camera, including resizing, normalization, and tensor quantization, converting the raw image data into a format that can be recognized by the deep learning model.
[0027] Step 2: Batch building and input organization:
[0028] The preprocessed data is grouped and packaged according to the set batch size to construct data iterators for the training and validation sets, which are used to realize batch input of data;
[0029] Step 3: Forward Propagation and Feature Extraction
[0030] Each batch of input images is fed into the EdgeCAM-Depth network, where layer-by-layer computation and feature fusion are performed through the encoder, decoder, and their core modules to obtain multi-scale depth prediction maps for subsequent supervision and optimization. The core modules of the encoder and decoder include CBAM attention, edge awareness module, skip connection attention, and scale layer.
[0031] Step 4: Loss Calculation and Training
[0032] The multi-scale depth prediction map is compared with the true depth label, and the multi-scale loss function is calculated; the total loss value of a single iteration is obtained, which is used to provide a basis for optimizing the model parameters.
[0033] Step 5: Backpropagation and parameter optimization:
[0034] Based on the final total loss value, the gradient of each layer parameter is calculated using the backpropagation algorithm, and the network weights are updated using the optimizer.
[0035] Furthermore, Step 1 includes:
[0036] Step 1.1: Load data:
[0037] Each element is a triple, that is: The triplet includes: image path, depth path, and mask path, where i∈1,2….n;
[0038] Output: List
[0039] Constructing a Dataset for Training Samples: Loading data using an iterator, loading RGB images I i Depth Image D i Mask M i ;
[0040]
[0041] in, LoadImage loads an RGB image, LoadDepth loads a depth image, and LoadMask loads a mask. o W o 3 represents the height, width, and number of channels of the image;
[0042] Output: Original triples (I i D i M i );
[0043] Step 1.2: Perform data augmentation and finally output the tensor. Data augmentation includes resizing, channel format conversion, normalization, and binarization masking;
[0044] The size adjustment includes: changing the original RGB image, depth image, and mask from (H... o W o Adjust to (H) t W t );
[0045] I' i =resize(I i H t W t )
[0046] D' i =resize(D i H t W t )
[0047] M' i =resize(M t H t W t )
[0048] Output: Triplet after dimensional standardization (I' i ,D' i ,M' i ), resize() means resizing, I' i ,D' i ,M' i This represents the original RGB image, depth image, and mask after standardization. (H) t W t To adjust the height and width to be uniform;
[0049] The channel format conversion includes: converting an H*W*C shaped image to C*H*W;
[0050] The scaled image is accessed via index:
[0051] I i ′[h,w,c],h∈[0,H t ], w∈[0,W t c∈{0,1,2}
[0052] Where: h, w represent the row and column coordinates of the pixel, c represents the channel index, corresponding to RGB respectively; I i [h,w,c] represents an indexed image;
[0053] RGB image normalization: The pixel value range [0,255] is normalized to [0,1] to obtain a normalized RGB image.
[0054]
[0055] Then, each channel was standardized:
[0056]
[0057] Where, μ c σ c The mean and method difference from ImageNet are calculated, respectively; after these two steps, the final network input tensor X is obtained. i [c,h,w];
[0058] Output:
[0059] The normalization process for the depth image includes:
[0060] Maximum depth D max for:
[0061]
[0062] Normalization is performed to obtain the normalized depth image.
[0063]
[0064] Output:
[0065] The binarized mask includes:
[0066] Depth image D after size standardization i Some pixels in the image do not have true depth; these pixels are invalid and need to be masked. When masking:
[0067]
[0068] M i Convert ' to boolean type for loss function masking;
[0069]
[0070] Output:
[0071] Furthermore, Step 2 includes:
[0072] Batch construction: For the b-th batch:
[0073]
[0074] Where B: batch size for each input batch, C: number of channels (3, RGB), H, W: height and width of the image;
[0075] Normalized input:
[0076]
[0077] Where: μ=(μ g ,μ G ,μ B () is the average of the three channels;
[0078] σ=(σ R ,σG ,σ B ) is the standard deviation of the three channels;
[0079] Input batch after original pixel normalization;
[0080] X (b) The channel-normalized tensor serves as the final input to the network.
[0081] Furthermore, Step 3 includes:
[0082] (I) For encoders:
[0083] The encoder consists of five downsampling stages;
[0084] Each stage begins by downsampling the feature map from the previous stage using a 3x3 convolutional layer with a stride of 2.
[0085] Next, the downsampled feature map is fed into a multi-dimensional perception module for deep feature extraction and enhancement;
[0086] The multidimensional perception module integrates dual convolution, channel and spatial attention modules, and edge perception modules, which are used to simultaneously capture high-level semantic information, focus on key regions, and enhance edge features, respectively.
[0087] A module that is reused in both the encoder and decoder is called a multidimensional sensing module.
[0088] In the encoder section, each layer consists of a downsampling convolutional layer and a multidimensional sensing module; the downsampling convolutional layer is responsible for reducing the spatial resolution and increasing the number of channels to obtain the feature F. i This feature is then input into the aforementioned multidimensional perception module, which outputs the enhanced feature F. out ; to each layer of F out Let it be U i , which serves as the encoder output of this layer, and also as the input of the skip connection during the decoding stage;
[0089] (II) For the decoder:
[0090] The output is processed by the multidimensional perception module after performing upsampling, skip connection attention, feature splicing and fusion, and multidimensional perception module processing at each stage.
[0091] (III) For multi-scale depth prediction heads:
[0092] An independent depth prediction head is set up for each output layer of the decoder to achieve multi-scale supervision. Each depth prediction head includes a 3*3 convolution, a ReLU activation function and a 1*1 convolution. Finally, it is scaled by a learnable scaling factor to generate the predicted depth map.
[0093] Furthermore, the internal processes of the multi-dimensional sensing module include:
[0094] (1) Double convolution, the operation process is as follows:
[0095] Input: F in Feature map;
[0096] a: Perform the first convolution, normalization, and activation processing;
[0097] F in After a 3x3 convolution Conv 3*3 Then, batch normalization (BN) is performed, and finally, the ReLU activation function ρ() is applied.
[0098] F1=ρ(BN(Conv 3*3 (F in ))
[0099] b: Perform a second convolution, normalization, and activation process;
[0100] The F1 algorithm is then processed through a 3x3 convolution, followed by batch normalization (BN), and finally activated by the ReLU activation function ρ().
[0101] F2=ρ(BN(Conv 3*3 (F1))
[0102] c: Random inactivation Dropout;
[0103] Finally, a random deactivation Dropout operation is applied to the output F2 of the second convolution:
[0104] F Dual =Dropout(F2)
[0105] (2) The operation process of the channel and spatial attention module is as follows:
[0106] For the channel attention module, the operation process includes:
[0107] Calculate the channel attention weights w c :
[0108] w c =σ(MLP(GAP(F))+MLP(GMP(F)) Dual )))
[0109] Channel attention weight w c Obtain the channel attention-weighted feature F′:
[0110] F′=F out ⊙w c
[0111] Where MLP stands for Multilayer Perception, GAP stands for Global Average, GMP stands for Max Pooling, σ stands for Sigmoid, and ⊙ stands for Element-wise Multiplication by Channel.
[0112] For the spatial attention module, the operation process is as follows:
[0113] Calculate the spatial attention weights w s :
[0114] w s =σ(Conv 7*7 (AvgPool ch (F'),MaxPool ch (F')]))
[0115] Through spatial attention weight w c We obtain the spatial attention-weighted feature F”:
[0116] F”=F'⊙w s
[0117] Where ⊙ represents element-wise multiplication by channel, Conv 7*7 For a 7x7 convolution, AvgPool ch For channel-level average pooling, MaxPool ch Max pooling for the channel dimension;
[0118] (3) Edge sensing module, the operation process is as follows:
[0119] E = BN(Conv) 5*5 (ρ(Conv 3*3 (F”))))
[0120] F out =F”+σ(α)·E
[0121] Where ρ(·) represents ReLU, and α is the learning residual coefficient.
[0122] Furthermore, Step 4 includes:
[0123] During the training phase, the model calculates a combined loss for multiple objectives. The combined loss of the multi-objective It combines the real depth map and the effective mask, and is composed of three weighted sums: pixel-level loss l s Edge loss and smoothing loss
[0124] Pixel-level loss s :
[0125]
[0126] Among them, D gt (i,j) is the true depth map, D pred (i,j) Predicts the depth map, with a mask of M effective pixels;
[0127] Calculate the edge loss using the Sobel operator.
[0128] E pred =Sobel(D pred )
[0129] E gt =Sobel(D gt )
[0130]
[0131] Where: E pred E gt These are the predicted edge map and the ground truth edge map, respectively.
[0132] Smoothing loss
[0133] Predicting depth in horizontal gradient Predicting depth in vertical gradient The weights are as follows:
[0134]
[0135] Among them: I gray The grayscale image is the input image;
[0136]
[0137] Multi-scale loss aggregation:
[0138]
[0139] Where λ1, λ2, and λ3 are hyperparameters.
[0140] Furthermore, Step 5 includes:
[0141] During backpropagation and optimization, the calculated multi-objective comprehensive loss is used. Backpropagation, which incorporates GradScaler with automatic mixed precision; the specific process is as follows:
[0142] initialization:
[0143] At the start of training, the parameter is θ0 and the learning rate is η;
[0144] The iterative process continues for each training batch t;
[0145] Calculate the loss:
[0146] Calculate the combined loss of multiple objectives.
[0147] Gradient scaling:
[0148] Loss Scaling to obtain
[0149]
[0150] The scaler.scale function performs scaling, typically using a scaling factor.
[0151] Calculate the gradient:
[0152]
[0153] in: Indicates the loss after scaling. Calculate the gradient by taking the partial derivative of the θ parameter, g t The gradient vector;
[0154] Gradient clipping includes:
[0155] For gradient g t Perform L2 paradigm clipping to obtain the clipped gradient g′ t :
[0156]
[0157] Where clip_norm = 1.0;
[0158] Parameter updates include:
[0159] Using the Adam optimizer and the clipped gradient g′ t To update the parameters:
[0160] θ t+1 =θ t -η·Adam(g′ t )
[0161] Where t represents the number of iterations, and η is a hyperparameter.
[0162] The present invention also provides a monocular ranging system based on EdgeCAM-Depth network, the system comprising: a module for executing the monocular ranging method for vehicle forward targets based on EdgeCAM-Depth network.
[0163] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the monocular ranging method for vehicle forward targets based on the EdgeCAM-Depth network.
[0164] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the monocular ranging method for vehicle forward targets based on the EdgeCAM-Depth network.
[0165] EdgeCAM-Depth (An Edge-Aware Multi-Scale Network with Channel-SpatialAttention for Robust Monocular Depth Estimation) is a monocular depth ranging solution that overcomes the limitations of existing technologies by systematically enhancing the U-Net encoder-decoder architecture. The core of this solution lies in the integration of a Channel-Spatial Attention Module (CBAM) and an EdgeAware Module, which endows the model with adaptive perception capabilities. CBAM allows the network to dynamically focus on the features and regions most important for depth prediction, significantly improving robustness in complex scenes; while the EdgeAware Module, through learnable residual control, accurately recovers the sharp outlines of objects, effectively solving the problem of blurred edges in depth maps.
[0166] To further optimize information flow and prediction accuracy, EdgeCAM-Depth introduces SkipAttention and a Learnable ScaleLayer. SkipAttention intelligently filters and weights the high-quality detail information passed by the encoder, ensuring the decoder efficiently recovers fine structures. Meanwhile, the Learnable ScaleLayer provides a self-calibration mechanism, adaptively adjusting the absolute scale of depth prediction, thus effectively mitigating the inherent scale ambiguity problem of monocular ranging.
[0167] EdgeCAM-Depth's technical solution is a highly integrated and effective approach. By combining attention mechanisms, edge perception, and intelligent information flow management, it provides a reliable, high-precision, and robust technical option for autonomous driving navigation applications.
[0168] The beneficial effects of this invention are:
[0169] 1. To address the issue of insufficient robustness in complex scenarios, this invention introduces a channel and spatial attention module (CBAM). This module allows the network to adaptively focus on the features most relevant to depth prediction. The channel attention mechanism enhances the feature channels most relevant to depth information, while spatial attention highlights regions in the image that contain rich depth cues (such as object edges and high-contrast textures). This dual attention mechanism enables the model to utilize limited image information more effectively, significantly improving robustness in various complex environments.
[0170] 2. To overcome the challenge of inaccurate object edge prediction, this invention designs an EdgeAwareModule. It explicitly extracts edge features of different granularities by using multi-scale convolutional kernels (such as 3x3 and 5x5). More importantly, this invention introduces a learnable residual control parameter alpha, allowing the model to adaptively determine the contribution of edge features to the final prediction. This dynamic fusion mechanism ensures that the network can prioritize preserving and enhancing object boundaries when recovering high-resolution depth maps, thereby generating clear and sharp depth maps and effectively avoiding edge blurring problems.
[0171] 3. To address the issue of noise introduced by skip connections in the U-Net architecture, this invention develops a SkipAttention module. This module intelligently filters and weights the features transmitted from the encoder by combining channel and spatial attention. Only those features that are most valuable for depth recovery and most helpful in recovering details are enhanced. This mechanism enables the decoder to utilize encoder information more efficiently, reduces information redundancy, and thus greatly improves the quality of the depth map and the ability to recover details.
[0172] 4. To address scale ambiguity and training stability issues, the EdgeCAM-Depth network employs a multi-scale prediction strategy and integrates a learnable ScaleLayer into each prediction head. This learnable scaling factor allows the model to adaptively adjust the absolute scale of depth predictions during training, rather than relying on a fixed output range. This self-calibration capability not only helps stabilize training but also enables the model to better adapt to the depth value distribution of different datasets, generating more accurate absolute depth values.
[0173] 5. This invention is based on the classic U-Net architecture and achieves depth enhancement by integrating a channel and spatial attention module, an edge awareness module, a skip connection attention module, multi-scale depth output, and a learnable scale layer. The channel and spatial attention module (CBAM) enables the network to adaptively focus on key features and regions, significantly improving the model's robustness. The edge awareness module utilizes a learnable residual control mechanism to accurately recover the sharp outlines of objects, effectively solving the edge blurring problem. Skip connection attention optimizes the information flow between the encoder and decoder, ensuring efficient recovery of high-quality details. The multi-scale depth output and learnable scale layer provide a self-calibration scheme to address scale ambiguity. Through these systematic innovations, EdgeCAM-Depth not only achieves a technological breakthrough but also provides a high-precision, highly robust monocular depth perception solution for applications in autonomous driving, robotics, and AR. Attached Figure Description
[0174] Figure 1 This is a schematic diagram of the EdgeCAM-Depth network structure in this invention;
[0175] Figure 2 This is a schematic diagram of the multi-dimensional sensing module structure in this invention;
[0176] Figure 3 This is a schematic diagram of the channel and spatial attention module structure in this invention;
[0177] Figure 4 This is a schematic diagram of the edge sensing module structure in this invention;
[0178] Figure 5 This is a schematic diagram of the skip link attention module structure in this invention;
[0179] Figure 6 This is a diagram illustrating monocular depth prediction in an embodiment of the present invention. Detailed Implementation
[0180] Example 1: As Figures 1-6 As shown, a monocular ranging method for targets ahead of a vehicle based on the EdgeCAM-Depth network is described, the method comprising:
[0181] Step 1: Data Acquisition and Preprocessing
[0182] The system reads and preprocesses the raw image data captured by the vehicle's front camera, including resizing, normalization, and tensor quantization, converting the raw image data into a format that can be recognized by the deep learning model.
[0183] Furthermore, Step 1 includes:
[0184] Step 1.1: Load data:
[0185] Each element is a triple, that is: The triplet includes: image path, depth path, and mask path, where i∈1,2….n;
[0186] Output: List
[0187] Constructing a Dataset for Training Samples: Loading data using an iterator, loading RGB images I i Depth Image D i Mask M i Among them, loading RGB image I i Preserve original color information and load depth image D. i LiDAR truth values, used for supervised training, with mask M loaded. i Mark depth pixels and filter invalid points;
[0188]
[0189] in, LoadImage loads an RGB image, LoadDepth loads a depth image, and LoadMask loads a mask. o W o 3 represents the height, width, and number of channels of the image;
[0190] Output: Original triples (I i D i M i );
[0191] Step 1.2: Perform data augmentation and finally output the tensor. Data augmentation includes resizing, channel format conversion, normalization, and binarization masking;
[0192] The resizing includes: resizing the original RGB image, depth image, and mask from (H... o W o Adjust to (H) t W t Ensure consistent network input;
[0193] I' i =resize(I i H t W t )
[0194] D' i =resize(Di H t W t )
[0195] M' i =resize(M t H t W t )
[0196] Output: Triplet after dimensional standardization (I' i ,D' i ,M' i ), resize() means resizing, I' i ,D' i ,M' i This represents the original RGB image, depth image, and mask after standardization. (H) t W t To adjust the height and width to be uniform;
[0197] The channel format conversion (ToTensor) includes: converting an H*W*C shaped image to C*H*W;
[0198] The scaled image is accessed via index:
[0199] I i ′[h,w,c],h∈[0,H t ], w∈[0,W t c∈{0,1,2}
[0200] Where: h, w represent the row and column coordinates of the pixel, c represents the channel index, corresponding to RGB respectively; I i [h,w,c] represents an indexed image;
[0201] RGB image normalization: Normalizes the pixel value range [0,255] to [0,1] to obtain a normalized RGB image.
[0202]
[0203] Then, each channel was standardized:
[0204]
[0205] Where, μ c σ c The mean and method difference from ImageNet are calculated, respectively; after these two steps, the final network input tensor X is obtained. i [c,h,w];
[0206] Output:
[0207] The normalization process for the depth image includes:
[0208] Maximum depth D max for:
[0209]
[0210] Normalization is performed to obtain the normalized depth image.
[0211]
[0212] Output:
[0213] The binarization mask includes:
[0214] Depth image D after size standardization i Some pixels in the image do not have true depth; these pixels are invalid and need to be masked. When masking:
[0215]
[0216] M i Convert ' to boolean type for loss function masking;
[0217]
[0218] Output:
[0219] Step 2: Batch building and input organization:
[0220] The preprocessed data is grouped and packaged according to the set batch size to build data iterators for the training and validation sets, which are used to achieve batch input of data; before being fed into the model, the input is again standardized using consistent mean and variance.
[0221] Furthermore, Step 2 includes:
[0222] Batch construction: For the b-th batch:
[0223]
[0224] Where B: batch size for each input batch, C: number of channels (3, RGB), H, W: height and width of the image;
[0225] Normalized input:
[0226]
[0227] Where: μ=(μ R ,μ G ,μ B () is the average of the three channels;
[0228] σ=(σ R ,σ G ,σ B ) is the standard deviation of the three channels;
[0229] Input batch after original pixel normalization;
[0230] X (b) The channel-normalized tensor serves as the final input to the network.
[0231] Step 3: Forward Propagation and Feature Extraction:
[0232] Each batch of input images is fed into the EdgeCAM-Depth network, where layer-by-layer computation and feature fusion are performed through the encoder, decoder, and their core modules to obtain multi-scale depth prediction maps for subsequent supervision and optimization. The core modules of the encoder and decoder include CBAM attention, edge awareness module, skip connection attention, and scale layer.
[0233] Furthermore, Step 3 includes:
[0234] (I) For encoders:
[0235] The encoder consists of five downsampling stages;
[0236] Each stage begins by downsampling the feature map from the previous stage using a 3x3 convolutional layer with a stride of 2.
[0237] Next, the downsampled feature map is fed into a multi-perception block for deep feature extraction and enhancement;
[0238] The multidimensional perception module integrates double convolution (DoubleConv), channel and spatial attention modules, and edge awareness module (EdgeAwareModule), which are used to simultaneously capture high-level semantic information, focus on key regions, and enhance edge features, respectively.
[0239] A module that is reused in both the encoder and decoder is called a multidimensional sensing module.
[0240] In the encoder section, each layer consists of a downsampling convolutional layer and a multidimensional sensing module; the downsampling convolutional layer is responsible for reducing the spatial resolution and increasing the number of channels to obtain the feature F. i This feature is then input into the aforementioned multidimensional perception module, which outputs the enhanced feature F. out ; to each layer of F out Let it be U i , which serves as the encoder output of this layer, and also as the input of the skip connection during the decoding stage;
[0241] (II) For the decoder:
[0242] The output is processed by the multidimensional perception module after performing upsampling, skip connection attention, feature splicing and fusion, and multidimensional perception module processing at each stage.
[0243] (III) For multi-scale depth prediction heads:
[0244] An independent depth prediction head is set up for each output layer of the decoder to achieve multi-scale supervision. Each depth prediction head includes a 3*3 convolution, a ReLU activation function and a 1*1 convolution. Finally, it is scaled by a learnable scaling factor to generate the predicted depth map.
[0245] Furthermore, the internal processes of the multi-dimensional sensing module include:
[0246] (1) Double convolution, the operation process is as follows:
[0247] Input: F in Feature map;
[0248] a: Perform the first convolution, normalization, and activation processing;
[0249] F in After a 3x3 convolution Conv 3*3 Then, batch normalization (BN) is performed, and finally, the ReLU activation function ρ() is applied.
[0250] F1=ρ(BN(Conv 3*3 (F in ))
[0251] b: Perform a second convolution, normalization, and activation process;
[0252] The F1 algorithm is then processed through a 3x3 convolution, followed by batch normalization (BN), and finally activated by the ReLU activation function ρ().
[0253] F2=ρ(BN(Conv 3*3 (F1))
[0254] c: Random inactivation Dropout;
[0255] Finally, a random deactivation Dropout operation is applied to the output F2 of the second convolution:
[0256] F Dual =Dropout(F2)
[0257] (2) Channel and Spatial Attention Module (CBAM Attention), the operation process is as follows:
[0258] For the channel attention module, the operation process includes:
[0259] Calculate the channel attention weights w c :
[0260] w c =σ(MLP(GAP(F))+MLP(GMP(F)) Dual )))
[0261] Channel attention weight w c Obtain the channel attention-weighted feature F′:
[0262] F′=F out ⊙w c
[0263] Where MLP stands for Multilayer Perception, GAP stands for Global Average, GMP stands for Max Pooling, σ stands for Sigmoid, and ⊙ stands for Element-wise Multiplication by Channel.
[0264] For the spatial attention module, the operation process is as follows:
[0265] Calculate the spatial attention weights w s :
[0266] w s =σ(Conv 7*7 (AvgPool ch (F'),MaxPool ch (F')]))
[0267] Through spatial attention weight w c We obtain the spatial attention-weighted feature F”:
[0268] F”=F'⊙w s
[0269] Where ⊙ represents element-wise multiplication by channel, Conv 7*7 For a 7x7 convolution, AvgPool ch For channel-level average pooling, MaxPool ch Max pooling for the channel dimension;
[0270] (3) EdgeAwareModule, the operation process is as follows:
[0271] E = BN(Conv) 5*5 (ρ(Conv 3*3 (F”))))
[0272] F out =F”+σ(α)·E
[0273] Where ρ(·) represents ReLU, and α is the learning residual coefficient.
[0274] Step 4: Loss Calculation and Training
[0275] The multi-scale depth prediction map is compared with the true depth label, and the multi-scale loss function is calculated; the total loss value of a single iteration is obtained, which is used to provide a basis for optimizing the model parameters.
[0276] Furthermore, Step 4 includes:
[0277] During the training phase, the model calculates a combined loss for multiple objectives. The combined loss of the multi-objective It combines the real depth map and the effective mask, and is composed of three weighted sums: pixel-level loss l s Edge loss and smoothing loss
[0278] Pixel-level loss s :
[0279]
[0280] Among them, D gt (i,j) is the true depth map, D pred (i,j) Predicts the depth map, with a mask of M effective pixels;
[0281] Calculate the edge loss using the Sobel operator.
[0282] E pred =Sobel(D pred )
[0283] E gt =Sobel(D gt )
[0284]
[0285] Where: E pred E gtThese are the predicted edge map and the ground truth edge map, respectively.
[0286] Smoothing loss
[0287] Predicting depth in horizontal gradient Predicting depth in vertical gradient The weights are as follows:
[0288]
[0289] Among them: I gray The grayscale image is the input image;
[0290]
[0291] Multi-scale loss aggregation:
[0292]
[0293] Where λ1, λ2, and λ3 are hyperparameters.
[0294] Step 5: Backpropagation and Parameter Optimization
[0295] Based on the final total loss value, the gradient of each layer parameter is calculated using the backpropagation algorithm, and the network weights are updated using an optimizer (such as Adam or SGD).
[0296] Furthermore, Step 5 includes:
[0297] During backpropagation and optimization, the calculated multi-objective comprehensive loss is used. Backpropagation, which incorporates GradScaler with automatic mixed precision; the specific process is as follows:
[0298] initialization:
[0299] At the start of training, the parameter is θ0 and the learning rate is η;
[0300] The iterative process continues for each training batch t;
[0301] Calculate the loss:
[0302] Calculate the combined loss of multiple objectives.
[0303] Gradient scaling:
[0304] Loss Scaling to obtain
[0305]
[0306] The scaler.scale function performs scaling, typically using a scaling factor.
[0307] Calculate the gradient:
[0308]
[0309] in: Indicates the loss after scaling. Calculate the gradient by taking the partial derivative of the θ parameter, g t The gradient vector;
[0310] Gradient clipping includes:
[0311] For gradient g t Perform L2 paradigm clipping to obtain the clipped gradient g′ t :
[0312]
[0313] Where clip_norm = 1.0;
[0314] Parameter updates include:
[0315] Using the Adam optimizer and the clipped gradient g′ t To update the parameters:
[0316] θ t+1 =θ t -η·Adam(g′ t )
[0317] Where t represents the number of iterations, and η is a hyperparameter.
[0318] Adam optimizer: A widely used adaptive learning rate optimization algorithm that combines the ideas of momentum and RMSprop. Adam aims to independently compute the adaptive learning rate for each model parameter, thereby converging more efficiently during training.
[0319] In the encoder section of this invention, each layer consists of a downsampling convolutional layer and a multi-sensor module; the downsampling convolutional layer is responsible for reducing the spatial resolution and increasing the number of channels to obtain the feature F. i This feature is then input into the aforementioned multi-sensor module (DoubleConv+CBAM+EdgeAware), which outputs the enhanced feature F. out To maintain consistency, this invention will use F in each layer. out Let it be U iIt serves as the encoder output for this layer and as the input to the skip connection during the decoding phase.
[0320] The encoder provided by this invention consists of 5 stages:
[0321] Input: RGB image with dimensions (B, 3, H, W);
[0322] (1) Downsampling convolution: The image is downsampled using a convolution operation with a kernel size of 3×3 and a stride of 2 to obtain the preliminary feature F1;
[0323] F1 = Conv2d stride=2 (X (b) )
[0324] (2) Multi-sensor module: Input F1 into the multi-sensor module (double convolution + CBAM attention + edge detection)
[0325] (Knowledge), enhance deep correlation features to obtain U1;
[0326] U1=Multi-perception Block(F1)
[0327] Among them: Multi-perception Block is a multi-sensory module.
[0328] Phase Two:
[0329] Input: U1 in the first stage;
[0330] (1) Downsampling convolution: The image is downsampled using a convolution operation with a kernel size of 3×3 and a stride of 2 to obtain the preliminary feature F2;
[0331] F2=Conv2d stride=2 (U1)
[0332] (2) Multi-sensor module: Input F2 into the multi-sensor module (double convolution + CBAM attention + edge detection)
[0333] (Knowledge), enhance deep correlation features to obtain U2;
[0334] U2=Multi-perception Block(F2)
[0335] Among them: Multi-perception Block is a multi-sensory module.
[0336] Phase Three:
[0337] Input: U2 in the second stage;
[0338] (1) Downsampling convolution: The image is downsampled using a convolution operation with a kernel size of 3×3 and a stride of 2 to obtain the preliminary feature F3;
[0339] F3=Conv2d stride=2 (U2)
[0340] (2) Multi-sensor module: Input F3 into the multi-sensor module (double convolution + CBAM attention + edge perception) to enhance depth-related features and obtain U3;
[0341] U3=Multi-perception Block(F3)
[0342] Among them: Multi-perception Block is a multi-sensory module. Phase Four:
[0343] Input: U3 in the third stage;
[0344] (1) Downsampling convolution: The image is downsampled using a convolution operation with a kernel size of 3×3 and a stride of 2 to obtain the preliminary feature F4;
[0345] F4 = Conv2d stride=2 (U3)
[0346] (2) Multi-sensor module: Input F4 into the multi-sensor module (double convolution + CBAM attention + edge perception) to enhance depth-related features and obtain U4;
[0347] U4=Multi-perception Block(F4)
[0348] Among them: Multi-perception Block is a multi-sensory module. Phase 5:
[0349] Input: U4 in stage 4;
[0350] (1) Downsampling convolution: The image is downsampled using a convolution operation with a kernel size of 3×3 and a stride of 2 to obtain the preliminary feature F5;
[0351] F5 = Conv2d stride=2 (U4)
[0352] (2) Multi-sensor module: Input F5 into the multi-sensor module (double convolution + CBAM attention + edge perception) to enhance depth-related features and obtain U5;
[0353] U5=Multi-perception Block(F5);
[0354] Among them: Multi-perception Block is a multi-sensory module.
[0355] (II) For the decoder:
[0356] Decoding Phase 1:
[0357] Input: Feature U5 and encoder layer 4 feature U4;
[0358] (1) Upsampling: Apply transposed convolution (ConvTranspose2d) to U5 to restore one time the spatial resolution and obtain feature Z4;
[0359] Z4 = ConvTranspose2d(U5)
[0360] (2) Skip Attention: Use SkipAttention on U4 to filter out valuable detailed features.
[0361] S'4 = SkipAttention(U4)
[0362] (3) Splicing and fusion: Splice Z4 and S'4 through channels;
[0363] V4 = concat(Z4, S'4)
[0364] (4) Multi-sensor module: Input V4 into the multi-sensor module (double convolution + CBAM attention + edge perception) to enhance depth-related features and obtain D4;
[0365] D4=Multi-perception Block(V4)
[0366] Decoding Phase 2:
[0367] Input: Stage 1 output D4 and encoder layer 3 feature U3;
[0368] (1) Upsampling: Apply transposed convolution (ConvTranspose2d) to D4 to restore one time the spatial resolution and obtain feature Z3;
[0369] Z3 = ConvTranspose2d(D4)
[0370] (2) Skip Attention: Use SkipAttention on U3 to filter out valuable detailed features.
[0371] S'3 = SkipAttention(U3)
[0372] (3) Splicing and fusion: Splice Z3 and S'3 through channels;
[0373] V3 = concat(Z3, S'3)
[0374] (4) Multi-sensor module: Input V3 into the multi-sensor module (double convolution + CBAM attention + edge perception) to enhance depth-related features and obtain D3;
[0375] D3=Multi-perception Block(V3)
[0376] Decoding Phase 3:
[0377] Input: Stage 2 output D3 and encoder Layer 2 features U2;
[0378] (1) Upsampling: Apply transposed convolution (ConvTranspose2d) to D3 to restore one time the spatial resolution and obtain feature Z2;
[0379] Z2 = ConvTranspose2d(D3)
[0380] (2) Skip Attention: Use SkipAttention on U2 to filter out valuable detailed features.
[0381] S'2 = SkipAttention(U2)
[0382] (3) Splicing and fusion: Splice Z2 and S'2 through channels;
[0383] V2 = concat(Z2, S'2)
[0384] (4) Multi-sensor module: Input V2 into the multi-sensor module (double convolution + CBAM attention + edge detection)
[0385] (Knowledge), enhance deep correlation features to obtain D2;
[0386] D2=Multi-perception Block(V2)
[0387] Decoding Phase 4:
[0388] Input: Stage 3 output D2 and encoder layer 1 features U1;
[0389] (1) Upsampling: Apply transpose convolution (ConvTranspose2d) to D2 to restore one time the spatial resolution and obtain feature Z1;
[0390] Z1 = ConvTranspose2d(D2)
[0391] (2) Skip Attention: Use SkipAttention on U1 to filter out valuable detailed features.
[0392] S'1 = SkipAttention(U1)
[0393] (3) Splicing and fusion: Splice Z1 and S'1 through channels;
[0394] V1 = concat(Z1, S'1)
[0395] (4) Multi-sensor module: Input V1 into the multi-sensor module (double convolution + CBAM attention + edge detection)
[0396] (Knowledge), enhance deep correlation features to obtain D1;
[0397] D1=Multi-perception Block(V1))
[0398] Output: D4, D3, D2, D1;
[0399] (III) For multi-scale depth prediction heads:
[0400] An independent depth prediction head is set up for each output layer of the decoder to achieve multi-scale supervision. Each depth prediction head consists of a 3*3 convolution, a ReLU activation function, and a 1*1 convolution, and is finally passed through a learnable scaling factor β. S Scaling is performed to generate a predicted depth map. Where S∈{1,2,3,4};
[0401]
[0402] Output: Where S∈{1,2,3,4}, β S It is a training scalar;
[0403] The key technical points of this invention include:
[0404] 1. Channel and Spatial Attention Module (CBAM): This is an adaptive feature enhancement technique. CBAM allows the network to dynamically learn during training which feature channels (Channel Attention) and spatial regions (Spatial Attention) are most important for depth prediction based on task requirements. This mechanism effectively suppresses noise and irrelevant information in images, highlighting textures and edges useful for depth prediction, thereby improving the model's robustness.
[0405] 2. EdgeAwareModule: This module is specifically designed to accurately recover edge details from depth maps. It uses multi-scale convolutional kernels (such as 3x3 and 5x5) to capture edge features at different scales and dynamically adjusts the contribution of edge features to the backbone feature flow through a learnable residual control parameter (alpha). This design ensures that the depth map maintains a clear and sharp transition at object boundaries, solving the edge blurring problem commonly found in traditional methods.
[0406] 3. Skip Attention: This module was introduced to optimize the information flow of skip connections. It applies channel and spatial attention to the encoder features before passing them to the decoder. This selective information delivery mechanism intelligently filters out the most valuable features for depth recovery from skip connections, reducing the impact of noise and redundant information, allowing the decoder to utilize information more efficiently to recover details.
[0407] 4. Learnable Scale Layer: This module is designed to address the scale ambiguity of monocular depth. It is a simple, trainable parameter applied to the final output of each depth prediction head. By learning this scaling factor during training, the model can adaptively adjust the absolute scale of depth prediction, thereby improving prediction accuracy and generalization ability.
[0408] 5. Multi-scale Depth Output and Supervision: The model sets independent prediction heads at different levels of the decoder, enabling the generation of depth maps at multiple resolutions. During training, these multi-scale predictions are compared with their corresponding ground truth depth maps, and the loss is calculated. This multi-scale supervision strategy helps the model learn depth information at different granularities, stabilizes training, and generates more comprehensive predictions.
[0409] 6. Combination of Multiple Loss Functions: To comprehensively optimize model performance, EdgeCAM-Depth typically uses a combination of multiple loss functions. Structural Similarity Loss (SSIM) encourages the predicted depth map to be structurally similar to the true depth map, generating a more natural visual effect. Edge-Aware Smoothness Loss constrains the predicted depth smoothness of flat regions while preserving object edges, preventing the generation of excessively noisy depth maps.
[0410] 7. Automatic Mixed Precision (AMP): To improve training efficiency and reduce GPU memory usage, the model employs AMP technology. This allows most computations to be performed using the lower-precision but faster FP16 data type, while critical operations still use FP32, significantly accelerating training speed while maintaining accuracy.
[0411] EdgeCAM-Depth is not merely a technology demonstrator, but a highly innovative and effective depth ranging solution. By systematically integrating the aforementioned key technologies, it successfully addresses the core challenges in monocular depth ranging. This model provides a reliable and efficient technical option for applications requiring accurate and reliable depth perception, such as autonomous driving, robot navigation, and augmented reality.
[0412] The present invention also provides a monocular ranging system based on EdgeCAM-Depth network, the system comprising: a module for executing the monocular ranging method for vehicle forward targets based on EdgeCAM-Depth network.
[0413] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the monocular ranging method for vehicle forward targets based on the EdgeCAM-Depth network.
[0414] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the monocular ranging method for vehicle forward targets based on the EdgeCAM-Depth network.
[0415] This invention uses the KITTI test dataset and employs the Abs Rel, Sq Rel, RMSE, RMSE_log, a1, a2, and a3 metrics to measure the prediction performance.
[0416] Among them, Abs Rel (Absolute Relative Error): Absolute relative error, this is the most commonly used metric for measuring depth prediction accuracy; Sq Rel (Squared Relative Error): Squared relative error, similar to Abs Rel, but it squares the prediction error; RMSE (Root Mean Squared Error): Root mean square error, this is a metric for measuring the absolute difference between the predicted depth and the true depth; RMSE_log (Root Mean Squared Error of Logarithmic Depth): Logarithmic root mean square error, this metric is less sensitive to errors at large depth values and focuses more on evaluating relative error; a1, a2, a3 (Accuracy Thresholds): These three metrics measure the ratio between the predicted depth and the true depth. a1 is calculated by statistically analyzing the proportion of pixels whose predicted depth to true depth ratio is within 1.25. The thresholds for a2 and a3 are the square and cube of 1.25, respectively. The higher these three values are, the better, as they directly reflect the accuracy of the model's predictions.
[0417] Table 1 compares the methods of monocular ranging.
[0418]
[0419]
[0420] The data shows that EdgeCAM-Depth significantly outperforms other methods across all metrics, which strongly demonstrates its superior performance.
[0421] Error metrics: EdgeCAM-Depth's Abs Rel (0.078), Sq Rel (0.414), RMSE (3.593), and RMSE_log (0.13) are all the lowest among all methods. This indicates that EdgeCAM-Depth has the smallest mean relative error, squared error, absolute error, and logarithmic error between the predicted depth and the true depth. In particular, EdgeCAM-Depth significantly outperforms other methods in the two most commonly used metrics, Abs Rel and RMSE.
[0422] Accuracy metrics: EdgeCAM-Depth's a1 (0.925), a2 (0.983), and a3 (0.994) are the highest among all methods. Especially a1, which indicates that 92.5% of the pixels predicted by EdgeCAM-Depth have a predicted depth-to-true depth ratio within 1.25, the highest proportion among all methods. This demonstrates that EdgeCAM-Depth performs excellently in terms of prediction accuracy, and its predictions are very close to the true values.
[0423] In summary, the EdgeCAM-Depth method demonstrates superior performance in monocular depth estimation tasks. It achieves state-of-the-art results in both error and accuracy, proving its effectiveness in addressing the challenges of monocular depth estimation.
[0424] Figure 6 This paper presents a comparison of depth prediction results of the present invention on the KITTI dataset. The top left image is the input RGB image of the road scene, the top center image is the true depth map provided by the LiDAR, and the top right image is the depth map predicted by the present method. It can be seen that the method of the present invention can accurately recover the depth distribution of the road and target objects ahead. The bottom left image shows the pixel-wise absolute error between the predicted result and the true value, indicating that the prediction error is small in near target areas (such as pedestrians, bicycles, and objects ahead of the road), while the error increases relatively in distant background areas. The scatter plots and error distribution plots in the bottom center and bottom right further reveal this pattern: the overall trend of the prediction result is close to the ideal straight line y=x, but the absolute error increases with the increase of the true depth. This shows that the method of the present invention can ensure high-precision ranging of key obstacles at close range in autonomous driving scenarios, while errors at distant locations will not significantly affect vehicle safety decisions, thus meeting the practical application requirements of monocular ranging in autonomous driving.
[0425] The specific embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A monocular ranging method for vehicle-ahead targets based on EdgeCAM-Depth network, characterized in that: The method includes: Step 1: Data Acquisition and Preprocessing The system reads and preprocesses the raw image data captured by the vehicle's front camera, including resizing, normalization, and tensor quantization, converting the raw image data into a format that can be recognized by the deep learning model. Step 2: Batch building and input organization: The preprocessed data is grouped and packaged according to the set batch size to construct data iterators for the training and validation sets, which are used to realize batch input of data; Step 3: Forward Propagation and Feature Extraction Each batch of input images is fed into the EdgeCAM-Depth network, where layer-by-layer computation and feature fusion are performed through the encoder, decoder, and their core modules to obtain multi-scale depth prediction maps for subsequent supervision and optimization. The core modules of the encoder and decoder include CBAM attention, edge awareness module, skip connection attention, and scale layer. Step 4: Loss Calculation and Training The multi-scale depth prediction map is compared with the true depth label, and the multi-scale loss function is calculated; the total loss value of a single iteration is obtained, which is used to provide a basis for optimizing the model parameters. Step 5: Backpropagation and parameter optimization: Based on the final total loss value, the gradient of the parameters of each layer is calculated using the backpropagation algorithm, and the network weights are updated using the optimizer. Step 3 includes: (a) For encoders: The encoder consists of five downsampling stages; Each stage begins by downsampling the feature map from the previous stage using a 3x3 convolutional layer with a stride of 2. Next, the downsampled feature map is fed into a multi-dimensional perception module for deep feature extraction and enhancement; The multidimensional perception module integrates dual convolution, channel and spatial attention modules, and edge perception modules, which are used to simultaneously capture high-level semantic information, focus on key regions, and enhance edge features, respectively. A module that is reused in both the encoder and decoder is called a multidimensional sensing module. In the encoder section, each layer consists of a downsampling convolutional layer and a multidimensional sensing module; the downsampling convolutional layer is responsible for reducing the spatial resolution and increasing the number of channels to obtain features. This feature is then input into the aforementioned multidimensional perception module, which outputs the enhanced feature. ; each layer Recorded as , which serves as the encoder output of this layer and also as the input to the skip connections during the decoding phase; (ii) For the decoder: The output is processed by the multidimensional perception module after performing upsampling, skip connection attention, feature splicing and fusion, and multidimensional perception module processing at each stage. (III) For multi-scale depth prediction heads: An independent depth prediction head is set up for each output layer of the decoder to achieve multi-scale supervision. Each depth prediction head includes a 3*3 convolution, a ReLU activation function and a 1*1 convolution. Finally, it is scaled by a learnable scaling factor to generate the predicted depth map.
2. The monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network according to claim 1, characterized in that: Step 1 includes: Step 1.1: Load data: Each element is a triple, that is: The triplet includes: image path, depth path, and mask path, where, ; Output: List ; Constructing training samples for the Dataset: Loading data using iterators, including RGB images. Depth images Mask ; ; ; ; in, , , To load an RGB image, To load the depth image, To load the mask, , 3 represents the height, width, and number of channels of the image; Output: Original triples ; Step 1.2: Perform data augmentation and finally output a tensor ( Data augmentation includes resizing, channel format conversion, normalization, and binarization masks. The size adjustment includes: converting the original RGB image, depth image, and mask from ( Adjust to ( ); ; ; ; Output: Triples after size standardization ( , ), Indicates size adjustment. , This represents the original RGB image, depth image, and mask after standardizing the dimensions. , To adjust the height and width to be uniform; The channel format conversion includes: converting an H*W*C shaped image to C*H*W; The scaled image is accessed via index: ; in: Represents the row and column coordinates of a pixel. Indicates the channel index, corresponding to RGB respectively; Indicates access to the image via index; RGB image normalization: The pixel value range [0,255] is normalized to [0,1] to obtain a normalized RGB image. : ; Then, each channel was standardized: ; in, The mean and method difference from ImageNet are calculated separately; after these two steps, the final network input tensor is obtained. ; Output: ; The normalization process for the depth image includes: Maximum depth for: ; Normalization is performed to obtain the normalized depth image. : ; Output: , ; The binarized mask includes: Depth image after size standardization Some pixels in the image lack true depth; these pixels are invalid and need to be masked. When masking: ; Will Convert to boolean type for loss function masking; ; Output: .
3. The monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network according to claim 1, characterized in that: Step 2 includes: Batch construction: For the b-th batch: ; Where B: batch size for each input, and C: number of channels (3, RGB). The height and width of the image; Normalized input: ; in: It is the average of the three channels; It is the standard deviation of the three channels; : Input batch after normalization of original pixels; The channel-normalized tensor serves as the final input to the network.
4. The monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network according to claim 1, characterized in that: The internal processes of the multi-dimensional sensing module include: (1) Double convolution, the operation process is as follows: enter: Feature map; a: Perform the first convolution, normalization, and activation processing; After 3x3 convolution Then, batch normalization (BN) is performed, and finally, the ReLU activation function is applied. deal with: ; b: Perform a second convolution, normalization, and activation process; After a 3x3 convolution, batch normalization (BN) is performed, and finally, the ReLU activation function is applied. deal with: ; c: Random inactivation Dropout; Finally, the output of the second convolution... Apply random dropout operation: ; (2) The operation process of the channel and spatial attention module is as follows: For the channel attention module, the operation process includes: Calculate channel attention weights : ; Channel attention weights Obtain channel attention weighted features : ; Among them, MLP stands for Multilayer Perception, GAP stands for Global Average, and GMP stands for Max Pooling. It is Sigmoid. To multiply element by element according to the channel; For the spatial attention module, the operation process is as follows: Calculate spatial attention weights : ; Spatial attention weights Obtain spatial attention-weighted features : ; in, To multiply element-wise according to the channel. It is a 7x7 convolution. For channel-dimensional average pooling, Max pooling for the channel dimension; (3) Edge sensing module, the operation process is as follows: ; ; in, Represents ReLU. It is the learning residual coefficient.
5. The monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network according to claim 1, characterized in that: Step 4 includes: During the training phase, the model calculates a combined loss for multiple objectives. The combined loss of this multi-objective It combines the real depth map and the effective mask, and is composed of a weighted sum of three parts: pixel-level loss. Edge loss and smoothing loss ; Pixel-level loss : ; in, True depth map Predicted depth map Mask of effective pixels; Calculate the edge loss using the Sobel operator. : ; ; ; in: , These are the predicted edge map and the ground truth edge map, respectively. Smoothing loss : Predicting depth in horizontal gradient Predicting depth in vertical gradient The weights are as follows: ; ; in: The grayscale image is the input image; ; Multi-scale loss aggregation: ; in, , , This is a hyperparameter.
6. The monocular ranging method for vehicle-front targets based on EdgeCAM-Depth network according to claim 1, characterized in that: Step 5 includes: During backpropagation and optimization, the calculated multi-objective comprehensive loss is used. Backpropagation, which incorporates GradScaler with automatic mixed precision, is performed as follows: initialization: At the start of training, the parameters are: The learning rate is ; The iterative process, for each training batch ; Calculate the loss: Calculate the combined loss of multiple objectives. ; Gradient scaling: Loss Scaling to obtain ; ; in: Function execution scaling is typically achieved using a scaling factor. Calculate the gradient: ; in: Indicates the loss after scaling. of Calculate the gradient by taking the partial derivatives of the parameters. The gradient vector; Gradient clipping includes: gradient Perform L2 paradigm clipping to obtain the clipped gradient. : ; Where clip_norm=1.0; Parameter updates include: Using the Adam optimizer and clipped gradients To update the parameters: ; in Indicates the number of iterations. This is a hyperparameter.
7. A monocular ranging system based on EdgeCAM-Depth network, characterized in that, The system includes a module for performing the monocular ranging method for vehicle-front targets based on the EdgeCAM-Depth network as described in any one of claims 1 to 6.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the monocular ranging method for vehicle-front targets based on the EdgeCAM-Depth network as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the monocular ranging method for vehicle-front targets based on the EdgeCAM-Depth network as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Monocular distance measurement method used in vehicle driving
CN115937312A
An edge-guided RGBD underwater salient object detection method with multi-attention
JP7605548B1