Position and posture measurement method and electronic device

By optimizing the method of processing multi-frame images and IMU measurement data, the pose measurement accuracy of electronic devices is improved, thereby improving the electronic anti-shake capability and image clarity, and solving the problem of low pose measurement accuracy in the existing technology. .

CN117689711BActive Publication Date: 2024-10-29HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311036573.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-16
Publication Date
2024-10-29
Estimated Expiration
2043-08-16

AI Technical Summary

Technical Problem

Existing pose measurement methods have low accuracy in electronic devices, resulting in low electronic anti-shake capabilities and low image clarity.

Method used

By obtaining the state quantity and IMU measurement data of multi-frame images, optimization processing is performed to improve the accuracy of pose measurement, including using IMU measurement components such as accelerometer offset, gyroscope offset, camera position, movement speed, and rotation angle. Construct graph constraint relationships and perform nonlinear optimization to calculate more accurate poses.

Benefits of technology

It improves the electronic anti-shake capability of electronic equipment and the clarity of images captured by cameras, and enhances the accuracy of pose measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117689711B_ABST
    Figure CN117689711B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a posture measurement method and electronic device, the method comprising: obtaining a first image and IMU measurement data corresponding to the first image; determining a first state quantity and a second state quantity of the first image according to the first image and the IMU measurement data; optimizing the second state quantity of the first image according to the first set, the second set, and the first state quantity of the first image to obtain an optimized second state quantity; and calculating the posture of the camera when shooting the first image according to the optimized second state quantity. The embodiment of the present application can improve the accuracy of posture measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a posture measurement method and electronic equipment. Background Art

[0002] Electronic image stabilization (EIS) is an anti-shake capability achieved through software algorithms. The technical operating principle is to detect the vibration amplitude of an electronic device (such as a mobile phone) through an inertial measurement unit (IMU) such as an accelerometer and / or a gyroscope, thereby calculating the camera posture, and dynamically adjusting the ISO, shutter and imaging algorithm of the electronic device camera based on the camera posture to achieve blur correction. However, the existing posture measurement method has low accuracy, and thus the electronic image stabilization capability of the electronic device is low, and the image clarity of the camera is low. Summary of the invention

[0003] The present application provides a posture measurement method and electronic device, which can improve the accuracy of posture measurement.

[0004] In the first aspect, the embodiment of the present application provides a posture measurement method, which is applied to an electronic device, and the electronic device includes a camera. The method includes: obtaining a first image and IMU measurement data corresponding to the first image; determining a first state quantity and a second state quantity of the first image according to the first image and the IMU measurement data, the first state quantity including an image residual corresponding to at least one feature point in the first image; the second state quantity including: a preset IMU measurement component; optimizing the second state quantity of the first image according to the first set, the second set, and the first state quantity of the first image to obtain an optimized second state quantity; the first set includes: the first state quantity of the m-frame image before the first image; the second set includes: the second state quantity of the n-frame image before the first image; m is a natural number, and n is a natural number; and calculating the posture of the camera when shooting the first image according to the optimized second state quantity. In this method, the second state quantity is optimized based on multiple first state quantities and second state quantities, so that the second state quantity is more accurate, and thus the posture of the calculated first image is more accurate.

[0005] In a possible implementation, the IMU measurement components include: accelerometer bias and gyroscope bias.

[0006] In a possible implementation, the IMU measurement component also includes at least one of the following components: the position of the camera, the moving speed of the camera, and the rotation angle of the camera.

[0007] In a possible implementation, the second state quantity of the first image is optimized according to the first set, the second set, and the first state quantity of the first image to obtain the optimized second state quantity, including: determining the graph constrained residual of the first state quantity of the first image and the graph constrained residual of other first state quantities in the first set according to the first state quantity of the earliest frame image shot in the first set; determining the graph constrained residual of the second state quantity of the first image and the graph constrained residual of other second state quantities in the second set according to the second state quantity of the earliest frame image shot in the second set; and optimizing the second state quantity of the first image according to the graph constrained residual.

[0008] In one possible implementation, the second state quantity of the first image is optimized according to the graph constraint residual, including: constructing a graph constraint relationship according to the first state quantity of the first image, other first state quantities in the first set, the second state quantity of the first image, and other second state quantities in the second set; minimizing the graph constraint residual, performing nonlinear optimization processing on the graph constraint relationship, and obtaining the optimized second state quantity of the first image.

[0009] In a possible implementation, the method further includes: performing nonlinear optimization processing on the graph constraint relationship to obtain an optimized first state quantity of the first image, other optimized first state quantities, and other optimized second state quantities; updating other first state quantities in the first set according to the optimized other first state quantities, adding the optimized first state quantity of the first image to the first set, and discarding the first state quantity of the image with the earliest shooting time; updating other second state quantities in the second set according to the optimized other second state quantities, adding the optimized second state quantity of the first image to the second set, and discarding the second state quantity of the image with the earliest shooting time.

[0010] In a possible implementation manner, before determining the first state quantity and the second state quantity of the first image, the method further includes: determining that the first image is a key frame image.

[0011] In one possible implementation, determining that the first image is a key frame image includes: determining that the distance between a feature point of the first image and a feature point in the second image that matches the feature point is greater than a first threshold; and / or determining that a movement distance of the camera in a preset direction is greater than a second threshold; and / or determining that a rotation angle of the camera in a preset direction is greater than a third threshold.

[0012] In a possible implementation manner, the method further includes: determining that the first image is not a key frame image, and calculating a camera pose corresponding to the first image according to a second state quantity of the first image.

[0013] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory; wherein one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the processor, enable the electronic device to execute any method of the first aspect.

[0014] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes any one of the methods of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0016] Figure 1 A schematic diagram of a flow chart of an electronic anti-shake method provided in an embodiment of the present application;

[0017] Figure 2 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0018] Figure 3 A schematic diagram of a software structure of an electronic device provided in an embodiment of the present application;

[0019] Figure 4 A schematic diagram of a flow chart of a posture measurement method provided in an embodiment of the present application;

[0020] Figure 5 A schematic diagram of the optimization principle provided for the embodiment of the present application;

[0021] Figure 6 Another schematic diagram of a flow chart of a posture measurement method provided in an embodiment of the present application;

[0022] Figure 7 A schematic diagram of the structure of the CAM set and the IMU set provided in the embodiment of the present application;

[0023] Figure 8 A schematic diagram of a discard state quantity provided in an embodiment of the present application;

[0024] Fig. 9 A schematic diagram of the covariance matrix principle provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.

[0026] First, the nouns involved in the embodiments of the present application are exemplified.

[0027] World coordinate system: The absolute coordinate system of the real world, used to describe the position of the camera.

[0028] Camera coordinate system: The optical center of the camera is the coordinate origin. The X-axis and Y-axis are parallel to the X-axis and Y-axis of the image coordinate system respectively. The optical axis of the camera is the Z-axis. The positive direction of the X-axis is the direction pointing to the right of the camera plane along the X-axis. The positive direction of the Y-axis is the direction pointing above the camera plane along the Y-axis. The positive direction of the Z-axis is along the optical axis pointing to the front of the camera.

[0029] Camera normalized coordinate system: Add a scale factor to the three-dimensional coordinates of the camera coordinate system to convert the three-dimensional coordinates into four-dimensional coordinates.

[0030] Image coordinate system: The center of the image plane is the coordinate origin, the X-axis and Y-axis are parallel to the two vertical sides of the image plane, and the positive directions of the X-axis and Y-axis are consistent with the camera coordinate system.

[0031] Pixel coordinate system: The top left corner of the image is taken as the origin, the X-axis and Y-axis are parallel to the X-axis and Y-axis of the image coordinate system respectively, and the positive directions of the X-axis and Y-axis are consistent with the camera coordinate system. Pixel coordinates are a coordinate system based on pixels. The main difference between the pixel coordinate system and the image coordinate system lies in the translation of the origin and the scaling of the size.

[0032] Accelerometer bias: refers to the zero-degree drift of the accelerometer, that is, the value of the accelerometer when the acceleration is 0.

[0033] Gyroscope bias: refers to the value of the gyroscope without external excitation.

[0034] Posture: Posture refers to the position and direction of the posture or posture of an object, robot or person in three-dimensional space. The posture in the embodiment of the present application refers to the position and direction of the camera in three-dimensional space, which can also be called camera posture or camera posture.

[0035] Electronic image stabilization (EIS) is an anti-shake capability achieved through software algorithms. Its technical operating principle is to detect the vibration amplitude of an electronic device (such as a mobile phone) through an inertial measurement unit (IMU) such as an accelerometer and / or gyroscope, thereby calculating the camera posture, and dynamically adjusting the ISO, shutter and imaging algorithm of the electronic device camera based on the camera posture to achieve blur correction.

[0036] In one example, see Figure 1The electronic image stabilization processing flow may include: the electronic device calculates the camera posture according to the IMU data, smoothes the camera posture according to the preset AI model, calculates the image deformation grid according to the smoothed camera posture, IMU data and camera-related data, processes the original image taken by the camera into a stable image according to the image deformation grid, and provides the stable image to the user as the image taken by the camera.

[0037] However, in the above process, the calculation of the smoothed camera pose is only based on the IMU data, so the calculation accuracy of the camera pose is low, which in turn leads to low accuracy of electronic image stabilization of the electronic device and low clarity of the generated stabilized image.

[0038] To this end, an embodiment of the present application provides a posture measurement method and an electronic device, which can improve the measurement accuracy of the camera posture.

[0039] Furthermore, in e.g. Figure 1 In the electronic image stabilization processing shown, the image deformation grid determined by the electronic device according to the camera posture is more accurate, and the clarity of the generated stable image is relatively higher, thereby improving the electronic image stabilization capability of the electronic device and improving the clarity of the image taken by the camera of the electronic device.

[0040] The electronic device of the embodiment of the present application is an electronic device including a camera, such as a mobile phone, a tablet computer (PAD), a watch, etc.

[0041] Figure 2 A schematic diagram of the structure of an electronic device is shown. Figure 2 As shown, the electronic device 100 may include a processor 110, a memory 120, a display screen 130, a camera 140, an IMU 150, etc. The IMU 150 may include: an acceleration sensor 151, a gyroscope 152, etc.

[0042] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate 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.

[0043] 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.

[0044] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0045] 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.

[0046] 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.

[0047] The internal memory 120 can be used to store computer executable program codes, which include instructions. The internal memory 130 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 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 130 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 100 by running instructions stored in the memory 120, and / or instructions stored in a memory provided in the processor.

[0048] The display screen 130 is used to display images, videos, etc. The display screen 130 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 100 may include one or more display screens 130.

[0049] The camera 140 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 light 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 100 may include 1 or N cameras 140, where N is a positive integer greater than 1. The camera of an electronic device may also be referred to as a camera of the electronic device in some technologies.

[0050] IMU150 is used to perform inertial measurement of electronic equipment.

[0051] The acceleration sensor 151 can detect the magnitude of acceleration in various directions (generally three axes) of the electronic device 100. When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected.

[0052] The gyro sensor 152 may be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (ie, x, y, and z axes) may be determined by the gyro sensor 152.

[0053] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. Taking the (Android) system as an example, the software structure of the electronic device 100 is exemplified.

[0054] Figure 3 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.

[0055] 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 five layers, from top to bottom: application layer, application framework layer (also called system framework layer), system library and Android runtime layer, hardware abstraction layer (HAL) and kernel layer.

[0056] The application layer may include several applications (hereinafter referred to as applications). In the embodiment of the present application, the application layer may include: a camera application.

[0057] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer, including various components and services to support the Android development of developers. In the embodiment of the present application, the application framework layer may include a camera service, etc.

[0058] The system library and Android runtime layer include the system library and Android Runtime. The system library can include multiple functional modules, such as surface manager, libc, etc. The Android runtime is responsible for the scheduling and management of the Android system, specifically including the core library and virtual machine. Among them, the core library contains two parts: one part is the function functions that need to be called by the Java language, and the other part is the Android core library; the virtual machine is used to run Android applications developed using the Java language.

[0059] The HAL layer is an interface layer between the operating system kernel and the hardware circuit. The HAL layer includes but is not limited to: the camera hardware abstraction layer (Camera HAL), which is used to process the image stream.

[0060] The kernel layer is the layer between hardware and software. The kernel layer may include: camera driver, accelerometer driver, gyroscope driver, etc. The camera driver is used to drive the camera. The accelerometer driver is used to drive the accelerometer. The gyroscope driver is used to drive the gyroscope.

[0061] Below, combined with the above Figure 2 and Figure 3 The structure of the electronic device shown illustrates the posture measurement method of the embodiment of the present application.

[0062] Optionally, the posture measurement method of the embodiment of the present application may be a function provided by the operating system of the electronic device, in which case the posture measurement method may be executed by a posture measurement module arranged in the driver layer or the framework layer. Alternatively, the posture measurement method of the embodiment of the present application may be a function provided by an application of the electronic device, such as a camera application, in which case the posture measurement method may be executed by the camera application.

[0063] Figure 4 is a flow chart of the posture measurement method according to an embodiment of the present application. Figure 4 As shown, the method may include:

[0064] Step 401: Obtain the j-th frame image and the IMU measurement data corresponding to the j-th frame image.

[0065] Assuming that the j-th frame image is an image taken by the camera at time t1, the IMU measurement data corresponding to the j-th image refers to the IMU measurement data at the same or similar measurement time t2 as time t1. It should be noted that the time difference between time t2 and time t1 is not limited in the embodiment of the present application. Generally speaking, the smaller the time difference between the two, the more accurate the camera pose obtained by subsequent calculation.

[0066] Optionally, the IMU measurement data may include: acceleration data measured by an acceleration sensor and angular velocity data measured by a gyroscope.

[0067] Optionally, the acceleration data may specifically include: the acceleration of the electronic device, and specifically may include: the acceleration of the electronic device in the x-, y-, and z-axis directions respectively.

[0068] Optionally, the angular velocity data may specifically include: the angular velocity of the electronic device, and specifically may include: the angular velocity of the electronic device rotating around the x, y, and z axes respectively.

[0069] The method for establishing the coordinate system used by the acceleration sensor and the gyroscope is not limited in the embodiment of the present application. Optionally, the coordinate system used by the acceleration sensor and the gyroscope can be the same or different, which is not limited in the embodiment of the present application.

[0070] Step 402: Determine the cam state quantity camj and the IMU state quantity IMUj of the j-th frame image according to the IMU measurement data.

[0071] The cam state quantity camj may include the reprojection errors corresponding to each feature point in the j-th frame image.

[0072] The above reprojection error may also be referred to as an image residual between the j-th frame image and the ith frame image, where the ith frame image is a frame image previous to the j-th frame image.

[0073] Optionally, feature points can be extracted from the j-th frame image and matched with the feature points of the i-th frame image; for feature point l in the j-th frame image, the pixel coordinates of feature point l in the j-th frame image are obtained. And the pixel coordinates of the feature point in the i-th frame image that matches the feature point l According to pixel coordinates and pixel coordinates Calculate the reprojection error corresponding to the feature point l.

[0074] The above is based on pixel coordinates and pixel coordinates Calculating the reprojection error corresponding to the feature point l may include:

[0075] According to pixel coordinates Calculate the measured coordinates of feature point l in the normalized camera coordinate system in, is the transformation matrix from the pixel coordinate system of the image to the normalized camera coordinate system;

[0076] According to pixel coordinates Calculate the measured coordinates of feature point l in the normalized camera coordinate system

[0077] Measuring coordinates Calculate the predicted coordinates of feature point l in the normalized camera coordinate system in,

[0078] Calculate the reprojection error corresponding to feature point l according to the measured coordinates and predicted coordinates of feature point l

[0079] In the above formula, It is the rotation transformation matrix from the IMU coordinate system to the camera coordinate system determined based on the IMU and camera peripherals. is the rotation transformation matrix from the world coordinate system to the IMU coordinate system corresponding to the j-th frame image, is the rotation transformation matrix from the IMU coordinate system to the world coordinate system corresponding to the i-th frame image, λ l is the normalization factor, It is the translation transformation matrix from the camera coordinate system to the IMU coordinate system determined based on the IMU and camera peripherals. is the translation transformation matrix from the IMU coordinate system to the world coordinate system corresponding to the i-th frame image, is the translation transformation matrix from the IMU coordinate system to the world coordinate system corresponding to the j-th frame image, It is the translation transformation matrix from the camera coordinate system to the IMU coordinate system determined based on the IMU and camera peripherals.

[0080] The IMU state quantity IMUj may include: an IMU measurement component corresponding to the j-th frame image.

[0081] The IMU measurement components may include: accelerometer bias ba, gyroscope bias bw. Optionally, the IMU measurement components may also include: position P of the electronic device, movement speed V of the electronic device, and / or rotation angle Q of the electronic device.

[0082] Assuming that the IMU measurement components include: the position P of the electronic device, the moving speed V of the electronic device, the rotation angle Q of the electronic device, the accelerometer bias ba, and the gyroscope bias bw, accordingly, the IMU state quantity IMUj may include: the position Pj of the electronic device corresponding to the j-th frame image, the moving speed Vj of the electronic device, the rotation angle Qj of the electronic device, the accelerometer bias baj, and the gyroscope bias bwj.

[0083] The calculation formulas for the position Pj of the electronic device corresponding to the j-th frame image, the moving speed Vj of the electronic device, and the rotation angle Qj of the electronic device are as follows:

[0084]

[0085]

[0086]

[0087]

[0088]

[0089] in, Indicates the position coordinates of the camera corresponding to the j-th frame image in the world coordinate system, Indicates the position coordinates of the camera corresponding to the i-th frame image in the world coordinate system, represents the speed of the camera corresponding to the i-th frame image in the world coordinate system, δt represents the time between the i-th frame image and the j-th frame image, represents the mean acceleration measured between the i-th frame image and the j-th frame image, Indicates the rotation angle of the camera corresponding to the j-th frame image in the world coordinate system, Indicates the rotation angle of the camera corresponding to the i-th frame image in the world coordinate system, represents the average angular velocity measured between the i-th frame image and the j-th frame image, ba j Indicates the acceleration bias corresponding to the j-th frame image, bω j represents the angular velocity bias corresponding to the j-th frame image. and / or It can be calculated using the median method, and the specific implementation of the embodiment of the present application will not be described in detail.

[0090] Step 403: Optimize the IMU state quantity IMUj of the j-th frame image according to the cam state quantity camj of the j-th frame image, the cam state quantities in the cam set, and the IMU state quantities in the IMU set to obtain the optimized IMU state quantity IMUj.

[0091] like Figure 5 As shown in FIG. 1 , landmark points A, B, and C correspond to feature points in the captured image. Feature point matching can be used to determine the feature points corresponding to the same landmark point in different frame images. For example, Figure 5In the figure, the cam state quantity and IMU state quantity in the image taken at time 1, the cam state quantity and IMU state quantity in the image taken at time 2, and the cam state quantity and IMU state quantity in the image taken at time 3 are taken as examples. The above cam state quantity and IMU state quantity can be called fixed states or historical states. The fixed states are used as prior information for prior estimation to estimate the cam state quantity and IMU state quantity in the image taken at time k. The estimated cam state quantity and IMU state quantity are also called estimated states. The estimated cam state quantity and IMU state quantity are corrected according to the image taken at time k and IMU data, so that the accurate IMU state quantity of the image taken at time k can be obtained, and then the camera pose of the image taken at time k can be calculated. Figure 5 The image captured at time k in the figure may correspond to the j-th frame image in the embodiment of the present application, and the images captured at time 1 to time 3 may correspond to the images of the three frames before the j-th frame.

[0092] The implementation of this step can refer to Figure 6 Steps 604 to 605 in are not described in detail here.

[0093] Step 404: Calculate the camera pose of the j-th frame image according to the optimized IMUj.

[0094] The camera pose may include: the position coordinates and rotation angle of the camera in the world coordinate system.

[0095] The optimized IMUj includes: optimized acceleration bias ba j1 , optimized gyroscope bias bω j1 .

[0096] In this step, calculating the camera pose of the j-th frame image may include:

[0097]

[0098]

[0099]

[0100] Figure 4In the method shown, the cam set includes the cam state quantities of m frames before the j-th frame image, and the IMU set includes the IMU state quantities of n frames before the j-th frame image. By using the state quantities in the cam set and the IMU set as prior information for prior estimation, the IMU state quantity IMUj of the j-th frame image is optimized in combination with the cam state quantity camj of the j-th frame image, so that the acceleration bias ba in IMUj j1 and gyro bias bω j1 More accurate, thereby making the position and posture of the j-th frame image calculated in step 404 more accurate.

[0101] Figure 6 FIG. 1 is another flow chart of the posture measurement method of the embodiment of the present application, taking the camera application to execute the method as an example. Figure 6 As shown, the method may include:

[0102] Step 600: Preparation step.

[0103] After the camera application enters the image preview interface based on user operation, or starts taking images or videos based on user operation, the pose measurement can be started. Accordingly, the preparation step for camera measurement, which can also be called the initialization step, can be started.

[0104] Optionally, a cam set and an IMU set are maintained in the electronic device, the number m of cam state quantities included in the cam set can be preset, and the number n of IMU state quantities included in the IMU set can be preset. Optionally, the values ​​of m and n can be the same or different. Due to the characteristics of the IMU, the correlation between the historical data with a long history and the currently detected data is weak, and the number n of IMU state quantities included in the IMU set can be less than the number m of cam state quantities included in the cam set.

[0105] The method for the camera application to initialize the cam set and the IMU set is illustrated as follows.

[0106] The camera application can obtain n frames of images taken by the camera from the camera driver, which are the 1st frame to the mth frame, and obtain the IMU measurement data corresponding to each frame of the image from the IMU driver, such as the accelerometer driver and the gyroscope driver; the camera application calculates the cam state quantity of the m frames of images to obtain cam1~camm, calculates the IMU state quantity of the m frames of images to obtain IMU1~IMUm, adds the cam state quantities cam1~camm of the m frames of images to the cam set, and adds the IMU state quantities IMU(m-n+1)~IMUm of the n frames of images most recently in time to the IMU set.

[0107] Assume m is 10 and n is 5. Figure 7, the cam set may include 10 cam state quantities, cam1 to cam10, and the cam state quantities are arranged in sequence from right to left according to the shooting time of the corresponding image. The cam state quantity cam1 is the cam state quantity of the 1st frame image, and the cam state quantity cam10 is the cam state quantity of the 10th frame image; the IMU set includes 5 IMU state quantities, imu1 to imu5, and the IMU state quantities are arranged in sequence from right to left according to the shooting time of the corresponding image. The IMU state quantity imu6 is the IMU state quantity of the 6th frame image, and the IMU state quantity imu10 is the IMU state quantity of the 10th frame image. Among them, the cam state quantities cam6 to cam10 and the IMU state quantities imu6 to imu10 correspond to each other, and are the cam state quantities and IMU state quantities of the same frame image.

[0108] The covariance matrix may be maintained in the electronic device, and the initial covariance matrix may be a unit matrix.

[0109] The electronic device calculates the initial camera pose p based on the m frames of images and the IMU measurement data of the m frames of images. 0 The specific calculation method can be implemented using the calculation method of the relevant initial camera pose, which is not limited in the embodiments of the present application.

[0110] When the camera application calculates the cam state quantity and the IMU state quantity of the m-frame image, the calculation method can refer to the corresponding description in step 402, and the main difference is:

[0111] When calculating the cam state and IMU state of m frames, the parameters other than the quantities to be calculated in the calculation formula are as follows: The above calculations can be completed using the initial value corresponding to this parameter.

[0112] In the above calculation formula, the parameters other than the quantity to be calculated are as follows: The initial value calculation method of etc. can be completed using a related method, which is not limited in the embodiments of the present application. For example, a motion reconstruction (structure-from-motion, SFM) method can be used to implement it.

[0113] Step 601: Acquire the (m+1)th frame image, and acquire the IMU measurement data corresponding to the (m+1)th frame image.

[0114] Combination Figure 3 The camera application can obtain the m+1th frame image taken by the camera from the camera driver, and obtain the IMU measurement data corresponding to the m+1th frame image from the IMU driver (such as the accelerometer driver and the gyroscope driver).

[0115] Step 602: Determine whether the (m+1)th frame image is a key frame image, if not, execute step 606, if yes, execute step 603.

[0116] In one example, feature points can be extracted from the m+1th frame image, and the moving distance of the feature points in the m+1th frame image relative to the matching feature points in the mth frame image can be calculated. When the moving distance is greater than a preset distance threshold, it can be determined that the m+1th frame image is a key frame image; otherwise, it is determined that the m+1th frame image is not a key frame image.

[0117] The embodiment of the present application does not limit the method for matching feature points between the (m+1)th frame image and the (m)th frame image, and can be implemented using a related feature point matching method.

[0118] Optionally, there may be multiple feature points extracted from each image. In this case, a statistical method can be used to determine that the m+1th frame image is a key frame image when the number of feature points whose moving distance is greater than a preset distance threshold among the multiple feature points is greater than a preset number threshold. Otherwise, the m+1th frame image is determined not to be a key frame image.

[0119] In another example, the moving distance of the electronic device in the x, y, and z axis directions can be calculated based on the acceleration data corresponding to the m+1th frame image. When the moving distance in at least one axis direction is greater than a preset distance threshold, the m+1th frame image is judged to be a key frame image; otherwise, the m+1th frame image is judged not to be a key frame image.

[0120] In the third example, the rotation angle of the electronic device in the x-, y-, and z-axis directions can be calculated based on the angular velocity data corresponding to the m+1th frame image. When the rotation angle in at least one axis direction is greater than a preset angle threshold, the m+1th frame image is judged to be a key frame image; otherwise, the m+1th frame image is judged not to be a key frame image.

[0121] In the fourth example, the judgment criteria of at least two of the above three examples can be combined. When at least one of the at least two judgment criteria is met, the m+1th frame image is judged to be a key frame image; otherwise, the m+1th frame image is judged not to be a key frame image.

[0122] For example, the judgment criteria of the three instances can be combined. In this case, when at least one of the following three conditions is met, the m+1th frame image is judged to be a key frame image, otherwise, the m+1th frame image is judged not to be a key frame image: the movement distance of the feature point in the m+1th frame image relative to the feature point matching it in the mth frame image is greater than a preset distance threshold, the movement distance of the electronic device in at least one of the x, y, and z axes is greater than the preset distance threshold, and the rotation angle of the electronic device in at least one of the x, y, and z axes is greater than a preset angle threshold.

[0123] This step is an optional step. In other words, it is not necessary to determine whether the m+1 frame image is a key frame image. Instead, each frame image is used as a key frame image to execute steps 603 and 604. In this case, the calculation accuracy of the camera pose can be improved, but the data processing capacity of the electronic device is relatively large. By determining the key frame in this step, the data processing capacity of the electronic device can be reduced.

[0124] Step 603: Determine the cam state cam(m+1) and the IMU state IMU(m+1) of the m+1th frame image according to the IMU measurement data corresponding to the m+1th frame image and the m+1th frame image.

[0125] The implementation of this step can refer to step 402, the main difference is: j is replaced by m+1, and i is replaced by m. In other words, the m+1th frame image in this step corresponds to the jth frame image in step 402, and the mth frame image corresponds to the ith frame image in step 402.

[0126] It should be noted that in the above calculation, the parameters other than the unknown quantity, such as etc. can also be implemented using the corresponding initial values.

[0127] Step 604: Calculate the graph constraint residuals corresponding to the cam state quantities cam2~cam(m+1) according to the oldest cam state quantity cam1 in the cam set, and calculate the graph constraint residuals corresponding to IMU2~IMU(m+1) according to the oldest IMU state quantity IMU1 in the IMU set.

[0128] Optionally, in this step, the graph constraint residual corresponding to the external parameter can also be calculated according to the oldest cam state cam1 in the cam set and the oldest IMU state IMU1 in the IMU set. The external parameter here refers to: the external parameter of the camera and the IMU.

[0129] The external parameters of the above-mentioned camera refer to the parameters of the camera in the world coordinate system, such as the camera's position, rotation direction, etc., which are used to convert the coordinates from the world coordinate system to the camera coordinate system, which can be determined specifically through calibration.

[0130] The external parameters of IMU refer to the parameters of IMU in the world coordinate system. Their function is to convert the coordinates from the world coordinate system to the IMU coordinate system, which can be determined through calibration.

[0131] Combination Figure 8In this step, in order to discard the oldest cam state in the cam set later, the information of the oldest cam state in the cam set should be retained in the graph constraint residual corresponding to cam2~cam(m+1). In order to discard the oldest IMU state in the IMU set, the information of the oldest IMU state in the IMU set should be retained in IMU(m-n+2)~IMU(m+1).

[0132] The calculation principle is described below.

[0133] Construct the following graph constraint relationship:

[0134]

[0135] Among them, H11, H12, H21, and H22 correspond to the parameter values ​​in the cam state quantity, δx1 represents any cam state quantity from cam2 to cam(m+1), δx2 represents the oldest cam state quantity cam1 in the cam set, and b1 and b2 take the initial values ​​corresponding to the cam state quantities;

[0136] Performing the following calculation on the above graph constraint relationship can obtain the graph constraint residual of δx1 The graph constraint residual retains the graph constraint relationship of the oldest cam state cam1

[0137]

[0138]

[0139]

[0140] Based on the above calculation principle, the graph constraint residuals corresponding to cam2~cam(m+1) can be calculated.

[0141] Based on the above similar calculation principles, the graph constraint residuals corresponding to IMU(m-n+2)~IMU(m+1) can also be calculated according to the oldest IMU state quantity IMU(m-n+1), and the graph constraint residuals corresponding to the external parameters can also be calculated. The specific calculation process will not be described in detail in the embodiments of this application.

[0142] Step 605: Optimize cam2~cam(m+1), IMU(m-n+2)~IMU(m+1) according to the above graph constrained residuals.

[0143] Optionally, the above external parameters may also be optimized.

[0144] Specifically, this step may include:

[0145] like Fig. 9As shown, assuming there are 4 frames of image corresponding to the camera pose x p1 ~x p4 , and the 6 observed landmarks. The line between the camera pose and the landmark indicates that the image captured by the camera includes the landmark. The line between the camera pose and the camera pose indicates the IMU constraint. They form a graph constraint based on similar Figure 7 The graph constraint shown can construct the graph constraint relation: Hδx=b, where H is the covariance matrix, δx represents the cam state quantity and the IMU state quantity, and b is the variable corresponding to the cam state quantity and the IMU state quantity;

[0146] Substitute the existing state quantities cam2~cam(m+1), IMU(m-n+2)~IMU(m+1) and external parameters into the covariance matrix H of the graph constraint relationship;

[0147] Minimize the graph constraint residuals corresponding to the existing state quantities cam2~cam(m+1), IMU(m-n+2)~IMU(m+1), and external parameters, perform nonlinear optimization on the graph constraint relationship Hδx=b, and obtain the optimal solution of cam2~cam(m+1), IMU(m-n+2)~IMU(m+1), and external parameters. The above optimal solution is also the optimized cam2~cam(m+1), IMU 7~IMU(m+1), and external parameters.

[0148] When performing nonlinear optimization, relevant nonlinear optimization methods such as gradient descent, Gauss-Newton, LM method, etc. can be used, which is not limited in the embodiments of the present application.

[0149] Step 606: Calculate the camera pose of the (m+1)th frame image.

[0150] If it is determined from step 602 that the m+1th frame image is not a key frame and this step is performed, the camera pose of the m+1th frame image can be calculated according to IMUj;

[0151] If this step is performed after step 605, the camera pose of the m+1th frame image can be calculated according to the optimized IMU (m+1).

[0152] The specific calculation method can be referred to step 403 and will not be described in detail here.

[0153] The camera pose corresponding to the m+1th frame image calculated in this step can be used as basic data for calculating the image deformation grid in electronic image stabilization.

[0154] Step 607: Update the covariance matrix H with the optimized cam2~cam(m+1), IMU(m-n+2)~IMU(m+1), and external parameters.

[0155] Step 608: Update the cam set and the IMU set according to the optimized optimal solutions of cam2~cam(m+1) and IMU(m-n+2)~IMU(m+1), and discard the oldest state quantities in the cam set and the IMU set.

[0156] Step 607 and step 608 are optional steps, which can be used as basic data for the camera application to calculate the camera pose corresponding to the m+2 frame image. Afterwards, the camera application can return to step 601, obtain the m+2 frame image and its corresponding IMU measurement data, and then execute steps 603 to 608 to calculate the camera pose corresponding to the m+2 frame image.

[0157] Figure 6 In the method shown, key frames and non-key frames are further distinguished, and only the cam state quantities and IMU state quantities of the key frame images are used to update the cam set and IMU set, thereby reducing the data processing amount of the electronic device while ensuring the accuracy of the camera pose.

[0158] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the processor is used to implement the method provided in the embodiment of the present application.

[0159] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the method provided by the embodiment of the present application.

[0160] The embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is run on a computer, it enables the computer to execute the method provided by the embodiment of the present application.

[0161] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0162] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0163] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0164] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the 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 a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.

[0165] The above is only a specific implementation of the present application. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A posture measurement method, characterized in that: Applied to an electronic device, the electronic device includes a camera, and the method includes: Acquire a first image and IMU measurement data corresponding to the first image; Determine a first state quantity and a second state quantity of the first image according to the first image and the IMU measurement data, wherein the first state quantity includes an image residual corresponding to at least one feature point in the first image; and the second state quantity includes: a preset IMU measurement component; The second state quantity of the first image is optimized according to the first set, the second set, and the first state quantity of the first image to obtain an optimized second state quantity; the first set includes: the first state quantity of the image m frames before the first image; the second set includes: the second state quantity of the image n frames before the first image; m is a natural number, and n is a natural number; Calculating the posture of the camera when taking the first image according to the optimized second state quantity; The step of optimizing the second state quantity of the first image according to the first set, the second set, and the first state quantity of the first image to obtain the optimized second state quantity includes: Determine, according to the first state quantity of the earliest frame image in the first set, the graph constrained residual of the first state quantity of the first image and the graph constrained residual of other first state quantities in the first set; Determine the graph-constrained residual of the second state quantity of the first image and the graph-constrained residual of other second state quantities in the second set according to the second state quantity of the earliest frame image in the second set; The second state quantity of the first image is optimized according to the graph constraint residual.

2. The method according to claim 1, characterized in that: The IMU measurement components include: accelerometer bias and gyroscope bias.

3. The method according to claim 2, characterized in that The IMU measurement component also includes at least one of the following components: the position of the camera, the moving speed of the camera, and the rotation angle of the camera.

4. The method according to any one of claims 1 to 3, characterized in that: The step of optimizing the second state quantity of the first image according to the graph constraint residual comprises: Constructing a graph constraint relationship according to the first state quantity of the first image, the other first state quantities in the first set, the second state quantity of the first image, and the other second state quantities in the second set; The graph constraint residual is minimized, and nonlinear optimization processing is performed on the graph constraint relationship to obtain an optimized second state quantity of the first image.

5. The method according to claim 4, characterized in that Also includes: Performing nonlinear optimization processing on the graph constraint relational expression to obtain an optimized first state quantity of the first image, an optimized other first state quantity, and an optimized other second state quantity; According to the other optimized first state quantities, the other first state quantities in the first set are updated, the optimized first state quantity of the first image is added to the first set, and the first state quantity of the image with the earliest shooting time is discarded; according to the other optimized second state quantities, the other second state quantities in the second set are updated, the optimized second state quantity of the first image is added to the second set, and the second state quantity of the image with the earliest shooting time is discarded.

6. The method according to any one of claims 1 to 3, characterized in that: Before determining the first state quantity and the second state quantity of the first image, the method further includes: It is determined that the first image is a key frame image.

7. The method according to claim 6, characterized in that The determining that the first image is a key frame image includes: Determine that a distance between a feature point of the first image and a feature point in the second image that matches the feature point is greater than a first threshold; and / or, Determining that the movement distance of the camera in a preset direction is greater than a second threshold; and / or, It is determined that the rotation angle of the camera in the preset direction is greater than a third threshold.

8. The method according to claim 6, characterized in that Also includes: It is determined that the first image is not a key frame image, and a camera pose corresponding to the first image is calculated according to a second state quantity of the first image.

9. An electronic device, characterized in that: include: Processor, memory; One or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the processor, enable the electronic device to perform the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Pose estimation method based on RGB-D and IMU information fusion

    CN109993113A

  • Posture determining method and device, and odometer

    CN110260861A