A video image motion smoothing processing method, device, equipment and storage medium
Through spherical linear interpolation and mean filtering processing technology, a smooth quaternion queue is established, which solves the problem of video image jitter in complex motion scenes and improves the smoothing effect and real-time performance of video images.
Patent Information
- Application Number
- CN202011541615.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-23
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-12-23
AI Technical Summary
The existing technology is difficult to effectively eliminate the jitter of video images in complex motion scenes, resulting in poor smoothing effects and low real-time performance of video images.
By obtaining the camera posture of the current video frame of the video stream, using quaternion representation and performing spherical linear interpolation processing and mean filtering processing, a smooth quaternion queue is established, and the output of the queue head is performed to achieve smooth processing of the video image.
It improves the smoothing effect of video images and the real-time performance of video image anti-shake in complex motion scenes, ensuring the stability and clarity of video images during motion.
Smart Images

Figure CN112734653B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of video image processing, and in particular relates to a method, device, equipment and storage medium for motion smoothing processing of video images. Background Art
[0002] With the development of science and technology and the progress of society, mobile devices have become an indispensable part of people's lives. People can use mobile devices to shoot videos and record every bit of life to share with friends. Therefore, video shooting has gradually become a way for many users to share socially and communicate. Although the camera configuration in mobile devices is getting higher and higher, the video images shot by mobile devices in a static state are clear and high-quality. However, when users hold mobile devices to shoot videos while walking or running or in various other complex sports scenes (for example, when placed in a car while driving), the mobile devices will become unstable. At this time, the recorded video data often has jitter, which easily causes the video image to be blurred, making the quality of the shot video unsatisfactory.
[0003] In the invention patent application document with patent publication number US10027893B2, a method for real-time video stabilization of a mobile device based on vehicle-mounted motion sensing is disclosed. Although this solution can adjust the current angular velocity in time according to future motion conditions to avoid sudden out-of-bounds and uneven angular velocity changes, it is difficult for this solution to balance motion tracking and image jitter elimination under complex and intense motion conditions. Summary of the invention
[0004] The purpose of the present invention is to provide a method, device, equipment and storage medium for motion smoothing of video images, aiming to solve the problem that the existing technology has low real-time performance and poor smoothing effect in video image jitter elimination in complex motion scenes.
[0005] In one aspect, the present invention provides a method for processing motion smoothing of a video image, the method comprising the following steps:
[0006] Obtaining a current camera posture corresponding to a current video frame of a video stream, and representing the current camera posture by a quaternion to obtain a current original quaternion corresponding to the current video frame;
[0007] Obtaining a smoothed quaternion of a previous video frame corresponding to the current video frame from a smoothed quaternion queue of cached frames, and smoothing the current original quaternion according to the smoothed quaternion of the previous video frame to obtain a current smoothed quaternion corresponding to the current video frame;
[0008] According to the current original quaternion and the current smoothed quaternion, the smoothed quaternion queue is subjected to smoothing filtering processing to obtain a processed smoothed quaternion queue;
[0009] When the queue length of the processed smooth quaternion queue exceeds the number of cached frames, a smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the processed smooth quaternion queue is output.
[0010] Preferably, the step of obtaining the smoothed quaternion of the previous video frame corresponding to the current video frame from the smoothed quaternion queue of the cached frames, and smoothing the current original quaternion according to the smoothed quaternion of the previous video frame comprises:
[0011] The smoothed quaternion of the previous video frame is used to perform spherical linear interpolation processing on the current original quaternion.
[0012] Further preferably, the step of performing spherical linear interpolation processing on the current original quaternion by using the smoothed quaternion of the previous video frame comprises:
[0013] Utilizing the smoothed quaternion of the previous video frame, spherical linear interpolation is performed on the current original quaternion through a preset smoothing formula v(k)=slerp(v(k-1),p(k),weight), wherein p(k) is the original quaternion of the kth frame, v(k) is the smoothed quaternion of the kth frame, v(k-1) is the smoothed quaternion of the k-1th frame, weight is the interpolation weight of p(k) during spherical linear interpolation, and k is an integer greater than 1.
[0014] Preferably, the step of performing smoothing filtering on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion to obtain a processed smoothed quaternion queue comprises:
[0015] According to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue, the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted to obtain an adjusted smoothed quaternion queue;
[0016] According to the current original quaternion and the current smoothed quaternion, the original quaternion queue and the adjusted smoothed quaternion queue are updated respectively to obtain an updated smoothed quaternion queue;
[0017] The updated smoothed quaternion queue is subjected to mean filtering processing to obtain a processed smoothed quaternion queue.
[0018] Further preferably, the step of following and adjusting the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue comprises:
[0019] According to the original quaternion corresponding to each video frame in the original quaternion queue, the preset following formula v(m)=slerp(v(m),p(m)) is used. smooth ,weight follow ) follows and adjusts the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue, wherein v(m) is the smoothed quaternion of the mth frame in the smoothed quaternion queue, and p(m) smooth Represents the original quaternion of the mth frame after the original quaternion queue is subjected to unconstrained iterative mean filtering, weight follow is the following weight, and m is an integer greater than 1.
[0020] Further preferably, the step of performing mean filtering on the updated smoothed quaternion queue comprises:
[0021] The updated smoothed quaternion queue is subjected to iterative mean filtering.
[0022] Preferably, after the step of smoothing the video image in the video stream by using the smoothed quaternion corresponding to the queue head in the smoothed quaternion queue, the method further comprises:
[0023] The original quaternion queue and the smoothed quaternion queue are updated.
[0024] In another aspect, the present invention provides a video image motion smoothing processing device, the device comprising:
[0025] A first parameter obtaining unit is used to obtain a current camera posture corresponding to a current video frame of a video stream, and to represent the current camera posture through a quaternion to obtain a current original quaternion corresponding to the current video frame;
[0026] A second parameter obtaining unit is used to obtain a smoothed quaternion of a previous video frame corresponding to the current video frame from a smoothed quaternion queue of cached frames, and to smooth the current original quaternion according to the smoothed quaternion of the previous video frame to obtain a current smoothed quaternion corresponding to the current video frame;
[0027] A queue smoothing filter unit, configured to perform smoothing filtering on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion, to obtain a processed smoothed quaternion queue; and
[0028] The smoothed image output unit is used to output the smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue when the queue length of the processed smoothed quaternion queue exceeds the number of cached frames.
[0029] Preferably, the second parameter obtaining unit includes:
[0030] The parameter acquisition subunit is used to perform spherical linear interpolation processing on the current original quaternion using the smoothed quaternion of the previous video frame.
[0031] Preferably, the queue smoothing filter unit comprises:
[0032] A queue following adjustment unit is used to follow and adjust the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue according to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue to obtain an adjusted smoothed quaternion queue;
[0033] A first queue updating unit is used to update the original quaternion queue and the adjusted smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion, respectively, to obtain an updated smoothed quaternion; and
[0034] The queue filtering processing unit is used to perform mean filtering on the updated smoothed quaternion queue to obtain a processed smoothed quaternion queue.
[0035] Further preferably, the queue following adjustment unit includes:
[0036] The following adjustment subunit is used to adjust the original quaternion corresponding to each video frame in the original quaternion queue by a preset following formula v(m)=slerp(v(m),p(m)) smooth ,weight follow ) follows and adjusts the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue, wherein v(m) is the smoothed quaternion of the mth frame in the smoothed quaternion queue, and p(m) smooth Represents the original quaternion of the mth frame after the original quaternion queue is subjected to unconstrained iterative mean filtering, weight follow is the following weight, and m is an integer greater than 1.
[0037] Further preferably, the queue filtering processing unit includes:
[0038] The filtering processing subunit is used to perform iterative mean filtering on the updated smoothed quaternion queue.
[0039] Preferably, the device further comprises:
[0040] The second queue updating unit is used to update the original quaternion queue and the smoothed quaternion queue.
[0041] On the other hand, the present invention also provides a video image processing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps described in the above-mentioned video image motion smoothing processing method are implemented.
[0042] On the other hand, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps described in the above-mentioned method for motion smoothing of video images are implemented.
[0043] The present invention performs smoothing processing on the current original quaternion corresponding to the current video frame of the acquired video stream to obtain the corresponding current smoothed quaternion, performs smoothing filtering processing on the smoothed quaternion queue of the cached frame according to the current original quaternion and the current smoothed quaternion, and when the queue length of the processed smoothed quaternion queue exceeds the number of cached frames, outputs the smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue, thereby improving the smoothing effect of the video image and the real-time performance of video image anti-shake in various complex motion scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flow chart of the implementation of the method for processing motion smoothing of video images provided in the first embodiment of the present invention;
[0045] Figure 2 is a flow chart of the implementation of the method for processing motion smoothing of video images provided in the second embodiment of the present invention;
[0046] Figure 3 is a schematic diagram of the structure of a motion smoothing processing device for a video image provided by Embodiment 3 of the present invention;
[0047] Figure 4 is a schematic diagram of a preferred structure of a motion smoothing processing device for a video image provided by Embodiment 3 of the present invention; and
[0048] Figure 5 It is a structural schematic diagram of a video image processing device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0050] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0051] Embodiment 1:
[0052] Figure 1 The implementation process of the video image motion smoothing processing method provided by the first embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0053] In step S101, the current camera posture corresponding to the current video frame of the video stream is obtained, and the current camera posture is represented by a quaternion to obtain a current original quaternion corresponding to the current video frame.
[0054] The embodiment of the present invention is applicable to video image processing devices such as video display and acquisition. In the embodiment of the present invention, when the video is recorded, the current camera posture corresponding to the current video frame of the video stream is obtained. The camera posture is a three-dimensional spatial information. The three-dimensional spatial information is represented by quaternion, and the current original quaternion corresponding to the current video frame is obtained.
[0055] In step S102, the smoothed quaternion of the previous video frame corresponding to the current video frame is obtained from the smoothed quaternion queue of the cached frame, and the current original quaternion is smoothed according to the smoothed quaternion of the previous video frame to obtain the current smoothed quaternion corresponding to the current video frame.
[0056] In an embodiment of the present invention, by setting a cache frame, the original quaternion and smoothed quaternion related to the video frame are cached in the form of a queue. After obtaining the current original quaternion corresponding to the current video frame, the smoothed quaternion of the previous video frame corresponding to the current video frame is obtained from the smoothed quaternion queue of the cache frame, and the current original quaternion is smoothed according to the smoothed quaternion of the previous video frame to obtain the current smoothed quaternion corresponding to the current video frame, wherein the previous video frame is a frame before the current video frame in two adjacent frames. When the current video frame is the first frame of the video stream, the current smoothed quaternion after smoothing is the current original quaternion, that is, v(1)=p(1), p(1) is the original quaternion of the first video frame, and v(1) is the smoothed quaternion of the first video frame.
[0057] When the current original quaternion is smoothed according to the smoothed quaternion of the previous video frame, preferably, the current original quaternion is processed by spherical linear interpolation using the smoothed quaternion of the previous video frame, thereby improving the smoothness of the transition between the previous and next frames of video images, making the presented video image more stable.
[0058] In step S103, smoothing filtering is performed on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion to obtain a processed smoothed quaternion queue.
[0059] In the embodiment of the present invention, the specific implementation process of performing smoothing filtering on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion is detailed in Embodiment 2.
[0060] In step S104, when the queue length of the processed smooth quaternion queue exceeds the number of cached frames, the smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the processed smooth quaternion queue is output.
[0061] In an embodiment of the present invention, the queue length of the smooth quaternion queue is detected in real time. When it is detected that the queue length of the processed smooth quaternion queue exceeds the preset number of cache frames, the smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the smooth quaternion queue is output.
[0062] Preferably, the number of cached frames can be set to 5, thereby meeting the requirement of hardware devices with a smaller number of cached frames.
[0063] After the smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the output processed smoothed quaternion queue is output, preferably, the original quaternion queue head is out of the queue, and the processed smoothed quaternion queue head is out of the queue, completing the update of the original quaternion queue and the smoothed quaternion queue, thereby improving the real-time performance of video image stabilization by setting the queue in the cache frame.
[0064] In an embodiment of the present invention, a current original quaternion corresponding to a current video frame of an acquired video stream is smoothed to obtain a corresponding current smoothed quaternion, and a smoothing filtering process is performed on a smoothed quaternion queue of a cached frame according to the current original quaternion and the current smoothed quaternion. When the queue length of the processed smoothed quaternion queue exceeds the number of cached frames, a smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue is output, thereby improving the smoothing effect of the video image and the real-time performance of video image anti-shake in various complex motion scenes.
[0065] Embodiment 2:
[0066] Figure 2 The implementation process of the video image motion smoothing processing method provided by the second embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0067] In step S201, the current camera posture corresponding to the current video frame of the video stream is obtained, and the current camera posture is represented by a quaternion to obtain the current original quaternion corresponding to the current video frame.
[0068] The embodiment of the present invention is applicable to video image processing devices such as video display and acquisition. In the embodiment of the present invention, when the video is recorded, the current camera posture corresponding to the current video frame of the video stream is obtained. The camera posture is a three-dimensional spatial information. The three-dimensional spatial information is represented by quaternion, and the current original quaternion corresponding to the current video frame is obtained.
[0069] In step S202, the smoothed quaternion of the previous video frame corresponding to the current video frame is obtained from the smoothed quaternion queue of the cached frame, and the current original quaternion is processed by spherical linear interpolation using the smoothed quaternion of the previous video frame to obtain the current smoothed quaternion corresponding to the current video frame.
[0070] In an embodiment of the present invention, by setting a cache frame, the original quaternion and smoothed quaternion related to the video frame are cached in the form of a queue. After obtaining the current original quaternion corresponding to the current video frame, the smoothed quaternion of the previous video frame corresponding to the current video frame is obtained from the smoothed quaternion queue of the cache frame, and the current original quaternion is subjected to spherical linear interpolation (Slerp) processing according to the smoothed quaternion of the previous video frame to obtain the current smoothed quaternion corresponding to the current video frame, wherein the previous video frame is a frame before the current video frame in two adjacent frames. When the current video frame is the first frame of the video stream, the current smoothed quaternion after smoothing is the current original quaternion, that is, v(1)=p(1), p(1) is the original quaternion of the first video frame, and v(1) is the smoothed quaternion of the first video frame.
[0071] When using the smoothed quaternion of the previous video frame to perform spherical linear interpolation processing on the current original quaternion, preferably, using the smoothed quaternion of the previous video frame, spherical linear interpolation processing is performed on the current original quaternion through a preset smoothing formula v(k)=slerp(v(k-1),p(k),weight), wherein p(k) is the original quaternion of the kth frame, v(k) is the smoothed quaternion of the kth frame, v(k-1) is the smoothed quaternion of the k-1th frame, weight is the interpolation weight of p(k) when performing spherical linear interpolation processing, and k is an integer greater than 1, thereby improving the smoothness of the transition between the previous and next frames of video images, making the presented video image more stable.
[0072] When the current original quaternion is subjected to spherical linear interpolation processing by the preset smoothing formula v(k)=slerp(v(k-1),p(k),weight), it is further preferred that the smoothed quaternion v(k-1) of the previous frame is used as the initial value to calculate the relative quaternion Δq between it and the original quaternion p(k), and then the metric value rate of the cropping polygon from the original screen boundary when the relative rotation amount of the current video frame is Δq is calculated, wherein the rate is 0 when the cropping polygon is within the inner frame, and the rate is 1 when it is outside the outer frame, and the closer the cropping polygon is to the outer frame when it is between the inner and outer frames, the greater the metric value, and then the metric value rate and the weight calculation formula are used. Calculate the weight weight, where min_weight represents the minimum weight, which is generally between 0.001 and 0.4; inner_rate represents the metric value corresponding to the inner border, which ranges from 0 to 1. The larger the inner_rate value, the higher the smoothness but the slower the following. When the value is too large, there will be a large jitter when it goes out of bounds. The smaller the value, the relatively lower the smoothness but the tighter the following. α is the sharpness of controlling the weight change, which is generally between 0.5 and 4. Finally, the smoothing formula v(k)=slerp(v(k-1),p(k),weight) is used to smooth the current original quaternion to obtain the current smoothed quaternion corresponding to the current video frame, thereby further improving the smoothness of the transition between the previous and next two frames of video images, making the presented video image more stable.
[0073] In step S203, according to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue, the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted to obtain an adjusted smoothed quaternion queue.
[0074] In an embodiment of the present invention, according to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue, the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted so that the smoothed quaternion approaches its corresponding original quaternion, thereby obtaining an adjusted smoothed quaternion queue.
[0075] When the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted, preferably, according to the original quaternion corresponding to each video frame in the original quaternion queue, a preset following formula v(m)=slerp(v(m),p(m) is used. smooth ,weight follow ) Follow and adjust the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue, where v(m) is the smoothed quaternion of the mth frame in the smoothed quaternion queue, and p(m) smooth Represents the original quaternion of the mth frame after the original quaternion queue is subjected to unconstrained iterative mean filtering, weightfollow To follow the weight, m is an integer greater than 1, thereby improving the smoothing effect of subsequent video images.
[0076] By following the preset formula v(m)=slerp(v(m),p(m) smooth ,weight follow ) When the smooth quaternion corresponding to each video frame in the smooth quaternion queue is followed and adjusted, it is further preferred that the relative quaternion Δq between the smooth quaternion of each video frame in the smooth quaternion queue and the corresponding original quaternion in the original quaternion queue is first calculated, and then the metric value of the clipping polygon from the original screen boundary is calculated for each video frame in the cache frame when the relative rotation amount is the corresponding Δq, and the metric value average rate_avr is calculated based on the metric values of all frames in the cache frame, and then the metric value average rate_avr is calculated based on rate_avr and the following weight formula Calculate the weight following the original quaternion follow , where min_weight follow represents the minimum following weight, which is generally between 0.002 and 0.4, and β controls the sharpness of weight change, which is generally between 0.5 and 4. Finally, the following formula v(m) = slerp(v(m), p(m) smooth ,weight follow )Adjust the cached frame smoothing quaternion queue to further improve the smoothing effect of subsequent video images.
[0077] In step S204, the original quaternion queue and the adjusted smoothed quaternion queue are updated respectively according to the current original quaternion and the current smoothed quaternion to obtain an updated smoothed quaternion queue.
[0078] In an embodiment of the present invention, the current original quaternion of the current video frame is added to the original quaternion queue, and the current smoothed quaternion is added to the adjusted smoothed quaternion queue, and the two queues are updated to obtain an updated smoothed quaternion queue.
[0079] In step S205, mean filtering is performed on the updated smoothed quaternion queue to obtain a processed smoothed quaternion queue.
[0080] In an embodiment of the present invention, mean filtering is performed on the updated smoothed quaternion queue to obtain a processed smoothed quaternion queue, thereby achieving noise reduction of the video image corresponding to each smoothed quaternion in the smoothed quaternion queue and smoothing of the camera posture.
[0081] When the updated smoothed quaternion queue is subjected to mean filtering, it is preferred that the updated smoothed quaternion queue is subjected to iterative mean filtering, and at the same time, after each iterative smoothing, it is determined whether the smoothed quaternion of each video frame in the queue will cause an out-of-bounds error, that is, it is determined whether the projection of the cropped area of each video frame in the original picture after smoothing exceeds the effective range of the picture. If an out-of-bounds error occurs, a binary search algorithm is used to find the quaternion that is closest to the smoothed quaternion and is guaranteed not to be out-of-bounds, and the quaternion is used as the smoothed result of the frame corresponding to the smoothed quaternion, thereby improving the smoothing and noise reduction effects on the video image corresponding to the smoothed quaternion.
[0082] In step S206, when the queue length of the processed smooth quaternion queue exceeds the number of cached frames, the smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the processed smooth quaternion queue is output.
[0083] In an embodiment of the present invention, the queue length of the smooth quaternion queue is detected in real time. When it is detected that the queue length of the processed smooth quaternion queue exceeds the preset number of cache frames, the smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the smooth quaternion queue is output.
[0084] Preferably, the number of cached frames is set to 5, so as to meet the requirements of hardware devices with a smaller number of cached frames.
[0085] After the smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the output processed smoothed quaternion queue is output, preferably, the original quaternion queue head is out of the queue, and the processed smoothed quaternion queue head is out of the queue, completing the update of the original quaternion queue and the smoothed quaternion queue, thereby improving the real-time performance of video image stabilization by setting the queue in the cache frame.
[0086] In an embodiment of the present invention, a current original quaternion corresponding to a current video frame of an acquired video stream is smoothed to obtain a corresponding current smoothed quaternion. According to the original quaternion corresponding to each video frame in the original quaternion queue of the cached frame, a smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted. According to the current original quaternion and the current smoothed quaternion, the original quaternion queue and the adjusted smoothed quaternion queue are updated respectively, and the updated smoothed quaternion queue is iteratively mean filtered. When the queue length of the processed smoothed quaternion queue exceeds the number of cached frames, a smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smooth quaternion queue is output, thereby improving the smoothing effect of the video image and the real-time performance of video image anti-shake in various complex motion scenes.
[0087] Embodiment three:
[0088] Figure 3 The structure of the video image motion smoothing processing device provided by the third embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, including:
[0089] The first parameter obtaining unit 31 is used to obtain the current camera posture corresponding to the current video frame of the video stream, and to express the current camera posture through a quaternion to obtain the current original quaternion corresponding to the current video frame.
[0090] The second parameter obtaining unit 32 is used to obtain the smoothed quaternion of the previous video frame corresponding to the current video frame from the smoothed quaternion queue of the cached frame, and smooth the current original quaternion according to the smoothed quaternion of the previous video frame to obtain the current smoothed quaternion corresponding to the current video frame.
[0091] The queue smoothing filter unit 33 is used to perform smoothing filtering processing on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion to obtain a processed smoothed quaternion queue.
[0092] The smoothed image output unit 34 is used to output the smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue when the queue length of the processed smoothed quaternion queue exceeds the number of cached frames.
[0093] Among them, Figure 4 As shown, preferably, the video image motion smoothing processing device of the embodiment of the invention further includes:
[0094] The second queue updating unit 35 is used to update the original quaternion queue and the smoothed quaternion queue.
[0095] The second parameter obtaining unit 32 includes:
[0096] The parameter obtaining subunit 321 is used to perform spherical linear interpolation processing on the current original quaternion using the smoothed quaternion of the previous video frame.
[0097] The queue smoothing filter unit 33 comprises:
[0098] The queue following adjustment unit 331 is used to follow and adjust the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue according to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue to obtain an adjusted smoothed quaternion queue;
[0099] A first queue updating unit 332 is used to update the original quaternion queue and the adjusted smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion, respectively, to obtain an updated smoothed quaternion; and
[0100] The queue filtering processing unit 333 is used to perform mean filtering on the updated smoothed quaternion queue to obtain a processed smoothed quaternion queue.
[0101] The queue following adjustment unit 331 includes:
[0102] The following adjustment subunit 3311 is used to adjust the original quaternion corresponding to each video frame in the original quaternion queue by a preset following formula v(m)=slerp(v(m),p(m) smooth ,weight follow ) Follow and adjust the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue, where v(m) is the smoothed quaternion of the mth frame in the smoothed quaternion queue, and p(m) smooth Represents the original quaternion of the mth frame after the original quaternion queue is subjected to unconstrained iterative mean filtering, weight follow is the following weight, and m is an integer greater than 1.
[0103] The queue filtering processing unit 333 includes:
[0104] The filtering processing subunit 3331 is used to perform iterative mean filtering on the updated smoothed quaternion queue.
[0105] In the embodiment of the present invention, each unit of the video image motion smoothing processing device can be implemented by a corresponding hardware or software unit, and each unit can be an independent software or hardware unit, or can be integrated into a software or hardware unit, which is not intended to limit the present invention. Specifically, the implementation of each unit can refer to the description of the aforementioned method embodiment, which will not be repeated here.
[0106] Embodiment 4:
[0107] Figure 5 The structure of a video image processing device provided by a fourth embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown.
[0108] The video image processing device 5 of the embodiment of the present invention includes a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer program 52, the steps in the above-mentioned video image motion smoothing processing method embodiment are implemented, such as Figure 1 Alternatively, when the processor 50 executes the computer program 52, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 3 The functions of the units 31 to 34 are shown.
[0109] In an embodiment of the present invention, a current original quaternion corresponding to a current video frame of an acquired video stream is smoothed to obtain a corresponding current smoothed quaternion, and a smoothing filtering process is performed on a smoothed quaternion queue of a cached frame according to the current original quaternion and the current smoothed quaternion. When the queue length of the processed smoothed quaternion queue exceeds the number of cached frames, a smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue is output, thereby improving the smoothing effect of the video image and the real-time performance of video image anti-shake in various complex motion scenes.
[0110] The video image processing device of the embodiment of the present invention can be a smart phone or tablet computer with a camera. The steps implemented when the processor 50 in the video image processing device 5 executes the computer program 52 to implement the video image motion smoothing processing method can refer to the description of the above method embodiment, which will not be repeated here.
[0111] Embodiment five:
[0112] In an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned video image motion smoothing processing method embodiment are implemented, for example, Figure 1 Alternatively, when the computer program is executed by a processor, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 3 The functions of the units 31 to 34 are shown.
[0113] In an embodiment of the present invention, a current original quaternion corresponding to a current video frame of an acquired video stream is smoothed to obtain a corresponding current smoothed quaternion, and a smoothing filtering process is performed on a smoothed quaternion queue of a cached frame according to the current original quaternion and the current smoothed quaternion. When the queue length of the processed smoothed quaternion queue exceeds the number of cached frames, a smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue is output, thereby improving the smoothing effect of the video image and the real-time performance of video image anti-shake in various complex motion scenes.
[0114] The computer-readable storage medium of the embodiment of the present invention may include any entity or device, recording medium that can carry computer program code, for example, ROM / RAM, magnetic disk, optical disk, flash memory and other memories.
[0115] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for smoothing motion of a video image, characterized in that: The method comprises the following steps: Obtaining a current camera posture corresponding to a current video frame of a video stream, and representing the current camera posture by a quaternion to obtain a current original quaternion corresponding to the current video frame; Obtaining a smoothed quaternion of a previous video frame corresponding to the current video frame from a smoothed quaternion queue of cached frames, and smoothing the current original quaternion according to the smoothed quaternion of the previous video frame to obtain a current smoothed quaternion corresponding to the current video frame; According to the current original quaternion and the current smoothed quaternion, the smoothed quaternion queue is subjected to smoothing filtering processing to obtain a processed smoothed quaternion queue; When the queue length of the processed smooth quaternion queue exceeds the number of cached frames, outputting a smoothed video frame image corresponding to the smooth quaternion corresponding to the queue head in the processed smooth quaternion queue; The step of performing smoothing filtering on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion to obtain the processed smoothed quaternion queue includes: According to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue, the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue is followed and adjusted to obtain an adjusted smoothed quaternion queue; According to the current original quaternion and the current smoothed quaternion, the original quaternion queue and the adjusted smoothed quaternion queue are updated respectively to obtain an updated smoothed quaternion queue; The updated smoothed quaternion queue is subjected to mean filtering processing to obtain a processed smoothed quaternion queue.
2. The method according to claim 1, characterized in that The step of obtaining the smoothed quaternion of the previous video frame corresponding to the current video frame from the smoothed quaternion queue of the cached frame, and smoothing the current original quaternion according to the smoothed quaternion of the previous video frame comprises: The smoothed quaternion of the previous video frame is used to perform spherical linear interpolation processing on the current original quaternion.
3. The method according to claim 2, characterized in that The step of performing spherical linear interpolation processing on the current original quaternion by using the smoothed quaternion of the previous video frame comprises: Utilizing the smoothed quaternion of the previous video frame, spherical linear interpolation is performed on the current original quaternion through a preset smoothing formula v(k)=slerp(v(k-1),p(k),weight), wherein p(k) is the original quaternion of the kth frame, v(k) is the smoothed quaternion of the kth frame, v(k-1) is the smoothed quaternion of the k-1th frame, weight is the interpolation weight of p(k) during spherical linear interpolation, and k is an integer greater than 1.
4. The method according to claim 1, characterized in that The step of following and adjusting the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue comprises: According to the original quaternion corresponding to each video frame in the original quaternion queue, the preset following formula v(m)=slerp(v(m),p(m)) is used. smooth ,weight follow ) follows and adjusts the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue, wherein v(m) is the smoothed quaternion of the mth frame in the smoothed quaternion queue, and p(m) smooth Represents the original quaternion of the mth frame after the original quaternion queue is subjected to unconstrained iterative mean filtering, weight follow is the following weight, and m is an integer greater than 1.
5. The method according to claim 1, characterized in that The step of performing mean filtering on the updated smoothed quaternion queue comprises: The updated smoothed quaternion queue is subjected to iterative mean filtering.
6. The method according to claim 1, characterized in that After the step of smoothing the video image in the video stream by using the smoothed quaternion corresponding to the queue head in the smoothed quaternion queue, the method further includes: The original quaternion queue and the smoothed quaternion queue are updated.
7. A video image motion smoothing processing device, characterized in that: The device comprises: A first parameter obtaining unit is used to obtain a current camera posture corresponding to a current video frame of a video stream, and to represent the current camera posture through a quaternion to obtain a current original quaternion corresponding to the current video frame; A second parameter obtaining unit is used to obtain a smoothed quaternion of a previous video frame corresponding to the current video frame from a smoothed quaternion queue of cached frames, and to smooth the current original quaternion according to the smoothed quaternion of the previous video frame to obtain a current smoothed quaternion corresponding to the current video frame; A queue smoothing filter unit, configured to perform smoothing filtering on the smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion, to obtain a processed smoothed quaternion queue; and A smoothed image output unit, configured to output a smoothed video frame image corresponding to the smoothed quaternion corresponding to the queue head in the processed smoothed quaternion queue when the queue length of the processed smoothed quaternion queue exceeds the number of cached frames; Wherein, the queue smoothing filter unit comprises: A queue following adjustment unit is used to follow and adjust the smoothed quaternion corresponding to each video frame in the smoothed quaternion queue according to the original quaternion queue of the cached frame and the corresponding smoothed quaternion queue to obtain an adjusted smoothed quaternion queue; A first queue updating unit is used to update the original quaternion queue and the adjusted smoothed quaternion queue according to the current original quaternion and the current smoothed quaternion, respectively, to obtain an updated smoothed quaternion; and The queue filtering processing unit is used to perform mean filtering on the updated smoothed quaternion queue to obtain a processed smoothed quaternion queue.
8. The device according to claim 7, characterized in that The second parameter obtaining unit includes: The parameter acquisition subunit is used to perform spherical linear interpolation processing on the current original quaternion using the smoothed quaternion of the previous video frame.
9. A video image processing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Video image motion smoothing processing method and device, equipment and storage medium
CN116489514A
Motion smoothing processing method, device and equipment of video image and storage medium
CN116489514B
