Image processing method and device, electronic equipment, and storage medium
By acquiring the current and historical poses of the electronic device and combining them with the motion state to predict the target pose for image stabilization, the problem of insufficient image stability at high zoom ranges is solved, achieving adaptive and real-time image stabilization effects.
Patent Information
- Application Number
- CN202311226124.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-09-21
AI Technical Summary
Existing image stabilization technologies cannot effectively stabilize images at high zoom levels (such as 100X to 120X), resulting in insufficient image stability and responsiveness.
By acquiring the current and historical poses of electronic devices and combining them with motion states, the target pose is predicted and anti-shake processing is performed, including filtering, interpolation, and pose transformation. The optimal pose is determined using pose sensors and deep learning models to reduce the impact of jitter.
It achieves adaptive image stabilization under different motion conditions, improving image stability and stabilization effect, and is suitable for real-time image stabilization scenarios such as image preview and autonomous driving.
Smart Images

Figure CN119676557B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method and apparatus, electronic device, and storage medium. Background Technology
[0002] When electronic devices, including mobile phones, cameras, and wearable devices, capture images through image acquisition components (such as cameras), changes in the position or posture of the electronic device, such as hand tremors when the user holds the electronic device to take a picture, or active movement of the electronic device, will cause the captured image to shake, affecting the image clarity and visual effect.
[0003] Currently, mainstream image stabilization technologies are applicable to focal lengths between 0.5X and 5X (12mm to 120mm). However, with the development of electronic devices and the increasing sophistication of lenses, coupled with electronic cropping, focal lengths can reach 100X (equivalent focal length 2400mm) or even 120X (equivalent focal length 2880mm). In such cases, the movements of electronic devices are linearly amplified many times over. If traditional electronic image stabilization algorithms are used, the stability and responsiveness of the processed image will be significantly insufficient. Summary of the Invention
[0004] This disclosure provides an image processing method and apparatus, an electronic device, and a storage medium.
[0005] According to a first aspect of the present disclosure, an image processing method is provided, comprising:
[0006] The current pose of the electronic device when it acquires the image, and the historical pose of the electronic device before acquiring the image;
[0007] The motion state of the electronic device is determined based on the current posture and the historical posture.
[0008] Based on the current posture, the historical posture, and the motion state, predict the target posture of the electronic device;
[0009] The image is stabilized using the target pose to obtain a stabilized image.
[0010] In some embodiments, predicting the target pose of the electronic device based on the current pose, the historical pose, and the motion state includes:
[0011] Different filtering processes are applied to the current pose and the historical pose to obtain different filtered poses;
[0012] Based on the motion state of the electronic device, the filtering posture to be interpolated is selected from the different filtering postures;
[0013] Interpolation processing is performed based on the filtered attitude to be interpolated to obtain the target attitude of the electronic device.
[0014] In some embodiments, the interpolation process based on the filtered pose to be interpolated to obtain the target pose of the electronic device includes:
[0015] Based on the duration of the motion state and the filtering posture to be interpolated, the interpolation coefficients corresponding to the filtering posture to be interpolated are determined.
[0016] Interpolation is performed based on the filtered attitude to be interpolated and the interpolation coefficients corresponding to the filtered attitude to be interpolated, to obtain the target attitude of the electronic device.
[0017] In some embodiments, the filtering pose to be interpolated includes two filtering poses, the filtering poses are represented by quaternions, and the interpolation process includes spherical linear interpolation of quaternions;
[0018] The step of determining the interpolation coefficients corresponding to the filter posture to be interpolated based on the duration of the motion state and the filter posture to be interpolated includes:
[0019] Based on the duration of the motion state, determine the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion;
[0020] Determine the cosine angle between the two filter poses to be interpolated;
[0021] Based on the cosine angle and the weights corresponding to the two filtering postures, the interpolation coefficients corresponding to each filtering posture to be interpolated are determined.
[0022] In some embodiments, the method further includes:
[0023] Obtain the duration threshold;
[0024] The step of determining the weights corresponding to the two filter poses to be interpolated in the spherical linear interpolation of the quaternion based on the duration of the motion state includes:
[0025] In response to the duration of the motion state being greater than a duration threshold, the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion are determined; wherein, the weight of the preset initial filter posture in the two filter postures to be interpolated is positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filter postures to be interpolated is a first preset value.
[0026] In response to the duration of the motion state being less than or equal to the duration threshold, the weight of the preset initial filtering posture is determined to be the first preset value, and the weight of the filtering posture to be interpolated other than the preset initial filtering posture is 0.
[0027] In some embodiments, the method further includes:
[0028] Obtain the focal length of the image captured by the electronic device;
[0029] The acquisition duration threshold includes:
[0030] When the focal length belongs to a preset focal length, the duration threshold corresponding to the focal length is determined according to a preset mapping relationship; wherein, the preset mapping relationship includes the mapping between the focal length and the duration threshold;
[0031] or,
[0032] If the focal length does not belong to the preset focal length, the duration threshold corresponding to the focal length is determined according to the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length; wherein, the first preset focal length and the second preset focal length both belong to the preset focal length.
[0033] In some embodiments, the first preset focal length and the second preset focal length are both preset focal lengths adjacent to the focal length; determining the duration threshold corresponding to the focal length based on the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length includes:
[0034] The ratio of the difference between the focal length and the second preset focal length to the difference between the first preset focal length and the second preset focal length is determined as the first focal length weight of the first preset focal length.
[0035] The ratio of the difference between the first preset focal length and the focal length to the difference between the first preset focal length and the second preset focal length is determined as the second focal length weight of the second preset focal length.
[0036] The sum of the result of weighting the first focal length weight on the preset duration threshold corresponding to the first preset focal length and the result of weighting the second focal length weight on the preset duration threshold corresponding to the second preset focal length is determined as the duration threshold corresponding to the focal length.
[0037] In some embodiments, the filtering of the current pose and the historical pose in different ways to obtain different filtered poses includes:
[0038] The current pose and the historical pose are weighted respectively, and the first filtered pose is obtained based on the weighted poses;
[0039] Perform Kalman filtering on the current pose and the historical pose to obtain a second filtered pose;
[0040] The current pose is weighted, and a third filtered pose is obtained based on the weighted current pose and the historical pose.
[0041] In some embodiments, the step of weighting the current pose and the historical pose, and obtaining the first filtered pose based on the weighted poses, includes:
[0042] The sum of the result of weighting the current pose with the first preset weight and the result of weighting the historical pose with the second preset weight is determined as the first filtered pose; wherein, the first preset weight is positively correlated with the difference between the current pose and the historical pose; the sum of the first preset weight and the second preset weight is the second preset value.
[0043] In some embodiments, the weighting of the current pose and the determination of the third filtered pose based on the weighted current pose and the historical poses include:
[0044] The sum of the result of weighting the current pose with the third preset weight and the historical pose is determined as the third filtered pose; wherein the third preset weight is less than the preset weight threshold.
[0045] In some embodiments, the motion state includes jitter, movement, and stillness; the step of selecting the filtering posture to be interpolated from the different filtering postures based on the motion state of the electronic device includes:
[0046] When the motion state includes jitter, the third filtering posture and the first filtering posture are determined as the filtering posture to be interpolated;
[0047] When the motion state includes moving or stationary, the first filtering posture and the second filtering posture are determined as the filtering posture to be interpolated.
[0048] In some embodiments, the current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity; determining the motion state of the electronic device based on the current attitude and the historical attitude includes:
[0049] Determine whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold, respectively.
[0050] If both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jitter.
[0051] or,
[0052] If the current angular velocity or the historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity.
[0053] In some embodiments, when the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, determining the motion state of the electronic device based on the current angular velocity and the historical angular velocity includes:
[0054] If the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, the motion state of the electronic device is determined to be jittering based on the current angular velocity and the historical angular velocity, in response to satisfying one of the following: the jitter frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold.
[0055] In response to the fact that both the current angular velocity and the historical angular velocity are less than the first preset angular velocity threshold, the motion state of the electronic device is determined to be stationary.
[0056] In response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity has not changed, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold, the motion state of the electronic device is determined to be moving.
[0057] In some embodiments, the step of using the target pose to perform image stabilization processing on the image to obtain a stabilized image includes:
[0058] The coordinates of pixels in the image are transformed using the target pose to obtain a coordinate-transformed image;
[0059] The image after coordinate transformation is cropped to obtain the image after image stabilization.
[0060] According to a second aspect of the present disclosure, an image processing apparatus is provided, comprising:
[0061] The first acquisition module is used to acquire the current posture of the electronic device when it is acquiring the image, and the historical posture of the electronic device before acquiring the image;
[0062] The determination module is used to determine the motion state of the electronic device based on the current posture and the historical posture;
[0063] The prediction module is used to predict the target posture of the electronic device based on the current posture, the historical posture, and the motion state.
[0064] The image stabilization module is used to perform image stabilization processing on the image based on the target pose, so as to obtain an image after image stabilization.
[0065] In some embodiments, the prediction module is configured to perform filtering processing on the current pose and the historical pose in different ways to obtain different filtered poses; select a filtered pose to be interpolated from the different filtered poses based on the motion state of the electronic device; and perform interpolation processing based on the filtered pose to be interpolated to obtain the target pose of the electronic device.
[0066] In some embodiments, the prediction module is configured to determine the interpolation coefficients corresponding to the filtered posture to be interpolated based on the duration of the motion state and the filtered posture to be interpolated; and to perform interpolation processing based on the filtered posture to be interpolated and the interpolation coefficients corresponding to the filtered posture to be interpolated to obtain the target posture of the electronic device.
[0067] In some embodiments, the filtering pose to be interpolated includes two filtering poses, the filtering poses are represented by quaternions, and the interpolation process includes spherical linear interpolation of quaternions;
[0068] The prediction module is used to determine the weights corresponding to the filter postures of two objects to be interpolated in the spherical linear interpolation of the quaternion based on the duration of the motion state; determine the cosine angle between the filter postures of the two objects to be interpolated; and determine the interpolation coefficients corresponding to the filter postures of each object to be interpolated based on the cosine angle and the weights corresponding to the two filter postures.
[0069] In some embodiments, the apparatus further includes:
[0070] The second acquisition module is used to acquire the duration threshold;
[0071] The prediction module is configured to, in response to the duration of the motion state being greater than a duration threshold, determine the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion; wherein, the weight of the preset initial filter posture among the two filter postures to be interpolated is positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filter postures to be interpolated is a first preset value; in response to the duration of the motion state being less than or equal to the duration threshold, determine the weight of the preset initial filter posture as the first preset value, and the weight of the filter postures to be interpolated other than the preset initial filter posture is 0.
[0072] In some embodiments, the apparatus further includes:
[0073] The third acquisition module is used to acquire the focal length when the electronic device acquires the image;
[0074] The second acquisition module is configured to, when the focal length belongs to a preset focal length, determine the duration threshold corresponding to the focal length according to a preset mapping relationship; wherein the preset mapping relationship includes a mapping between the focal length and the duration threshold; or, when the focal length does not belong to the preset focal length, determine the duration threshold corresponding to the focal length according to the duration thresholds corresponding to a first preset focal length greater than the focal length and a second preset focal length less than the focal length; wherein both the first preset focal length and the second preset focal length belong to the preset focal length.
[0075] In some embodiments, the second acquisition module is configured to determine the first focal length weight of the first preset focal length as the ratio of the difference between the focal length and the second preset focal length to the difference between the first preset focal length and the second preset focal length; determine the second focal length weight of the second preset focal length as the ratio of the difference between the first preset focal length and the focal length to the difference between the first preset focal length and the second preset focal length; and determine the duration threshold corresponding to the focal length as the sum of the result of weighting the first focal length weight on a preset duration threshold corresponding to the first preset focal length and the result of weighting the second focal length weight on a preset duration threshold corresponding to the second preset focal length.
[0076] In some embodiments, the prediction module is configured to perform weighted processing on the current pose and the historical pose respectively, and obtain a first filtered pose based on each weighted pose; perform Kalman filtering on the current pose and the historical pose to obtain a second filtered pose; perform weighted processing on the current pose, and obtain a third filtered pose based on the weighted current pose and the historical pose.
[0077] In some embodiments, the prediction module is used to determine the first filtered posture as the sum of the result of weighting the current posture with a first preset weight and the result of weighting the historical posture with a second preset weight; wherein the first preset weight is positively correlated with the difference between the current posture and the historical posture; and the sum of the first preset weight and the second preset weight is a second preset value.
[0078] In some embodiments, the prediction module is used to determine the third filtered posture as the sum of the result of weighting the current posture with the third preset weight and the historical posture; wherein the third preset weight is less than a preset weight threshold.
[0079] In some embodiments, the motion state includes jitter, movement, and stillness; the prediction module is configured to determine the third filtering posture and the first filtering posture as the filtering posture to be interpolated when the motion state includes jitter; and to determine the first filtering posture and the second filtering posture as the filtering posture to be interpolated when the motion state includes movement or stillness.
[0080] In some embodiments, the current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity; the determining module is configured to determine whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold; if both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jitter; or, if either the current angular velocity or the historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity.
[0081] In some embodiments, the determining module is configured to, when the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, determine the motion state of the electronic device as jittering based on the current angular velocity and the historical angular velocity, in response to satisfying one of the following: the jitter frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold; determine the motion state of the electronic device as stationary in response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity does not change, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold; and determine the motion state of the electronic device as moving in response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity does not change, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold.
[0082] In some embodiments, the image stabilization module is used to transform the coordinates of pixels in the image using the target pose to obtain a coordinate-transformed image; and to crop the coordinate-transformed image to obtain the image after image stabilization.
[0083] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0084] A processor; a memory for storing processor-executable instructions; wherein the processor is configured to perform the method as described in the first aspect above.
[0085] According to a fourth aspect of the present disclosure, a storage medium is provided, comprising:
[0086] When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method described in the first aspect above.
[0087] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:
[0088] The reliability of the current pose varies depending on the motion state of the electronic device. For example, if the electronic device is shaking, the reliability of the current pose is low because shaking has a significant impact on it, while the reliability of the historical pose is high. The target pose after reducing the impact of shaking is closer to the historical pose. If the electronic device is moving (e.g., a user holding the device and panning to take a picture), the current pose after moving is more consistent with the pose of the currently captured image, thus the reliability of the current pose is high, while the reliability of the historical pose is low. The target pose after reducing the impact of shaking is closer to the current pose. Therefore, this embodiment determines the motion state of the electronic device based on the current pose and the historical pose, and predicts the target pose of the electronic device based on the current pose, the historical pose, and the motion state. The target pose after reducing the impact of shaking is then used to perform image stabilization. On the one hand, this makes the image after stabilization better match the motion state of the electronic device, achieving adaptive stabilization for the electronic device in different motion scenarios with better stabilization effect. On the other hand, since this embodiment does not introduce the future pose of the electronic device, real-time stabilization can be achieved. This solution has a significant advantage in scenarios with high real-time stabilization requirements, such as image preview and autonomous driving path planning.
[0089] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0090] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0091] Figure 1 This is a flowchart illustrating an image processing method according to an embodiment of the present disclosure.
[0092] Figure 2 This is an example diagram showing the weights corresponding to the filtering postures of two objects to be interpolated in the spherical linear interpolation of quaternions, as determined by an embodiment of this disclosure.
[0093] Figure 3 This is an example image comparing images before and after image stabilization processing, as shown in an embodiment of this disclosure.
[0094] Figure 4 This is a diagram of an image processing apparatus shown in an embodiment of the present disclosure.
[0095] Figure 5 This is a block diagram of an electronic device illustrated in an embodiment of this disclosure. Detailed Implementation
[0096] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0097] Among related technologies, image stabilization techniques include Electronic Image Stabilization (EIS) and Optical Image Stabilization (OIS). Electronic image stabilization works by using accelerometers and gyroscopes within electronic devices to detect the amplitude of vibrations, dynamically adjusting the camera's sensitivity, shutter speed, and imaging algorithms to correct blurring caused by hand shake. Optical image stabilization, on the other hand, involves installing miniature motors inside the lens that can move in multiple directions. These motors convert real-time vibration information detected by the gyroscope and accelerometer into electrical signals, predicting the image shift caused by tilt. This image shift is then fed back to the motors, causing them to move the sensors with an offset equal to but opposite in direction to the predicted shift. This offset cancels out image shifts caused by hand tremors, achieving image stabilization.
[0098] However, this type of image stabilization technology has significant shortcomings in image stability and responsiveness at different zoom ratios, especially at focal lengths as high as 100X (2400mm) or even 120X (2880mm).
[0099] In this regard, embodiments of the present disclosure provide an image processing method, the execution subject of which can be an image processing device. For example, the image processing method can be executed by an electronic device including an image acquisition component, a server, or other electronic devices. The electronic device can be a mobile phone, camera, tablet computer, in-vehicle device, wearable device, etc. If the execution subject is a server or other electronic device, after acquiring the image and posture captured by the electronic device, it is sent to the server or other electronic device. The server or other electronic device then performs image stabilization processing based on the image and posture, and can also feed back the stabilized image to the electronic device for preview or subsequent image processing. In some possible implementations, the image processing method can be implemented by a processor calling computer-readable instructions stored in memory. The following description uses an electronic device as the execution subject for image processing as an example.
[0100] Figure 1 This is a flowchart illustrating an image processing method according to an embodiment of the present disclosure. Figure 1 It can be seen that the process includes the following steps:
[0101] S101. Obtain the current posture of the electronic device when it is acquiring the image, and the historical posture of the electronic device before acquiring the image;
[0102] S102. Determine the motion state of the electronic device based on the current posture and the historical posture;
[0103] S103. Based on the current posture, the historical posture, and the motion state, predict the target posture of the electronic device;
[0104] S104. Use the target pose to perform image stabilization processing on the image to obtain the image after image stabilization.
[0105] In this embodiment of the disclosure, the electronic device may be the aforementioned terminal device including the image acquisition component, such as a mobile phone, camera, tablet computer, vehicle-mounted device, wearable device, etc.
[0106] In step S101, the current attitude of the electronic device when acquiring the image and the historical attitude of the electronic device before acquiring the image can be obtained based on the attitude sensor. The attitude sensor can be a three-axis gyroscope, angular velocity sensor, displacement sensor, etc. Correspondingly, the current attitude and historical attitude can include rotation matrix, Euler angle, quaternion, angular velocity, vector displacement, etc.
[0107] In step S102, the motion state of the electronic device is determined based on the current attitude and the historical attitude. In some embodiments, if the current attitude is consistent with the historical attitude, such as the current angular velocity being consistent with the historical angular velocity (including the magnitude of the current angular velocity being consistent with the magnitude of the historical angular velocity and the direction of the current angular velocity being consistent with the direction of the historical angular velocity), the electronic device is determined to be in a moving (e.g., translational) motion state. If the current attitude is inconsistent with the historical attitude, such as the direction of the current angular velocity being inconsistent with the direction of the historical angular velocity, the electronic device is determined to be in a jittering (e.g., reciprocating jitter) motion state.
[0108] In some embodiments, the jitter frequency of the electronic device is determined based on the current attitude and multiple historical attitudes. If the jitter frequency of the electronic device is greater than a preset frequency threshold, the electronic device is determined to be in a jittering motion state; if the jitter frequency of the electronic device is less than or equal to the preset frequency threshold, the electronic device is determined to be in a moving motion state. The jitter frequency of the electronic device can be characterized by the number of angular velocities whose angular velocity difference between adjacent moments exceeds a preset angular velocity difference threshold; or it can be characterized by the number of angular velocities whose angular velocity direction changes between adjacent moments.
[0109] In some embodiments, the current pose and historical poses are processed based on a preset state model to obtain the motion state of the electronic device. The preset state model can be trained based on a deep learning network. For example, based on pose sample data and label values, the network (such as a Convolutional Neural Network (CNN) or a Deep Neural Network (DNN)) is trained and its parameters are tuned to obtain the state model, where the label values represent the preset motion state.
[0110] Understandably, if the electronic device is in a state of shaking, this shaking has a significant impact on the current posture, thus the reliability of the current posture is low, while the reliability of the historical posture is high. If the electronic device is in a state of movement (such as when a user holds the device and moves it to take a picture), the current posture after the movement is more consistent with the posture of the currently captured image, thus the reliability of the current posture is high, while the reliability of the historical posture is low.
[0111] In step S103, the electronic device predicts its target pose based on the current pose, historical pose, and motion state. In some embodiments, as mentioned above, if the motion state of the electronic device is jittering, the reliability of the current pose is low, while the reliability of the historical pose is high, so the historical pose can be used as the target pose; or the sum of the weighted result of the current pose and the weighted result of the historical pose can be used as the target pose; wherein the weight of the current pose is less than the weight of the historical pose.
[0112] In some embodiments, as described above, if the motion state of the electronic device is moving, the current posture has a higher reliability and the historical posture has a lower reliability, so the current posture can be used as the target posture; or the sum of the weighted result of the current posture and the weighted result of the historical posture can be used as the target posture; wherein, the weight of the current posture is greater than the weight of the historical posture.
[0113] In some embodiments, the current attitude and the historical attitude can be smoothed and filtered to obtain the smoothed current attitude and the smoothed historical attitude; thereby, based on a similar method to the foregoing embodiments, the target attitude of the electronic device can be predicted according to the smoothed current attitude, the smoothed historical attitude and the motion state.
[0114] In some embodiments, the current posture, historical posture, and motion state are processed based on a preset posture model to obtain the target posture of the electronic device. The preset posture model can be trained using a deep learning network. For example, it can be obtained by training and tuning a network such as a convolutional neural network or a deep learning network based on posture sample data associated with motion states and label values. The label values represent the preset target posture.
[0115] It is understood that the target posture of the electronic device predicted in the embodiments of this disclosure is a posture that matches the motion state of the electronic device, based on the current posture and historical postures. Therefore, the target posture can characterize the posture of the electronic device after reducing the impact of jitter.
[0116] After determining the target pose of the electronic device, step S104 is executed to perform image stabilization processing on the image currently acquired by the electronic device using the target pose, thereby obtaining the image after image stabilization.
[0117] In some embodiments, the electronic device determines the pose difference between the target pose and the current pose based on the target pose and the current pose, and calculates the transformation matrix corresponding to the image to be processed based on the pose difference; wherein the transformation matrix may include at least one of a rotation matrix and a translation matrix. Thus, the coordinates of each pixel in the image are transformed according to the transformation matrix corresponding to the image to be processed, and the transformed coordinates of each pixel are determined, thereby obtaining the target image.
[0118] In some embodiments, based on the aforementioned transformation matrix, the coordinates of pixels outside the preset center range in the image are transformed to determine the transformed coordinates of each pixel outside the preset center range. Thus, based on the transformed coordinates of the pixels outside the preset center range and the coordinates of the pixels within the preset center range, a target image is obtained. If the transformed coordinates of the pixels outside the preset center range overlap with the coordinates of the pixels within the center range, the average value of the overlapping pixels is taken as the pixel value of the pixel at that coordinate.
[0119] It is understandable that the reliability of the current pose varies depending on the motion state of the electronic device. For example, if the electronic device is shaking, the reliability of the current pose is low because shaking has a significant impact on the current pose, while the reliability of the historical pose is high. The target pose after reducing the impact of shaking is closer to the historical pose. If the electronic device is moving (such as when a user holds the device and moves it to take a picture), the current pose after moving is more consistent with the pose of the currently captured image, thus the reliability of the current pose is high, while the reliability of the historical pose is low. The target pose after reducing the impact of shaking is closer to the current pose. Therefore, this embodiment determines the motion state of the electronic device based on the current pose and the historical pose, and predicts the target pose of the electronic device based on the current pose, the historical pose, and the motion state. The target pose after reducing the impact of shaking is then used to perform image stabilization. On the one hand, this makes the image after stabilization better match the motion state of the electronic device, achieving adaptive stabilization of the electronic device under different motion scenarios, resulting in better stabilization. On the other hand, since this embodiment does not introduce the future pose of the electronic device, real-time stabilization can be achieved. This solution has a significant advantage in scenarios with high requirements for real-time stabilization, such as image preview and autonomous driving path planning.
[0120] In some embodiments, predicting the target pose of the electronic device based on the current pose, the historical pose, and the motion state includes:
[0121] Different filtering processes are applied to the current pose and the historical pose to obtain different filtered poses;
[0122] Based on the motion state of the electronic device, the filtering posture to be interpolated is selected from the different filtering postures;
[0123] Interpolation processing is performed based on the filtered attitude to be interpolated to obtain the target attitude of the electronic device.
[0124] In the embodiments of this disclosure, the electronic device performs filtering processing on the current attitude and the historical attitude in different ways to obtain different filtered attitudes; for example, low-pass filtering is performed on the current attitude and the historical attitude to obtain a low-pass filtered attitude; stabilization filtering is performed on the current attitude and the historical attitude to obtain a stabilized attitude (with little difference from the historical attitude); median filtering is performed on the current attitude and the historical attitude to obtain a median filtered attitude; Kalman filtering is performed on the current attitude and the historical attitude to obtain a Kalman filtered attitude, etc. This disclosure does not limit the specific filtering method.
[0125] It is understandable that, as mentioned above, the attitude after low-pass filtering and the attitude after median filtering are filtered attitudes after noise reduction; the attitude after stabilization is closer to the historical attitude; and the attitude after Kalman filtering is the attitude of the best predicted estimate.
[0126] After obtaining different filtered attitudes, the electronic device selects the filtered attitude to be interpolated from the different filtered attitudes based on the motion state. For example, if the motion state is jittering, the current attitude has low confidence and the historical attitude has high confidence. Thus, the attitude after low-pass filtering and the attitude after stabilization can be used as the attitude to be interpolated, reducing the influence of the current attitude with low confidence on the target attitude.
[0127] For example, if the motion state is moving, the current attitude has a higher confidence level, while the historical attitude has a lower confidence level. Therefore, the attitude after median filtering and the attitude after Kalman filtering can be used as the attitude to be interpolated, reducing the influence of the historical attitude with lower confidence level on the target attitude.
[0128] After determining the pose to be interpolated, the electronic device performs interpolation processing on the filtered pose to be interpolated based on algorithms such as nearest neighbor interpolation, linear interpolation, bilinear interpolation, and higher-order interpolation to obtain the target pose of the electronic device.
[0129] It is understood that, on the one hand, the embodiments of this disclosure perform filtering processing on the current posture and historical posture in different ways to obtain different filtered postures, which can reduce noise interference; on the other hand, based on the motion state of the electronic device, the filtered posture to be interpolated is selected from different filtered postures, and interpolation processing is performed based on the filtered posture to be interpolated to obtain the target posture of the electronic device, which can reduce the influence of postures with low reliability in motion on the target posture and improve the accuracy of the target posture.
[0130] In some embodiments, the interpolation process based on the filtered pose to be interpolated to obtain the target pose of the electronic device includes:
[0131] Based on the duration of the motion state and the filtering posture to be interpolated, the interpolation coefficients corresponding to the filtering posture to be interpolated are determined.
[0132] Interpolation is performed based on the filtered attitude to be interpolated and the interpolation coefficients corresponding to the filtered attitude to be interpolated, to obtain the target attitude of the electronic device.
[0133] In this embodiment, the duration of a motion state represents the duration of maintaining the same motion state. The electronic device determines the interpolation coefficients corresponding to the filter attitude to be interpolated based on the duration of the motion state and the filter attitude to be interpolated. In some embodiments, the interpolation coefficients of the filter attitude to be interpolated corresponding to the duration of the motion state are determined based on a preset coefficient mapping relationship; wherein the preset coefficient mapping relationship is a mapping relationship obtained through multiple experiments for different motion states, including the mapping between the coefficients of the motion state, duration, and filter attitude to be interpolated.
[0134] In some embodiments, the duration of the motion state is processed based on a preset function corresponding to the motion state to obtain the interpolation coefficients corresponding to the filtered posture to be interpolated; wherein, the preset function is a function equation obtained by fitting multiple trials for different motion states.
[0135] After determining the interpolation coefficients corresponding to the filtered pose to be interpolated, the electronic device in this embodiment performs interpolation processing based on the filtered pose to be interpolated and the interpolation coefficients corresponding to the filtered pose to be interpolated, to obtain the target pose of the electronic device. In some embodiments, for each filtered pose to be interpolated, the filtered pose is weighted using the interpolation coefficients corresponding to the filtered pose to obtain a weighted result; the sum of the weighted results corresponding to each filtered pose to be interpolated is used as the target pose after linear interpolation.
[0136] In some embodiments, based on a nonlinear function, each interpolation coefficient is processed, and the processed difference coefficients are used to weight the filtered attitude to be interpolated. The sum of the weighted results corresponding to each filtered attitude to be interpolated is taken as the target attitude after nonlinear interpolation. Wherein, if the filtered attitude includes displacement, the nonlinear function can be a quadratic function fitted after multiple trials; if the filtered attitude includes Euler angles, the nonlinear function can be a function including sine and / or cosine components fitted after multiple trials, etc.
[0137] Taking jitter as an example, the pose to be interpolated includes the pose after low-pass filtering and the pose after stabilization. If the target pose is the sum of the weighted result of the low-pass filtered pose and the weighted result of the stabilized pose, the longer the duration of the jitter state, the lower the confidence of the current pose and the higher the confidence of the historical pose. This can increase the weight of the stabilized pose and decrease the weight of the low-pass filtered pose, thereby improving the matching degree between the target pose and the duration of the jitter state.
[0138] Taking movement as an example, the pose to be interpolated includes the pose after median filtering and the pose after Kalman filtering. If the target pose is the sum of the weighted result of the pose to be interpolated and the weighted result of the pose after Kalman filtering, the longer the duration of the movement, the higher the confidence of the current pose and the lower the confidence of the historical pose. This can increase the weight of the pose after Kalman filtering and decrease the weight of the pose after median filtering, thereby improving the matching degree between the target pose and the duration of the movement.
[0139] It is understandable that the impact of the current pose and historical poses on the target pose differs depending on the duration of the motion state. To address this, embodiments of this disclosure dynamically determine the interpolation coefficients corresponding to the filter pose to be interpolated based on the duration of the motion state and the filter pose to be interpolated. Interpolation is then performed based on the filter pose to be interpolated and its corresponding interpolation coefficients to obtain the target pose of the electronic device. Compared to methods using fixed interpolation coefficients, embodiments of this disclosure can improve the accuracy of dynamically allocating the interpolation coefficients of the filter pose to be interpolated based on the duration of the motion state and the degree of matching with the motion scene, thereby helping to improve the accuracy of determining the target pose.
[0140] In some embodiments, the filtering pose to be interpolated includes two filtering poses, the filtering poses are represented by quaternions, and the interpolation process includes spherical linear interpolation of quaternions;
[0141] The step of determining the interpolation coefficients corresponding to the filter posture to be interpolated based on the duration of the motion state and the filter posture to be interpolated includes:
[0142] Based on the duration of the motion state, determine the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion;
[0143] Determine the cosine angle between the two filter poses to be interpolated;
[0144] Based on the cosine angle and the weights corresponding to the two filtering postures, the interpolation coefficients corresponding to each filtering posture to be interpolated are determined.
[0145] In this embodiment of the disclosure, the filtering pose to be interpolated includes two filtering poses, which are represented by quaternions. The interpolation process includes spherical linear interpolation of quaternions; wherein, the spherical linear interpolation equation of quaternions can be expressed by the following formula (1):
[0146]
[0147] Where SLERP represents spherical linear interpolation, q represents the interpolated target attitude, q1 and q2 represent two quaternions to be interpolated, θ represents the cosine angle between the two quaternions to be interpolated, and ratio represents the weights corresponding to the filtered attitude in the spherical linear interpolation of the quaternions. If the motion state of the electronic device is jitter, q1 can represent the stabilized filtered attitude, and q2 can represent the low-pass filtered attitude; if the running state of the electronic device is movement, q1 can represent the Kalman filtered attitude, and q2 can represent the low-pass filtered attitude.
[0148] The electronic device in this embodiment determines the weights corresponding to the filtered postures of two objects to be interpolated in the spherical linear interpolation of quaternions based on the duration of the motion state. For example, if the motion state is jitter, and the two filtered postures to be interpolated are the low-pass filtered posture and the stabilized posture, the weights of the low-pass filtered posture and the stabilized posture corresponding to the duration of the jitter state are determined based on a preset weight mapping relationship corresponding to the jitter state. The preset weight mapping relationship corresponding to the jitter state includes the mapping between the duration, the weight of the low-pass filtered posture, and the weight of the stabilized posture.
[0149] For example, if the motion state is "movement", and the two filtered postures to be interpolated are the posture after low-pass filtering and the posture after Kalman filtering, the weights of the low-pass filtered posture and the Kalman filtered posture corresponding to the duration of the motion state are determined based on the preset weight mapping relationship corresponding to the motion state. The preset weight mapping relationship corresponding to the motion state includes the mapping between the duration, the weights of the low-pass filtered posture, and the weights of the Kalman filtered posture.
[0150] Furthermore, the electronic device of this disclosure also determines the cosine angle between two filtering postures to be interpolated; wherein the cosine angle θ can be determined by the following formula (2):
[0151] θ=cos -1 (q1.q2); (2)
[0152] After determining the weights corresponding to the filter postures of the two interpolated values and the cosine angle between them in the spherical linear interpolation of quaternions, the electronic device determines the interpolation coefficients corresponding to the filter postures of each interpolated value based on the cosine angle and the weights corresponding to the two filter postures, as shown in the aforementioned formula (1). The difference coefficient corresponding to q1, The difference coefficient is q2. Alternatively, based on the preset difference coefficient formula, the weights corresponding to the cosine angle and the two filter postures are processed to obtain the interpolation coefficients corresponding to each filter posture to be interpolated; wherein, the preset difference coefficient formula can be obtained by fitting multiple experiments under different durations of motion states, and this disclosure does not limit it.
[0153] It is understood that the embodiments of this disclosure utilize a spherical linear interpolation algorithm for quaternions to perform interpolation processing based on two filtered postures to be interpolated, which can improve the rationality and accuracy of interpolation using filtered postures represented by quaternions. In addition, the embodiments of this disclosure dynamically determine the weights corresponding to the two filtered postures to be interpolated in the spherical linear interpolation of quaternions based on the duration of the motion state, which can improve the matching degree between the weights and the motion scene of the electronic device, and further improve the accuracy of determining the interpolation coefficients corresponding to the filtered postures to be interpolated based on the weights and cosine angles.
[0154] In some embodiments, the filtering of the current pose and the historical pose in different ways to obtain different filtered poses includes:
[0155] The current pose and the historical pose are weighted respectively, and the first filtered pose is obtained based on the weighted poses;
[0156] Perform Kalman filtering on the current pose and the historical pose to obtain a second filtered pose;
[0157] The current pose is weighted, and a third filtered pose is obtained based on the weighted current pose and the historical pose.
[0158] In this embodiment of the disclosure, the electronic device performs weighted processing on the current pose and the historical pose respectively, and obtains a first filtered pose based on each weighted pose, such as the pose after low-pass filtering as described above. For example, the first filtered pose candQtLPF can be represented by the following formula (3):
[0159] candQtLPF=(1-weight LPF )*Q′ -1 +weight LPF *Q0; (3)
[0160] Where Q0 represents the current attitude, Q′ -1 Indicating a historical stance, weight LPF This represents the weight of the current pose in the first filtered pose, (1-weight) LPF ) represents the weight of the historical pose in the first filtered pose.
[0161] The electronic device in this embodiment performs weighted processing on the current attitude, and obtains a third filtered attitude based on the weighted current attitude and the historical attitude, as described above for stabilization. For example, the third filtered attitude, candQtSuperStable, can be represented by the following formula (4):
[0162] candQtSuperStable=Q′ -1 +weight ss *Q0; (4)
[0163] Where, weight SS This represents the weight of the current attitude in the third filtered attitude.
[0164] This embodiment of the disclosure performs Kalman filtering on the current attitude and the historical attitude to obtain a second filtered attitude, as described above for the Kalman-filtered attitude. The second filtered attitude is obtained based on the following formulas (5) to (8):
[0165]
[0166] in, This represents the prior estimated attitude, where F is the preset state transition matrix. Represents the historical attitude, B is the preset control matrix, and u t-1 This is the preset input control value.
[0167]
[0168] in, P represents the prior estimate of the covariance. b-1 G is the preset covariance matrix, and G is the preset process noise covariance matrix.
[0169]
[0170] Among them, K t Let H represent the Kalman gain, H be the preset measurement matrix, and R be the preset observation noise covariance matrix.
[0171]
[0172] in, This represents the posterior estimated pose, corresponding to the aforementioned second filtered pose; z t This represents the actual observed value, corresponding to the aforementioned current attitude.
[0173] In addition, the Kalman filter formula also includes the posterior estimate of the covariance, which can be expressed by the following formula (9):
[0174]
[0175] It should be noted that if the current attitude includes the current quaternion and the historical attitude includes the historical quaternion, the attitude in the above formula can be characterized by a 7-dimensional state variable (w, X, Y, Z, x, y, z) including quaternions, where (w, X, Y, Z) represents quaternions and (x, y, z) represents the three-axis components of the attitude sensor (such as a gyroscope).
[0176] Therefore, the second pose candQtKalman of this embodiment can be represented based on the following formula (10):
[0177]
[0178] in, Indicates taking The first four bits are used to obtain the second filtering attitude represented by quaternions.
[0179] It is understood that the embodiments of this disclosure perform weighted processing on the current pose and historical pose respectively, and obtain a first filtered pose based on each weighted pose. This can improve the flexibility of adjusting the first filtered pose as needed by adjusting the weights of the current pose and historical pose. Furthermore, the Kalman filter algorithm is a relatively mature prediction algorithm. The embodiments of this disclosure perform Kalman filtering on the current pose and historical pose, which can improve the accuracy of the second filtered pose. The embodiments of this disclosure perform weighted processing on the current pose, and obtain a third filtered pose based on the weighted current pose and historical pose. This can improve the convenience of adjusting the influence of the current pose on the third filtered pose by adjusting the weights of the current pose.
[0180] In some embodiments, the step of weighting the current pose and the historical pose, and obtaining the first filtered pose based on the weighted poses, includes:
[0181] The sum of the result of weighting the current pose with the first preset weight and the result of weighting the historical pose with the second preset weight is determined as the first filtered pose; wherein, the first preset weight is positively correlated with the difference between the current pose and the historical pose; the sum of the first preset weight and the second preset weight is the second preset value.
[0182] In this embodiment of the disclosure, the first preset weight corresponds to the aforementioned weight. LPF Taking a second preset value of 1 as an example, the sum of the first preset weight and the second preset weight is 1, that is, the second preset weight is 1 - weight. LPF .
[0183] Since the first preset weight represents the degree of influence of the current pose on the first filtered pose, and if the difference between the current pose and the historical pose is Diff(Q′) -1 A larger Q0 indicates a higher probability of being in a moving state, thus the reliability of the current attitude is higher, while the reliability of historical attitudes is lower. Therefore, in this embodiment, the first preset weight is positively correlated with the difference between the current attitude and historical attitudes, and the second preset weight is negatively correlated with the difference between the current attitude and historical attitudes. This scheme improves the accuracy of determining the first filtered attitude as the sum of the result of weighting the current attitude with the first preset weight and the result of weighting the historical attitude with the second preset weight.
[0184] In some embodiments, the weighting of the current pose and the determination of the third filtered pose based on the weighted current pose and the historical poses include:
[0185] The sum of the result of weighting the current pose with the third preset weight and the historical pose is determined as the third filtered pose; wherein the third preset weight is less than the preset weight threshold.
[0186] In this embodiment of the disclosure, the third preset weight corresponds to the aforementioned weight. SS In this embodiment, the sum of the result of weighting the current attitude with a third preset weight and the historical attitude is determined as the third filtered attitude. The third preset weight is less than a preset weight threshold; for example, the third preset weight is 0.00001. This scheme results in a third filtered attitude that is closer to the historical attitude, improving the accuracy of determining the target attitude based on the interpolated attitude, including the third filtered attitude, even under conditions of jitter.
[0187] In some embodiments, the motion state includes jitter, movement, and stillness; the step of selecting the filtering posture to be interpolated from the different filtering postures based on the motion state of the electronic device includes:
[0188] When the motion state includes jitter, the third filtering posture and the first filtering posture are determined as the filtering posture to be interpolated;
[0189] When the motion state includes moving or stationary, the first filtering posture and the second filtering posture are determined as the filtering posture to be interpolated.
[0190] In this embodiment, the motion state includes jitter, movement, and stillness. When the motion state of the electronic device is determined to be jitter based on the current attitude and historical attitudes, the third filter attitude and the first filter attitude are determined as the filter attitudes to be interpolated. Since the difference between the current attitude and the historical attitude is small in the jitter state, the historical attitude has high reliability. As can be seen from the positive correlation between the aforementioned first preset weight and the difference between the current attitude and the historical attitude, the historical attitude has a significant impact on the first filter attitude. Furthermore, since the third filter attitude is closer to the historical attitude, this embodiment, when the motion state includes jitter, determines the third filter attitude and the first filter attitude as the filter attitudes to be interpolated, which can improve the accuracy of determining the target attitude in the jitter state based on the filter attitudes to be interpolated.
[0191] When the motion state of the electronic device is determined to be moving or stationary based on the current attitude and historical attitudes, the first and second filtered attitudes are determined as the filtered attitudes to be interpolated. Since the current attitude differs significantly from the historical attitude in a moving state, the current attitude has high reliability; and since the third filtered attitude is closer to the historical attitude, this embodiment of the present disclosure, when the motion state includes moving, determines the second and first filtered attitudes as the filtered attitudes to be interpolated, which can improve the accuracy of determining the target attitude in a jittery state based on the filtered attitudes to be interpolated. Furthermore, since the current attitude has very high reliability in a stationary state, this embodiment of the present disclosure, when the motion state includes stationary, determines the second and first filtered attitudes as the filtered attitudes to be interpolated, which can also improve the accuracy of determining the target attitude in a stationary state based on the filtered attitudes to be interpolated.
[0192] In some embodiments, the method further includes:
[0193] Obtain the duration threshold;
[0194] The step of determining the weights corresponding to the two filter poses to be interpolated in the spherical linear interpolation of the quaternion based on the duration of the motion state includes:
[0195] In response to the duration of the motion state being greater than a duration threshold, the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion are determined; wherein, the weight of the preset initial filter posture in the two filter postures to be interpolated is positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filter postures to be interpolated is a first preset value.
[0196] In response to the duration of the motion state being less than or equal to the duration threshold, the weight of the preset initial filtering posture is determined to be the first preset value, and the weight of the filtering posture to be interpolated other than the preset initial filtering posture is 0.
[0197] In this embodiment of the disclosure, the electronic device obtains the duration threshold by obtaining a preset duration threshold stored in memory, or by obtaining the duration threshold corresponding to the motion state based on the preset correspondence between motion states and duration thresholds.
[0198] The preset initial filtering attitude in this embodiment is any of the aforementioned filtering attitudes. For example, the preset initial filtering attitude is the first filtering attitude.
[0199] In this embodiment of the disclosure, in response to a motion state duration exceeding a duration threshold, the weights corresponding to the two filter postures to be interpolated in the quaternion spherical linear interpolation are determined. Specifically, the weight of a preset initial filter posture is positively correlated with the motion state duration, and the sum of the weights corresponding to the two filter postures is a first preset value; that is, the weight of the other filter posture is negatively correlated with the motion state duration. For example, the first preset value is 1.
[0200] Figure 2 An example diagram illustrating the weights corresponding to the filtering poses of two objects to be interpolated in the spherical linear interpolation of quaternions, as shown in this embodiment of the disclosure. Combined with... Figure 2 Taking the preset initial filtering posture as the first filtering posture as an example, if the motion state is jitter, the two filtering postures to be interpolated include the first filtering posture and the third filtering posture. If the jitter duration is less than or equal to the duration threshold, the weight of the first filtering posture remains at the initial filtering posture and does not move. At this time, the weight of the corresponding first filtering posture is the first preset value, and the weight of the third filtering posture is 0. If the jitter duration is greater than the duration threshold, the weight of the first filtering posture moves from the initial filtering posture to the third filtering posture (moving in the direction of decreasing weight). The distance moved is positively correlated with the duration of the jitter. As the duration of the jitter increases, the weight of the corresponding first filtering posture decreases, and the weight of the third filtering posture increases.
[0201] It should be noted that during the process of the weight of the first filtering posture moving from the initial filtering posture to the third filtering posture, if the motion state of the electronic device changes to moving, the weight of the first filtering posture moves in the opposite direction (moving in the direction of increasing weight). As the duration of the moving state increases, the weight of the corresponding first filtering posture increases, and the weight of the third filtering posture decreases.
[0202] Taking the preset initial filtering posture as the first filtering posture as an example, if the motion state is movement, the two filtering postures to be interpolated include the first filtering posture and the second filtering posture. If the movement duration is less than or equal to the duration threshold, the weight of the first filtering posture remains at the initial filtering posture and does not move. At this time, the weight of the first filtering posture is the first preset value, and the weight of the second filtering posture is 0. If the movement duration is greater than the duration threshold, the weight of the first filtering posture moves from the initial filtering posture to the second filtering posture (moving in the direction of decreasing weight). The distance moved is positively correlated with the duration of jitter. As the duration of the movement state increases, the weight of the corresponding first filtering posture decreases, and the weight of the second filtering posture increases.
[0203] It should be noted that during the process of the weight of the first filtering posture moving from the initial filtering posture to the second filtering posture, if the motion state of the electronic device changes to jitter, the weight of the first filtering posture will move in the opposite direction (moving in the direction of increasing weight). As the duration of the jitter state increases, the weight of the corresponding first filtering posture increases, and the weight of the second filtering posture decreases.
[0204] It is understandable that noise influences the current and / or historical postures, causing noise to affect the filtered posture to be interpolated. To address this, in this embodiment, when the duration of the motion state is less than or equal to a duration threshold, the weight of the preset initial filtered posture is determined to be a first preset value, and the weight of the filtered posture to be interpolated other than the preset initial filtered posture is 0, which can reduce the impact of noise on weight fluctuations. Furthermore, in this embodiment, when the duration of the motion state is greater than the duration threshold, i.e., the motion state is relatively stable, the weight of the preset initial filtered posture is determined to be positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filtered postures to be interpolated is the first preset value, which can improve the stability and accuracy of determining the weights corresponding to the filtered postures to be interpolated.
[0205] In some embodiments, the method further includes:
[0206] Obtain the focal length of the image captured by the electronic device;
[0207] The acquisition duration threshold includes:
[0208] When the focal length belongs to a preset focal length, the duration threshold corresponding to the focal length is determined according to a preset mapping relationship; wherein, the preset mapping relationship includes the mapping between the focal length and the duration threshold;
[0209] or,
[0210] If the focal length does not belong to the preset focal length, the duration threshold corresponding to the focal length is determined according to the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length; wherein, the first preset focal length and the second preset focal length both belong to the preset focal length.
[0211] In this embodiment of the disclosure, the focal length of the image acquired by the electronic device is obtained; wherein, the focal length can be characterized by magnification, such as 20X, 30X, or by equivalent focal length, such as 12mm, 120mm.
[0212] In this embodiment, when the focal length belongs to a preset focal length, the duration threshold corresponding to the focal length is determined based on the mapping relationship between the preset focal length and the duration threshold. This scheme improves the convenience of determining the duration threshold corresponding to commonly used focal lengths.
[0213] In embodiments of this disclosure, when the focal length does not belong to a preset focal length, the duration threshold corresponding to the focal length is determined based on the duration thresholds corresponding to a first preset focal length greater than the focal length and a second preset focal length less than the focal length. For example, if the preset focal lengths are 30X, 100X, and 120X, then the duration threshold corresponding to the focal length of 40X can be the average of the duration thresholds corresponding to 30X and 120X; or, based on different duration weights, the sum of the duration thresholds corresponding to 30X and 120X. This disclosure does not limit this approach.
[0214] It is understood that the present disclosure embodiments determine the duration threshold corresponding to the focal length when the electronic device acquires the image, which can improve the matching degree between the target pose determined by the duration threshold and the focal length when the image is acquired, thereby improving the image stabilization effect. In addition, the present disclosure embodiments support the determination of the duration threshold for any focal length, are easy to expand, and can dynamically adjust the duration threshold parameter according to different focal lengths and scenes, making up for the shortcomings of existing image stabilization algorithms under ultra-telephoto (such as 120X) conditions.
[0215] It should be noted that, based on the above method, other parameters corresponding to focal lengths, such as ISO and shutter speed, can also be determined in the embodiments of this disclosure. For example, when the focal length belongs to a preset focal length, the shutter speed corresponding to the focal length can be determined according to a preset mapping relationship; wherein, the preset mapping relationship includes the mapping between focal length and shutter speed;
[0216] Alternatively, if the focal length is not a preset focal length, the shutter speed corresponding to the focal length can be determined based on the shutter speeds corresponding to the first preset focal length (greater than the focal length) and the second preset focal length (less than the focal length).
[0217] In some embodiments, the first preset focal length and the second preset focal length are both preset focal lengths adjacent to the focal length; determining the duration threshold corresponding to the focal length based on the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length includes:
[0218] The ratio of the difference between the focal length and the second preset focal length to the difference between the first preset focal length and the second preset focal length is determined as the first focal length weight of the first preset focal length.
[0219] The ratio of the difference between the first preset focal length and the focal length to the difference between the first preset focal length and the second preset focal length is determined as the second focal length weight of the second preset focal length.
[0220] The sum of the result of weighting the first focal length weight on the preset duration threshold corresponding to the first preset focal length and the result of weighting the second focal length weight on the preset duration threshold corresponding to the second preset focal length is determined as the duration threshold corresponding to the focal length.
[0221] In this embodiment of the disclosure, the first preset focal length and the second preset focal length are both preset focal lengths adjacent to the focal length; for example, the preset focal lengths are 20X, 30X, 70X, and 100X, and the first preset focal length corresponding to the focal length of 40X is 30X, and the second preset focal length is 70X.
[0222] This embodiment of the disclosure determines the duration threshold parm corresponding to the focal length (e.g., 40X) when the electronic device acquires the image based on a first preset focal length and a second preset focal length. 40X It can be expressed by the following formula (11):
[0223]
[0224] Among them, parm 30X Parm represents the duration threshold corresponding to the first preset focal length. 70X The second preset focal length represents the time threshold, 40 represents the focal length when the electronic device acquires the image, 30 represents the first preset focal length, and 70 represents the second preset focal length. This scheme improves the convenience of determining the time threshold corresponding to non-preset focal lengths.
[0225] In some embodiments, the current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity; determining the motion state of the electronic device based on the current attitude and the historical attitude includes:
[0226] Determine whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold, respectively.
[0227] If both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jitter.
[0228] or,
[0229] If the current angular velocity or the historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity.
[0230] In this embodiment of the disclosure, the current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity. Since the angular velocity of the electronic device is smaller in a jittering state compared to a moving state, and larger in a jittering state compared to a stationary state, this embodiment of the disclosure determines whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold. If both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jittering. The first preset angular velocity threshold is a threshold for distinguishing between jittering and stationary states, and the second preset angular velocity threshold is a threshold for distinguishing between jittering and moving states.
[0231] If the current angular velocity or historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity. This scheme improves the convenience and immediacy of determining the jitter state, and clarifies the necessity of further determining the motion state of the electronic device when the current angular velocity or historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold.
[0232] In some embodiments, when the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, determining the motion state of the electronic device based on the current angular velocity and the historical angular velocity includes:
[0233] If the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, the motion state of the electronic device is determined to be jittering based on the current angular velocity and the historical angular velocity, in response to satisfying one of the following: the jitter frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold.
[0234] In response to the fact that both the current angular velocity and the historical angular velocity are less than the first preset angular velocity threshold, the motion state of the electronic device is determined to be stationary.
[0235] In response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity has not changed, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold, the motion state of the electronic device is determined to be moving.
[0236] In this embodiment, if both the current angular velocity and the historical angular velocity are less than a first preset angular velocity threshold, i.e., both the current angular velocity and the historical angular velocity are very small, it indicates that the electronic device is likely stable (e.g., the electronic device is mounted on a tripod or gimbal). Therefore, the motion state of the electronic device is determined to be stationary, or a character indicating stationarity, such as "1", is output. Since the motion state of the electronic device is stationary, the reliability of the current posture of the electronic device is very high. In this scenario, the stabilization performance based on the determined target posture is good.
[0237] The historical angular velocity in this embodiment may further include multiple angular velocities at different times. If the current angular velocity or historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, based on the current angular velocity and the historical angular velocity, in response to satisfying one of the following: the jitter frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold, the motion state of the electronic device is determined to be jitter, or a character representing jitter, such as "0", is output. The jitter frequency of the electronic device can be characterized by the number of angular velocities whose difference in angular velocity between adjacent times is greater than a preset angular velocity difference threshold; or it can be characterized by the number of angular velocities whose direction of angular velocity changes between adjacent times.
[0238] It is understood that when an electronic device is in a state of vibration, there is a higher probability that the vibration frequency is large, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is long. Therefore, in this embodiment of the present disclosure, if one of the following conditions is met: the vibration frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold, the accuracy of determining the motion state of the electronic device as vibration is high.
[0239] In response to one of the following conditions being met: the jitter frequency is less than or equal to a preset frequency threshold, the direction of the angular velocity has not changed, or the duration of the change in the direction of the angular velocity is less than or equal to a first preset duration threshold, the motion state of the electronic device is determined to be moving, or a character representing movement, such as "1", is output. Since both moving and stationary states have high reliability regarding the current posture, the character representing movement and the character representing stationary can be set to be the same, improving the simplification of subsequent logic for determining the target posture based on the motion state.
[0240] It is understandable that when an electronic device is in motion, there is a high probability that the shaking frequency is low, the direction of the angular velocity does not change, and the duration of the change in the direction of the angular velocity is short (such as a scenario where the hand hits a wall and continues to move while shooting with a handheld electronic device). Therefore, in response to satisfying one of the following: the shaking frequency is less than or equal to a preset frequency threshold, the direction of the angular velocity does not change, and the duration of the change in the direction of the angular velocity is less than or equal to a first preset duration threshold, the accuracy of determining the motion state of the electronic device as moving is high.
[0241] It should be noted that determining whether one of the above conditions is met based on the current angular velocity and historical angular velocities can be done by using a single state machine to check whether all the above conditions are met, or by using different state machines to check whether one condition is met separately. This disclosure does not limit this approach. By designing state machines for different scenarios, the shortcomings of common anti-shake algorithms in single scenarios are compensated for.
[0242] In some embodiments, the step of using the target pose to perform image stabilization processing on the image to obtain a stabilized image includes:
[0243] The coordinates of pixels in the image are transformed using the target pose to obtain a coordinate-transformed image;
[0244] The image after coordinate transformation is cropped to obtain the image after image stabilization.
[0245] In this embodiment, after determining the target pose, the electronic device transforms the coordinates of pixels in the image using the target pose to obtain a coordinate-transformed image. In some embodiments, the electronic device determines the pose difference between the target pose and the current pose based on the target pose and the current pose, and calculates the transformation matrix corresponding to the image to be processed based on the pose difference. The transformation matrix may include at least one of a rotation matrix and a translation matrix. Thus, the coordinates of each pixel in the image are transformed according to the transformation matrix corresponding to the image to be processed, and the transformed coordinates of each pixel are determined, thereby obtaining the target image.
[0246] In some embodiments, after determining the target pose, the electronic device generates a homography matrix using the target pose and the current pose, and then uses the homography matrix to transform the coordinates of the pixels in the image to obtain the image after coordinate transformation.
[0247] The electronic device in this embodiment of the present disclosure crops the image after coordinate transformation, such as by center cropping or random cropping, to obtain the image after image stabilization. Figure 3 These are example images comparing images before and after image stabilization processing, as shown in embodiments of this disclosure. Figure 3 In the image, L1 represents the image before image stabilization, and L2 represents the image after image stabilization. In the image marked by L2, the part marked by the dashed box M1 is the maximum field of view excluding the black border, and the part marked by the dashed box M2 is the image after image stabilization and center cropping.
[0248] Figure 4 This is a diagram of an image processing apparatus shown in an embodiment of the present disclosure, consisting of... Figure 4 It can be seen that this includes:
[0249] The first acquisition module 401 is used to acquire the current posture of the electronic device when it acquires the image, and the historical posture of the electronic device before acquiring the image.
[0250] The determining module 402 is used to determine the motion state of the electronic device based on the current posture and the historical posture;
[0251] Prediction module 403 is used to predict the target posture of the electronic device based on the current posture, the historical posture, and the motion state;
[0252] The image stabilization module 404 is used to perform image stabilization processing on the image using the target pose to obtain an image after image stabilization.
[0253] In some embodiments, the prediction module 403 is used to perform filtering processing on the current posture and the historical posture in different ways to obtain different filtered postures; select the filtered posture to be interpolated from the different filtered postures based on the motion state of the electronic device; and perform interpolation processing based on the filtered posture to be interpolated to obtain the target posture of the electronic device.
[0254] In some embodiments, the prediction module 403 is used to determine the interpolation coefficients corresponding to the filter posture to be interpolated based on the duration of the motion state and the filter posture to be interpolated; and to perform interpolation processing based on the filter posture to be interpolated and the interpolation coefficients corresponding to the filter posture to be interpolated to obtain the target posture of the electronic device.
[0255] In some embodiments, the filtering pose to be interpolated includes two filtering poses, the filtering poses are represented by quaternions, and the interpolation process includes spherical linear interpolation of quaternions;
[0256] The prediction module 403 is used to determine the weights corresponding to the filter postures of two objects to be interpolated in the spherical linear interpolation of the quaternion based on the duration of the motion state; determine the cosine angle between the filter postures of the two objects to be interpolated; and determine the interpolation coefficients corresponding to the filter postures of each object to be interpolated based on the cosine angle and the weights corresponding to the two filter postures.
[0257] In some embodiments, the apparatus further includes:
[0258] The second acquisition module 405 is used to acquire the duration threshold;
[0259] The prediction module 403 is configured to, in response to the duration of the motion state being greater than a duration threshold, determine the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion; wherein, the weight of the preset initial filter posture among the two filter postures to be interpolated is positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filter postures to be interpolated is a first preset value; in response to the duration of the motion state being less than or equal to the duration threshold, determine the weight of the preset initial filter posture as the first preset value, and the weight of the filter postures to be interpolated other than the preset initial filter posture is 0.
[0260] In some embodiments, the apparatus further includes:
[0261] The third acquisition module 406 is used to acquire the focal length when the electronic device acquires the image;
[0262] The second acquisition module 405 is configured to, when the focal length belongs to a preset focal length, determine the duration threshold corresponding to the focal length according to a preset mapping relationship; wherein the preset mapping relationship includes a mapping between the focal length and the duration threshold; or, when the focal length does not belong to the preset focal length, determine the duration threshold corresponding to the focal length according to the duration thresholds corresponding to a first preset focal length greater than the focal length and a second preset focal length less than the focal length; wherein both the first preset focal length and the second preset focal length belong to the preset focal length.
[0263] In some embodiments, the second acquisition module 405 is configured to determine the first focal length weight of the first preset focal length as the ratio of the difference between the focal length and the second preset focal length to the difference between the first preset focal length and the second preset focal length; determine the second focal length weight of the second preset focal length as the ratio of the difference between the first preset focal length and the focal length to the difference between the first preset focal length and the second preset focal length; and determine the duration threshold corresponding to the focal length as the sum of the result of weighting the first focal length weight on the preset duration threshold corresponding to the first preset focal length and the result of weighting the second focal length weight on the preset duration threshold corresponding to the second preset focal length.
[0264] In some embodiments, the prediction module 403 is configured to perform weighted processing on the current pose and the historical pose respectively, and obtain a first filtered pose based on each weighted pose; perform Kalman filtering on the current pose and the historical pose to obtain a second filtered pose; perform weighted processing on the current pose, and obtain a third filtered pose based on the weighted current pose and the historical pose.
[0265] In some embodiments, the prediction module 403 is used to determine the first filtered posture as the sum of the result of weighting the current posture with a first preset weight and the result of weighting the historical posture with a second preset weight; wherein the first preset weight is positively correlated with the difference between the current posture and the historical posture; and the sum of the first preset weight and the second preset weight is a second preset value.
[0266] In some embodiments, the prediction module 403 is used to determine the third filtered posture as the sum of the result of weighting the current posture with the third preset weight and the historical posture; wherein the third preset weight is less than a preset weight threshold.
[0267] In some embodiments, the motion state includes jitter, movement, and stillness; the prediction module 403 is configured to determine the third filtering posture and the first filtering posture as the filtering posture to be interpolated when the motion state includes jitter; and to determine the first filtering posture and the second filtering posture as the filtering posture to be interpolated when the motion state includes movement or stillness.
[0268] In some embodiments, the current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity; the determining module 402 is configured to determine whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold; if both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jitter; or, if either the current angular velocity or the historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity.
[0269] In some embodiments, the determining module 402 is configured to, when the current angular velocity or the historical angular velocity is greater than or equal to the first preset angular velocity threshold, or less than or equal to the second preset angular velocity threshold, determine the motion state of the electronic device as jittering based on the current angular velocity and the historical angular velocity, in response to satisfying one of the following: the jitter frequency of the electronic device is greater than a preset frequency threshold, the direction of the angular velocity changes, or the duration of the change in the direction of the angular velocity is greater than a first preset duration threshold; determine the motion state of the electronic device as stationary in response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity does not change, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold; and determine the motion state of the electronic device as moving in response to satisfying one of the following: the jitter frequency is less than or equal to the preset frequency threshold, the direction of the angular velocity does not change, or the duration of the change in the direction of the angular velocity is less than or equal to the first preset duration threshold.
[0270] In some embodiments, the image stabilization module 404 is used to transform the coordinates of pixels in the image using the target pose to obtain a coordinate-transformed image; and to crop the coordinate-transformed image to obtain the image after image stabilization.
[0271] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0272] Figure 5This is a block diagram illustrating an electronic device according to an embodiment of this disclosure. For example, the electronic device 800 may be a mobile phone, a mobile computer, etc.
[0273] Reference Figure 5 The electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0274] Processing component 802 typically controls the overall operation of electronic device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0275] Memory 804 is configured to store various types of data to support the operation of electronic device 800. Examples of this data include instructions for any application or method operating on electronic device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0276] Power supply component 806 provides power to various components of electronic device 800. Power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800.
[0277] Multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0278] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when electronic device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0279] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0280] Sensor assembly 814 includes one or more sensors, such as the aforementioned attitude sensors, for providing state assessments of various aspects of electronic device 800. For example, sensor assembly 814 can detect the on / off state of electronic device 800, the relative positioning of components, such as the display and keypad of electronic device 800, changes in position of electronic device 800 or a component of electronic device 800, the presence or absence of user contact with electronic device 800, orientation or acceleration / deceleration of electronic device 800, and temperature changes of electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0281] Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices. Electronic device 800 can access wireless networks based on communication standards, such as Wi-Fi, 4G, or 5G, or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0282] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0283] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of an electronic device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0284] A non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the aforementioned image processing method.
[0285] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the foregoing claims.
[0286] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that, The method includes: The current pose of the electronic device when it acquires the image, and the historical pose of the electronic device before acquiring the image; The motion state of the electronic device is determined based on the current posture and the historical posture. Different filtering processes are applied to the current pose and the historical pose to obtain different filtered poses; wherein, any filtering process applies to both the current pose and the historical pose, and each filtering process corresponds to a filtered pose after the filtering process. Based on the motion state of the electronic device, a filtering posture to be interpolated is selected from the different filtering postures; wherein, the filtering posture to be interpolated includes two; Interpolation processing is performed based on the filtered attitude to be interpolated to obtain the target attitude of the electronic device; The image is stabilized using the target pose to obtain a stabilized image.
2. The method according to claim 1, characterized in that, The interpolation process based on the filtered attitude to be interpolated to obtain the target attitude of the electronic device includes: Based on the duration of the motion state and the filtering posture to be interpolated, the interpolation coefficients corresponding to the filtering posture to be interpolated are determined. Interpolation is performed based on the filtered attitude to be interpolated and the interpolation coefficients corresponding to the filtered attitude to be interpolated, to obtain the target attitude of the electronic device.
3. The method according to claim 2, characterized in that, The filtering posture to be interpolated includes two filtering postures, which are represented by quaternions, and the interpolation process includes spherical linear interpolation of quaternions. The step of determining the interpolation coefficients corresponding to the filter posture to be interpolated based on the duration of the motion state and the filter posture to be interpolated includes: Based on the duration of the motion state, determine the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion; Determine the cosine angle between the two filter poses to be interpolated; Based on the cosine angle and the weights corresponding to the two filtering postures, the interpolation coefficients corresponding to each filtering posture to be interpolated are determined.
4. The method according to claim 3, characterized in that, The method further includes: Obtain the duration threshold; The step of determining the weights corresponding to the two filter poses to be interpolated in the spherical linear interpolation of the quaternion based on the duration of the motion state includes: In response to the duration of the motion state being greater than a duration threshold, the weights corresponding to the two filter postures to be interpolated in the spherical linear interpolation of the quaternion are determined; wherein, the weight of the preset initial filter posture in the two filter postures to be interpolated is positively correlated with the duration of the motion state, and the sum of the weights corresponding to the two filter postures to be interpolated is a first preset value. In response to the duration of the motion state being less than or equal to the duration threshold, the weight of the preset initial filtering posture is determined to be the first preset value, and the weight of the filtering posture to be interpolated other than the preset initial filtering posture is 0.
5. The method according to claim 4, characterized in that, The method further includes: Obtain the focal length of the image captured by the electronic device; The acquisition duration threshold includes: When the focal length belongs to a preset focal length, the duration threshold corresponding to the focal length is determined according to a preset mapping relationship; wherein, the preset mapping relationship includes the mapping between the focal length and the duration threshold; or, If the focal length does not belong to the preset focal length, the duration threshold corresponding to the focal length is determined according to the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length; wherein, the first preset focal length and the second preset focal length both belong to the preset focal length.
6. The method according to claim 5, characterized in that, Both the first preset focal length and the second preset focal length are preset focal lengths adjacent to the focal length; determining the duration threshold corresponding to the focal length based on the duration thresholds corresponding to the first preset focal length which is greater than the focal length and the second preset focal length which is less than the focal length includes: The ratio of the difference between the focal length and the second preset focal length to the difference between the first preset focal length and the second preset focal length is determined as the first focal length weight of the first preset focal length. The ratio of the difference between the first preset focal length and the focal length to the difference between the first preset focal length and the second preset focal length is determined as the second focal length weight of the second preset focal length. The sum of the result of weighting the first focal length weight on the preset duration threshold corresponding to the first preset focal length and the result of weighting the second focal length weight on the preset duration threshold corresponding to the second preset focal length is determined as the duration threshold corresponding to the focal length.
7. The method according to claim 1, characterized in that, The process of applying different filtering methods to the current pose and the historical pose to obtain different filtered poses includes: The current pose and the historical pose are weighted respectively, and the first filtered pose is obtained based on the weighted poses; Perform Kalman filtering on the current pose and the historical pose to obtain a second filtered pose; The current pose is weighted, and a third filtered pose is obtained based on the weighted current pose and the historical pose.
8. The method according to claim 7, characterized in that, The step of weighting the current pose and the historical pose, and obtaining the first filtered pose based on the weighted poses, includes: The sum of the result of weighting the current pose with the first preset weight and the result of weighting the historical pose with the second preset weight is determined as the first filtered pose; wherein, the first preset weight is positively correlated with the difference between the current pose and the historical pose; the sum of the first preset weight and the second preset weight is the second preset value.
9. The method according to claim 7, characterized in that, The step of weighting the current pose and obtaining the third filtered pose based on the weighted current pose and the historical pose includes: The sum of the result of weighting the current pose with the third preset weight and the historical pose is determined as the third filtered pose; wherein the third preset weight is less than the preset weight threshold.
10. The method according to claim 7, characterized in that, The motion states include jitter, movement, and stillness; the process of selecting the filtering posture to be interpolated from the different filtering postures based on the motion state of the electronic device includes: When the motion state is jittering, the third filtering posture and the first filtering posture are determined as the filtering posture to be interpolated; When the motion state is either moving or stationary, the first filtering posture and the second filtering posture are determined as the filtering posture to be interpolated.
11. The method according to claim 1, characterized in that, The current attitude includes the current angular velocity, and the historical attitude includes the historical angular velocity; determining the motion state of the electronic device based on the current attitude and the historical attitude includes: Determine whether the current angular velocity and the historical angular velocity are between a first preset angular velocity threshold and a second preset angular velocity threshold, respectively. If both the current angular velocity and the historical angular velocity are between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined to be jitter. or, If the current angular velocity or the historical angular velocity is not between the first preset angular velocity threshold and the second preset angular velocity threshold, the motion state of the electronic device is determined based on the current angular velocity and the historical angular velocity.
12. The method according to claim 1, characterized in that, The step of using the target pose to perform image stabilization processing on the image to obtain a stabilized image includes: The coordinates of pixels in the image are transformed using the target pose to obtain a coordinate-transformed image; The image after coordinate transformation is cropped to obtain the image after image stabilization.
13. An image processing apparatus, characterized in that, The device includes: The first acquisition module is used to acquire the current posture of the electronic device when it is acquiring the image, and the historical posture of the electronic device before acquiring the image; The determination module is used to determine the motion state of the electronic device based on the current posture and the historical posture; The prediction module is used to perform filtering processing on the current pose and the historical pose in different ways to obtain different filtered poses; wherein, any filtering processing method is applied to the current pose and the historical pose, and each filtering processing method corresponds to a filtered pose after filtering processing; based on the motion state of the electronic device, a filter pose to be interpolated is selected from the different filtered poses; wherein, the filter pose to be interpolated includes two; interpolation processing is performed based on the filter pose to be interpolated to obtain the target pose of the electronic device; The image stabilization module is used to perform image stabilization processing on the image based on the target pose, so as to obtain an image after image stabilization.
14. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to perform the method as described in any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1 to 12.
Citation Information
Patent Citations
Multi-layer filtering based method and device for determining camera attitude matrix and equipment
CN107516327A
Image shooting anti-shake method, device, terminal and readable storage medium
CN113395454A
