A visual positioning method, electronic equipment, medium and product
By clustering and screening candidate frames in the visual positioning system, the problem of reduced positioning accuracy caused by texture repetition is solved and the accuracy of the visual positioning system is improved.
Patent Information
- Application Number
- CN202211518232.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-11-29
AI Technical Summary
The existing visual positioning system (VPS) has the problem of reduced positioning accuracy or failure in some scenes, mainly due to inaccurate positioning caused by repeated textures or too many candidate frames with similar textures.
By obtaining multiple retrieved images, determine the rotation information and position information of each candidate frame, cluster representative vectors of similar features, filter out cluster sets that meet preset conditions, calculate the camera pose, and reduce the number of candidate frames with repeated textures. Probability and improve calculation accuracy.
It improves the accuracy of calculating camera poses, ensures that each type of clustering set includes candidate frames of different retrieved images, reduces the impact of texture duplication or similar frames, and improves positioning accuracy.
Smart Images

Figure CN116680431B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a visual positioning electronic device. Background Art
[0002] With the continuous development of AR, VR and Metaverse, the positioning technologies involved, including ultra-wideband, Bluetooth, WIFI and visual positioning VPS, are also maturing. Among them, VPS positioning technology is widely used because it has the advantages of low cost and high positioning accuracy compared with other positioning technologies.
[0003] However, the existing VPS positioning technology has the problem of reduced positioning accuracy or positioning failure in some scenarios. Summary of the invention
[0004] The visual positioning method, electronic device, medium and product provided in this application are intended to solve the problem of reduced positioning accuracy or positioning failure in some scenarios of existing VPS positioning technology.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In the first aspect, the embodiment of the present application is a visual positioning method, which can be applied to an electronic device including a camera, including: obtaining a candidate frame set by searching through multiple retrieved images, and then clustering the candidate frames in the candidate frame set, clustering the candidate frames with similar features into one category, so that multiple cluster sets can be obtained, and then the cluster sets that meet the preset conditions are screened out, and then the camera's posture is determined according to the representative vectors in the cluster sets that meet the preset conditions. In the present application, multiple retrieval images taken at different angles at the same position can be retrieved to retrieve candidate frame sets of multiple retrieval images. In this way, when classifying the candidate frame sets, it can be ensured that each cluster set includes candidate frames retrieved by different retrieval images, which increases the complexity of the retrieval and reduces the probability of candidate frames with repeated textures or similar textures, thereby improving the accuracy of calculating the camera's posture.
[0007] Furthermore, the rotation information and position information of each candidate frame can be determined, wherein the rotation information may include a rotation matrix R, which is used to represent the rotation angle of the camera when taking the picture, and the position information may include a position matrix T, which is used to represent the position of the camera in space when taking the picture. Then, the representative vector of the corresponding candidate frame can be determined based on the rotation matrix and the position matrix, and then the representative vector of each candidate frame can be clustered.
[0008] In some possible implementation methods, taking a candidate frame as an example, the initial position coordinates of the candidate frame in space can be determined according to the position matrix T, for example, it can be recorded as (x0, y0, z0), and then the initial vector P(x0, y0, z0) can be determined through the candidate frame position coordinates and the initial origin coordinates (0, 0, 0). The initial vector can be rotated around any axis through the rotation matrix R, and then the rotation angle in R, that is, the Euler angle, can be used to determine the rotated vector P' after the rotation, and the position coordinates of the selected frame after rotation in space can be determined. After determining the rotation vector P', the coordinates of P' can be marked as (x0', y0', z0'), combined with the initial vector P(x0, y0, z0), and the initial position coordinates (x0, y0, z0) are used to make a vector L that coincides with the P' vector, and the vector L is used as the representative vector of the candidate frame. Based on the same principle, the representative vector corresponding to each candidate frame can be obtained.
[0009] In some possible implementations, for each representative vector, the nearest cluster center is found, and the representative vectors whose distance from the cluster center is less than a first spatial offset threshold and whose offset angle with the cluster center is within a first deviation angle threshold are grouped into one category. For example, the first spatial offset threshold can be set to 5m, and the first deviation angle threshold is 10 degrees. Then, for a certain cluster center, the representative vectors whose distance from the cluster center is less than 5m and whose offset deviation angle with the cluster center is less than 10 degrees are grouped into one category. Based on the same principle, multiple representative vectors can be clustered to obtain multiple cluster sets.
[0010] Furthermore, the cluster sets with the top M representative vector quantities are selected from the obtained multiple cluster sets, where M is a positive integer greater than or equal to 2.
[0011] In some possible implementations, in order to effectively reduce the matching and posture calculation time, the filtered cluster sets can also be secondary clustered to obtain multiple secondary cluster sets. Specifically, a second deviation angle threshold and a second spatial offset threshold can be set. For example, the second spatial offset threshold can be set to 2.5m, and the second deviation angle threshold can be set to 5 degrees. For a certain secondary clustering center, the representative vectors whose distance from the center is less than 2.5m and whose deviation angle from the center is less than 5 degrees are found as one category. Based on the same principle, the filtered cluster sets that meet the preset conditions can be re-clustered to obtain multiple secondary cluster sets. The cluster set with the largest number of representative vectors is filtered out from the multiple secondary cluster sets, and then the posture of the electronic device is determined based on the candidate frames in the cluster set with the largest number of representative vectors.
[0012] In some possible implementations, feature extraction and feature matching can be performed on the candidate frames corresponding to each representative vector to determine at least three feature points. For example, four sets of solutions can be calculated using three feature points. Each solution can be called a pose information, which is used to determine the camera's pose. Each pose information may include a set of rotation matrices and translation matrices. Four rotation matrices and translation matrices are obtained, and then the fourth feature point is used as a check point. The world coordinates of the fourth feature point are substituted into the calculated matrix, that is, the camera pose is calculated from the four possible solutions respectively, and four projections in space are obtained (one solution corresponds to one projection). Then, the fourth feature point is reprojected, and the error is calculated to determine that the solution with the smallest error is the camera's pose.
[0013] In a second aspect, the present application provides an electronic device, including: a camera processor and a memory;
[0014] The camera is used to collect video streams;
[0015] One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device performs the method described in any one of the first aspects.
[0016] In a third aspect, the present application provides a computer storage medium, comprising computer instructions, which, when executed on a mobile terminal, enables the electronic device to execute the method described in any one of the first aspects.
[0017] In a fourth aspect, the present application provides a computer program product, comprising instructions; when the instructions are executed by an electronic device, the electronic device executes the method described in any one of the first aspects.
[0018] It can be seen from the above technical solution that the present application has the following beneficial effects:
[0019] The embodiment of the present application can obtain multiple retrieval images, and retrieve the candidate frame sets through the obtained multiple retrieval images, and then determine the representative vector of each candidate frame through the rotation information and position information of each candidate frame set, and then cluster the representative vectors with similar features into one category to obtain multiple cluster sets, screen out the cluster sets that meet the preset conditions, and then calculate the camera's posture according to the representative vectors in the cluster sets that meet the preset conditions. In the present application, multiple retrieval images taken at different angles at the same position can be used for retrieval, and then candidate frame sets of multiple retrieval images can be retrieved. In this way, when the candidate frame sets are classified, it can be ensured that each cluster set includes candidate frames retrieved by different retrieval images, which increases the complexity of the retrieval and reduces the probability of candidate frames with repeated textures or similar textures, thereby improving the accuracy of calculating the camera's posture. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 An exemplary diagram of the composition of an electronic device provided in an embodiment of the present application;
[0021] Figure 2 An example diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0022] Figure 3A A schematic diagram of a user opening a camera application provided in an embodiment of the present application;
[0023] Figure 3B A camera interface preview diagram provided in an embodiment of the present application;
[0024] Figure 3C A schematic diagram of vector rotation provided in an embodiment of the present application;
[0025] Figure 3D A schematic diagram of vector clustering provided in an embodiment of the present application;
[0026] Figure 4 A flowchart of a visual positioning method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.
[0028] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0029] In order to make the description of the following embodiments clear and concise, a brief introduction to the related technology is first given:
[0030] VPS stands for Visual Positioning System / Service. This technology is based on 3D maps and matches image data captured by cameras such as smart terminals. It can identify location information with high accuracy. It is a service that can combine camera data with AR and provide accurate information. This mechanism can reduce the cost of developing information infrastructure and systems, using camera images to identify locations based on existing general three-dimensional maps. This technology was launched by Google and can accurately locate indoors without satellite signals.
[0031] In the prior art, VPS positioning obtains a search image through an electronic device, and searches the search image to find multiple candidate frames in the same scene from a database. Since the search is performed through a search image, the angle is limited, so there are many candidate frames with repeated textures or similar textures among the multiple candidate frames retrieved, resulting in inaccurate positioning.
[0032] The embodiment of the present application provides a visual positioning method to solve the problem of reduced positioning accuracy or positioning failure in some scenarios of the existing VPS positioning technology. In order to make the technical solution of the present application clearer and easier to understand, the image processing method provided by the embodiment of the present application is introduced from the perspective of electronic equipment in combination with the accompanying drawings.
[0033] Figure 4 A flowchart of a visual positioning method provided in an embodiment of the present application is shown in FIG. Figure 4 The specific steps shown include:
[0034] S101: The electronic device obtains multiple search images.
[0035] In this embodiment, the multiple search images refer to multiple photos taken by a camera at different angles at the same position.
[0036] The electronic device can take photos through the camera to obtain multiple search images. For example, the electronic device can take photos through a single camera or through multiple cameras, and this application does not limit this. Among them, taking photos through a single camera can refer to the electronic device taking photos through a single camera 193; taking photos through multiple cameras can refer to the electronic device taking photos through multiple cameras 193 (for example, two cameras, the two cameras can be a main camera and a portrait camera, or a wide-angle camera and a telephoto camera, etc.). The embodiment of the present application does not specifically limit whether it is a single camera or a multi-camera photo. The skilled technician can set the electronic device to select a single camera or a multi-camera according to the actual scenario.
[0037] When a user performs a touch operation on the touch sensor 180K, the touch sensor 180K can obtain the user's touch operation and report the touch operation to the processor 110. After receiving the touch operation sent by the touch sensor 180K, the processor 110 can respond to the touch operation and start the application corresponding to the touch operation.
[0038] like Figure 3A As shown, Figure 3A A schematic diagram of a user opening a camera application is shown. For example, the user touches to open the camera. The touch sensor 180K can receive the user's touch operation on the camera icon 301 and report the touch operation on the camera icon 301 to the processor 110. After receiving the touch operation on the camera icon 301, the processor 110 can respond to the above touch operation, start the application corresponding to the camera icon 301 (which can be simply referred to as the camera application), and display the camera's shooting preview interface on the display screen 194.
[0039] In addition, in the embodiment of the present application, other methods can be used to enable the electronic device to start the camera application and display the camera shooting preview interface on the display screen 194. This is not limited here.
[0040] In some implementations, after the processor 110 starts the camera application, the camera application may automatically enter the photo taking mode. Figure 3BAs shown, the shooting preview interface of the camera application may include various functional controls such as a mode selection control 302 and a camera setting control 303. The touch sensor 180K may receive the user's touch operation on the above functional controls and report it to the processor 110, so that the processor 110 controls the camera application to enter the corresponding interface in response to the above touch operation. In some examples, the user can trigger the camera application to enter different shooting modes through the mode selection control 302. The shooting mode may be, for example, a VR mode, a telephoto mode, etc., and the camera setting control 303 may be used to enable functions such as filters, watermarks, and panorama. For example, the user may set the initial mode of the camera application to VR mode through the camera setting control 303. When the user reopens the camera application again, the camera application automatically enters VR mode. The initial mode of the camera application may also be set to a video recording mode through the camera setting control 303. When the user reopens the camera application again, the camera application automatically enters the video recording mode.
[0041] After the electronic device enters the VR mode, the user can click the control 304 in the shooting preview interface to trigger the photo shooting operation. After the electronic device detects that the user has triggered the photo shooting operation, it can start shooting and obtain the retrieved image. In some embodiments, the user can also trigger the photo shooting operation by gesture shooting and sound shooting. The electronic device detects the photo shooting gesture set by the user or the sound set by the user, and can trigger the photo shooting operation to start shooting.
[0042] The electronic device responds to multiple photo-taking operations triggered by the user, adjusting a different shooting angle each time, and can obtain multiple retrieval pictures.
[0043] S102: The electronic device retrieves a database picture set from a database according to a plurality of retrieval pictures.
[0044] In this embodiment, the database may also be called a feature map, which may be pre-built based on the basic requirements. The database image refers to an image retrieved from the database, and the database image set includes multiple database images. The database image retrieved from the database according to each retrieved image may also be called a candidate frame.
[0045] Specifically, the electronic device may preset the number of database images that can be retrieved from the database for each search image. For example, 50 database images can be retrieved from the database by presetting one search image. Then, the multiple database images retrieved by each search image may be regarded as a picture subset and a value N may be preset, indicating that the first N database images in each picture subset are taken.
[0046] In some possible implementation methods, feature extraction can be performed on each retrieved image to obtain feature representation, and then similarity measurement and metric learning can be performed. Finally, the images in the obtained multiple image subsets can be sorted according to similarity, and then the first image in each image subset can be taken to obtain the retrieval result, that is, the database image set.
[0047] The following example uses 3 search images to retrieve 150 database images from the database, with N being 30.
[0048] The first search image can retrieve 50 database images from the database to obtain a subset of images corresponding to the first search image, which can be called the first image subset here. The second search image can retrieve 50 database images from the database to obtain a subset of images corresponding to the second search image, which can be called the second image subset here. The third search image can retrieve 50 database images from the database to obtain a subset of images corresponding to the third search image, which can be called the third image subset here. It should be noted that the database images in each image subset are sorted from high to low according to similarity, and then the first 30 database images in each image subset are taken out, that is, 90 database images form a database image set. It is worth noting that the numbers 1, 3, 50, etc. that appear here are only exemplary examples and are not limited here.
[0049] S103: The electronic device obtains rotation information and position information of each database image in the database image set.
[0050] In this embodiment, the rotation information may include a rotation matrix R, which is used to represent the rotation angle of the camera when taking the picture, and the position information may include a position matrix T, which is used to represent the position of the camera in space when taking the picture.
[0051] The rotation information and position information of each database image are obtained from the database to determine the rotation angle and the position in space of each database image.
[0052] S104: Determine a representative vector of the corresponding database image according to the rotation information and the position information, and obtain a plurality of representative vectors.
[0053] In this embodiment, the database pictures obtained by retrieval can be called candidate frames, such as Figure 3C As shown, taking a candidate frame as an example, according to [R, T] of the candidate frame in the database, the position coordinates of the candidate frame after rotation in space can be determined.
[0054] Specifically, the initial position coordinates of the candidate frame in space can be determined according to the position matrix T, for example, it can be recorded as (x0, y0, z0), and then the initial vector P(x0, y0, z0) can be determined through the candidate frame position coordinates and the initial origin coordinates (0, 0, 0). The initial vector can be rotated around any axis through the rotation matrix R, and then the rotation angle in R, that is, the Euler angle, can be used to determine the rotated vector P' after the rotation, and the position coordinates of the selected frame after rotation in space can be determined.
[0055] Furthermore, the four elements [q0, q1, q2, q3] can be determined by the rotation matrix R. The Euler angle of the rotation matrix R can be calculated by the four elements. The specific formula is as follows:
[0056]
[0057] Among them, Φ, θ, Ψ represent the angle measurement of the image rotation relative to the original coordinate axis, that is, the Euler angle. According to the Euler angle and the rotation matrix R, the translation component t of P(x0, y0, z0) around any axis can be determined. Then, according to the translation component and the rotation matrix R, the 4*4 transformation matrix of the candidate frame can be determined. According to the 4*4 transformation matrix, the rotated vector P' can be calculated. The specific formula is as follows:
[0058]
[0059] Where R is the 3*3 matrix of the rotation component, and t is the 3*1 vector of the translation component. The rotated vector P' can be calculated based on the product of the T4*4 transformation matrix and the P vector, and then the representative vector L can be determined based on P' and P.
[0060] Specifically, after determining the rotation vector P', the coordinates of P' can be marked as (x0', y0', z0'). Combined with the initial vector P (x0, y0, z0), a vector L that coincides with the P' vector is made through the initial position coordinates (x0, y0, z0). Vector L is used as the representative vector of the candidate frame. Based on the same principle, the representative vector corresponding to each candidate frame can be obtained.
[0061] In some possible implementations, the length of each representative vector L is limited. In order to cluster candidate frames at a certain angle together, each representative vector L may be extended separately.
[0062] S105: The electronic device clusters the multiple representative vectors to obtain multiple cluster sets.
[0063] In this embodiment, the electronic device can cluster multiple representative vectors by using the kmeans clustering algorithm to obtain multiple cluster sets. The kmeans clustering algorithm can be used to cluster multiple representative vectors, and representative vectors with similar features are clustered into one category.
[0064] Specifically, Figure 3D As shown, the first deviation angle threshold and the first spatial offset threshold are pre-set, and then the number of categories k to be clustered is selected, and the centers of k cluster sets are selected. It should be noted that k can be selected according to needs, and the center of the cluster set can also be called the cluster center. For example, there are 3. Of course, this is just an example and is not specifically limited. For each representative vector, find the center of the sphere closest to it, and group the distance from the center of the sphere less than the first spatial offset threshold and the offset angle with the center of the sphere within the first deviation angle threshold range into one category. For example, the first spatial offset threshold can be set to 5m, and the first deviation angle threshold is 10 degrees. For a certain center of the sphere, find the representative vector with a distance from the center of the sphere less than 5m and an offset deviation angle with the center of the sphere less than 10 degrees as one category. Based on the same principle, multiple representative vectors can be clustered to obtain multiple cluster sets. Among them, the representative vectors in each cluster set roughly intersect at the same point.
[0065] It should be noted that several cluster sets may represent the same angle. Taking three angles at the same position as an example, the multiple frame selection results are clustered to obtain multiple cluster sets. The multiple cluster sets can be divided into up to three categories of results. Each category of results can represent an angle. It should be noted that each category of results may include several cluster sets. In each category of results, the representative vectors of candidate frames between different cluster sets are parallel because the transformation in space is consistent, but the positions of the spatial coordinate points may be different; the angles of the candidate frames may fluctuate within a certain angle. For example, the three categories of results can be divided into the first category of results, the second category of results and the third category of results. The first category of results includes the first cluster set and the second cluster set, and the second category of results includes the second cluster set and the third cluster set. Because the first cluster set and the second cluster set both belong to the first category of results, the first cluster set and the second cluster set represent an angle, and the representative vector in the first cluster set and the representative in the second cluster set are parallel to each other. The third cluster set and the fourth cluster set both belong to the second category of results, so the third cluster set and the fourth cluster set represent an angle, and the representative vector in the third cluster set and the representative direction in the fourth cluster set are parallel to each other.
[0066] In some embodiments, in order to avoid large error in the result due to large coordinates of the center of the cluster set, the cluster sets whose center coordinates are greater than the coordinate threshold can be filtered out, and the candidate frames corresponding to the vectors in the cluster sets whose center coordinates are greater than the coordinate threshold can be filtered out, where the coordinate threshold can be pre-set according to needs.
[0067] S106: The electronic device selects a cluster set that meets a preset condition from among the multiple cluster sets.
[0068] The preset condition may be to select the cluster sets with the top M representative vectors from multiple cluster sets, where M may be preset to at least 2. For example, in the case of 3, the cluster sets with the top 3 representative vectors are selected from multiple cluster sets. For example, multiple representative vectors are clustered to obtain 5 cluster sets, where the number of representative vectors included in the cluster sets is 10, 9, 8, 7, and 6, respectively. Then, cluster sets corresponding to the number of representative vectors of 10, 9, and 8 are selected. Then, the cluster sets that do not meet the preset conditions and the abnormal candidate frames therein are removed.
[0069] In some embodiments, in order to effectively reduce the matching and pose calculation time, the filtered cluster set can be further subjected to secondary clustering to obtain multiple secondary cluster sets, and the center of the secondary cluster set can be called the center of this cluster.
[0070] A second deviation angle threshold and a second spatial offset threshold can be set. It should be noted that the second deviation angle threshold and the second spatial offset threshold can be obtained by adjusting the first deviation angle threshold and the first spatial offset threshold. For example, the second spatial offset threshold can be set to 2.5m, and the second deviation angle threshold is 5 degrees. For a certain secondary clustering sphere center, the representative vectors whose distance from the sphere center is less than 2.5m and whose deviation angle from the sphere center is less than 5 degrees are found as one category. Based on the same principle, the clustering sets that meet the preset conditions can be re-clustered to obtain multiple secondary clustering sets. Then, the clustering set with the largest number of representative vectors is selected from the secondary clustering set. In this way, the clustering set with the largest number of representative vectors is selected from the secondary clustering set.
[0071] S107: The electronic device calculates the position and posture of the camera according to the representative vector in the cluster set that meets the preset conditions.
[0072] The electronic device can calculate the camera's pose through the PnP algorithm.
[0073] PnP (full name Perspective-n-Points) refers to the problem of object motion positioning from 3D to 2D point pairs, that is, given the coordinates of the object in the world coordinate system and the pixel coordinates of the object in the image plane of the camera, the camera's position and posture are solved.
[0074] Specifically, the electronic device may extract features from the candidate frames corresponding to each representative vector, and then perform feature matching between the candidate frames, thereby obtaining feature points.
[0075] The following discusses the following situations:
[0076] Case 1:
[0077] When N is equal to 1, that is, when there is only one feature point, assume that the feature point is p1, the optical center of the camera is Oc, and assume that the feature point is in the middle of the image, that is, p1Oc is the camera z-axis. At this time, the camera may be at any point on a sphere with an arbitrary radius and the feature point p1 as the center, and the radius of the sphere cannot be determined. There are countless solutions.
[0078] Case 2:
[0079] When N is equal to 2, assuming that the two feature points are p1 and p2, and the optical center of the camera is Oc, the world coordinates of p1 and p2 are known, then the distance between p1p2 is known, and the pixel coordinates of the feature points and the camera internal parameters are known, and the cosine value of ∠p1Ocp2 can be calculated. The pinhole imaging model can be used to calculate that the length of one of the sides Ocp1 is equal to r1, and then the cosine theorem is used to calculate that the length of the other side Ocp2 is equal to r2. Then, a sphere is drawn with p1 and p2 as the center and r1 and r2 as the radius. The intersection of the two spheres is the possible position of the camera. At this time, there are still countless solutions. The junction of the two spheres is an area, and the camera may be at any position in this area.
[0080] Case 3:
[0081] When N is equal to 3, a sphere with P3 as the center is added on the basis of the original one. At this time, the camera is located at the intersection of the three spheres. There are four points at the intersection, that is, there are four possible solutions for the camera position, one of which is the optimal solution.
[0082] Case 4:
[0083] When N is greater than 3, another sphere is added, and the four spheres intersect at one point, which is the position of the camera. However, as can be seen from case 3, when three feature points are known, four possible solutions can be found, and the optimal solution is one of the four solutions. In order to find the optimal solution, one more feature point is considered, which will obviously increase the calculation time.
[0084] In order to increase the calculation efficiency, we can first use three feature points to calculate four sets of solutions. Each solution can be called a pose information, which is used to determine the camera's pose. Each pose information can include a set of rotation matrix and translation matrix. After obtaining four rotation matrices and translation matrices, we can choose to use the fourth feature point as the test point, and bring the world coordinates of the fourth feature point into the calculated matrix. That is, we can calculate the camera pose from the four possible solutions respectively, and obtain four projections in space (one solution corresponds to one projection). Then, after reprojecting the fourth feature point, we can calculate the error and determine that the solution with the smallest error is the camera's pose.
[0085] Therefore, the electronic device can obtain at least three feature points by matching features between candidate frames, and then project them separately, calculate the errors, and determine that the solution with the smallest error is the camera pose.
[0086] In the embodiments provided in the present application, the electronic device can obtain multiple retrieval images, retrieve through the multiple retrieval images to obtain a candidate frame set, and then determine the representative vector of each candidate frame through the rotation information and position information of each candidate frame set, and then cluster the representative vectors with similar features into one category to obtain multiple cluster sets, so that a cluster set that meets the preset conditions can be screened out from the multiple cluster sets, and then the camera's posture can be calculated based on the representative vectors in the cluster sets that meet the preset conditions. In the present application, multiple retrieval images taken at different angles at the same position can be retrieved to retrieve candidate frame sets of multiple retrieval images. In this way, when classifying the candidate frame sets, it can be ensured that each cluster set includes candidate frames retrieved by different retrieval images, which increases the complexity of the retrieval and reduces the probability of candidate frames with repeated textures or similar textures, thereby improving the accuracy of calculating the camera posture.
[0087] In some embodiments, the electronic device may be a mobile phone, a tablet computer, a desktop, a laptop, a notebook computer, an ultra-mobile personal computer (UMPC), a handheld computer, a netbook, a personal digital assistant (PDA), a wearable electronic device, a smart watch, etc. The present application does not impose any special restrictions on the specific form of the above electronic devices. In this embodiment, the structure of the electronic device may be as follows: Figure 1 As shown, Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0088] like Figure 1As shown, the electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a touch sensor 180K, etc.
[0089] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0090] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0091] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0092] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0093] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0094] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface to realize the touch function of the electronic device.
[0095] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0096] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0097] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0098] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to realize the shooting function of the electronic device. The processor 110 and the display screen 194 communicate via the DSI interface to realize the display function of the electronic device.
[0099] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0100] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge an electronic device, and can also be used to transfer data between an electronic device and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0101] It is understandable that the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0102] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor.
[0103] The electronic device implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0104] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oled, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0105] A series of graphical user interfaces (GUIs) can be displayed on the display screen 194 of the electronic device, and these GUIs are the main screens of the electronic device. Generally speaking, the size of the display screen 194 of the electronic device is fixed, and only limited controls can be displayed on the display screen 194 of the electronic device. A control is a GUI element, which is a software component included in an application program, and controls all data processed by the application program and interactive operations on the data. Users can interact with the control through direct manipulation to read or edit relevant information of the application program. Generally speaking, a control can include visual interface elements such as icons, controls, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets.
[0106] The electronic device can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0107] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature, and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0108] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0109] Digital signal processors are used to process digital signals. In addition to processing digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency point, a digital signal processor is used to perform Fourier transform on the frequency point energy.
[0110] Video codecs are used to compress or decompress digital videos. Electronic devices can support one or more video codecs. In this way, electronic devices can play or record videos in multiple coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0111] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and continuously self-learn. NPU can realize applications such as intelligent cognition of electronic devices, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0112] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos can be stored in the external memory card.
[0113] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 121, and / or the instructions stored in the memory provided in the processor.
[0114] The electronic device can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0115] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0116] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device can listen to music or listen to a hands-free call through the speaker 170A.
[0117] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0118] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device can be provided with at least one microphone 170C. In other embodiments, the electronic device can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device can also be provided with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, and directional recording function, etc.
[0119] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0120] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device, which is different from the position of the display screen 194.
[0121] The key 190 includes a power key, a volume key, etc. The key 190 can be a mechanical key or a touch key. The electronic device can receive key input and generate key signal input related to user settings and function control of the electronic device.
[0122] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0123] In addition, an operating system is running on the above components, such as the iOS operating system developed by Apple, the Android open source operating system developed by Google, and the Windows operating system developed by Microsoft. Application programs can be installed and run on the operating system.
[0124] The operating system of the electronic device may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device.
[0125] Figure 2 It is an example diagram of the software structure of the electronic device according to the embodiment of the present application.
[0126] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, framework layer, Android runtime and system library, and kernel layer.
[0127] The application layer can include a series of application packages. Figure 2 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0128] The framework layer provides application programming interface (API) and programming framework for the application layer. The framework layer includes some predefined functions. Figure 2 As shown, the framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0129] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0130] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0131] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0132] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0133] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0134] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0135] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0136] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0137] The application layer and framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0138] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0139] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0140] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0141] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0142] A 2D graphics engine is a drawing engine for 2D drawings.
[0143] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0144] It should be noted that although the embodiments of the present application are described using the Android system as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS and Windows.
[0145] An embodiment of the present application further provides a computer storage medium, comprising computer instructions, which, when executed on a mobile terminal, enables the electronic device to execute a method as described in any one of the above embodiments.
[0146] An embodiment of the present application further provides a computer program product, including instructions; when the instructions are executed by an electronic device, the electronic device executes any of the methods described in the above embodiments.
[0147] The technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk, etc., various media that can store program codes.
[0148] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A visual positioning method, applied to electronic equipment, characterized in that: include: Get multiple search images; Searching according to the multiple search images to obtain a set of candidate frames; Determine rotation information and position information of each candidate frame in the candidate frame set; The rotation information includes a rotation matrix, and the position information includes a position matrix; According to the position matrix of each candidate frame, the initial origin coordinates and initial vector of the corresponding candidate frame in space are determined, each of the initial vectors is rotated according to the corresponding rotation matrix, the vector of each candidate frame after rotation in space is determined, and a line segment is made through each initial origin coordinate to coincide with the corresponding rotated vector to obtain a representative vector of each candidate frame; Clustering the representative vector of each candidate frame to obtain multiple cluster sets; Filtering out a cluster set that meets a preset condition from the multiple cluster sets; Determining the posture of the electronic device according to the candidate frames in the cluster set that meets the preset conditions, wherein determining the posture of the electronic device according to the candidate frames in the cluster set that meets the preset conditions includes: Perform feature extraction and feature matching on the candidate frames corresponding to each representative vector in the cluster set that meets the preset conditions to determine at least three feature points; Determine a plurality of position and posture information according to the at least three feature points, wherein the position and posture information is used to determine the position and posture of the electronic device; The posture of the electronic device is determined based on the posture information with the smallest reprojection error among the multiple posture information.
2. The method according to claim 1, characterized in that The clustering of the representative vector of each candidate frame includes: Determine multiple cluster sphere centers and the position of each cluster sphere center; The nearest cluster center is determined for each representative vector, and vectors whose distance from the cluster center is less than a first spatial offset threshold and whose offset angle from the cluster center is less than a first deviation angle threshold are grouped into one category.
3. The method according to claim 2, characterized in that The step of selecting a cluster set that meets a preset condition from the plurality of cluster sets includes: A cluster set with the top M number of representative vectors is selected from the multiple cluster sets, where M is a positive integer greater than or equal to 2.
4. The method according to claim 3, characterized in that Before determining the position and posture of the electronic device according to the candidate frames in the cluster set that meets the preset conditions, the method further includes: Determine the secondary clustering sphere center and the position of each secondary clustering sphere center; Determine the nearest secondary clustering sphere center for each representative vector in the screened clustering set, and group the vectors whose distance to the secondary clustering sphere center is less than a second spatial offset threshold and whose offset angle to the secondary clustering sphere center is less than a second deviation angle threshold into one category; obtain multiple secondary clustering sets; Filtering out a cluster set with the largest number of representative vectors from the multiple secondary cluster sets; The step of determining the posture of the electronic device according to the candidate frames in the cluster set that meets the preset conditions includes: The posture of the electronic device is determined according to the candidate frames in the cluster set with the largest number of representative vectors.
5. An electronic device, characterized in that: include: Camera, processor and memory; The camera is used to collect video streams; Wherein, one or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-4.
6. A computer storage medium, characterized in that: The method comprises computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 4.
7. A computer program product, characterized in that When the computer program product runs on a computer, the computer executes the method according to any one of claims 1 to 4.
