A method for target detection and ranging based on similar triangles
By fusing a fast ranging algorithm based on similar triangles with a depth estimation network, the problem of detection and ranging in monocular vision ranging algorithms under low-resolution image conditions is solved, achieving high-precision and fast target detection and ranging, which is suitable for vehicle-road cooperative driving systems.
Patent Information
- Application Number
- CN202310600799.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-25
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2043-05-25
AI Technical Summary
Existing monocular vision ranging algorithms suffer from inaccurate target distance measurements due to imaging device errors, and their detection and ranging performance is poor under low-resolution image conditions, making it difficult to meet the real-time and accuracy requirements of vehicle-road cooperative driving.
A fast ranging algorithm based on similar triangles is combined with a convolutional neural network for target detection. The target distance is calculated using camera intrinsic parameters and geometric relationships, and the ranging results are fused and corrected through a depth estimation network to improve detection accuracy and speed.
It achieves fast and accurate target detection and ranging under low-resolution image conditions, meeting the real-time requirements of vehicle-road cooperative driving. It has high detection accuracy with an error within 0.8 meters.
Smart Images

Figure CN116740657B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of target detection and monocular depth estimation, specifically relating to a target detection and ranging method based on similar triangles. Background Technology
[0002] As one of the most important inventions since the 18th century, the automobile has greatly improved people's pace of life and promoted the progress of civilization. Today, the development level of the automotive industry has become a benchmark for technological progress. However, while enjoying the convenience brought by automobiles, people also suffer from traffic accidents. According to incomplete statistics, no fewer than 10 million people are injured or killed in traffic accidents worldwide each year. To prevent traffic accidents, vehicles must maintain a safe distance from pedestrians and other vehicles. Vehicle-to-everything (V2X) driving, as an important component of autonomous driving systems, is also crucial for improving the reliability and safety of autonomous driving systems. By using image-based methods to perceive the positions of vehicles and pedestrians, a large number of accidents can be effectively avoided and prevented.
[0003] Monocular vision ranging algorithms first acquire images of the observed scene using a camera, then employ object detection algorithms to identify and detect objects in the images, and finally measure the object distance based on the imaging model, function fitting, or geometric derivation methods, combined with the detection results. Due to errors in the imaging device or its installation, camera imaging may differ from expectations. Therefore, before measuring the distance to a target, the camera needs to be calibrated. The entire image or image pixels are corrected based on the obtained camera intrinsic parameters, and then the corrected image pixels are input into the monocular ranging model for distance measurement. Summary of the Invention
[0004] This invention provides a target detection and ranging method based on similar triangles. The model boasts high recognition accuracy and computational efficiency, while consuming minimal memory. It achieves good detection and ranging results even with low-resolution input images. The overall architecture is lightweight and fast, making it of great significance for vehicle-road cooperative driving, which demands high real-time performance.
[0005] The specific technical solution adopted in this invention is as follows:
[0006] A target detection and ranging method based on similar triangles includes the following steps:
[0007] S1. Acquire video stream of the lane area using a camera installed directly above the lane, and capture images of each frame in the video stream;
[0008] S2. Scale each captured image frame to the input image size of the target detection network, and standardize the scaled image frames to obtain the frames to be detected.
[0009] S3. Input the frame to be detected into the target detection network, extract the features in the frame to be detected through the convolutional neural network model, and then use the extracted features to obtain the position and category of the moving target in the frame to be detected through the detection head.
[0010] S4. Based on the moving target detection results in the frame to be detected, and combined with the camera intrinsic parameters, camera suspension position, and pre-calibrated reference lines, the actual distance between the moving target in the frame to be detected and the camera is obtained through a fast ranging algorithm based on similar triangles, using the geometric relationship between the moving target and the reference lines during the camera imaging process.
[0011] Preferably, in step S1, the target detection network is pre-trained using a labeled video dataset, and the video dataset contains data collected under various scenes and weather conditions.
[0012] Preferably, in step S2, the method for obtaining the frame to be detected from each acquired image frame through image processing is as follows:
[0013] First, the original image frame is scaled. During the scaling process, any unnecessary zeros are filled in to make the image fit the input size of the object detection network. The scaling factor, Scale, is the minimum of the aspect ratios of the input image to the object detection network and the original image frame.
[0014] Then, z-score normalization is performed on all pixel values in the scaled image to obtain the frame to be detected.
[0015] Preferably, in S3, the target detection network includes a feature extraction network and a target detection head, wherein the feature extraction network consists of a convolutional neural network model and a Neck layer, and the target detection head is used to detect the positions of pedestrians and vehicles on the road in the image.
[0016] Preferably, the camera is located directly above the lane, and the lower edge of its image is perpendicular to the direction of the lane line.
[0017] Preferably, in step S4, the process of calculating the actual distance using the fast distance measurement algorithm based on similar triangles is as follows:
[0018] S41. Using the physical position of the lower edge of the camera image on the road as a reference line, obtain the camera focal length F from the intrinsic parameters of the camera during imaging. At the same time, combine the position of the moving target detected in the frame to be detected to calculate the horizontal distance L between the moving target and the camera. The calculation formula is as follows:
[0019]
[0020] In the formula: H is the installation height of the camera from the road, D is the horizontal distance between the reference line and the projection of the camera on the road, α is the angle between the imaging surface of the camera's internal sensor and the horizontal plane, and Δ is the distance between the imaging positions of the moving target and the reference line on the imaging surface of the camera.
[0021] S42. Based on the spatial geometric relationship between the camera and the moving target, calculate the actual distance EC between the moving target and the camera. The calculation formula is as follows:
[0022]
[0023] The calculated EC is used as the ranging result output by the fast ranging algorithm.
[0024] Preferably, the frame to be detected is input into the depth estimation network to obtain the depth map corresponding to the frame to be detected. The mean depth value of all pixels in the central local area of the depth map is calculated and used as the first target distance value. At the same time, the actual distance obtained by the fast ranging algorithm in S4 is used as the second target distance value. The first target distance value and the second target distance value are fused and corrected to obtain the final value of the actual distance between the moving target and the camera.
[0025] Preferably, the width and height of the central local region of the depth map are half the width and height of the depth map, respectively.
[0026] Preferably, the input to the depth estimation network is the frame to be detected in RGB format, and the internal depth map output process is as follows:
[0027] 1) First, the frame to be detected is downsampled twice by 0.5 times to obtain the first feature map. Then, the first feature map is downsampled once by 0.5 times and upsampled once by 2 times to obtain the second feature map. Subtract the second feature map from the first feature map to obtain the third feature map.
[0028] 2) The frame to be detected is passed through four swin-transformer modules in sequence to extract feature maps of four different scales;
[0029] 3) Input the deepest feature map extracted by the fourth swin-transformer module into the depth prediction block, which is composed of concatenated convolutional modules and MLP layers. The depth prediction block outputs multiple discrete depth estimates corresponding to the frame to be detected.
[0030] 4) The deepest feature map extracted by the fourth swin-transformer module is input into the PSP module of the feature pyramid structure. The module output then passes through four cascaded attention modules in sequence. The four attention modules correspond one-to-one with the four swin-transformer modules to form skip connections. When each attention module executes the attention mechanism, it uses the output feature of the previous cascaded module as the query Q, and the feature map extracted by the corresponding swin-transformer module as the key K and value V. The feature output of the last attention module after attention fusion is used as the fourth feature map.
[0031] 5) The third and fourth feature maps are concatenated, and then passed through two convolutional modules and a Softmax layer to output a weight vector corresponding to each pixel in the frame to be detected. The dimension of the weight vector is the same as the number of discrete depth estimates output by the depth prediction block, and the weights in the weight vector correspond one-to-one with the discrete depth estimates. For each pixel in the frame to be detected, the discrete depth estimates output by the depth prediction block are weighted and summed using the corresponding weight vector to obtain the depth value corresponding to each pixel, thereby converting the frame to be detected into a depth map of the same size.
[0032] Preferably, the first target distance value depth model The distance value depth between the second target fast The method for fusion correction is weighted correction, and the final value of the actual distance is depth. final The calculation formula is as follows:
[0033] depth final =λ*depth fast +(1-λ)*depth model
[0034] In the formula: λ represents a weight value that is greater than 0 and less than 1.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] 1. This invention integrates target detection networks and lightweight ranging algorithms, resulting in fast detection and ranging speeds with high accuracy in traffic scenarios.
[0037] 2. The present invention can further integrate the estimation results of the depth estimation network and add attention and context mechanisms to the depth estimation network, and use the feature pyramid structure to predict the depth at multiple scales, thereby improving the accuracy of ranging.
[0038] 3. In view of the problem of inaccurate depth estimation of object edges in depth estimation, this invention proposes to improve the accuracy of depth estimation at the edges by adding targeted edge residual information. Attached Figure Description
[0039] Figure 1 This invention provides a target detection and ranging method based on similar triangles;
[0040] Figure 2 This is a structural diagram of the fast ranging algorithm based on similar triangles of the present invention;
[0041] Figure 3 This is the result of a fast ranging algorithm in a real traffic scenario in an embodiment of the present invention;
[0042] Figure 4 This is the result of a fast ranging algorithm in another actual traffic scenario in this embodiment of the invention;
[0043] Figure 5 This is a diagram of the depth estimation network structure of the present invention. Detailed Implementation
[0044] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be noted that the embodiments described below are intended to facilitate the understanding of the present invention and do not constitute any limitation thereof.
[0045] like Figure 1 As shown, in a preferred embodiment of the present invention, a target detection and ranging method based on similar triangles is provided, the method comprising the following steps:
[0046] S1. Acquire video streams of the lane area using a camera installed directly above the lane, and capture images of each frame in the video stream.
[0047] To ensure the successful implementation of the rapid ranging method described in this invention, the camera must be mounted directly above the lane using a mounting pole, and not on the side of the road, to avoid the horizontal projection of its imaging direction forming an angle with the vehicle's direction of travel. Specifically, after installation, the camera needs to be adjusted in angle and orientation to ensure that the lower edge of its image is perpendicular to the lane line direction.
[0048] S2. Scale each captured image frame to the input image size of the target detection network, and standardize the scaled image frames to obtain the frames to be detected.
[0049] In embodiments of the present invention, each acquired image frame needs to undergo pre-processing to ensure that the resulting frame to be detected meets the input requirements of the subsequent neural network. This image processing procedure needs to be selected based on the actual situation of the image and the neural network's requirements for the input image. Generally, it can involve basic image processing operations such as scaling, cropping, and normalization. In embodiments of the present invention, the method for image processing each frame is as follows:
[0050] First, the original image frame is scaled. During the scaling process, any unnecessary values are filled with zeros to make the image fit the input size of the object detection network. The scaling factor, Scale, is the minimum of the aspect ratios of the input image to the object detection network and the original image frame. This scaling ratio is expressed by the following formula:
[0051]
[0052] In the formula: Dst.width and Dst.height represent the width and height of the input image of the object detection network, respectively, and Origin.width and Origin.height represent the width and height of the original image frame, respectively.
[0053] Then, z-score normalization is performed on all pixel values in the scaled image to obtain the frame to be detected. Specifically, the normalization method involves subtracting the average pixel value from the standard deviation. After normalization, the image is fed into the object detection network for detection.
[0054] S3. Input the frame to be detected into the target detection network, extract the features in the frame to be detected through the convolutional neural network model, and then use the extracted features to obtain the position and category of the moving target in the frame to be detected through the detection head.
[0055] In the embodiments of the present invention, the above-mentioned target detection network is trained in advance using a labeled video dataset, and in order to ensure good detection performance in different environments, the video dataset should contain training data collected under various scenes and weather conditions.
[0056] The network structure of the aforementioned object detection network is not limited. In the embodiments of the present invention, the object detection network includes a feature extraction network and an object detection head. The feature extraction network consists of a convolutional neural network model and a Neck layer. The Neck layer adopts a combination of FPN and PAN, which can further improve the detection accuracy. The object detection head obtains the position of the moving target in the image based on the extracted features and accurately classifies the target. In this embodiment, the target category can include pedestrians and vehicles. Therefore, the object detection head can be used to detect the position of pedestrians and vehicles on the road in the image, that is, to obtain the position and category of the target box in the image. The aforementioned object detection network to be Necked can be directly implemented using the YOLOv5 model, which has the advantages of strong learning ability, high computational efficiency, and low memory cost.
[0057] S4. Based on the moving target detection results in the frame to be detected, and combined with the camera intrinsic parameters, camera suspension position, and pre-calibrated reference lines, the actual distance between the moving target in the frame to be detected and the camera is obtained through a fast ranging algorithm based on similar triangles, using the geometric relationship between the moving target and the reference lines during the camera imaging process.
[0058] In the embodiments of the present invention, the above-mentioned fast ranging algorithm based on similar triangles is actually calculated based on the principle of similar triangles in the imaging process, and the similarity relationship is as follows: Figure 2 As shown in the middle left figure. It should be noted that, for ease of explanation, Figure 2 The distance between the focal point inside the camera and the imaging surface is magnified in the left image. However, in practical applications, this focal length is negligible relative to the actual distance between the camera and the road. Therefore, the position of the focal point in the image can represent the position of the camera. Figure 2 The right figure illustrates the similar triangle calculation principle of this invention. After obtaining the detection results from the target detection network, since the final result of the ranging is to output the distance from the target detection box to the camera along with the corresponding physical target, the straight-line distance from the target to the camera's projection point on the road surface can be measured first. Then, the straight-line distance to the camera is calculated based on geometric relationships. In this process, a reference line can be pre-selected. In this embodiment, the reference line can be found corresponding to the bottom edge of the image captured by the camera. The distance from the target to the reference line is calculated based on the geometric relationships shown in the figure. The process of this fast ranging algorithm calculating the actual distance is as follows:
[0059] S41. Using the physical position of the lower edge of the camera image on the road as a reference line, obtain the camera focal length F from the intrinsic parameters of the camera during imaging, and combine it with the position of the moving target detected in the frame to be detected, referring to... Figure 2 As shown in the middle right figure, the distance to EB in the figure is calculated as follows:
[0060]
[0061] Correspondingly, the horizontal distance L between the moving target and the camera, L = EB + D, is calculated as follows:
[0062]
[0063] In the formula: H is the installation height of the camera above the road, D is the horizontal distance between the reference line and the camera's projection on the road, α is the angle between the camera's internal sensor imaging surface and the horizontal plane, and Δ is the distance between the imaging positions of the moving target and the reference line on the camera's imaging surface (which can be converted from pixel distance using camera intrinsic parameters). Among the above parameters, H, D, and α can be measured on-site, F is a known parameter of the camera, and Δ can be measured from the camera film.
[0064] It should be noted that since cameras are generally mounted on upright poles, the aforementioned horizontal distance D can actually be equivalent to the horizontal distance from the reference line to the pole.
[0065] S42. Based on the spatial geometric relationship between the camera and the moving target, calculate the actual distance EC between the moving target and the camera. The calculation formula is as follows:
[0066]
[0067] The calculated EC is used as the ranging result output by the fast ranging algorithm.
[0068] It should be noted that since the camera is continuously acquiring video streams, the target detection and ranging results for each frame can be obtained using the method described above, so this process can be real-time. Of course, the target detection and ranging can also be performed at intervals of a certain number of frames; there is no limitation on this.
[0069] To demonstrate the practical effectiveness of the target detection and ranging methods shown in S1 to S4 above, they were validated in a real traffic scenario. Figure 3 and Figure 4 The detection results are shown in Tables 3 and 4, which are image frames captured by cameras at two different intersections. The corresponding detection performance for these two intersection scenarios is shown in Tables 3 and 4, respectively.
[0070] Table 3
[0071] Object ID category Confidence Predicted distance / m Actual distance / m 1 vehicle 91% 103.9 103.5 2 vehicle 91% 47.4 47.2 3 vehicle 92% 39.9 40.0 4 vehicle 95% 14.2 14.2
[0072] Table 4
[0073] Object ID category Confidence Predicted distance / m Actual distance / m 1 vehicle 97% 100.8 100.5 2 vehicle 93% 80.1 79.9 3 vehicle 95% 22.0 21.8 4 Person 95% 24.3 24.5
[0074] The results above show that the model has both detection and ranging capabilities for real-world scenarios, with detection confidence levels exceeding 90% and ranging errors remaining within 0.8m. Therefore, the method proposed in this invention, by integrating a target detection network and a lightweight, fast ranging algorithm, achieves fast detection and ranging speeds with high accuracy in traffic scenarios.
[0075] In another embodiment of the present invention, the fast ranging result obtained based on the above-mentioned target detection network and lightweight fast ranging algorithm can be further corrected by integrating a depth estimation network. The specific steps are as follows:
[0076] The frame to be detected is input into the depth estimation network to obtain the depth map corresponding to the frame to be detected. The mean depth value of all pixels in the central local area of the depth map is calculated and used as the first target distance value. At the same time, the actual distance obtained by the fast ranging algorithm in S4 is used as the second target distance value. The first target distance value and the second target distance value are fused and corrected to obtain the final value of the actual distance of the moving target from the camera.
[0077] It should be noted that when calculating the distance value of the first target from the depth map, it is best to remove the surrounding edge pixels. Therefore, it is sufficient to select pixels from a central local area to include in the mean calculation. In an embodiment of the present invention, preferably, the width and height of the central local area of the depth map are half the width and height of the depth map, respectively.
[0078] In embodiments of this invention, the depth estimation network is based on a transformer model and employs a multi-feature fusion method, giving the model powerful contextual modeling capabilities. The model uses a Swin-transformer as its backbone network and a Feature Pyramid (PSP) block to predict depth at multiple scales. Prediction employs a method of first predicting bins, then perbin probabilities, and finally calculating the final depth result (PB block). Simultaneously, to address the issue of insufficient edge prediction accuracy in depth estimation, the model uses a method of downsampling and upsampling the original input image size, followed by subtraction to obtain residual edge information. This residual edge information is then concatenated with the features used for subsequent depth prediction, enhancing the edge information of the features. Figure 5 As shown, the input to this depth estimation network is the frame to be detected in RGB format, and the internal depth map output process is described in detail below:
[0079] 1) First, the frame to be detected is downsampled twice by 0.5 times to obtain the first feature map. Then, the first feature map is downsampled once by 0.5 times and upsampled once by 2 times to obtain the second feature map. Subtract the second feature map from the first feature map to obtain the third feature map.
[0080] 2) The frame to be detected is passed through four swin-transformer modules in sequence to extract feature maps of four different scales;
[0081] 3) Input the deepest feature map extracted by the fourth swin-transformer module into the depth prediction block, which is composed of concatenated convolutional modules and MLP layers. The depth prediction block outputs multiple discrete depth estimates corresponding to the frame to be detected.
[0082] 4) The deepest feature map extracted by the fourth swin-transformer module is input into the PSP module (i.e., PSP Block) of the feature pyramid structure. The module output then passes through four cascaded attention modules in sequence. The four attention modules correspond one-to-one with the four swin-transformer modules to form skip connections. When each attention module executes the attention mechanism, it uses the output feature of the previous cascaded module as the query Q, and the feature map extracted by the corresponding swin-transformer module as the key K and value V. The feature map after attention fusion output by the last attention module is used as the fourth feature map.
[0083] It's important to note that there's a one-to-one correspondence between the four attention modules and the four Swin-transformer modules; in the diagram, the Nth attention module corresponds to the Nth Swin-transformer module. During the forward propagation of the data, the order of the attention modules is: 1st attention module, 2nd attention module, 3rd attention module, 4th attention module, while the order of the Swin-transformer modules is: 4th Swin-transformer module, 3rd Swin-transformer module, 2nd Swin-transformer module, 1st Swin-transformer module. The feature map parameters output by the four Swin-transformer modules are labeled as follows: Figure 5 middle.
[0084] 5) The third and fourth feature maps are concatenated, and then passed through two convolutional modules and a Softmax layer to output the weight vector corresponding to each pixel in the frame to be detected. The dimension of the weight vector is the same as the number of discrete depth estimates output by the depth prediction block, and the weights in the weight vector correspond one-to-one with the discrete depth estimates. For each pixel in the frame to be detected, the discrete depth estimates output by the depth prediction block are weighted and summed using the corresponding weight vector to obtain the depth value corresponding to each pixel, thereby converting the frame to be detected into a depth map of the same size.
[0085] This invention will use the first target distance value depth model The distance value depth between the second target fast There are various methods for performing fusion correction. In embodiments of the present invention, a weighted correction can be used, that is, the final value of the actual distance, depth. final The calculation formula is as follows:
[0086] depth final =λ*depth fast +(1-λ)*depth model
[0087] In the formula, λ represents a weight value greater than 0 and less than 1. The specific value of λ can be optimized and adjusted according to actual conditions.
[0088] The embodiments described above provide a detailed explanation of the technical solutions and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A target detection and ranging method based on similar triangles, characterized in that, Includes the following steps: S1. Acquire video streams of the lane area using a camera installed directly above the lane, and capture images of each frame in the video stream; S2. Scale each captured image frame to the input image size of the target detection network, and standardize the scaled image frames to obtain the frames to be detected. S3. Input the frame to be detected into the target detection network, extract the features in the frame to be detected through the convolutional neural network model, and then use the extracted features to obtain the position and category of the moving target in the frame to be detected through the detection head. S4. Based on the moving target detection results in the frame to be detected, and combined with the camera intrinsic parameters, camera suspension position, and pre-calibrated reference lines, the actual distance between the moving target in the frame to be detected and the camera is obtained through a fast ranging algorithm based on similar triangles, utilizing the geometric relationship between the moving target and the reference lines during the camera imaging process. The process of calculating the actual distance using the fast ranging algorithm based on similar triangles is as follows: S41. Using the physical position of the lower edge of the camera image on the road as a reference line, obtain the camera focal length F from the intrinsic parameters of the camera during imaging. At the same time, combine the position of the moving target detected in the frame to be detected to calculate the horizontal distance L between the moving target and the camera. The calculation formula is as follows: In the formula: Where D is the installation height of the camera above the road, and D is the horizontal distance between the reference line and the camera's projection on the road. Δ is the angle between the imaging surface of the camera's internal sensor and the horizontal plane, and Δ is the distance between the imaging positions of the moving target and the reference line on the camera's imaging surface. S42. Calculate the actual distance between the moving target and the camera based on the spatial geometric relationship between the camera and the moving target. The calculation formula is: Calculated The distance measurement result is output by the fast distance measurement algorithm.
2. The target detection and ranging method based on similar triangles according to claim 1, characterized in that, In step S1, the target detection network is pre-trained using a labeled video dataset, which contains data collected under various scenes and weather conditions.
3. The target detection and ranging method based on similar triangles according to claim 1, characterized in that, In step S2, the method for obtaining the frame to be detected from each acquired image frame through image processing is as follows: First, the original image frame is scaled. During the scaling process, any unnecessary zeros are filled in to make the image fit the input size of the object detection network. The scaling factor, Scale, is the minimum of the aspect ratios of the input image to the object detection network and the original image frame. Then, z-score normalization is performed on all pixel values in the scaled image to obtain the frame to be detected.
4. The target detection and ranging method based on similar triangles according to claim 1, characterized in that, In S3, the target detection network includes a feature extraction network and a target detection head. The feature extraction network consists of a convolutional neural network model and a Neck layer. The target detection head is used to detect the positions of pedestrians and vehicles on the road in the image.
5. The target detection and ranging method based on similar triangles according to claim 1, characterized in that, The camera is located directly above the lane, and the lower edge of its image is perpendicular to the direction of the lane line.
6. The target detection and ranging method based on similar triangles according to claim 1, characterized in that, The frame to be detected is input into the depth estimation network to obtain the depth map corresponding to the frame to be detected. The mean depth value of all pixels in the central local area of the depth map is calculated and used as the first target distance value. At the same time, the actual distance obtained by the fast ranging algorithm in S4 is used as the second target distance value. The first target distance value and the second target distance value are fused and corrected to obtain the final value of the actual distance of the moving target from the camera.
7. The target detection and ranging method based on similar triangles according to claim 6, characterized in that, The width and height of the central local region of the depth map are half the width and half the height of the depth map, respectively.
8. The target detection and ranging method based on similar triangles according to claim 6, characterized in that, The depth estimation network takes the detected frame in RGB format as input, and its internal depth map output process is as follows: 1) First, perform two 0.5x downsampling operations on the frame to be detected to obtain the first feature map. Then, perform one 0.5x downsampling operation and one 2x upsampling operation on the first feature map to obtain the second feature map. Subtract the second feature map from the first feature map to obtain the third feature map. 2) The frame to be detected is passed through four swin-transformer modules in sequence to extract feature maps of four different scales; 3) Input the deepest feature map extracted by the fourth swin-transformer module into the depth prediction block, which is composed of concatenated convolutional modules and MLP layers. The depth prediction block outputs multiple discrete depth estimates corresponding to the frame to be detected. 4) The deepest feature map extracted by the fourth swin-transformer module is input into the PSP module of the feature pyramid structure. The module output then passes through four cascaded attention modules in sequence. The four attention modules correspond one-to-one with the four swin-transformer modules to form skip connections. When each attention module executes the attention mechanism, it uses the output feature of the previous cascaded module as the query Q, and the feature map extracted by the corresponding swin-transformer module as the key K and value V. The feature output of the last attention module after attention fusion is used as the fourth feature map. 5) The third and fourth feature maps are concatenated, and then passed through two convolutional modules and a Softmax layer to output a weight vector corresponding to each pixel in the frame to be detected. The dimension of the weight vector is the same as the number of discrete depth estimates output by the depth prediction block, and the weights in the weight vector correspond one-to-one with the discrete depth estimates. For each pixel in the frame to be detected, the discrete depth estimates output by the depth prediction block are weighted and summed using the corresponding weight vector to obtain the depth value corresponding to each pixel, thereby converting the frame to be detected into a depth map of the same size.
9. The target detection and ranging method based on similar triangles according to claim 8, characterized in that, The first target distance value Distance value between the second target The method for fusion correction is weighted correction, and the final value of the actual distance is... The calculation formula is as follows: In the formula: This represents a weight value that is greater than 0 and less than 1.
Citation Information
Patent Citations
Optimized depth extraction and passive ranging based on monocular vision
CN109146980A
Camera distance measurement method and device, and electronic device
CN109931906A