WO2022002039A1 - Visual positioning method and device based on visual map - Google Patents

Visual positioning method and device based on visual map Download PDF

Info

Publication number
WO2022002039A1
WO2022002039A1 PCT/CN2021/103073 CN2021103073W WO2022002039A1 WO 2022002039 A1 WO2022002039 A1 WO 2022002039A1 CN 2021103073 W CN2021103073 W CN 2021103073W WO 2022002039 A1 WO2022002039 A1 WO 2022002039A1
Authority
WO
WIPO (PCT)
Prior art keywords
positioning
current frame
frame
matching
current
Prior art date
Application number
PCT/CN2021/103073
Other languages
French (fr)
Chinese (zh)
Inventor
李建禹
易雨亭
龙学雄
Original Assignee
杭州海康机器人技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州海康机器人技术有限公司 filed Critical 杭州海康机器人技术有限公司
Publication of WO2022002039A1 publication Critical patent/WO2022002039A1/en

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C21/00Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00
    • G01C21/20Instruments for performing navigational calculations

Definitions

  • the present application relates to the field of visual navigation, and in particular, to a visual positioning method and device based on a visual map.
  • Visual navigation is to collect images of the surrounding environment through a camera device, and perform calculations based on the images to complete the position determination and path recognition of the mobile robot.
  • the constructed environment map Taking the map based on the ground texture as an example, when the mobile robot moves through a texture point, according to the feature registration of the current image and the map collected at the texture point, the pose of the current mobile robot can be calculated, and the ground texture-based method can be performed. positioning navigation.
  • the present application provides a visual localization method based on a visual map to improve the robustness of visual localization.
  • a visual positioning method based on a visual map provided by this application is implemented as follows:
  • feature point extraction is performed to obtain the feature points of the current frame
  • the feature points in the current frame are matched with the map points in the map to obtain the matching feature points
  • the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
  • a random sampling consensus algorithm is used to determine the best matching feature point set
  • the positioning The state is determined according to the positioning result of the previous frame and the current number of frames that have failed to locate continuously; the positioning state includes an uninitialized state, a successful positioning state, and a relocation state;
  • the positioning strategy includes initialization positioning in an uninitialized state, normal positioning in a successful positioning state, relocation in a relocation state, and conversion relationships between the positioning states;
  • the conversion relationship between the various positioning states includes:
  • the current positioning state is the uninitialized state
  • the initialization positioning if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
  • the current positioning status is the positioning successful status
  • the normal positioning if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
  • the relocation When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning success state. If the relocation fails, determine whether the number of consecutive failed positioning frames exceeds the set frame number threshold, or determine whether the current frame is different from the last positioning. Whether the distance between the successful poses exceeds the set first distance threshold, if it exceeds the set number of frames threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set number of frames threshold or the set first distance threshold, then keep the current positioning loss state;
  • the determining of the positioning strategy according to the current positioning state includes generating positioning logic according to each positioning state and the conversion relationship between the respective positioning states; wherein, the logical content of the positioning logic includes: executing the current frame indicated by the corresponding positioning strategy The positioning process, the corresponding positioning strategy is the positioning strategy under the current positioning state;
  • Matching the feature points in the current frame with the map points in the map based on the positioning strategy including, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determining the candidate map range in the map for the current frame , to match the feature points in the current frame with the map points in the candidate map range.
  • generating the positioning logic according to each positioning state and the conversion relationship between the respective positioning states including,
  • the current frame will be positioned normally
  • the current frame will be initialized and positioned.
  • the current frame is relocated.
  • initializing and positioning the current frame further comprising,
  • the current frame is the first frame, it is determined that the current positioning state is an uninitialized state,
  • the current frame positioning is recorded successfully, and the status is switched to the positioning success state. If the current frame positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
  • the current positioning status is the positioning successful status.
  • the current frame positioning is recorded successfully, and the current positioning success status is maintained; if the current frame positioning fails, the current frame positioning failure is recorded, and the status is switched to the positioning loss state;
  • the current frame is initialized and positioned, further comprising,
  • the current continuous positioning failure frame number exceeds the frame number threshold, or the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, it is determined that the current positioning state is an uninitialized state,
  • the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
  • the current continuous positioning failure frame number does not exceed the frame number threshold or the distance between the current frame and the most recent successful positioning does not exceed the set first distance threshold, then the current frame is relocated, further comprising,
  • the current positioning state is a positioning loss state.
  • the current frame relocation If the current frame relocation is successful, record the current frame positioning success, and switch to the positioning success state; if the current frame relocation fails, record the current frame positioning failure, keep the current positioning loss state, and return to the judgment whether the current continuous positioning failure frame number is Exceeds the set number of frames threshold, or whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold.
  • the candidate map range in the map for the current frame including,
  • map points in the map are used as the first candidate map range, or the auxiliary information is used to obtain the first candidate map range; the map points within the first candidate map range are screened by brute force matching, If the feature matching degree of every two map points exceeds the set second matching threshold, then randomly delete one of the map points to obtain the revised first candidate map range;
  • the pose prediction is performed on the current frame according to the inter-frame motion information from the previous frame to the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the second frame in the map is determined. candidate map range;
  • the pose prediction is performed on the current frame to obtain the predicted pose of the current frame, including,
  • the first method Obtain the frame pose transformation from the previous frame to the current frame through the wheel odometer or inertial measurement element, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame. ;
  • the second method obtain the inter-frame pose transformation from the previous frame to the current frame through the visual odometry, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame;
  • the third method According to the historical frame for which the positioning result has been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame ;
  • the fourth method adopt at least two of the first method, the second method, and the third method to obtain the first predicted pose of the current frame respectively, and obtain at least two first predicted poses;
  • the Kalman filter is used to filter the at least two first predicted poses to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame; or, nonlinear optimization is used. method, optimize based on the at least two first predicted poses, obtain an optimized second predicted pose, and use the second predicted pose as the final predicted pose of the current frame;
  • the objective function of nonlinear optimization is the sum of various error terms obtained according to various methods, wherein, using a nonlinear optimization method to optimize based on the at least two first predicted poses, including: The pose, the first predicted pose of the current frame obtained in different ways, and the pose transformation between frames are used as initial values, and are substituted into the objective function of nonlinear optimization to solve the position when the objective function of nonlinear optimization achieves the minimum value. pose as the second predicted pose.
  • determining the second candidate map range in the map according to the predicted pose of the current frame including,
  • the first neighborhood of the center is determined as the second candidate map range
  • the second neighborhood of the center is determined as the third candidate map range
  • the range of the second neighborhood is greater than the range of the first neighborhood.
  • a random sampling consistency algorithm is used to determine the best matching feature point set, including,
  • the current pose is calculated, and the fitted pose estimation of the current matching feature point subset is obtained,
  • For each matching feature point in the matching feature point set according to the spatial position of the projected point of the matching feature point, determine whether the distance between the projected point of the matching feature point in the current frame and the map point matched by the matching feature point in the map is less than If the set second distance threshold is less than the set second distance threshold, then determine that the matching feature point is an inner point; repeatedly perform the described judgment of the projection point of the matching feature point in the current frame and the matching feature point in the map Whether the distance of the matched map points is less than the set second distance threshold, until all matching feature points in the current matching feature point set have been judged as interior points;
  • Described judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation including,
  • At least two or more best matching feature point sets are respectively given weights that measure the matching degree between the current frame and the candidate map range; the weights are based on the number of matching feature points in the best matching feature point set and the number of feature points extracted from the current frame. , the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set or any combination thereof is determined,
  • the set weight threshold and maximum weight it is judged whether the best matching feature point set satisfies the conditions for the current frame pose calculation.
  • the method further includes:
  • the non-linear optimization based on sliding window is used to calculate the pose of the current frame;
  • the optimized variable is the pose of each image frame in the sliding window, the sliding window includes the current frame, and
  • the optimization constraints are the feature points of the current frame and the previous key Inter-frame matching constraints between frame feature points, and/or map matching constraints between current frame feature points and map points in the map,
  • the inter-frame matching error and/or the map matching error are minimized, and the optimized pose of the current frame is obtained as the positioning result;
  • the map matching constraint is: the error between the pixel position of the first matching map point back-projected on the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, or, in the current frame
  • the first matching feature point is : the feature point in the current frame is matched with the map point in the map to obtain the successfully matched feature point
  • the first matching map point is: the map point successfully matched by the first matching feature point;
  • the inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, or, the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the pixel of the previous key frame error between positions;
  • the method After the current image is acquired and the current frame is obtained, feature point extraction is performed based on the current frame, and before the feature points of the current frame are obtained, the method includes performing image preprocessing on the current frame.
  • the least squares method is used to minimize the inter-frame matching error and/or the map matching error to obtain the optimized current frame pose, including,
  • the objective function for optimization is: a first result obtained by weighting the sum of map matching errors of all the first matching feature points of all frames in the current sliding window with the first weight, and , the second result obtained by weighting the sum of the inter-frame matching errors of all the second matching map points between all frames between each frame in the current sliding window and its previous key frame with the second weight, the accumulated information about the first the sum of the result and the second result;
  • map matching error initial value Take the map matching error obtained according to the pose of the current frame, the spatial position information of the first matching map point, the camera internal reference, and the pixel coordinates of the first matching feature point matching the first matching map point in the current frame, as the map matching error initial value
  • the iterative solution makes the pose of the current frame when the objective function used for optimization achieves the minimum value, and the optimized current pose is obtained;
  • the method further includes:
  • the current frame is a key frame: the number of the first matching feature points in the current frame is less than the first threshold, and the number of the second matching feature points in the current frame is less than the second threshold;
  • the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold. If the frame threshold is set, the earliest key frame added in the sliding window will be deleted. If the set first frame threshold is not reached, the earliest key frame added in the sliding window will not be deleted;
  • the performing image preprocessing on the current frame includes,
  • the current frame is de-distorted to obtain a de-distorted image
  • the foreground image is used as the current frame after image preprocessing. If it is not uniform, the foreground image is stretched to obtain the current frame after image preprocessing.
  • performing stretching processing on the foreground image includes:
  • the pixel value of the foreground image is less than or equal to the set minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range;
  • the pixel value of the foreground image is greater than the minimum gray value and less than the set maximum gray value, the pixel value that is proportional to the maximum value of the pixel is used as the pixel value of the foreground image; the ratio is the pixel value of the foreground image and the minimum value. The ratio of the difference between the gray values to the difference between the maximum gray value and the minimum gray value;
  • the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the range of pixel values;
  • feature point extraction is performed to obtain the feature points of the current frame, including,
  • the feature points in the grid are arranged in descending order according to the response value of the feature points, the first Q feature points are retained, and the filtered feature points are obtained; among them, Q is based on the feature points in the target image frame.
  • the number and the set upper limit of the total number of feature points, and the total number of grid feature points are determined;
  • Feature descriptors are calculated separately for each feature point after screening.
  • a visual positioning device based on a visual map provided by the application includes:
  • the image acquisition module collects the current image and obtains the current frame
  • the feature extraction module based on the current frame, performs feature point extraction to obtain the feature points of the current frame;
  • the positioning module determines the positioning strategy according to the current positioning state. Based on the positioning strategy, the feature points in the current frame are matched with the map points in the map to obtain matching feature points. When the matching feature points meet the requirements for the current frame pose calculation. When conditions are met, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
  • the present application also provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of any of the above-mentioned visual map-based visual positioning methods are implemented.
  • the present application also provides a mobile robot, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement any of the above-mentioned visual map-based visual positioning methods A step of.
  • the present application also provides a computer program product containing instructions, when the computer program product containing instructions is run on a computer, the computer program product can cause the computer to execute any of the above-mentioned steps of the visual map-based visual positioning method.
  • the present application also provides a computer program, which, when running on a computer, causes the computer to execute the steps of any of the above-mentioned visual map-based visual positioning methods.
  • the visual positioning method based on the visual map provided by the present application performs feature matching and pose calculation of the current frame according to the positioning strategy determined by the current positioning state, and does not need to set accurate calibration points; and, compared with the prior art , because different positioning strategies are used for positioning in different positioning states, so that positioning for various positioning states can be achieved, so it has better robustness to unmapped areas or when positioning fails; at the same time, Compared with the prior art positioning scheme of setting calibration points, only images passing through the calibration points can be positioned more accurately, and the positioning process of this scheme can continue to match with the map without significant jumps in the positioning results.
  • FIG. 1 is a schematic flowchart of visual positioning in this embodiment.
  • Figure 2 is a schematic diagram of feature point screening.
  • FIG. 3 is a schematic diagram of a transition relationship between positioning states.
  • FIG. 4 is a schematic diagram of positioning logic.
  • FIG. 5 is a schematic flow chart of initializing positioning.
  • FIG. 6 is a schematic diagram of map point screening.
  • FIG. 7 is a schematic flow chart of normal positioning.
  • FIG. 8 is a schematic flowchart of a relocation.
  • 9a and 9b are a schematic diagram of determining a candidate map range.
  • FIG. 10 is a schematic diagram of a visual positioning device based on a visual map of the present application.
  • FIG. 11 is a schematic diagram of an image preprocessing module.
  • FIG. 12 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in an image coordinate system.
  • FIG. 13 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in the world coordinate system.
  • the present application determines the positioning logic according to different positioning strategies adopted in different positioning states, so that the positioning state is converted when the positioning logic is satisfied, wherein the positioning strategies are different in the processing of pose prediction and feature matching, so that the overall positioning Robustness is increased.
  • the following description will be based on the visual positioning based on the visual map, wherein the visual map is a feature map that has been constructed in advance, and the map has map points with three-dimensional spatial information, that is, the world coordinates and descriptions of the feature points are stored in the map.
  • Sub-information that is, map points in the map can also be called feature points in the map
  • the descriptor information of any feature point is the information used to describe the image features of the feature point, which is used in the feature matching process, such as Color features, texture features, etc., wherein the descriptor information may also be called feature descriptors or descriptors.
  • the visual map is a texture map constructed based on the collected ground texture information, which can be a two-dimensional or three-dimensional point cloud map with feature descriptors, and the coverage of the texture map can be Continuous coverage can also be discrete coverage.
  • the following takes a 3D point cloud map as an example.
  • FIG. 1 is a schematic flowchart of the visual positioning in this embodiment. After loading the texture map, the mobile robot performs the following steps:
  • Step 101 collecting a current image to obtain a current frame
  • Step 102 Perform image preprocessing on the current frame to make the texture in the image prominent, including but not limited to one or more of optional processes such as image de-distortion, image filtering, and image enhancement.
  • This step 102 is an optional step based on image quality. For example, whether to add image preprocessing is determined according to whether the current frame is over-distorted and whether the texture is significant. It should be noted that if it is determined based on the image quality that the current frame does not need to be added to image preprocessing, after the current frame is collected, the feature points of the current frame can be directly extracted to obtain the feature points of the current frame. The process of extracting the feature points to obtain the feature points of the current frame is the same as the process of extracting the feature points of the preprocessed current frame.
  • Step 1021 perform de-distortion processing on the current frame according to the distortion coefficient of the camera, to obtain a de-distorted image I(u, v), where u and v represent pixel coordinates.
  • Step 1022 determine whether the pixel value of each pixel in the de-distorted image is greater than the set first pixel threshold, if it is greater than the set first pixel threshold, then perform an inversion operation on the pixel whose pixel value is greater than the first pixel threshold , then filter the de-distorted image after the inversion operation, if it is not greater than the set first pixel threshold, directly perform image filtering on the de-distorted image I (u, v) to obtain the background image I b (u , v).
  • the so-called inversion operation refers to: using 255 to subtract the original pixel value as the new image pixel value, the inverted image is compared with the original image, the black and white is reversed, the light and shade are reversed. on the contrary.
  • Step 1023 the image distortion spent subtracting the background image, foreground image to obtain I f (u, v), wherein, the foreground image equation is expressed as:
  • I f (u, v) I (u, v) -I b (u, v)
  • Step 1024 it is determined foreground image I f (u, v) whether or not the pixel value distribution, even if, then the foreground image as the current frame after pretreatment, if not uniform, the foreground image is stretched to obtain pre- the current frame after;
  • whether the pixel values of any image are evenly distributed can determine whether the pixel values of the image are distributed in the entire grayscale range, so as to prevent the contrast from being reduced due to the image being too dark or overexposed.
  • an image grayscale histogram is calculated, the number of pixels in each grayscale interval is counted, and if the pixel grayscale values are concentrated in a larger or smaller grayscale interval, the image is determined.
  • the pixel values of the image are not uniformly distributed; if there are pixel distributions in each grayscale interval, it is determined that the pixel values of the image are uniformly distributed.
  • stretching the foreground image may be:
  • the pixel value of the foreground image is the minimum value within the pixel value range, that is, the pixel value is 0; where the minimum gray value and the maximum gray value can be A preset gray value threshold; or, the minimum gray value may be the minimum value among the gray values of the foreground image pixels, and the maximum gray value may be the maximum value among the gray values of the foreground image pixels.
  • the ratio is: the ratio of the difference between the pixel value of the foreground image and the minimum gray value and the difference between the maximum gray value and the minimum gray value, that is, using the difference between the pixel value of the foreground image and the minimum gray value
  • the difference is divided by the difference between the maximum gray value and the minimum gray value to obtain the ratio.
  • the pixel value of the foreground image is the maximum value within the pixel value range, for example, the maximum value of the pixel is 255.
  • I min is the minimum gray value
  • I max is the maximum gray value.
  • the pixel value ranges from 0 to 255.
  • Step 103 Extract the image feature points in the preprocessed current frame, and calculate the descriptor based on the feature points to obtain the feature points and descriptors of the current frame, that is, extract the feature points in the preprocessed current frame, and based on the feature points
  • the point calculation is based on the descriptor of the feature point, so as to obtain the descriptor of the feature point of the current frame.
  • the descriptor form is the same as the descriptor form of the map point in the map.
  • features such as ORB (Oriented FAST and Rotated BRIEF), Scale Invariant Feature Transform (SIFT), SURF (Speeded Up Robust Features) and the like can be used.
  • ORB Oriented FAST and Rotated BRIEF
  • the feature point of the current frame is also the ORB feature point.
  • ORB is a feature point optimized based on FAST (Features from Accelerated Segment Test) feature point and BRIEF descriptor, which adds the calculation of FAST direction and the anti-rotation invariance of Brief.
  • the image feature points in the preprocessed current frame are extracted according to the manner of forming with the feature points of the constructed map.
  • ORB feature points may be used.
  • the collected ground texture images are usually scale-stable, multi-scale features do not need to be constructed to enhance the scale invariance of features, so the construction of pyramid images can be abandoned, and feature extraction based on the current frame image is equivalent to that based on the source image.
  • the pyramid image is also called an image pyramid, and the so-called image pyramid is a collection of images of different resolutions derived from the same image.
  • the extracted feature points can be screened.
  • Figure 2 is a schematic diagram of feature point screening.
  • the FAST feature is used as an example to introduce the feature point screening process. Specifically: after the FAST (Features from Accelerated Segment Test) feature is extracted, the current frame can be divided into a predetermined number of grids, and each grid is filtered. The Q feature points with the highest FAST response value are retained, and the screened feature points are obtained. Among them, Q is determined according to the number of feature points in one frame of target image, the upper limit of the total number of feature points set, and the total number of frame points in the grid, and the number of feature points retained by different grids is different.
  • FAST Features from Accelerated Segment Test
  • the determination of Q is expressed mathematically as:
  • the FAST response value refers to the score value extracted by the FAST corner point, that is, the score of the point becoming a FAST corner point, and the higher the score, the more significant the FAST feature is.
  • other types of feature points also have similar score values (response values), which are used to measure the significance of the point as a feature point.
  • FAST can be regarded as an algorithm for extracting corner points.
  • FAST corner points are defined as: if a pixel is significantly different from enough pixels in its surrounding neighborhood, the pixel may be a corner point; among them, the corner point is
  • the points with particularly prominent attributes in certain aspects are the isolated points with the largest or smallest intensity on some attributes, the end points of the line segments, etc., which play a very important role in the understanding and analysis of image graphics; While retaining the important features of image graphics, it can effectively reduce the amount of information data, make the information content very high, effectively improve the speed of calculation, and be conducive to the reliable matching of images, making real-time processing possible.
  • Step 104 in view of the fact that in the process of positioning, if the ground texture of the current position has not been mapped, or the ground texture has changed, then the current frame and the map point cannot be properly matched, and then there will be a frame positioning loss. Case. Therefore, in the positioning process, different positioning strategies are used for positioning in the current frame according to different current positioning states. which is:
  • the positioning state includes an uninitialized state, a successful positioning state, and a relocation state
  • the positioning strategies corresponding to each positioning state include: initialized positioning in an uninitialized state , the normal positioning in the successful positioning state, the relocation in the relocation state, and the transition relationship between the various states.
  • the relocation state may also be referred to as a location loss state.
  • FIG. 3 is a schematic diagram of a transition relationship between positioning states. in,
  • the current positioning state is the uninitialized state
  • the initialization positioning if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
  • the current positioning status is the positioning successful status
  • the normal positioning if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
  • the current positioning state is the positioning loss state
  • the relocation if the relocation is successful, it will switch to the positioning successful state. If the relocation fails, it is judged whether the number of frames of continuous positioning failure exceeds the set threshold of the number of frames, or whether the current frame and the last successful positioning are successful. Whether the distance between the poses exceeds the set first distance threshold, if it exceeds the set frame number threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set frame number threshold or the set first distance threshold, the current positioning loss state is maintained.
  • the current frame when using the current frame for positioning, if the current positioning state is uninitialized, the current frame will be initialized and positioned. If the initialization and positioning is successful, the current positioning state will be converted to the positioning successful state. If the initialization and positioning fails. , keep the current uninitialized state; if the current positioning state is the positioning successful state, the current frame will be positioned normally; if the normal positioning is successful, the current positioning successful state will be maintained; if the normal positioning fails, the current positioning state will be converted to the positioning lost state; If the current positioning state is the positioning loss state, the current frame will be relocated. If the relocation is successful, it will be converted to the positioning successful state.
  • the relocation fails, it will be judged whether the number of consecutive failed frames exceeds the set frame number threshold. Or, determine whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, and if it exceeds the set frame number threshold or the set first distance threshold, the current positioning state transitions to In the uninitialized state, if the set frame number threshold or the set first distance threshold is not exceeded, the current positioning loss state is maintained.
  • FIG. 4 is a schematic diagram of positioning logic, including,
  • Step 1041 determine whether the current frame is the first frame
  • the current frame is the first frame, it means that there is no positioning result of the previous frame, it is determined that the current positioning state is an uninitialized state, and initialization positioning is performed. Switch to the positioning success state. If the positioning fails, record the current frame positioning failure and keep the current uninitialized state; that is, if the current frame is the first frame, it is determined that the current positioning state is the uninitialized state, and the current frame is uninitialized. The initialization positioning in the state, and based on the positioning result of the current frame, according to the conversion relationship between the positioning states, the current positioning state is updated.
  • step 1042 If it is not the first frame, go to step 1042.
  • Step 1042 determine whether the positioning of the previous frame is successful
  • the positioning of the previous frame it is determined that the current positioning state is the successful positioning state, and normal positioning is performed. If the positioning is successful, that is, the matching in Figure 1 is successful, the current frame positioning is recorded successfully, and the current positioning successful state is maintained. If the positioning fails, Record the positioning failure of the current frame, and switch to the positioning loss state; that is, if the positioning of the previous frame is successful, the current positioning status is determined as the positioning successful state, and the normal positioning in the positioning successful state is performed for the current frame, and based on the current frame The positioning result, according to the conversion relationship between each positioning state, update the current positioning state;
  • step 1043 If the positioning of the previous frame fails, go to step 1043.
  • Step 1043 judging whether the current continuous positioning failure frame number exceeds the frame number threshold, or whether the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold;
  • the current positioning state is determined to be an uninitialized state, and initialization positioning is performed.
  • the positioning is successful, that is, the matching in Figure 1 is successful, record the current frame positioning success, and switch to the positioning success state; if the positioning fails, record the current frame positioning failure, and keep the current uninitialized state; that is, determine the current state as uninitialized In the initialization state, the initialization positioning in the uninitialized state is performed on the current frame, and based on the positioning results of the current frame, the current positioning state is updated according to the conversion relationship between the positioning states; if the current number of consecutive failed positioning frames does not exceed the frame number threshold, Or, if the distance between the current frame and the pose with the most recent successful positioning does not exceed the set first distance threshold, determine that the current state is a repositioning state, and execute the repositioning.
  • the positioning is successful, that is, the matching in Figure 1 is successful. Then record the current frame positioning success, and switch to the positioning success state. If the positioning fails, record the current frame positioning failure, keep the current positioning loss state, and return to step 1043; Relocation in the state of location loss is performed, and based on the location result of the current frame, the current location state is updated according to the conversion relationship between each location state.
  • Initial positioning is a positioning strategy performed when the first frame or the number of consecutive failed positioning frames exceeds the threshold. Since there is no positioning result of the previous frame at this time, accurate pose prediction cannot be performed.
  • the first candidate map range is usually obtained by searching map points in the global map or using auxiliary information, and comparing the feature points of the current frame with the map points in the global map or the first candidate map range. Map points are matched. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, so as to obtain the positioning result of the current frame.
  • all map points in the map can also be used as the first candidate map range, or the auxiliary information can be used to obtain the first candidate map range;
  • the points are screened by violent matching. If the feature matching degree of each two map points exceeds the set second matching threshold, one of the map points will be randomly deleted to obtain the revised first candidate map range; then, the current frame The feature points in are matched with the map points within the first candidate map range. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, so as to obtain the positioning result of the current frame.
  • the so-called brute force matching is: pairwise matching, that is, the possibility of each matching is calculated and screened.
  • Normal positioning is a positioning strategy performed when the positioning of the previous frame is successful.
  • the pose prediction of the current frame can be used to predict the pose of the current frame more accurately. Therefore, when performing feature matching, it can be determined according to the first neighborhood of the predicted pose.
  • the feature points of the current frame are matched with the map points in the second candidate map range. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, thereby obtaining the positioning result of the current frame.
  • Relocation is a positioning strategy performed when the previous frame positioning is lost.
  • the last frame that is not lost and the current frame is used as a reference frame, and the pose of the current frame is predicted according to the reference frame.
  • the frame closest to the current frame is used as the reference frame.
  • the pose prediction of the current frame is performed to obtain the predicted pose of the current frame.
  • the third candidate map range is determined according to the second neighborhood of the predicted pose, and the feature points of the current frame and the map points in the third candidate map range are matched by the method of brute force matching. Guaranteed robustness of relocation, of course, is not limited to brute force matching. If the relocation matching is successful, the pose of the current frame is calculated according to the matching feature points to obtain the positioning result of the current frame.
  • the range of the first neighborhood is smaller than the range of the second neighborhood.
  • the pose of the current frame is the pose of the mobile robot that collected the current frame
  • the positioning result of the current frame is the current positioning result of the mobile robot.
  • the pose of the mobile robot includes a position and an attitude.
  • pose prediction and feature matching can be used as: There are two steps in the process of matching the feature points in the frame with the map points in the map to obtain the matching feature points.
  • the initialization positioning only includes the processing flow of feature matching and pose calculation.
  • the feature matching method is different from the feature matching method in normal positioning and relocation.
  • the feature matching is as follows: the feature points in the current frame are compared with the map. It is a link in the process of matching the map points in to obtain the matching feature points.
  • the three positioning methods of initial positioning, normal positioning and repositioning are different matching methods; and when matching When the feature points meet the conditions for the pose calculation of the current frame, in the three positioning modes of initial positioning, normal positioning and repositioning, the pose of the current frame is calculated according to the matching feature points, and the specific implementation process of obtaining the positioning result can be the same.
  • step 105 performing graph optimization on the pose of the current frame that has been successfully positioned, so as to optimize the positioning result and improve the accuracy of the positioning.
  • the so-called graph optimization can also be called pose graph optimization, which is used to optimize the positioning results.
  • the purpose of positioning optimization is to make the output positioning results more accurate and smooth, and improve the accuracy and robustness of the entire system.
  • the positioning optimization adopts a nonlinear optimization based on a sliding window, the optimized variable is the pose of each image frame in the sliding window, the current frame is added to the sliding window, and the optimization constraints are the inter-frame matching constraints, and /or map matching constraints, using the LM method (least square method) to minimize the inter-frame matching error and/or map projection error to obtain the optimized pose of the current frame.
  • the map projection error is also called map matching error, and the error obtained by the map matching constraint is the map matching error, and the error obtained by the inter-frame matching constraint is the inter-frame matching error.
  • the map matching constraint is: the error between the pixel position of the first matching map point back-projected to the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, that is, two pixel positions
  • the two pixel positions are respectively: the pixel position of the first matching map point back-projected on the current frame, and the pixel position of the first matching feature point matching the map point in the current frame; or, the current
  • the two spatial positions are: the spatial position where the first matching feature point in the current frame is projected to the world coordinate system, and the first matching map point matched by the first matching feature point is in the world coordinate system.
  • the spatial position of the first matching feature point is: the feature point in the current frame is matched with the map point in the map to obtain a successful matching feature point;
  • the first matching map point is: the first matching feature point is successfully matched the map point;
  • the inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world
  • the error between the spatial positions in the coordinate system, that is, the error between two spatial positions, the two spatial positions are respectively: the spatial position where the first matching feature point in the current frame is projected to the world coordinate system, and the current In the previous key frame of the frame, the second matching feature point that matches the first matching feature point is projected to the spatial position in the world coordinate system; or, the second matching map point that matches the second matching feature point is back-projected to the current
  • the error between the pixel position of the frame and the pixel position of the second matching map point back-projected to the previous key frame, that is, the error between two pixel positions, the two pixel positions are: and the second matching feature point
  • the matched second matching map point is back-projected to the pixel position of the current frame, and the second matching map point is
  • the previous keyframe is the keyframe that is closest to the collection time of the current frame among the set keyframes.
  • FIG. 12 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame.
  • the second matching feature point is a subset of the first matching feature point set
  • the second matching map point matching the second matching feature point is: a subset of the first matching map point set matching with the first matching feature point .
  • the error between the pixel position of the first matching map point back-projected to the current frame and the pixel position of the first matching feature point matched by the first map point constitutes a map matching constraint
  • the second matching map point is back-projected to the current frame.
  • the error between the pixel position and the pixel position of the last key frame of the back-projected current frame of the second matching map point constitutes an inter-frame matching constraint.
  • map matching constraints and the inter-frame matching constraints described in the embodiments of the present application are determined in the image coordinate system, the map matching constraints and the inter-frame matching constraints can also be determined in the world coordinate system.
  • FIG. 13 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in the world coordinate system.
  • the error between the spatial position of the first matching feature point in the current frame projected to the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system constitutes a map matching constraint , that is, the error between two spatial positions constitutes a map matching constraint
  • the two spatial positions are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system, and the first matching feature point matches The spatial position of the first matching map point in the world coordinate system; the spatial position of the first matching feature point in the current frame projected to the world coordinate system matches the first matching feature point in the previous key frame of the current frame.
  • the error between the second matching feature point projected to the spatial position in the world coordinate system constitutes the inter-frame matching constraint, that is, the error between the two spatial positions constitutes the inter-frame matching constraint, and the two spatial positions are: the current frame
  • the first matching feature point in is projected to the spatial position in the world coordinate system
  • the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the spatial position in the world coordinate system.
  • the spatial position of the matching feature point projected into the world coordinate system is obtained according to the camera model, according to the camera internal parameters, the pixel position of the matching feature point, and the pose of the frame where the matching feature point is located.
  • the first matching feature point is a feature point in the best matching feature point set.
  • the map matching constraint is: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the first matching map point matching the first matching feature point is in the world.
  • the error between the spatial positions in the coordinate system, the inter-frame matching constraints are: the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the previous The error between the pixel positions of the keyframes, correspondingly,
  • the inter-frame matching error and/or map matching error is minimized, and the optimized current frame pose is obtained, including constructing an objective function for optimization.
  • the objective function for optimization is: taking the current sliding window The first result obtained by the sum of the map matching errors of all the first matching feature points of all the frames in the current sliding window, and/or the inter-frame matching of all the second matching map points of all the frames in the current sliding window and its previous key frame
  • the second result obtained by the sum of errors; that is, the objective function used for optimization can be: the first result obtained by the sum of the map matching errors of all the first matching feature points of all frames in the current sliding window , it can also be: the second result obtained by the sum of the inter-frame matching errors of all the frames in the current sliding window and all the second matching map points of the previous key frame, or can also be: the above-mentioned first result and the second result sum of results.
  • the map matching errors of all the first matching feature points in any frame are: The error between the spatial positions of the first matching map points in the point matching in the world coordinate system; and based on the above inter-frame matching constraints, it can be known that any frame is matched with all the second matching map points of the previous key frame.
  • the error is: the error between the back-projection of the second matching map point matching the second matching feature point to the pixel position of the frame and the back-projection of the second matching map point to the pixel position of the previous key frame, where, here
  • the second matching feature point of is the feature point matching the first matching feature point of the frame in the previous key frame of the frame.
  • e ik-map is the map matching error between the pixel position of the first matching map point k back-projected on the current frame i and the pixel position of the first matching feature point k that matches the map point in the current frame i;
  • p ik is the pixel coordinate of the first matching feature point k in the current frame i
  • K is the camera internal parameter matrix,
  • X k is the three-dimensional coordinate of the first matching map point k in the map, R i and t i are obtained through the first matching feature point the pose of the current frame i.
  • e ijm-frame is the back-projection error of the second matching map point m between the current frame i and the previous key frame j, that is, the matching error between frames
  • X m is the second matching feature in the current frame i and the previous key frame j
  • R i, t i is the current pose frame i
  • R j, t j is the pose of the previous key frame j
  • I is the total number of frames in the sliding window
  • K is the total number of first matching feature points in the current frame
  • j is the previous key frame of each frame in the sliding window
  • M is the total number of second matching map points back projected in the current frame .
  • the iterative solution makes the current frame pose when the objective function obtains the minimum value, and the pose is taken as the current positioning result.
  • the objective function for optimization is: weighted with the first weight.
  • the first result obtained by the sum of the map matching errors of all the first matching feature points of all frames in the current sliding window, and the second weighted weighting of all the second key frames between each frame in the current sliding window and its previous key frame
  • the objective function used for optimization is mathematically expressed as:
  • ⁇ 1 and ⁇ 2 are weights.
  • the pose of all frames in the constraint frame can also be used as a variable to be optimized for optimization.
  • the current sliding window is optimized, that is, whether the current frame can be used as a key frame and whether it can exist in the sliding window is identified, so as to further improve the accuracy of positioning, that is, to improve the accuracy of subsequent positioning using image frames.
  • the current frame is determined as a key frame when one of the following conditions is met: the number of first matching feature points in the current frame is less than the first threshold, or the number of second matching feature points in the current frame is less than the second threshold.
  • the current frame is deleted in the sliding window. If the current frame is a non-key frame, the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold, and if it reaches the first frame threshold , the earliest added keyframe in the sliding window is deleted, and if the first frame threshold is not reached, the earliest added keyframe in the sliding window is not deleted.
  • step 104 Each positioning strategy involved in step 104 will be described below.
  • FIG. 5 is a schematic flowchart of initializing positioning. After image preprocessing and feature point extraction of the current frame, the initial positioning includes,
  • Step 501 Match the feature points of the current frame with the map points in the map.
  • a first matching feature point is obtained, and the obtained first matching feature point constitutes a first matching feature point set; in this way, for the first matching feature point set;
  • the spatial position information of the first matching map point matched with the first matching feature point is determined as the spatial position information of the first matching feature point, so as to obtain the two-dimensional feature point of the current frame and the three-dimensional feature point in the map. matching of feature points.
  • the matching can be performed as follows: for any feature point of the current frame, calculate whether the matching degree between the feature point in the current frame and the map point descriptor in the map is less than the set first matching threshold, if it is less than the set first matching threshold.
  • the determined first matching threshold is determined to match, and if it is not less than the set first matching threshold, it is determined to be mismatched; wherein, the matching degree can be described by the Hamming distance, and the matching threshold is the Hamming distance threshold;
  • the map points in the map can be all map points in the map, and then the brute force matching method is used for matching, that is, the possibility of each matching is calculated when pairwise matching is performed;
  • the auxiliary information is used to obtain the candidate map range, that is, the above-mentioned first candidate map range, and the feature points in the current frame are matched with the map points in the first candidate map range, for example , and set easily identifiable positions as candidate map ranges, such as the starting and ending positions of paths, turning positions, and crossing positions.
  • the auxiliary information can be position information of easily identifiable positions.
  • FIG. 6 is a schematic diagram of map point screening, wherein the dotted circles are map points removed by screening, and the solid circles are candidate map positions.
  • Step 501 is repeated until all feature points of the current frame are matched.
  • Step 502 in view of the fact that there may be some mismatched points when only the descriptors of the feature points are used to match the feature points, preferably, a certain method can be used to screen the best first matching feature points to improve the accuracy of matching the feature points. , thereby improving the accuracy of the pose of the current frame. Therefore, in this step 502, based on the first matching feature point, a random sampling consistency (RANSAC) algorithm can be used to determine the best matching feature point set, which specifically includes:
  • Step 5021 from the first matching feature point set obtained in step 501, randomly select the matching feature points for calculating the pose estimation of the current frame, and obtain the current matching feature point subset;
  • Step 5022 based on the mapping of the spatial position information and the pixel position information established by the matching feature points in the current matching feature point subset, calculate the current pose, thereby obtaining the fitting pose estimation of the matching feature point subset; that is, Calculate the current position based on the mapping, which is a mapping between the spatial position information and the pixel position information established by using the matching feature points in the current matching feature point subset; and, the calculated current pose can be used as the matching feature point subset. Fitting pose estimation;
  • calculating the current pose includes but is not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iterative 2D-ICP (2D-2D), 3-dimensional nearest neighbor iterative 3D-ICP (3D-3D), the homography matrix H(2D-2D).
  • the product of the homography matrix and the spatial position coordinate matrix corresponds to the pixel coordinate matrix, which is expressed mathematically as:
  • the degree of freedom of the homography matrix is 8, and the value of each element in the homography matrix can be obtained through the correspondence between the spatial positions of the four first matching feature points and the pixel positions.
  • singular value (SVD) decomposition By performing singular value (SVD) decomposition on the homography matrix, the corresponding rotation matrix R and translation vector t can be obtained, and the fitted pose estimation can be obtained.
  • Step 5023 since the fitting pose estimation is obtained from the matching feature points in the subset, in order to consider whether other matching feature points in the first matching feature set also conform to the currently calculated fitted pose estimation, it is necessary to calculate the point rate.
  • the spatial positions of all feature points in the current frame are obtained according to the fitted pose estimation and the camera internal parameters, and the spatial positions of the projection points of all the feature points are obtained.
  • two-dimensional pixel coordinate points can be mapped to three-dimensional coordinate points.
  • this mapping is called projection; otherwise, from three-dimensional coordinate points to two-dimensional coordinate points, this mapping is called inverse projection. That is, the spatial position of the feature point refers to the spatial position of the projection point of the feature point.
  • the feature point itself exists in the image coordinate system, and the spatial position of the projection point can be obtained by projection.
  • Projection points exist in the world coordinate system.
  • step 5023 all the first matching feature points in the current frame are projected to three-dimensional spatial positions, that is, projected into a map, as the spatial positions of the projected points. Therefore, for any first matching feature point i in the current frame, its three-dimensional space coordinates can be obtained.
  • p i is the pixel coordinate of the first matching feature point i in the current frame
  • R and t are the current fitting pose estimation
  • X i is the three-dimensional space coordinate of the first matching feature point i projected to the map, that is, the projection point Three-dimensional space coordinates
  • K is the camera internal parameter matrix.
  • Step 5024 for each first matching feature point in the first matching feature point set, determine whether the distance between the projection point of the first matching feature point in the current frame and the map point matched by the first matching feature point in the map is less than If the set second distance threshold is smaller than the set second distance threshold, it is determined that the first matching feature point is an inner point, wherein, in the judgment process, the spatial position of the projection point of the first matching feature point can be to judge.
  • Step 5024 is repeatedly performed until all the first matching feature points are determined whether they are interior points.
  • Step 5025 Count the number of current inliers, and use the ratio of the current number of inliers to the number of first matching feature points as the inlier rate; the larger the ratio, the higher the inlier rate, which means the higher the degree of fitting, the better the fitting pose. The better the estimation, the better the randomly selected matching feature points.
  • Step 5026 determine whether the number of inliers currently counted is the largest in the previous iterations, if it is the largest in the previous iterations, then take the set formed by the current inliers as the current best matching feature point set, and then execute step 5027, if is not the largest in previous iterations, the current best matching feature point set is not updated, but step 5027 is directly executed,
  • Step 5027 determine whether the end condition is reached, if the end condition is met, then execute step 503, if the end condition is not met, return to step 5021, so as to randomly select a subset of matching feature points for fitting pose estimation, so as to carry out the fitting method.
  • the cycle of the pose estimation to the best matching feature point set confirmation that is, the cycle of executing S5021-S5027;
  • the end condition includes at least one of the following conditions:
  • the number of iterations satisfies the preset conditions; in order to make at least one random selection during the iterative loop process under the condition of confidence ⁇ , so that the selected m points are all interior points, which is beneficial to the process of the loop. , the best value of the fitted pose estimate can be obtained at least once. Therefore, the number of iterations ⁇ should satisfy the following conditions:
  • m is the size of the subset, that is, the number of matching feature points in the subset; the confidence level is generally set in the range of 0.95 to 0.99.
  • is the interior point rate. In general, ⁇ is usually unknown, so the proportion of interior points under the worst condition can be taken, or the proportion under the worst condition can be set in the initial state, and then with the number of iterations, the Update to the current maximum inlier rate.
  • represents the expectation of the number of times that "the subsets are all interior points" in the i rounds.
  • Step 503 judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation
  • the pose calculation of the current frame is performed, and the calculation of the current pose includes but is not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iteration 2D-ICP(2D-2D), 3D nearest neighbor iterative 3D-ICP(3D-3D), homography matrix H(2D-2D);
  • the current frame positioning fails. It should be noted that in the case of not using the best matching feature point set, that is, based on the positioning strategy, the feature points in the current frame are matched with the map points in the map, and after the matching feature points are obtained, you can directly Determine whether the matching feature points meet the conditions for the current frame pose calculation, and when the judgment result is yes, calculate the pose of the current frame according to the matching feature points, and obtain the positioning result, wherein the current frame is calculated according to the matching feature points.
  • the methods of pose include but are not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iterative 2D-ICP (2D-2D), 3-dimensional nearest neighbor iterative 3D-ICP (3D-3D) ), the homography matrix H(2D-2D).
  • one of the embodiments in view of the different pose calculation methods required by different pose calculation conditions are different, taking the homography matrix H(2D-2D) as an example, to solve the pose at least There are 4 matching feature points, therefore, it is judged whether the number of matching feature points in the best matching feature point set satisfies the conditions for pose calculation.
  • each best matching feature point set is given a weight to measure the matching degree between the current frame and the candidate map range; the weight can also be based on the current frame.
  • the set weight threshold and maximum weight determine the unique best matching feature point set, so as to determine that the best matching feature point set meets the conditions for pose calculation; for example, adopt the weight threshold and the unique maximum weight Combined, that is, filter out the best matching feature point set whose weight is greater than the weight threshold, and select the unique best matching feature point set from the best matching feature point set according to the principle that the difference between the largest weight and the next largest weight is the largest.
  • the best matching feature point set determine the unique best matching feature point set, so as to determine that the best matching feature point set meets the conditions for pose calculation; for example, adopt the weight threshold and the unique maximum weight Combined, that is, filter out the best matching feature point set whose weight is greater than the weight threshold, and select the unique best matching feature point set from the best matching feature point set according to the principle that the difference between the largest weight and the next largest weight is the largest.
  • FIG. 7 is a schematic flow chart of normal positioning. After image preprocessing and feature point extraction of the current frame, normal positioning includes,
  • Step 701 in view of the fact that the positioning result of the previous frame has been obtained, according to the inter-frame motion information from the previous frame to the current frame, perform pose prediction on the current frame to obtain the predicted pose, so as to use the predicted pose to determine the second candidate. map range, thereby improving the efficiency of matching;
  • Pose prediction methods include,
  • Embodiment 1 Obtain the inter-frame pose transformation from the previous frame to the current frame through a wheeled odometer or an inertial measurement unit (IMU), and obtain the current frame based on the positioning result of the previous frame and the inter-frame pose transformation. Predict the pose.
  • a wheeled odometer or an inertial measurement unit IMU
  • the inter-frame pose transformation from the previous frame to the current frame is obtained through visual odometry (VO), and the predicted pose of the current frame is obtained based on the positioning result of the previous frame and the inter-frame pose transformation.
  • VO visual odometry
  • This implementation requires only image information, no additional inertial information.
  • Embodiment 3 According to several historical frames for which positioning results have been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted position of the current frame based on the positioning results of the previous frame and the inter-frame pose transformation. posture. This implementation does not rely on any information about the current frame.
  • Embodiment 4 at least two of Embodiments 1 to 3 are used to obtain the first predicted poses of the current frame respectively, and at least two first predicted poses are obtained; Kalman filter is used to analyze the at least two first predicted poses. A predicted pose is filtered to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame, or, a nonlinear optimization method is used, based on the at least two first predicted poses The pose is optimized to obtain the optimized second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame;
  • the objective function of nonlinear optimization is constructed according to the various error terms obtained in various embodiments, and the mathematical expression is:
  • e ijs represents the error term when the implementation s is adopted
  • T i represents the pose of the previous frame i, that is, the positioning result of the previous frame i
  • T j represents the first predicted pose of the current frame j
  • ⁇ T ij represents the inter-frame position between the previous frame i and the current frame j Pose transformation
  • ⁇ j is the Lie algebra representation of the predicted pose of the current frame
  • S is the total number of implementations adopted.
  • the pose T i of the previous frame i, the first predicted pose T j of the current frame j obtained by different implementations, and the inter-frame pose transformation ⁇ T ij are substituted into the objective function as initial values, and the solution makes the objective function obtain the minimum value. posture at the time.
  • Step 702 according to the predicted pose of the current frame, determine the second candidate map range, match the feature points in the current frame with the map points in the second candidate map range, when the matching is successful, obtain the third matching feature point, Then perform step 703,
  • one embodiment is, as shown in FIG. 9a, taking the map position determined by the predicted pose of the current frame as the center, and determining the first neighborhood of the center as the second candidate map range; matching
  • the method can use brute force matching, that is, violently calculate the descriptor distance between all feature points in the current frame and the feature points in the candidate map range, and select the feature point with the smallest descriptor distance as the matching feature point. This method is suitable for use when the confidence of the predicted pose is low or the number of feature points to be matched is small.
  • the second candidate map range of the feature point is determined, that is, according to the predicted pose of the current frame. and the pixel coordinates of the feature point, calculate the projection point position of the feature point projected into the map, and take the first neighborhood of the projection point as the center as the second candidate map range of the feature point, calculate the current frame feature point and the first
  • the calculation formula used to calculate the position of the projection point projected from the feature point to the map may be the formula about p i shown in the relevant description of step 5023 expression.
  • the first neighborhood may be a map area covered by a set radius with the center as the center.
  • Step 702 is repeated until all feature points of the current frame are matched.
  • Step 703 based on the third matching feature point, adopt the random sampling consistency algorithm to determine the best matching feature point set, this step 703 is the same as step 502,
  • Step 704 determine whether the number of matching feature points in the best matching feature point set satisfies the conditions for the current frame pose calculation, if the conditions for the current frame pose calculation are met, then perform the current frame pose calculation , if the conditions for the current frame pose calculation are not met, it is determined that the current frame positioning fails.
  • This step 703 is the same as step 503 .
  • FIG. 8 is a schematic flowchart of a relocation. After image preprocessing and feature point extraction of the current frame, relocation includes,
  • Step 801 since the positioning of the previous frame fails, according to the historical frame of the successful positioning, trace the latest frame in the historical frame as a reference frame, and perform pose prediction on the current frame according to the inter-frame motion information from the reference frame to the current frame, and obtain: Predicting the pose, so as to use the predicted pose to determine the third candidate map range, thereby improving the efficiency of matching;
  • the pose prediction method is the same as the pose prediction method in step 701, and only the reference frame needs to be regarded as the previous frame.
  • Step 802 according to the predicted pose of the current frame, determine the third candidate map range, match the feature points in the current frame with the map points in the third candidate map range, when the matching is successful, obtain the fourth matching feature point, Then step 803 is executed,
  • an implementation manner is to take the map position determined by the predicted pose of the current frame as the center, and determine the second neighborhood of the center as the third candidate map range; the matching method can be brute force matching. , to improve the robustness of relocation.
  • the third candidate map range of the feature point is determined according to the projection range of the feature point, that is, according to the predicted pose of the current frame and the pixels of the feature point Coordinates, calculate the position of the projection point projected from the feature point of the current frame to the map, the second neighborhood centered on the position of the projection point is used as the third candidate map range of the feature point, and calculate the feature point of the current frame and the third candidate map range In the matching of map points within, the feature point pair with the smallest descriptor distance is selected as the matching feature point.
  • the second neighborhood may be a map range covered by a set radius with the center as the center.
  • Step 802 is repeated until all feature points of the current frame are matched.
  • Step 803 based on the fourth matching feature point, adopt the random sampling consistency algorithm to determine the best matching feature point set, this step 803 is the same as step 502,
  • Step 804 determine whether the number of matching feature points in the best matching feature point set satisfies the conditions for pose calculation, if it meets the conditions for pose calculation, then perform the pose calculation of the current frame, if not The condition used for pose calculation, it is determined that the current frame positioning fails.
  • the LM optimization method is used to solve the problem.
  • the visual positioning method provided in this embodiment does not need to transform the ground for positioning using texture maps, and can use natural textures for positioning, and the cost is low;
  • the positioning logic determined by the positioning strategy enhances the adaptability in the case of local texture changes or lack of local textures. Whether it is a texture map or a non-textured visual map, there is no need to pre-set accurate calibration points, image acquisition is easy, and positioning During the process, it can continue to match with the map without large jumps. In some areas where the map is built, it can be located on any path, not limited to the path of the map, which improves the robustness of the positioning process; different Different positioning strategies in pose prediction and feature matching processing not only improve the accuracy of positioning, but also help to improve the efficiency of positioning.
  • FIG. 10 is a schematic diagram of a visual positioning device based on a visual map of the present application.
  • the device includes,
  • the image acquisition module 1001 collects the current image to obtain the current frame
  • the feature extraction module 100 based on the current frame, performs feature point extraction to obtain the feature points of the current frame;
  • the positioning module 1003 determines a positioning strategy according to the current positioning state; based on the positioning strategy, a candidate map range in the map is determined for the current frame, and the feature points in the current frame are matched with the map points within the candidate range to obtain matching feature points.
  • the matching feature points meet the conditions for solving the pose of the current frame, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
  • the positioning module 1003 includes:
  • the positioning state sub-module 1004 determines the current positioning state according to the positioning result of the previous frame and the current number of frames with continuous positioning failures,
  • the positioning strategy sub-module 1005 determines a positioning strategy according to the current positioning state, and the positioning strategy includes: initialization positioning in an uninitialized state, normal positioning in a successful positioning state, relocation in a relocation state, and between each positioning state conversion relationship;
  • the positioning logic sub-module 1006 generates positioning logic according to each positioning state and the conversion relationship between each positioning state; wherein, the logical content of the positioning logic includes: performing the positioning process indicated by the corresponding positioning strategy on the current frame, the The corresponding positioning strategy is the positioning strategy in the current positioning state;
  • Matching and positioning sub-module 1007 based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determine the candidate map range in the map for the current frame, and match the feature points in the current frame with the map points within the candidate range , obtain the matching feature points, and calculate the pose of the current frame according to the matching feature points;
  • the pose graph optimization sub-module 1008 performs graph optimization on the pose of the current frame.
  • the positioning module 1003 is further configured to, after obtaining the matching feature points, use a random sampling consistency algorithm to determine the best matching feature point set based on the matching feature points, and determine whether the best matching feature point set satisfies the requirements for The conditions for the current frame pose calculation, when the best matching feature point set does not meet the conditions for the current frame pose calculation, it is determined that the current frame positioning fails.
  • the conversion relationship between the various positioning states includes:
  • the current positioning state is the uninitialized state
  • the initialization positioning if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
  • the current positioning status is the positioning successful status
  • the normal positioning if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
  • the relocation When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning success state. If the relocation fails, determine whether the number of frames of continuous positioning failure exceeds the set threshold of the number of frames, or determine whether the current frame is different from the most recent positioning. Whether the distance between the successful poses exceeds the set first distance threshold, if it exceeds the set number of frames threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set number of frames threshold or the set first distance threshold, the current position loss state is maintained.
  • the matching and positioning sub-module 1007 includes:
  • the candidate map determination unit 1009 determines the candidate map range in the map for the current frame according to the positioning process indicated by the positioning strategy in each state,
  • the feature matching unit 1010 matches the feature points in the current frame with the map points in the candidate area,
  • the pose calculation unit 1011 calculates the pose of the current frame according to the matching feature points.
  • the positioning logic sub-module 1006 is specifically used for:
  • the current frame will be positioned normally
  • the current frame will be initialized and positioned.
  • the current frame is relocated.
  • the positioning logic sub-module 1006 is further configured to determine that the current positioning state is an uninitialized state according to the current frame being the first frame before initializing and positioning the current frame if the current frame is the first frame,
  • the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
  • the positioning logic sub-module 1006 is also used to determine that the current positioning state is a positioning success state according to the successful positioning of the previous frame before performing normal positioning on the current frame if the positioning of the previous frame is successful, and if the current frame is successfully positioned normally, Then record the current frame positioning success, keep the current positioning successful state, if the current frame fails to locate normally, record the current frame positioning failure, and switch to the positioning loss state;
  • the positioning logic sub-module 1006 is also used for:
  • the current continuous positioning failure frame number exceeds the frame number threshold, or the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, it is determined that the current positioning state is an uninitialized state,
  • the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
  • the positioning logic sub-module 1006 is also used for:
  • the current frame is relocated. If the current frame number of consecutive positioning failures does not exceed the frame number threshold or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, the current frame is relocated.
  • the current positioning state is a positioning loss state
  • the current frame relocation If the current frame relocation is successful, record the current frame positioning success, and switch to the positioning success state; if the current frame relocation fails, record the current frame positioning failure, keep the current positioning loss state, and return to the judgment whether the current continuous positioning failure frame number is Exceeds the set number of frames threshold, or whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold.
  • the matching and positioning sub-module 1007 is specifically used for:
  • map points in the map are used as the first candidate map range, or the auxiliary information is used to obtain the first candidate map range; the map points within the first candidate map range are screened by brute force matching, If the feature matching degree of every two map points exceeds the set second matching threshold, then randomly delete one of the map points to obtain the revised first candidate map range;
  • the pose prediction is performed on the current frame according to the inter-frame motion information from the previous frame to the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the second frame in the map is determined. candidate map range;
  • the matching positioning sub-module 1007 performs pose prediction on the current frame according to the inter-frame motion information from the previous frame to the current frame, and obtains the predicted pose of the current frame, including:
  • the first method Obtain the frame pose transformation from the previous frame to the current frame through the wheel odometer or inertial measurement element, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame. ;or
  • the second method obtain the inter-frame pose transformation from the previous frame to the current frame through the visual odometry, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame; or
  • the third method According to the historical frame for which the positioning result has been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame ;or,
  • the fourth method adopt at least two of the first method, the second method, and the third method to obtain the first predicted pose of the current frame respectively, and obtain at least two first predicted poses;
  • the Kalman filter is used to filter the at least two first predicted poses to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame; or, nonlinear optimization is used. method, optimize based on the at least two first predicted poses, obtain an optimized second predicted pose, and use the second predicted pose as the final predicted pose of the current frame;
  • the objective function of nonlinear optimization is the sum of various error terms obtained according to various methods, wherein, using a nonlinear optimization method to optimize based on the at least two first predicted poses, including: The pose, the first predicted pose of the current frame obtained in different ways, and the pose transformation between frames are used as initial values, and are substituted into the objective function of nonlinear optimization to solve the position when the objective function of nonlinear optimization achieves the minimum value. pose as the second predicted pose.
  • the matching and positioning sub-module 1007 is specifically used for:
  • the first neighborhood of the center is determined as the second candidate map range
  • the second neighborhood of the center is determined as the third candidate map range
  • the range of the second neighborhood is greater than the range of the first neighborhood.
  • the positioning module 1003 is specifically used for:
  • the current pose is calculated, and the fitted pose estimation of the current matching feature point subset is obtained,
  • For each matching feature point in the matching feature point set according to the spatial position of the projected point of the matching feature point, determine whether the distance between the projected point of the matching feature point in the current frame and the map point matched by the matching feature point in the map is less than If the set second distance threshold is less than the set second distance threshold, then determine that the matching feature point is an inner point; repeatedly perform the described judgment of the projection point of the matching feature point in the current frame and the matching feature point in the map Whether the distance of the matched map points is less than the set second distance threshold, until all matching feature points in the current matching feature point set have been judged as interior points;
  • Described judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation including,
  • At least two or more best matching feature point sets are respectively given weights that measure the matching degree between the current frame and the candidate map range; the weights are based on the number of matching feature points in the best matching feature point set and the number of feature points extracted from the current frame. , the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set or any combination thereof is determined,
  • the set weight threshold and maximum weight it is judged whether the best matching feature point set satisfies the conditions for the current frame pose calculation.
  • the positioning module 1003 is also used to calculate the pose of the current frame according to the matching feature points, and after obtaining the positioning result, it also includes:
  • the non-linear optimization based on sliding window is used to calculate the pose of the current frame;
  • the optimized variable is the pose of each image frame in the sliding window, the sliding window includes the current frame, and
  • the optimization constraints are the feature points of the current frame and the previous key Inter-frame matching constraints between frame feature points, and/or map matching constraints between current frame feature points and map points in the map,
  • the inter-frame matching error and/or the map matching error are minimized, and the optimized pose of the current frame is obtained as the positioning result;
  • the map matching constraint is: the error between the pixel position of the first matching map point back-projected on the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, or, in the current frame
  • the first matching feature point is : the feature point in the current frame is matched with the map point in the map to obtain the successfully matched feature point
  • the first matching map point is: the map point successfully matched by the first matching feature point;
  • the inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, or, the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the pixel of the previous key frame error between positions;
  • the image acquisition module 1001 is further configured to collect the current image, and after obtaining the current frame, perform feature point extraction based on the current frame, and perform image preprocessing on the current frame before obtaining the feature points of the current frame.
  • the positioning module 1003 is specifically used for:
  • the objective function for optimization is: a first result obtained by weighting the sum of map matching errors of all the first matching feature points of all frames in the current sliding window with the first weight, and , the second result obtained by weighting the sum of the inter-frame matching errors of all the second matching map points between all frames between each frame in the current sliding window and its previous key frame with the second weight, the accumulated information about the first the sum of the result and the second result;
  • map matching error initial value Take the map matching error obtained according to the pose of the current frame, the spatial position information of the first matching map point, the camera internal reference, and the pixel coordinates of the first matching feature point matching the first matching map point in the current frame, as the map matching error initial value
  • the iterative solution makes the pose of the current frame when the objective function used for optimization achieves the minimum value, and the optimized current pose is obtained;
  • the positioning module is also used to obtain the optimized pose of the current frame
  • the current frame is a key frame: the number of the first matching feature points in the current frame is less than the first threshold, and the number of the second matching feature points in the current frame is less than the second threshold;
  • the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold, and if it reaches the set first frame threshold If the threshold is one frame, the earliest added keyframe in the sliding window will be deleted. If the set first frame threshold is not reached, the earliest added keyframe in the sliding window will not be deleted;
  • the image preprocessing performed by the image acquisition module 1001 on the current frame includes:
  • the current frame is de-distorted to obtain a de-distorted image
  • the foreground image is used as the current frame after image preprocessing. If it is not uniform, the foreground image is stretched to obtain the current frame after image preprocessing.
  • Stretching the foreground image includes:
  • the pixel value of the foreground image is less than or equal to the set minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range;
  • the pixel value of the foreground image is greater than the minimum gray value and less than the set maximum gray value, the pixel value that is proportional to the maximum value of the pixel is used as the pixel value of the foreground image; the ratio is the pixel value of the foreground image and the minimum value. The ratio of the difference between the gray values to the difference between the maximum gray value and the minimum gray value;
  • the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the range of pixel values;
  • feature point extraction is performed to obtain the feature points of the current frame, including,
  • the feature points in the grid are arranged in descending order according to the response value of the feature points, the first Q feature points are retained, and the filtered feature points are obtained; among them, Q is based on the feature points in the target image frame.
  • the number and the set upper limit of the total number of feature points, and the total number of grid feature points are determined;
  • Feature descriptors are calculated separately for each feature point after screening.
  • the visual positioning device further includes an image preprocessing module 1012 for preprocessing the image; preferably, see FIG. 11 , which is a schematic diagram of the image preprocessing module.
  • the image preprocessing module 1012 includes,
  • the image de-distortion sub-module performs de-distortion processing on the source image frame according to the distortion coefficient of the camera to obtain a de-distorted image
  • the image filtering sub-module performs image filtering on the dedistorted image to obtain the background image
  • Image difference sub-module subtract the background image from the distorted image to obtain the foreground image
  • Image stretching sub-module which stretches the foreground image to obtain the target image frame.
  • the image filtering sub-module, the image difference sub-module, and the image stretching sub-module can be used to enhance the image texture.
  • the present application also provides a mobile robot, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the steps of the above-mentioned visual map-based visual positioning method.
  • the memory may include random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk storage.
  • RAM Random Access Memory
  • NVM non-Volatile Memory
  • the memory may also be at least one storage device located away from the aforementioned processor.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • FPGA Field-Programmable Gate Array
  • Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned visual positioning method based on a visual map are implemented.
  • Embodiments of the present invention also provide a computer program product containing instructions, which, when running on a computer, causes the computer to execute the steps of the above-mentioned visual positioning method based on a visual map.
  • An embodiment of the present invention further provides a computer program, which, when running on a computer, causes the computer to execute the steps of the above-mentioned visual positioning method based on a visual map.
  • a computer program which, when running on a computer, causes the computer to execute the steps of the above-mentioned visual positioning method based on a visual map.

Abstract

A visual positioning method based on a visual map. The method comprises: collecting a current image, and obtaining a current frame (101); on the basis of the current frame, performing feature point extraction to obtain feature points of the current frame (103); and determining a positioning strategy according to a current positioning state, matching the feature points in the current frame with map points in a map on the basis of the positioning strategy to obtain matched feature points, and when the matched feature points satisfy conditions for pose calculation of the current frame, calculating a pose of the current frame according to the matched feature points to obtain a positioning result (104). According to the method, a calibration point having an accurate position does not need to be set, relatively good robustness is achieved for an area without map building or when positioning fails, and a continuous match with the map can be performed in the positioning process without large jumping.

Description

一种基于视觉地图的视觉定位方法、装置A visual positioning method and device based on a visual map
本申请要求于2020年06月30日提交中国专利局、申请号为202010618519.1发明名称为“一种基于视觉地图的视觉定位方法、装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on June 30, 2020 with the application number 202010618519.1 titled "A Visual Positioning Method and Device Based on Visual Maps", the entire contents of which are incorporated by reference in in this application.
技术领域technical field
本申请涉及视觉导航领域,特别地,涉及一种基于视觉地图的视觉定位方法、装置。The present application relates to the field of visual navigation, and in particular, to a visual positioning method and device based on a visual map.
背景技术Background technique
视觉导航是通过摄像装置对周围环境进行图像采集,并基于图像进行计算,完成移动机器人的位置确定和路径识别,其通常需要依赖视觉地图来完成,其中,视觉地图是利用图像特征点以及描述子构建的环境地图。以基于地面纹理的地图为例,移动机器人移动经过某纹理点的时候,根据在该纹理点处所采集当前图像与地图的特征配准,解算出当前移动机器人的位姿,即可进行基于地面纹理的定位导航。Visual navigation is to collect images of the surrounding environment through a camera device, and perform calculations based on the images to complete the position determination and path recognition of the mobile robot. The constructed environment map. Taking the map based on the ground texture as an example, when the mobile robot moves through a texture point, according to the feature registration of the current image and the map collected at the texture point, the pose of the current mobile robot can be calculated, and the ground texture-based method can be performed. positioning navigation.
现有的基于视觉地图的定位方法,使用一帧图像的匹配结果进行定位,导致定位鲁棒性差。Existing localization methods based on visual maps use the matching results of a frame of images for localization, resulting in poor localization robustness.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种基于视觉地图的视觉定位方法,以提高视觉定位的鲁棒性。The present application provides a visual localization method based on a visual map to improve the robustness of visual localization.
本申请提供的一种基于视觉地图的视觉定位方法是这样实现的:A visual positioning method based on a visual map provided by this application is implemented as follows:
采集当前图像,得到当前帧;Collect the current image to get the current frame;
基于当前帧,进行特征点提取,得到当前帧的特征点;Based on the current frame, feature point extraction is performed to obtain the feature points of the current frame;
根据当前定位状态确定定位策略,Determine the positioning strategy according to the current positioning state,
基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点,Based on the positioning strategy, the feature points in the current frame are matched with the map points in the map to obtain the matching feature points,
当匹配特征点满足用于当前帧位姿解算的条件时,根据匹配特征点计算当前帧的位姿,得到定位结果。When the matching feature points meet the conditions for the current frame pose calculation, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
可选地,所述得到匹配特征点之后,进一步包括,Optionally, after obtaining the matching feature points, it further includes,
基于匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,Based on the matching feature points, a random sampling consensus algorithm is used to determine the best matching feature point set,
判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,当最佳匹配特征点集合不满足用于当前帧位姿解算的条件时,判定当前帧定位失败;所述定位状态根据上一帧的定位结果、当前连续定位失败帧数确定;所述定位状态包括,未初始化状态,定位成功状态,以及重定位状态;Determine whether the best matching feature point set satisfies the conditions for the current frame pose calculation, when the best matching feature point set does not meet the current frame pose calculation conditions, determine that the current frame positioning fails; the positioning The state is determined according to the positioning result of the previous frame and the current number of frames that have failed to locate continuously; the positioning state includes an uninitialized state, a successful positioning state, and a relocation state;
所述定位策略包括,未初始化状态下的初始化定位,定位成功状态下的正常定位,重定位状态下的重定位,以及各个定位状态之间转换关系;The positioning strategy includes initialization positioning in an uninitialized state, normal positioning in a successful positioning state, relocation in a relocation state, and conversion relationships between the positioning states;
其中,所述各个定位状态之间转换关系包括,Wherein, the conversion relationship between the various positioning states includes:
当前定位状态为未初始化状态时,如果初始化定位成功,则转换至定位成功状态,如果初始化定位失败,保持当前未初始化状态;When the current positioning state is the uninitialized state, if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
当前定位状态为定位成功状态时,如果正常定位成功,则保持当前定位成功状态,如果正常定位失败,转换至定位丢失状态;When the current positioning status is the positioning successful status, if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
当前定位状态为定位丢失状态时,如果重定位成功,则转换至定位成功状态,如果重定位失败, 判断连续定位失败的帧数是否超过设定的帧数阈值,或者判断当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值,如果超过设定的帧数阈值或设定的第一距离阈值,则转换至未初始化状态,如果未超过设定的帧数阈值或设定的第一距离阈值,则保持当前定位丢失状态;When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning success state. If the relocation fails, determine whether the number of consecutive failed positioning frames exceeds the set frame number threshold, or determine whether the current frame is different from the last positioning. Whether the distance between the successful poses exceeds the set first distance threshold, if it exceeds the set number of frames threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set number of frames threshold or the set first distance threshold, then keep the current positioning loss state;
所述根据当前定位状态确定定位策略包括,根据各个定位状态以及各个定位状态之间转换关系,生成定位逻辑;其中,所述定位逻辑的逻辑内容包括:对当前帧执行相应的定位策略所指示的定位过程,所述相应的定位策略为当前定位状态下的定位策略;The determining of the positioning strategy according to the current positioning state includes generating positioning logic according to each positioning state and the conversion relationship between the respective positioning states; wherein, the logical content of the positioning logic includes: executing the current frame indicated by the corresponding positioning strategy The positioning process, the corresponding positioning strategy is the positioning strategy under the current positioning state;
所述基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,包括,基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,将当前帧中的特征点与候选地图范围内的地图点进行匹配。Matching the feature points in the current frame with the map points in the map based on the positioning strategy, including, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determining the candidate map range in the map for the current frame , to match the feature points in the current frame with the map points in the candidate map range.
可选地,所述根据各个定位状态以及各个定位状态之间转换关系,生成定位逻辑,包括,Optionally, generating the positioning logic according to each positioning state and the conversion relationship between the respective positioning states, including,
判断当前帧是否是第一帧,Determine whether the current frame is the first frame,
如果当前帧是第一帧,则对当前帧进行初始化定位,If the current frame is the first frame, initialize the current frame,
如果当前帧不是第一帧,则判断上一帧是否定位成功,If the current frame is not the first frame, it is judged whether the positioning of the previous frame is successful.
如果上一帧定位成功,则对当前帧进行正常定位;If the positioning of the previous frame is successful, the current frame will be positioned normally;
如果上一帧定位不成功,则判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值;If the positioning of the previous frame is unsuccessful, it is judged whether the current number of consecutive failed frames exceeds the set number of frames threshold, or whether the distance between the current frame and the pose of the last successful positioning exceeds the set first distance threshold ;
如果当前连续定位失败帧数超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位,If the current frame number of consecutive positioning failures exceeds the frame number threshold or the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, the current frame will be initialized and positioned.
如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位。If the current frame number of consecutive positioning failures does not exceed the frame number threshold or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, the current frame is relocated.
可选地,所述如果当前帧是第一帧,则对当前帧进行初始化定位,进一步包括,Optionally, if the current frame is the first frame, initializing and positioning the current frame, further comprising,
根据当前帧是第一帧,判定当前定位状态为未初始化状态,According to the current frame is the first frame, it is determined that the current positioning state is an uninitialized state,
如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧定位失败,记录当前帧定位失败,保持当前未初始化状态;If the initialization and positioning of the current frame is successful, the current frame positioning is recorded successfully, and the status is switched to the positioning success state. If the current frame positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
所述如果上一帧定位成功,则对当前帧进行正常定位,进一步包括,Described if the positioning of the previous frame is successful, then the current frame is positioned normally, further comprising,
根据上一帧定位成功,判定当前定位状态为定位成功状态,According to the successful positioning of the previous frame, it is determined that the current positioning status is the positioning successful status.
如果当前帧正常定位成功,则记录当前帧定位成功,保持当前定位成功状态,如果当前帧定位失败,记录当前帧定位失败,转换至定位丢失状态;If the normal positioning of the current frame is successful, the current frame positioning is recorded successfully, and the current positioning success status is maintained; if the current frame positioning fails, the current frame positioning failure is recorded, and the status is switched to the positioning loss state;
所述如果当前连续定位失败帧数超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位,进一步包括,Described if the current continuous positioning failure frame number exceeds the frame number threshold, or, the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, then the current frame is initialized and positioned, further comprising,
根据当前连续定位失败帧数超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,判定当前定位状态为未初始化状态,According to the current continuous positioning failure frame number exceeds the frame number threshold, or the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, it is determined that the current positioning state is an uninitialized state,
如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧初始化定位失败,记录当前帧定位失败,保持当前未初始化状态;If the initialization positioning of the current frame is successful, the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
所述如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位,进一步包括,Described if the current continuous positioning failure frame number does not exceed the frame number threshold or the distance between the current frame and the most recent successful positioning does not exceed the set first distance threshold, then the current frame is relocated, further comprising,
根据当前连续定位失败帧数未超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距 离未超过设定的第一距离阈值,判定当前定位状态为定位丢失状态,According to the current continuous positioning failure frame number does not exceed the frame number threshold, or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, it is determined that the current positioning state is a positioning loss state.
如果当前帧重定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧重定位失败,记录当前帧定位失败,保持当前定位丢失状态,返回所述判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值的步骤。If the current frame relocation is successful, record the current frame positioning success, and switch to the positioning success state; if the current frame relocation fails, record the current frame positioning failure, keep the current positioning loss state, and return to the judgment whether the current continuous positioning failure frame number is Exceeds the set number of frames threshold, or whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold.
可选地,所述基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,包括,Optionally, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determine the candidate map range in the map for the current frame, including,
对当前帧进行初始化定位时,将地图中的所有地图点作为第一候选地图范围,或者,利用辅助信息获得第一候选地图范围;对第一候选地图范围内的地图点采用暴力匹配进行筛选,如果每两个地图点特征匹配度超过设定的第二匹配阈值,则随机删掉其中的一个地图点,得到修正后的第一候选地图范围;When the current frame is initialized and positioned, all map points in the map are used as the first candidate map range, or the auxiliary information is used to obtain the first candidate map range; the map points within the first candidate map range are screened by brute force matching, If the feature matching degree of every two map points exceeds the set second matching threshold, then randomly delete one of the map points to obtain the revised first candidate map range;
对当前帧进行正常定位时,根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第二候选地图范围;When performing normal positioning on the current frame, the pose prediction is performed on the current frame according to the inter-frame motion information from the previous frame to the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the second frame in the map is determined. candidate map range;
对当前帧进行重定位时,根据定位成功的历史帧,向前追溯历史帧中与当前帧最近的一帧并作为参考帧,将该参考帧作为上一帧,根据该上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第三候选地图范围。When relocating the current frame, according to the historical frame that has been successfully positioned, trace forward the closest frame to the current frame in the historical frame and use it as the reference frame, and use the reference frame as the previous frame, and according to the previous frame to the current frame The motion information between frames is obtained, the pose prediction is performed on the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the third candidate map range in the map is determined.
可选地,所述根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿,包括,Optionally, according to the inter-frame motion information from the previous frame to the current frame, the pose prediction is performed on the current frame to obtain the predicted pose of the current frame, including,
第一方式:通过轮式里程计或惯性测量元件获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The first method: Obtain the frame pose transformation from the previous frame to the current frame through the wheel odometer or inertial measurement element, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame. ;
或者or
第二方式:通过视觉里程计获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The second method: obtain the inter-frame pose transformation from the previous frame to the current frame through the visual odometry, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame;
或者or
第三方式:根据已获得定位结果的历史帧,预测上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The third method: According to the historical frame for which the positioning result has been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame ;
或者,or,
第四方式:至少采用第一方式、第二方式、第三方式中的两方式,分别求得当前帧的第一预测位姿,得到至少两个第一预测位姿;The fourth method: adopt at least two of the first method, the second method, and the third method to obtain the first predicted pose of the current frame respectively, and obtain at least two first predicted poses;
采用卡尔曼滤波器对所述至少两个第一预测位姿进行滤波,得到滤波后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;或者,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,得到优化后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;The Kalman filter is used to filter the at least two first predicted poses to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame; or, nonlinear optimization is used. method, optimize based on the at least two first predicted poses, obtain an optimized second predicted pose, and use the second predicted pose as the final predicted pose of the current frame;
其中,非线性优化的目标函数为根据各个方式所得到的各个误差项之和,其中,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,包括:将上一帧的位姿、不同方式所得到的当前帧的第一预测位姿、以及帧间位姿变换作为初始值,代入非线性优化的目标函数,求解使得非线性优化的目标函数取得最小值时的位姿,作为第二预测位姿。Wherein, the objective function of nonlinear optimization is the sum of various error terms obtained according to various methods, wherein, using a nonlinear optimization method to optimize based on the at least two first predicted poses, including: The pose, the first predicted pose of the current frame obtained in different ways, and the pose transformation between frames are used as initial values, and are substituted into the objective function of nonlinear optimization to solve the position when the objective function of nonlinear optimization achieves the minimum value. pose as the second predicted pose.
可选地,所述根据当前帧的预测位姿,确定地图中第二候选地图范围,包括,Optionally, determining the second candidate map range in the map according to the predicted pose of the current frame, including,
以当前帧的预测位姿所确定的地图位置为中心,将该中心的第一邻域确定为第二候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the first neighborhood of the center is determined as the second candidate map range,
或者or
对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第一邻域作为该特征点第二候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and take the position of the projection point as the center of the first neighborhood as the center. The second candidate map range of the feature point;
所述根据当前帧的预测位姿,确定地图中第三候选地图范围,包括,Described according to the predicted pose of the current frame, determine the third candidate map range in the map, including,
以当前帧的预测位姿所确定的地图位置为中心,将该中心的第二邻域确定为第三候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the second neighborhood of the center is determined as the third candidate map range,
或者or
对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第二邻域作为该特征点第三候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and the second neighborhood with the position of the projection point as the center is used as the The third candidate map range of the feature point;
所述第二邻域的范围大于第一邻域的范围。The range of the second neighborhood is greater than the range of the first neighborhood.
可选地,所述基于匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,包括,Optionally, based on the matching feature points, a random sampling consistency algorithm is used to determine the best matching feature point set, including,
从匹配特征点所构成的匹配特征点集合中,随机选择用于计算当前帧位姿估计的匹配特征点,得到当前匹配特征点子集;From the set of matching feature points formed by the matching feature points, randomly select the matching feature points for calculating the pose estimation of the current frame, and obtain a subset of the current matching feature points;
基于利用当前匹配特征点子集中的匹配特征点所建立的空间位置信息与像素位置信息的映射,计算当前位姿,得到该当前匹配特征点子集的拟合位姿估计,Based on the mapping between the spatial position information and the pixel position information established by the matching feature points in the current matching feature point subset, the current pose is calculated, and the fitted pose estimation of the current matching feature point subset is obtained,
根据拟合位姿估计以及相机内参,获取当前帧中所有的特征点的空间位置,得到所有特征点的投影点空间位置;Obtain the spatial positions of all feature points in the current frame according to the fitted pose estimation and camera internal parameters, and obtain the projected point spatial positions of all feature points;
对于匹配特征点集合中的每个匹配特征点,根据该匹配特征点的投影点空间位置,判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值,如果小于设定的第二距离阈值,则判定该匹配特征点为内点;反复执行所述判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值的步骤,直至当前匹配特征点集合中所有匹配特征点都被进行了内点的判定;For each matching feature point in the matching feature point set, according to the spatial position of the projected point of the matching feature point, determine whether the distance between the projected point of the matching feature point in the current frame and the map point matched by the matching feature point in the map is less than If the set second distance threshold is less than the set second distance threshold, then determine that the matching feature point is an inner point; repeatedly perform the described judgment of the projection point of the matching feature point in the current frame and the matching feature point in the map Whether the distance of the matched map points is less than the set second distance threshold, until all matching feature points in the current matching feature point set have been judged as interior points;
统计当前内点数量,判断当前统计的内点数量是否为历次迭代中的最大,如果是历次迭代中的最大,则将当前内点所构成的集合作为当前最佳匹配特征点集合;Count the number of current interior points, and judge whether the current number of interior points is the largest in the previous iterations. If it is the largest in the previous iterations, the set formed by the current interior points is used as the current best matching feature point set;
判断是否达到结束条件,如果达到结束条件,则将当前最佳匹配特征点集合作为最终的最佳匹配特征点集合,如果未达到结束条件,返回所述从匹配特征点所构成的匹配特征点集合中随机选择用于计算当前帧位姿估计的匹配特征点的步骤;Judging whether the end condition is reached, if the end condition is reached, the current best matching feature point set is used as the final best matching feature point set, if the end condition is not reached, the matching feature point set formed from the matching feature points is returned. The step of randomly selecting matching feature points for calculating the pose estimation of the current frame;
所述判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,包括,Described judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation, including,
根据匹配特征点的数量判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件;According to the number of matching feature points, determine whether the best matching feature point set satisfies the conditions for the current frame pose calculation;
或者,or,
对至少两个以上最佳匹配特征点集合分别赋予衡量当前帧与候选地图范围匹配程度的权值;所述权值根据最佳匹配特征点集合中的匹配特征点数量、当前帧特征点提取数量,特征点分布情况,匹配特征点初始数量与最佳匹配特征点集合中的匹配特征点数量之一或其任意组合确定,At least two or more best matching feature point sets are respectively given weights that measure the matching degree between the current frame and the candidate map range; the weights are based on the number of matching feature points in the best matching feature point set and the number of feature points extracted from the current frame. , the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set or any combination thereof is determined,
根据设定的权值阈值和最大权值,判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件。According to the set weight threshold and maximum weight, it is judged whether the best matching feature point set satisfies the conditions for the current frame pose calculation.
可选地,所述根据匹配特征点计算当前帧的位姿,得到定位结果之后,所述方法还包括,Optionally, after calculating the pose of the current frame according to the matching feature points and obtaining the positioning result, the method further includes:
对计算得到当前帧的位姿采用基于滑动窗口的非线性优化;优化的变量为滑动窗口内各图像帧 的位姿,该滑动窗口包括当前帧,优化的约束为当前帧特征点与上一关键帧特征点之间的帧间匹配约束、和/或当前帧特征点与地图中的地图点之间的地图匹配约束,The non-linear optimization based on sliding window is used to calculate the pose of the current frame; the optimized variable is the pose of each image frame in the sliding window, the sliding window includes the current frame, and the optimization constraints are the feature points of the current frame and the previous key Inter-frame matching constraints between frame feature points, and/or map matching constraints between current frame feature points and map points in the map,
利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,作为定位结果;Using the least squares method, the inter-frame matching error and/or the map matching error are minimized, and the optimized pose of the current frame is obtained as the positioning result;
其中,in,
地图匹配约束为:第一匹配地图点反投影到当前帧上的像素位置与当前帧中与该第一匹配地图点匹配的第一匹配特征点的像素位置之间的误差,或者,当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差;所述第一匹配特征点为:当前帧中的特征点与地图中的地图点进行匹配所得到匹配成功的特征点;第一匹配地图点为:被第一匹配特征点匹配成功的地图点;The map matching constraint is: the error between the pixel position of the first matching map point back-projected on the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, or, in the current frame The error between the spatial position of the first matching feature point projected to the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system; the first matching feature point is : the feature point in the current frame is matched with the map point in the map to obtain the successfully matched feature point; the first matching map point is: the map point successfully matched by the first matching feature point;
帧间匹配约束为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置之间的误差,或者,与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差;The inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, or, the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the pixel of the previous key frame error between positions;
所述采集当前图像,得到当前帧之后,基于当前帧,进行特征点提取,得到当前帧的特征点之前,所述方法包括,对当前帧进行图像预处理。After the current image is acquired and the current frame is obtained, feature point extraction is performed based on the current frame, and before the feature points of the current frame are obtained, the method includes performing image preprocessing on the current frame.
可选地,所述利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,包括,Optionally, the least squares method is used to minimize the inter-frame matching error and/or the map matching error to obtain the optimized current frame pose, including,
构建用于优化的目标函数,该用于优化的目标函数为:以第一权值加权当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,以及,以第二权值加权当前滑动窗口中各帧与其上一关键帧之间所有帧间的所有第二匹配地图点的帧间匹配误差之和所得到的第二结果,所累加的关于第一结果与第二结果之和;constructing an objective function for optimization, the objective function for optimization is: a first result obtained by weighting the sum of map matching errors of all the first matching feature points of all frames in the current sliding window with the first weight, and , the second result obtained by weighting the sum of the inter-frame matching errors of all the second matching map points between all frames between each frame in the current sliding window and its previous key frame with the second weight, the accumulated information about the first the sum of the result and the second result;
以根据当前帧的位姿、第一匹配地图点的空间位置信息、相机内参、当前帧中的与第一匹配地图点匹配的第一匹配特征点的像素坐标所得到的地图匹配误差,作为地图匹配误差初始值,Take the map matching error obtained according to the pose of the current frame, the spatial position information of the first matching map point, the camera internal reference, and the pixel coordinates of the first matching feature point matching the first matching map point in the current frame, as the map matching error initial value,
以根据当前帧位姿、第二匹配地图点的空间位置信息、上一关键帧的位姿、相机内参矩阵所得到帧间匹配误差,作为帧间匹配误差初始值,Taking the inter-frame matching error obtained according to the current frame pose, the spatial position information of the second matching map point, the pose of the previous key frame, and the camera internal parameter matrix as the initial value of the inter-frame matching error,
迭代求解使得用于优化的目标函数取得最小值时当前帧的位姿,得到优化后的当前位姿;The iterative solution makes the pose of the current frame when the objective function used for optimization achieves the minimum value, and the optimized current pose is obtained;
所述得到优化后的当前帧位姿之后,所述方法还包括,After the optimized current frame pose is obtained, the method further includes:
满足以下条件之一时,判定当前帧为关键帧:当前帧中第一匹配特征点的数量小于第一阈值,当前帧中第二匹配特征点的数量小于第二阈值;When one of the following conditions is met, it is determined that the current frame is a key frame: the number of the first matching feature points in the current frame is less than the first threshold, and the number of the second matching feature points in the current frame is less than the second threshold;
若当前帧为非关键帧时,则在滑动窗口中删除该当前帧,若当前帧为关键帧,则判断当前滑动窗口中帧数量是否达到设定的第一帧阈值,如果设定的第一帧阈值,则删除滑动窗口中最早添加的关键帧,如果未达到设定的第一帧阈值,则不删除滑动窗口中最早添加的关键帧;If the current frame is a non-key frame, the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold. If the frame threshold is set, the earliest key frame added in the sliding window will be deleted. If the set first frame threshold is not reached, the earliest key frame added in the sliding window will not be deleted;
所述对当前帧进行图像预处理包括,The performing image preprocessing on the current frame includes,
根据相机的畸变系数对当前帧进行去畸变处理,得到去畸变图像,According to the distortion coefficient of the camera, the current frame is de-distorted to obtain a de-distorted image,
判断去畸变图像中各个像素点的像素值是否大于第一像素阈值,如果大于第一像素阈值,则将像素值大于第一像素阈值的像素点进行取反操作,然后进行图像滤波,得到背景图像,如果不大于 第一像素阈值,将去畸变图像进行图像滤波,得到背景图像,Determine whether the pixel value of each pixel in the dedistorted image is greater than the first pixel threshold, if it is greater than the first pixel threshold, invert the pixels whose pixel value is greater than the first pixel threshold, and then perform image filtering to obtain the background image , if it is not greater than the first pixel threshold, perform image filtering on the dedistorted image to obtain the background image,
用去畸变图像减去背景图像,得到前景图像,Subtract the background image from the undistorted image to get the foreground image,
判断前景图像中的像素值是否分布均匀,如果均匀,则将该前景图像作为图像预处理后的当前帧,如果不均匀,对前景图像进行拉伸处理,得到图像预处理后的当前帧。It is judged whether the pixel values in the foreground image are uniformly distributed. If uniform, the foreground image is used as the current frame after image preprocessing. If it is not uniform, the foreground image is stretched to obtain the current frame after image preprocessing.
可选地,所述前景图像进行拉伸处理包括,Optionally, performing stretching processing on the foreground image includes:
若前景图像像素值小于等于设定的最小灰度值时,将该前景图像像素值取值为像素取值范围内的最小值;If the pixel value of the foreground image is less than or equal to the set minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range;
若前景图像像素值大于最小灰度值、且小于设定的最大灰度值时,按照与像素最大值成一定比例的像素值作为该前景图像像素值;所述比例为前景图像像素值与最小灰度值之差与最大灰度值与最小灰度值之差的比值;If the pixel value of the foreground image is greater than the minimum gray value and less than the set maximum gray value, the pixel value that is proportional to the maximum value of the pixel is used as the pixel value of the foreground image; the ratio is the pixel value of the foreground image and the minimum value. The ratio of the difference between the gray values to the difference between the maximum gray value and the minimum gray value;
若前景图像像素值大于等于最大灰度值时,将该前景图像像素值取值为像素取值范围内的最大值;If the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the range of pixel values;
所述基于当前帧,进行特征点提取,得到当前帧的特征点,包括,Described based on the current frame, feature point extraction is performed to obtain the feature points of the current frame, including,
对当前帧进行特征检测,得到特征点,Perform feature detection on the current frame to obtain feature points,
将当前帧划分成预定数量的网格,divide the current frame into a predetermined number of grids,
对于任一网格中的特征点,将网格内的特征点按特征点响应值降序排列,保留前Q个特征点,得到筛选后的特征点;其中,Q根据该目标图像帧中特征点的数量和设定的特征点总数上限、以及该网格特征点总数确定;For the feature points in any grid, the feature points in the grid are arranged in descending order according to the response value of the feature points, the first Q feature points are retained, and the filtered feature points are obtained; among them, Q is based on the feature points in the target image frame. The number and the set upper limit of the total number of feature points, and the total number of grid feature points are determined;
对筛选后的各特征点,分别计算特征描述子。Feature descriptors are calculated separately for each feature point after screening.
本申请提供的一种基于视觉地图的视觉定位装置,该装置包括,A visual positioning device based on a visual map provided by the application, the device includes:
图像采集模块,采集当前图像,得到当前帧;The image acquisition module collects the current image and obtains the current frame;
特征提取模块,基于当前帧,进行特征点提取,得到当前帧的特征点;The feature extraction module, based on the current frame, performs feature point extraction to obtain the feature points of the current frame;
定位模块,根据当前定位状态确定定位策略,基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点,当匹配特征点满足用于当前帧位姿解算的条件时,根据匹配特征点计算当前帧的位姿,得到定位结果。The positioning module determines the positioning strategy according to the current positioning state. Based on the positioning strategy, the feature points in the current frame are matched with the map points in the map to obtain matching feature points. When the matching feature points meet the requirements for the current frame pose calculation. When conditions are met, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
本申请还提供一种计算机可读存储介质,所述存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述任一所述基于视觉地图的视觉定位方法的步骤。The present application also provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of any of the above-mentioned visual map-based visual positioning methods are implemented.
本申请还提供了一种移动机器人,包括存储器、处理器,所述存储器存储有计算机程序,所述处理器被配置执行所述计算机程序,以实现上述任一所述基于视觉地图的视觉定位方法的步骤。The present application also provides a mobile robot, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement any of the above-mentioned visual map-based visual positioning methods A step of.
本申请还提供了一种包含指令的计算机程序产品,所述包含指令的计算机程序产品在计算机上运行时,使得计算机执行上述任一所述基于视觉地图的视觉定位方法的步骤。The present application also provides a computer program product containing instructions, when the computer program product containing instructions is run on a computer, the computer program product can cause the computer to execute any of the above-mentioned steps of the visual map-based visual positioning method.
本申请还提供了一种计算机程序,所述计算机程序在计算机上运行时,使得计算机执行上述任一所述基于视觉地图的视觉定位方法的步骤。The present application also provides a computer program, which, when running on a computer, causes the computer to execute the steps of any of the above-mentioned visual map-based visual positioning methods.
本申请提供的基于视觉地图的视觉定位方法,根据当前定位状态所确定的定位策略来进行当前帧的特征匹配和位姿计算,不需要设定位置精确的标定点;并且,相对于现有技术,由于在不同的定位状态下采用不同的定位策略来进行定位,使得可以实现针对各种定位状态的定位,因此,对未建图区域或定位失败时,具有较佳的鲁棒性;同时,相对于现有技术的设置标定点的定位方案中, 只有经过标定点的图像能够得到较精准定位,本方案的定位过程中可以持续与地图进行匹配而定位结果不会存在大幅跳变。The visual positioning method based on the visual map provided by the present application performs feature matching and pose calculation of the current frame according to the positioning strategy determined by the current positioning state, and does not need to set accurate calibration points; and, compared with the prior art , because different positioning strategies are used for positioning in different positioning states, so that positioning for various positioning states can be achieved, so it has better robustness to unmapped areas or when positioning fails; at the same time, Compared with the prior art positioning scheme of setting calibration points, only images passing through the calibration points can be positioned more accurately, and the positioning process of this scheme can continue to match with the map without significant jumps in the positioning results.
附图说明Description of drawings
为了更清楚地说明本申请实施例和现有技术的技术方案,下面对实施例和现有技术中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,本领域普通技术人员来讲还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application and the technical solutions of the prior art, the following briefly introduces the drawings required in the embodiments and the prior art. Obviously, the drawings in the following description are only the For some embodiments of the application, those of ordinary skill in the art can also obtain other drawings according to these drawings.
图1是本实施例视觉定位的一种流程示意图。FIG. 1 is a schematic flowchart of visual positioning in this embodiment.
图2为特征点筛选示意图。Figure 2 is a schematic diagram of feature point screening.
图3为定位状态之间转换关系的一种示意图。FIG. 3 is a schematic diagram of a transition relationship between positioning states.
图4为定位逻辑的一种示意图。FIG. 4 is a schematic diagram of positioning logic.
图5为初始化定位的一种流程示意图。FIG. 5 is a schematic flow chart of initializing positioning.
图6为地图点筛选的一种示意图。FIG. 6 is a schematic diagram of map point screening.
图7为正常定位的一种流程示意图。FIG. 7 is a schematic flow chart of normal positioning.
图8为重定位的一种流程示意图。FIG. 8 is a schematic flowchart of a relocation.
图9a和图9b为确定候选地图范围的一种示意图。9a and 9b are a schematic diagram of determining a candidate map range.
图10为本申请的基于视觉地图的视觉定位装置的一种示意图。FIG. 10 is a schematic diagram of a visual positioning device based on a visual map of the present application.
图11为图像预处理模块的一种示意图。FIG. 11 is a schematic diagram of an image preprocessing module.
图12为图像坐标系下当前帧的地图匹配约束、帧间匹配约束的一种示意图。FIG. 12 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in an image coordinate system.
图13为世界坐标系下当前帧的地图匹配约束、帧间匹配约束的一种示意图。FIG. 13 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in the world coordinate system.
具体实施方式detailed description
为使本申请的目的、技术方案、及优点更加清楚明白,以下参照附图并举实施例,对本申请进一步详细说明。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。本领域普通技术人员基于本申请中的实施例所获得的所有其他实施例,都属于本申请保护的范围。In order to make the objectives, technical solutions, and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and examples. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application fall within the protection scope of the present application.
本申请根据不同定位状态所采用不同的定位策略而确定定位逻辑,使得定位状态在满足定位逻辑的情形下进行转换,其中,定位策略在位姿预测、特征匹配的处理上不同,从而使得定位整体上的鲁棒性得以增加。以下将以基于视觉地图的视觉定位来进行说明,其中,视觉地图为已预先构建好的特征地图,该地图中具有三维空间信息的地图点,即,地图中保存有特征点的世界坐标和描述子信息,也就是,地图中的地图点也可以称为地图中的特征点,任一特征点的描述子信息为用于描述该特征点的图像特征的信息,用于特征匹配过程中,例如颜色特征、纹理特征等,其中,描述子信息也可以称为特征描述子或者描述子。The present application determines the positioning logic according to different positioning strategies adopted in different positioning states, so that the positioning state is converted when the positioning logic is satisfied, wherein the positioning strategies are different in the processing of pose prediction and feature matching, so that the overall positioning Robustness is increased. The following description will be based on the visual positioning based on the visual map, wherein the visual map is a feature map that has been constructed in advance, and the map has map points with three-dimensional spatial information, that is, the world coordinates and descriptions of the feature points are stored in the map. Sub-information, that is, map points in the map can also be called feature points in the map, and the descriptor information of any feature point is the information used to describe the image features of the feature point, which is used in the feature matching process, such as Color features, texture features, etc., wherein the descriptor information may also be called feature descriptors or descriptors.
为便于理解,实施例中,示例性的,视觉地图为基于采集的地面纹理信息所构建的纹理地图,可以是二维或三维带有特征描述子的点云地图,该纹理地图覆盖范围可以是连续覆盖的,也可以是离散覆盖的。以下以三维点云地图为例。For ease of understanding, in the embodiment, for example, the visual map is a texture map constructed based on the collected ground texture information, which can be a two-dimensional or three-dimensional point cloud map with feature descriptors, and the coverage of the texture map can be Continuous coverage can also be discrete coverage. The following takes a 3D point cloud map as an example.
参见图1所示,图1为本实施例视觉定位的一种流程示意图。移动机器人在加载有纹理地图后,执行如下步骤:Referring to FIG. 1 , FIG. 1 is a schematic flowchart of the visual positioning in this embodiment. After loading the texture map, the mobile robot performs the following steps:
步骤101,采集当前图像,得到当前帧; Step 101, collecting a current image to obtain a current frame;
步骤102,对当前帧进行图像预处理,以使得图像中的纹理显著,包括且不限于,图像去畸变、图像滤波、图像增强等可选的处理中的一种或多种。该步骤102为基于图像质量的可选步骤。例如,根据当前帧是否去过畸变、纹理是否显著确定是否加入图像预处理。需要说明的是,若基于图像质量判定出当前帧无需加入图像预处理,则在采集到当前帧后,可以直接对当前帧进行特征点提取,得到当前帧的特征点,其中,直接对当前帧进行特征点提取,得到当前帧的特征点的过程,与对预处理后的当前帧进行特征点提取的过程相同。Step 102: Perform image preprocessing on the current frame to make the texture in the image prominent, including but not limited to one or more of optional processes such as image de-distortion, image filtering, and image enhancement. This step 102 is an optional step based on image quality. For example, whether to add image preprocessing is determined according to whether the current frame is over-distorted and whether the texture is significant. It should be noted that if it is determined based on the image quality that the current frame does not need to be added to image preprocessing, after the current frame is collected, the feature points of the current frame can be directly extracted to obtain the feature points of the current frame. The process of extracting the feature points to obtain the feature points of the current frame is the same as the process of extracting the feature points of the preprocessed current frame.
可选地,对当前帧进行图像预处理的一种流程示意图,包括如下步骤:Optionally, a schematic flowchart of performing image preprocessing on the current frame, including the following steps:
步骤1021,根据相机的畸变系数对当前帧进行去畸变处理,得到去畸变图像I(u,v),其中,u、v表示像素坐标。 Step 1021, perform de-distortion processing on the current frame according to the distortion coefficient of the camera, to obtain a de-distorted image I(u, v), where u and v represent pixel coordinates.
步骤1022,判断去畸变图像中各个像素点的像素值是否大于设定的第一像素阈值,如果大于设定的第一像素阈值,则将像素值大于第一像素阈值的像素点进行取反操作,然后对进行了取反操作后的去畸变图像进行滤波,如果不大于设定的第一像素阈值,直接对去畸变图像I(u,v),进行图像滤波,得到背景图像I b(u,v)。其中,以彩色图像或灰度图像为例,所谓取反操作是指:利用255减去原来的像素值,作为新的图像像素值,取反后的图像与原图像相比,黑白颠倒,明暗相反。 Step 1022, determine whether the pixel value of each pixel in the de-distorted image is greater than the set first pixel threshold, if it is greater than the set first pixel threshold, then perform an inversion operation on the pixel whose pixel value is greater than the first pixel threshold , then filter the de-distorted image after the inversion operation, if it is not greater than the set first pixel threshold, directly perform image filtering on the de-distorted image I (u, v) to obtain the background image I b (u , v). Among them, taking a color image or a grayscale image as an example, the so-called inversion operation refers to: using 255 to subtract the original pixel value as the new image pixel value, the inverted image is compared with the original image, the black and white is reversed, the light and shade are reversed. on the contrary.
步骤1023,用去畸变图像减去背景图像,得到前景图像I f(u,v),其中,前景图像的数学式表达为: Step 1023, the image distortion spent subtracting the background image, foreground image to obtain I f (u, v), wherein, the foreground image equation is expressed as:
I f(u,v)=I(u,v)-I b(u,v) I f (u, v) = I (u, v) -I b (u, v)
步骤1024,判断前景图像I f(u,v)的像素值是否分布均匀,如果均匀,则将前景图像作为预处理后的当前帧,如果不均匀,则对前景图像进行拉伸,得到预处理后的当前帧; Step 1024, it is determined foreground image I f (u, v) whether or not the pixel value distribution, even if, then the foreground image as the current frame after pretreatment, if not uniform, the foreground image is stretched to obtain pre- the current frame after;
其中,任一图像的像素值是否分布均匀可以判断该图像的像素值是否在整个灰度范围内都有分布,防止图像过暗或过曝造成的对比度下降。示例性的,在一种实现方式中,计算图像灰度直方图,统计各灰度等级区间的像素数量,如果像素灰度值集中在较大或较小的灰度区间内,则判定该图像的像素值不均匀分布;如果各个灰度区间均有像素分布,则判定该图像的像素值均匀分布。Among them, whether the pixel values of any image are evenly distributed can determine whether the pixel values of the image are distributed in the entire grayscale range, so as to prevent the contrast from being reduced due to the image being too dark or overexposed. Exemplarily, in an implementation manner, an image grayscale histogram is calculated, the number of pixels in each grayscale interval is counted, and if the pixel grayscale values are concentrated in a larger or smaller grayscale interval, the image is determined. The pixel values of the image are not uniformly distributed; if there are pixel distributions in each grayscale interval, it is determined that the pixel values of the image are uniformly distributed.
示例性的,对前景图像进行拉伸处理可以为:Exemplarily, stretching the foreground image may be:
当前景图像像素值小于等于最小灰度值时,将该前景图像像素值取值为像素取值范围内的最小值,即像素值为0;其中,最小灰度值和最大灰度值可以为预先设定的灰度值阈值;或者,最小灰度值可以为前景图像像素的灰度值中的最小值,而最大灰度值可以为前景图像像素的灰度值中的最大值。When the pixel value of the foreground image is less than or equal to the minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range, that is, the pixel value is 0; where the minimum gray value and the maximum gray value can be A preset gray value threshold; or, the minimum gray value may be the minimum value among the gray values of the foreground image pixels, and the maximum gray value may be the maximum value among the gray values of the foreground image pixels.
当前景图像像素值大于最小灰度值、且小于最大灰度值时,将增加该前景图像像素值的对比度;可选地,按照与像素最大值成一定比例的像素值作为该前景图像像素值;可选地,所述比例为:前景图像像素值与最小灰度值之差与最大灰度值与最小灰度值之差的比值,也就是,利用前景图像像素值与最小灰度值之差,除以最大灰度值和最小灰度值之差,得到所述比例。When the pixel value of the foreground image is larger than the minimum gray value and smaller than the maximum gray value, the contrast of the pixel value of the foreground image will be increased; Optionally, the ratio is: the ratio of the difference between the pixel value of the foreground image and the minimum gray value and the difference between the maximum gray value and the minimum gray value, that is, using the difference between the pixel value of the foreground image and the minimum gray value The difference is divided by the difference between the maximum gray value and the minimum gray value to obtain the ratio.
当前景图像像素值大于等于最大灰度值时,将该前景图像像素值取值为像素取值范围内的最大值,例如,像素最大值为255。When the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the pixel value range, for example, the maximum value of the pixel is 255.
用数学式表达为:Mathematically expressed as:
拉伸后的前景图像I f'(u,v)表示为: After stretching foreground image I f '(u, v) is expressed as:
Figure PCTCN2021103073-appb-000001
Figure PCTCN2021103073-appb-000001
其中,I min为最小灰度值,I max为最大灰度值,在上式中,像素取值范围为0~255。 Among them, I min is the minimum gray value, and I max is the maximum gray value. In the above formula, the pixel value ranges from 0 to 255.
步骤103,提取预处理后的当前帧中的图像特征点,并基于特征点计算描述子,得到当前帧的特征点和描述子,即提取预处理后的当前帧中的特征点,并基于特征点计算针对特征点的描述子,从而得到当前帧的特征点的描述子。其中,描述子形式与地图中地图点的描述子形式相同。示例性的,可采用ORB(Oriented FAST and Rotated BRIEF)、尺度不变特征变换(SIFT)、SURF(Speeded Up Robust Features)等特征。例如,地图点的特征点为ORB(Oriented FAST and Rotated BRIEF)特征点,则当前帧的特征点也为ORB特征点。其中,ORB为以FAST(Features from Accelerated Segment Test)特征点、BRIEF描述子为基础进行优化的特征点,其中添加有FAST方向的计算和BRIEF的抗旋转不变性。Step 103: Extract the image feature points in the preprocessed current frame, and calculate the descriptor based on the feature points to obtain the feature points and descriptors of the current frame, that is, extract the feature points in the preprocessed current frame, and based on the feature points The point calculation is based on the descriptor of the feature point, so as to obtain the descriptor of the feature point of the current frame. Among them, the descriptor form is the same as the descriptor form of the map point in the map. Exemplarily, features such as ORB (Oriented FAST and Rotated BRIEF), Scale Invariant Feature Transform (SIFT), SURF (Speeded Up Robust Features) and the like can be used. For example, if the feature point of the map point is the ORB (Oriented FAST and Rotated BRIEF) feature point, the feature point of the current frame is also the ORB feature point. Among them, ORB is a feature point optimized based on FAST (Features from Accelerated Segment Test) feature point and BRIEF descriptor, which adds the calculation of FAST direction and the anti-rotation invariance of Brief.
可选地,按照与所构建地图的特征点形成方式,提取预处理后的当前帧中的图像特征点。Optionally, the image feature points in the preprocessed current frame are extracted according to the manner of forming with the feature points of the constructed map.
在本实施例中,示例性的,可以采用ORB特征点。In this embodiment, exemplarily, ORB feature points may be used.
鉴于所采集的地面纹理图像通常尺度稳定,无需多尺度的特征进行构建,以增强特征的尺度不变性,故而可放弃金字塔图像的构建,而基于当前帧图像进行特征提取,以相当于基于源图像进行特征提取,从而减小特征提取需要的计算量,提高计算效率。其中,金字塔图像也称为图像金字塔,所谓图像金字塔为源自同一张图像的不同分辨率的图像集合。鉴于均匀而又显著的特征点能减少相机位姿计算时的定位误差,为了提高定位的性能和效率,可对提取的特征点进行筛选。图2为特征点筛选示意图。示例性的,以FAST特征为例介绍特征点的筛选过程,具体而言:在提取FAST(Features from Accelerated Segment Test)特征后,可以将当前帧划分为预定数量的网格,每个网格筛选出Q个FAST响应值最高的特征点予以保留,得到筛选后的特征点。其中,Q根据一帧目标图像中特征点的数量和所设特征点总数上限、网格中的帧点总数确定,不同网格所保留的特征点数不同。例如,一帧目标图像中,特征点总数的上限设定为100个,当前帧特征点的数量为2000个,则该帧目标图像中每20个特征点选出一个,如果某网格中有20个特征点,则该网格保留的特征点为1,即,Q=1。Q的确定用数学式表达为:In view of the fact that the collected ground texture images are usually scale-stable, multi-scale features do not need to be constructed to enhance the scale invariance of features, so the construction of pyramid images can be abandoned, and feature extraction based on the current frame image is equivalent to that based on the source image. Perform feature extraction, thereby reducing the amount of computation required for feature extraction and improving computational efficiency. Among them, the pyramid image is also called an image pyramid, and the so-called image pyramid is a collection of images of different resolutions derived from the same image. In view of the fact that uniform and significant feature points can reduce the positioning error in the calculation of camera pose, in order to improve the performance and efficiency of positioning, the extracted feature points can be screened. Figure 2 is a schematic diagram of feature point screening. Exemplarily, the FAST feature is used as an example to introduce the feature point screening process. Specifically: after the FAST (Features from Accelerated Segment Test) feature is extracted, the current frame can be divided into a predetermined number of grids, and each grid is filtered. The Q feature points with the highest FAST response value are retained, and the screened feature points are obtained. Among them, Q is determined according to the number of feature points in one frame of target image, the upper limit of the total number of feature points set, and the total number of frame points in the grid, and the number of feature points retained by different grids is different. For example, in a frame of target image, the upper limit of the total number of feature points is set to 100, and the number of feature points in the current frame is 2000, then select one feature point for every 20 feature points in the target image of this frame. If there are 20 feature points, the feature point retained by the grid is 1, that is, Q=1. The determination of Q is expressed mathematically as:
Figure PCTCN2021103073-appb-000002
Figure PCTCN2021103073-appb-000002
其中,符号
Figure PCTCN2021103073-appb-000003
表示向下取整。
Among them, the symbol
Figure PCTCN2021103073-appb-000003
Indicates rounded down.
其中,FAST响应值指FAST角点提取的得分值,即:该点成为FAST角点的得分是多少,其得分越高,FAST特征越显著。并且,其他类型特征点也有类似的得分值(响应值),用于衡量该点成为特征点的显著程度。并且,FAST可以看做是提取角点的一种算法,FAST角点定义为:若某像素与其周围邻域内足够多的像素点相差较大,则该像素可能是角点;其中,角点是图像很重要的特征,某方面属性特别突出的点,是在某些属性上强度最大或者最小的孤立点、线段的终点等,其对图像图形的理解和分析有很重要的作用;角点在保留图像图形重要特征的同时,可以有效地减少信息的数据量,使其信息的含量很高,有效地提高了计算的速度,有利于图像的可靠匹配,使得实时处理成为可能。Among them, the FAST response value refers to the score value extracted by the FAST corner point, that is, the score of the point becoming a FAST corner point, and the higher the score, the more significant the FAST feature is. Moreover, other types of feature points also have similar score values (response values), which are used to measure the significance of the point as a feature point. Moreover, FAST can be regarded as an algorithm for extracting corner points. FAST corner points are defined as: if a pixel is significantly different from enough pixels in its surrounding neighborhood, the pixel may be a corner point; among them, the corner point is The very important features of the image, the points with particularly prominent attributes in certain aspects are the isolated points with the largest or smallest intensity on some attributes, the end points of the line segments, etc., which play a very important role in the understanding and analysis of image graphics; While retaining the important features of image graphics, it can effectively reduce the amount of information data, make the information content very high, effectively improve the speed of calculation, and be conducive to the reliable matching of images, making real-time processing possible.
步骤104,鉴于在定位的过程中,如果遇到当前位置的地面纹理未曾建图,或地面纹理发生改变等情况,那么当前帧与地图点不能正常匹配,这时就会出现某一帧定位丢失的情况。因此,在定位过程中根据当前不同的定位状态,在当前帧采用不同的定位策略进行定位。即: Step 104, in view of the fact that in the process of positioning, if the ground texture of the current position has not been mapped, or the ground texture has changed, then the current frame and the map point cannot be properly matched, and then there will be a frame positioning loss. Case. Therefore, in the positioning process, different positioning strategies are used for positioning in the current frame according to different current positioning states. which is:
根据当前定位状态,确定与当前定位状态对应的定位策略,其中,定位状态包括未初始化状态,定位成功状态,以及重定位状态,各个定位状态分别对应的定位策略包括,未初始化状态下的初始化定位,定位成功状态下的正常定位,重定位状态下的重定位,以及各个状态之间的转换关系。其中,重定位状态又可以称为定位丢失状态。关于初始化定位、正常定位和重定位的相关内容,下文结合对于当前帧的具体定位过程进行说明。Determine a positioning strategy corresponding to the current positioning state according to the current positioning state, wherein the positioning state includes an uninitialized state, a successful positioning state, and a relocation state, and the positioning strategies corresponding to each positioning state include: initialized positioning in an uninitialized state , the normal positioning in the successful positioning state, the relocation in the relocation state, and the transition relationship between the various states. The relocation state may also be referred to as a location loss state. Regarding the content related to initialization positioning, normal positioning, and relocation, the following description will be given in conjunction with the specific positioning process for the current frame.
参见图3所示,图3为定位状态之间转换关系的一种示意图。其中,Referring to FIG. 3 , FIG. 3 is a schematic diagram of a transition relationship between positioning states. in,
当前定位状态为未初始化状态时,如果初始化定位成功,则转换至定位成功状态,如果初始化定位失败,保持当前未初始化状态;When the current positioning state is the uninitialized state, if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
当前定位状态为定位成功状态时,如果正常定位成功,则保持当前定位成功状态,如果正常定位失败,转换至定位丢失状态;When the current positioning status is the positioning successful status, if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
当前定位状态为定位丢失状态时,如果重定位成功,则转换至定位成功状态,如果重定位失败,判断连续定位失败的帧数是否超过设定的帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值,如果超过设定的帧数阈值或设定的第一距离阈值,则转换至未初始化状态,如果未超过设定的帧数阈值或设定的第一距离阈值,则保持当前定位丢失状态。When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning successful state. If the relocation fails, it is judged whether the number of frames of continuous positioning failure exceeds the set threshold of the number of frames, or whether the current frame and the last successful positioning are successful. Whether the distance between the poses exceeds the set first distance threshold, if it exceeds the set frame number threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set frame number threshold or the set first distance threshold, the current positioning loss state is maintained.
以当前帧为例,在利用当前帧进行定位时,若当前定位状态为未初始化状态,则对当前帧进行初始化定位,如果初始化定位成功,则当前定位状态转换至定位成功状态,如果初始化定位失败,保持当前未初始化状态;若当前定位状态为定位成功状态,则对当前帧进行正常定位,如果正常定位成功,则保持当前定位成功状态,如果正常定位失败,当前定位状态转换至定位丢失状态;若当前定位状态为定位丢失状态,则对当前帧进行重定位,如果重定位成功,则转换至定位成功状态,如果重定位失败,判断连续定位失败的帧数是否超过设定的帧数阈值,或者,判断当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值,如果超过设定的帧数阈值或设定的第一距离阈值,则当前定位状态转换至未初始化状态,如果未超过设定的帧数阈值或设定的第一距离阈值,则保持当前定位丢失状态。Taking the current frame as an example, when using the current frame for positioning, if the current positioning state is uninitialized, the current frame will be initialized and positioned. If the initialization and positioning is successful, the current positioning state will be converted to the positioning successful state. If the initialization and positioning fails. , keep the current uninitialized state; if the current positioning state is the positioning successful state, the current frame will be positioned normally; if the normal positioning is successful, the current positioning successful state will be maintained; if the normal positioning fails, the current positioning state will be converted to the positioning lost state; If the current positioning state is the positioning loss state, the current frame will be relocated. If the relocation is successful, it will be converted to the positioning successful state. If the relocation fails, it will be judged whether the number of consecutive failed frames exceeds the set frame number threshold. Or, determine whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, and if it exceeds the set frame number threshold or the set first distance threshold, the current positioning state transitions to In the uninitialized state, if the set frame number threshold or the set first distance threshold is not exceeded, the current positioning loss state is maintained.
基于定位状态之间转换关系,可以得到定位逻辑流程,所得到的定位逻辑的逻辑内容包括:对当前帧执行相应的定位策略所指示的定位过程,相应的定位策略为当前定位状态下的定位策略。参见图1和图4所示,图4为定位逻辑的一种示意图,包括,Based on the conversion relationship between the positioning states, the positioning logic flow can be obtained, and the logical content of the obtained positioning logic includes: executing the positioning process indicated by the corresponding positioning strategy on the current frame, and the corresponding positioning strategy is the positioning strategy in the current positioning state . Referring to FIG. 1 and FIG. 4, FIG. 4 is a schematic diagram of positioning logic, including,
步骤1041,判断当前帧是否是第一帧, Step 1041, determine whether the current frame is the first frame,
如果当前帧是第一帧,则说明没有上一帧的定位结果,判定当前定位状态为未初始化状态,执行初始化定位,如果定位成功,即图1中的匹配成功,则记录当前帧定位成功,转换至定位成功状态,如果定位失败,记录当前帧定位失败,保持当前未初始化状态;也就是说,如果当前帧为第一帧,则判定当前定位状态为未初始化状态,对当前帧执行未初始化状态下的初始化定位,并基于当前帧的定位结果,按照各个定位状态之间转换关系,更新当前定位状态。If the current frame is the first frame, it means that there is no positioning result of the previous frame, it is determined that the current positioning state is an uninitialized state, and initialization positioning is performed. Switch to the positioning success state. If the positioning fails, record the current frame positioning failure and keep the current uninitialized state; that is, if the current frame is the first frame, it is determined that the current positioning state is the uninitialized state, and the current frame is uninitialized. The initialization positioning in the state, and based on the positioning result of the current frame, according to the conversion relationship between the positioning states, the current positioning state is updated.
如果不是第一帧,执行步骤1042,If it is not the first frame, go to step 1042,
步骤1042,判断上一帧是否定位成功, Step 1042, determine whether the positioning of the previous frame is successful,
如果上一帧定位成功,则判定当前定位状态为定位成功状态,执行正常定位,如果定位成功,即图1中的匹配成功,则记录当前帧定位成功,保持当前定位成功状态,如果定位失败,记录当前帧定位失败,转换至定位丢失状态;也就是说,如果上一帧定位成功,则判定当前定位状态为定位成功状态,对当前帧执行定位成功状态下的正常定位,并基于当前帧的定位结果,按照各个定位状态之间转换关系,更新当前定位状态;If the positioning of the previous frame is successful, it is determined that the current positioning state is the successful positioning state, and normal positioning is performed. If the positioning is successful, that is, the matching in Figure 1 is successful, the current frame positioning is recorded successfully, and the current positioning successful state is maintained. If the positioning fails, Record the positioning failure of the current frame, and switch to the positioning loss state; that is, if the positioning of the previous frame is successful, the current positioning status is determined as the positioning successful state, and the normal positioning in the positioning successful state is performed for the current frame, and based on the current frame The positioning result, according to the conversion relationship between each positioning state, update the current positioning state;
如果上一帧定位失败,执行步骤1043,If the positioning of the previous frame fails, go to step 1043,
步骤1043,判断当前连续定位失败帧数是否超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值; Step 1043, judging whether the current continuous positioning failure frame number exceeds the frame number threshold, or whether the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold;
如果当前连续定位失败帧数超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则判定当前定位状态为未初始化状态,执行初始化定位,如果定位成功,即图1中的匹配成功,则记录当前帧定位成功,转换至定位成功状态,如果定位失败,记录当前帧定位失败,保持当前未初始化状态;也就是,判定当前状态为未初始化状态,对当前帧执行未初始化状态下的初始化定位,并基于当前帧的定位结果,按照各个定位状态之间转换关系,更新当前定位状态;如果当前连续定位失败帧数未超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,判定当前状态为重定位状态,执行重定位,如果定位成功,即图1中的匹配成功,则记录当前帧定位成功,转换至定位成功状态,如果定位失败,记录当前帧定位失败,保持当前定位丢失状态,返回执行步骤1043;也就是,判定当前定位状态为定位丢失状态,对当前帧执行定位丢失状态下的重定位,并基于当前帧的定位结果,按照各个定位状态之间转换关系,更新当前定位状态。If the current number of frames of continuous positioning failure exceeds the frame number threshold, or the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, the current positioning state is determined to be an uninitialized state, and initialization positioning is performed. , if the positioning is successful, that is, the matching in Figure 1 is successful, record the current frame positioning success, and switch to the positioning success state; if the positioning fails, record the current frame positioning failure, and keep the current uninitialized state; that is, determine the current state as uninitialized In the initialization state, the initialization positioning in the uninitialized state is performed on the current frame, and based on the positioning results of the current frame, the current positioning state is updated according to the conversion relationship between the positioning states; if the current number of consecutive failed positioning frames does not exceed the frame number threshold, Or, if the distance between the current frame and the pose with the most recent successful positioning does not exceed the set first distance threshold, determine that the current state is a repositioning state, and execute the repositioning. If the positioning is successful, that is, the matching in Figure 1 is successful. Then record the current frame positioning success, and switch to the positioning success state. If the positioning fails, record the current frame positioning failure, keep the current positioning loss state, and return to step 1043; Relocation in the state of location loss is performed, and based on the location result of the current frame, the current location state is updated according to the conversion relationship between each location state.
其中,in,
初始化定位是在第一帧或连续定位失败帧数超过阈值的情况下进行的定位策略。由于此时没有上一帧的定位结果,因此无法进行准确的位姿预测。初始化定位的定位过程中,通常采用搜索全局地图中的地图点或利用辅助信息等方法获得第一候选地图范围,将当前帧的特征点与全局地图中的地图点或第一候选地图范围中的地图点进行匹配,如果匹配成功,则根据匹配特征点计算当前帧的位姿,从而得到当前帧的定位结果。需要说明的是,对当前帧进行初始化定位时,也可以将地图中的所有地图点作为第一候选地图范围,或者,利用辅助信息获得第一候选地图范围;对第一候选地图范围内的地图点采用暴力匹配进行筛选,如果每两个地图点特征匹配度超过设定的第二匹配阈值,则随机删掉其中的一个地图点,得到修正后的第一候选地图范围;进而,将当前帧中的特征点与第一候选地图范围内的地图点进行匹配,如果匹配成功,则根据匹配特征点计算当前帧的位姿,从而得到当前帧的定位结果。其中,所谓暴力匹配即是:两两匹配,也就是将每一种匹配的可能性都计算并筛选一遍。Initial positioning is a positioning strategy performed when the first frame or the number of consecutive failed positioning frames exceeds the threshold. Since there is no positioning result of the previous frame at this time, accurate pose prediction cannot be performed. In the positioning process of initial positioning, the first candidate map range is usually obtained by searching map points in the global map or using auxiliary information, and comparing the feature points of the current frame with the map points in the global map or the first candidate map range. Map points are matched. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, so as to obtain the positioning result of the current frame. It should be noted that when initializing and positioning the current frame, all map points in the map can also be used as the first candidate map range, or the auxiliary information can be used to obtain the first candidate map range; The points are screened by violent matching. If the feature matching degree of each two map points exceeds the set second matching threshold, one of the map points will be randomly deleted to obtain the revised first candidate map range; then, the current frame The feature points in are matched with the map points within the first candidate map range. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, so as to obtain the positioning result of the current frame. Among them, the so-called brute force matching is: pairwise matching, that is, the possibility of each matching is calculated and screened.
正常定位是在上一帧定位成功的情况下进行的定位策略。在正常定位的定位过程中,在上一帧定位成功的情况下,通过位姿预测可以较准确的预测当前帧位姿,因此在进行特征匹配时,可以根据预测位姿的第一邻域确定第二候选地图范围,将当前帧的特征点与第二候选地图范围中的地图点进行匹配,如果匹配成功,则根据匹配特征点计算当前帧的位姿,从而得到当前帧的定位结果。Normal positioning is a positioning strategy performed when the positioning of the previous frame is successful. During the positioning process of normal positioning, when the positioning of the previous frame is successful, the pose prediction of the current frame can be used to predict the pose of the current frame more accurately. Therefore, when performing feature matching, it can be determined according to the first neighborhood of the predicted pose. In the second candidate map range, the feature points of the current frame are matched with the map points in the second candidate map range. If the matching is successful, the pose of the current frame is calculated according to the matching feature points, thereby obtaining the positioning result of the current frame.
重定位是在上一帧定位丢失的情况下进行的定位策略。在上一帧定位丢失的情况下,向前追溯定位未丢失与当前帧的最近一帧作为参考帧,根据参考帧预测出当前帧的位姿,也就是说,向前追 溯定位成功的历史帧中与当前帧最近的一帧并作为参考帧,根据参考帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿。在进行特征匹配时,根据预测位姿的第二邻域确定第三候选地图范围,并将当前帧的特征点与第三候选地图范围中的地图点采用暴力匹配的方法进行特征匹配,这样可以保证重定位的鲁棒性,当然并不局限于暴力匹配。如果重定位匹配成功,则根据匹配特征点计算当前帧的位姿,从而得到当前帧的定位结果。Relocation is a positioning strategy performed when the previous frame positioning is lost. In the case where the positioning of the previous frame is lost, the last frame that is not lost and the current frame is used as a reference frame, and the pose of the current frame is predicted according to the reference frame. The frame closest to the current frame is used as the reference frame. According to the inter-frame motion information from the reference frame to the current frame, the pose prediction of the current frame is performed to obtain the predicted pose of the current frame. When performing feature matching, the third candidate map range is determined according to the second neighborhood of the predicted pose, and the feature points of the current frame and the map points in the third candidate map range are matched by the method of brute force matching. Guaranteed robustness of relocation, of course, is not limited to brute force matching. If the relocation matching is successful, the pose of the current frame is calculated according to the matching feature points to obtain the positioning result of the current frame.
可选地,所述第一邻域的范围小于第二邻域的范围。Optionally, the range of the first neighborhood is smaller than the range of the second neighborhood.
需要强调的是,当前帧的位姿即为采集当前帧的移动机器人的位姿,而当前帧的定位结果即为移动机器人的当前定位结果。其中,移动机器人的位姿包括位置和姿态。It should be emphasized that the pose of the current frame is the pose of the mobile robot that collected the current frame, and the positioning result of the current frame is the current positioning result of the mobile robot. Among them, the pose of the mobile robot includes a position and an attitude.
并且,正常定位和重定位均符合位姿预测、特征匹配和位姿计算的处理流程,区别点在于具体的位姿预测方式和特征匹配方式,其中,位姿预测和特征匹配可以作为:将当前帧中的特征点与地图中的地图点进行匹配从而得到匹配特征点的过程中的两个环节。而初始化定位仅仅包括特征匹配和位姿计算的处理流程,特征匹配方式与正常定位和重定位中的特征匹配方式不同,针对初始化定位而言,特征匹配作为:将当前帧中的特征点与地图中的地图点进行匹配从而得到匹配特征点的过程中的一个环节。也就是说,针对将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点的过程,初始定位、正常定位和重定位三种定位方式下是不同的匹配方式;而当匹配特征点满足用于当前帧位姿解算的条件时,初始定位、正常定位和重定位三种定位方式下,根据匹配特征点计算当前帧的位姿,得到定位结果的具体实现过程可以相同。In addition, normal positioning and repositioning are in line with the processing flow of pose prediction, feature matching and pose calculation. The difference lies in the specific pose prediction method and feature matching method. Among them, pose prediction and feature matching can be used as: There are two steps in the process of matching the feature points in the frame with the map points in the map to obtain the matching feature points. The initialization positioning only includes the processing flow of feature matching and pose calculation. The feature matching method is different from the feature matching method in normal positioning and relocation. For the initialization positioning, the feature matching is as follows: the feature points in the current frame are compared with the map. It is a link in the process of matching the map points in to obtain the matching feature points. That is to say, for the process of matching the feature points in the current frame with the map points in the map to obtain the matching feature points, the three positioning methods of initial positioning, normal positioning and repositioning are different matching methods; and when matching When the feature points meet the conditions for the pose calculation of the current frame, in the three positioning modes of initial positioning, normal positioning and repositioning, the pose of the current frame is calculated according to the matching feature points, and the specific implementation process of obtaining the positioning result can be the same.
参见图1,步骤105,对定位成功的当前帧位姿进行图优化,以对定位结果进行优化,提高定位的准确性。Referring to FIG. 1, step 105, performing graph optimization on the pose of the current frame that has been successfully positioned, so as to optimize the positioning result and improve the accuracy of the positioning.
其中,所谓图优化也可以称为位姿图优化,其用于对定位结果进行优化,定位优化的目的是使输出的定位结果更准确,平滑,提升整个系统的准确性和鲁棒性。可选地,定位优化采用基于滑动窗口的非线性优化,优化的变量为滑动窗口内各图像帧的位姿,所述当前帧被增加至滑动窗口中,优化的约束为帧间匹配约束、和/或地图匹配约束,利用LM方法(最小二乘法),最小化帧间匹配误差和/或地图投影误差,得到优化后的当前帧位姿。其中,地图投影误差也称为地图匹配误差,并且,地图匹配约束所得到的误差为地图匹配误差,帧间匹配约束所得到的误差为帧间匹配误差。其中,Among them, the so-called graph optimization can also be called pose graph optimization, which is used to optimize the positioning results. The purpose of positioning optimization is to make the output positioning results more accurate and smooth, and improve the accuracy and robustness of the entire system. Optionally, the positioning optimization adopts a nonlinear optimization based on a sliding window, the optimized variable is the pose of each image frame in the sliding window, the current frame is added to the sliding window, and the optimization constraints are the inter-frame matching constraints, and /or map matching constraints, using the LM method (least square method) to minimize the inter-frame matching error and/or map projection error to obtain the optimized pose of the current frame. The map projection error is also called map matching error, and the error obtained by the map matching constraint is the map matching error, and the error obtained by the inter-frame matching constraint is the inter-frame matching error. in,
地图匹配约束为:第一匹配地图点反投影到当前帧上的像素位置与当前帧中与该第一匹配地图点匹配的第一匹配特征点的像素位置之间的误差,即两个像素位置之间的误差,该两个像素位置分别为:第一匹配地图点反投影到当前帧上的像素位置,以及当前帧中与该地图点匹配的第一匹配特征点的像素位置;或者,当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差,即两个空间位置之间的误差,该两个空间位置分别为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置,以及该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置;所述第一匹配特征点为:当前帧中的特征点与地图中的地图点进行匹配所得到匹配成功的特征点;第一匹配地图点为:被第一匹配特征点匹配成功的地图点;The map matching constraint is: the error between the pixel position of the first matching map point back-projected to the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, that is, two pixel positions The two pixel positions are respectively: the pixel position of the first matching map point back-projected on the current frame, and the pixel position of the first matching feature point matching the map point in the current frame; or, the current The error between the projection of the first matching feature point in the frame to the spatial position in the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system, that is, the difference between the two spatial positions. The two spatial positions are: the spatial position where the first matching feature point in the current frame is projected to the world coordinate system, and the first matching map point matched by the first matching feature point is in the world coordinate system. The spatial position of the first matching feature point is: the feature point in the current frame is matched with the map point in the map to obtain a successful matching feature point; the first matching map point is: the first matching feature point is successfully matched the map point;
帧间匹配约束为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置之间的误差, 即两个空间位置之间的误差,该两个空间位置分别为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置,以及当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置;或者,与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差,即两个像素位置之间的误差,该两个像素位置分别为:与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置,以及该第二匹配地图点反投影到上一关键帧的像素位置。另外,为了防止地图规模过大,可以将部分帧设为关键帧,加入地图中保存,那么,上一关键帧则为设定的关键帧中与当前帧采集时间最近的关键帧。关于任一视频帧是否可以作为关键帧的判定方式可以参见下文中,对于当前帧是否可以作为关键帧的描述内容。The inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, that is, the error between two spatial positions, the two spatial positions are respectively: the spatial position where the first matching feature point in the current frame is projected to the world coordinate system, and the current In the previous key frame of the frame, the second matching feature point that matches the first matching feature point is projected to the spatial position in the world coordinate system; or, the second matching map point that matches the second matching feature point is back-projected to the current The error between the pixel position of the frame and the pixel position of the second matching map point back-projected to the previous key frame, that is, the error between two pixel positions, the two pixel positions are: and the second matching feature point The matched second matching map point is back-projected to the pixel position of the current frame, and the second matching map point is back-projected to the pixel position of the previous key frame. In addition, in order to prevent the map from being too large, you can set some frames as keyframes and add them to the map to save. Then, the previous keyframe is the keyframe that is closest to the collection time of the current frame among the set keyframes. For the way of determining whether any video frame can be used as a key frame, please refer to the following description for whether the current frame can be used as a key frame.
参见图12所示,图12为当前帧的地图匹配约束、帧间匹配约束的一种示意图。其中,第二匹配特征点是第一匹配特征点集合的子集,与第二匹配特征点匹配的第二匹配地图点是:与第一匹配特征点匹配的第一匹配地图点集合的子集。第一匹配地图点反投影至当前帧的像素位置与该第一地图点匹配的第一匹配特征点的像素位置之间的误差,构成地图匹配约束;第二匹配地图点反投影至当前帧的像素位置,与该第二匹配地图点反投影当前帧的上一关键帧的像素位置之间的误差,构成帧间匹配约束。Referring to FIG. 12 , FIG. 12 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame. Wherein, the second matching feature point is a subset of the first matching feature point set, and the second matching map point matching the second matching feature point is: a subset of the first matching map point set matching with the first matching feature point . The error between the pixel position of the first matching map point back-projected to the current frame and the pixel position of the first matching feature point matched by the first map point constitutes a map matching constraint; the second matching map point is back-projected to the current frame. The error between the pixel position and the pixel position of the last key frame of the back-projected current frame of the second matching map point constitutes an inter-frame matching constraint.
所应理解的是,尽管本申请实施例所述地图匹配约束、帧间匹配约束是在图像坐标系下确定的,地图匹配约束和帧间匹配约束也可以在世界坐标系下确定。It should be understood that although the map matching constraints and the inter-frame matching constraints described in the embodiments of the present application are determined in the image coordinate system, the map matching constraints and the inter-frame matching constraints can also be determined in the world coordinate system.
参见图13所示,图13为世界坐标系下当前帧的地图匹配约束、帧间匹配约束的一种示意图。其中,当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差构成地图匹配约束,即两个空间位置之间的误差构成地图匹配约束,该两个空间位置分别为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置,以及该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置;当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置之间的误差构成帧间匹配约束,即两个空间位置之间的误差构成帧间匹配约束,该两个空间位置分别为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置,以及当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置。所述匹配特征点投影至世界坐标系中的空间位置按照相机模型,根据相机内参、匹配特征点的像素位置、匹配特征点所在的帧的位姿得到。Referring to FIG. 13 , FIG. 13 is a schematic diagram of map matching constraints and inter-frame matching constraints of the current frame in the world coordinate system. Wherein, the error between the spatial position of the first matching feature point in the current frame projected to the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system constitutes a map matching constraint , that is, the error between two spatial positions constitutes a map matching constraint, and the two spatial positions are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system, and the first matching feature point matches The spatial position of the first matching map point in the world coordinate system; the spatial position of the first matching feature point in the current frame projected to the world coordinate system matches the first matching feature point in the previous key frame of the current frame. The error between the second matching feature point projected to the spatial position in the world coordinate system constitutes the inter-frame matching constraint, that is, the error between the two spatial positions constitutes the inter-frame matching constraint, and the two spatial positions are: the current frame The first matching feature point in is projected to the spatial position in the world coordinate system, and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the spatial position in the world coordinate system. The spatial position of the matching feature point projected into the world coordinate system is obtained according to the camera model, according to the camera internal parameters, the pixel position of the matching feature point, and the pose of the frame where the matching feature point is located.
可选地,所述第一匹配特征点为最佳匹配特征点集合中的特征点。Optionally, the first matching feature point is a feature point in the best matching feature point set.
示例性的,在一种实现方式中,地图匹配约束为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差,帧间匹配约束为:与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差,相应的,Exemplarily, in an implementation manner, the map matching constraint is: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the first matching map point matching the first matching feature point is in the world. The error between the spatial positions in the coordinate system, the inter-frame matching constraints are: the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the previous The error between the pixel positions of the keyframes, correspondingly,
利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,包括,构建用于优化的目标函数,该用于优化的目标函数为:以当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,和/或,以当前滑动窗口中所有帧与其上一关键帧的 所有第二匹配地图点的帧间匹配误差之和所得到的第二结果;也就是说,该用于优化的目标函数可以为:以当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,也可以为:以当前滑动窗口中所有帧与其上一关键帧的所有第二匹配地图点的帧间匹配误差之和所得到的第二结果,还可以为:上述的第一结果和第二结果之和。Using the least squares method, the inter-frame matching error and/or map matching error is minimized, and the optimized current frame pose is obtained, including constructing an objective function for optimization. The objective function for optimization is: taking the current sliding window The first result obtained by the sum of the map matching errors of all the first matching feature points of all the frames in the current sliding window, and/or the inter-frame matching of all the second matching map points of all the frames in the current sliding window and its previous key frame The second result obtained by the sum of errors; that is, the objective function used for optimization can be: the first result obtained by the sum of the map matching errors of all the first matching feature points of all frames in the current sliding window , it can also be: the second result obtained by the sum of the inter-frame matching errors of all the frames in the current sliding window and all the second matching map points of the previous key frame, or can also be: the above-mentioned first result and the second result sum of results.
另外,基于上述的地图匹配约束可知,任一帧的所有第一匹配特征点的地图匹配误差为:该帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差;而基于上述的帧间匹配约束可知,任一帧与其上一关键帧的所有第二匹配地图点的帧间匹配误差为:与第二匹配特征点匹配的第二匹配地图点反投影到该帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差,其中,此处的第二匹配特征点为该帧的上一关键帧中,与该帧的第一匹配特征点匹配的特征点。In addition, based on the above-mentioned map matching constraints, it can be known that the map matching errors of all the first matching feature points in any frame are: The error between the spatial positions of the first matching map points in the point matching in the world coordinate system; and based on the above inter-frame matching constraints, it can be known that any frame is matched with all the second matching map points of the previous key frame. The error is: the error between the back-projection of the second matching map point matching the second matching feature point to the pixel position of the frame and the back-projection of the second matching map point to the pixel position of the previous key frame, where, here The second matching feature point of is the feature point matching the first matching feature point of the frame in the previous key frame of the frame.
以优化的约束为帧间匹配约束和地图匹配约束为例,用于优化的目标函数数学式表示为:Taking the optimization constraints as inter-frame matching constraints and map matching constraints as an example, the mathematical formula of the objective function used for optimization is expressed as:
Figure PCTCN2021103073-appb-000004
Figure PCTCN2021103073-appb-000004
其中,in,
e ik-map=p ik-(K(R iX k+t i)),e ijm-frame=(K(R iX m+t i))-(K(R jX m+t j)) e ik-map = p ik -(K(R i X k +t i )), e ijm-frame =(K(R i X m +t i ))-(K(R j X m +t j ) )
e ik-map为第一匹配地图点k反投影到当前帧i上的像素位置与当前帧i中与该地图点匹配的第一匹配特征点k的像素位置之间的地图匹配误差;p ik为当前帧i中第一匹配特征点k的像素坐标,K为相机内参矩阵,X k为地图中的第一匹配地图点k的三维坐标,R i、t i为通过第一匹配特征点得到的当前帧i的位姿。 e ik-map is the map matching error between the pixel position of the first matching map point k back-projected on the current frame i and the pixel position of the first matching feature point k that matches the map point in the current frame i; p ik is the pixel coordinate of the first matching feature point k in the current frame i, K is the camera internal parameter matrix, X k is the three-dimensional coordinate of the first matching map point k in the map, R i and t i are obtained through the first matching feature point the pose of the current frame i.
e ijm-frame为第二匹配地图点m在当前帧i和上一关键帧j的反投影误差,即帧间匹配误差,X m为当前帧i和上一关键帧j中的第二匹配特征点所匹配的第二匹配地图点m的三维坐标,R i、t i为当前帧i的位姿,R j、t j为上一关键帧j的位姿,可通过第二匹配特征点得到。 e ijm-frame is the back-projection error of the second matching map point m between the current frame i and the previous key frame j, that is, the matching error between frames, X m is the second matching feature in the current frame i and the previous key frame j a second matching point matching three-dimensional coordinates of the map point m, R i, t i is the current pose frame i, R j, t j is the pose of the previous key frame j, may be obtained by the second feature point matching .
I为滑动窗口中帧的总数,K为当前帧内第一匹配特征点的总数,j为滑动窗口中各帧的上一关键帧,M为当前帧中所反投影的第二匹配地图点总数。I is the total number of frames in the sliding window, K is the total number of first matching feature points in the current frame, j is the previous key frame of each frame in the sliding window, M is the total number of second matching map points back projected in the current frame .
在用于优化的目标函数中,In the objective function used for optimization,
代入根据当前帧i的位姿、地图中的第一匹配地图点k的三维坐标、相机内参矩阵K、当前帧i中的第一匹配特征点k的像素坐标所得到的地图匹配约束,作为地图匹配约束初始值;Substitute the map matching constraints obtained according to the pose of the current frame i, the three-dimensional coordinates of the first matching map point k in the map, the camera internal parameter matrix K, and the pixel coordinates of the first matching feature point k in the current frame i, as the map match constraint initial value;
代入根据当前帧i的位姿、地图中第二匹配地图点m的三维坐标、上一关键帧的位姿、相机内参矩阵K、所得到帧间匹配约束,作为帧间匹配约束初始值,Substitute the pose of the current frame i, the three-dimensional coordinates of the second matching map point m in the map, the pose of the previous key frame, the camera internal parameter matrix K, and the obtained inter-frame matching constraint as the initial value of the inter-frame matching constraint,
迭代求解使得目标函数取得最小值时的当前帧位姿,将该位姿作为当前定位结果。The iterative solution makes the current frame pose when the objective function obtains the minimum value, and the pose is taken as the current positioning result.
进一步地,还可以赋以地图匹配约束和帧间匹配约束不同的权值,来构建所述目标函数,以进一步提高定位的准确性,该用于优化的目标函数为:以第一权值加权当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,以及,以第二权值加权当前滑动窗口中各帧与其上一关键帧之间所有第二匹配地图点的帧间匹配误差之和所得到的第二结果,所累加的第一结果与第二结果之和;也就是说:该目标函数为:以第一权值加权第一结果和以第二权值加权第二结果后所得到的和值;用于优化的目标函数用数学式表示为:Further, different weights of map matching constraints and inter-frame matching constraints can also be assigned to construct the objective function to further improve the accuracy of positioning. The objective function for optimization is: weighted with the first weight. The first result obtained by the sum of the map matching errors of all the first matching feature points of all frames in the current sliding window, and the second weighted weighting of all the second key frames between each frame in the current sliding window and its previous key frame The second result obtained by the sum of the inter-frame matching errors of the matching map points, the sum of the accumulated first result and the second result; that is, the objective function is: weighting the first result with the first weight and taking The sum obtained after the second result is weighted by the second weight; the objective function used for optimization is mathematically expressed as:
Figure PCTCN2021103073-appb-000005
Figure PCTCN2021103073-appb-000005
其中,γ 1、γ 2为权值。 Among them, γ 1 and γ 2 are weights.
此外,在迭代求解当前帧位姿时,还可以将约束帧中所有各帧的位姿作为待优化的变量来进行优化。In addition, when iteratively solving the pose of the current frame, the pose of all frames in the constraint frame can also be used as a variable to be optimized for optimization.
在优化结束后,对当前滑动窗口进行优化,即识别当前帧是否可以作为关键帧以及是否可以存在于滑动窗口中,以进一步提高定位的准确性,即提高后续利用图像帧的定位的准确性。具体为:After the optimization is completed, the current sliding window is optimized, that is, whether the current frame can be used as a key frame and whether it can exist in the sliding window is identified, so as to further improve the accuracy of positioning, that is, to improve the accuracy of subsequent positioning using image frames. Specifically:
满足以下条件之一时,判定当前帧为关键帧:当前帧中第一匹配特征点的数量小于第一阈值,或,当前帧中第二匹配特征点的数量小于第二阈值。The current frame is determined as a key frame when one of the following conditions is met: the number of first matching feature points in the current frame is less than the first threshold, or the number of second matching feature points in the current frame is less than the second threshold.
若当前帧为非关键帧时,则在滑动窗口中删除该当前帧,若当前帧为关键帧,则判断当前滑动窗口中帧数量是否达到设定的第一帧阈值,如果达到第一帧阈值,则删除滑动窗口中最早添加的关键帧,如果未达到第一帧阈值,则不删除滑动窗口中最早添加的关键帧。If the current frame is a non-key frame, the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold, and if it reaches the first frame threshold , the earliest added keyframe in the sliding window is deleted, and if the first frame threshold is not reached, the earliest added keyframe in the sliding window is not deleted.
以下对步骤104中所涉及的各个定位策略进行说明。Each positioning strategy involved in step 104 will be described below.
参见图5所示,图5为初始化定位的一种流程示意图。当前帧在图像预处理和特征点提取之后,初始化定位包括,Referring to FIG. 5 , FIG. 5 is a schematic flowchart of initializing positioning. After image preprocessing and feature point extraction of the current frame, the initial positioning includes,
步骤501,将当前帧的特征点与地图中的地图点进行匹配,匹配成功时,得到第一匹配特征点,所得到的第一匹配特征点构成第一匹配特征点集合;这样,对于第一匹配特征点而言,将与第一匹配特征点匹配的第一匹配地图点的空间位置信息确定为该第一匹配特征点的空间位置信息,从而获得当前帧的二维特征点与地图中三维特征点的匹配。Step 501: Match the feature points of the current frame with the map points in the map. When the matching is successful, a first matching feature point is obtained, and the obtained first matching feature point constitutes a first matching feature point set; in this way, for the first matching feature point set; In terms of matching feature points, the spatial position information of the first matching map point matched with the first matching feature point is determined as the spatial position information of the first matching feature point, so as to obtain the two-dimensional feature point of the current frame and the three-dimensional feature point in the map. matching of feature points.
所述匹配可以是这样进行的:对于当前帧的任一特征点,计算当前帧中的特征点与地图中地图点描述子之间的匹配度是否小于设定的第一匹配阈值,如果小于设定的第一匹配阈值,则判定匹配,如果不小于设定的第一匹配阈值,判定不匹配;其中,匹配度可以用汉明距离来描述,匹配阈值为汉明距离阈值;The matching can be performed as follows: for any feature point of the current frame, calculate whether the matching degree between the feature point in the current frame and the map point descriptor in the map is less than the set first matching threshold, if it is less than the set first matching threshold. The determined first matching threshold is determined to match, and if it is not less than the set first matching threshold, it is determined to be mismatched; wherein, the matching degree can be described by the Hamming distance, and the matching threshold is the Hamming distance threshold;
在该步骤501中,地图中的地图点可以是地图中所有的地图点,这时采用暴力匹配的方法进行匹配,即,进行两两匹配时每一种匹配的可能性都进行计算;In this step 501, the map points in the map can be all map points in the map, and then the brute force matching method is used for matching, that is, the possibility of each matching is calculated when pairwise matching is performed;
可选地,为了减少匹配计算的计算量,利用辅助信息获得候选地图范围,即上述的第一候选地图范围,将当前帧中的特征点与第一候选地图范围内的地图点进行匹配,例如,设置易辨识的位置作为候选地图范围,如路径起终点位置,转弯位置,十字交叉位置。以网格路径地图为例,可设置所有路径的交点位置和角点位置作为候选地图范围,相应的,辅助信息可以为易辨识的位置的位置信息。Optionally, in order to reduce the calculation amount of the matching calculation, the auxiliary information is used to obtain the candidate map range, that is, the above-mentioned first candidate map range, and the feature points in the current frame are matched with the map points in the first candidate map range, for example , and set easily identifiable positions as candidate map ranges, such as the starting and ending positions of paths, turning positions, and crossing positions. Taking a grid path map as an example, the positions of intersections and corners of all paths can be set as candidate map ranges, and correspondingly, the auxiliary information can be position information of easily identifiable positions.
进一步地,由于实际下视纹理场地情况不一,极有可能出现相似纹理、重复纹理的情况,例如,地毯、地砖等,鉴于此,可以对候选地图范围内的地图点进行筛选,以防止存在特征相似或相同的地图点。地图点筛选可采用暴力匹配的方法进行,即对每两个地图点特征匹配,如果匹配度超过设定的第二匹配阈值,则说明两个地图点之间非常相似,需要随机删掉一个地图点,以防止在定位初始化的过程中存在误匹配的风险。参见图6所示,图6为地图点筛选的一种示意图,其中,虚线圈为被筛选去除掉的地图点,实线圈为候选地图位置。Further, because the actual situation of the texture site varies, it is very likely that similar textures and repeated textures will occur, such as carpets, floor tiles, etc. In view of this, the map points within the candidate map range can be screened to prevent the existence of Map points with similar or identical features. The map point screening can be performed by brute force matching, that is, for every two map point features, if the matching degree exceeds the set second matching threshold, it means that the two map points are very similar, and one map needs to be deleted randomly. point to prevent the risk of mis-matching during positioning initialization. Referring to FIG. 6 , FIG. 6 is a schematic diagram of map point screening, wherein the dotted circles are map points removed by screening, and the solid circles are candidate map positions.
重复执行该步骤501,直至当前帧的所有特征点都进行了匹配。Step 501 is repeated until all feature points of the current frame are matched.
步骤502,鉴于仅仅利用特征点的描述子进行特征点匹配时,可能存在一些误匹配点,较佳地,可以采用一定的方法筛选最佳第一匹配特征点,以提高匹配特征点的准确性,从而提高当前帧的位姿的准确性。故而,在该步骤502中,基于第一匹配特征点,可以采用随机抽样一致性(RANSAC)算法确定最佳匹配特征点集合,具体包括, Step 502, in view of the fact that there may be some mismatched points when only the descriptors of the feature points are used to match the feature points, preferably, a certain method can be used to screen the best first matching feature points to improve the accuracy of matching the feature points. , thereby improving the accuracy of the pose of the current frame. Therefore, in this step 502, based on the first matching feature point, a random sampling consistency (RANSAC) algorithm can be used to determine the best matching feature point set, which specifically includes:
步骤5021,从步骤501所得到第一匹配特征点集合中,随机选择用于计算当前帧位姿估计的匹配特征点,得到当前匹配特征点子集; Step 5021, from the first matching feature point set obtained in step 501, randomly select the matching feature points for calculating the pose estimation of the current frame, and obtain the current matching feature point subset;
步骤5022,基于利用当前匹配特征点子集中的匹配特征点所建立的空间位置信息与像素位置信息的映射,计算当前位姿,从而获得该匹配特征点子集的拟合位姿估计;也就是说,基于映射来计算当前位置,该映射为利用当前匹配特征点子集中的匹配特征点所建立的空间位置信息与像素位置信息的映射;并且,所计算得到的当前位姿可以作为该匹配特征点子集的拟合位姿估计; Step 5022, based on the mapping of the spatial position information and the pixel position information established by the matching feature points in the current matching feature point subset, calculate the current pose, thereby obtaining the fitting pose estimation of the matching feature point subset; that is, Calculate the current position based on the mapping, which is a mapping between the spatial position information and the pixel position information established by using the matching feature points in the current matching feature point subset; and, the calculated current pose can be used as the matching feature point subset. Fitting pose estimation;
该步骤5022中,计算当前位姿包括且不限于以下方法:透视N点定位PNP(2D-3D)方法,2维最邻近迭代2D-ICP(2D-2D),3维最邻近迭代3D-ICP(3D-3D),单应矩阵H(2D-2D)。In step 5022, calculating the current pose includes but is not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iterative 2D-ICP (2D-2D), 3-dimensional nearest neighbor iterative 3D-ICP (3D-3D), the homography matrix H(2D-2D).
以通过单应矩阵计算位姿为例。Take the calculation of the pose through the homography matrix as an example.
由于移动机器人是在平面中运动,空间位置坐标在同一平面z=0中,则单应矩阵与空间位置坐标矩阵的乘积对应为像素坐标矩阵,用数学式表达为:Since the mobile robot moves in a plane and the spatial position coordinates are in the same plane z=0, the product of the homography matrix and the spatial position coordinate matrix corresponds to the pixel coordinate matrix, which is expressed mathematically as:
Figure PCTCN2021103073-appb-000006
Figure PCTCN2021103073-appb-000006
其中单应矩阵的自由度为8,通过4个第一匹配特征点的空间位置和像素位置的对应关系,可以求出单应矩阵中每一个元素的值。对单应矩阵进行奇异值(SVD)分解,可以求得相应的旋转矩阵R和平移向量t,得到拟合位姿估计。The degree of freedom of the homography matrix is 8, and the value of each element in the homography matrix can be obtained through the correspondence between the spatial positions of the four first matching feature points and the pixel positions. By performing singular value (SVD) decomposition on the homography matrix, the corresponding rotation matrix R and translation vector t can be obtained, and the fitted pose estimation can be obtained.
步骤5023,由于拟合位姿估计是由子集中的匹配特征点得到的,为了考量第一匹配特征集合中的其他匹配特征点是否也符合当前计算出来的拟合位姿估计,因此,需要计算内点率。在该步骤5023中,根据拟合位姿估计以及相机内参,获取当前帧中所有的特征点的空间位置,得到所有特征点的投影点空间位置。 Step 5023, since the fitting pose estimation is obtained from the matching feature points in the subset, in order to consider whether other matching feature points in the first matching feature set also conform to the currently calculated fitted pose estimation, it is necessary to calculate the point rate. In this step 5023, the spatial positions of all feature points in the current frame are obtained according to the fitted pose estimation and the camera internal parameters, and the spatial positions of the projection points of all the feature points are obtained.
利用相机投影模型,可以将二维像素坐标点映射到三维坐标点,在本文中,这种映射称之为投影;反之,由三维坐标点映射到二维坐标点,这种映射称之为反投影。也就是说,特征点的空间位置是指特征点的投影点的空间位置。其中,特征点本身是存在于图像坐标系上的,可通过投影得到投影点的空间位置。投影点是存在于世界坐标系上的。Using the camera projection model, two-dimensional pixel coordinate points can be mapped to three-dimensional coordinate points. In this paper, this mapping is called projection; otherwise, from three-dimensional coordinate points to two-dimensional coordinate points, this mapping is called inverse projection. That is, the spatial position of the feature point refers to the spatial position of the projection point of the feature point. Among them, the feature point itself exists in the image coordinate system, and the spatial position of the projection point can be obtained by projection. Projection points exist in the world coordinate system.
在该步骤5023中,将当前帧中的所有第一匹配特征点投影至三维空间位置,即,投影至地图中,作为投影点的空间位置。故而,对于当前帧中的任一第一匹配特征点i,可以求得其三维空间坐标。In this step 5023, all the first matching feature points in the current frame are projected to three-dimensional spatial positions, that is, projected into a map, as the spatial positions of the projected points. Therefore, for any first matching feature point i in the current frame, its three-dimensional space coordinates can be obtained.
数学式可以表达为:The mathematical formula can be expressed as:
p i=K(RX i+t) p i =K(RX i +t)
其中,p i为当前帧中第一匹配特征点i的像素坐标,R、t为当前拟合位姿估计,X i为第一匹配特征点i投影至地图的三维空间坐标,即投影点的三维空间坐标,K为相机内参矩阵。 Among them, p i is the pixel coordinate of the first matching feature point i in the current frame, R and t are the current fitting pose estimation, and X i is the three-dimensional space coordinate of the first matching feature point i projected to the map, that is, the projection point Three-dimensional space coordinates, K is the camera internal parameter matrix.
步骤5024,对于第一匹配特征点集合中的每个第一匹配特征点,判断当前帧中该第一匹配特征点的投影点与地图中该第一匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值,如果小于设定的第二距离阈值,则判定该第一匹配特征点为内点,其中,在判断过程中,可以根据该第一匹配特征点的投影点空间位置来进行判断。 Step 5024, for each first matching feature point in the first matching feature point set, determine whether the distance between the projection point of the first matching feature point in the current frame and the map point matched by the first matching feature point in the map is less than If the set second distance threshold is smaller than the set second distance threshold, it is determined that the first matching feature point is an inner point, wherein, in the judgment process, the spatial position of the projection point of the first matching feature point can be to judge.
反复执行该步骤5024,直至所有第一匹配特征点都被进行了是否是内点的判定。 Step 5024 is repeatedly performed until all the first matching feature points are determined whether they are interior points.
步骤5025,统计当前内点数量,将当前内点数量与第一匹配特征点数量的比值作为内点率;比值越大,内点率越高,则说明拟合程度越高,拟合位姿估计越佳,所随机选择的匹配特征点越佳。Step 5025: Count the number of current inliers, and use the ratio of the current number of inliers to the number of first matching feature points as the inlier rate; the larger the ratio, the higher the inlier rate, which means the higher the degree of fitting, the better the fitting pose. The better the estimation, the better the randomly selected matching feature points.
步骤5026,判断当前统计的内点数量是否是历次迭代中的最大,如果是历次迭代中的最大,则将当前内点所构成的集合作为当前最佳匹配特征点集合,然后执行步骤5027,如果不是历次迭代中的最大,对当前最佳匹配特征点集合不进行更新,而直接执行步骤5027,Step 5026, determine whether the number of inliers currently counted is the largest in the previous iterations, if it is the largest in the previous iterations, then take the set formed by the current inliers as the current best matching feature point set, and then execute step 5027, if is not the largest in previous iterations, the current best matching feature point set is not updated, but step 5027 is directly executed,
步骤5027,判断是否达到结束条件,如果达到结束条件,则执行步骤503,如果未达到结束条件,返回步骤5021,以便重新随机选择匹配特征点子集来进行拟合位姿估计,从而进行从拟合位姿估计至最佳匹配特征点集合确认的循环,即循环执行S5021-S5027;Step 5027, determine whether the end condition is reached, if the end condition is met, then execute step 503, if the end condition is not met, return to step 5021, so as to randomly select a subset of matching feature points for fitting pose estimation, so as to carry out the fitting method. The cycle of the pose estimation to the best matching feature point set confirmation, that is, the cycle of executing S5021-S5027;
其中,结束条件包括至少以下条件之一:The end condition includes at least one of the following conditions:
1)内点率满足预设的条件,1) The interior point rate satisfies the preset conditions,
2)迭代次数满足预设的条件;为了在置信度η的条件下,在迭代循环过程中,至少有一次随机选择,使得选择的m个点均为内点,这样有利于在循环的过程中,至少有一次能取得拟合位姿估计的最佳值。因此,迭代次数α应该满足以下条件:2) The number of iterations satisfies the preset conditions; in order to make at least one random selection during the iterative loop process under the condition of confidence η, so that the selected m points are all interior points, which is beneficial to the process of the loop. , the best value of the fitted pose estimate can be obtained at least once. Therefore, the number of iterations α should satisfy the following conditions:
Figure PCTCN2021103073-appb-000007
Figure PCTCN2021103073-appb-000007
其中,m为子集的大小,即,子集中匹配特征点的数量;置信度一般设置在0.95~0.99的范围内。ε为内点率,在一般情况下,ε通常是未知的,因此可以取最坏条件下内点的比例,或者在初始状态下设置为最坏条件下的比例,然后随着迭代次数,不断更新为当前最大的内点率。Among them, m is the size of the subset, that is, the number of matching feature points in the subset; the confidence level is generally set in the range of 0.95 to 0.99. ε is the interior point rate. In general, ε is usually unknown, so the proportion of interior points under the worst condition can be taken, or the proportion under the worst condition can be set in the initial state, and then with the number of iterations, the Update to the current maximum inlier rate.
3)子集全部是内点的概率满足要求设定的置信度的要求,具体为,将选取的子集看作为“全部是内点”或“不全部是内点”这两种结果的二项分布,而前者的概率为p=1/ε m。对于p足够小的情况下,可以将其看作为一种泊松分布,因此,在i次循环中,有θ个“子集全部是内点”的概率可以表达为: 3) The probability that the subsets are all interior points satisfies the required confidence level. Specifically, the selected subset is regarded as the two results of "all interior points" or "not all interior points". term distribution, while the probability of the former is p=1/ε m . For the case where p is small enough, it can be regarded as a Poisson distribution. Therefore, in the i cycle, the probability that there are θ "subsets are all interior points" can be expressed as:
Figure PCTCN2021103073-appb-000008
Figure PCTCN2021103073-appb-000008
其中,λ表示在i次循环中,“子集全都是内点”的选取次数的期望。Among them, λ represents the expectation of the number of times that "the subsets are all interior points" in the i rounds.
例如,希望在这i次迭代循环中所选子集“没有一个全是内点”的概率小于某个置信度,即:p(0,λ)=e <1-η,以置信度为95%为例,λ约等于3,表示在95%置信度下,在i次循环中,平均可以选到3次“好”的子集。 For example, it is hoped that the probability that "none of the selected subsets are all interior points" in this i iteration loop is less than a certain confidence level, that is: p(0, λ) = e - λ < 1 - η, with confidence level Taking 95% as an example, λ is approximately equal to 3, which means that under 95% confidence, in i cycles, an average of 3 "good" subsets can be selected.
步骤503,判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件, Step 503, judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation,
如果满足用于当前帧位姿解算的条件,则进行当前帧的位姿计算,计算当前位姿包括且不限于以下方法:透视N点定位PNP(2D-3D)方法,2维最邻近迭代2D-ICP(2D-2D),3维最邻近迭代 3D-ICP(3D-3D),单应矩阵H(2D-2D);If the conditions for the pose calculation of the current frame are met, the pose calculation of the current frame is performed, and the calculation of the current pose includes but is not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iteration 2D-ICP(2D-2D), 3D nearest neighbor iterative 3D-ICP(3D-3D), homography matrix H(2D-2D);
如果不满足用于当前帧位姿解算的条件,判定当前帧定位失败。需要说明的是,在不采用最佳匹配特征点集合的情况下,也就是,在基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点后,可以直接判断匹配特征点是否满足用于当前帧位姿解算的条件,并在判断结果为是时,根据匹配特征点计算当前帧的位姿,得到定位结果,其中,根据匹配特征点计算当前帧的位姿的方式包括并不局限于以下方法:透视N点定位PNP(2D-3D)方法,2维最邻近迭代2D-ICP(2D-2D),3维最邻近迭代3D-ICP(3D-3D),单应矩阵H(2D-2D)。If the conditions for the current frame pose calculation are not met, it is determined that the current frame positioning fails. It should be noted that in the case of not using the best matching feature point set, that is, based on the positioning strategy, the feature points in the current frame are matched with the map points in the map, and after the matching feature points are obtained, you can directly Determine whether the matching feature points meet the conditions for the current frame pose calculation, and when the judgment result is yes, calculate the pose of the current frame according to the matching feature points, and obtain the positioning result, wherein the current frame is calculated according to the matching feature points. The methods of pose include but are not limited to the following methods: perspective N-point positioning PNP (2D-3D) method, 2-dimensional nearest neighbor iterative 2D-ICP (2D-2D), 3-dimensional nearest neighbor iterative 3D-ICP (3D-3D) ), the homography matrix H(2D-2D).
在该步骤503中,实施方式之一,鉴于不同的位姿计算方法所要求的位姿解算的条件是不同的,以单应矩阵H(2D-2D)为例,解算出位姿至少要4个匹配特征点,故而,判断最佳匹配特征点集合中匹配特征点的数量是否满足用于位姿解算的条件。In this step 503, one of the embodiments, in view of the different pose calculation methods required by different pose calculation conditions are different, taking the homography matrix H(2D-2D) as an example, to solve the pose at least There are 4 matching feature points, therefore, it is judged whether the number of matching feature points in the best matching feature point set satisfies the conditions for pose calculation.
实施方式之二,当由于多个候选地图范围使得最佳匹配特征点集合有多个时,需要通过确定唯一的最佳匹配特征点集合,以便基于当前帧与多个候选地图范围的匹配情况来判断是否有某一候选地图范围可以满足匹配成功的条件。具体是:In the second embodiment, when there are multiple sets of best matching feature points due to multiple candidate map ranges, it is necessary to determine a unique set of best matching feature points, so as to determine the best matching feature point set based on the matching situation between the current frame and multiple candidate map ranges. Determine whether there is a candidate map range that meets the conditions for successful matching. specifically is:
根据最佳匹配特征点集合中的匹配特征点数量,也就是根据内点数量,对各个最佳匹配特征点集合赋予衡量当前帧与候选地图范围匹配程度的权值;该权值还可以根据当前帧特征点提取数量,特征点分布情况,匹配特征点初始数量与最佳匹配特征点集合中的匹配特征点数量(筛选得到的内点数量)之一或其任意组合,来确定权值。According to the number of matching feature points in the best matching feature point set, that is, according to the number of interior points, each best matching feature point set is given a weight to measure the matching degree between the current frame and the candidate map range; the weight can also be based on the current frame. The number of frame feature points extracted, the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set (the number of inliers obtained by screening) or any combination thereof to determine the weight.
根据设定的权值阈值和最大权值,确定唯一最佳匹配特征点集合,从而判定最佳匹配特征点集合满足用于位姿解算的条件;例如,采用权值阈值与唯一最大权值相结合,即,筛选出权值大于权值阈值的最佳匹配特征点集合,按照最大权值与次大权值差异最大的原则,从筛选出的最佳匹配特征点集合中选择唯一的最佳匹配特征点集合。According to the set weight threshold and maximum weight, determine the unique best matching feature point set, so as to determine that the best matching feature point set meets the conditions for pose calculation; for example, adopt the weight threshold and the unique maximum weight Combined, that is, filter out the best matching feature point set whose weight is greater than the weight threshold, and select the unique best matching feature point set from the best matching feature point set according to the principle that the difference between the largest weight and the next largest weight is the largest. The best matching feature point set.
参见图7所示,图7为正常定位的一种流程示意图。当前帧在图像预处理和特征点提取之后,正常定位包括,Referring to FIG. 7 , FIG. 7 is a schematic flow chart of normal positioning. After image preprocessing and feature point extraction of the current frame, normal positioning includes,
步骤701,鉴于上一帧的定位结果已被获取,根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到预测位姿,以便利用该预测位姿确定第二候选地图范围,从而提高匹配的效率; Step 701, in view of the fact that the positioning result of the previous frame has been obtained, according to the inter-frame motion information from the previous frame to the current frame, perform pose prediction on the current frame to obtain the predicted pose, so as to use the predicted pose to determine the second candidate. map range, thereby improving the efficiency of matching;
位姿预测的方法包括,Pose prediction methods include,
实施方式一,通过轮式里程计或惯性测量元件(IMU)获得上一帧到当前帧的帧间位姿变换,基于上一帧的定位结果、以及帧间位姿变换,求得当前帧的预测位姿。Embodiment 1: Obtain the inter-frame pose transformation from the previous frame to the current frame through a wheeled odometer or an inertial measurement unit (IMU), and obtain the current frame based on the positioning result of the previous frame and the inter-frame pose transformation. Predict the pose.
实施方式二,通过视觉里程计(VO)获得上一帧到当前帧的帧间位姿变换,基于上一帧的定位结果、以及帧间位姿变换,求得当前帧的预测位姿。该实施方式仅需要图像信息,不需要额外的惯性信息。In the second embodiment, the inter-frame pose transformation from the previous frame to the current frame is obtained through visual odometry (VO), and the predicted pose of the current frame is obtained based on the positioning result of the previous frame and the inter-frame pose transformation. This implementation requires only image information, no additional inertial information.
实施方式三,根据若干已获得定位结果的历史帧,预测上一帧到当前帧的帧间位姿变换,基于上一帧的定位结果、以及帧间位姿变换,求得当前帧的预测位姿。该实施方式不依赖当前帧的任何信息。Embodiment 3: According to several historical frames for which positioning results have been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted position of the current frame based on the positioning results of the previous frame and the inter-frame pose transformation. posture. This implementation does not rely on any information about the current frame.
实施方式四,至少采用实施方式一至三中的两实施方式,分别求得当前帧的第一预测位姿,得到至少两个第一预测位姿;采用卡尔曼滤波器对所述至少两个第一预测位姿进行滤波,得到滤波后 的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿,或者,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,得到优化后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;In Embodiment 4, at least two of Embodiments 1 to 3 are used to obtain the first predicted poses of the current frame respectively, and at least two first predicted poses are obtained; Kalman filter is used to analyze the at least two first predicted poses. A predicted pose is filtered to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame, or, a nonlinear optimization method is used, based on the at least two first predicted poses The pose is optimized to obtain the optimized second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame;
例如,根据各个实施方式所得到的各个误差项,构建非线性优化的目标函数,数学表达式为:For example, the objective function of nonlinear optimization is constructed according to the various error terms obtained in various embodiments, and the mathematical expression is:
Figure PCTCN2021103073-appb-000009
Figure PCTCN2021103073-appb-000009
其中,e ijs表示采用实施方式s时的误差项,
Figure PCTCN2021103073-appb-000010
T i表示上一帧i的位姿,即上一帧i的定位结果,T j表示当前帧j的第一预测位姿,ΔT ij表示上一帧i到当前帧j之间的帧间位姿变换,ξ j为当前帧预测位姿的李代数表示,S为所采用的实施方式的总数。
Among them, e ijs represents the error term when the implementation s is adopted,
Figure PCTCN2021103073-appb-000010
T i represents the pose of the previous frame i, that is, the positioning result of the previous frame i, T j represents the first predicted pose of the current frame j, ΔT ij represents the inter-frame position between the previous frame i and the current frame j Pose transformation, ξ j is the Lie algebra representation of the predicted pose of the current frame, and S is the total number of implementations adopted.
将上一帧i的位姿T i、不同实施方式所得到的当前帧j的第一预测位姿T j以及帧间位姿变换ΔT ij作为初始值代入目标函数,求解使得目标函数取得最小值时的位姿。 The pose T i of the previous frame i, the first predicted pose T j of the current frame j obtained by different implementations, and the inter-frame pose transformation ΔT ij are substituted into the objective function as initial values, and the solution makes the objective function obtain the minimum value. posture at the time.
步骤702,根据当前帧的预测位姿,确定第二候选地图范围,将当前帧中的特征点与第二候选地图范围内的地图点进行匹配,当匹配成功时,得到第三匹配特征点,然后执行步骤703, Step 702, according to the predicted pose of the current frame, determine the second candidate map range, match the feature points in the current frame with the map points in the second candidate map range, when the matching is successful, obtain the third matching feature point, Then perform step 703,
在该步骤702中,一种实施方式是,参见图9a所示,以当前帧的预测位姿所确定的地图位置为中心,将该中心的第一邻域确定为第二候选地图范围;匹配的方式可以采用暴力匹配,即暴力计算当前帧所有特征点与候选地图范围内的特征点的描述子距离,选取描述子距离最小的特征点作为匹配特征点。该方式适合预测位姿的置信度较低或待匹配的特征点数量较少时使用。In this step 702, one embodiment is, as shown in FIG. 9a, taking the map position determined by the predicted pose of the current frame as the center, and determining the first neighborhood of the center as the second candidate map range; matching The method can use brute force matching, that is, violently calculate the descriptor distance between all feature points in the current frame and the feature points in the candidate map range, and select the feature point with the smallest descriptor distance as the matching feature point. This method is suitable for use when the confidence of the predicted pose is low or the number of feature points to be matched is small.
另一种实施方式是,参见图9b所示,对于当前帧的每个特征点,根据该特征点的投影范围,确定该特征点的第二候选地图范围,即,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第一邻域作为该特征点第二候选地图范围,计算当前帧特征点与第二候选地图范围内的地图点的匹配,选取描述子距离最小的特征点对作为匹配特征点。其中,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置所采用的计算公式可以为步骤5023的相关描述中所示出的关于p i的表达式。 Another embodiment is, as shown in FIG. 9b, for each feature point of the current frame, according to the projection range of the feature point, the second candidate map range of the feature point is determined, that is, according to the predicted pose of the current frame. and the pixel coordinates of the feature point, calculate the projection point position of the feature point projected into the map, and take the first neighborhood of the projection point as the center as the second candidate map range of the feature point, calculate the current frame feature point and the first For the matching of map points within the range of two candidate maps, the feature point pair with the smallest descriptor distance is selected as the matching feature point. Wherein, according to the predicted pose of the current frame and the pixel coordinates of the feature point, the calculation formula used to calculate the position of the projection point projected from the feature point to the map may be the formula about p i shown in the relevant description of step 5023 expression.
较佳地,第一邻域可以是以中心为圆心、设定半径所覆盖的地图范围。Preferably, the first neighborhood may be a map area covered by a set radius with the center as the center.
重复执行该步骤702,直至当前帧的所有特征点都进行了匹配。Step 702 is repeated until all feature points of the current frame are matched.
步骤703,基于第三匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,该步骤703与步骤502相同, Step 703, based on the third matching feature point, adopt the random sampling consistency algorithm to determine the best matching feature point set, this step 703 is the same as step 502,
步骤704,判断最佳匹配特征点集合中匹配特征点的数量是否满足用于当前帧位姿解算的条件,如果满足用于当前帧位姿解算的条件,则进行当前帧的位姿计算,如果不满足用于当前帧位姿解算的条件,判定当前帧定位失败。该步骤703与步骤503相同。 Step 704, determine whether the number of matching feature points in the best matching feature point set satisfies the conditions for the current frame pose calculation, if the conditions for the current frame pose calculation are met, then perform the current frame pose calculation , if the conditions for the current frame pose calculation are not met, it is determined that the current frame positioning fails. This step 703 is the same as step 503 .
参见图8所示,图8为重定位的一种流程示意图。当前帧在图像预处理和特征点提取之后,重定位包括,Referring to FIG. 8, FIG. 8 is a schematic flowchart of a relocation. After image preprocessing and feature point extraction of the current frame, relocation includes,
步骤801,由于上一帧定位失败,根据定位成功的历史帧,追溯历史帧中最近的一帧作为参考帧,根据参考帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到预测位姿,以便利用该预测位姿确定第三候选地图范围,从而提高匹配的效率; Step 801, since the positioning of the previous frame fails, according to the historical frame of the successful positioning, trace the latest frame in the historical frame as a reference frame, and perform pose prediction on the current frame according to the inter-frame motion information from the reference frame to the current frame, and obtain: Predicting the pose, so as to use the predicted pose to determine the third candidate map range, thereby improving the efficiency of matching;
其中,位姿预测方法与步骤701中的位姿预测方法相同,只需将参考帧当作上一帧即可。The pose prediction method is the same as the pose prediction method in step 701, and only the reference frame needs to be regarded as the previous frame.
步骤802,根据当前帧的预测位姿,确定第三候选地图范围,将当前帧中的特征点与第三候选地图范围内的地图点进行匹配,当匹配成功时,得到第四匹配特征点,然后执行步骤803, Step 802, according to the predicted pose of the current frame, determine the third candidate map range, match the feature points in the current frame with the map points in the third candidate map range, when the matching is successful, obtain the fourth matching feature point, Then step 803 is executed,
在该步骤802中,一种实施方式是,以当前帧的预测位姿所确定的地图位置为中心,将该中心的第二邻域确定为第三候选地图范围;匹配的方式可以采用暴力匹配,以提高重定位的鲁棒性。In this step 802, an implementation manner is to take the map position determined by the predicted pose of the current frame as the center, and determine the second neighborhood of the center as the third candidate map range; the matching method can be brute force matching. , to improve the robustness of relocation.
另一种实施方式是,对于当前帧的每个特征点,根据该特征点的投影范围,确定该特征点的第三候选地图范围,即,根据当前帧的预测位姿和该特征点的像素坐标,计算当前帧特征点投影到地图中的投影点位置,以该投影点位置为中心的第二邻域作为该特征点的第三候选地图范围,计算当前帧特征点与第三候选地图范围内的地图点的匹配,选取描述子距离最小的特征点对作为匹配特征点。Another implementation is that, for each feature point of the current frame, the third candidate map range of the feature point is determined according to the projection range of the feature point, that is, according to the predicted pose of the current frame and the pixels of the feature point Coordinates, calculate the position of the projection point projected from the feature point of the current frame to the map, the second neighborhood centered on the position of the projection point is used as the third candidate map range of the feature point, and calculate the feature point of the current frame and the third candidate map range In the matching of map points within, the feature point pair with the smallest descriptor distance is selected as the matching feature point.
可选地,第二邻域可以是以中心为圆心、设定半径所覆盖的地图范围。Optionally, the second neighborhood may be a map range covered by a set radius with the center as the center.
重复执行该步骤802,直至当前帧的所有特征点都进行了匹配。Step 802 is repeated until all feature points of the current frame are matched.
步骤803,基于第四匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,该步骤803与步骤502相同, Step 803, based on the fourth matching feature point, adopt the random sampling consistency algorithm to determine the best matching feature point set, this step 803 is the same as step 502,
步骤804,判断最佳匹配特征点集合中匹配特征点的数量是否满足用于位姿解算的条件,如果满足用于位姿解算的条件,则进行当前帧的位姿计算,如果不满足用于位姿解算的条件,判定当前帧定位失败。 Step 804, determine whether the number of matching feature points in the best matching feature point set satisfies the conditions for pose calculation, if it meets the conditions for pose calculation, then perform the pose calculation of the current frame, if not The condition used for pose calculation, it is determined that the current frame positioning fails.
在重定位成功计算当前帧位姿时,由于最佳匹配特征点集合是通过参考帧来确定的,存在较大误差的概率较高,较佳地,采用LM优化的方法来求解。When relocation successfully calculates the pose of the current frame, since the best matching feature point set is determined by the reference frame, there is a high probability of a large error. Preferably, the LM optimization method is used to solve the problem.
本实施例提供的视觉定位方法,对于采用纹理地图的定位而言,相比于传统二维码定位,无需对地面进行改造,利用自然纹理即可定位,成本较低;通过不同定位状态下的定位策略而确定的定位逻辑,增强了局部纹理变化或局部纹理缺失情形下的适应性,无论是纹理地图还是非纹理的视觉地图,都不需要预先设定精确地标定点,图像获取简便,并且定位过程中可以持续与地图进行匹配而不会存在大幅跳变,在部分建图的区域内,可以任意路径定位,而不局限于建图的路径上,提高了定位过程中的鲁棒性;不同定位策略在位姿预测、特征匹配处理上的不同,既提高了定位的准确性,又有利于提高定位的效率。Compared with the traditional two-dimensional code positioning, the visual positioning method provided in this embodiment does not need to transform the ground for positioning using texture maps, and can use natural textures for positioning, and the cost is low; The positioning logic determined by the positioning strategy enhances the adaptability in the case of local texture changes or lack of local textures. Whether it is a texture map or a non-textured visual map, there is no need to pre-set accurate calibration points, image acquisition is easy, and positioning During the process, it can continue to match with the map without large jumps. In some areas where the map is built, it can be located on any path, not limited to the path of the map, which improves the robustness of the positioning process; different Different positioning strategies in pose prediction and feature matching processing not only improve the accuracy of positioning, but also help to improve the efficiency of positioning.
参见图10所示,图10为本申请的基于视觉地图的视觉定位装置的一种示意图。该装置包括,Referring to FIG. 10 , FIG. 10 is a schematic diagram of a visual positioning device based on a visual map of the present application. The device includes,
图像采集模块1001,采集当前图像,得到当前帧;The image acquisition module 1001 collects the current image to obtain the current frame;
特征提取模块1002,基于当前帧,进行特征点提取,得到当前帧的特征点;The feature extraction module 1002, based on the current frame, performs feature point extraction to obtain the feature points of the current frame;
定位模块1003,根据当前定位状态确定定位策略;基于定位策略,为当前帧确定地图中候选地图范围,将当前帧中的特征点与候选地范围内的地图点进行匹配,得到匹配特征点,当匹配特征点满足用于当前帧位姿解算的条件时,根据匹配特征点计算当前帧的位姿,得到定位结果。The positioning module 1003 determines a positioning strategy according to the current positioning state; based on the positioning strategy, a candidate map range in the map is determined for the current frame, and the feature points in the current frame are matched with the map points within the candidate range to obtain matching feature points. When the matching feature points meet the conditions for solving the pose of the current frame, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
其中,所述定位模块1003包括,Wherein, the positioning module 1003 includes:
定位状态子模块1004,根据上一帧的定位结果、当前连续定位失败帧数确定当前定位状态,The positioning state sub-module 1004 determines the current positioning state according to the positioning result of the previous frame and the current number of frames with continuous positioning failures,
定位策略子模块1005,根据当前定位状态确定定位策略,所述定位策略包括,未初始化状态下的初始化定位,定位成功状态下的正常定位,重定位状态下的重定位,以及各个定位状态之间转换关系;The positioning strategy sub-module 1005 determines a positioning strategy according to the current positioning state, and the positioning strategy includes: initialization positioning in an uninitialized state, normal positioning in a successful positioning state, relocation in a relocation state, and between each positioning state conversion relationship;
定位逻辑子模块1006,根据各个定位状态以及各个定位状态之间转换关系,生成定位逻辑;其中,所述定位逻辑的逻辑内容包括:对当前帧执行相应的定位策略所指示的定位过程,所述相应的定位策略为当前定位状态下的定位策略;The positioning logic sub-module 1006 generates positioning logic according to each positioning state and the conversion relationship between each positioning state; wherein, the logical content of the positioning logic includes: performing the positioning process indicated by the corresponding positioning strategy on the current frame, the The corresponding positioning strategy is the positioning strategy in the current positioning state;
匹配定位子模块1007,基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,将当前帧中的特征点与候选地范围内的地图点进行匹配,得到匹配特征点,根据匹配特征点计算当前帧的位姿;Matching and positioning sub-module 1007, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determine the candidate map range in the map for the current frame, and match the feature points in the current frame with the map points within the candidate range , obtain the matching feature points, and calculate the pose of the current frame according to the matching feature points;
位姿图优化子模块1008,对当前帧位姿进行图优化。可选地,所述定位模块1003,还用于在得到匹配特征点之后,基于匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,当最佳匹配特征点集合不满足用于当前帧位姿解算的条件时,判定当前帧定位失败。The pose graph optimization sub-module 1008 performs graph optimization on the pose of the current frame. Optionally, the positioning module 1003 is further configured to, after obtaining the matching feature points, use a random sampling consistency algorithm to determine the best matching feature point set based on the matching feature points, and determine whether the best matching feature point set satisfies the requirements for The conditions for the current frame pose calculation, when the best matching feature point set does not meet the conditions for the current frame pose calculation, it is determined that the current frame positioning fails.
可选地,所述各个定位状态之间转换关系包括,Optionally, the conversion relationship between the various positioning states includes:
当前定位状态为未初始化状态时,如果初始化定位成功,则转换至定位成功状态,如果初始化定位失败,保持当前未初始化状态;When the current positioning state is the uninitialized state, if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
当前定位状态为定位成功状态时,如果正常定位成功,则保持当前定位成功状态,如果正常定位失败,转换至定位丢失状态;When the current positioning status is the positioning successful status, if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
当前定位状态为定位丢失状态时,如果重定位成功,则转换至定位成功状态,如果重定位失败,判断连续定位失败的帧数是否超过设定的帧数阈值,或者判断当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值,如果超过设定的帧数阈值或设定的第一距离阈值,则转换至未初始化状态,如果未超过设定的帧数阈值或设定的第一距离阈值,则保持当前定位丢失状态。When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning success state. If the relocation fails, determine whether the number of frames of continuous positioning failure exceeds the set threshold of the number of frames, or determine whether the current frame is different from the most recent positioning. Whether the distance between the successful poses exceeds the set first distance threshold, if it exceeds the set number of frames threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set number of frames threshold or the set first distance threshold, the current position loss state is maintained.
所述匹配定位子模块1007包括,The matching and positioning sub-module 1007 includes:
候选地图确定单元1009,基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,The candidate map determination unit 1009, based on the positioning logic, determines the candidate map range in the map for the current frame according to the positioning process indicated by the positioning strategy in each state,
特征匹配单元1010,将当前帧中的特征点与候选地范围内的地图点进行匹配,The feature matching unit 1010 matches the feature points in the current frame with the map points in the candidate area,
位姿计算单元1011,根据匹配特征点计算当前帧的位姿。The pose calculation unit 1011 calculates the pose of the current frame according to the matching feature points.
可选地,定位逻辑子模块1006具体用于:Optionally, the positioning logic sub-module 1006 is specifically used for:
判断当前帧是否是第一帧,Determine whether the current frame is the first frame,
如果当前帧是第一帧,则对当前帧进行初始化定位,If the current frame is the first frame, initialize the current frame,
如果当前帧不是第一帧,则判断上一帧是否定位成功,If the current frame is not the first frame, it is judged whether the positioning of the previous frame is successful.
如果上一帧定位成功,则对当前帧进行正常定位;If the positioning of the previous frame is successful, the current frame will be positioned normally;
如果上一帧定位不成功,则判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值;If the positioning of the previous frame is unsuccessful, it is judged whether the current number of consecutive failed frames exceeds the set number of frames threshold, or whether the distance between the current frame and the pose of the last successful positioning exceeds the set first distance threshold ;
如果当前连续定位失败帧数超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位,If the current frame number of consecutive positioning failures exceeds the frame number threshold or the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, the current frame will be initialized and positioned.
如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位。If the current frame number of consecutive positioning failures does not exceed the frame number threshold or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, the current frame is relocated.
可选地,所述定位逻辑子模块1006还用于在如果当前帧是第一帧,则对当前帧进行初始化定位之前,根据当前帧是第一帧,判定当前定位状态为未初始化状态,Optionally, the positioning logic sub-module 1006 is further configured to determine that the current positioning state is an uninitialized state according to the current frame being the first frame before initializing and positioning the current frame if the current frame is the first frame,
如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧初始化定位失败,记录当前帧定位失败,保持当前未初始化状态;If the initialization positioning of the current frame is successful, the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
所述定位逻辑子模块1006还用于在如果上一帧定位成功,则对当前帧进行正常定位之前,根据上一帧定位成功,判定当前定位状态为定位成功状态,如果当前帧正常定位成功,则记录当前帧定位成功,保持当前定位成功状态,如果当前帧正常定位失败,记录当前帧定位失败,转换至定位丢失状态;The positioning logic sub-module 1006 is also used to determine that the current positioning state is a positioning success state according to the successful positioning of the previous frame before performing normal positioning on the current frame if the positioning of the previous frame is successful, and if the current frame is successfully positioned normally, Then record the current frame positioning success, keep the current positioning successful state, if the current frame fails to locate normally, record the current frame positioning failure, and switch to the positioning loss state;
所述定位逻辑子模块1006还用于:The positioning logic sub-module 1006 is also used for:
在如果当前连续定位失败帧数超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位之前,If the current frame number of consecutive positioning failures exceeds the frame number threshold, or the distance between the current frame and the pose of the latest successful positioning exceeds the set first distance threshold, before initializing the current frame positioning,
根据当前连续定位失败帧数超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,判定当前定位状态为未初始化状态,According to the current continuous positioning failure frame number exceeds the frame number threshold, or the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, it is determined that the current positioning state is an uninitialized state,
如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧初始化定位失败,记录当前帧定位失败,保持当前未初始化状态;If the initialization positioning of the current frame is successful, the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
所述定位逻辑子模块1006还用于:The positioning logic sub-module 1006 is also used for:
在如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位之前,Before the current frame is relocated, if the current frame number of consecutive positioning failures does not exceed the frame number threshold or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, the current frame is relocated.
根据当前连续定位失败帧数未超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,判定当前定位状态为定位丢失状态,According to the current continuous positioning failure frame number does not exceed the frame number threshold, or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, it is determined that the current positioning state is a positioning loss state,
如果当前帧重定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧重定位失败,记录当前帧定位失败,保持当前定位丢失状态,返回所述判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值的步骤。If the current frame relocation is successful, record the current frame positioning success, and switch to the positioning success state; if the current frame relocation fails, record the current frame positioning failure, keep the current positioning loss state, and return to the judgment whether the current continuous positioning failure frame number is Exceeds the set number of frames threshold, or whether the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold.
可选地,所述匹配定位子模块1007具体用于:Optionally, the matching and positioning sub-module 1007 is specifically used for:
对当前帧进行初始化定位时,将地图中的所有地图点作为第一候选地图范围,或者,利用辅助信息获得第一候选地图范围;对第一候选地图范围内的地图点采用暴力匹配进行筛选,如果每两个地图点特征匹配度超过设定的第二匹配阈值,则随机删掉其中的一个地图点,得到修正后的第一候选地图范围;When the current frame is initialized and positioned, all map points in the map are used as the first candidate map range, or the auxiliary information is used to obtain the first candidate map range; the map points within the first candidate map range are screened by brute force matching, If the feature matching degree of every two map points exceeds the set second matching threshold, then randomly delete one of the map points to obtain the revised first candidate map range;
对当前帧进行正常定位时,根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第二候选地图范围;When performing normal positioning on the current frame, the pose prediction is performed on the current frame according to the inter-frame motion information from the previous frame to the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the second frame in the map is determined. candidate map range;
对当前帧进行重定位时,根据定位成功的历史帧,向前追溯历史帧中与当前帧最近的一帧并作为参考帧,将该参考帧作为上一帧,根据该上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第三候选地图范围。When relocating the current frame, according to the historical frame that has been successfully positioned, trace forward the closest frame to the current frame in the historical frame and use it as the reference frame, and use the reference frame as the previous frame, and according to the previous frame to the current frame The motion information between frames is obtained, the pose prediction is performed on the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the third candidate map range in the map is determined.
可选地,所述匹配定位子模块1007根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿,包括,Optionally, the matching positioning sub-module 1007 performs pose prediction on the current frame according to the inter-frame motion information from the previous frame to the current frame, and obtains the predicted pose of the current frame, including:
第一方式:通过轮式里程计或惯性测量元件获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;或者The first method: Obtain the frame pose transformation from the previous frame to the current frame through the wheel odometer or inertial measurement element, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame. ;or
第二方式:通过视觉里程计获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、 以及上一帧的定位结果,求得当前帧的预测位姿;或者The second method: obtain the inter-frame pose transformation from the previous frame to the current frame through the visual odometry, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame; or
第三方式:根据已获得定位结果的历史帧,预测上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;或者,The third method: According to the historical frame for which the positioning result has been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame ;or,
第四方式:至少采用第一方式、第二方式、第三方式中的两方式,分别求得当前帧的第一预测位姿,得到至少两个第一预测位姿;The fourth method: adopt at least two of the first method, the second method, and the third method to obtain the first predicted pose of the current frame respectively, and obtain at least two first predicted poses;
采用卡尔曼滤波器对所述至少两个第一预测位姿进行滤波,得到滤波后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;或者,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,得到优化后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;The Kalman filter is used to filter the at least two first predicted poses to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame; or, nonlinear optimization is used. method, optimize based on the at least two first predicted poses, obtain an optimized second predicted pose, and use the second predicted pose as the final predicted pose of the current frame;
其中,非线性优化的目标函数为根据各个方式所得到的各个误差项之和,其中,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,包括:将上一帧的位姿、不同方式所得到的当前帧的第一预测位姿、以及帧间位姿变换作为初始值,代入非线性优化的目标函数,求解使得非线性优化的目标函数取得最小值时的位姿,作为第二预测位姿。Wherein, the objective function of nonlinear optimization is the sum of various error terms obtained according to various methods, wherein, using a nonlinear optimization method to optimize based on the at least two first predicted poses, including: The pose, the first predicted pose of the current frame obtained in different ways, and the pose transformation between frames are used as initial values, and are substituted into the objective function of nonlinear optimization to solve the position when the objective function of nonlinear optimization achieves the minimum value. pose as the second predicted pose.
所述匹配定位子模块1007具体用于:The matching and positioning sub-module 1007 is specifically used for:
以当前帧的预测位姿所确定的地图位置为中心,将该中心的第一邻域确定为第二候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the first neighborhood of the center is determined as the second candidate map range,
或者or
对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第一邻域作为该特征点第二候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and take the position of the projection point as the center of the first neighborhood as the center. The second candidate map range of the feature point;
所述根据当前帧的预测位姿,确定地图中第三候选地图范围,包括,Described according to the predicted pose of the current frame, determine the third candidate map range in the map, including,
以当前帧的预测位姿所确定的地图位置为中心,将该中心的第二邻域确定为第三候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the second neighborhood of the center is determined as the third candidate map range,
或者or
对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第二邻域作为该特征点第三候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and the second neighborhood with the position of the projection point as the center is used as the The third candidate map range of the feature point;
所述第二邻域的范围大于第一邻域的范围。The range of the second neighborhood is greater than the range of the first neighborhood.
可选地,所述定位模块1003具体用于:Optionally, the positioning module 1003 is specifically used for:
从匹配特征点所构成的匹配特征点集合中,随机选择用于计算当前帧位姿估计的匹配特征点,得到当前匹配特征点子集;From the set of matching feature points formed by the matching feature points, randomly select the matching feature points for calculating the pose estimation of the current frame, and obtain a subset of the current matching feature points;
基于利用当前匹配特征点子集中的匹配特征点所建立的空间位置信息与像素位置信息的映射,计算当前位姿,得到该当前匹配特征点子集的拟合位姿估计,Based on the mapping between the spatial position information and the pixel position information established by the matching feature points in the current matching feature point subset, the current pose is calculated, and the fitted pose estimation of the current matching feature point subset is obtained,
根据拟合位姿估计以及相机内参,获取当前帧中所有的特征点的空间位置,得到所有特征点的投影点空间位置;Obtain the spatial positions of all feature points in the current frame according to the fitted pose estimation and camera internal parameters, and obtain the projected point spatial positions of all feature points;
对于匹配特征点集合中的每个匹配特征点,根据该匹配特征点的投影点空间位置,判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈 值,如果小于设定的第二距离阈值,则判定该匹配特征点为内点;反复执行所述判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值的步骤,直至当前匹配特征点集合中所有匹配特征点都被进行了内点的判定;For each matching feature point in the matching feature point set, according to the spatial position of the projected point of the matching feature point, determine whether the distance between the projected point of the matching feature point in the current frame and the map point matched by the matching feature point in the map is less than If the set second distance threshold is less than the set second distance threshold, then determine that the matching feature point is an inner point; repeatedly perform the described judgment of the projection point of the matching feature point in the current frame and the matching feature point in the map Whether the distance of the matched map points is less than the set second distance threshold, until all matching feature points in the current matching feature point set have been judged as interior points;
统计当前内点数量,判断当前统计的内点数量是否为历次迭代中的最大,如果是历次迭代中的最大,则将当前内点所构成的集合作为当前最佳匹配特征点集合;Count the number of current interior points, and judge whether the current number of interior points is the largest in the previous iterations. If it is the largest in the previous iterations, the set formed by the current interior points is used as the current best matching feature point set;
判断是否达到结束条件,如果达到结束条件,则将当前最佳匹配特征点集合作为最终的最佳匹配特征点集合,如果未达到结束条件,返回所述从匹配特征点所构成的匹配特征点集合中随机选择用于计算当前帧位姿估计的匹配特征点的步骤;Judging whether the end condition is reached, if the end condition is reached, the current best matching feature point set is used as the final best matching feature point set, if the end condition is not reached, the matching feature point set formed from the matching feature points is returned. The step of randomly selecting matching feature points for calculating the pose estimation of the current frame;
所述判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,包括,Described judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation, including,
根据匹配特征点的数量判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件;According to the number of matching feature points, determine whether the best matching feature point set satisfies the conditions for the current frame pose calculation;
或者,or,
对至少两个以上最佳匹配特征点集合分别赋予衡量当前帧与候选地图范围匹配程度的权值;所述权值根据最佳匹配特征点集合中的匹配特征点数量、当前帧特征点提取数量,特征点分布情况,匹配特征点初始数量与最佳匹配特征点集合中的匹配特征点数量之一或其任意组合确定,At least two or more best matching feature point sets are respectively given weights that measure the matching degree between the current frame and the candidate map range; the weights are based on the number of matching feature points in the best matching feature point set and the number of feature points extracted from the current frame. , the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set or any combination thereof is determined,
根据设定的权值阈值和最大权值,判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件。According to the set weight threshold and maximum weight, it is judged whether the best matching feature point set satisfies the conditions for the current frame pose calculation.
可选地,所述定位模块1003还用于根据匹配特征点计算当前帧的位姿,得到定位结果之后,还包括,Optionally, the positioning module 1003 is also used to calculate the pose of the current frame according to the matching feature points, and after obtaining the positioning result, it also includes:
对计算得到当前帧的位姿采用基于滑动窗口的非线性优化;优化的变量为滑动窗口内各图像帧的位姿,该滑动窗口包括当前帧,优化的约束为当前帧特征点与上一关键帧特征点之间的帧间匹配约束、和/或当前帧特征点与地图中的地图点之间的地图匹配约束,The non-linear optimization based on sliding window is used to calculate the pose of the current frame; the optimized variable is the pose of each image frame in the sliding window, the sliding window includes the current frame, and the optimization constraints are the feature points of the current frame and the previous key Inter-frame matching constraints between frame feature points, and/or map matching constraints between current frame feature points and map points in the map,
利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,作为定位结果;Using the least squares method, the inter-frame matching error and/or the map matching error are minimized, and the optimized pose of the current frame is obtained as the positioning result;
其中,in,
地图匹配约束为:第一匹配地图点反投影到当前帧上的像素位置与当前帧中与该第一匹配地图点匹配的第一匹配特征点的像素位置之间的误差,或者,当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差;所述第一匹配特征点为:当前帧中的特征点与地图中的地图点进行匹配所得到匹配成功的特征点;第一匹配地图点为:被第一匹配特征点匹配成功的地图点;The map matching constraint is: the error between the pixel position of the first matching map point back-projected on the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, or, in the current frame The error between the spatial position of the first matching feature point projected to the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system; the first matching feature point is : the feature point in the current frame is matched with the map point in the map to obtain the successfully matched feature point; the first matching map point is: the map point successfully matched by the first matching feature point;
帧间匹配约束为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置之间的误差,或者,与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差;The inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, or, the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the pixel of the previous key frame error between positions;
所述图像采集模块1001还用于采集当前图像,得到当前帧之后,基于当前帧,进行特征点提取,得到当前帧的特征点之前,对当前帧进行图像预处理。The image acquisition module 1001 is further configured to collect the current image, and after obtaining the current frame, perform feature point extraction based on the current frame, and perform image preprocessing on the current frame before obtaining the feature points of the current frame.
所述定位模块1003具体用于:The positioning module 1003 is specifically used for:
构建用于优化的目标函数,该用于优化的目标函数为:以第一权值加权当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,以及,以第二权值加权当前滑动窗口中各帧与其上一关键帧之间所有帧间的所有第二匹配地图点的帧间匹配误差之和所得到的第二结果,所累加的关于第一结果与第二结果之和;constructing an objective function for optimization, the objective function for optimization is: a first result obtained by weighting the sum of map matching errors of all the first matching feature points of all frames in the current sliding window with the first weight, and , the second result obtained by weighting the sum of the inter-frame matching errors of all the second matching map points between all frames between each frame in the current sliding window and its previous key frame with the second weight, the accumulated information about the first the sum of the result and the second result;
以根据当前帧的位姿、第一匹配地图点的空间位置信息、相机内参、当前帧中的与第一匹配地图点匹配的第一匹配特征点的像素坐标所得到的地图匹配误差,作为地图匹配误差初始值,Take the map matching error obtained according to the pose of the current frame, the spatial position information of the first matching map point, the camera internal reference, and the pixel coordinates of the first matching feature point matching the first matching map point in the current frame, as the map matching error initial value,
以根据当前帧位姿、第二匹配地图点的空间位置信息、上一关键帧的位姿、相机内参矩阵所得到帧间匹配误差,作为帧间匹配误差初始值,Taking the inter-frame matching error obtained according to the current frame pose, the spatial position information of the second matching map point, the pose of the previous key frame, and the camera internal parameter matrix as the initial value of the inter-frame matching error,
迭代求解使得用于优化的目标函数取得最小值时当前帧的位姿,得到优化后的当前位姿;The iterative solution makes the pose of the current frame when the objective function used for optimization achieves the minimum value, and the optimized current pose is obtained;
所述所述定位模块还用于得到优化后的当前帧位姿之后,The positioning module is also used to obtain the optimized pose of the current frame,
满足以下条件之一时,判定当前帧为关键帧:当前帧中第一匹配特征点的数量小于第一阈值,当前帧中第二匹配特征点的数量小于第二阈值;When one of the following conditions is met, it is determined that the current frame is a key frame: the number of the first matching feature points in the current frame is less than the first threshold, and the number of the second matching feature points in the current frame is less than the second threshold;
若当前帧为非关键帧时,则在滑动窗口中删除该当前帧,若当前帧为关键帧,则判断当前滑动窗口中帧数量是否达到设定的第一帧阈值,如果达到设定的第一帧阈值,则删除滑动窗口中最早添加的关键帧,如果未达到设定的第一帧阈值,则不删除滑动窗口中最早添加的关键帧;If the current frame is a non-key frame, the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold, and if it reaches the set first frame threshold If the threshold is one frame, the earliest added keyframe in the sliding window will be deleted. If the set first frame threshold is not reached, the earliest added keyframe in the sliding window will not be deleted;
所述所述图像采集模块1001对当前帧进行图像预处理包括,The image preprocessing performed by the image acquisition module 1001 on the current frame includes:
根据相机的畸变系数对当前帧进行去畸变处理,得到去畸变图像,According to the distortion coefficient of the camera, the current frame is de-distorted to obtain a de-distorted image,
判断去畸变图像中各个像素点的像素值是否大于第一像素阈值,如果大于第一像素阈值,则将像素值大于第一像素阈值的像素点进行取反操作,然后进行图像滤波,得到背景图像,如果不大于第一像素阈值,将去畸变图像进行图像滤波,得到背景图像,Determine whether the pixel value of each pixel in the dedistorted image is greater than the first pixel threshold, if it is greater than the first pixel threshold, invert the pixels whose pixel value is greater than the first pixel threshold, and then perform image filtering to obtain the background image , if it is not greater than the first pixel threshold, perform image filtering on the dedistorted image to obtain the background image,
用去畸变图像减去背景图像,得到前景图像,Subtract the background image from the undistorted image to get the foreground image,
判断前景图像中的像素值是否分布均匀,如果均匀,则将该前景图像作为图像预处理后的当前帧,如果不均匀,对前景图像进行拉伸处理,得到图像预处理后的当前帧。It is judged whether the pixel values in the foreground image are uniformly distributed. If it is uniform, the foreground image is used as the current frame after image preprocessing. If it is not uniform, the foreground image is stretched to obtain the current frame after image preprocessing.
所述前景图像进行拉伸处理包括,Stretching the foreground image includes:
若前景图像像素值小于等于设定的最小灰度值时,将该前景图像像素值取值为像素取值范围内的最小值;If the pixel value of the foreground image is less than or equal to the set minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range;
若前景图像像素值大于最小灰度值、且小于设定的最大灰度值时,按照与像素最大值成一定比例的像素值作为该前景图像像素值;所述比例为前景图像像素值与最小灰度值之差与最大灰度值与最小灰度值之差的比值;If the pixel value of the foreground image is greater than the minimum gray value and less than the set maximum gray value, the pixel value that is proportional to the maximum value of the pixel is used as the pixel value of the foreground image; the ratio is the pixel value of the foreground image and the minimum value. The ratio of the difference between the gray values to the difference between the maximum gray value and the minimum gray value;
若前景图像像素值大于等于最大灰度值时,将该前景图像像素值取值为像素取值范围内的最大值;If the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the range of pixel values;
所述基于当前帧,进行特征点提取,得到当前帧的特征点,包括,Described based on the current frame, feature point extraction is performed to obtain the feature points of the current frame, including,
对当前帧进行特征检测,得到特征点,Perform feature detection on the current frame to obtain feature points,
将当前帧划分成预定数量的网格,divide the current frame into a predetermined number of grids,
对于任一网格中的特征点,将网格内的特征点按特征点响应值降序排列,保留前Q个特征点,得到筛选后的特征点;其中,Q根据该目标图像帧中特征点的数量和设定的特征点总数上限、以及 该网格特征点总数确定;For the feature points in any grid, the feature points in the grid are arranged in descending order according to the response value of the feature points, the first Q feature points are retained, and the filtered feature points are obtained; among them, Q is based on the feature points in the target image frame. The number and the set upper limit of the total number of feature points, and the total number of grid feature points are determined;
对筛选后的各特征点,分别计算特征描述子。Feature descriptors are calculated separately for each feature point after screening.
为了提高定位的效率,视觉定位装置还包括图像预处理模块1012,用于对图像进行预处理;较佳地,参见图11所示,图11为图像预处理模块的一种示意图。该图像预处理模块1012包括,In order to improve the efficiency of positioning, the visual positioning device further includes an image preprocessing module 1012 for preprocessing the image; preferably, see FIG. 11 , which is a schematic diagram of the image preprocessing module. The image preprocessing module 1012 includes,
图像去畸变子模块,根据相机的畸变系数对源图像帧进行去畸变处理,得到去畸变图像,The image de-distortion sub-module performs de-distortion processing on the source image frame according to the distortion coefficient of the camera to obtain a de-distorted image,
图像滤波子模块,将去畸变图像进行图像滤波,得到背景图像,The image filtering sub-module performs image filtering on the dedistorted image to obtain the background image,
图像差分子模块,用去畸变图像减去背景图像,得到前景图像,Image difference sub-module, subtract the background image from the distorted image to obtain the foreground image,
图像拉伸子模块,对前景图像进行拉伸处理,得到目标图像帧。Image stretching sub-module, which stretches the foreground image to obtain the target image frame.
其中,当视觉地图为纹理地图时,图像滤波子模块,图像差分子模块,图像拉伸子模块可用于增强图像纹理。Among them, when the visual map is a texture map, the image filtering sub-module, the image difference sub-module, and the image stretching sub-module can be used to enhance the image texture.
本申请还提供一种移动机器人,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器被配置执行所述计算机程序,以实现上述基于视觉地图的视觉定位方法的步骤。The present application also provides a mobile robot, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the steps of the above-mentioned visual map-based visual positioning method.
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
本申请实施例还提供了一种计算机可读存储介质,所述存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述基于视觉地图的视觉定位方法的步骤。Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned visual positioning method based on a visual map are implemented.
本发明实施例还提供了一种包含指令的计算机程序产品,所述包含指令的计算机程序产品在计算机上运行时,使得计算机执行上述的基于视觉地图的视觉定位方法的步骤。Embodiments of the present invention also provide a computer program product containing instructions, which, when running on a computer, causes the computer to execute the steps of the above-mentioned visual positioning method based on a visual map.
本发明实施例还提供了一种计算机程序,所述计算机程序在计算机上运行时,使得计算机执行上述的基于视觉地图的视觉定位方法的步骤。对于装置/网络侧设备/存储介质实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。An embodiment of the present invention further provides a computer program, which, when running on a computer, causes the computer to execute the steps of the above-mentioned visual positioning method based on a visual map. For the apparatus/network-side device/storage medium embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the partial description of the method embodiment.
在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。In this document, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such existence between these entities or operations. The actual relationship or sequence. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion such that a process, method, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。The above descriptions are only preferred embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the present application. within the scope of protection.

Claims (16)

  1. 一种基于视觉地图的视觉定位方法,该方法包括,A visual positioning method based on a visual map, the method comprising,
    采集当前图像,得到当前帧;Collect the current image to get the current frame;
    基于当前帧,进行特征点提取,得到当前帧的特征点;Based on the current frame, feature point extraction is performed to obtain the feature points of the current frame;
    根据当前定位状态确定定位策略,Determine the positioning strategy according to the current positioning state,
    基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点,Based on the positioning strategy, the feature points in the current frame are matched with the map points in the map to obtain the matching feature points,
    当匹配特征点满足用于当前帧位姿解算的条件时,根据匹配特征点计算当前帧的位姿,得到定位结果。When the matching feature points meet the conditions for the current frame pose calculation, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
  2. 如权利要求1所述的方法,其中,所述得到匹配特征点之后,所述方法还包括,The method of claim 1, wherein after obtaining the matching feature points, the method further comprises:
    基于匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,Based on the matching feature points, a random sampling consensus algorithm is used to determine the best matching feature point set,
    判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,当最佳匹配特征点集合不满足用于当前帧位姿解算的条件时,判定当前帧定位失败;所述定位状态根据上一帧的定位结果、当前连续定位失败帧数确定;所述定位状态包括,未初始化状态,定位成功状态,以及重定位状态;Judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation, when the best matching feature point set does not meet the current frame pose calculation conditions, it is judged that the current frame positioning fails; the positioning The state is determined according to the positioning result of the previous frame and the current number of consecutive failed frames; the positioning state includes an uninitialized state, a successful positioning state, and a relocation state;
    所述定位策略包括,未初始化状态下的初始化定位,定位成功状态下的正常定位,重定位状态下的重定位,以及各个定位状态之间转换关系;The positioning strategy includes initialization positioning in an uninitialized state, normal positioning in a successful positioning state, relocation in a relocation state, and conversion relationships between the positioning states;
    其中,所述各个定位状态之间转换关系包括,Wherein, the conversion relationship between the various positioning states includes:
    当前定位状态为未初始化状态时,如果初始化定位成功,则转换至定位成功状态,如果初始化定位失败,则保持当前未初始化状态;When the current positioning state is the uninitialized state, if the initialization positioning is successful, it will switch to the positioning successful state, and if the initialization positioning fails, the current uninitialized state will be maintained;
    当前定位状态为定位成功状态时,如果正常定位成功,则保持当前定位成功状态,如果正常定位失败,转换至定位丢失状态;When the current positioning status is the positioning successful status, if the normal positioning is successful, the current positioning successful status will be maintained, and if the normal positioning fails, it will switch to the positioning lost status;
    当前定位状态为定位丢失状态时,如果重定位成功,则转换至定位成功状态,如果重定位失败,则判断连续定位失败的帧数是否超过设定的帧数阈值,或者判断当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值,如果超过设定的帧数阈值或设定的第一距离阈值,则转换至未初始化状态,如果未超过设定的帧数阈值或设定的第一距离阈值,则保持当前定位丢失状态;When the current positioning state is the positioning loss state, if the relocation is successful, it will switch to the positioning success state. If the relocation fails, it will be judged whether the number of frames of continuous positioning failure exceeds the set threshold of the number of frames, or the current frame and the most recent frame will be judged. Whether the distance between the successfully positioned poses exceeds the set first distance threshold, if it exceeds the set frame number threshold or the set first distance threshold, it will switch to the uninitialized state, if it does not exceed the set frame If the number threshold or the set first distance threshold is exceeded, the current positioning loss state is maintained;
    所述根据当前定位状态确定定位策略包括,根据各个定位状态以及各个定位状态之间转换关系,生成定位逻辑;其中,所述定位逻辑的逻辑内容包括:对当前帧执行相应的定位策略所指示的定位过程,所述相应的定位策略为当前定位状态下的定位策略;The determining of the positioning strategy according to the current positioning state includes generating positioning logic according to each positioning state and the conversion relationship between the respective positioning states; wherein, the logical content of the positioning logic includes: executing the current frame indicated by the corresponding positioning strategy The positioning process, the corresponding positioning strategy is the positioning strategy under the current positioning state;
    所述基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,包括,基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,将当前帧中的特征点与候选地图范围内的地图点进行匹配。Matching the feature points in the current frame with the map points in the map based on the positioning strategy, including, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, determining the candidate map range in the map for the current frame , to match the feature points in the current frame with the map points in the candidate map range.
  3. 如权利要求2所述的方法,其中,所述根据各个定位状态以及各个定位状态之间转换关系,生成定位逻辑,包括,The method according to claim 2, wherein, generating the positioning logic according to each positioning state and the conversion relationship between the respective positioning states, comprising:
    判断当前帧是否是第一帧,Determine whether the current frame is the first frame,
    如果当前帧是第一帧,则对当前帧进行初始化定位,If the current frame is the first frame, initialize the current frame,
    如果当前帧不是第一帧,则判断上一帧是否定位成功,If the current frame is not the first frame, it is judged whether the positioning of the previous frame is successful.
    如果上一帧定位成功,则对当前帧进行正常定位;If the positioning of the previous frame is successful, the current frame will be positioned normally;
    如果上一帧定位不成功,则判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值;If the positioning of the previous frame is unsuccessful, it is judged whether the current number of consecutive failed frames exceeds the set number of frames threshold, or whether the distance between the current frame and the pose of the last successful positioning exceeds the set first distance threshold ;
    如果当前连续定位失败帧数超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位,If the current frame number of consecutive positioning failures exceeds the frame number threshold or the distance between the current frame and the last successful positioning pose exceeds the set first distance threshold, the current frame will be initialized and positioned.
    如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位。If the current frame number of consecutive positioning failures does not exceed the frame number threshold or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, the current frame is relocated.
  4. 如权利要求3所述的方法,其中,所述如果当前帧是第一帧,则对当前帧进行初始化定位,进一步包括,The method of claim 3, wherein, if the current frame is the first frame, initializing and positioning the current frame, further comprising:
    根据当前帧是第一帧,判定当前定位状态为未初始化状态,According to the current frame is the first frame, it is determined that the current positioning state is an uninitialized state,
    如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,当前帧初始化定位失败,则记录当前帧定位失败,保持当前未初始化状态;If the initialization positioning of the current frame is successful, the current frame positioning success is recorded, and the status is switched to the positioning successful state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
    所述如果上一帧定位成功,则对当前帧进行正常定位,进一步包括,Described if the positioning of the previous frame is successful, then the current frame is positioned normally, further comprising,
    根据上一帧定位成功,判定当前定位状态为定位成功状态,According to the successful positioning of the previous frame, it is determined that the current positioning status is the positioning successful status.
    如果当前帧正常定位成功,则记录当前帧定位成功,保持当前定位成功状态,如果当前帧正常定位失败,则记录当前帧定位失败,转换至定位丢失状态;If the normal positioning of the current frame is successful, the current frame positioning is recorded successfully, and the current positioning success status is maintained. If the current frame positioning fails normally, the current frame positioning failure is recorded, and the status is converted to positioning loss;
    所述如果当前连续定位失败帧数超过帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,则对当前帧进行初始化定位,进一步包括,Described if the current continuous positioning failure frame number exceeds the frame number threshold, or, the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, then the current frame is initialized and positioned, further comprising,
    根据当前连续定位失败帧数超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离超过设定的第一距离阈值,判定当前定位状态为未初始化状态,According to the current continuous positioning failure frame number exceeds the frame number threshold, or the distance between the current frame and the most recent successful positioning pose exceeds the set first distance threshold, it is determined that the current positioning state is an uninitialized state,
    如果当前帧初始化定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧初始化定位失败,记录当前帧定位失败,保持当前未初始化状态;If the initialization positioning of the current frame is successful, the current frame positioning success is recorded, and the status is switched to the positioning success state. If the current frame initialization positioning fails, the current frame positioning failure is recorded, and the current uninitialized state is maintained;
    所述如果当前连续定位失败帧数未超过帧数阈值或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,则对当前帧进行重定位,进一步包括,Described if the current continuous positioning failure frame number does not exceed the frame number threshold or the distance between the current frame and the most recent successful positioning does not exceed the set first distance threshold, then the current frame is relocated, further comprising,
    根据当前连续定位失败帧数未超过帧数阈值,或者当前帧与最近一次定位成功的位姿之间的距离未超过设定的第一距离阈值,判定当前定位状态为定位丢失状态,According to the current continuous positioning failure frame number does not exceed the frame number threshold, or the distance between the current frame and the last successful positioning pose does not exceed the set first distance threshold, it is determined that the current positioning state is a positioning loss state,
    如果当前帧重定位定位成功,则记录当前帧定位成功,转换至定位成功状态,如果当前帧重定位定位失败,记录当前帧定位失败,保持当前定位丢失状态,返回所述判断当前连续定位失败帧数是否超过设定的帧数阈值,或者,当前帧与最近一次定位成功的位姿之间的距离是否超过设定的第一距离阈值的步骤。If the current frame relocation and positioning is successful, record the current frame positioning success, and switch to the positioning success state; if the current frame relocation positioning fails, record the current frame positioning failure, keep the current positioning loss state, and return to the frame that judges the current continuous positioning failure The step of checking whether the number of frames exceeds the set threshold of the number of frames, or whether the distance between the current frame and the pose of the last successful positioning exceeds the set first distance threshold.
  5. 如权利要求4所述的方法,其中,所述基于定位逻辑,按照各个状态下的定位策略所指示的定位过程,为当前帧确定地图中候选地图范围,包括,The method according to claim 4, wherein, based on the positioning logic, according to the positioning process indicated by the positioning strategy in each state, the candidate map range in the map is determined for the current frame, including:
    对当前帧进行初始化定位时,将地图中的所有地图点作为第一候选地图范围,或者,利用辅助信息获得第一候选地图范围;对第一候选地图范围内的地图点采用暴力匹配进行筛选,如果每两个地图点特征匹配度超过设定的第二匹配阈值,则随机删掉其中的一个地图点,得到修正后的第一候选地图范围;When the current frame is initialized and positioned, all map points in the map are used as the first candidate map range, or the auxiliary information is used to obtain the first candidate map range; the map points within the first candidate map range are screened by brute force matching, If the feature matching degree of every two map points exceeds the set second matching threshold, then randomly delete one of the map points to obtain the revised first candidate map range;
    对当前帧进行正常定位时,根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第二候选地图范围;When performing normal positioning on the current frame, the pose prediction is performed on the current frame according to the inter-frame motion information from the previous frame to the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the second frame in the map is determined. candidate map range;
    对当前帧进行重定位时,根据定位成功的历史帧,向前追溯历史帧中与当前帧最近的一帧并作为参考帧,将该参考帧作为上一帧,根据该上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿;根据当前帧的预测位姿,确定地图中第三候选地图范围。When relocating the current frame, according to the historical frame that has been successfully positioned, trace forward the closest frame to the current frame in the historical frame and use it as the reference frame, and use the reference frame as the previous frame, and according to the previous frame to the current frame The motion information between frames is obtained, the pose prediction is performed on the current frame, and the predicted pose of the current frame is obtained; according to the predicted pose of the current frame, the third candidate map range in the map is determined.
  6. 如权利要求5所述的方法,其中,所述根据上一帧到当前帧的帧间运动信息,对当前帧进行位姿预测,得到当前帧的预测位姿,包括,The method according to claim 5, wherein, according to the inter-frame motion information from the previous frame to the current frame, performing pose prediction on the current frame to obtain the predicted pose of the current frame, comprising:
    第一方式:通过轮式里程计或惯性测量元件获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The first method: Obtain the frame pose transformation from the previous frame to the current frame through the wheel odometer or inertial measurement element, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame. ;
    或者or
    第二方式:通过视觉里程计获得上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The second method: obtain the inter-frame pose transformation from the previous frame to the current frame through the visual odometry, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame;
    或者or
    第三方式:根据已获得定位结果的历史帧,预测上一帧到当前帧的帧间位姿变换,基于帧间位姿变换、以及上一帧的定位结果,求得当前帧的预测位姿;The third method: According to the historical frame for which the positioning result has been obtained, predict the inter-frame pose transformation from the previous frame to the current frame, and obtain the predicted pose of the current frame based on the inter-frame pose transformation and the positioning result of the previous frame ;
    或者,or,
    第四方式:至少采用第一方式、第二方式、第三方式中的两方式,分别求得当前帧的第一预测位姿,得到至少两个第一预测位姿;The fourth method: adopt at least two of the first method, the second method, and the third method to obtain the first predicted pose of the current frame respectively, and obtain at least two first predicted poses;
    采用卡尔曼滤波器对所述至少两个第一预测位姿进行滤波,得到滤波后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;或者,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,得到优化后的第二预测位姿,将第二预测位姿作为当前帧最终的预测位姿;The Kalman filter is used to filter the at least two first predicted poses to obtain a filtered second predicted pose, and the second predicted pose is used as the final predicted pose of the current frame; or, nonlinear optimization is used. method, optimize based on the at least two first predicted poses, obtain an optimized second predicted pose, and use the second predicted pose as the final predicted pose of the current frame;
    其中,非线性优化的目标函数为根据各个方式所得到的各个误差项之和,其中,采用非线性优化的方法,基于所述至少两个第一预测位姿进行优化,包括:将上一帧的位姿、不同方式所得到的当前帧的第一预测位姿、以及帧间位姿变换作为初始值,代入非线性优化的目标函数,求解使得非线性优化的目标函数取得最小值时的位姿,作为第二预测位姿。Wherein, the objective function of nonlinear optimization is the sum of various error terms obtained according to various methods, wherein, using a nonlinear optimization method to optimize based on the at least two first predicted poses, including: The pose, the first predicted pose of the current frame obtained in different ways, and the pose transformation between frames are used as initial values, and are substituted into the objective function of nonlinear optimization to solve the position when the objective function of nonlinear optimization achieves the minimum value. pose as the second predicted pose.
  7. 如权利要求5或6所述的方法,其中,所述根据当前帧的预测位姿,确定地图中第二候选地图范围,包括,The method according to claim 5 or 6, wherein, determining the second candidate map range in the map according to the predicted pose of the current frame, comprising:
    以当前帧的预测位姿所确定的地图位置为中心,将该中心的第一邻域确定为第二候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the first neighborhood of the center is determined as the second candidate map range,
    或者or
    对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征点投影到地图中的投影点位置,以该投影点位置为中心的第一邻域作为该特征点第二候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and take the position of the projection point as the center of the first neighborhood as the center. The second candidate map range of the feature point;
    所述根据当前帧的预测位姿,确定地图中第三候选地图范围,包括,Described according to the predicted pose of the current frame, determine the third candidate map range in the map, including,
    以当前帧的预测位姿所确定的地图位置为中心,将该中心的第二邻域确定为第三候选地图范围,Taking the map position determined by the predicted pose of the current frame as the center, the second neighborhood of the center is determined as the third candidate map range,
    或者or
    对于当前帧的每个特征点,根据当前帧的预测位姿和该特征点的像素坐标,计算该特征 点投影到地图中的投影点位置,以该投影点位置为中心的第二邻域作为该特征点第三候选地图范围;For each feature point of the current frame, according to the predicted pose of the current frame and the pixel coordinates of the feature point, calculate the position of the projection point projected from the feature point to the map, and the second neighborhood with the position of the projection point as the center is used as the The third candidate map range of the feature point;
    所述第二邻域的范围大于第一领域的范围。The range of the second neighborhood is larger than the range of the first area.
  8. 如权利要求2所述的方法,其中,所述基于匹配特征点,采用随机抽样一致性算法确定最佳匹配特征点集合,包括,The method according to claim 2, wherein, based on the matching feature points, using a random sampling consistency algorithm to determine the best matching feature point set, comprising:
    从匹配特征点所构成的匹配特征点集合中,随机选择用于计算当前帧位姿估计的匹配特征点,得到当前匹配特征点子集;From the set of matching feature points formed by the matching feature points, randomly select the matching feature points for calculating the pose estimation of the current frame, and obtain a subset of the current matching feature points;
    基于利用当前匹配特征点子集中的匹配特征点所建立的空间位置信息与像素位置信息的映射,计算当前位姿,得到该当前匹配特征点子集的拟合位姿估计,Based on the mapping between the spatial position information and the pixel position information established by the matching feature points in the current matching feature point subset, the current pose is calculated, and the fitted pose estimation of the current matching feature point subset is obtained,
    根据拟合位姿估计以及相机内参,获取当前帧中所有的特征点的空间位置,得到所有特征点的投影点空间位置;Obtain the spatial positions of all feature points in the current frame according to the fitted pose estimation and camera internal parameters, and obtain the projected point spatial positions of all feature points;
    对于匹配特征点集合中的每个匹配特征点,根据该匹配特征点的投影点空间位置,判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值,如果小于设定的第二距离阈值,则判定该匹配特征点为内点;反复执行所述判断当前帧中该匹配特征点的投影点与地图中该匹配特征点所匹配地图点的距离是否小于设定的第二距离阈值的步骤,直至当前匹配特征点集合中所有匹配特征点都被进行了内点的判定;For each matching feature point in the matching feature point set, according to the spatial position of the projected point of the matching feature point, determine whether the distance between the projected point of the matching feature point in the current frame and the map point matched by the matching feature point in the map is less than If the set second distance threshold is less than the set second distance threshold, then determine that the matching feature point is an inner point; repeatedly perform the described judgment of the projection point of the matching feature point in the current frame and the matching feature point in the map Whether the distance of the matched map points is less than the set second distance threshold, until all matching feature points in the current matching feature point set have been judged as interior points;
    统计当前内点数量,判断当前统计的内点数量是否为历次迭代中的最大,如果是历次迭代中的最大,则将当前内点所构成的集合作为当前最佳匹配特征点集合;Count the number of current interior points, and judge whether the current number of interior points is the largest in the previous iterations. If it is the largest in the previous iterations, the set formed by the current interior points is used as the current best matching feature point set;
    判断是否达到结束条件,如果达到约束条件,则将当前最佳匹配特征点集合作为最终的最佳匹配特征点集合,如果未达到约束条件,返回所述从匹配特征点所构成的匹配特征点集合中随机选择用于计算当前帧位姿估计的匹配特征点的步骤;Judging whether the end condition is reached, if the constraint condition is met, the current best matching feature point set is used as the final best matching feature point set, if the constraint condition is not met, the matching feature point set formed from the matching feature points is returned. The step of randomly selecting matching feature points for calculating the pose estimation of the current frame;
    所述判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件,包括,Described judging whether the best matching feature point set satisfies the conditions for the current frame pose calculation, including,
    根据匹配特征点的数量判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件;According to the number of matching feature points, determine whether the best matching feature point set satisfies the conditions for the current frame pose calculation;
    或者,or,
    对至少两个以上最佳匹配特征点集合分别赋予衡量当前帧与候选地图范围匹配程度的权值;所述权值根据最佳匹配特征点集合中的匹配特征点数量、当前帧特征点提取数量,特征点分布情况,匹配特征点初始数量与最佳匹配特征点集合中的匹配特征点数量之一或其任意组合确定,At least two or more best matching feature point sets are respectively given weights that measure the matching degree between the current frame and the candidate map range; the weights are based on the number of matching feature points in the best matching feature point set and the number of feature points extracted from the current frame. , the distribution of feature points, one of the initial number of matching feature points and the number of matching feature points in the best matching feature point set or any combination thereof is determined,
    根据设定的权值阈值和最大权值,判断最佳匹配特征点集合是否满足用于当前帧位姿解算的条件。According to the set weight threshold and maximum weight, it is judged whether the best matching feature point set satisfies the conditions for the current frame pose calculation.
  9. 如权利要求1所述的方法,其中,所述根据匹配特征点计算当前帧的位姿,得到定位结果之后,所述方法还包括,The method according to claim 1, wherein after calculating the pose of the current frame according to the matching feature points and obtaining a positioning result, the method further comprises:
    对计算得到当前帧的位姿采用基于滑动窗口的非线性优化;优化的变量为滑动窗口内各图像帧的位姿,该滑动窗口包括当前帧,优化的约束为当前帧特征点与上一关键帧特征点之间的帧间匹配约束、和/或当前帧特征点与地图中的地图点之间的地图匹配约束,The non-linear optimization based on sliding window is used to calculate the pose of the current frame; the optimized variable is the pose of each image frame in the sliding window, the sliding window includes the current frame, and the optimization constraints are the feature points of the current frame and the previous key Inter-frame matching constraints between frame feature points, and/or map matching constraints between current frame feature points and map points in the map,
    利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,作为定位结果;Using the least squares method, the inter-frame matching error and/or the map matching error are minimized, and the optimized pose of the current frame is obtained as the positioning result;
    其中,in,
    地图匹配约束为:第一匹配地图点反投影到当前帧上的像素位置与当前帧中与该第一匹配地图点匹配的第一匹配特征点的像素位置之间的误差,或者,当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与该第一匹配特征点匹配的第一匹配地图点在世界坐标系中的空间位置之间的误差;所述第一匹配特征点为:当前帧中的特征点与地图中的地图点进行匹配所得到匹配成功的特征点;第一匹配地图点为:被第一匹配特征点匹配成功的地图点;The map matching constraint is: the error between the pixel position of the first matching map point back-projected on the current frame and the pixel position of the first matching feature point matching the first matching map point in the current frame, or, in the current frame The error between the spatial position of the first matching feature point projected to the world coordinate system and the spatial position of the first matching map point matching the first matching feature point in the world coordinate system; the first matching feature point is : the feature point in the current frame is matched with the map point in the map to obtain the successfully matched feature point; the first matching map point is: the map point successfully matched by the first matching feature point;
    帧间匹配约束为:当前帧中的第一匹配特征点投影至世界坐标系中的空间位置与当前帧的上一关键帧中与该第一匹配特征点匹配的第二匹配特征点投影至世界坐标系中的空间位置之间的误差,或者,与第二匹配特征点匹配的第二匹配地图点反投影到当前帧的像素位置与该第二匹配地图点反投影到上一关键帧的像素位置之间的误差;The inter-frame matching constraints are: the first matching feature point in the current frame is projected to the spatial position in the world coordinate system and the second matching feature point matching the first matching feature point in the previous key frame of the current frame is projected to the world The error between the spatial positions in the coordinate system, or, the second matching map point matching the second matching feature point is back-projected to the pixel position of the current frame and the second matching map point is back-projected to the pixel of the previous key frame error between positions;
    所述采集当前图像,得到当前帧之后,基于当前帧,进行特征点提取,得到当前帧的特征点之前,所述方法包括,对当前帧进行图像预处理。After the current image is acquired and the current frame is obtained, feature point extraction is performed based on the current frame, and before the feature points of the current frame are obtained, the method includes performing image preprocessing on the current frame.
  10. 如权利要求9所述的方法,其中,所述利用最小二乘法,最小化帧间匹配误差和/或地图匹配误差,得到优化后的当前帧位姿,包括,The method according to claim 9, wherein, using the least squares method to minimize the inter-frame matching error and/or the map matching error to obtain the optimized pose of the current frame, comprising:
    构建用于优化的目标函数,该用于优化的目标函数为:以第一权值加权当前滑动窗口中所有帧的所有第一匹配特征点的地图匹配误差之和所得到的第一结果,以及,以第二权值加权当前滑动窗口中各帧与其上一关键帧之间所有帧间的所有第二匹配地图点的帧间匹配误差之和所得到的第二结果,所累加的关于第一结果与第二结果之和;constructing an objective function for optimization, the objective function for optimization is: a first result obtained by weighting the sum of map matching errors of all the first matching feature points of all frames in the current sliding window with the first weight, and , the second result obtained by weighting the sum of the inter-frame matching errors of all the second matching map points between all frames between each frame in the current sliding window and its previous key frame with the second weight, the accumulated information about the first the sum of the result and the second result;
    以根据当前帧的位姿、第一匹配地图点的空间位置信息、相机内参、当前帧中的与第一匹配地图点匹配的第一匹配特征点的像素坐标所得到的地图匹配误差,作为地图匹配误差初始值,Take the map matching error obtained according to the pose of the current frame, the spatial position information of the first matching map point, the camera internal reference, and the pixel coordinates of the first matching feature point matching the first matching map point in the current frame, as the map matching error initial value,
    以根据当前帧位姿、第二匹配地图点的空间位置信息、上一关键帧的位姿、相机内参矩阵所得到帧间匹配误差,作为帧间匹配误差初始值,Taking the inter-frame matching error obtained according to the current frame pose, the spatial position information of the second matching map point, the pose of the previous key frame, and the camera internal parameter matrix as the initial value of the inter-frame matching error,
    迭代求解使得用于优化的目标函数取得最小值时当前帧的位姿,得到优化后的当前位姿;The iterative solution makes the pose of the current frame when the objective function used for optimization achieves the minimum value, and the optimized current pose is obtained;
    所述得到优化后的当前帧位姿之后,所述方法还包括,After the optimized current frame pose is obtained, the method further includes:
    满足以下条件之一时,判定当前帧为关键帧:当前帧中第一匹配特征点的数量小于第一阈值,当前帧中第二匹配特征点的数量小于第二阈值;When one of the following conditions is met, it is determined that the current frame is a key frame: the number of the first matching feature points in the current frame is less than the first threshold, and the number of the second matching feature points in the current frame is less than the second threshold;
    若当前帧为非关键帧时,则在滑动窗口中删除该当前帧,若当前帧为关键帧,则判断当前滑动窗口中帧数量是否达到设定的第一帧阈值,如果达到设定的第一帧阈值,则删除滑动窗口中最早添加的关键帧,如果未达到设定的第一帧阈值,则不删除滑动窗口中最早添加的关键帧;If the current frame is a non-key frame, the current frame is deleted in the sliding window. If the current frame is a key frame, it is judged whether the number of frames in the current sliding window reaches the set first frame threshold, and if it reaches the set first frame threshold If the threshold is one frame, the earliest added keyframe in the sliding window will be deleted. If the set first frame threshold is not reached, the earliest added keyframe in the sliding window will not be deleted;
    所述对当前帧进行图像预处理包括,The performing image preprocessing on the current frame includes,
    根据相机的畸变系数对当前帧进行去畸变处理,得到去畸变图像,According to the distortion coefficient of the camera, the current frame is de-distorted to obtain a de-distorted image,
    判断去畸变图像中各个像素点的像素值是否大于第一像素阈值,如果大于第一像素阈值,则将像素值大于第一像素阈值的像素点进行取反操作,然后进行图像滤波,得到背景图像,如果不大于第一像素阈值,则将去畸变图像进行图像滤波,得到背景图像,Determine whether the pixel value of each pixel in the dedistorted image is greater than the first pixel threshold, if it is greater than the first pixel threshold, invert the pixels whose pixel value is greater than the first pixel threshold, and then perform image filtering to obtain the background image , if it is not greater than the first pixel threshold, the dedistorted image is subjected to image filtering to obtain the background image,
    用去畸变图像减去背景图像,得到前景图像,Subtract the background image from the undistorted image to get the foreground image,
    判断前景图像中的像素值是否分布均匀,如果均匀,则将该前景图像作为图像预处理后的当前 帧,如果不均匀,对前景图像进行拉伸处理,得到图像预处理后的当前帧。It is judged whether the pixel values in the foreground image are evenly distributed. If it is uniform, the foreground image is used as the current frame after image preprocessing. If it is not uniform, the foreground image is stretched to obtain the current frame after image preprocessing.
  11. 如权利要求10所述的方法,其中,所述前景图像进行拉伸处理包括,The method of claim 10, wherein performing the stretching process on the foreground image comprises:
    若前景图像像素值小于等于设定的最小灰度值时,将该前景图像像素值取值为像素取值范围内的最小值;If the pixel value of the foreground image is less than or equal to the set minimum gray value, the pixel value of the foreground image is the minimum value within the pixel value range;
    若前景图像像素值大于最小灰度值、且小于设定的最大灰度值时,按照与像素最大值成一定比例的像素值作为该前景图像像素值;所述比例为前景图像像素值与最小灰度值之差与最大灰度值与最小灰度值之差的比值;If the pixel value of the foreground image is greater than the minimum gray value and less than the set maximum gray value, the pixel value that is proportional to the maximum value of the pixel is used as the pixel value of the foreground image; the ratio is the pixel value of the foreground image and the minimum value. The ratio of the difference between the gray values to the difference between the maximum gray value and the minimum gray value;
    若前景图像像素值大于等于最大灰度值时,将该前景图像像素值取值为像素取值范围内的最大值;If the pixel value of the foreground image is greater than or equal to the maximum gray value, the pixel value of the foreground image is the maximum value within the range of pixel values;
    所述基于当前帧,进行特征点提取,得到当前帧的特征点,包括,Described based on the current frame, feature point extraction is performed to obtain the feature points of the current frame, including,
    对当前帧进行特征检测,得到特征点,Perform feature detection on the current frame to obtain feature points,
    将当前帧划分成预定数量的网格,divide the current frame into a predetermined number of grids,
    对于任一网格中的特征点,将网格内的特征点按特征点响应值降序排列,保留前Q个特征点,得到筛选后的特征点;其中,Q根据该目标图像帧中特征点的数量和设定的特征点总数上限、以及该网格特征点总数确定;For the feature points in any grid, the feature points in the grid are arranged in descending order according to the response value of the feature points, the first Q feature points are retained, and the filtered feature points are obtained; among them, Q is based on the feature points in the target image frame. The number and the set upper limit of the total number of feature points, and the total number of grid feature points are determined;
    对筛选后的各特征点,分别计算特征描述子。Feature descriptors are calculated separately for each feature point after screening.
  12. 一种基于视觉地图的视觉定位装置,该装置包括,A visual positioning device based on a visual map, the device comprising,
    图像采集模块,采集当前图像,得到当前帧;The image acquisition module collects the current image and obtains the current frame;
    特征提取模块,基于当前帧,进行特征点提取,得到当前帧的特征点;The feature extraction module, based on the current frame, performs feature point extraction to obtain the feature points of the current frame;
    定位模块,根据当前定位状态确定定位策略,基于定位策略,将当前帧中的特征点与地图中的地图点进行匹配,得到匹配特征点,当匹配特征点满足用于当前帧位姿解算的条件时,根据匹配特征点计算当前帧的位姿,得到定位结果。The positioning module determines the positioning strategy according to the current positioning state. Based on the positioning strategy, the feature points in the current frame are matched with the map points in the map to obtain the matching feature points. When the matching feature points meet the requirements for the current frame pose calculation. When conditions are met, the pose of the current frame is calculated according to the matching feature points, and the positioning result is obtained.
  13. 一种计算机可读存储介质,所述存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至11任一所述基于视觉地图的视觉定位方法的步骤。A computer-readable storage medium, storing a computer program in the storage medium, the computer program implementing the steps of the visual map-based visual positioning method according to any one of claims 1 to 11 when the computer program is executed by a processor.
  14. 一种移动机器人,包括存储器、处理器,所述存储器存储有计算机程序,所述处理器被配置执行所述计算机程序,以实现上述权利要求1至11任一项所述的方法的步骤。A mobile robot comprising a memory and a processor, wherein the memory stores a computer program, the processor is configured to execute the computer program to implement the steps of the method of any one of claims 1 to 11 above.
  15. 一种包含指令的计算机程序产品,所述包含指令的计算机程序产品在计算机上运行时,使得计算机执行权利要求1至11任一所述的方法步骤。A computer program product containing instructions, when the computer program product containing instructions is run on a computer, causes the computer to perform the method steps of any one of claims 1 to 11.
  16. 一种计算机程序,所述计算机程序在计算机上运行时,使得计算机执行权利要求1至11任一所述的方法步骤。A computer program which, when run on a computer, causes the computer to perform the method steps of any one of claims 1 to 11.
PCT/CN2021/103073 2020-06-30 2021-06-29 Visual positioning method and device based on visual map WO2022002039A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010618519.1 2020-06-30
CN202010618519.1A CN111780763B (en) 2020-06-30 2020-06-30 Visual positioning method and device based on visual map

Publications (1)

Publication Number Publication Date
WO2022002039A1 true WO2022002039A1 (en) 2022-01-06

Family

ID=72759967

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/103073 WO2022002039A1 (en) 2020-06-30 2021-06-29 Visual positioning method and device based on visual map

Country Status (2)

Country Link
CN (1) CN111780763B (en)
WO (1) WO2022002039A1 (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114111803A (en) * 2022-01-26 2022-03-01 中国人民解放军战略支援部队航天工程大学 Visual navigation method of indoor satellite platform
CN114577215A (en) * 2022-03-10 2022-06-03 山东新一代信息产业技术研究院有限公司 Method, device and medium for updating feature map of mobile robot
CN114782495A (en) * 2022-06-16 2022-07-22 西安中科立德红外科技有限公司 Multi-target tracking method, system and computer storage medium
CN114898084A (en) * 2022-04-18 2022-08-12 荣耀终端有限公司 Visual positioning method, device and storage medium
CN115049847A (en) * 2022-06-21 2022-09-13 上海大学 Characteristic point local neighborhood characteristic matching method based on ORB descriptor
CN115439536A (en) * 2022-08-18 2022-12-06 北京百度网讯科技有限公司 Visual map updating method and device and electronic equipment
CN115451996A (en) * 2022-08-30 2022-12-09 华南理工大学 Homography vision mileometer method for indoor environment
CN115493612A (en) * 2022-10-12 2022-12-20 中国第一汽车股份有限公司 Vehicle positioning method and device based on visual SLAM
CN116147618A (en) * 2023-01-17 2023-05-23 中国科学院国家空间科学中心 Real-time state sensing method and system suitable for dynamic environment
CN116778141A (en) * 2023-08-28 2023-09-19 深圳联友科技有限公司 ORB algorithm-based method for rapidly identifying and positioning picture
WO2024001849A1 (en) * 2022-06-28 2024-01-04 中兴通讯股份有限公司 Visual-localization-based pose determination method and apparatus, and electronic device
CN117419690A (en) * 2023-12-13 2024-01-19 陕西欧卡电子智能科技有限公司 Pose estimation method, device and medium of unmanned ship
CN117710469A (en) * 2024-02-06 2024-03-15 四川大学 Online dense reconstruction method and system based on RGB-D sensor

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111524192B (en) * 2020-04-20 2023-10-03 阿波罗智能技术(北京)有限公司 Calibration method, device and system for external parameters of vehicle-mounted camera and storage medium
CN111780763B (en) * 2020-06-30 2022-05-06 杭州海康机器人技术有限公司 Visual positioning method and device based on visual map
CN112509027B (en) * 2020-11-11 2023-11-21 深圳市优必选科技股份有限公司 Repositioning method, robot, and computer-readable storage medium
CN112488007B (en) * 2020-12-04 2023-10-13 深圳市优必选科技股份有限公司 Visual positioning method, device, robot and storage medium
CN113160270A (en) * 2021-02-24 2021-07-23 广州视源电子科技股份有限公司 Visual map generation method, device, terminal and storage medium
CN112950710A (en) * 2021-02-24 2021-06-11 广州极飞科技股份有限公司 Pose determination method and device, electronic equipment and computer readable storage medium
CN112950715B (en) * 2021-03-04 2024-04-30 杭州迅蚁网络科技有限公司 Visual positioning method and device of unmanned aerial vehicle, computer equipment and storage medium
CN112990003B (en) * 2021-03-11 2023-05-19 深圳市无限动力发展有限公司 Image sequence repositioning judging method, device and computer equipment
CN113034595A (en) * 2021-03-19 2021-06-25 浙江商汤科技开发有限公司 Visual positioning method and related device, equipment and storage medium
CN113239072A (en) * 2021-04-27 2021-08-10 华为技术有限公司 Terminal equipment positioning method and related equipment thereof
CN113252033B (en) * 2021-06-29 2021-10-15 长沙海格北斗信息技术有限公司 Positioning method, positioning system and robot based on multi-sensor fusion
CN115267796B (en) * 2022-08-17 2024-04-09 深圳市普渡科技有限公司 Positioning method, positioning device, robot and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106885574A (en) * 2017-02-15 2017-06-23 北京大学深圳研究生院 A kind of monocular vision robot synchronous superposition method based on weight tracking strategy
CN107990899A (en) * 2017-11-22 2018-05-04 驭势科技(北京)有限公司 A kind of localization method and system based on SLAM
US20200166944A1 (en) * 2016-08-29 2020-05-28 Trifo, Inc. Fault-Tolerance to Provide Robust Tracking for Autonomous and Non-Autonomous Positional Awareness
CN111750864A (en) * 2020-06-30 2020-10-09 杭州海康机器人技术有限公司 Repositioning method and device based on visual map
CN111780763A (en) * 2020-06-30 2020-10-16 杭州海康机器人技术有限公司 Visual positioning method and device based on visual map
CN112541970A (en) * 2020-11-30 2021-03-23 北京华捷艾米科技有限公司 Relocation method and device in centralized cooperative SlAM

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104732518B (en) * 2015-01-19 2017-09-01 北京工业大学 A kind of PTAM improved methods based on intelligent robot terrain surface specifications
US10054445B2 (en) * 2016-05-16 2018-08-21 Northrop Grumman Systems Corporation Vision-aided aerial navigation
CN107390245B (en) * 2017-07-13 2020-07-10 广东小天才科技有限公司 Positioning method, device, equipment and storage medium
CN109544636B (en) * 2018-10-10 2022-03-15 广州大学 Rapid monocular vision odometer navigation positioning method integrating feature point method and direct method
CN109633725B (en) * 2018-10-31 2021-03-30 百度在线网络技术(北京)有限公司 Processing method and device for positioning initialization and readable storage medium
CN111322993B (en) * 2018-12-13 2022-03-04 杭州海康机器人技术有限公司 Visual positioning method and device
CN110108258B (en) * 2019-04-09 2021-06-08 南京航空航天大学 Monocular vision odometer positioning method
CN110361005B (en) * 2019-06-26 2021-03-26 达闼机器人有限公司 Positioning method, positioning device, readable storage medium and electronic equipment
CN111156984B (en) * 2019-12-18 2022-12-09 东南大学 Monocular vision inertia SLAM method oriented to dynamic scene

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200166944A1 (en) * 2016-08-29 2020-05-28 Trifo, Inc. Fault-Tolerance to Provide Robust Tracking for Autonomous and Non-Autonomous Positional Awareness
CN106885574A (en) * 2017-02-15 2017-06-23 北京大学深圳研究生院 A kind of monocular vision robot synchronous superposition method based on weight tracking strategy
CN107990899A (en) * 2017-11-22 2018-05-04 驭势科技(北京)有限公司 A kind of localization method and system based on SLAM
CN111750864A (en) * 2020-06-30 2020-10-09 杭州海康机器人技术有限公司 Repositioning method and device based on visual map
CN111780763A (en) * 2020-06-30 2020-10-16 杭州海康机器人技术有限公司 Visual positioning method and device based on visual map
CN112541970A (en) * 2020-11-30 2021-03-23 北京华捷艾米科技有限公司 Relocation method and device in centralized cooperative SlAM

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114111803A (en) * 2022-01-26 2022-03-01 中国人民解放军战略支援部队航天工程大学 Visual navigation method of indoor satellite platform
CN114577215A (en) * 2022-03-10 2022-06-03 山东新一代信息产业技术研究院有限公司 Method, device and medium for updating feature map of mobile robot
CN114577215B (en) * 2022-03-10 2023-10-27 山东新一代信息产业技术研究院有限公司 Method, equipment and medium for updating characteristic map of mobile robot
CN114898084B (en) * 2022-04-18 2023-08-25 荣耀终端有限公司 Visual positioning method, device and storage medium
CN114898084A (en) * 2022-04-18 2022-08-12 荣耀终端有限公司 Visual positioning method, device and storage medium
CN117036663A (en) * 2022-04-18 2023-11-10 荣耀终端有限公司 Visual positioning method, device and storage medium
CN114782495A (en) * 2022-06-16 2022-07-22 西安中科立德红外科技有限公司 Multi-target tracking method, system and computer storage medium
CN115049847A (en) * 2022-06-21 2022-09-13 上海大学 Characteristic point local neighborhood characteristic matching method based on ORB descriptor
CN115049847B (en) * 2022-06-21 2024-04-16 上海大学 ORB descriptor-based feature point local neighborhood feature matching method
WO2024001849A1 (en) * 2022-06-28 2024-01-04 中兴通讯股份有限公司 Visual-localization-based pose determination method and apparatus, and electronic device
CN115439536A (en) * 2022-08-18 2022-12-06 北京百度网讯科技有限公司 Visual map updating method and device and electronic equipment
CN115439536B (en) * 2022-08-18 2023-09-26 北京百度网讯科技有限公司 Visual map updating method and device and electronic equipment
CN115451996A (en) * 2022-08-30 2022-12-09 华南理工大学 Homography vision mileometer method for indoor environment
CN115451996B (en) * 2022-08-30 2024-03-29 华南理工大学 Homography visual odometer method facing indoor environment
CN115493612A (en) * 2022-10-12 2022-12-20 中国第一汽车股份有限公司 Vehicle positioning method and device based on visual SLAM
CN116147618A (en) * 2023-01-17 2023-05-23 中国科学院国家空间科学中心 Real-time state sensing method and system suitable for dynamic environment
CN116147618B (en) * 2023-01-17 2023-10-13 中国科学院国家空间科学中心 Real-time state sensing method and system suitable for dynamic environment
CN116778141A (en) * 2023-08-28 2023-09-19 深圳联友科技有限公司 ORB algorithm-based method for rapidly identifying and positioning picture
CN116778141B (en) * 2023-08-28 2023-12-22 深圳联友科技有限公司 ORB algorithm-based method for rapidly identifying and positioning picture
CN117419690B (en) * 2023-12-13 2024-03-12 陕西欧卡电子智能科技有限公司 Pose estimation method, device and medium of unmanned ship
CN117419690A (en) * 2023-12-13 2024-01-19 陕西欧卡电子智能科技有限公司 Pose estimation method, device and medium of unmanned ship
CN117710469A (en) * 2024-02-06 2024-03-15 四川大学 Online dense reconstruction method and system based on RGB-D sensor
CN117710469B (en) * 2024-02-06 2024-04-12 四川大学 Online dense reconstruction method and system based on RGB-D sensor

Also Published As

Publication number Publication date
CN111780763B (en) 2022-05-06
CN111780763A (en) 2020-10-16

Similar Documents

Publication Publication Date Title
WO2022002039A1 (en) Visual positioning method and device based on visual map
WO2022002150A1 (en) Method and device for constructing visual point cloud map
US11798132B2 (en) Image inpainting method and apparatus, computer device, and storage medium
Labbé et al. Cosypose: Consistent multi-view multi-object 6d pose estimation
CN111780764B (en) Visual positioning method and device based on visual map
CN111750864B (en) Repositioning method and device based on visual map
CN109035304B (en) Target tracking method, medium, computing device and apparatus
JP4964159B2 (en) Computer-implemented method for tracking an object in a sequence of video frames
JP5940453B2 (en) Method, computer program, and apparatus for hybrid tracking of real-time representations of objects in a sequence of images
US8503760B2 (en) System and method for real-time object recognition and pose estimation using in-situ monitoring
Touati et al. An energy-based model encoding nonlocal pairwise pixel interactions for multisensor change detection
Chen et al. A hierarchical model incorporating segmented regions and pixel descriptors for video background subtraction
JP2010238226A (en) Method and system for tracking object
CN110097584A (en) The method for registering images of combining target detection and semantic segmentation
WO2019080743A1 (en) Target detection method and apparatus, and computer device
JP2019185787A (en) Remote determination of containers in geographical region
WO2022247126A1 (en) Visual localization method and apparatus, and device, medium and program
Di et al. A unified framework for piecewise semantic reconstruction in dynamic scenes via exploiting superpixel relations
Zhao et al. Learning probabilistic coordinate fields for robust correspondences
CN113112479A (en) Progressive target detection method and device based on key block extraction
US20220311910A1 (en) Corner detection method and corner detection device
CN107067411B (en) Mean-shift tracking method combined with dense features
KR20170037804A (en) Robust visual odometry system and method to irregular illumination changes
Kim et al. Ep2p-loc: End-to-end 3d point to 2d pixel localization for large-scale visual localization
Wang et al. Feature extraction algorithm based on improved ORB with adaptive threshold

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21833195

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21833195

Country of ref document: EP

Kind code of ref document: A1