High-precision map construction method and device
Combining lidar data with visual feature matching and optimization to build high-precision maps solves the problems of high lidar positioning costs and high requirements for visual positioning data collection, and achieves low-cost, accurate visual positioning and coordinate consistency.
Patent Information
- Application Number
- CN202310268267.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2024-09-20
AI Technical Summary
Existing lidar positioning technology is costly and has poor positioning effect in degraded scenes. Although the visual positioning algorithm is low-cost, it has high requirements for data collection and is difficult to construct high-precision maps, resulting in coordinate inconsistencies between visual and laser positioning. .
A high-precision map construction method is used to obtain the current frame image data, perform visual feature matching and optimization, and combine it with lidar point cloud data to achieve accurate construction and update of visual maps to ensure coordinate consistency between vision and laser positioning. .
It achieves low-cost visual positioning, ensures positioning accuracy in some radar positioning failure scenarios, reduces data collection requirements, avoids mapping failures and coordinate inconsistencies, and improves mapping speed and robustness.
Smart Images

Figure CN118670374A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of map construction, and in particular to a method and device for constructing a high-precision map for visual positioning. Background Art
[0002] In the robot / car / autonomous driving industry, the real-time positioning of the robot / car itself usually relies on pre-established high-precision maps. A common positioning mode is lidar positioning, which obtains the current positioning data by matching the point cloud frame data obtained by the lidar at the current moment with the high-precision map. This is a high-precision global positioning mode and the most widely used positioning mode in the industry. Its main disadvantage is that the required lidar sensor is expensive and often cannot achieve good positioning in degraded scenarios (such as long corridors, tunnels, squares, etc.). These problems limit the large-scale commercial application of positioning algorithms.
[0003] Visual positioning algorithm is an alternative algorithm to laser positioning algorithm. The cost of camera is very low, and visual positioning relies on environmental texture information rather than structural information, so it can achieve good performance in degraded scenes. When using visual positioning algorithm, the construction of visual high-precision map is the prerequisite for its implementation. A common visual map construction method is SfM algorithm, which is a method of restoring environmental 3D structural information through a series of photos arranged in time order; another common algorithm is global visual 3D reconstruction, that is, in several pictures with common view relationship, feature points with matching relationship are used to solve the photo pose and restore the feature 3D coordinates. The main difference between the two is that the former requires the photos to be arranged in order while the latter does not. These two algorithms also have great limitations. For example, they require cameras with very high accuracy and resolution, and the cost is even higher than that of laser radar. In addition, they are both algorithms that restore 3D information from 2D information, so the requirements for data collection are very high, a large amount of data needs to be collected, and there must be enough common view between photos, which is likely to cause reconstruction failure. Furthermore, these two algorithms are very time-consuming. The more important problem is that the visual map reconstructed by pure visual 3D reconstruction is inconsistent with the high-precision point cloud map. For example, the coordinate error of the map points in the visual map is larger, and there is spatial offset / distortion, which leads to different positioning results of visual positioning and laser positioning at the same position in their respective maps, making it difficult to unify the coordinate system. The fundamental reason for this situation is that the pure visual method of obtaining 3D point cloud, which uses 2D information to restore 3D information, is less accurate than the method of directly obtaining 3D information (lidar). Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a method and device for constructing a high-precision map for visual positioning, which serves visual positioning to replace high-cost lidar positioning, thereby achieving cost reduction and positioning in some scenarios where radar positioning fails.
[0005] To achieve the above object, the present invention provides a method for constructing a high-precision map, comprising the following steps:
[0006] Step 1, obtain the image data collected by the current frame and create the current visual frame;
[0007] Step 2, performing frame-to-frame matching of visual features based on the current visual frame and the previous visual frame, and performing a first feature update on the visual map points in the current visual map;
[0008] Step 3, extracting a number of new visual feature points on each layer of the current visual frame, and performing frame-map matching of visual features based on the visual feature points extracted on the current visual frame and the visual map points in the current visual map, and performing a second feature update on the visual map points in the current visual map;
[0009] Step 4: Determine whether the visual feature points on each layer of the current visual frame reach the preset value:
[0010] If yes, proceed to step 5;
[0011] Otherwise, retain some of the remaining visual feature points after frame-map matching in step 3, so that the visual feature points on each layer of the current visual frame reach the preset value, and create new visual map points based on the retained visual feature points, and then proceed to step 5;
[0012] Step 5, optimizing the 3D coordinates of the visual map points corresponding to all the visual feature points on the current visual frame, and performing a third feature update on the visual map points in the current visual map.
[0013] In one embodiment, in step 1, creating the current visual frame is specifically:
[0014] Convert the image data collected by the current frame into a grayscale image, and normalize the grayscale value of each pixel in the grayscale image;
[0015] An L-layer image pyramid is constructed based on the grayscale image after the normalization operation, in which the scaling factor of the resolution between layers is λ.
[0016] The constructed L-layer image pyramid is used as the current visual frame, and its sequence number and pose are recorded.
[0017] In one embodiment, in the current visual frame, the maximum number of visual feature points on each layer is:
[0018]
[0019] Among them, n j is the maximum number of visual feature points on the jth layer, λj-1 is the multiple of the resolution between the jth layer and the first layer, λ L-1 is the multiple of the resolution between the Lth layer and the first layer, and N is the maximum number of visual feature points in a visual frame.
[0020] In one embodiment, the posture determination process of the current visual frame is:
[0021] In the process of collecting image data, laser radar point cloud data is collected, and based on the laser radar point cloud data, real-time laser positioning is performed in the high-precision map to obtain the position and posture of the laser radar point cloud data.
[0022] If the current visual frame and the lidar point cloud data have the same timestamp, the pose of the current visual frame in, are the external parameters of the body coordinate system and the camera coordinate system;
[0023] If the current visual frame and the lidar point cloud data do not have the same timestamp, the pose of the current visual frame is obtained by interpolating the positions of the previous and next two frames of lidar point cloud data.
[0024] In one embodiment, in step 2, the frame-to-frame matching process is:
[0025] For all visual feature points on all layers of the previous visual frame, optical flow tracking is performed on the corresponding layer of the current visual frame to obtain the pixel coordinates of the tracked visual feature points on the corresponding layer of the current visual frame, and this type of pixel coordinates is defined as 1# pixel coordinates;
[0026] Calculate the descriptor of the 1# pixel coordinates on each layer of the current visual frame, and add the serial number of the current frame and the layer, 1# pixel coordinates, and descriptors corresponding to the tracked visual feature points to the features of the corresponding visual map points in the visual map. Traversing the 1# pixel coordinates completes the first update of the visual map point features in the current visual map.
[0027] In one embodiment, in step 3, when extracting new visual feature points, the pixel coordinates of the newly extracted visual feature points are at least K pixels away from the pixel coordinates of the existing tracked visual feature points to avoid the features being too close on the pixel plane.
[0028] In one embodiment, in step 3, the frame-map matching process is:
[0029] Define the newly extracted visual feature points in step 3 as 1# visual feature points, and calculate the descriptors of all 1# visual feature points, which are defined as 1# descriptors;
[0030] For any visual map point m within the FoV range of the current visual frame, perform the following operations:
[0031] Get all the historical visual frames where the visual map point m is observed, calculate the angle between the current visual frame pose and all the historical visual frame poses, and get the descriptor of the visual map point m in the historical visual frame with the smallest angle, which is defined as 2# descriptor;
[0032] Get the pixel coordinates of the visual map point m on each layer of the current visual frame, defined as 2# pixel coordinates;
[0033] For each layer of the current visual frame, calculate the similarity between the 1# descriptor and the 2# descriptor of all 1# visual feature points within the window centered on the corresponding 2# pixel coordinates, and define the 1# visual feature point corresponding to the 1# descriptor with the smallest similarity as the 2# visual feature point;
[0034] Determine whether the similarity corresponding to 2# visual feature point is less than the threshold:
[0035] If yes, add the sequence number of the current frame, the layer corresponding to the 2# visual feature point, the pixel coordinates and the descriptor to the features of the visual map point m, and then process the next visual map point;
[0036] Otherwise, directly proceed to the next visual map point;
[0037] Traversing all visual map points in the current visual map within the FoV range of the current visual frame, that is, completing the second update of the visual map point features in the current visual map.
[0038] In one embodiment, in step 4, the remaining visual feature points after the frame-map matching in step 3 are retained, specifically:
[0039] For any layer of the current visual frame, obtain the difference δn between the current visual map point of the layer and the preset value;
[0040] Calculate the grayscale differences between all remaining visual feature points and the surrounding visual feature points after frame-map matching in step 3, and select δn visual feature points with the largest grayscale differences to retain.
[0041] In one embodiment, in step 4, creating a new visual map point based on the retained visual feature point is specifically:
[0042] Define the retained visual feature point as 3# visual feature point, and use the point cloud near the current position in the high-precision map as the local point cloud map of the current frame;
[0043] Projecting the local point cloud map onto each layer of the current visual frame to construct a depth map pyramid;
[0044] For any 3# visual feature point, select the depth value corresponding to the pixel coordinates with depth value closest to the pixel coordinates of the 3# visual feature point in the corresponding layer of the depth map pyramid as the depth value of the 3# visual feature point;
[0045] Based on the depth value of the 3# visual feature point, the 3D coordinates of the 3# visual feature point are obtained, a new visual map point is created, and the current frame number and the 3D coordinates, layer, descriptor, and pixel coordinates of the 3# visual feature point are added to the visual map as features of the newly created visual map point;
[0046] Traversing all 3# visual feature points, the third update of the visual map point features in the current visual map is completed.
[0047] In one embodiment, the 3D coordinates of the 3# visual feature point are obtained based on the depth value of the 3# visual feature point:
[0048]
[0049]
[0050] u=π(x
[0051] Where P w is the 3D coordinate of the 3# visual feature point, P c is the camera coordinate of 3# visual feature point, is the transformation matrix from the body coordinate system to the world coordinate system, x is the normalized coordinate, π(·) is the camera internal parameter, u is the pixel coordinate of the 3# visual feature point, P c ,z is the depth value of the 3# visual feature point.
[0052] In one embodiment, the high-precision map construction method further includes:
[0053] Step 6: Determine whether the current visual frame is a key frame:
[0054] If yes, construct the word based on the descriptor of the current visual frame and the pixel coordinates of the visual feature points and add it to the bag of words, and then perform steps 1 to 6 after obtaining new image data;
[0055] Otherwise, perform steps 1 to 6 after acquiring new image data.
[0056] To achieve the above object, the present invention also provides a high-precision map construction device, which uses the above method to construct a high-precision map, and the high-precision map construction device includes:
[0057] A visual frame construction unit, used to obtain image data collected by the current frame and create the current visual frame;
[0058] A frame-to-frame matching unit, used for performing frame-to-frame matching of visual features based on a current visual frame and a previous visual frame, and performing a first feature update on a visual map point in a current visual map;
[0059] The feature extraction unit is used to extract a number of new visual feature points on each layer of the current visual frame.
[0060] A frame-map matching unit, used for performing frame-map matching of visual features based on visual feature points extracted from the current visual frame and visual map points in the current visual map, and performing a second feature update on the visual map points in the current visual map;
[0061] A visual map point creation unit, for retaining some of the visual feature points remaining after frame-map matching when the visual feature points on the layer of the current visual frame do not reach a preset value, so that the visual feature points on each layer of the current visual frame reach a preset value, and creating new visual map points based on the retained visual feature points;
[0062] A coordinate optimization unit is used to optimize the 3D coordinates of the visual map points corresponding to all visual feature points on the current visual frame, and perform a third feature update on the visual map points in the current visual map;
[0063] The key frame extraction unit is used to construct words from the key frame descriptors and the pixel coordinates of the visual feature points and add them to the bag of words.
[0064] To achieve the above object, the present invention further provides a terminal device, which is a computer, an unmanned vehicle, an unmanned aerial vehicle, an unmanned driving device or a mobile robot, and is provided with:
[0065] Memory, used to store programs;
[0066] A processor is used to execute the program stored in the memory. When the program is executed, the processor is used to execute part or all of the steps of the above method.
[0067] To achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions; when the computer-executable instructions are executed by a processor, they are used to implement part or all of the steps of the above method.
[0068] The present invention has the following beneficial technical effects:
[0069] 1. The visual high-precision map constructed by the present invention can realize visual positioning at low cost, realize cost-reduced positioning and positioning in some scenes where radar positioning fails;
[0070] 2. The visual high-precision map constructed by the present invention occupies the same space as the laser radar point cloud high-precision map. The positioning data provided by the visual positioning in the visual high-precision map and the laser radar positioning data can be understood by the downstream modules in the same way;
[0071] 3. The visual high-precision map constructed by the present invention not only has a fast construction speed and high robustness, but also has relatively low requirements for data collection, and there will be no problem of map construction failure. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0073] Figure 1 This is a flowchart of the high-precision map construction method in Example 1 of the present invention;
[0074] Figure 2 It is a schematic diagram of a visual map point being observed by multiple visual frames in Example 1 of the present invention;
[0075] Figure 3 A schematic diagram of the matching relationship between features in Example 1 of the present invention;
[0076] Figure 4 This is a structural block diagram of a high-precision map construction device in Embodiment 2 of the present invention;
[0077] Figure 5 This is a structural block diagram of the terminal device in Example 3 of the present invention.
[0078] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0079] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0080] In addition, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0081] Example 1
[0082] This embodiment discloses a method for constructing a high-precision map for visual positioning. The visual map established by this method is completely consistent with the coordinates of the high-precision point cloud map used for laser positioning. The visual positioning result based on the output of the visual map is equivalent to the laser positioning result in the high-precision map, and no additional spatial distortion and spatial transformation are required. The constructed high-precision visual map mainly serves visual positioning and can replace laser radar positioning to achieve cost reduction and positioning in some radar positioning failure scenarios. It not only has fast mapping speed and high robustness, but also has relatively low requirements for data collection, and will not cause mapping failure problems.
[0083] The high-precision map in this embodiment is a visual map, which consists of a set of visual map points, a set of visual frames, and a bag of words.
[0084] For any visual map point, its features include:
[0085] 3D coordinates: x, y, z;
[0086] Descriptor: d1, d2, ..., d n ;
[0087] Frame number: F1, F2, ..., F n ;
[0088] Layers: l1, l2, ..., l n ;
[0089] Pixel coordinates: u1, u2, ..., u n .
[0090] The value of n can be limited. For example, n can be set to 20, that is, when the data saved by a certain feature is greater than 20, the oldest observation data is deleted.
[0091] For any visual frame, its features include:
[0092] Frame number: i;
[0093] Pose: T;
[0094] Observed visual map point number: m1, m2, ..., m n .
[0095] The bag of words contains keyframes and their descriptor words.
[0096] For a certain visual map point, it may be observed on different layers in different visual frames. i Layer l i It is observed on the layer l of this visual frame. i The observed descriptor is d i , pixel coordinate is u i Therefore, the frame number, layer, pixel coordinates and descriptor stored in the visual map are one-to-one corresponding. Its observations on different visual frames have a 2D-2D matching relationship, and its 3D coordinates have a 3D-2D matching relationship with a certain observation on any visual frame. The subscript n indicates that the visual map point is observed and recorded on n visual frames. For this visual map point, (d i , l i ,u i ) is its position in the visual frame F i A feature / observation on i It is the pixel coordinate of the visual map point on the visual frame.
[0097] For a visual frame, it records its own position and frame number, as well as the IDs of all visual map points it observes. Therefore, for a visual map point, the corresponding visual frame can be found according to the frame number it records, and for a visual frame, all visual map points it observes can be found according to the visual map point number it records. This is a fast two-way search method.
[0098] The bag of words is a commonly used tool in the field of vision, used for loop detection and relocalization. When a key frame is identified during the mapping process, its descriptor and feature coordinates are used to construct words and added to the bag of words.
[0099] The hardware requirements for the high-precision map construction method in this embodiment are: having both a camera and a lidar sensor. The lidar is only required when building a visual map, not when visual positioning. Figure 1 The high-precision map construction method in this embodiment specifically includes the following steps:
[0100] Step 1, obtain the image data collected by the current frame and create the current visual frame;
[0101] Step 2, performing frame-to-frame matching of visual features based on the current visual frame and the previous visual frame, and performing a first feature update on the visual map points in the current visual map;
[0102] Step 3, extracting a number of new visual feature points on each layer of the current visual frame, and performing frame-map matching of visual features based on the visual feature points extracted on the current visual frame and the visual map points in the current visual map, and performing a second feature update on the visual map points in the current visual map;
[0103] Step 4: Determine whether the visual feature points on each layer of the current visual frame reach the preset value:
[0104] If yes, proceed to step 5;
[0105] Otherwise, retain some of the remaining visual feature points after frame-map matching in step 3, so that the visual feature points on each layer of the current visual frame reach the preset value, and create new visual map points based on the retained visual feature points, and then proceed to step 5;
[0106] Step 5, optimizing the 3D coordinates of the visual map points corresponding to all the visual feature points on the current visual frame, and performing a third feature update on the visual map points in the current visual map;
[0107] Step 6: Determine whether the current visual frame is a key frame:
[0108] If yes, construct the word based on the descriptor of the current visual frame and the pixel coordinates of the visual feature points and add it to the bag of words, and then perform steps 1 to 6 after obtaining new image data;
[0109] Otherwise, perform steps 1 to 6 after acquiring new image data.
[0110] For visual maps, radar frame and photo frame data need to be collected. If there is no high-precision point cloud map, the image data required for the visual map and the point cloud data required for the high-precision point cloud map can be collected at the same time. The high-precision point cloud map is first constructed using the existing mapping algorithm, and then the visual map is constructed based on the high-precision point cloud map.
[0111] In step 1, the creation process of the current visual frame is:
[0112] In the process of collecting image data, the laser radar point cloud data is collected, and real-time laser positioning is performed in the high-precision point cloud map based on the laser radar point cloud data to obtain a local point cloud map. In the high-precision point cloud map, the point cloud near the current position is used as the local map at the current moment. At this time, data playback is performed based on the existing high-precision point cloud map. For the current moment, the laser radar point cloud data is matched with the high-precision point cloud map to obtain the position and posture of the current laser radar point cloud data frame. Using the external parameters of the existing body coordinate system b and camera coordinate system c You can get the current c-system pose Right now:
[0113]
[0114] If the current visual frame and the lidar point cloud data have the same timestamp, the pose of the current visual frame can be directly obtained by formula (1);
[0115] If the current visual frame and the lidar point cloud data do not have the same timestamp, the pose of the current visual frame is obtained by interpolating the positions of the two previous and next frames of lidar point cloud data. That is, the C-based poses corresponding to the two previous and next frames of lidar point cloud data are first calculated by formula (1), and then the pose of the current visual frame is interpolated from the two C-based poses.
[0116] After obtaining the pose of the current visual frame, the image data collected by the current frame is converted into a grayscale image. For a certain pixel in the image data, the conversion relationship between its RGB and grayscale values is:
[0117] gray=0.2126×r+0.7125×g+0.0722×b (2)
[0118] Among them, gray is the gray value of the corresponding pixel, r, g, b are the RGB values of the corresponding pixels;
[0119] After the collected image data is converted into a grayscale image, the grayscale value of each pixel in the grayscale image needs to be normalized. Specifically, the maximum grayscale value in the grayscale image is recorded as gray max , for each pixel’s gray value, map it according to the following formula:
[0120]
[0121] Then, an image pyramid is constructed based on the grayscale image after normalization. For an L-layer image pyramid, the scaling factor between layers is λ. Then the resolutions of the first, second, ..., L-th layer images are 1, λ, ..., λ of the first layer image resolution, respectively. L-1 times, each layer of image is obtained by downsampling the previous layer of image according to the scaling factor. For each visual frame, at most N features are retained. Then for the jth layer of image, the maximum number of features on this layer of image is n j satisfy:
[0122]
[0123] Finally, the constructed L-layer image pyramid is used as the current visual frame, and its frame number and pose are recorded.
[0124] It should be noted that in this embodiment, there is no restriction on the layer frame of the visual frame, and there may be only one layer, which is equivalent to not building an image pyramid. It may also be 3 layers, 5 layers, etc.
[0125] The frame-to-frame matching in step 2 is mainly used to obtain the matching relationship between the continuously observed features / visual map points in different visual frames. For a visual feature point on a layer of the previous visual frame, optical flow tracking is performed on the corresponding layer of the current visual frame to obtain the pixel coordinates of the corresponding layer of the visual feature point in the current visual frame, and calculate the descriptor of the pixel coordinates of the layer. For this visual feature point, it has been observed continuously for at least 2 frames. Therefore, for this visual feature point, assuming that it has been observed a times, it has the following associated data, that is, the feature information f includes:
[0126] 3D coordinates: x, y, z
[0127] Current visual frame pixel coordinates, layers and descriptors: u, l, d;
[0128] The pixel coordinates and layer of the previous visual frame: u(-1), l(-1), d(-1); ...
[0130] a-1 frame before the visual frame pixel coordinates and layer: u(-(a-1)), l(-(a-1)), d(-(a-1));
[0131] Subsequently, the newly calculated descriptor, layer, pixel coordinates of the visual feature point in the current frame and the current frame sequence number are added to the corresponding point in the visual map.
[0132] Therefore, the specific process of frame-to-frame matching in this embodiment is as follows:
[0133] For all visual feature points on all layers of the previous visual frame, optical flow tracking is performed on the corresponding layer of the current visual frame to obtain the pixel coordinates of the tracked visual feature points on the corresponding layer of the current visual frame, and this type of pixel coordinates is defined as 1# pixel coordinates;
[0134] Calculate the descriptor of the 1# pixel coordinates on each layer of the current visual frame, and add the serial number of the current frame and the layer, 1# pixel coordinates, and descriptors corresponding to the tracked visual feature points to the features of the corresponding visual map points in the visual map. Traversing the 1# pixel coordinates completes the first update of the visual map point features in the current visual map.
[0135] In step 3, existing extraction algorithms such as FAST, HARRIS, superpoint, etc. can be used to extract new visual feature points. The present embodiment is not limited to a certain extraction algorithm, such as extracting ORB feature points as visual feature points, and other feature points can also be extracted as visual feature points. At this time, for each layer j of the current visual frame, several new visual feature points are extracted respectively, and the pixel coordinates of the newly extracted visual feature points and the existing tracked visual feature points are at least K pixels away from each other to avoid the features being too close on the pixel plane. For each visual feature point, its descriptor in the corresponding layer is calculated. There are also a variety of extraction algorithms for descriptors, such as ORB, surf, BRISK and other algorithms. The descriptor in this embodiment is the ORB descriptor.
[0136] In step 3, frame-map matching is mainly used to obtain the matching relationship between visual map points in different visual frames whose observation time is discontinuous. The frame-frame matching in step 2 can only obtain those features that are continuously observed in time, and cannot obtain the matching relationship between features that are discontinuous in time. For example, the body was in a certain posture at a certain moment, and after a long period of continuous operation in different positions, it returned to a similar posture. For a certain feature, continuous observation cannot be achieved. At this time, frame-map matching is required. Project the existing visual map points in the existing visual map that are within the FoV range of the current visual frame onto all layers of the current visual frame. For example Figure 2 As shown in the figure, for a visual map point m, it is within the FoV range of the current visual frame and is observed in several visual frames, that is, F k 、F p 、F n , where the current visual frame is F n , the historical visual frame is F k , F p .
[0137] Using the Rodriguez formula, the rotation matrix parts in these frame poses can be converted into rotation vectors:
[0138]
[0139] in, is the rotation matrix of the visual frame, n is the rotation vector of the visual frame;
[0140] After converting the rotation matrix part into the rotation vector, the historical visual frame F is calculated respectively. k 、F p Pose and current visual frame F p The posture angle is:
[0141] θ=arccos(n1,n2) (6)
[0142] Among them, θ is the angle between the two visual frame poses corresponding to the rotation vectors n1 and n2;
[0143] Select the historical visual frame with the smallest angle and its descriptor, such as the historical visual frame F p With the current visual frame F n The angle is the smallest. In the historical visual frame F p In the above figure, the descriptor of the visual map point m is d and the layer is j, then d is the descriptor used in the current matching of the landmark point. n On each layer, the visual map point m has corresponding theoretical pixel coordinates. Within the window range centered on the pixel coordinates of each layer, its descriptor d is compared with the descriptors of all newly extracted visual feature points in the layer. In the case of the ORB descriptor, the similarity is characterized by the Mahalanobis distance between the descriptors. The feature f with the smallest descriptor distance among all layers is selected. If this distance is less than a threshold, the feature f is the feature of the map point m in the frame. The layer where the feature f is located is not necessarily the same as the layer where the visual map point m is located in the historical visual frame F. p The descriptor, layer, pixel coordinates, and current frame pose of the feature f in the current frame are added to the visual map point m, thus completing the frame-map matching of the visual map point m.
[0144] Therefore, the frame-map matching process in this embodiment is:
[0145] Define the newly extracted visual feature points in step 3 as 1# visual feature points, and calculate the descriptors of all 1# visual feature points, which are defined as 1# descriptors;
[0146] For any visual map point m within the FoV range of the current visual frame, perform the following operations:
[0147] Get all the historical visual frames where the visual map point m is observed, calculate the angle between the current visual frame pose and all the historical visual frame poses, and get the descriptor of the visual map point m in the historical visual frame with the smallest angle, which is defined as 2# descriptor;
[0148] Get the pixel coordinates of the visual map point m on each layer of the current visual frame, defined as 2# pixel coordinates;
[0149] For each layer of the current visual frame, calculate the similarity between the 1# descriptor and the 2# descriptor of all 1# visual feature points within the window centered on the corresponding 2# pixel coordinates, and define the 1# visual feature point corresponding to the 1# descriptor with the smallest similarity as the 2# visual feature point;
[0150] Determine whether the similarity corresponding to 2# visual feature point is less than the threshold:
[0151] If yes, add the sequence number of the current frame, the layer corresponding to the 2# visual feature point, the pixel coordinates and the descriptor to the features of the visual map point m, and then process the next visual map point;
[0152] Otherwise, directly proceed to the next visual map point;
[0153] Traversing all visual map points in the current visual map within the FoV range of the current visual frame, that is, completing the second update of the visual map point features in the current visual map.
[0154] In step 4, for each layer of the current visual frame after frame-to-frame matching and frame-to-map matching, assume that a total of h j visual feature points (including the points obtained in the frame-to-frame matching and frame-to-map matching), if h j Less than n j , then the layer needs to be supplemented with at most n j -h j For the remaining feature points newly extracted in step 3 (the visual feature points that did not obtain a matching relationship in the frame-map matching), keep the best n j -h j feature points, so that the visual feature points on layer j reach the preset value n j Specifically in this embodiment, the process of retaining some of the visual feature points remaining after the frame-map matching in step 3 is as follows:
[0155] For any layer of the current visual frame, obtain the difference δn between the current visual map point of the layer and the preset value;
[0156] Calculate the grayscale differences between all remaining visual feature points and the surrounding visual feature points after frame-map matching in step 3, and select δn visual feature points with the largest grayscale differences to retain.
[0157] In step 4, by performing deep association on the visual features without matching relationships (the above-mentioned retained visual feature points), the matching relationship between the 2D visual feature points and the 3D coordinates is obtained, and a new visual map point is created. The specific implementation process is as follows:
[0158] Define the retained visual feature point as 3# visual feature point, and use the point cloud near the current position in the high-precision map as the local point cloud map of the current frame;
[0159] The local point cloud map is projected onto each layer of the current visual frame to construct a depth map pyramid, which is:
[0160]
[0161] For a local map point, its world coordinate is P w , through the posture Convert to the current frame camera system c coordinate P c , P c Divide by its z value to get its normalized coordinate x, and get its pixel coordinate in the layer according to the camera intrinsic parameter π of the layer. Then, set the depth value to P at the pixel coordinate position on the depth map of the layer. c The z value of .
[0162] For any 3# visual feature point, select the depth value corresponding to the pixel coordinates with depth value closest to the pixel coordinates of the 3# visual feature point in the corresponding layer of the depth map pyramid as the depth value of the 3# visual feature point;
[0163] The reverse process of formula (7) can be used to obtain the 3D coordinates of the 3# visual feature point based on the depth value of the 3# visual feature point, and then create a new visual map point. The current frame number and the 3D coordinates, layer, descriptor, and pixel coordinates of the 3# visual feature point are added to the visual map as the features of the newly created visual map point;
[0164] Traversing all 3# visual feature points, the third update of the visual map point features in the current visual map is completed.
[0165] It is worth noting that if the current visual frame is the first frame, the aforementioned frame-to-frame matching and frame-to-map matching are not performed, and the feature point extraction in step 3 is performed directly, and then the visual map point creation in step 4 is performed.
[0166] After frame-to-frame matching, frame-to-map matching, and visual map point creation, all visual feature points on the current visual frame correspond to at least one set of 2D pixel coordinate-3D world coordinate matching relationships. For visual map points that have been observed multiple times, they have multiple 2D pixel coordinate matching relationships. At this point, all observed visual map points on the current visual frame (continuously observed visual map points and newly created visual map points) are optimized and their 3D coordinates are updated.
[0167] The matching relationship between features is as follows Figure 3 As shown, map point m i and m i+1 are visual map points observed continuously by consecutive frames, respectively in visual frame F k 、F k+1 、F k+2 and visual frame F k+1 、F k+2 、F k+3 Observed; map point m jis observed by time-discontinuous frames, which are visual frames F k 、F p Observed; map point m j+1 is a newly extracted visual map point, which is only captured by frame F p+1 Observed.
[0168] For a visual map point m, its pixel coordinates observed on frame F are u, then when its 3D coordinates are projected onto the pixel plane of frame F, the projection error Δr is:
[0169]
[0170] in, is the pixel coordinates of the 3D coordinates of the visual map point m projected onto the current visual frame, and u is the pixel coordinates actually observed on the current visual frame. For the pinhole camera model, the relationship between its pixel coordinates and camera coordinates is:
[0171]
[0172] Among them, K is the camera internal parameter, which can be obtained by the previous internal parameter calibration and is currently considered known. The relationship between its camera coordinates and map coordinates is:
[0173]
[0174] in, is a known quantity, is the predicted value of the current map coordinate of the feature and is the amount to be optimized.
[0175] The derivative of the projection error with respect to the camera coordinates is:
[0176]
[0177] Among them, X, Y, and Z are the coordinates of the feature in the camera system, and fx and fy are the camera internal parameters. The derivative of the camera system coordinates to the map system coordinates is:
[0178]
[0179] According to the chain rule of derivation:
[0180]
[0181] According to the chain rule, the increment delta_x of the 3D coordinates of the visual map point can be obtained, and adding it to the 3D coordinates can achieve the optimization of the 3D coordinates of the visual map point. This embodiment does not limit the optimization method of the 3D coordinates of the map point, and a filtering method can be used, such as ESIKF (state error iterative Kalman filter); or an optimization method, such as Gauss-Newton algorithm.
[0182] In this embodiment, the specific implementation process of step 6 is:
[0183] The pose of the current visual frame is searched in the keyframe pose kdtree by radius, and all keyframes within the range of dis meters are searched. If they exist, their direction vectors, i.e., orientation, are compared with those of the keyframes. When the orientation angle is less than the threshold, the current visual frame is determined not to be a keyframe, otherwise it is determined to be a keyframe. If there is no keyframe within the range of dis meters, the current visual frame is also a keyframe. If the current visual frame is a keyframe, its pose is added to the kdtree, and the visual frame descriptor and feature point pixel coordinates are used to construct words and added to the bag of words.
[0184] It is worth noting that the application of the high-precision map construction method in this embodiment is not limited to visual positioning, but can also be applied to mobile robots, intelligent driving vehicles, surveying and mapping, three-dimensional reconstruction equipment, visual odometers, SLAM algorithms, etc.
[0185] Example 2
[0186] Based on the high-precision map construction method in Example 1, this embodiment discloses a high-precision map construction device. Figure 4 The high-precision map construction device includes a visual frame construction unit, a frame-frame matching unit, a feature extraction unit, a frame-map matching unit, a visual map point creation unit, a coordinate optimization unit and a key frame extraction unit. The high-precision map construction device is used to execute some or all steps of the high-precision map construction method in Example 1, and to construct a high-precision visual map. Specifically:
[0187] The visual frame construction unit is used to obtain the image data collected by the current frame and create the current visual frame;
[0188] The frame-to-frame matching unit is used to perform frame-to-frame matching of visual features according to the current visual frame and the previous visual frame, and perform the first feature update on the visual map points in the current visual map;
[0189] The feature extraction unit is used to extract several new visual feature points on each layer of the current visual frame.
[0190] The frame-map matching unit is used to perform frame-map matching of visual features based on the visual feature points extracted on the current visual frame and the visual map points in the current visual map, and perform a second feature update on the visual map points in the current visual map;
[0191] The visual map point creation unit is used to retain the remaining visual feature points after some frame-map matching when the visual feature points on the layer of the current visual frame do not reach the preset value, so that the visual feature points on each layer of the current visual frame reach the preset value, and create new visual map points based on the retained visual feature points;
[0192] The coordinate optimization unit is used to optimize the 3D coordinates of the visual map points corresponding to all the visual feature points on the current visual frame, and perform a third feature update on the visual map points in the current visual map;
[0193] The key frame extraction unit is used to construct words from the key frame descriptors and the pixel coordinates of the visual feature points and add them into the bag of words.
[0194] In this embodiment, the specific working process and working principle of the visual frame construction unit, frame-frame matching unit, feature extraction unit, frame-map matching unit, visual map point creation unit, coordinate optimization unit and key frame extraction unit are the same as the method in Example 1, so they will not be repeated in this embodiment.
[0195] Example 3
[0196] like Figure 5 The terminal device disclosed in this embodiment is shown, including a transmitter, a receiver, a memory and a processor. Among them, the transmitter is used to send instructions and data, the receiver is used to receive instructions and data, the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions stored in the memory to implement some or all of the steps performed by the high-precision map construction method in the above-mentioned embodiment 1. Its specific implementation process is the same as the high-precision map construction method in the above-mentioned embodiment 1.
[0197] It should be noted that the above memory can be independent or integrated with the processor. When the memory is independently provided, the terminal device further includes a bus for connecting the memory and the processor.
[0198] In the specific application process, the terminal device is a computer, an unmanned vehicle, a drone, an unmanned driving device or a mobile robot, etc.
[0199] Example 4
[0200] This embodiment discloses a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, some or all of the steps executed by the high-precision map construction method in the above-mentioned embodiment 1 are implemented.
[0201] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A method for constructing a high-precision map, characterized in that: The steps include: Step 1, obtain the image data collected by the current frame and create the current visual frame; Step 2, performing frame-to-frame matching of visual features based on the current visual frame and the previous visual frame, and performing a first feature update on the visual map points in the current visual map; Step 3, extracting a number of new visual feature points on each layer of the current visual frame, and performing frame-map matching of visual features based on the visual feature points extracted on the current visual frame and the visual map points in the current visual map, and performing a second feature update on the visual map points in the current visual map; Step 4: Determine whether the visual feature points on each layer of the current visual frame reach the preset value: If yes, proceed to step 5; Otherwise, retain some of the remaining visual feature points after frame-map matching in step 3, so that the visual feature points on each layer of the current visual frame reach the preset value, and create new visual map points based on the retained visual feature points, and then proceed to step 5; Step 5, optimizing the 3D coordinates of the visual map points corresponding to all the visual feature points on the current visual frame, and performing a third feature update on the visual map points in the current visual map.
2. The method for constructing a high-precision map according to claim 1, characterized in that: In step 1, the creation of the current visual frame is specifically as follows: Convert the image data collected by the current frame into a grayscale image, and normalize the grayscale value of each pixel in the grayscale image; An L-layer image pyramid is constructed based on the grayscale image after the normalization operation, in which the scaling factor of the resolution between layers is λ. The constructed L-layer image pyramid is used as the current visual frame, and its sequence number and pose are recorded.
3. The method for constructing a high-precision map according to claim 2, characterized in that: In the current visual frame, the maximum number of visual feature points on each layer is: Among them, n j is the maximum number of visual feature points on the jth layer, λ j-1 is the multiple of the resolution between the jth layer and the first layer, λ L-1 is the multiple of the resolution between the Lth layer and the first layer, and N is the maximum number of visual feature points in a visual frame.
4. The method for constructing a high-precision map according to claim 2, characterized in that: The pose determination process of the current visual frame is: In the process of collecting image data, laser radar point cloud data is collected, and based on the laser radar point cloud data, real-time laser positioning is performed in the high-precision point cloud map to obtain the position and posture of the laser radar point cloud data. If the current visual frame and the lidar point cloud data have the same timestamp, the pose of the current visual frame in, are the external parameters of the body coordinate system and the camera coordinate system; If the current visual frame and the lidar point cloud data do not have the same timestamp, the pose of the current visual frame is obtained by interpolating the positions of the previous and next two frames of lidar point cloud data.
5. The method for constructing a high-precision map according to claim 1, 2 or 3, characterized in that: In step 2, the frame-to-frame matching process is: For all visual feature points on all layers of the previous visual frame, optical flow tracking is performed on the corresponding layer of the current visual frame to obtain the pixel coordinates of the tracked visual feature points on the corresponding layer of the current visual frame, and this type of pixel coordinates is defined as 1# pixel coordinates; Calculate the descriptor of the 1# pixel coordinates on each layer of the current visual frame, and add the serial number of the current frame and the layer, 1# pixel coordinates, and descriptors corresponding to the tracked visual feature points to the features of the corresponding visual map points in the visual map. Traversing the 1# pixel coordinates completes the first update of the visual map point features in the current visual map.
6. The method for constructing a high-precision map according to claim 1, 2 or 3, characterized in that: In step 3, the frame-map matching process is: Define the newly extracted visual feature points in step 3 as 1# visual feature points, and calculate the descriptors of all 1# visual feature points, which are defined as 1# descriptors; For any visual map point m within the FoV range of the current visual frame, perform the following operations: Get all the historical visual frames where the visual map point m is observed, calculate the angle between the current visual frame pose and all the historical visual frame poses, and get the descriptor of the visual map point m in the historical visual frame with the smallest angle, which is defined as 2# descriptor; Get the pixel coordinates of the visual map point m on each layer of the current visual frame, defined as 2# pixel coordinates; For each layer of the current visual frame, calculate the similarity between the 1# descriptor and the 2# descriptor of all 1# visual feature points within the window centered on the corresponding 2# pixel coordinates, and define the 1# visual feature point corresponding to the 1# descriptor with the smallest similarity as the 2# visual feature point; Determine whether the similarity corresponding to 2# visual feature point is less than the threshold: If yes, add the sequence number of the current frame, the layer corresponding to the 2# visual feature point, the pixel coordinates and the descriptor to the features of the visual map point m, and then process the next visual map point; Otherwise, directly proceed to the next visual map point; Traversing all visual map points in the current visual map within the FoV range of the current visual frame, that is, completing the second update of the visual map point features in the current visual map.
7. The method for constructing a high-precision map according to claim 1, 2 or 3, characterized in that: In step 4, the remaining visual feature points after the frame-map matching in step 3 are retained, specifically: For any layer of the current visual frame, obtain the difference δn between the current visual map point of the layer and the preset value; Calculate the grayscale differences between all remaining visual feature points and the surrounding visual feature points after frame-map matching in step 3, and select δn visual feature points with the largest grayscale differences to retain.
8. The method for constructing a high-precision map according to claim 1, 2 or 3, characterized in that: In step 4, the creation of new visual map points based on the retained visual feature points is specifically as follows: Define the retained visual feature point as 3# visual feature point, and use the point cloud near the current position in the high-precision map as the local point cloud map of the current frame; Projecting the local point cloud map onto each layer of the current visual frame to construct a depth map pyramid; For any 3# visual feature point, select the depth value corresponding to the pixel coordinates with depth value closest to the pixel coordinates of the 3# visual feature point in the corresponding layer of the depth map pyramid as the depth value of the 3# visual feature point; Based on the depth value of the 3# visual feature point, the 3D coordinates of the 3# visual feature point are obtained, a new visual map point is created, and the current frame number and the 3D coordinates, layer, descriptor, and pixel coordinates of the 3# visual feature point are added to the visual map as features of the newly created visual map point; Traversing all 3# visual feature points, the third update of the visual map point features in the current visual map is completed.
9. The method for constructing a high-precision map according to claim 1, 2 or 3, characterized in that: Also includes: Step 6: Determine whether the current visual frame is a key frame: If yes, construct the word based on the descriptor of the current visual frame and the pixel coordinates of the visual feature points and add it to the bag of words, and then perform steps 1 to 6 after obtaining new image data; Otherwise, perform steps 1 to 6 after acquiring new image data.
10. A high-precision map construction device, characterized in that: A high-precision map is constructed by using the method described in any one of claims 1 to 9, wherein the high-precision map construction device comprises: A visual frame construction unit, used to obtain image data collected by the current frame and create the current visual frame; A frame-to-frame matching unit, used for performing frame-to-frame matching of visual features based on a current visual frame and a previous visual frame, and performing a first feature update on a visual map point in a current visual map; The feature extraction unit is used to extract a number of new visual feature points on each layer of the current visual frame. A frame-map matching unit, used for performing frame-map matching of visual features based on visual feature points extracted from the current visual frame and visual map points in the current visual map, and performing a second feature update on the visual map points in the current visual map; A visual map point creation unit, for retaining some of the visual feature points remaining after frame-map matching when the visual feature points on the layer of the current visual frame do not reach a preset value, so that the visual feature points on each layer of the current visual frame reach a preset value, and creating new visual map points based on the retained visual feature points; A coordinate optimization unit is used to optimize the 3D coordinates of the visual map points corresponding to all visual feature points on the current visual frame, and perform a third feature update on the visual map points in the current visual map; The key frame extraction unit is used to construct words from the key frame descriptors and the pixel coordinates of the visual feature points and add them to the bag of words.
