A 3D reconstruction method combining IMU data
By combining IMU data to analyze the matching relationship of image pairs, the problem of mismatching in 3D reconstruction is solved, the reconstruction effect is improved, and the accuracy of the 3D model is ensured.
Patent Information
- Application Number
- CN202310216413.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-02-27
AI Technical Summary
Existing three-dimensional reconstruction methods in indoor environments lead to feature matching errors due to similar structures of reconstructed objects, resulting in mismatching and affecting the reconstruction effect.
Combined with IMU data, by obtaining and analyzing the position and direction of each frame of image, the matching relationship between image pairs is determined, and mismatched image pairs are deleted, thereby improving the reconstruction effect.
It effectively avoids mismatching, improves the accuracy and reliability of 3D reconstruction, and ensures the accuracy of the output 3D model.
Smart Images

Figure CN117115333B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision, and in particular to a three-dimensional reconstruction method combining IMU data. Background Art
[0002] High-precision 3D reconstruction is one of the important research directions of computer vision. Due to the similar structures of the reconstructed objects themselves, existing reconstruction methods may cause feature matching errors, resulting in unsatisfactory reconstruction results. For example, when performing 3D reconstruction of indoor environments (such as offices, shopping malls, and teaching buildings), existing reconstruction methods may make mismatches in areas with similar indoor backgrounds and furnishings, thereby judging images collected at completely different locations as images of the same location, affecting the reconstruction effect. Summary of the invention
[0003] The present application provides a three-dimensional reconstruction method combined with IMU data. When an electronic device performs three-dimensional reconstruction of a reconstructed object based on a video sequence of the reconstructed object, it can determine whether a similar image pair has a mismatch in combination with the position and direction of each frame of the image captured by the electronic device. After determining that a mismatch has occurred, the electronic device can delete the mismatched similar image pairs, thereby shielding the negative impact of the mismatched image pairs and improving the reconstruction effect.
[0004] In a first aspect, the present application provides a data processing method, applied to a first electronic device, the method comprising: obtaining a first video sequence obtained by shooting a first space by a second electronic device; determining multiple image pairs in the first video sequence; obtaining first pose data, the first pose data including an acquisition direction of each frame image in the first video sequence; using the first image pair to establish a three-dimensional model of the first space, the first image pair including a second image pair whose image acquisition direction matches among the multiple image pairs, and not including a third image pair whose image acquisition direction does not match among the multiple image pairs.
[0005] By implementing the method provided in the first aspect, the first electronic device can obtain the video sequence and posture data for reconstruction. Among them, the first electronic device can determine the acquisition direction of each frame of the video sequence through the posture data, and then the first electronic device can determine the positional relationship of the image pair composed of two frames of images according to the above posture data, and determine whether the two frames of images match. The first electronic device can select image pairs with matching acquisition directions from the image pairs, and then use the image pairs with matching acquisition directions for three-dimensional reconstruction, thereby shielding the negative impact of mismatched (i.e., mismatched) image pairs and improving the reconstruction effect.
[0006] In combination with the method provided in the first aspect, in some embodiments, the acquisition directions are matched, specifically including: an angle between the acquisition directions is less than or equal to a first threshold.
[0007] By implementing the method provided in the above embodiment, the first electronic device can determine that the image acquisition directions in the image pair match when the acquisition method angle of the image pair is less than or equal to a preset value, such as a first threshold; conversely, when the acquisition method angle of the image pair is greater than the above preset value, the first electronic device can determine that the image acquisition directions in the image pair do not match.
[0008] In combination with the method provided in the first aspect, in some embodiments, the first pose data also includes the acquisition position of each frame image in the first video sequence; and the image acquisition positions in the second image pair match.
[0009] In the implementation of the method provided in the above embodiment, the first pose data also includes the acquisition position of each frame of the image in the video sequence. On the basis of determining the acquisition method angle of the image pair, the first electronic device can also determine the position difference between the two frames of the image in the image pair through the above acquisition position. Combining the acquisition method angle and the position difference, the first electronic device can determine whether the two frames of the image in the image pair are images of the same object taken at the same position, thereby avoiding mismatching and improving the reconstruction effect.
[0010] In combination with the method provided in the first aspect, in some embodiments, the acquisition positions are matched, specifically including: the distance between the acquisition positions is less than or equal to a second threshold.
[0011] By implementing the method provided in the above embodiment, when the distance difference between the acquisition positions of an image pair is less than or equal to the second threshold, the first electronic device can determine that the image acquisition positions in the image pair match; conversely, when the distance difference between the acquisition positions of an image pair is greater than the second threshold, the first electronic device can determine that the image acquisition positions in the image pair do not match.
[0012] In combination with the method provided in the first aspect, in some embodiments, the image contents of two frames of images in any one of the multiple image pairs are similar.
[0013] By implementing the method provided in the above embodiment, the first electronic device can first determine similar images with similar image content from the video sequence. Based on the similar image pairs, the first electronic device can determine whether the similar image pairs are correctly matched images of the same object taken at the same location, thereby avoiding mismatching and improving the reconstruction effect. If the image pairs are not similar, it is obvious that the first electronic device will not use the image pair for reconstruction, and therefore, will not affect the reconstruction result.
[0014] In combination with the method provided in the first aspect, in some embodiments, the first posture data is obtained by any one or more of the following: accelerometer data or gyroscope data collected when the second electronic device shoots the first video sequence.
[0015] When implementing the method provided in the above embodiment, the second electronic device can be configured with an IMU, and while collecting the video sequence, the accelerometer data and the gyroscope data can be collected through the IMU. Then, the second electronic device, or the first electronic device, can determine the direction and position of the second electronic device at any time during the collection process by integrating the above accelerometer data and the gyroscope data, and then the first electronic device can determine the collection method and collection position corresponding to each frame image in the video sequence when performing three-dimensional reconstruction, and determine whether the image pair is a correctly matched image of the same object taken at the same position.
[0016] In combination with the method provided in the first aspect, in some embodiments, before using the first image pair to establish a three-dimensional model of the first space, the method also includes: determining the external points of a fourth image pair, the fourth image pair being any one of the first image pairs, and the external points of an image pair refer to feature points in the image pair that do not conform to the projection relationship of the image pair; deleting the external points of the fourth image pair.
[0017] By implementing the method provided in the above embodiment, after the first electronic device determines the correctly matched similar graphic pairs, it can determine the feature point pairs with unreasonable matching relationships in the similar graphic pairs, and then delete the above feature point pairs to shield the negative impact of the incorrectly matched feature point pairs in the image pairs and improve the reconstruction effect.
[0018] In combination with the method provided in the first aspect, in some embodiments, determining the external points of the fourth image pair specifically includes: using a first number of feature point pairs in the fourth image pair to determine a first basic matrix, the first basic matrix is used to represent the projection relationship of the fourth image pair; determining the external points in the remaining feature point pairs in the fourth image pair whose projection relationship is inconsistent with the first basic matrix, and the ratio of the number of external points to the number of all feature points in the fourth image pair is less than or equal to a third threshold.
[0019] By implementing the method provided in the above embodiment, the first electronic device can determine the basic matrix with a smaller error than the actual projection relationship through an iterative feature point pair back-deduction method, thereby avoiding the elimination of correctly matched feature point pairs in the image pair after the basic matrix error is large, while retaining the incorrectly matched feature point pairs.
[0020] In combination with the method provided in the first aspect, in some embodiments, the error between the first angle and the second angle is less than or equal to a fourth threshold, the first angle is the acquisition direction angle of the fourth image pair determined by the first basic matrix, and the second angle is the acquisition direction angle of the fourth image pair determined by the first pose data.
[0021] By implementing the method provided in the above embodiment, the first electronic device can determine the projection relationship between the image pairs through the IMU data, and then further verify the basic matrix reflecting the projection relationship determined by the feature point pairs. When the two verify each other, the first electronic device can determine that the basic matrix reflecting the projection relationship determined by the feature point pairs is valid, and then the first electronic device can use the above valid basic matrix to determine the external points in the image pair, perform external point removal, and further avoid removing the correctly matched feature point pairs in the image pair after the basic matrix error is large, while retaining the incorrectly matched feature point pairs.
[0022] In combination with the method provided in the first aspect, in some embodiments, the first space has the same or similar structure at two or more locations.
[0023] When implementing the method provided in the above embodiment, when the first space has the same or similar structures at two or more positions, the first electronic device is prone to mismatching when determining similar image pairs, thereby affecting the reconstruction effect. In this case, the three-dimensional reconstruction method combined with IMU data provided by this application can effectively solve the above mismatching problem, ensure the reconstruction effect, and output an accurate and reliable three-dimensional model.
[0024] In a second aspect, the present application provides an electronic device, comprising one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method described in the first aspect and any possible implementation method of the first aspect.
[0025] In a third aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions so that the electronic device executes the method described in the first aspect and any possible implementation method of the first aspect.
[0026] In a fourth aspect, the present application provides a computer-readable storage medium comprising instructions, which, when executed on an electronic device, causes the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect.
[0027] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect.
[0028] It can be understood that the electronic device provided in the second aspect, the chip system provided in the third aspect, the computer storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method provided in the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of an electronic device provided in an embodiment of the present application;
[0030] Figure 2 A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;
[0031] Figure 3 A schematic diagram of an electronic device group provided in an embodiment of the present application;
[0032] Figure 4 An indoor floor plan of a building provided for an embodiment of the present application;
[0033] Figure 5 The embodiment of the present application provides a set of images S1 and S2 acquired at different positions;
[0034] Figure 6 is a flow chart of a three-dimensional reconstruction method combining IMU data provided in an embodiment of the present application;
[0035] Figure 7 is a schematic diagram of image centering feature points provided by an embodiment of the present application;
[0036] Figure 8 This is a schematic diagram of another mismatch provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application.
[0038] Figure 1 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0039] The present application embodiment provides an electronic device, which is denoted as electronic device 100. Figure 1 As shown, the electronic device 100 may be configured with a camera module 130. The camera module 130 may include one or more cameras. The one or more cameras include but are not limited to a wide-angle camera, an ultra-wide-angle camera, a telephoto camera, a black-and-white camera, etc. Any camera may continuously output a two-dimensional image, that is, output a video sequence composed of two-dimensional images.
[0040] A 3D reconstruction client is pre-installed in the electronic device 100. The 3D reconstruction client is an application pre-installed with an algorithm code corresponding to the 3D reconstruction method described in this application, and can perform feature extraction on the video sequence output by the camera module 130 according to the 3D reconstruction method described in this application, thereby constructing a 3D scene corresponding to the video sequence.
[0041] Specifically, Figure 2 A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application.
[0042] The electronic device 100 may include a processor 110, a memory 120, a camera module 130, a display screen 140, a sensor module 150, etc. The sensor module 150 may include a gyroscope 150A and an accelerometer 150B. It is understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. The electronic device 100 may also include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0043] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. A memory can also be set in the processor 110 for storing instructions and data.
[0044] The memory 120 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc. The non-volatile memory can also store executable programs and store user and application data, etc., which can be loaded into the random access memory in advance for direct reading and writing by the processor 110. The electronic device 100 may also include an external memory interface. The external memory interface can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100.
[0045] In the embodiment of the present application, the program code, resources and other data information corresponding to the 3D reconstruction client can be stored in the memory 120 and / or the non-volatile memory connected to the external memory interface. When the 3D reconstruction client is running, the program code, resources and other data information stored in the memory 120 and / or the non-volatile memory connected to the external memory interface can be loaded into the processor 110, and then the feature extraction and matching of the video sequence and the 3D reconstruction are realized through the processing of the processor 110.
[0046] The electronic device 100 can realize shooting function and display function through ISP, camera module 130, video codec, GPU, display screen 140 and application processor.
[0047] The ISP is used to process the data fed back by the camera module 130. For example, when taking a photo, the shutter is opened, and light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. In some embodiments, the ISP can be set in the camera module 130.
[0048] The camera module 130 includes one or more cameras. The camera is used to capture static 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 standard RGB, YUV and other formats.
[0049] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in various coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, etc.
[0050] The GPU is a microprocessor for image processing, which is connected to the display screen 140 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, which execute program instructions to generate or change display information.
[0051] The display screen 140 is used to display images, videos, etc. The display screen 140 includes a display panel. The display screen 140 includes a display panel. The display panel can be a liquid crystal display (LCD). The display panel can also be made of 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 100 may include 1 or N display screens 140, where N is a positive integer greater than 1.
[0052] In the embodiment of the present application, when starting 3D reconstruction, the electronic device 100 can obtain a video containing a reconstructed object through the shooting capability provided by the ISP, the camera module 130, and the video codec. Among them, the electronic device 100 can send the video encapsulated by the video codec to the 3D reconstruction client, so that the 3D reconstruction client can obtain a video sequence containing the reconstructed object and then perform 3D reconstruction. In some embodiments, the electronic device 100 can also directly send the video sequence output by the DSP to the 3D reconstruction client for use.
[0053] The gyroscope (GYRO) 150A can output the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes). In the embodiment of the present application, the gyroscope 150A can be used to determine the direction of the electronic device 100. The direction of the electronic device 100 described in the embodiment of the present application refers to the direction of the optical center when the camera in the electronic device 100 captures an image. At any moment, the direction of the optical center can be the same as or different from the direction of movement of the electronic device 100.
[0054] The accelerometer (ACC) 150B can output the acceleration of the electronic device 100 in three axes (ie, x, y and z axes). In the embodiment of the present application, the accelerometer 150B can be used to determine the motion trajectory of the electronic device 100.
[0055] The gyroscope 150A and the accelerometer 150B may be collectively referred to as an inertial measurement unit (IMU). The three-axis angular velocity data output by the gyroscope 150A and the three-axis acceleration data output by the accelerometer 150B may be collectively referred to as IMU data.
[0056] In an embodiment of the present application, the electronic device 100 can use IMU data to determine the position and orientation of the electronic device 100 at the corresponding moment of each frame image in the video sequence, and use the above position and orientation in three-dimensional reconstruction to improve the reconstruction effect.
[0057] Not limited to Figure 2 In addition to the components shown, the electronic device 100 may also include other more components, such as an antenna, a mobile communication module, a wireless communication module, an audio module (speaker, receiver, microphone, headphone jack), a pressure sensor, a distance sensor, a proximity light sensor, an ambient light sensor, a touch sensor, a motor, an indicator light, etc., which are not listed here one by one.
[0058] In an optional embodiment, the electronic device 100 is a mobile phone. In other embodiments, the electronic device 100 may also be a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device, and the embodiment of the present application does not impose any special restrictions on the specific type of the electronic device.
[0059] Figure 3 A schematic diagram of an electronic device group provided in an embodiment of the present application.
[0060] The present application embodiment provides an electronic device group, which is denoted as electronic device group 200. Figure 3 As shown, the electronic device group 200 may include an electronic device 300 and an electronic device 400. The electronic device 300 is pre-installed with a 3D reconstruction client. The electronic device 400 is configured with one or more cameras.
[0061] A wired / wireless connection is established between the electronic device 300 and the electronic device 400. The wireless connection includes but is not limited to a high-fidelity wireless communication (wireless fidelity, Wi-Fi) connection, a Bluetooth connection, an infrared connection, an NFC connection, a ZigBee connection, or a mobile network connection supporting 2G, 3G, 4G, 5G and subsequent standard protocols.
[0062] After the electronic device 400 generates and outputs a video sequence through one or more cameras configured by itself, the video sequence can be sent to the electronic device 300 based on the wired / wireless connection. Then, the electronic device 300 can extract features from the received video sequence through a preset 3D reconstruction client, thereby constructing a 3D model of the scene corresponding to the video sequence.
[0063] The structure of the electronic device group 200 composed of the electronic device 300 and the electronic device 400 can be referred to Figure 3, which will not be described here. It is understandable that when the electronic device group 200 is used to perform three-dimensional reconstruction, the electronic device 400 should be configured with an IMU. In this way, when the electronic device 400 collects a video sequence including the reconstructed object through one or more cameras configured by itself, the electronic device 400 can also synchronously obtain IMU data aligned with the above video sequence through the IMU, and then use the above IMU data to assist in three-dimensional reconstruction and improve the reconstruction effect.
[0064] In an optional embodiment, the electronic device 300 is a laptop computer, and the electronic device 400 is a home surveillance camera or smart glasses. In other embodiments, the electronic device 300 can also be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a UMPC, a netbook, a PDA, an AR device, a VR device, an AI device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device, etc. The electronic device 400 can be a digital camera, a sports camera, a handheld camera device, etc. The embodiments of the present application do not impose any special restrictions on the specific types of the above-mentioned electronic devices.
[0065] The electronic device 100 can obtain two-dimensional images of the reconstructed object at different positions and different viewing angles to obtain a target video sequence, and then use the above-mentioned video target video sequence to realize three-dimensional reconstruction of the above-mentioned reconstructed object. Similarly, corresponding to the electronic device 100, the electronic device group 200 can also perform the above-mentioned operation to complete the three-dimensional reconstruction of the reconstructed object. The following description will be given by taking the electronic device 100 as an example, and the electronic device group 200 will not be repeated.
[0066] Figure 4 A building interior plan view provided for an embodiment of the present application. Figure 4 The 3D indoor scene of the building shown can be called a reconstructed object. Figure 4 As shown, the reconstructed object may include area A, area B, and area C. For example, area A may be an office area, area B may be a corridor, and area C may be an elevator shaft. The electronic device 100 may shoot at any position of the reconstructed object formed by the above areas to obtain a target video sequence for reconstructing the scene.
[0067] Taking an office as an example, the decoration styles of different areas of the reconstructed object are usually consistent and simple, which means that the images obtained at different locations will not have large differences, that is, texture duplication occurs, which in turn leads to mismatching during the 3D reconstruction process, affecting the reconstruction effect. Mismatching means that images at different locations are judged as images of the same location from different perspectives, and are used to reconstruct the 3D environment of that location.
[0068] For example, the electronic device 100 may be configured as follows: Figure 4The target video sequence of area B (corridor) is obtained by following the trajectory shown by the arrow in the middle, and is used to reconstruct area B. The electronic device 100 can obtain an image S1 of point P1 at position P1 and direction θ1, and can obtain an image S2 of point P2 at position P2 and direction θ2.
[0069] Figure 5 The embodiment of the present application provides a set of images S1 and S2 acquired at different positions. Figure 5 As shown, image S1 and image S2 include highly similar object elements such as ceiling, wall, wall-mounted signboard, floor, locker, etc. The only relatively obvious difference between image S1 and image S2 is that a password cabinet is placed between the locker and the wall in image S1, while the corresponding position in image S2 is a printer and a cardboard box, and the outer colors of the password cabinet and the printer are very similar.
[0070] For the electronic device 100 implementing the three-dimensional reconstruction, the electronic device 100 tends to ignore the difference between the password cabinet and the printer based on more highly similar object elements such as ceilings, walls, wall-mounted billboards, floors, and lockers, thereby determining image S1 and image S2 as two images of position P1 (or P2), causing mismatching, thereby reducing the reconstruction effect of the reconstructed object, and obtaining a three-dimensional environment that is significantly different from the reconstructed object. For example, the password cabinet is between the locker and the wall at position P1 in the actual environment, while the printer or an object that combines the features of the password cabinet and the printer is between the locker and the wall at position P1 after reconstruction, which is inconsistent with the actual scene.
[0071] For example, in order to avoid the texture duplication problem caused by the same or similar structure of the reconstructed object, which affects the reconstruction effect, the present application provides a three-dimensional reconstruction method combined with IMU data.
[0072] In the three-dimensional reconstruction method combined with IMU data provided in the present application, the electronic device 100 can obtain the IMU data corresponding to each frame of the image. On the basis of determining that the two frames of images are a similar image pair, the electronic device 100 can determine whether the IMU data of the similar image pair matches. Specifically, when the relative rotation of the electronic device 100 reflected by the IMU data of the similar image pair is within a preset range, the IMU data of the similar image pair matches. For similar image pairs whose relative rotation exceeds the preset range, the electronic device 100 can determine that the similar image pair has a mismatch. Therefore, the electronic device 100 can delete the mismatch relationship between the similar image pairs.
[0073] In this way, in the subsequent reconstruction process, the electronic device 100 can shield the negative impact brought by the mismatched image pairs as much as possible and improve the reconstruction effect.
[0074] Figure 6It is a flow chart of a three-dimensional reconstruction method combined with IMU data provided in an embodiment of the present application.
[0075] S401, obtaining target video sequence and IMU data.
[0076] refer to Figure 1 The electronic device 100 shown in FIG. 1 may include a camera module 130. First, the electronic device 100 may obtain a target video sequence through the camera module 130. For example, referring to Figure 4 , the electronic device 100 can shoot according to a preset trajectory to obtain a target video sequence including area B (reconstructed object).
[0077] The electronic device 100 is also provided with an inertial measurement unit IMU. While the electronic device 100 can acquire a target video sequence through the camera module 130, the IMU can generate and output IMU data reflecting the position and direction of the electronic device 100. The IMU data includes three-axis angular velocity data output by the gyroscope 150A and three-axis acceleration data output by the accelerometer 150B.
[0078] The target video sequence output by the camera module 130 and the IMU data output by the IMU can be aligned by time stamp. Table 1 exemplarily shows a set of target video sequences and IMU data aligned by time stamp.
[0079] Table 1
[0080]
[0081] As shown in Table 1, when the electronic device 100 captures the video frame F1, the three-axis acceleration of the electronic device 100 may be (-0.5536, 9.5126, -0.6559), and the three-axis angular velocity may be (-0.0040, 0.0077, 0.0059). The above (-0.5536, 9.5126, -0.6559) and (-0.0040, 0.0077, 0.0059) are the IMU data corresponding to F1.
[0082] S402: Acquire feature points of the image.
[0083] For any frame of image (video frame) in the target video sequence output by the camera module 130, the electronic device 100 can perform feature detection on it to obtain the feature points of the image. In image processing, feature points refer to points where the grayscale value of the image changes dramatically, usually corner points and edge points. Feature points can identify objects in the image and reflect the essential characteristics of the image.
[0084] The electronic device 100 can obtain feature points corresponding to any frame of image through a feature point detection algorithm.
[0085] The above-mentioned feature point detection algorithm includes but is not limited to the Scale Invariant Feature Transform (SIFT) algorithm, the Speeded-Up Robust Features (SURF) algorithm, the Features from Accelerated Segment Test (FAST) algorithm, the Binary Robust Independent Elementary Features (BRIEF) algorithm, the Oriented FAST and Rotated BRIEF (ORB) algorithm, etc. In some implementations, the above-mentioned feature point detection algorithm may also be a feature detection algorithm based on deep learning, such as SuperPoint, etc. The embodiment of the present application does not limit the feature point detection algorithm.
[0086] The positions of the imaging points of an object point in three-dimensional space are generally different in two frames of images with different viewing angles. Figure 7 As shown, the imaging point of object point W in image Pic1 is W1, and the imaging point of object point W in image Pic2 is W2. In the 3D reconstruction process, electronic device 100 needs to determine the 3D coordinates of object point W based on W1 in Pic1 and W2 in Pic2.
[0087] Therefore, after acquiring the feature points of each frame of image, the electronic device 100 further needs to determine the feature point pairs corresponding to the same object point in the two frames of image.
[0088] Exemplarily, video frame F1 includes 100 feature points: P1, P2, ..., P100, and F2 includes 100 feature points: Q1, Q2, ..., Q100. Taking P1 and Q1 as an example, P1 and Q1 correspond to the same three-dimensional space object point. Through the above-mentioned feature point detection algorithm, the electronic device 100 can determine that P1 and Q1 correspond to the same three-dimensional space object point. Therefore, the electronic device 100 can determine that the above-mentioned feature points P1 and Q1 corresponding to the same three-dimensional space object point are a feature point pair. By analogy, the electronic device 100 can determine all feature point pairs in video frames F1 and video frames F2.
[0089] It is understandable that the feature points in any two frames of images are not completely matched one by one, and there are residual feature points with no matching relationship. For example, video frame F2 does not have a feature point that matches feature point P2 in video frame F1.
[0090] S403: Determine similar image pairs in the video sequence.
[0091] Generally, the higher the similarity between two frames of images, the more feature point pairs that have matching relationships between the two frames of images. The electronic device 100 can determine similar image pairs in the target video sequence based on the feature point pairs of any two frames of images determined in S402.
[0092] The electronic device 100 can determine similar image pairs in the video sequence by means of a bag-of-words retrieval method. Specifically, the electronic device 100 can construct a visual vocabulary based on feature points in the image, and generate a bag of words including all visual vocabulary. The electronic device 100 can determine the visual vocabulary included in each frame of the image, and then the electronic device 100 can determine whether the two frames of images are similar by comparing the visual vocabulary corresponding to any two frames of images, and then determine all similar image pairs in the video sequence. Not limited to bag-of-words retrieval, the electronic device 100 can also determine the similarity between any two frames of images by other image retrieval methods.
[0093] S404: Integrate the IMU data.
[0094] Performing a primary integration on the acceleration data output by the IMU can determine the speed of the electronic device 100 at each moment. Performing a secondary integration on the basis of the speed can determine the position of the electronic device 100 at each moment. Performing a primary integration on the gyroscope data output by the IMU can determine the direction of the electronic device 100 at each moment.
[0095] Taking the IMU data shown in Table 1 as an example, after executing S404, the electronic device 100 can obtain the posture data described in Table 2 that describes the position and direction of the electronic device 100 at different times.
[0096] Table 2
[0097]
[0098] As shown in Table 2, after the data output by ACC is integrated twice, the values of X, Y, and Z in ACC can represent the coordinates of the electronic device 100 in the three-dimensional space at the current moment, that is, the position of the electronic device 100. For example, the position of the electronic device 100 at the moment T1 is (-0.5626, 9.5539, -0.6733). At any moment, the position of the electronic device 100 corresponds to the acquisition position of the corresponding video frame. For example, the position of the electronic device 100 (-0.5626, 9.5539, -0.6733) is the acquisition position of the video frame F1.
[0099] After integrating the data output by GYRO, the values of X, Y, and Z in GYRO can represent the direction of the electronic device 100 in the three-dimensional space at the current moment, that is, the direction of the electronic device 100. For example, the direction of the electronic device 100 at time T1 is (-0.0019, 0.0029, 0.0021). At any moment, the direction of the electronic device 100 corresponds to the acquisition direction of the corresponding video frame. For example, the direction of the electronic device 100 (-0.0019, 0.0029, 0.0021) is the acquisition direction of the video frame F1.
[0100] The embodiment of the present application does not limit the sequence of S402 - S403 and S404 .
[0101] S405: Determine the relative rotation angle between frames of the similar image pair.
[0102] After integrating the gyroscope data to determine the direction of the electronic device 100 at each moment, the electronic device 100 can determine the relative rotation of the electronic device 100 corresponding to any two frames of images, that is, the relative rotation between frames (the angle between the acquisition directions).
[0103] Exemplarily, when the electronic device 100 moves to Figure 4 When the electronic device 100 is at position P1, based on the position data output by the IMU data integration, the electronic device 100 can determine the coordinates of the current position: P1 and the current direction of the electronic device 100: θ1. Figure 4 When the electronic device 100 is at position P2, the electronic device 100 can determine the coordinates of the current position: P2 and the current direction of the electronic device 100: θ2. The angle (angle difference) between θ1 and θ2 is the relative rotation (△θ) of the electronic device 100 between P1 and P2, that is, the relative rotation between S1 and S2.
[0104] Not every two image frames are similar image pairs. Therefore, from the perspective of reducing computational costs, the electronic device 100 does not need to immediately determine the inter-frame relative rotation between every two image frames after integrating the IMU data (ie, S404).
[0105] Preferably, in a scenario where the video frames in a video sequence are aligned with the IMU data through timestamps, after determining that any two frames of images are a similar image pair (i.e., S403), the electronic device 100 can obtain the integral result of the IMU data corresponding to the above two frames of images, i.e., the pose data corresponding to the above two frames of images, and then determine the inter-frame relative rotation corresponding to the two frames of images.
[0106] S406: Delete the incorrect matching relationship.
[0107] refer to Figure 5As introduced in the object reconstruction itself, similar structures existing in the object reconstruction itself easily lead to texture duplication, which in turn leads to mismatching. Therefore, after executing the step shown in S403, the similar image pairs determined by the electronic device 100 include correctly matched similar image pairs (similar images in the same position) and mismatched similar image pairs (similar images in different positions). Mismatching will have a negative impact on the subsequent reconstruction process and affect the reconstruction effect. Therefore, after executing S403, the electronic device 100 needs to determine and delete the mismatching relationship to reduce the negative impact corresponding to the mismatch and improve the reconstruction effect.
[0108] In an embodiment of the present application, the electronic device 100 can use the relative rotation between frames to determine and delete the mismatch relationship in the similar image pair. Specifically, the electronic device 100 can set a rotation angle threshold thres_r (first threshold). When the relative rotation between frames corresponding to any group of similar image pairs exceeds the above rotation angle threshold, the electronic device 100 can determine that the similar image pair is a mismatched similar image pair, and then delete the similar image pair.
[0109] The electronic device 100 is Figure 4 Taking the images S1 and S2 captured at the positions P1 and P2 shown as an example, the electronic device 100 can determine the inter-frame relative rotation △θ=|θ1-θ2| of the images S1 and S2. Exemplarily, θ1=45°, θ2=225°, thres_r=45°, then the electronic device 100 can determine the inter-frame relative rotation △θ=180° of the images S1 and S2, which is greater than the rotation angle threshold thres_r. Therefore, the electronic device 100 can determine that the images S1 and S2 are mismatched, and then the electronic device 100 can delete the image pair S1 and S2 from the similar image pair to avoid the interference of the mismatched image pair S1 and S2 and improve the reconstruction effect.
[0110] The above rotation angle threshold can be set according to the field of view (FOV) of the camera used. The larger the FOV, the larger the rotation angle threshold corresponding to the camera can be set. Conversely, the smaller the FOV, the smaller the rotation angle threshold corresponding to the camera should be set.
[0111] In some scenarios, the inter-frame relative rotation △θ of a similar image pair is less than the threshold thres_r, or even 0, but the two frames of the similar image pair are not images of the same position and the same viewing angle.
[0112] refer to Figure 8 , the electronic device 100 captures a frame of image S3 at the posture of P3, θ3, and image S3 is similar to image S1. At this time, only considering the relative rotation between the frames of image S3 and image S1, the electronic device 100 will determine that image S3 and image S1 are correctly matched. However, through Figure 8It can be seen that the similarity between image S3 and image S1 is not caused by shooting the same object, but by the existence of the same or similar structure in the reconstructed object. Figure 8 In the scenario shown, the electronic device 100 cannot identify and delete the above-mentioned mismatching relationship simply by using relative rotation between frames.
[0113] In another embodiment, the electronic device 100 may also use the integration result of the acceleration data, that is, the image acquisition position, to determine the position difference between the two frames of the similar image pair. The electronic device 100 may preset a position difference threshold (second threshold). When the position difference between the two frames of the similar image pair exceeds the position difference threshold, the electronic device 100 may determine that the similar image pair is a mismatched similar image pair, and then delete the similar image pair.
[0114] like Figure 8 As shown, the electronic device 100 can determine that the distance between P1 and P3 is much larger than the position difference threshold. At this time, the electronic device 100 determines that a mismatch has occurred between image S3 and image S1. Therefore, the electronic device 100 deletes the matching relationship between image S3 and image S1 to avoid interference of the mismatched image on S1 and S3, thereby improving the reconstruction effect.
[0115] The electronic device 100 may first determine the relative rotation between frames of the similar image pair, or may first determine the distance between the acquisition positions of the similar image pair. The embodiment of the present application does not limit this order.
[0116] S407: Eliminate external points in similar image pairs.
[0117] After executing the step shown in S406, the electronic device 100 can use the remaining correctly matched similar image pairs to perform three-dimensional reconstruction, determine the position of each object in the image in the three-dimensional space, and output the reconstruction result.
[0118] To further improve the reconstruction effect, optionally, after S406, the electronic device 100 may verify the feature points in the remaining correctly matched similar image pairs, and delete the feature points in the image pairs that have unreasonable matching relationships.
[0119] Specifically, taking any one similar image pair (the fourth image pair) among the correctly matched similar image pairs as an example, the electronic device 100 may first randomly select 8 feature point pairs (the first number of feature point pairs) from the similar image pair. Figure 7 As shown in FIG. 1 , the combination of feature points in two frames of images corresponding to the same object point in three-dimensional space is called a feature point pair.
[0120] Then, the electronic device 100 can use the above 8 feature point pairs to determine the basic matrix F of the similar image pair. In epipolar geometry, the basic matrix represents the geometric constraint relationship (i.e., the projection relationship) between the image points of the same object point on the imaging planes of two perspective cameras. In the embodiment of the present application, the basic matrix F represents the projection relationship between the above similar image pairs.
[0121] Through the above-mentioned basic matrix F, the electronic device 100 can determine the distance d from other feature points of the above-mentioned similar image pairs to the corresponding epipolar lines, and mark the feature points with d < thres_d (distance threshold) as inliers, and mark the feature points with d > thres_d as outliers. Among them, when one feature point in a feature point pair is an outlier, the other feature point is also an outlier. Finally, the electronic device 100 can count the ratio of the number of inliers to the total number of feature points in the similar image pairs (recorded as inlier ratio), or the ratio of the number of outliers to the total number of feature points (recorded as inlier ratio), for subsequent verification of the error of the basic matrix F.
[0122] Since there are mismatches in feature point matching, there is an error between the basic matrix determined by the electronic device 100 based on the feature point pairs in the image and the actual basic matrix. In order to reduce the above error, the electronic device 100 performs the above operation multiple times, selecting different 8 feature point pairs each time, thereby obtaining different basic matrices F and different inlier ratios and exlier ratios. The higher the inlier ratio means that there are more feature points in the image pair that satisfy the calculated basic matrix F. At this time, the error between the calculated basic matrix F and the actual basic matrix is smaller; conversely, the error between the calculated basic matrix F and the actual basic matrix is larger.
[0123] The electronic device 100 may set an inner point ratio threshold thres_p1. When the ratio of the number of inner points to the total number of feature points is greater than the threshold thres_p1, the electronic device 100 may determine that the basic matrix F at this time has a smaller error than the actual basic matrix, and may be referred to as a target basic matrix. On the contrary, the electronic device 100 may set an outer point ratio threshold thres_p2. When the ratio of the number of outer points to the total number of feature points is less than or equal to the threshold thres_p2 (third threshold), the electronic device 100 may determine that the basic matrix F at this time is the target basic matrix (first basic matrix). The electronic device 100 may use the above-mentioned target basic matrix to characterize the projection relationship between the similar image pairs. Then, the electronic device 100 deletes the outer points that do not conform to the projection relationship under the target basic matrix.
[0124] In an embodiment of the present application, the electronic device 100 can also directly determine the inter-frame relative rotation (second angle) of the image pair through the posture data. It can be understood that there are errors in determining the inter-frame relative rotation of the image pair through the posture data. At the same time, the electronic device 100 can use the target basic matrix to determine the inter-frame relative rotation (second angle) of the image pair. At this time, the electronic device 100 compares the inter-frame relative rotation determined based on the target basic matrix with the inter-frame relative rotation determined based on the posture data. When the error between the inter-frame relative rotation determined based on the target basic matrix and the inter-frame relative rotation determined based on the posture data is within the threshold value thres_δ, the electronic device 100 can determine that the above-mentioned target basic matrix is valid. Then, the electronic device 100 can delete the external points that do not conform to the projection relationship under the valid target basic matrix.
[0125] S408: Incremental reconstruction.
[0126] After S407, the number of feature point pairs in each group of similar image pairs will be updated. Specifically, after deleting the outliers, the number of feature point pairs in the similar image pairs will decrease.
[0127] The electronic device 100 may first determine a group of similar image pairs with the most feature point pairs from all similar image pairs. The electronic device 100 may perform pose estimation based on the group of similar image pairs with the most feature point pairs, and triangulate the three-dimensional coordinates of the feature points in the image. Then, the electronic device 100 may perform PNP (Perspective-n-Point) calculations using the determined three-dimensional coordinates and the feature points in the remaining images, determine the camera pose of each frame, and then triangulate new three-dimensional coordinates. By analogy, the three-dimensional coordinates of all feature points in the entire video sequence are restored, and then the three-dimensional reconstruction results of the reconstructed objects corresponding to the video sequence are output.
[0128] by Figure 4 In the office environment shown, after executing S408, the electronic device 100 may output a three-dimensional model of the office.
[0129] S409: Optimize the reconstruction result.
[0130] Optionally, the electronic device 100 can construct a reprojection error function by using a bundle adjustment (BA) method, and then use the function to optimize all camera poses and three-dimensional coordinates, thereby outputting a more accurate and detailed reconstruction result. Not limited to the BA method, the electronic device 100 can also use other methods for optimization, which is not limited in the embodiments of the present application.
[0131] By implementing the 3D reconstruction method provided in the embodiment of the present application, after determining the similar image pairs, the electronic device 100 can determine whether the similar image pairs are mismatched based on the IMU data. After determining that a mismatch has occurred, the electronic device 100 can delete the mismatched similar image pairs, thereby shielding the negative impact of the mismatched image pairs and improving the reconstruction effect.
[0132] In a three-dimensional reconstruction scenario where the reconstructed object has two or more identical or similar structures, the three-dimensional reconstruction method provided in the embodiment of the present application can effectively shield the mismatch caused by the identical or similar structure of the reconstructed object itself, improve the accuracy of similar image pairs, and improve the reconstruction effect.
[0133] In the embodiment of the present application, the first electronic device and the second electronic device may be the same electronic device, for example Figure 1 The electronic device 100 shown in the figure can not only complete the work of video sequence acquisition and IMU data acquisition, but also complete the work of three-dimensional reconstruction based on video sequence and IMU data. Alternatively, the first electronic device and the second electronic device can be different electronic devices, for example Figure 3 The electronic device group 200 shown. The electronic device 400 in the electronic device group 200 can complete the work of video sequence acquisition and IMU data acquisition, and the electronic device 300 in the electronic device group 200 can complete the work of three-dimensional reconstruction based on the video sequence and IMU data.
[0134] The target reconstruction object may be referred to as the first space. For example, Figure 4 The office area shown can be called the first space. Figure 4 The video series obtained in the office area shown can be called the first video sequence. In this scenario, the IMU data collected by the electronic device 100 during the above shooting process, and then the data indicating the position and / or direction of the electronic device 100 at different times obtained by integration can be called the first pose data.
[0135] In S405, the similar image pair correctly matched by the inter-frame relative rotation (i.e., the acquisition direction angle) can be called the first image pair, and the similar image pair incorrectly matched can be called the third image pair. Among them, in the method of determining the matched similar image pair by combining the inter-frame relative rotation (i.e., the acquisition direction angle) and the position difference, the similar image pair whose position difference is within the preset value can be called the second image, and then, the similar image pair whose inter-frame relative rotation meets the preset value determined from the second image pair can be called the first image pair.
[0136] As used in the specification and appended claims of the present application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also include plural expressions, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items. As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrase "when determining..." or "if (stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "when (stated condition or event) is detected" or "in response to detecting (stated condition or event)", depending on the context.
[0137] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0138] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
Claims
1. A data processing method, applied to a first electronic device, characterized in that: The method comprises: Acquire a first video sequence obtained by shooting the first space by the second electronic device; Determine a plurality of image pairs in the first video sequence, wherein image contents of two frames of images in any one of the plurality of image pairs are similar; Acquire first pose data, where the first pose data includes an acquisition direction and an acquisition position of each frame image in the first video sequence; Establishing a three-dimensional model of the first space using a first image pair, wherein the first image pair includes a second image pair having a matching image acquisition direction and a matching acquisition position among the multiple image pairs, and does not include a third image pair having an unmatched image acquisition direction and / or an unmatched acquisition position among the multiple image pairs; The acquisition direction matching means that the angle between the acquisition directions of two frames of images in the image pair is less than or equal to a first threshold; the acquisition position matching means that the distance between the acquisition positions of two frames of images in the image pair is less than or equal to a second threshold.
2. The method according to claim 1, characterized in that The first posture data is obtained by any one or more of the following: accelerometer data or gyroscope data collected when the second electronic device shoots the first video sequence.
3. The method according to claim 1, characterized in that Before establishing the three-dimensional model of the first space using the first image pair, the method further includes: Determine an outlier of a fourth image pair, the fourth image pair being any one of the first image pairs, an outlier of an image pair being a feature point of the image pair that does not conform to a projection relationship of the image pair; Outliers of the fourth image pair are deleted.
4. The method according to claim 3, characterized in that The determining of the outer points of the fourth image pair specifically includes: Determine a first basic matrix using a first number of feature point pairs in the fourth image pair, where the first basic matrix is used to represent a projection relationship of the fourth image pair; Outliers in the remaining feature point pairs in the fourth image pair whose projection relationships are inconsistent with the first basic matrix are determined, and a ratio of the number of the outliers to the number of all feature points in the fourth image pair is less than or equal to a third threshold.
5. The method according to claim 4, characterized in that An error between the first angle and the second angle is less than or equal to a fourth threshold, the first angle is an acquisition direction angle of the fourth image pair determined by the first basic matrix, and the second angle is an acquisition direction angle of the fourth image pair determined by the first posture data.
6. The method according to claim 1, characterized in that The first space has the same or similar structure at two or more locations.
7. An electronic device, characterized in that: The method comprises one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program codes, wherein the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the method according to any one of claims 1 to 6 is executed.
8. A chip system, the chip system is applied to electronic equipment, the chip system comprises one or more processors, characterized in that: The processor is configured to call computer instructions so as to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the method according to any one of claims 1 to 6 is executed.
