WO2023207899A1 - Anti-shake processing method and apparatus for video, and storage medium and electronic device - Google Patents

Anti-shake processing method and apparatus for video, and storage medium and electronic device Download PDF

Info

Publication number
WO2023207899A1
WO2023207899A1 PCT/CN2023/090288 CN2023090288W WO2023207899A1 WO 2023207899 A1 WO2023207899 A1 WO 2023207899A1 CN 2023090288 W CN2023090288 W CN 2023090288W WO 2023207899 A1 WO2023207899 A1 WO 2023207899A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame
shake
video
type
angle
Prior art date
Application number
PCT/CN2023/090288
Other languages
French (fr)
Chinese (zh)
Inventor
桑标
肖龙报
袁文亮
朱力
Original Assignee
影石创新科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 影石创新科技股份有限公司 filed Critical 影石创新科技股份有限公司
Publication of WO2023207899A1 publication Critical patent/WO2023207899A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/68Control of cameras or camera modules for stable pick-up of the scene, e.g. compensating for camera body vibrations
    • H04N23/682Vibration or motion blur correction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/68Control of cameras or camera modules for stable pick-up of the scene, e.g. compensating for camera body vibrations
    • H04N23/681Motion detection
    • H04N23/6812Motion detection based on additional sensors, e.g. acceleration sensors

Definitions

  • the present application relates to the field of video processing technology, and specifically to a video anti-shake processing method, device, storage medium and electronic equipment.
  • the captured video content is unstable, resulting in poor video quality.
  • the captured video can be stabilized.
  • Commonly used anti-shake processing methods include trajectory smoothing algorithms.
  • the trajectory smoothing algorithm is used to smooth the motion trajectory of the shooting device to obtain an ideal motion trajectory, and then perform anti-shake processing on the captured video based on the ideal motion trajectory.
  • this anti-shake processing method can only optimize the movement of the shooting device and does not take into account the display effect of the video content, which may easily result in poor display effect of the processed video content and is not conducive to improving the video quality.
  • Embodiments of the present application provide a video anti-shake processing method, device, storage medium and electronic equipment, which can improve video quality.
  • inventions of the present application provide a video anti-shake processing method.
  • the method includes:
  • the out-of-bounds angle of the video frame determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
  • anti-shake processing is performed on the video to be processed.
  • embodiments of the present application also provide a video anti-shake processing device, including:
  • the first data acquisition module is used to acquire the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
  • the second data acquisition module is used to obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory;
  • the video processing module is used to determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed based on the out-of-bounds angle of the video frame;
  • the field of view calculation module is used to determine the anti-shake field of view of the jitter frame based on the out-of-bounds angle of the reference frame corresponding to the jitter frame;
  • the anti-shake processing module is used to perform anti-shake processing on the video to be processed based on the anti-shake field of view of the shake frame.
  • embodiments of the present application also provide a computer-readable storage medium on which a computer program is stored.
  • the computer program When the computer program is run on a computer, it causes the computer to perform anti-shake of video as provided in any embodiment of the present application. Approach.
  • embodiments of the present application further provide an electronic device, including a processor and a memory.
  • the memory contains a computer program.
  • the processor invokes the computer program to perform anti-shake processing of videos as provided in any embodiment of the present application. method.
  • the technical solution provided by the embodiment of this application is to obtain the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed. According to the motion trajectory, the out-of-bounds angle of the video frame in the video to be processed is obtained. According to the out-of-bounds angle of the video frame, from The reference frame and the jitter frame corresponding to the reference frame are determined in the video to be processed. In this way, the jitter frame that jitters according to the movement of the shooting device in the video to be processed can be obtained according to the motion trajectory of the shooting device.
  • the anti-shake field of view angle of the shake frame is determined, and anti-shake processing is performed on the video to be processed according to the anti-shake field angle of the shake frame. It is possible to adaptively adjust the out-of-bounds angle of the shake frame according to the shaking situation of the shake frame, so that the adjusted out-of-bounds angle of the shake frame can adapt to the motion changes of the shooting device and improve the video anti-shake processing effect.
  • the anti-shake field angle of the jitter frame is determined based on the out-of-bounds angle of the reference frame corresponding to the jitter frame and the motion of the jitter frame, which also ensures that the video content of the jitter frame will not be lost after adjustment. , ensuring maximum utilization of video content and improving video quality.
  • FIG. 1 is a schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram describing the relationship between the reference frame, the jitter frame and the video frame in the video anti-shake processing method provided by the embodiment of the present application.
  • FIG. 3 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of the second field of view angle curve and the third field of view angle curve in the video anti-shake processing method provided by the embodiment of the present application.
  • FIG. 5 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a reference frame in the video anti-shake processing method provided by the embodiment of the present application.
  • FIG. 7 is a schematic flowchart of step 107 in the video anti-shake processing method provided by the embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a video anti-shake processing device provided by an embodiment of the present application.
  • Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • an embodiment means that a particular feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application.
  • the appearances of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are they consistent with other embodiments. Examples are mutually exclusive independent or alternative embodiments. Those skilled in the art understand, both explicitly and implicitly, that the embodiments described herein may be combined with other embodiments.
  • Embodiments of the present application provide a video anti-shake processing method.
  • the execution subject of the video anti-shake processing method may be the video anti-shake processing device provided in the embodiment of the present application, or a video anti-shake processing device integrated with the video anti-shake processing device.
  • the anti-shake processing device of the video can be implemented in the form of hardware or software.
  • the electronic device can be a smart phone, a tablet computer, a handheld computer, a television, a movie player and other devices with video playback functions, or a camera, a video camera, etc. , aircraft and other shooting devices with shooting functions.
  • the video to be processed is shot by the smartphone, and the smartphone can perform anti-shake processing on the video to be processed shot by itself; of course, the video to be processed can also be shot by a camera, and the video can be processed through the camera. Transmit to the smartphone, which performs anti-shake processing on the video to be processed.
  • the electronic device is a camera
  • the video to be processed can be captured by the camera, and then the camera can perform anti-shake processing on the video to be processed.
  • the solution provided by the embodiment of the present application is to perform post-shake stabilization processing on the captured video to be processed.
  • related anti-shake technologies there are mechanical stabilization methods and optical stabilization methods, but both methods require improvement of the hardware of electronic equipment or the addition of auxiliary equipment, which increases the cost of video anti-shake and requires higher camera performance.
  • the solution proposed in this application avoids excessive cost investment, has higher applicability, and is easier to promote.
  • the execution subject of the solution of this application is a shooting device.
  • the shooting device can perform anti-shake processing on the video and save the video after anti-shaking processing, thereby improving the video quality.
  • the video after anti-shake processing is stored in the shooting device, so that there will be no obvious jitter when the video is played, which improves the video display effect and ensures the user experience.
  • the solution provided by this application can also obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory of the shooting device, so as to determine the jitter frame of the video to be processed based on the motion of the shooting device, and The motion of the jitter frame is measured, and the out-of-bounds angle of the jitter frame is adaptively adjusted according to the motion of the jitter frame, so that the adjusted out-of-bounds angle of the jitter frame can adapt to the movement changes of the shooting device and improve the video anti-shake processing effect. At the same time, it also ensures that the video content of jittered frames will not be lost during the adjustment process, ensuring maximum utilization of video content and improving video quality.
  • the solution provided by the present application is explained in detail with the photographing device as the execution subject.
  • FIG. 1 is a schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • the specific process of the video anti-shake processing method provided by the embodiment of this application can be as follows:
  • the shooting device has a built-in gyroscope. Through the gyroscope, the position and posture of the shooting device at each moment can be obtained, and the position and posture of the shooting device at each moment can be obtained.
  • the posture can constitute the motion trajectory of the shooting device.
  • the motion trajectory of the shooting device represents the jitter of the video frames in the video to be processed, where the motion trajectory at each moment in the motion trajectory The pose corresponds to the video frame in the video to be processed.
  • the relative rotation amount between the video frames when the video frame is shot can be obtained based on the association between each pose in the motion trajectory and the corresponding video frame.
  • the relative rotation between video frames can be expressed by an angle, and the parameters that the angle can represent include horizontal rotation and vertical rotation.
  • the out-of-bounds angle of each video frame can be obtained.
  • the out-of-bounds angle refers to the maximum angle at which the video frame is angularly rotated and the angularly rotated video frame is cropped so that the image content in the video frame does not go out of bounds.
  • the maximum angle that can be rotated for the video frame is the out-of-bounds angle of the video frame.
  • the out-of-bounds angle of the video frame determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed.
  • the video frame in the video to be processed whose out-of-bounds angle is smaller than the preset field of view is determined as a reference frame
  • the video frame whose out-of-bounds angle is greater than or equal to the preset field of view is a non-reference frame.
  • all video frames can be divided into two categories, one is the reference frame and the other is the non-reference frame.
  • each reference frame corresponds to a different number of jitter frames, and the jitter frames corresponding to each reference frame are video frames distributed near the reference frame. These video frames may include other reference frames or non- Reference frame. Therefore, for each jitter frame, each jitter frame can correspond to one reference frame or multiple reference frames, as shown in Figure 2.
  • Figure 2 is a reference for the description of the video anti-shake processing method provided by the embodiment of the present application. Schematic diagram of the relationship between frames, jitter frames and video frames. In Figure 2, all video frames are divided into reference frames and non-reference frames, and the jitter frame corresponding to each reference frame can be another reference frame and/or non-reference frame. frame. The following are examples:
  • the 10th video frame is a reference frame
  • the 15th video frame is also a reference frame
  • the jitter frames corresponding to the 10th frame reference frame can be frames 5-9 and 11-15
  • the 15th frame is a reference frame.
  • the corresponding jitter frames may be frames 13-14 and 16-17.
  • the reference frame corresponding to jitter frame 5 is frame 10
  • the reference frames corresponding to jitter frame 13 are frames 10 and 15.
  • one or more reference frames can be determined from the video to be processed.
  • Each reference frame corresponds to a jitter frame.
  • the jitter frame is determined based on the out-of-bounds angle of the reference frame, and for the jitter frame When performing anti-shake processing, it is based on the out-of-bounds angle of its corresponding reference frame.
  • the anti-shake field angle of the jitter frame can be calculated based on the out-of-bounds angle of the reference frame corresponding to the jitter frame.
  • the anti-shake field angle is used to perform anti-shake processing on the jitter frame so that the processed jitter frame will not There is obvious jitter.
  • the present application is not limited by the execution order of each described step. Certain steps may also be performed in other orders or at the same time if no conflict occurs.
  • the motion trajectory of the shooting device when shooting the video to be processed can be obtained, and the out-of-bounds angle of the video frame in the video to be processed can be obtained based on the motion trajectory, so that the out-of-bounds angle can be obtained from the video to be processed.
  • the reference frame and the jitter frame corresponding to the reference frame are determined in the video, so that the jitter frame that jitters occurs when the shooting device moves is determined from the video to be processed.
  • the anti-shake field of view angle of the jitter frame is determined based on the out-of-bounds angle of the reference frame, and then the jitter frame is anti-shake processed according to the anti-shake field angle, so as to adaptively adjust the out-of-bounds angle of the jitter frame according to the jitter condition of the jitter frame. , which ensures maximum utilization of video content while performing anti-shake, which is beneficial to improving video quality.
  • the motion trajectory in the step of obtaining the motion trajectory of the shooting device when shooting the video to be processed, may also be a motion trajectory that is first processed by a trajectory smoothing algorithm and then smoothed, thereby reducing the motion of the shooting device in the video to be processed. Impact.
  • the out-of-bounds angle of the video frame can be calculated through quaternions, where each pose in the motion trajectory can represent the three-axis angular velocity, and the three-axis angular velocity can be converted through quaternions to obtain the video Frame rotation, after obtaining the relative rotation amount between each video frame, the out-of-bounds angle of each video frame can be obtained based on the relative rotation amount.
  • FIG. 3 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • the step of determining the reference frame and the jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame includes:
  • the video frame in the video to be processed whose out-of-boundary angle is smaller than the preset field of view angle can be used as a reference frame.
  • the jitter frame corresponding to each reference frame can be determined through the method provided in this embodiment.
  • the preset field of view angle can be a larger field of view angle value, or can be the maximum field of view angle supported by the shooting device. Of course, the preset field of view angle can also be set by the user according to actual needs. Taking the video frame with an out-of-bounds angle smaller than the preset field of view angle as the reference frame means that the out-of-bounds angle of the reference frame is smaller and the adjustable range is also smaller. Relatively speaking, the jitter of the reference frame is not obvious.
  • m represents the number of jittered frames
  • FOV max represents the preset field of view angle
  • FOV n represents the out-of-bounds angle of the reference frame
  • f represents the rate of change of field of view angle.
  • f can be set by the user, or it can default to a value obtained based on experience.
  • f can be 0.1, 0.5, 1 and other values.
  • m video frames located before the reference frame and m video frames located after the reference frame can be selected, and then the selected 2m
  • the video frame is used as the jitter frame corresponding to the reference frame.
  • the number of jitter frames corresponding to each reference frame may be calculated in sequence, and the m frames before and after the video may be selected based on the position of the reference frame in the video to be processed.
  • a video frame is used as the jitter frame corresponding to the reference frame.
  • the number of jitter frames corresponding to the reference frame is determined by the out-of-bounds angle of the reference frame. If the out-of-bounds angles of different reference frames are different, the number of corresponding jitter frames will be different. It can be seen from the above formula that the number of jitter frames corresponding to the reference frame is proportional to the out-of-bounds angle of the reference frame.
  • the jitter frames corresponding to different reference frames may also partially overlap.
  • the 20th and 25th frames in the video frames to be processed are reference frames, and the number of jitter frames corresponding to the 20th frame is 3, that is
  • the 17th, 18th, 19th, 21st, 22nd, and 23rd video frames in the video to be processed are the jitter frames corresponding to the 20th frame, and the number of jitter frames corresponding to the 25th frame is 5, that is, the number of jitter frames in the video to be processed is Video frames 20, 21, 22, 23, 24, 26, 27, 28, 29, and 30 are jitter frames corresponding to the 25th frame.
  • the jitter frames overlapping the 20th and 25th frames are the 22nd and 25th frames. 23 frames.
  • the jitter frame corresponding to a certain reference frame there may be one or more other reference frames in the jitter frame corresponding to a certain reference frame.
  • the 20th frame in the jitter frame corresponding to the 25th frame mentioned above is the reference frame.
  • the step of determining the anti-shake field of view angle of the shake frame based on the out-of-bounds angle of the reference frame corresponding to the shake frame includes:
  • the number of frames between each jitter frame and its corresponding reference frame can be obtained.
  • FOVm is the anti-shake field of view angle of the jitter frame
  • FOVn is the out-of-bounds angle of the reference frame
  • f is the change rate of the field of view angle
  • the value of the anti-shake field angle of the jitter frame is based on the out-of-bounds angle of the reference frame, and is distributed in an equal difference sequence on both sides of the reference frame.
  • the out-of-bounds angle of the reference frame corresponding to the jitter frame is 90
  • f is 0.1
  • m is 3
  • the reference frame is the 20th frame
  • the jitter frame corresponding to the reference frame They are the 17th, 18th, 19th, 21st, 22nd, and 23rd frames respectively.
  • the anti-shake field of view angle is 90.2
  • the anti-shake field angle of jitter frame 19 is 90.1
  • the anti-shake field angle of jitter frame 21 is 90.1
  • the anti-shake field angle of jitter frame 22 is 90.2
  • the anti-shake field angle of jitter frame 23 is 90.2
  • the field of view is 90.3.
  • the anti-shake field angles of the corresponding jitter frames are calculated one by one in the order of the reference frames. Therefore, for the overlapping jitter frames, the overlapping jitter frames A frame has multiple anti-shake field angles according to the number of corresponding reference frames. By analyzing the multiple anti-shake field angles corresponding to the overlapping jitter frames, the final anti-shake field angle of the overlapping jitter frames is determined. Field angle.
  • the 17th, 18th, 19th, 21st, 22nd, and 23rd video frames in the video to be processed are the jitter frames corresponding to the 20th frame
  • the 20th, 21st, 22nd, 23rd, 24th, 26th, and 27th video frames in the video to be processed are , 28, 29, and 30 video frames are the jitter frames corresponding to the 25th frame, among which the overlapping jitter frames are the 21st, 22nd, and 23rd frames.
  • the reference frames corresponding to the dither frame 22 are the 20th frame and the 25th frame.
  • the dither frame 22 has an anti-shake field of view angle corresponding to the reference frame 20 and another anti-shake field angle corresponding to the reference frame. 25 corresponding anti-shake field of view, the final anti-shake field of view of the shake frame 22 can be determined by analyzing the two anti-shake field of view angles.
  • the minimum value among multiple anti-shake field angles corresponding to overlapping jitter frames can be selected as the final anti-shake field angle.
  • the anti-shake field angle of the jitter frame 22 is 90.2.
  • the out-of-bounds angle of the reference frame 25 is 80.
  • the anti-shake field of view angle of the jitter frame 22 calculated by the method in the above embodiment should be 80.3, where one anti-shake field angle of the jitter frame 22 is 90.2, and the other anti-shake field angle is 80.3, then The smaller anti-shake field of view angle (80.3) is selected as the final anti-shake field of view angle of the jitter frame 22 .
  • the minimum value is selected as the final anti-shake field angle from multiple anti-shake field angles corresponding to the jitter frame.
  • the average value, the medium value, and the average value can also be selected.
  • the minimum value in this embodiment can be replaced with other values to re-determine the final anti-shake field of view. Such expansion methods should be included in the scope of protection covered by this application.
  • the step of performing anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame includes:
  • the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where the first field of view angle curve is based on the out-of-bounds value of each video frame in the video to be processed. angularly constructed;
  • the out-of-bounds angle of each video frame is obtained through the motion trajectory, and each out-of-bounds angle constitutes the first field of view angle curve.
  • the out-of-boundary angle corresponding to the jitter frame in the first field of view angle curve can be adjusted to the anti-shake field angle of the jitter frame, thereby obtaining the second field of view angle curve.
  • the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, including:
  • the first field of view angle curve is subjected to angle transformation processing according to the anti-shake field of view angle of the target shake frame to obtain the second field of view angle curve.
  • the anti-shake field angle is compared with the out-of-boundary angle of the shake frame.
  • the anti-shake field angle is greater than the out-of-bounds angle
  • the anti-shake field angle of the shake frame is not compared.
  • the out-of-bounds angle is adjusted to the anti-shake field of view, thereby avoiding the loss of video content due to excessive adjustment of the shake frame, thereby ensuring video quality.
  • the step of performing anti-shake processing on the video to be processed according to the second field of view curve includes:
  • Figure 4 is the second view of the video anti-shake processing method provided by the embodiment of the present application. Schematic diagram of the field angle curve and the third field of view angle curve.
  • the unsmooth polyline in Figure 4 is the second field of view angle curve before iterative smoothing filtering, and the smoother curve is the third field of view angle curve after processing. .
  • the numerical value on the second field of view angle curve is uniformly called the field of view angle.
  • the number of frames of the smoothing window is set, and then the field of view angles of multiple video frames on both sides of each video frame are selected one by one according to the number of frames to calculate the average value. , and then assign the average value to each video frame to achieve the effect of average filtering.
  • the number of frames in the smoothing window can be 21, then select the 10th-20th frame and the 22-32nd frame field of view, and average the 21 field of view angles to get The average value is used as the new field of view angle of the 20th frame.
  • the third field of view angle curve can be obtained, and by comparing the second field of view angle curve and the third field of view angle curve, the third field of view angle curve can be obtained
  • the field of view angle of the part of the angle curve that is greater than the second field of view angle curve is adjusted to the original value. For example, for the 25th frame, the field of view angle in the third field of view angle curve is 90, while in the second field of view angle curve If the field of view angle in the curve is 20, then the field of view angle of frame 25 in the third field of view angle curve is adjusted from 90 to the original value of 20.
  • the smoothing filtering process can be continued on the adjusted third field of view angle curve, and so on, each time Smoothing filtering, and adjusting the field of view angle of the part of the field of view angle curve after smoothing that is greater than the field of view angle curve before smoothing to the original value. This is regarded as an adjustment cycle, and iteration is carried out with this adjustment cycle. Process until the number of iterations reaches the preset number, or until the filtered field angle curve is smooth enough.
  • the first preset condition is the preset number of times, or the curvature of the viewing angle curve.
  • the preset times can be set according to actual needs, for example, set to 20, 23, 25, 30, etc.
  • the second field of view angle curve is iteratively smoothed and filtered through a moving average filter until the first
  • the preset conditions before obtaining the third field of view angle curve also include:
  • the out-of-view angle in the second viewing angle curve that is outside the preset viewing angle interval is adjusted.
  • the preset field of view range can refer to the angular range covered by the above-mentioned preset field of view. From the above, it can be seen that the preset field of view can be a larger field of view value, or it can also be a shooting device.
  • the maximum field of view angle supported, and one boundary of the preset field of view angle range is the preset field of view angle, and the other boundary can also be a smaller field of view angle value, or the minimum field of view angle supported by the shooting device.
  • adjusting the second field of view angle curve through the preset field of view angle can make the second field of view angle curve larger than the maximum field of view angle.
  • the out-of-view angle of the field of view is adjusted to the maximum field of view angle, and the out-of-field angle in the second field of view angle curve that is smaller than the minimum field of view angle is adjusted to the minimum field of view angle, thereby ensuring the second field of view angle curve obtained after adjustment. All the field of view angles are within the preset field of view range, thereby ensuring the video display effect.
  • anti-shake processing is performed on the video to be processed according to the third field of view curve, including:
  • anti-shake processing can also be performed on the video to be processed according to the third field of view angle curve.
  • each field of view angle in the third field of view angle curve is used for anti-shake processing. corresponding relationship with the video frames in the video frames to be processed, and each video frame is rotated and cropped according to the field of view angle in the third field of view angle curve to obtain the processed video.
  • the solution provided by the embodiments of the present application uses each reference frame as a benchmark to determine the anti-shake field angles of multiple jitter frames near the reference frame, and determines each When the anti-shake field of view of a jitter frame is determined, its anti-shake field of view is determined based on the distance between the jitter frame and the corresponding reference frame. When it is closer to the reference frame, the anti-shake field of view is smaller. When it is farther from the reference frame, the anti-shake field of view is smaller.
  • the anti-shake field of view is large, and the distance between the jitter frame and the reference frame is relatively close, indicating that the jitter of the jitter frame is relatively large, and using a smaller anti-shake field of view will not easily cause the video content to go out of bounds, thus ensuring the video display Effect, and when the distance between the jitter frame and the reference frame is far, it means that the jitter of the jitter frame is relatively small, and using a larger anti-shake field of view can improve the anti-shake effect. Furthermore, by smoothing and filtering the second field of view curve, there will be no abrupt changes in field of view between video frames after anti-shake processing, thereby improving video quality.
  • Figure 5 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
  • the video frame whose out-of-bounds angle is smaller than the preset field of view angle in the video to be processed is determined. After setting the reference frame, the method also includes:
  • the reference frame is a first-type reference frame, determine the video frame between two adjacent first-type reference frames as a jitter frame corresponding to the two adjacent first-type reference frames;
  • the reference frame is a second type reference frame, perform the step of determining the number m of dither frames corresponding to the reference frame based on the out-of-bounds angle and the preset field of view angle of the reference frame.
  • a reference frame that is closely spaced between two adjacent reference frames is determined as a first type of reference frame, and reference frames other than the first type of reference frame are considered as a second type of reference frame.
  • first type of reference frame there are multiple reference frames in the video to be processed, and the out-of-bounds angle of each reference frame is smaller than the preset field of view angle, and there may be video frames between two adjacent reference frames whose out-of-bounds angle is not smaller than the preset field of view angle. There may also be no video frames whose out-of-boundary angle is not smaller than the preset field of view angle.
  • Figure 6 is a schematic diagram of a reference frame provided by the implementation of this application.
  • the unfilled rectangle represents the reference frame
  • the rectangle with diagonal lines represents the reference frame whose out-of-bounds angle is not less than the preset field of view angle, where the reference frames are sorted, and then the closely spaced frames between each two reference frames are
  • the reference frame is determined to be the first type of reference frame, and the reference frames that are far apart between each two reference frames are regarded as the second type of reference frame.
  • the method before step 103, the method further includes:
  • the video frame between two adjacent first-type reference frames is determined as a jitter frame corresponding to the two adjacent first-type reference frames. It can be understood that the out-of-boundary angle of the dithered frame between two adjacent first-type reference frames is not less than the preset field of view angle.
  • the method mentioned in the above embodiment is followed: according to the out-of-boundary angle and the preset field of view angle corresponding to each reference frame, the number m of jitter frames corresponding to the reference frame is determined, and The contents mentioned in the subsequent steps process the jitter frames corresponding to the second type of reference frame.
  • a reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as a first type of reference frame, and a reference frame other than the first type of reference frame is determined as a second type of reference frame.
  • the method also includes:
  • any method can be used to determine whether the interval between two adjacent reference frames meets the second preset condition. If it meets the second preset condition, the two adjacent reference frames are determined to be the first type of reference frame. .
  • the predicted number of video frames that should exist between the two adjacent reference frames can be calculated based on the out-of-boundary angle and the preset field of view angle of the two adjacent reference frames, and the number of predicted frames and the actual number of frames can be calculated. Compare the number of frames. When the number of predicted frames is larger, it means that the two adjacent reference frames The actual number of frames between them is smaller, that is, the interval between the two adjacent reference frames meets the second preset condition, that is, the interval is smaller.
  • x represents the number of predicted frames
  • h represents the coefficient
  • FOV max represents the preset field of view angle
  • FOV n1 and FOV n2 represent two adjacent reference frames
  • f represents the rate of change of field of view angle.
  • h can be set according to actual needs, for example, set to 1.5, 2, 3 and other values.
  • the actual number of frames between two adjacent reference frames can be compared with the preset number of frames.
  • the actual number of frames is smaller, it means that the interval between the two adjacent reference frames meets the The second preset condition is that the interval is small.
  • the preset frame number can be set according to actual needs, or it can also be a default value, such as 40, 50, 60, etc.
  • the number of predicted frames can also be calculated at the same time, the number of predicted frames is compared with the preset number of frames, the maximum value is selected from the two, and then the maximum value is compared with the actual number of frames. When the actual number of frames When it is less than the maximum value of the two, it is determined that the interval between two adjacent reference frames meets the second preset condition.
  • the first reference frame (the 20th frame of the original video) and the second reference frame (the 25th frame of the original video) are two adjacent reference frames.
  • the jitter frame corresponding to the first type of reference frame is the first type of jitter frame
  • the jitter frame corresponding to the second type of reference frame is the second type of jitter frame
  • the steps of determining the reference frame and the jitter frame corresponding to the reference frame from the video to be processed include:
  • the anti-shake field of view angle of the first-type jitter frame is determined, where,
  • the sub-out-of-bounds area is composed of the video frame between two adjacent first-category reference frames corresponding to the first-category jitter frame and the two adjacent first-category reference frames;
  • two adjacent first reference frames and the video frames between them constitute a sub-out-of-bounds area.
  • the anti-shake field angle of the first type of shaking frame corresponding to the first type of reference frame it is based on It is calculated from the out-of-boundary angles of two adjacent first jitter frames and the frame sequence of the first jitter frame in the sub-out-of-bounds area, that is, the anti-shake field angle of the first type of jitter frame, and the out-of-bounds angle of its two adjacent reference frames. Angles are associated.
  • the first type of jitter frame is determined based on the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the sub-out-of-bounds area.
  • the anti-shake field of view of the jitter frame includes:
  • a represents the offset coefficient
  • FOV n1 and FOV n2 represent two adjacent reference frames
  • n 2 -n 1 represents the actual number of frames.
  • the anti-shake offset can be determined based on the frame sequence and offset coefficient of the first type of jitter frame.
  • the anti-shake offset is determined as the product of the offset coefficient and the frame sequence, where each sub-frame The first type of reference frame and the first type of jitter frame are sorted in order in the out-of-bounds area.
  • the size of the anti-shake offset is related to the sorting of the first type of jitter frame in its corresponding sub-out-of-bounds area.
  • the anti-shake field of view angle is calculated based on any one of its two adjacent adjacent first-type reference frames, and the anti-shake field angle in each sub-out-of-boundary area is calculated.
  • the anti-shake field angles of the first type of jitter frames are in an arithmetic sequence.
  • k represents the frame sequence
  • k 1, 2,..., n 2 -n 1
  • FOV n1+k represents the anti-shake view of the k-th first-type jitter frame after the first first-type reference frame.
  • Field angle, a represents the offset coefficient
  • k*a represents the anti-shake offset
  • FOV n1 represents the out-of-bounds angle of the first first-type reference frame.
  • the anti-shake field angle of each first-type jitter frame in the sub-out-of-boundary area can also be calculated based on the second first-type reference frame in the sub-out-of-boundary area, which will not be described again here.
  • Figure 7 is a schematic flowchart of step 107 in the video anti-shake processing method provided by the embodiment of the present application.
  • the step of determining the video frames between them as jitter frames corresponding to two adjacent first-type reference frames includes:
  • For the first type reference frame determine the video frame between two adjacent first type reference frames and the two adjacent first type reference frames as a sub-out-of-bounds area
  • the predicted out-of-boundary angle is smaller than the actual out-of-bounds angle, determine the video frame between the first and last two first-type reference frames as the jitter frame corresponding to the first and last two first-type reference frames.
  • the multiple adjacent sub-out-of-bounds areas can be merged into one out-of-bounds area, and the number of first-type reference frames in each out-of-bounds area is not the same. Less than 3, it is understandable that the length of any out-of-bounds area is greater than the length of the sub-out-of-bounds area, where the number of first-type reference frames in the sub-out-of-bounds area is 2.
  • the out-of-bounds area can be divided to divide an out-of-bounds area into at least one interval segment, and the length of each interval segment is greater than the length of the sub-out-of-bounds area, that is, there are at least 3 first-type references in each interval segment. frame.
  • Each interval segment may not overlap or may overlap, or any at least three first-type reference frames may be arranged and combined.
  • first-type reference frames in the sub-out-of-bounds area, namely (n 1 , n 2 , n 3 , n 4 , n 5 , n 6 ), when dividing the interval segments, if (n 1 , n 2 , n 3 ) and (n 4 , n 5 , n 6 ) are taken as one interval segment respectively, then the two interval segments No overlap.
  • the specific method is: using the out-of-boundary angles of the first and last two first-type reference frames in the interval segment, predict the predicted out-of-boundary angle of the first-type reference frame between the two, and compare the predicted field of view angle with the actual out-of-bounds angle.
  • the predicted out-of-bounds angle is smaller than the actual out-of-bounds angle, it means that the distance between the first and last two first-type reference frames is far, and the video frame between the two can be determined as its corresponding first-type jitter frame .
  • the first type of jitter frame includes not only the first type reference frame located between the first and last two first type reference frames, but also includes video frames whose out-of-bounds angle is not less than the preset field of view angle.
  • the predicted out-of-bounds angle when the predicted out-of-bounds angle is not less than the actual out-of-bounds angle, it means that the distance between the first and last two first-type reference frames is close, and there is no jitter frame between them, that is, the out-of-bounds angle of the video frame between the two does not need to be adjust.
  • the jitter frame corresponding to the first type of reference frame is the first type of jitter frame
  • the jitter frame corresponding to the second type of reference frame is the second type of jitter frame. Jitter-like frames
  • the anti-shake field angle of the first-type jitter frame is determined based on the out-of-boundary angles of the first and last two first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame within the interval.
  • the anti-shake offset coefficient a of a type of jitter frame, and then the anti-shake offset k*a is obtained based on the frame sequence k and the anti-shake offset coefficient a, and then based on the first type of reference frame at the top, or based on the Based on the second type of reference frame at the tail, the anti-shake field of view of the first type of jitter frame is calculated.
  • the final anti-shake field angle is selected from the minimum value of the corresponding multiple anti-shake field angles, or its corresponding
  • For the average value of multiple anti-shake field angles refer specifically to the content mentioned in the above embodiments, which will not be described again here.
  • anti-shake processing is performed on the video to be processed according to the anti-shake field of view of the jitter frame, including:
  • anti-shake processing is performed on the video to be processed.
  • the first type target jitter frame whose anti-shake field angle is not larger than the out-of-bounds angle is determined from the first type of jitter frame, so as to determine the anti-shake frame according to the first type of target jitter frame.
  • the jitter field of view is used to perform anti-shake processing on the first type of jitter frame
  • the second type of target jitter frame whose anti-shake field of view angle is not greater than the out-of-bounds angle is determined from the second type of jitter frame, so as to determine the jitter frame according to the second type of target jitter frame.
  • the anti-shake field of view performs anti-shake processing on the second type of target jitter frames.
  • the out-of-bounds angle of the jitter frame is not adjusted to the anti-shake field of view angle, thereby avoiding the loss of video content due to excessive adjustment of the jitter frame, thereby ensuring Video quality.
  • anti-shake processing is performed on the video to be processed, including:
  • the first field of view angle curve is angled. Degree transformation processing to obtain a second field of view angle curve, where the first field of view angle curve is constructed based on the out-of-bounds angle of each video frame in the video to be processed;
  • the out-of-bounds angle corresponding to the first type of target jitter frame in the first field of view angle curve can be adjusted is the anti-shake field of view angle of the jitter frame of the first type of target, and adjusts the out-of-bounds angle corresponding to the jitter frame of the second type of target to the anti-shake field of view angle of the jitter frame of the second type of target, thereby obtaining the second field of view angle curve.
  • the second field of view angle curve can be processed through the preset field of view angle interval, so that all the field of view angles in the third field of view angle curve are within the preset field of view angle interval, and then Ensure the video display effect.
  • the method before adjusting the out-of-view angle in the second viewing angle curve that is outside the preset viewing angle interval according to the preset viewing angle interval, the method further includes:
  • anti-shake processing is performed on the video to be processed according to the third field of view curve, including:
  • the video anti-shake processing method proposed by the embodiment of the present invention can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle according to the out-of-bounds angle.
  • the out-of-bounds angle of the jitter frame enables the adjusted out-of-bounds angle of the jitter frame to adapt to the motion changes of the shooting device, that is, when the motion changes are small, a larger angle is used to ensure the utilization of the field of view angle. In large situations, a smaller angle is used to provide an anti-shake effect. Furthermore, the field of view angle curve is smoothed so that there will be no abrupt angle changes between adjacent frames. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
  • a video anti-shake processing device 200 is also provided. Please refer to FIG. 8 , which is a schematic structural diagram of a video anti-shake processing device 200 provided by an embodiment of the present application.
  • the video anti-shake processing device 200 is applied to electronic equipment, and the video anti-shake processing device 200 Set 200 includes:
  • the first data acquisition module 201 is used to acquire the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
  • the second data acquisition module 202 is used to obtain the out-of-bounds angle of the video frame in the video to be processed according to the motion trajectory;
  • the video processing module 203 is used to determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame;
  • the field of view calculation module 204 is used to determine the anti-shake field of view angle of the jitter frame based on the out-of-bounds angle of the reference frame corresponding to the jitter frame;
  • the anti-shake processing module 205 is used to perform anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame.
  • the video processing module 203 is also used to:
  • the out-of-boundary angle and the preset field of view angle of the reference frame determine the number m of jitter frames corresponding to the reference frame
  • the m video frames located before the reference frame and the m video frames located after the reference frame are determined as jitter frames corresponding to the reference frame.
  • the field of view calculation module 204 is also used to:
  • the anti-shake field of view angle of the jitter frame is determined.
  • the anti-shake processing module 205 is also used to:
  • the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where the first field of view angle curve is based on the out-of-bounds value of each video frame in the video to be processed. angularly constructed;
  • the anti-shake processing module 205 is also used to:
  • the field of view calculation module 204 is also used to:
  • the video frame between two adjacent first-type reference frames is determined as a jitter frame corresponding to the two adjacent first-type reference frames;
  • the reference frame is a second type of reference frame, then perform the step of determining the number m of jitter frames corresponding to the reference frame based on the out-of-boundary angle and the preset field of view angle of the reference frame.
  • a reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as a first type of reference frame, and a reference frame other than the first type of reference frame is determined as a second type of reference frame.
  • the field of view angle calculation module 204 is also used to:
  • the jitter frame corresponding to the first type of reference frame is the first type of jitter frame
  • the jitter frame corresponding to the second type of reference frame is the second type of jitter frame
  • the field of view calculation module 204 is also used to:
  • the anti-shake field of view angle of the first-type jitter frame is determined, where,
  • the sub-out-of-bounds area is composed of the video frame between two adjacent first-category reference frames corresponding to the first-category jitter frame and the two adjacent first-category reference frames;
  • the field of view calculation module 204 is also used to:
  • the anti-shake field of view angle of the first-type jitter frame is determined based on the anti-shake offset and the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame.
  • the field of view calculation module 204 is also used to:
  • the video frame between two adjacent first type reference frames and the two adjacent first type reference frames are determined as a sub-out-of-bounds area
  • the video frame between the first and last two first-category reference frames is determined to be the same as the first and last two first-category reference frames.
  • the jitter frame corresponding to the first type of reference frame is the first type of jitter frame
  • the jitter frame corresponding to the second type of reference frame is the second type of jitter frame
  • the field of view calculation module 204 is also used to:
  • the anti-shake field angle of the first-type jitter frame is determined based on the out-of-boundary angles of the first and last two first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame within the interval.
  • the anti-shake processing module 205 is also used to:
  • anti-shake processing is performed on the video to be processed.
  • the anti-shake processing module 205 is also used to:
  • the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where, A field of view curve is constructed based on the out-of-bounds angle of each video frame in the video to be processed;
  • the video anti-shake processing device 200 provided by the embodiment of the present application belongs to the same concept as the video anti-shake processing method in the above embodiment, and the video anti-shake processing device 200 can achieve video anti-shake.
  • the specific implementation process can be found in the video anti-shake processing method embodiment, and will not be described again here.
  • the video anti-shake processing device proposed in the embodiment of the present application can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle according to the out-of-bounds angle.
  • the out-of-bounds angle of the jitter frame enables the adjusted out-of-bounds angle of the jitter frame to adapt to the motion changes of the shooting device, that is, when the motion changes are small, a larger angle is used to ensure the utilization of the field of view angle. In large situations, a smaller angle is used to provide an anti-shake effect. Furthermore, the field of view curve is smoothed to smooth the gap between adjacent frames. There will be no abrupt angle changes. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
  • An embodiment of the present application also provides an electronic device.
  • the electronic device may be a smart phone, a tablet computer, a handheld computer, a television, a movie player, a camera, a camcorder, an aircraft, or other equipment.
  • Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device 300 includes a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, and a computer program stored on the memory 302 and executable on the processor.
  • the processor 301 is electrically connected to the memory 302.
  • the structure of the electronic device shown in the figures does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figures, or combine certain components, or arrange different components.
  • the processor 301 is the control center of the electronic device 300, using various interfaces and lines to connect various parts of the entire electronic device 300, by running or loading software programs and/or modules stored in the memory 302, and calling the software programs and/or modules stored in the memory 302. data, perform various functions of the electronic device 300 and process the data, thereby overall monitoring the electronic device 300 .
  • the processor 301 in the electronic device 300 will follow the following steps to load instructions corresponding to the processes of one or more application programs into the memory 302, and the processor 301 will run the instructions stored in the memory.
  • 302 applications to achieve various functions:
  • the out-of-bounds angle of the video frame determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
  • anti-shake processing is performed on the video to be processed.
  • the electronic device provided in this embodiment can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle from the video to be processed based on the out-of-bounds angle.
  • Determining the reference frame and the jitter frame corresponding to the reference frame realizes the determination of the jitter frame that jittered when the shooting device moved from the video to be processed, and adaptively adjusts the out-of-bounds of the jitter frame according to the movement of the jitter frame.
  • the adjusted out-of-bounds angle of the jitter frame can adapt to the motion changes of the shooting device, that is, use a larger angle when the motion changes are small, ensuring the utilization of the field of view angle, and use it when the motion changes are large
  • a smaller angle provides an anti-shake effect. Furthermore, by smoothing the field of view curve, there will be no abrupt blur between adjacent frames. angle changes. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
  • embodiments of the present application provide a computer-readable storage medium.
  • Persons of ordinary skill in the art can understand that all or part of the steps in the method of implementing the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in In a computer-readable storage medium, when the program is executed, it includes the following steps:
  • the out-of-bounds angle of the video frame determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
  • anti-shake processing is performed on the video to be processed.
  • the above-mentioned storage media can be ROM/RAM, magnetic disk, optical disk, etc. Since the computer program stored in the storage medium can execute the steps in any video anti-shake processing method provided by the embodiments of the present application, it is possible to realize the anti-shake processing method of any video provided by the embodiments of the present application.
  • the beneficial effects that can be achieved by the dither processing method are detailed in the previous embodiments and will not be described again here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

Disclosed in the present application are an anti-shake processing method and apparatus for a video, and a storage medium and an electronic device. The method comprises: acquiring a video to be processed and a movement trajectory of a recording apparatus of when same records said video; according to the movement trajectory, acquiring an out-of-range angle of a video frame in said video; according to the out-of-range angle of the video frame, determining, from said video, a reference frame and a shake frame corresponding to the reference frame; according to the out-of-range angle of the reference frame corresponding to the shake frame, determining an anti-shake field of view of the shake frame; and according to the anti-shake field of view of the shake frame, performing anti-shake processing on said video. An out-of-range angle of a shake frame is adjusted according to a movement trajectory of a recording apparatus, so as to obtain an anti-shake field of view, and anti-shake processing is performed on a video to be processed according to the anti-shake field of view of the shake frame, such that an anti-shake effect of a video and a display effect of video content are both taken into consideration, thereby improving the quality of the video.

Description

视频的防抖处理方法、装置、存储介质及电子设备Video anti-shake processing method, device, storage medium and electronic equipment 技术领域Technical field
本申请涉及视频处理技术领域,具体涉及一种视频的防抖处理方法、装置、存储介质及电子设备。The present application relates to the field of video processing technology, and specifically to a video anti-shake processing method, device, storage medium and electronic equipment.
背景技术Background technique
在拍摄过程中,由于拍摄装置的位姿变化,导致拍摄的视频内容不稳定,致使视频质量较差。During the shooting process, due to changes in the posture of the shooting device, the captured video content is unstable, resulting in poor video quality.
为提高视频质量,可对拍摄的视频进行防抖处理。常用的防抖处理方式包括轨迹平滑算法,其中,通过轨迹平滑算法对拍摄装置的运动轨迹进行平滑处理,得到理想的运动轨迹,进而根据理想的运动轨迹对拍摄的视频进行防抖处理。To improve video quality, the captured video can be stabilized. Commonly used anti-shake processing methods include trajectory smoothing algorithms. The trajectory smoothing algorithm is used to smooth the motion trajectory of the shooting device to obtain an ideal motion trajectory, and then perform anti-shake processing on the captured video based on the ideal motion trajectory.
但此种防抖处理方式仅能够对拍摄装置的运动进行优化,并未考虑到视频内容的显示效果,容易造成处理后的视频内容的显示效果差,并不利于提高视频质量。However, this anti-shake processing method can only optimize the movement of the shooting device and does not take into account the display effect of the video content, which may easily result in poor display effect of the processed video content and is not conducive to improving the video quality.
发明内容Contents of the invention
本申请实施例提供一种视频的防抖处理方法、装置、存储介质及电子设备,能够提高视频质量。Embodiments of the present application provide a video anti-shake processing method, device, storage medium and electronic equipment, which can improve video quality.
第一方面,本申请实施例提供一种视频的防抖处理方法,方法包括:In a first aspect, embodiments of the present application provide a video anti-shake processing method. The method includes:
获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹;Obtain the video to be processed and the movement trajectory of the shooting device when shooting the video to be processed;
根据运动轨迹,获取待处理视频中视频帧的出界角;According to the motion trajectory, obtain the out-of-bounds angle of the video frame in the video to be processed;
根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧;According to the out-of-bounds angle of the video frame, determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角;Determine the anti-shake field of view angle of the jitter frame according to the out-of-bounds angle of the reference frame corresponding to the jitter frame;
根据抖动帧的防抖视场角,对待处理视频进行防抖处理。According to the anti-shake field of view of the shake frame, anti-shake processing is performed on the video to be processed.
第二方面,本申请实施例还提供一种视频的防抖处理装置,包括:In a second aspect, embodiments of the present application also provide a video anti-shake processing device, including:
第一数据获取模块,用于获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹;The first data acquisition module is used to acquire the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
第二数据获取模块,用于根据运动轨迹,获取待处理视频中视频帧的出界角;The second data acquisition module is used to obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory;
视频处理模块,用于根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧;The video processing module is used to determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed based on the out-of-bounds angle of the video frame;
视场角计算模块,用于根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角;The field of view calculation module is used to determine the anti-shake field of view of the jitter frame based on the out-of-bounds angle of the reference frame corresponding to the jitter frame;
防抖处理模块,用于根据抖动帧的防抖视场角,对待处理视频进行防抖处理。The anti-shake processing module is used to perform anti-shake processing on the video to be processed based on the anti-shake field of view of the shake frame.
第三方面,本申请实施例还提供一种计算机可读存储介质,其上存储有计算机程序,当计算机程序在计算机上运行时,使得计算机执行如本申请任一实施例提供的视频的防抖处理方法。In a third aspect, embodiments of the present application also provide a computer-readable storage medium on which a computer program is stored. When the computer program is run on a computer, it causes the computer to perform anti-shake of video as provided in any embodiment of the present application. Approach.
第四方面,本申请实施例还提供一种电子设备,包括处理器和存储器,存储器有计算机程序,处理器通过调用计算机程序,用于执行如本申请任一实施例提供的视频的防抖处理方法。 In a fourth aspect, embodiments of the present application further provide an electronic device, including a processor and a memory. The memory contains a computer program. The processor invokes the computer program to perform anti-shake processing of videos as provided in any embodiment of the present application. method.
本申请实施例提供的技术方案,通过获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹,根据运动轨迹,获取待处理视频中视频帧的出界角,根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧,通过此种方式能够根据拍摄装置的运动轨迹,得到待处理视频中根据拍摄装置的运动发生抖动的抖动帧。进而根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角,根据抖动帧的防抖视场角对待处理视频进行防抖处理。实现了根据抖动帧的抖动情况适应性地调节抖动帧的出界角,使得调节后的抖动帧的出界角能够适应拍摄装置的运动变化,提升视频防抖处理效果。其次,在调节抖动帧时,根据抖动帧对应的参照帧的出界角,以及抖动帧的运动情况,确定出抖动帧的防抖视场角,也保证调节后抖动帧的视频内容不会发生损失,保证了视频内容的最大利用率,提高了视频质量。The technical solution provided by the embodiment of this application is to obtain the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed. According to the motion trajectory, the out-of-bounds angle of the video frame in the video to be processed is obtained. According to the out-of-bounds angle of the video frame, from The reference frame and the jitter frame corresponding to the reference frame are determined in the video to be processed. In this way, the jitter frame that jitters according to the movement of the shooting device in the video to be processed can be obtained according to the motion trajectory of the shooting device. Then, based on the out-of-boundary angle of the reference frame corresponding to the shake frame, the anti-shake field of view angle of the shake frame is determined, and anti-shake processing is performed on the video to be processed according to the anti-shake field angle of the shake frame. It is possible to adaptively adjust the out-of-bounds angle of the shake frame according to the shaking situation of the shake frame, so that the adjusted out-of-bounds angle of the shake frame can adapt to the motion changes of the shooting device and improve the video anti-shake processing effect. Secondly, when adjusting the jitter frame, the anti-shake field angle of the jitter frame is determined based on the out-of-bounds angle of the reference frame corresponding to the jitter frame and the motion of the jitter frame, which also ensures that the video content of the jitter frame will not be lost after adjustment. , ensuring maximum utilization of video content and improving video quality.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can also be obtained based on these drawings without exerting creative efforts.
图1为本申请实施例提供的视频的防抖处理方法的流程示意图。FIG. 1 is a schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
图2为本申请实施例提供的视频的防抖处理方法中描述参照帧、抖动帧与视频帧三者之间关系的示意图。FIG. 2 is a schematic diagram describing the relationship between the reference frame, the jitter frame and the video frame in the video anti-shake processing method provided by the embodiment of the present application.
图3为本申请实施例提供的视频的防抖处理方法的另一流程示意图。FIG. 3 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
图4为本申请实施例提供的视频的防抖处理方法中第二视场角曲线和第三视场角曲线的示意图。FIG. 4 is a schematic diagram of the second field of view angle curve and the third field of view angle curve in the video anti-shake processing method provided by the embodiment of the present application.
图5为本申请实施例提供的视频的防抖处理方法的又一流程示意图。FIG. 5 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application.
图6为本申请实施例提供的视频的防抖处理方法中参照帧的示意图。FIG. 6 is a schematic diagram of a reference frame in the video anti-shake processing method provided by the embodiment of the present application.
图7为本申请实施例提供的视频的防抖处理方法中步骤107的流程示意图。FIG. 7 is a schematic flowchart of step 107 in the video anti-shake processing method provided by the embodiment of the present application.
图8为本申请实施例提供的视频的防抖处理装置的结构示意图。FIG. 8 is a schematic structural diagram of a video anti-shake processing device provided by an embodiment of the present application.
图9为本申请实施例提供的电子设备的结构示意图。Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有付出创造性劳动前提下所获得的所有其他实施例,都属于本申请的保护范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of this application.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施 例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。Reference herein to "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The appearances of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are they consistent with other embodiments. Examples are mutually exclusive independent or alternative embodiments. Those skilled in the art understand, both explicitly and implicitly, that the embodiments described herein may be combined with other embodiments.
本申请实施例提供一种视频的防抖处理方法,该视频的防抖处理方法的执行主体可以是本申请实施例提供的视频的防抖处理装置,或者集成了该视频的防抖处理装置的电子设备。其中,该视频的防抖处理装置可以采用硬件或者软件的方式实现,电子设备可以是智能手机、平板电脑、掌上电脑、电视机、电影机等具有播放视频功能的设备,还可以是相机、摄像机、飞行器等具有拍摄功能的拍摄装置。比如,当电子设备为智能手机时,待处理视频由智能手机拍摄得到,智能手机可对自身拍摄得到的待处理视频进行防抖处理;当然地,待处理视频还可由相机拍摄得到,并通过相机传输至智能手机,由智能手机对待处理视频进行防抖处理。再比如,当电子设备为相机时,待处理视频可由相机拍摄得到,然后通过相机对待处理视频进行防抖处理。Embodiments of the present application provide a video anti-shake processing method. The execution subject of the video anti-shake processing method may be the video anti-shake processing device provided in the embodiment of the present application, or a video anti-shake processing device integrated with the video anti-shake processing device. Electronic equipment. Among them, the anti-shake processing device of the video can be implemented in the form of hardware or software. The electronic device can be a smart phone, a tablet computer, a handheld computer, a television, a movie player and other devices with video playback functions, or a camera, a video camera, etc. , aircraft and other shooting devices with shooting functions. For example, when the electronic device is a smartphone, the video to be processed is shot by the smartphone, and the smartphone can perform anti-shake processing on the video to be processed shot by itself; of course, the video to be processed can also be shot by a camera, and the video can be processed through the camera. Transmit to the smartphone, which performs anti-shake processing on the video to be processed. For another example, when the electronic device is a camera, the video to be processed can be captured by the camera, and then the camera can perform anti-shake processing on the video to be processed.
需要说明的是,本申请实施例提供的方案是对拍摄得到的待处理视频进行后期的防抖处理的。相关防抖技术中,有机械稳定方法和光学稳定方法,但该两种方法均需要对电子设备的硬件进行改进或者增加辅助设备,增加了视频防抖的成本,且对相机性能要求较高。相比于相关防抖技术而言,本申请的方案避免了过多的成本投入,适用性较高,更易推广。It should be noted that the solution provided by the embodiment of the present application is to perform post-shake stabilization processing on the captured video to be processed. Among related anti-shake technologies, there are mechanical stabilization methods and optical stabilization methods, but both methods require improvement of the hardware of electronic equipment or the addition of auxiliary equipment, which increases the cost of video anti-shake and requires higher camera performance. Compared with related anti-shake technologies, the solution proposed in this application avoids excessive cost investment, has higher applicability, and is easier to promote.
为更好地理解本申请提供的方案,此处提供一个应用场景对本申请提供的方案进行解释说明。比如,本申请方案的执行主体为拍摄装置,每当拍摄装置拍摄得到一个视频,拍摄装置即可对该视频进行防抖处理,并将防抖处理后的视频进行保存,从而能够提升视频质量。当用户播放视频时,拍摄装置中存储的是防抖处理后的视频,使得视频播放时并不会出现明显的抖动,提高了视频显示效果,保障了用户体验。In order to better understand the solution provided by this application, an application scenario is provided here to explain the solution provided by this application. For example, the execution subject of the solution of this application is a shooting device. Whenever the shooting device captures a video, the shooting device can perform anti-shake processing on the video and save the video after anti-shaking processing, thereby improving the video quality. When the user plays the video, the video after anti-shake processing is stored in the shooting device, so that there will be no obvious jitter when the video is played, which improves the video display effect and ensures the user experience.
而相比于相关技术中,本申请提供的方案还能够根据拍摄装置的运动轨迹获取待处理视频中视频帧的出界角,以根据拍摄装置的运动情况,确定出待处理视频的抖动帧,以及抖动帧的运动情况,并根据抖动帧的运动情况适应性地调节该抖动帧的出界角,使得调节后的抖动帧的出界角能够适应拍摄装置的运动变化,提升视频防抖处理效果。同时,也保证调节过程中抖动帧的视频内容不会发生损失,保证了视频内容的最大利用率,提高了视频质量。在以下的实施例中,则以拍摄装置为执行主体对本申请提供的方案进行详细地解释说明。Compared with related technologies, the solution provided by this application can also obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory of the shooting device, so as to determine the jitter frame of the video to be processed based on the motion of the shooting device, and The motion of the jitter frame is measured, and the out-of-bounds angle of the jitter frame is adaptively adjusted according to the motion of the jitter frame, so that the adjusted out-of-bounds angle of the jitter frame can adapt to the movement changes of the shooting device and improve the video anti-shake processing effect. At the same time, it also ensures that the video content of jittered frames will not be lost during the adjustment process, ensuring maximum utilization of video content and improving video quality. In the following embodiments, the solution provided by the present application is explained in detail with the photographing device as the execution subject.
请参阅图1,图1为本申请实施例提供的视频的防抖处理方法的流程示意图。本申请实施例提供的视频的防抖处理方法的具体流程可以如下:Please refer to FIG. 1 , which is a schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application. The specific process of the video anti-shake processing method provided by the embodiment of this application can be as follows:
101、获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹。101. Obtain the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed.
其中,拍摄装置中内置有陀螺仪,通过陀螺仪即可得到拍摄装置在每一时刻的位姿,而每一时刻的 位姿即可构成拍摄装置的运动轨迹。Among them, the shooting device has a built-in gyroscope. Through the gyroscope, the position and posture of the shooting device at each moment can be obtained, and the position and posture of the shooting device at each moment can be obtained. The posture can constitute the motion trajectory of the shooting device.
通过获取拍摄装置所拍摄的待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹,即通过拍摄装置的运动轨迹表示待处理视频中视频帧的抖动情况,其中,运动轨迹中每一时刻的位姿是与待处理视频中的视频帧相对应的。By obtaining the video to be processed captured by the shooting device and the motion trajectory of the shooting device when shooting the video to be processed, that is, the motion trajectory of the shooting device represents the jitter of the video frames in the video to be processed, where the motion trajectory at each moment in the motion trajectory The pose corresponds to the video frame in the video to be processed.
102、根据运动轨迹,获取待处理视频中视频帧的出界角。102. According to the motion trajectory, obtain the out-of-bounds angle of the video frame in the video to be processed.
当得到运动轨迹之后,即可根据运动轨迹中每一位姿与对应的视频帧的关联,得到在拍摄该视频帧时的视频帧之间的相对旋转量。After the motion trajectory is obtained, the relative rotation amount between the video frames when the video frame is shot can be obtained based on the association between each pose in the motion trajectory and the corresponding video frame.
其中,视频帧之间的相对旋转量可用角度表示,角度所能表征的参数包括水平方向的旋转和竖直方向的旋转。Among them, the relative rotation between video frames can be expressed by an angle, and the parameters that the angle can represent include horizontal rotation and vertical rotation.
根据视频帧之间的相对旋转量,可得到每一视频帧的出界角。其中,出界角指的是对视频帧进行角度旋转,并对角度旋转后的视频帧进行裁剪后,使得视频帧中的图像内容不会出界时的最大的角度。比如,以水平旋转为例,当旋转某个视频帧时,为保证视频帧中的原图像内容完整,可对该视频帧旋转的最大角度即为该视频帧的出界角。According to the relative rotation between video frames, the out-of-bounds angle of each video frame can be obtained. Among them, the out-of-bounds angle refers to the maximum angle at which the video frame is angularly rotated and the angularly rotated video frame is cropped so that the image content in the video frame does not go out of bounds. For example, taking horizontal rotation as an example, when rotating a video frame, in order to ensure that the original image content in the video frame is complete, the maximum angle that can be rotated for the video frame is the out-of-bounds angle of the video frame.
103、根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧。其中,将待处理视频中出界角小于预设视场角的视频帧,确定为参照帧,而出界角大于或等于预设视场角的视频帧则为非参照帧,可以理解地,根据预设视场角可将所有视频帧分成两类,一类为参照帧,另一类为非参照帧。103. According to the out-of-bounds angle of the video frame, determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed. Among them, the video frame in the video to be processed whose out-of-bounds angle is smaller than the preset field of view is determined as a reference frame, and the video frame whose out-of-bounds angle is greater than or equal to the preset field of view is a non-reference frame. Understandably, according to the preset Assuming the field of view, all video frames can be divided into two categories, one is the reference frame and the other is the non-reference frame.
对于每一个参照帧而言,每一个参照帧对应有不同数量的抖动帧,且每一参照帧对应的抖动帧为该参照帧附近分布的视频帧,这些视频帧可包括另外的参照帧或非参照帧。因此,对于每一个抖动帧而言,每一抖动帧可对应一个参照帧或多个参照帧,可参照图2所示,图2为本申请实施例提供的视频的防抖处理方法中描述参照帧、抖动帧与视频帧三者之间关系的示意图,图2中所有视频帧分为参照帧和非参照帧,而每一参照帧对应的抖动帧可为另外的参照帧和/或者非参照帧。以下进行举例说明:For each reference frame, each reference frame corresponds to a different number of jitter frames, and the jitter frames corresponding to each reference frame are video frames distributed near the reference frame. These video frames may include other reference frames or non- Reference frame. Therefore, for each jitter frame, each jitter frame can correspond to one reference frame or multiple reference frames, as shown in Figure 2. Figure 2 is a reference for the description of the video anti-shake processing method provided by the embodiment of the present application. Schematic diagram of the relationship between frames, jitter frames and video frames. In Figure 2, all video frames are divided into reference frames and non-reference frames, and the jitter frame corresponding to each reference frame can be another reference frame and/or non-reference frame. frame. The following are examples:
比如,第10帧视频帧为参照帧,第15帧视频帧也为参照帧,而第10帧参照帧对应的抖动帧可为第5-9帧和第11-15帧,第15帧参照帧对应的抖动帧可为第13-14帧和第16-17帧,此时,抖动帧5对应的参照帧为第10帧,抖动帧13对应的参照帧为第10帧和第15帧。For example, the 10th video frame is a reference frame, the 15th video frame is also a reference frame, and the jitter frames corresponding to the 10th frame reference frame can be frames 5-9 and 11-15, and the 15th frame is a reference frame. The corresponding jitter frames may be frames 13-14 and 16-17. In this case, the reference frame corresponding to jitter frame 5 is frame 10, and the reference frames corresponding to jitter frame 13 are frames 10 and 15.
104、根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角。104. Determine the anti-shake field of view angle of the shake frame according to the out-of-bounds angle of the reference frame corresponding to the shake frame.
根据视频帧的出界角,可从待处理视频中确定出一个或多个参照帧,其中,每一参照帧对应有抖动帧,抖动帧是根据参照帧的出界角确定出的,且对抖动帧进行防抖处理时,是以其对应的参照帧的出界角为依据的。 According to the out-of-bounds angle of the video frame, one or more reference frames can be determined from the video to be processed. Each reference frame corresponds to a jitter frame. The jitter frame is determined based on the out-of-bounds angle of the reference frame, and for the jitter frame When performing anti-shake processing, it is based on the out-of-bounds angle of its corresponding reference frame.
105、根据抖动帧的防抖视场角,对待处理视频进行防抖处理。105. According to the anti-shake field of view of the shake frame, perform anti-shake processing on the video to be processed.
通过根据抖动帧对应的参照帧的出界角,即可计算出抖动帧的防抖视场角,其中,防抖视场角用于对抖动帧进行防抖处理,使得处理后的抖动帧不会出现明显的抖动。The anti-shake field angle of the jitter frame can be calculated based on the out-of-bounds angle of the reference frame corresponding to the jitter frame. The anti-shake field angle is used to perform anti-shake processing on the jitter frame so that the processed jitter frame will not There is obvious jitter.
具体实施时,本申请不受所描述的各个步骤的执行顺序的限制,在不产生冲突的情况下,某些步骤还可以采用其它顺序进行或者同时进行。During specific implementation, the present application is not limited by the execution order of each described step. Certain steps may also be performed in other orders or at the same time if no conflict occurs.
通过本申请实施例中的视频的防抖处理方法,能够通过获取拍摄装置拍摄待处理视频时的运动轨迹,并根据运动轨迹得到待处理视频中视频帧的出界角,从而根据出界角从待处理视频中确定出参照帧,以及参照帧对应的抖动帧,实现了从待处理视频中确定出在拍摄装置运动时发生了抖动的抖动帧。之后以参照帧的出界角为依据确定抖动帧的防抖视场角,进而根据防抖视场角对抖动帧进行防抖处理,实现根据抖动帧的抖动情况适应性地调节抖动帧的出界角,在进行防抖的同时保证了视频内容的最大利用率,利于提高视频质量。Through the video anti-shake processing method in the embodiment of the present application, the motion trajectory of the shooting device when shooting the video to be processed can be obtained, and the out-of-bounds angle of the video frame in the video to be processed can be obtained based on the motion trajectory, so that the out-of-bounds angle can be obtained from the video to be processed. The reference frame and the jitter frame corresponding to the reference frame are determined in the video, so that the jitter frame that jitters occurs when the shooting device moves is determined from the video to be processed. Then, the anti-shake field of view angle of the jitter frame is determined based on the out-of-bounds angle of the reference frame, and then the jitter frame is anti-shake processed according to the anti-shake field angle, so as to adaptively adjust the out-of-bounds angle of the jitter frame according to the jitter condition of the jitter frame. , which ensures maximum utilization of video content while performing anti-shake, which is beneficial to improving video quality.
根据前面实施例所描述的方法,以下将举例作进一步详细说明。Based on the method described in the previous embodiment, examples will be given below for further detailed explanation.
在一些实施例中,当获取到拍摄待处理视频时拍摄装置的运动轨迹的步骤中,运动轨迹也可为先通过轨迹平滑算法处理后平滑的运动轨迹,从而减小了拍摄装置运动对待处理视频的影响。In some embodiments, in the step of obtaining the motion trajectory of the shooting device when shooting the video to be processed, the motion trajectory may also be a motion trajectory that is first processed by a trajectory smoothing algorithm and then smoothed, thereby reducing the motion of the shooting device in the video to be processed. Impact.
在一些实施例中,可通过四元数计算视频帧的出界角,其中,运动轨迹中的每一位姿即可表示三轴角速度,通过四元数对三轴角速度进行转换,即可得到视频帧的旋转,当得到每一视频帧之间的相对旋转量之后,即可根据相对旋转量得到每一视频帧的出界角。In some embodiments, the out-of-bounds angle of the video frame can be calculated through quaternions, where each pose in the motion trajectory can represent the three-axis angular velocity, and the three-axis angular velocity can be converted through quaternions to obtain the video Frame rotation, after obtaining the relative rotation amount between each video frame, the out-of-bounds angle of each video frame can be obtained based on the relative rotation amount.
请参阅图3,图3为本申请实施例提供的视频的防抖处理方法的另一流程示意图。在一些实施例中,根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧的步骤,包括:Please refer to FIG. 3 , which is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application. In some embodiments, the step of determining the reference frame and the jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame includes:
1031、将待处理视频中出界角小于预设视场角的视频帧,确定为参照帧;1031. Determine the video frame in the video to be processed whose out-of-bounds angle is smaller than the preset field of view angle as a reference frame;
1032、根据参照帧的出界角和预设视场角,确定参照帧对应的抖动帧的数量m;1032. Determine the number m of jitter frames corresponding to the reference frame according to the out-of-bounds angle and the preset field of view angle of the reference frame;
1033、将位于参照帧之前的m个视频帧以及位于参照帧之后的m个视频帧,确定为参照帧对应的抖动帧。1033. Determine the m video frames located before the reference frame and the m video frames located after the reference frame as jitter frames corresponding to the reference frame.
在该实施例中,可根据每一视频帧的出界角,将待处理视频中出界角小于预设视场角的视频帧作为参照帧。而待处理视频中可以有一个或多个参照帧,当有多个参照帧时,对于每一参照帧,可通过本实施例提供的方法确定每一参照帧对应的抖动帧。In this embodiment, according to the out-of-boundary angle of each video frame, the video frame in the video to be processed whose out-of-boundary angle is smaller than the preset field of view angle can be used as a reference frame. There may be one or more reference frames in the video to be processed. When there are multiple reference frames, for each reference frame, the jitter frame corresponding to each reference frame can be determined through the method provided in this embodiment.
其中,预设视场角可为一个较大的视场角数值,也可为拍摄装置支持的最大视场角,当然地,该预设视场角也可由用户根据实际需求设定。而将出界角小于预设视场角的视频帧作为参照帧,说明参照帧的出界角较小,可调节的幅度也较小,相对而言,参照帧的抖动并不明显。 The preset field of view angle can be a larger field of view angle value, or can be the maximum field of view angle supported by the shooting device. Of course, the preset field of view angle can also be set by the user according to actual needs. Taking the video frame with an out-of-bounds angle smaller than the preset field of view angle as the reference frame means that the out-of-bounds angle of the reference frame is smaller and the adjustable range is also smaller. Relatively speaking, the jitter of the reference frame is not obvious.
示例性地,根据参照帧的出界角和预设视场角计算该参照帧对应的抖动帧数量时,可采用如下公式:
m=(FOVmax-FOVn)÷f
For example, when calculating the number of jitter frames corresponding to the reference frame based on the out-of-bounds angle and the preset field of view angle of the reference frame, the following formula can be used:
m=(FOV max -FOV n )÷f
该公式中,m表示抖动帧的数量,FOVmax表示预设视场角,FOVn表示参照帧的出界角,f表示视场角变化率。其中,f可由用户设定,也可默认为根据经验得到的数值,比如,f可为0.1,0.5、1等数值。In this formula, m represents the number of jittered frames, FOV max represents the preset field of view angle, FOV n represents the out-of-bounds angle of the reference frame, and f represents the rate of change of field of view angle. Among them, f can be set by the user, or it can default to a value obtained based on experience. For example, f can be 0.1, 0.5, 1 and other values.
得到抖动帧的数量m之后,可按照参照帧在待处理视频中的位置,选取位于该参照帧之前的m帧视频帧,以及位于该参照帧之后的m帧视频帧,进而将选取的2m个视频帧作为该参照帧对应的抖动帧。After obtaining the number m of jitter frames, according to the position of the reference frame in the video to be processed, m video frames located before the reference frame and m video frames located after the reference frame can be selected, and then the selected 2m The video frame is used as the jitter frame corresponding to the reference frame.
可以理解地,待处理视频中可以有多个参照帧,可按照顺序依次计算每一参照帧对应的抖动帧的数量,并根据该参照帧在待处理视频中的位置选取位于该视频前后各m个视频帧作为该参照帧对应的抖动帧。而参照帧对应的抖动帧的数量根据参照帧的出界角而定,不同参照帧的出界角不同,则其对应的抖动帧的数量不同。由上述公式可知,参照帧对应的抖动帧的数量与参照帧的出界角成正比。It is understandable that there may be multiple reference frames in the video to be processed, and the number of jitter frames corresponding to each reference frame may be calculated in sequence, and the m frames before and after the video may be selected based on the position of the reference frame in the video to be processed. A video frame is used as the jitter frame corresponding to the reference frame. The number of jitter frames corresponding to the reference frame is determined by the out-of-bounds angle of the reference frame. If the out-of-bounds angles of different reference frames are different, the number of corresponding jitter frames will be different. It can be seen from the above formula that the number of jitter frames corresponding to the reference frame is proportional to the out-of-bounds angle of the reference frame.
另外,不同参照帧对应的抖动帧也有可能会出现部分重叠,比如,待处理视频帧中的第20帧和第25帧为参照帧,而第20帧对应的抖动帧的数量为3个,即待处理视频中的第17、18、19、21、22、23帧视频帧为第20帧对应的抖动帧,而第25帧对应的抖动帧的数量为5个,即待处理视频中的第20、21、22、23、24、26、27、28、29、30帧视频帧为第25帧对应的抖动帧,其中,第20帧和第25帧重叠的抖动帧为第22帧和第23帧。In addition, the jitter frames corresponding to different reference frames may also partially overlap. For example, the 20th and 25th frames in the video frames to be processed are reference frames, and the number of jitter frames corresponding to the 20th frame is 3, that is The 17th, 18th, 19th, 21st, 22nd, and 23rd video frames in the video to be processed are the jitter frames corresponding to the 20th frame, and the number of jitter frames corresponding to the 25th frame is 5, that is, the number of jitter frames in the video to be processed is Video frames 20, 21, 22, 23, 24, 26, 27, 28, 29, and 30 are jitter frames corresponding to the 25th frame. Among them, the jitter frames overlapping the 20th and 25th frames are the 22nd and 25th frames. 23 frames.
其次,某一参照帧对应的抖动帧中还可能存在另外的一个或多个参照帧,比如上述的第25帧对应的抖动帧中的第20帧为参照帧。Secondly, there may be one or more other reference frames in the jitter frame corresponding to a certain reference frame. For example, the 20th frame in the jitter frame corresponding to the 25th frame mentioned above is the reference frame.
请参阅图3,在一些实施例中,根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角的步骤,包括:Please refer to Figure 3. In some embodiments, the step of determining the anti-shake field of view angle of the shake frame based on the out-of-bounds angle of the reference frame corresponding to the shake frame includes:
1041、确定抖动帧与其对应的参照帧的间隔帧数;1041. Determine the number of frames between the jitter frame and its corresponding reference frame;
1042、根据间隔帧数和抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角。1042. Determine the anti-shake field of view angle of the dither frame based on the number of interval frames and the out-of-boundary angle of the reference frame corresponding to the dither frame.
其中,根据抖动帧与参照帧在待处理视频中的位置,即可得到每一抖动帧与其对应的参照帧的间隔帧数,抖动帧距参照帧越远,间隔帧数越大,反之间隔帧数越小。Among them, according to the positions of the jitter frame and the reference frame in the video to be processed, the number of frames between each jitter frame and its corresponding reference frame can be obtained. The further the jitter frame is from the reference frame, the greater the number of frames, and inversely the number of frames between the frames. The smaller the number.
而计算抖动帧的防抖视场角时,是以其对应的参照帧的出界角为基准的,计算公式如下:
FOVm=FOVn+i×f
When calculating the anti-shake field of view angle of a jitter frame, it is based on the out-of-bounds angle of its corresponding reference frame. The calculation formula is as follows:
FOV m = FOV n +i×f
该公式中,FOVm为抖动帧的防抖视场角,FOVn为参照帧的出界角,f为视场角变化率,i为间隔帧数,i=1、2...m;In this formula, FOVm is the anti-shake field of view angle of the jitter frame, FOVn is the out-of-bounds angle of the reference frame, f is the change rate of the field of view angle, i is the number of interval frames, i=1, 2...m;
由上可知,抖动帧的防抖视场角的数值是以参照帧的出界角为基准,在参照帧两侧呈等差序列分布的。比如,抖动帧对应的参照帧的出界角为90,f为0.1,m为3,参照帧为第20帧,参照帧对应的抖动帧 分别为第17、18、19、21、22、23帧,对于抖动帧17而言,该抖动帧17的防抖视场角=90+3*0.1=90.3,以此类推,抖动帧18的防抖视场角为90.2,抖动帧19的防抖视场角为90.1,抖动帧21的防抖视场角为90.1,抖动帧22的防抖视场角为90.2,抖动帧23的防抖视场角为90.3。It can be seen from the above that the value of the anti-shake field angle of the jitter frame is based on the out-of-bounds angle of the reference frame, and is distributed in an equal difference sequence on both sides of the reference frame. For example, the out-of-bounds angle of the reference frame corresponding to the jitter frame is 90, f is 0.1, m is 3, the reference frame is the 20th frame, and the jitter frame corresponding to the reference frame They are the 17th, 18th, 19th, 21st, 22nd, and 23rd frames respectively. For the dithered frame 17, the anti-shake field of view of the dithered frame 17=90+3*0.1=90.3, and so on, the anti-shake field angle of the dithered frame 18 The anti-shake field of view angle is 90.2, the anti-shake field angle of jitter frame 19 is 90.1, the anti-shake field angle of jitter frame 21 is 90.1, the anti-shake field angle of jitter frame 22 is 90.2, the anti-shake field angle of jitter frame 23 is 90.2 The field of view is 90.3.
可以理解的,对于某些参照帧对应的抖动帧具有重叠的情况,因按照参照帧的顺序逐一计算与其对应的抖动帧的防抖视场角,因此,对于重叠的抖动帧,该重叠的抖动帧根据与其对应的参照帧的数量,具有对应的多个防抖视场角,通过分析该重叠的抖动帧对应的多个防抖视场角,以确定该重叠的抖动帧最终的防抖视场角。比如,待处理视频中的第17、18、19、21、22、23帧视频帧为第20帧对应的抖动帧,待处理视频中的第20、21、22、23、24、26、27、28、29、30帧视频帧为第25帧对应的抖动帧,其中,重叠的抖动帧为第21帧、第22帧和第23帧。以重叠的抖动帧22为例,抖动帧22对应的参照帧为第20帧和第25帧,则抖动帧22具有一个与参照帧20对应的防抖视场角,还具有另一个与参照帧25对应的防抖视场角,可通过分析两个防抖视场角以确定出抖动帧22最终的防抖视场角。It can be understood that for some jitter frames corresponding to overlapping reference frames, the anti-shake field angles of the corresponding jitter frames are calculated one by one in the order of the reference frames. Therefore, for the overlapping jitter frames, the overlapping jitter frames A frame has multiple anti-shake field angles according to the number of corresponding reference frames. By analyzing the multiple anti-shake field angles corresponding to the overlapping jitter frames, the final anti-shake field angle of the overlapping jitter frames is determined. Field angle. For example, the 17th, 18th, 19th, 21st, 22nd, and 23rd video frames in the video to be processed are the jitter frames corresponding to the 20th frame, and the 20th, 21st, 22nd, 23rd, 24th, 26th, and 27th video frames in the video to be processed are , 28, 29, and 30 video frames are the jitter frames corresponding to the 25th frame, among which the overlapping jitter frames are the 21st, 22nd, and 23rd frames. Taking the overlapping dither frame 22 as an example, the reference frames corresponding to the dither frame 22 are the 20th frame and the 25th frame. Then the dither frame 22 has an anti-shake field of view angle corresponding to the reference frame 20 and another anti-shake field angle corresponding to the reference frame. 25 corresponding anti-shake field of view, the final anti-shake field of view of the shake frame 22 can be determined by analyzing the two anti-shake field of view angles.
示例性地,可选择重叠的抖动帧对应的多个防抖视场角中的最小值作为最终防抖视场角。继续以上述重叠的抖动帧22为例,当参照帧为第20帧时,抖动帧22的防抖视场角为90.2,当参照帧为第25帧时,比如参照帧25的出界角为80,则抖动帧22通过上述实施例中的方式计算得到的防抖视场角应为80.3,其中,抖动帧22的一个防抖视场角为90.2,另一个防抖视场角为80.3,则选择较小的防抖视场角(80.3)作为抖动帧22的最终的防抖视场角。For example, the minimum value among multiple anti-shake field angles corresponding to overlapping jitter frames can be selected as the final anti-shake field angle. Continuing to take the above-mentioned overlapping jitter frame 22 as an example, when the reference frame is the 20th frame, the anti-shake field angle of the jitter frame 22 is 90.2. When the reference frame is the 25th frame, for example, the out-of-bounds angle of the reference frame 25 is 80. , then the anti-shake field of view angle of the jitter frame 22 calculated by the method in the above embodiment should be 80.3, where one anti-shake field angle of the jitter frame 22 is 90.2, and the other anti-shake field angle is 80.3, then The smaller anti-shake field of view angle (80.3) is selected as the final anti-shake field of view angle of the jitter frame 22 .
可以理解地,本实施例中采用了从抖动帧对应的多个防抖视场角中选择最小值作为最终的防抖视场角,作为本实施例的扩展方式,也可选择平均值、中值等替换本实施例中的最小值以重新确定最终的防抖视场角,如此类扩展方式均应列入本申请所涵盖的保护范围。It can be understood that in this embodiment, the minimum value is selected as the final anti-shake field angle from multiple anti-shake field angles corresponding to the jitter frame. As an extension of this embodiment, the average value, the medium value, and the average value can also be selected. The minimum value in this embodiment can be replaced with other values to re-determine the final anti-shake field of view. Such expansion methods should be included in the scope of protection covered by this application.
在一些实施例中,根据抖动帧的防抖视场角,对待处理视频进行防抖处理的步骤,包括:In some embodiments, the step of performing anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame includes:
根据抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,其中,第一视场角曲线是根据待处理视频中每一视频帧的出界角构建的;According to the anti-shake field of view of the shake frame, the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where the first field of view angle curve is based on the out-of-bounds value of each video frame in the video to be processed. angularly constructed;
根据第二视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the second field of view curve.
其中,通过运动轨迹得到每一视频帧的出界角,而每一出界角构成了第一视场角曲线。当得到抖动帧的防抖视场角后,可将第一视场角曲线中与抖动帧对应的出界角调整为该抖动帧的防抖视场角,从而得到第二视场角曲线。Among them, the out-of-bounds angle of each video frame is obtained through the motion trajectory, and each out-of-bounds angle constitutes the first field of view angle curve. After obtaining the anti-shake field of view angle of the jitter frame, the out-of-boundary angle corresponding to the jitter frame in the first field of view angle curve can be adjusted to the anti-shake field angle of the jitter frame, thereby obtaining the second field of view angle curve.
在一些实施例中,根据抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,包括:In some embodiments, according to the anti-shake field of view angle of the shake frame, the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, including:
从抖动帧中确定出防抖视场角不大于出界角的目标抖动帧; Determine the target jitter frame whose anti-shake field of view angle is not greater than the out-of-bounds angle from the jitter frames;
根据目标抖动帧的防抖视场角对第一视场角曲线进行角度变换处理,得到第二视场角曲线。The first field of view angle curve is subjected to angle transformation processing according to the anti-shake field of view angle of the target shake frame to obtain the second field of view angle curve.
其中,当计算得到抖动帧的防抖视场角之后,将该防抖视场角与该抖动帧的出界角进行对比,当防抖视场角大于出界角时,则不将该抖动帧的出界角调整为防抖视场角,从而避免了因对抖动帧的调节幅度过大,造成视频内容的缺失,从而保证了视频质量。Among them, after the anti-shake field of view angle of the shake frame is calculated, the anti-shake field angle is compared with the out-of-boundary angle of the shake frame. When the anti-shake field angle is greater than the out-of-bounds angle, the anti-shake field angle of the shake frame is not compared. The out-of-bounds angle is adjusted to the anti-shake field of view, thereby avoiding the loss of video content due to excessive adjustment of the shake frame, thereby ensuring video quality.
在一些实施例中,根据第二视场角曲线对待处理视频进行防抖处理的步骤,包括:In some embodiments, the step of performing anti-shake processing on the video to be processed according to the second field of view curve includes:
通过移动平均滤波器对第二视场角曲线进行迭代平滑滤波处理,直至满足第一预设条件,得到第三视场角曲线;Perform iterative smoothing filtering processing on the second field of view angle curve through a moving average filter until the first preset condition is met, and a third field of view angle curve is obtained;
根据第三视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the third field of view curve.
在该实施例中,当得到第二视场角曲线之后,通过移动平均滤波器对第二视场角曲线进行迭代平滑滤波处理,能够得到平滑的第三视场角曲线,通过第三视场角曲线对待处理视频进行防抖处理,能够避免待处理视频中出现突兀的视频帧变化的情况,具体请参阅图4,图4为本申请实施例提供的视频的防抖处理方法中第二视场角曲线和第三视场角曲线的示意图,图4中不平滑的折线为未经迭代平滑滤波处理前的第二视场角曲线,比较平滑的曲线为处理后的第三视场角曲线。In this embodiment, after the second viewing angle curve is obtained, the second viewing angle curve is subjected to iterative smoothing filtering processing through a moving average filter, and a smooth third viewing angle curve can be obtained. Anti-shake processing of the video to be processed using the angular curve can avoid sudden video frame changes in the video to be processed. Please refer to Figure 4 for details. Figure 4 is the second view of the video anti-shake processing method provided by the embodiment of the present application. Schematic diagram of the field angle curve and the third field of view angle curve. The unsmooth polyline in Figure 4 is the second field of view angle curve before iterative smoothing filtering, and the smoother curve is the third field of view angle curve after processing. .
其中,为方便对第二视场角上的出界角或防抖视场角进行表述,统一将第二视场角曲线上的数值称为视场角。通过移动平均滤波器对第二视场角曲线进行处理时,通过设定平滑窗口的帧数量,进而根据帧数量逐一选取每一视频帧两侧的多个视频帧的视场角求取平均值,进而将该平均值赋值给每一视频帧,达到平均滤波的效果。比如,在对第20帧滤波时,平滑窗口的帧数量可取21,进而选取第10-20帧,以及22-32帧视场角,对该21个视场角求取平均值,以将得到的平均值作为第20帧新的视场角。Among them, in order to facilitate the description of the out-of-view angle or the anti-shake field angle at the second field of view, the numerical value on the second field of view angle curve is uniformly called the field of view angle. When processing the second field of view angle curve through the moving average filter, the number of frames of the smoothing window is set, and then the field of view angles of multiple video frames on both sides of each video frame are selected one by one according to the number of frames to calculate the average value. , and then assign the average value to each video frame to achieve the effect of average filtering. For example, when filtering the 20th frame, the number of frames in the smoothing window can be 21, then select the 10th-20th frame and the 22-32nd frame field of view, and average the 21 field of view angles to get The average value is used as the new field of view angle of the 20th frame.
此外,通过对第二视场角曲线进行一次平滑滤波处理,即可得到第三视场角曲线,通过将第二视场角曲线和第三视场角曲线进行对比,以将第三视场角曲中大于第二视场角曲线的部分的视场角调整为原数值,比如,对于第25帧,在第三视场角曲线中的视场角为90,而在第二视场角曲线中的视场角为20,则将第三视场角曲线中第25帧的视场角由90调整为原数值20。In addition, by performing a smoothing filtering process on the second field of view angle curve, the third field of view angle curve can be obtained, and by comparing the second field of view angle curve and the third field of view angle curve, the third field of view angle curve can be obtained The field of view angle of the part of the angle curve that is greater than the second field of view angle curve is adjusted to the original value. For example, for the 25th frame, the field of view angle in the third field of view angle curve is 90, while in the second field of view angle curve If the field of view angle in the curve is 20, then the field of view angle of frame 25 in the third field of view angle curve is adjusted from 90 to the original value of 20.
而当对第三视场角曲线中大于第二视场角曲线中的部分调整为原数值之后,还可继续对调整后的第三视场角曲线进行平滑滤波处理,依次类推,每进行一次平滑滤波,以及将平滑滤波后的视场角曲线中大于平滑滤波前的视场角曲线的部分的视场角调整为原数值,以此,视为一个调整周期,进而以该调整周期进行迭代处理,直至迭代次数达到预设次数,或者直至滤波后的视场角曲线足够平滑。After adjusting the part of the third field of view angle curve that is greater than the second field of view angle curve to the original value, the smoothing filtering process can be continued on the adjusted third field of view angle curve, and so on, each time Smoothing filtering, and adjusting the field of view angle of the part of the field of view angle curve after smoothing that is greater than the field of view angle curve before smoothing to the original value. This is regarded as an adjustment cycle, and iteration is carried out with this adjustment cycle. Process until the number of iterations reaches the preset number, or until the filtered field angle curve is smooth enough.
其中,第一预设条件即为预设次数,或者视场角曲线的曲率。而预设次数可根据实际需求设定,比如,设定为20、23、25、30等。The first preset condition is the preset number of times, or the curvature of the viewing angle curve. The preset times can be set according to actual needs, for example, set to 20, 23, 25, 30, etc.
在一些实施例中,在通过移动平均滤波器对第二视场角曲线进行迭代平滑滤波处理,直至满足第一 预设条件,得到第三视场角曲线之前,还包括:In some embodiments, the second field of view angle curve is iteratively smoothed and filtered through a moving average filter until the first The preset conditions before obtaining the third field of view angle curve also include:
根据预设视场角区间,对第二视场角曲线中处于预设视场角区间以外的出界角进行调节。According to the preset viewing angle interval, the out-of-view angle in the second viewing angle curve that is outside the preset viewing angle interval is adjusted.
其中,预设视场角区间可指上述提及的预设视场角所涵盖的角度范围,由上可知,预设视场角可为一个较大的视场角数值,也可为拍摄装置支持的最大视场角,而预设视场角区间的一个边界为预设视场角,另一个边界也可为一个较小的视场角数值,或者为拍摄装置支持的最小视场角。Among them, the preset field of view range can refer to the angular range covered by the above-mentioned preset field of view. From the above, it can be seen that the preset field of view can be a larger field of view value, or it can also be a shooting device. The maximum field of view angle supported, and one boundary of the preset field of view angle range is the preset field of view angle, and the other boundary can also be a smaller field of view angle value, or the minimum field of view angle supported by the shooting device.
比如,以最大视场角和最小视场角组成的预设视场角区间为例,通过预设视场角对第二视场角曲线进行调整,能够将第二视场角曲线中大于最大视场角的出界角调整为该最大视场角,将第二视场角曲线中小于最小视场角的出界角调整为该最小视场角,从而保证调整后得到的第二视场角曲线中的所有视场角均处于预设视场角区间,进而保证视频的显示效果。For example, taking the preset field of view interval consisting of the maximum field of view angle and the minimum field of view angle as an example, adjusting the second field of view angle curve through the preset field of view angle can make the second field of view angle curve larger than the maximum field of view angle. The out-of-view angle of the field of view is adjusted to the maximum field of view angle, and the out-of-field angle in the second field of view angle curve that is smaller than the minimum field of view angle is adjusted to the minimum field of view angle, thereby ensuring the second field of view angle curve obtained after adjustment. All the field of view angles are within the preset field of view range, thereby ensuring the video display effect.
在一些实施例中,根据第三视场角曲线对待处理视频进行防抖处理,包括:In some embodiments, anti-shake processing is performed on the video to be processed according to the third field of view curve, including:
得到第三视场角曲线之后,将第三视场角曲线与第二视场角曲线进行对比,用第三视场角曲线中的每一视场角与第二视场角取值中对应的视场角求差值,进而从所有差值中选择最大差值,并将第三视场角曲线中每一视场角减去该最大差值,实现对第三视场角曲线的整体滤波,实现对第三视场角曲线的平滑处理,以提高视频防抖效果。After obtaining the third field of view angle curve, compare the third field of view angle curve with the second field of view angle curve, and use each field angle in the third field of view angle curve to correspond to the value of the second field of view angle. Calculate the difference between the field of view angles, then select the maximum difference value from all the differences, and subtract the maximum difference value from each field of view angle in the third field of view angle curve to achieve the overall calculation of the third field of view angle curve. Filter to achieve smooth processing of the third field of view curve to improve the video anti-shake effect.
在通过上述实施例得到第三视场角曲线之后,还可根据第三视场角曲线对待处理视频进行防抖处理,在进行处理时,是根据第三视场角曲线中每一视场角与待处理视频帧中视频帧的对应关系,并将每一视频帧按照第三视场角曲线中的视场角进行旋转并裁剪,以得到处理后的视频。After obtaining the third field of view angle curve through the above embodiment, anti-shake processing can also be performed on the video to be processed according to the third field of view angle curve. During processing, each field of view angle in the third field of view angle curve is used for anti-shake processing. corresponding relationship with the video frames in the video frames to be processed, and each video frame is rotated and cropped according to the field of view angle in the third field of view angle curve to obtain the processed video.
由上述实施例中提及的内容可知,本申请实施例提供的方案,通过以每一参照帧为基准,确定该参照帧附近的多个抖动帧的防抖视场角,且在确定每一抖动帧的防抖视场角时,根据抖动帧距对应参照帧的距离确定其防抖视场角,当距离参照帧较近时,防抖视场角较小,当距离参照帧较远时,防抖视场角较大,其中,抖动帧与参照帧距离较近,说明抖动帧的抖动相对较大,而采用较小的防抖视场角不易造成视频内容出界,从而保证了视频显示效果,而当抖动帧与参照帧距离较远时,说明抖动帧的抖动相对较小,采用较大的防抖视场角能够提高防抖效果。再者,还通过对第二视场角曲线进行平滑滤波处理,使得防抖处理后的视频帧之间不会出现突兀的视场角变化,从而提高了视频质量。As can be seen from the content mentioned in the above embodiments, the solution provided by the embodiments of the present application uses each reference frame as a benchmark to determine the anti-shake field angles of multiple jitter frames near the reference frame, and determines each When the anti-shake field of view of a jitter frame is determined, its anti-shake field of view is determined based on the distance between the jitter frame and the corresponding reference frame. When it is closer to the reference frame, the anti-shake field of view is smaller. When it is farther from the reference frame, the anti-shake field of view is smaller. , the anti-shake field of view is large, and the distance between the jitter frame and the reference frame is relatively close, indicating that the jitter of the jitter frame is relatively large, and using a smaller anti-shake field of view will not easily cause the video content to go out of bounds, thus ensuring the video display Effect, and when the distance between the jitter frame and the reference frame is far, it means that the jitter of the jitter frame is relatively small, and using a larger anti-shake field of view can improve the anti-shake effect. Furthermore, by smoothing and filtering the second field of view curve, there will be no abrupt changes in field of view between video frames after anti-shake processing, thereby improving video quality.
在确定每一参照帧对应的抖动帧时,抖动帧之间会出现重叠现象,为避免对某一抖动帧反复确定防抖视场角,还可通过判断相邻参照帧之间的间隔是否较近,进而当相邻参照帧之间的间隔较近时,并不采用上述方式确定该相邻参照帧之间抖动帧的防抖视场角,具体如下:When determining the jitter frame corresponding to each reference frame, there will be overlap between the jitter frames. In order to avoid repeatedly determining the anti-shake field angle for a certain jitter frame, it can also be determined by judging whether the interval between adjacent reference frames is relatively large. Furthermore, when the distance between adjacent reference frames is relatively close, the above method is not used to determine the anti-shake field of view angle of the jitter frame between adjacent reference frames, as follows:
请参阅图5,图5为本申请实施例提供的视频的防抖处理方法的又一流程示意图,在一些实施例中,将待处理视频中出界角小于预设视场角的视频帧,确定为参照帧之后,该方法还包括: Please refer to Figure 5. Figure 5 is another schematic flowchart of a video anti-shake processing method provided by an embodiment of the present application. In some embodiments, the video frame whose out-of-bounds angle is smaller than the preset field of view angle in the video to be processed is determined. After setting the reference frame, the method also includes:
106、将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除第一类参照帧之外的参照帧确定为第二类参照帧;106. Determine the reference frame whose interval between two adjacent reference frames meets the second preset condition as the first type of reference frame, and determine the reference frame other than the first type of reference frame as the second type of reference frame;
107、若参照帧为第一类参照帧,则将相邻两个第一类参照帧之间的视频帧,确定为与相邻两个第一类参照帧对应的抖动帧;107. If the reference frame is a first-type reference frame, determine the video frame between two adjacent first-type reference frames as a jitter frame corresponding to the two adjacent first-type reference frames;
108、若参照帧为第二类参照帧,则执行根据参照帧的出界角和预设视场角,确定参照帧对应的抖动帧的数量m的步骤。108. If the reference frame is a second type reference frame, perform the step of determining the number m of dither frames corresponding to the reference frame based on the out-of-bounds angle and the preset field of view angle of the reference frame.
在该实施例中,将相邻两个参照帧之间的间隔较近的参照帧确定为第一类参照帧,而除第一类参照帧之外的参照帧视为第二类参照帧。比如,待处理视频中具有多个参照帧,每一参照帧的出界角小于预设视场角,而相邻两个参照帧之间可存在出界角不小于预设视场角的视频帧,也可不存在出界角不小于预设视场角的视频帧。In this embodiment, a reference frame that is closely spaced between two adjacent reference frames is determined as a first type of reference frame, and reference frames other than the first type of reference frame are considered as a second type of reference frame. For example, there are multiple reference frames in the video to be processed, and the out-of-bounds angle of each reference frame is smaller than the preset field of view angle, and there may be video frames between two adjacent reference frames whose out-of-bounds angle is not smaller than the preset field of view angle. There may also be no video frames whose out-of-boundary angle is not smaller than the preset field of view angle.
如图6所示,图6为本申请实施提供的参照帧的示意图。未填充的矩形表示参照帧,而具有斜线的矩形表示出界角不小于预设视场角的参照帧,其中,对参照帧进行排序,然后将每两个参照帧之间的间隔较近的参照帧确定为第一类参照帧,而每两个参照帧之间的间隔较远的参照帧视为第二类参照帧。As shown in Figure 6, Figure 6 is a schematic diagram of a reference frame provided by the implementation of this application. The unfilled rectangle represents the reference frame, and the rectangle with diagonal lines represents the reference frame whose out-of-bounds angle is not less than the preset field of view angle, where the reference frames are sorted, and then the closely spaced frames between each two reference frames are The reference frame is determined to be the first type of reference frame, and the reference frames that are far apart between each two reference frames are regarded as the second type of reference frame.
在一些实施例中,在步骤103之前,该方法还包括:In some embodiments, before step 103, the method further includes:
当参照帧为第一类参照帧时,则将相邻两个第一类参照帧之间的视频帧,确定为相邻两个第一类参照帧对应的抖动帧。可以理解地,该相邻两个第一类参照帧之间的抖动帧的出界角均不小于预设视场角。When the reference frame is a first-type reference frame, the video frame between two adjacent first-type reference frames is determined as a jitter frame corresponding to the two adjacent first-type reference frames. It can be understood that the out-of-boundary angle of the dithered frame between two adjacent first-type reference frames is not less than the preset field of view angle.
当参照帧为第二类参照帧时,则按照上述实施例中提及的方式:根据每一参照帧对应的出界角和预设视场角,确定参照帧对应的抖动帧的数量m,以及后续的步骤中提及的内容对第二类参照帧对应的抖动帧进行处理。具体内容参照上述实施例,此处不再赘述。When the reference frame is a second type of reference frame, the method mentioned in the above embodiment is followed: according to the out-of-boundary angle and the preset field of view angle corresponding to each reference frame, the number m of jitter frames corresponding to the reference frame is determined, and The contents mentioned in the subsequent steps process the jitter frames corresponding to the second type of reference frame. For specific details, refer to the above embodiments and will not be described again here.
在一些实施例中,将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除第一类参照帧之外的参照帧确定为第二类参照帧之前,方法还包括:In some embodiments, a reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as a first type of reference frame, and a reference frame other than the first type of reference frame is determined as a second type of reference frame. Before the class reference frame, the method also includes:
根据相邻两个参照帧的出界角和预设视场角,计算相邻两个参照帧之间的预测帧数,当预测帧数大于实际帧数时,判定相邻两个参照帧之间的间隔符合第二预设条件;Calculate the number of predicted frames between two adjacent reference frames based on the out-of-boundary angle and preset field of view angle of two adjacent reference frames. When the number of predicted frames is greater than the actual number of frames, determine the distance between two adjacent reference frames. The interval meets the second preset condition;
或者,当相邻两个参照帧之间的间隔不大于预设帧数时,判定相邻两个参照帧之间的间隔符合第二预设条件。Alternatively, when the interval between two adjacent reference frames is not greater than the preset number of frames, it is determined that the interval between two adjacent reference frames meets the second preset condition.
在该实施例中,可通过任意一种方式判断相邻两个参照帧之间的间隔是否符合第二预设条件,当符合时,将该相邻两个参照帧确定为第一类参照帧。In this embodiment, any method can be used to determine whether the interval between two adjacent reference frames meets the second preset condition. If it meets the second preset condition, the two adjacent reference frames are determined to be the first type of reference frame. .
在一实施例中,可根据相邻两个参照帧的出界角和预设视场角,计算相邻两个参照帧之间应该存在的视频帧的预测帧数,并将预测帧数与实际帧数进行比较,当预测帧数较大时,说明该相邻两个参照帧 之间的实际帧数较小,即该相邻两个参照帧之间的间隔符合第二预设条件,即间隔较小。In one embodiment, the predicted number of video frames that should exist between the two adjacent reference frames can be calculated based on the out-of-boundary angle and the preset field of view angle of the two adjacent reference frames, and the number of predicted frames and the actual number of frames can be calculated. Compare the number of frames. When the number of predicted frames is larger, it means that the two adjacent reference frames The actual number of frames between them is smaller, that is, the interval between the two adjacent reference frames meets the second preset condition, that is, the interval is smaller.
其中,根据出界角和预设视场角计算预测帧数的公式如下:
x=h·(2·FOVMAX-FOVn1-FOVn2)/f
Among them, the formula for calculating the number of predicted frames based on the out-of-bounds angle and the preset field of view angle is as follows:
x=h·(2·FOV MAX -FOV n1 -FOV n2 )/f
该公式中,x表示预测帧数,h表示系数,FOVmax表示预设视场角,FOVn1和FOVn2表示相邻的两个参照帧,f表示视场角变化率。其中,h可根据实际需求设定,比如,设定为1.5、2、3等数值。In this formula, x represents the number of predicted frames, h represents the coefficient, FOV max represents the preset field of view angle, FOV n1 and FOV n2 represent two adjacent reference frames, and f represents the rate of change of field of view angle. Among them, h can be set according to actual needs, for example, set to 1.5, 2, 3 and other values.
在另一实施例中,可将相邻两个参照帧之间的实际帧数与预设帧数进行对比,当实际帧数较小时,说明该相邻两个参照帧之间的间隔符合第二预设条件,即间隔较小。In another embodiment, the actual number of frames between two adjacent reference frames can be compared with the preset number of frames. When the actual number of frames is smaller, it means that the interval between the two adjacent reference frames meets the The second preset condition is that the interval is small.
其中,预设帧数可根据实际需求设定,还可为默认数值,比如40、50、60等。Among them, the preset frame number can be set according to actual needs, or it can also be a default value, such as 40, 50, 60, etc.
在又一实施例中,还可同时计算预测帧数,将预测帧数与预设帧数进行比较,从两者中选取最大值,之后将最大值与实际帧数进行比较,当实际帧数小于两者中的最大值时,判断两个相邻参照帧之间的间隔符合第二预设条件。In another embodiment, the number of predicted frames can also be calculated at the same time, the number of predicted frames is compared with the preset number of frames, the maximum value is selected from the two, and then the maximum value is compared with the actual number of frames. When the actual number of frames When it is less than the maximum value of the two, it is determined that the interval between two adjacent reference frames meets the second preset condition.
此处进行举例说明,比如,第1个参照帧(原视频第20帧)和第2个参照帧(原视频第25帧)为相邻两个参照帧,第1个参照帧和第2个参照帧之间的实际帧数为25-20=5,而预测帧数为x=(1.5*(2*100-99-98)/0.1)=45,其中,预测帧数为45,预设帧数为60,预测帧数<预设帧数,将实际帧数与预设帧数进行比较,可知实际帧数5小于预设帧数60,则视为第1个参照帧和第2个参照帧之间的间隔符合第二预设条件,第1个参照帧和第2个参照帧均为第一类参照帧。Here is an example. For example, the first reference frame (the 20th frame of the original video) and the second reference frame (the 25th frame of the original video) are two adjacent reference frames. The first reference frame and the second The actual number of frames between reference frames is 25-20=5, and the number of predicted frames is x=(1.5*(2*100-99-98)/0.1)=45, where the number of predicted frames is 45, and the default The number of frames is 60, the number of predicted frames < the preset number of frames, compare the actual number of frames with the preset number of frames, it can be seen that the actual number of frames 5 is less than the preset number of frames 60, then it is regarded as the first reference frame and the second The interval between the reference frames meets the second preset condition, and the first reference frame and the second reference frame are both first-type reference frames.
在一些实施例中,第一类参照帧对应的抖动帧为第一类抖动帧,第二类参照帧对应的抖动帧为第二类抖动帧;In some embodiments, the jitter frame corresponding to the first type of reference frame is the first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is the second type of jitter frame;
根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧的步骤,包括:According to the out-of-bounds angle of the video frame, the steps of determining the reference frame and the jitter frame corresponding to the reference frame from the video to be processed include:
根据第一类抖动帧对应的相邻两个第一类参照帧的出界角以及第一类抖动帧在子出界区中的帧序列,确定第一类抖动帧的防抖视场角,其中,子出界区由第一类抖动帧对应的相邻两个第一类参照帧之间的视频帧以及相邻两个第一类参照帧构成;According to the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the sub-out-of-bounds area, the anti-shake field of view angle of the first-type jitter frame is determined, where, The sub-out-of-bounds area is composed of the video frame between two adjacent first-category reference frames corresponding to the first-category jitter frame and the two adjacent first-category reference frames;
确定第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据间隔帧数和第二类抖动帧对应的第二类参照帧的出界角,确定第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type reference frame, and determine the anti-shake of the second type of jitter frame based on the number of interval frames and the out-of-boundary angle of the second type of reference frame corresponding to the second type of jitter frame Field of view.
在该实施例中,相邻两个第一参照帧及其之间的视频帧构成子出界区,在确定第一类参照帧对应的第一类抖动帧的防抖视场角时,是根据相邻两个第一抖动帧的出界角以及第一抖动帧在子出界区中的帧序列计算得到的,即第一类抖动帧的防抖视场角,与其相邻两个参照帧的出界角相关联。In this embodiment, two adjacent first reference frames and the video frames between them constitute a sub-out-of-bounds area. When determining the anti-shake field angle of the first type of shaking frame corresponding to the first type of reference frame, it is based on It is calculated from the out-of-boundary angles of two adjacent first jitter frames and the frame sequence of the first jitter frame in the sub-out-of-bounds area, that is, the anti-shake field angle of the first type of jitter frame, and the out-of-bounds angle of its two adjacent reference frames. Angles are associated.
而对于第二类参照帧对应的第二类抖动帧,则按照上述提及的方式确定每一第二类抖动帧的防抖视场角,具体可参照公式FOVm=FOVn+i×f,此处不再赘述。 For the second type of jitter frame corresponding to the second type of reference frame, the anti-shake field of view angle of each second type of jitter frame is determined according to the method mentioned above. For details, refer to the formula FOV m = FOV n +i×f , which will not be described again here.
请参阅图5,在一些实施例中,根据第一类抖动帧对应的相邻两个第一类参照帧的出界角以及第一类抖动帧在子出界区中的帧序列,确定第一类抖动帧的防抖视场角,包括:Please refer to Figure 5. In some embodiments, the first type of jitter frame is determined based on the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the sub-out-of-bounds area. The anti-shake field of view of the jitter frame includes:
1043、根据第一类抖动帧对应的相邻两个第一类参照帧的出界角和实际帧数,确定偏移系数;1043. Determine the offset coefficient based on the out-of-boundary angles and actual frame numbers of two adjacent first-type reference frames corresponding to the first-type jitter frame;
1044、根据偏移系数,以及第一类抖动帧在子出界区中的帧序列,确定第一类抖动帧的防抖偏移量;1044. Determine the anti-shake offset of the first type of jitter frame according to the offset coefficient and the frame sequence of the first type of jitter frame in the sub-outbound area;
1045、根据防抖偏移量和第一类抖动帧对应的相邻两个第一类参照帧的出界角,确定第一类抖动帧的防抖视场角。1045. Determine the anti-shake field of view angle of the first-type jitter frame based on the anti-shake offset and the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame.
在该实施例中,根据相邻两个第一类参照帧的出界角和实际帧数,确定偏移系数的公式如下:
a=(FOVn2-FOVn1)/(n2-n1)
In this embodiment, based on the out-of-boundary angles of two adjacent first-type reference frames and the actual number of frames, the formula for determining the offset coefficient is as follows:
a=(FOV n2 -FOV n1 )/(n 2 -n 1 )
该公式中,a表示偏移系数,FOVn1和FOVn2表示相邻的两个参照帧,n2-n1表示实际帧数。In this formula, a represents the offset coefficient, FOV n1 and FOV n2 represent two adjacent reference frames, and n 2 -n 1 represents the actual number of frames.
当得到偏移系数之后,可根据第一类抖动帧的帧序列和偏移系数确定其防抖偏移量,确定防抖偏移量为偏移系数和帧序列的乘积,其中,每一子出界区中按照顺序对第一类参照帧和第一类抖动帧进行排序,防抖偏移量的大小与第一类抖动帧在其对应的子出界区中的排序相关,当第一类抖动帧的帧序列越大时,第一类抖动帧的防抖偏移量越大,反之,防抖偏移量越小。After the offset coefficient is obtained, the anti-shake offset can be determined based on the frame sequence and offset coefficient of the first type of jitter frame. The anti-shake offset is determined as the product of the offset coefficient and the frame sequence, where each sub-frame The first type of reference frame and the first type of jitter frame are sorted in order in the out-of-bounds area. The size of the anti-shake offset is related to the sorting of the first type of jitter frame in its corresponding sub-out-of-bounds area. When the first type of jitter frame When the frame sequence of the frame is larger, the anti-shake offset of the first type of jitter frame is larger, and conversely, the anti-shake offset is smaller.
计算第一类抖动帧的防抖偏移量时,是以其对应的相邻两个第一类参照帧中的任意一个为基准计算防抖视场角的,而每一子出界区中的第一类抖动帧的防抖视场角呈等差序列。When calculating the anti-shake offset of a first-type jitter frame, the anti-shake field of view angle is calculated based on any one of its two adjacent adjacent first-type reference frames, and the anti-shake field angle in each sub-out-of-boundary area is calculated. The anti-shake field angles of the first type of jitter frames are in an arithmetic sequence.
比如,以每一子出界区中的第一个第一类参照帧为例,计算该子出界区中每一第一类抖动帧的防抖视场角的公式如下:
FOVn1+k=k·a+FOVn1
For example, taking the first type-I reference frame in each sub-out-of-bounds area as an example, the formula for calculating the anti-shake field angle of each type-I jitter frame in the sub-out-of-bounds area is as follows:
FOV n1+k =k·a+FOV n1
该公式中,k表示帧序列,k=1、2、…、n2-n1,FOVn1+k表示第一个第一类参照帧之后的第k个第一类抖动帧的防抖视场角,a表示偏移系数,k*a表示防抖偏移量,FOVn1表示第一个第一类参照帧的出界角。In this formula, k represents the frame sequence, k = 1, 2,..., n 2 -n 1 , FOV n1+k represents the anti-shake view of the k-th first-type jitter frame after the first first-type reference frame. Field angle, a represents the offset coefficient, k*a represents the anti-shake offset, and FOV n1 represents the out-of-bounds angle of the first first-type reference frame.
同理,也可根据子出界区中的第二个第一类参照帧计算该子出界区中每一第一类抖动帧的防抖视场角,此处不再赘述。In the same way, the anti-shake field angle of each first-type jitter frame in the sub-out-of-boundary area can also be calculated based on the second first-type reference frame in the sub-out-of-boundary area, which will not be described again here.
请参阅图7,图7为本申请实施例提供的视频的防抖处理方法中步骤107的流程示意图,在一些实施例中,对于第一类参照帧,将相邻两个第一类参照帧之间的视频帧,确定为与相邻两个第一类参照帧对应的抖动帧的步骤,包括:Please refer to Figure 7. Figure 7 is a schematic flowchart of step 107 in the video anti-shake processing method provided by the embodiment of the present application. In some embodiments, for the first type of reference frame, two adjacent first type reference frames are The step of determining the video frames between them as jitter frames corresponding to two adjacent first-type reference frames includes:
1071、对于第一类参照帧,将相邻两个第一类参照帧之间的视频帧以及相邻两个第一类参照帧确定为一个子出界区;1071. For the first type reference frame, determine the video frame between two adjacent first type reference frames and the two adjacent first type reference frames as a sub-out-of-bounds area;
1072、对于不存在相邻子出界区的子出界区,将子出界区内的两个第一类参照帧之间的视频帧,确 定为与两个第一类参照帧对应的抖动帧;1072. For a sub-out-of-bounds area that does not have adjacent sub-out-of-bounds areas, determine the video frame between the two first-type reference frames in the sub-out-of-bounds area. It is determined as the jitter frame corresponding to the two first-type reference frames;
1073、对于存在相邻子出界区的子出界区,将相邻的多个子出界区合并为一个出界区,并将出界区划分为至少一个区间段,区间段的长度大于子出界区的长度;1073. For sub-out-of-bounds areas with adjacent sub-out-of-bounds areas, merge the adjacent sub-out-of-bounds areas into one out-of-bounds area, and divide the out-of-bounds area into at least one interval segment, the length of the interval segment is greater than the length of the sub-out-of-bounds area;
1074、对于每一区间段,根据区间段内首尾两个第一类参照帧的出界角,计算首尾两个第一类参照帧之间的第一类参照帧的预测出界角;1074. For each interval segment, calculate the predicted out-of-boundary angle of the first-type reference frame between the first and last two first-type reference frames in the interval segment;
1075、若预测出界角小于实际出界角,则将首尾两个第一类参照帧之间的视频帧,确定为与首尾两个第一类参照帧对应的抖动帧。1075. If the predicted out-of-boundary angle is smaller than the actual out-of-bounds angle, determine the video frame between the first and last two first-type reference frames as the jitter frame corresponding to the first and last two first-type reference frames.
在此实施例中,当存在多个相邻的子出界区时,可将该多个相邻的子出界区合并为一个出界区,而每一出界区中的第一类参照帧的数量不少于3个,可以理解地,任意一个出界区的长度大于子出界区的长度,其中,子出界区中第一类参照帧的数量为2个。In this embodiment, when there are multiple adjacent sub-out-of-bounds areas, the multiple adjacent sub-out-of-bounds areas can be merged into one out-of-bounds area, and the number of first-type reference frames in each out-of-bounds area is not the same. Less than 3, it is understandable that the length of any out-of-bounds area is greater than the length of the sub-out-of-bounds area, where the number of first-type reference frames in the sub-out-of-bounds area is 2.
示例性地,可对出界区进行划分,以将一个出界区划分为至少一个区间段,每一区间段的长度大于子出界区的长度,即每个区间段中至少存在3个第一类参照帧。For example, the out-of-bounds area can be divided to divide an out-of-bounds area into at least one interval segment, and the length of each interval segment is greater than the length of the sub-out-of-bounds area, that is, there are at least 3 first-type references in each interval segment. frame.
其中,每一区间段可不重叠,也可重叠,也可对任意至少3个第一类参照帧进行排列组合。此处进行举例说明,比如,将多个相邻的子出界区合并为一个出界区之后,该子出界区中具有6个第一类参照帧,分别为(n1、n2、n3、n4、n5、n6),划分区间段时,若取(n1、n2、n3)和(n4、n5、n6)分别为一个区间段,则该两个区间段不重叠。若取(n1、n2、n3)、(n2、n3、n4)、(n3、n4、n5)、(n4、n5、n6)分别为一个区间段,则该4个区间段部分重叠。若取(n1、n2、n3)、(n2、n3、n4)、(n3、n4、n5)、(n4、n5、n6)、(n1、n5、n6)、(n2、n5、n6)、(n3、n5、n6)、(n1、n2、n4)、(n1、n2、n5)、(n1、n2、n6)、(n2、n3、n5)等分别为一个区间段,则该多个区间段是按照排列组合的方式选取的。具体实施例时,可视实际需求选择对区间段的划分方式以及区间段的长度,此处不再列举。Each interval segment may not overlap or may overlap, or any at least three first-type reference frames may be arranged and combined. Here is an example. For example, after multiple adjacent sub-out-of-bounds areas are merged into one out-of-bounds area, there are 6 first-type reference frames in the sub-out-of-bounds area, namely (n 1 , n 2 , n 3 , n 4 , n 5 , n 6 ), when dividing the interval segments, if (n 1 , n 2 , n 3 ) and (n 4 , n 5 , n 6 ) are taken as one interval segment respectively, then the two interval segments No overlap. If (n 1 , n 2 , n 3 ), (n 2 , n 3 , n 4 ), (n 3 , n 4 , n 5 ), (n 4 , n 5 , n 6 ) are taken as an interval segment respectively , then the four interval segments partially overlap. If we take (n 1 , n 2 , n 3 ), (n 2 , n 3 , n 4 ), (n 3 , n 4 , n 5 ), (n 4 , n 5 , n 6 ), (n 1 , n 5 , n 6 ), (n 2 , n 5 , n 6 ), (n 3 , n 5 , n 6 ), (n 1 , n 2 , n 4 ), (n 1 , n 2 , n 5 ) , (n 1 , n 2 , n 6 ), (n 2 , n 3 , n 5 ), etc. are each an interval segment, then the multiple interval segments are selected according to the arrangement and combination. In specific embodiments, the method of dividing the interval segments and the length of the interval segments may be selected based on actual requirements, which will not be listed here.
当得到区间段之后,则确定是否需要对该区间段中的视频帧进行调节,即需要确定该区间段中是否存在抖动帧。其中,具体的方式为:通过该区间段中首尾两个第一类参照帧的出界角,预测两者之间的第一类参照帧的预测出界角,并将该预测视场角与实际出界角进行对比,当预测出界角小于实际出界角时,则说明首尾两个第一类参照帧之间的距离较远,可将两者之间的视频帧确定为其对应的第一类抖动帧。此时,第一类抖动帧中既包括位于首尾两个第一类参照帧之间的第一类参照帧,也包括出界角不小于预设视场角的视频帧。After the interval segment is obtained, it is determined whether the video frames in the interval segment need to be adjusted, that is, it is necessary to determine whether there is a jitter frame in the interval segment. The specific method is: using the out-of-boundary angles of the first and last two first-type reference frames in the interval segment, predict the predicted out-of-boundary angle of the first-type reference frame between the two, and compare the predicted field of view angle with the actual out-of-bounds angle. When the predicted out-of-bounds angle is smaller than the actual out-of-bounds angle, it means that the distance between the first and last two first-type reference frames is far, and the video frame between the two can be determined as its corresponding first-type jitter frame . At this time, the first type of jitter frame includes not only the first type reference frame located between the first and last two first type reference frames, but also includes video frames whose out-of-bounds angle is not less than the preset field of view angle.
其中,当预测出界角不小于实际出界角时,说明首尾两个第一类参照帧之间的距离较近,两者之间不存在抖动帧,即两者之间的视频帧的出界角无需调节。Among them, when the predicted out-of-bounds angle is not less than the actual out-of-bounds angle, it means that the distance between the first and last two first-type reference frames is close, and there is no jitter frame between them, that is, the out-of-bounds angle of the video frame between the two does not need to be adjust.
在一些实施例中,第一类参照帧对应的抖动帧为第一类抖动帧,第二类参照帧对应的抖动帧为第二 类抖动帧;In some embodiments, the jitter frame corresponding to the first type of reference frame is the first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is the second type of jitter frame. Jitter-like frames;
根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角的步骤,包括:The steps of determining the anti-shake field of view angle of the shake frame based on the out-of-bounds angle of the reference frame corresponding to the shake frame include:
根据第一类抖动帧对应的首尾两个第一类参照帧的出界角以及第一类抖动帧在区间段内中的帧序列,确定第一类抖动帧的防抖视场角。The anti-shake field angle of the first-type jitter frame is determined based on the out-of-boundary angles of the first and last two first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame within the interval.
确定第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据间隔帧数和第二类抖动帧对应的第一参照帧的出界角,确定第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type reference frame, and determine the anti-shake visual angle of the second type of jitter frame based on the number of interval frames and the out-of-boundary angle of the first reference frame corresponding to the second type of jitter frame. Field angle.
在该实施例中,对区间段的第一类抖动帧的防抖视场角进行计算时,可参照上述实施例中的公式FOVn1+k=k·a+FOVn1,其中,每一区间段中的第一类抖动帧按照顺序排列,对于每一区间段中的第一类抖动帧,根据其在区间段中的帧序列和首尾两个第一类参照帧的出界角,计算得到第一类抖动帧的防抖偏移系数a,然后根据帧序列k和防抖偏移系数a得到防抖偏移量k*a,之后以位于首位的第一类参照帧为依据,或以位于尾部的第二类参照帧为依据,计算第一类抖动帧的防抖视场角。In this embodiment, when calculating the anti-shake field of view angle of the first type of jitter frame in the interval segment, reference can be made to the formula FOV n1+k =k·a+FOV n1 in the above embodiment, where, in each interval The first type of jitter frames in the segment are arranged in order. For the first type of jitter frame in each interval segment, the first type of jitter frame is calculated based on its frame sequence in the interval segment and the out-of-boundary angle of the first and last two first type reference frames. The anti-shake offset coefficient a of a type of jitter frame, and then the anti-shake offset k*a is obtained based on the frame sequence k and the anti-shake offset coefficient a, and then based on the first type of reference frame at the top, or based on the Based on the second type of reference frame at the tail, the anti-shake field of view of the first type of jitter frame is calculated.
可以理解地,当存在重叠的区间段时,对于重叠的第一类抖动帧,其最终的防抖视场角选择其对应的多个防抖视场角中的最小值,也可选择其对应的多个防抖视场角的平均值,具体参照上述实施例提及的内容,此处不再赘述。It can be understood that when there are overlapping intervals, for the overlapping first type of jitter frame, the final anti-shake field angle is selected from the minimum value of the corresponding multiple anti-shake field angles, or its corresponding For the average value of multiple anti-shake field angles, refer specifically to the content mentioned in the above embodiments, which will not be described again here.
对于计算第二类抖动帧的防抖视场角,可参照上述提及的内容,此处不再赘述。For calculating the anti-shake field angle of the second type of jitter frame, reference can be made to the above-mentioned content, which will not be described again here.
在一些实施例中,根据抖动帧的防抖视场角,对待处理视频进行防抖处理,包括:In some embodiments, anti-shake processing is performed on the video to be processed according to the anti-shake field of view of the jitter frame, including:
从第一类抖动帧中确定出防抖视场角不大于出界角的第一类目标抖动帧,从第二类抖动帧中确定出防抖视场角不大于出界角的第二类目标抖动帧;Determine the first type of target jitter frame whose anti-shake field angle is not larger than the out-of-bounds angle from the first type of jitter frame, and determine the second type of target jitter whose anti-shake field angle is not larger than the out-of-bounds angle from the second type of jitter frame frame;
根据第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角,对待处理视频进行防抖处理。According to the anti-shake field of view of the first type of target jitter frame and the anti-shake field of view of the second type of target jitter frame, anti-shake processing is performed on the video to be processed.
以上述实施例提及的内容为参照,同理,从第一类抖动帧中确定出防抖视场角不大于出界角的第一类目标抖动帧,以根据第一类目标抖动帧的防抖视场角对第一类抖动帧进行防抖处理,从第二类抖动帧中确定出防抖视场角不大于出界角的第二类目标抖动帧,以根据第二类目标抖动帧的防抖视场角对第二类目标抖动帧进行防抖处理。Taking the content mentioned in the above embodiment as a reference, similarly, the first type target jitter frame whose anti-shake field angle is not larger than the out-of-bounds angle is determined from the first type of jitter frame, so as to determine the anti-shake frame according to the first type of target jitter frame. The jitter field of view is used to perform anti-shake processing on the first type of jitter frame, and the second type of target jitter frame whose anti-shake field of view angle is not greater than the out-of-bounds angle is determined from the second type of jitter frame, so as to determine the jitter frame according to the second type of target jitter frame. The anti-shake field of view performs anti-shake processing on the second type of target jitter frames.
当防抖视场角大于出界角时,则不将该抖动帧的出界角调整为防抖视场角,从而避免了因对抖动帧的调节幅度过大,造成视频内容的缺失,从而保证了视频质量。When the anti-shake field of view angle is greater than the out-of-bounds angle, the out-of-bounds angle of the jitter frame is not adjusted to the anti-shake field of view angle, thereby avoiding the loss of video content due to excessive adjustment of the jitter frame, thereby ensuring Video quality.
在一些实施例中,根据第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角,对待处理视频进行防抖处理,包括:In some embodiments, based on the anti-shake field of view of the first type of target jitter frame and the anti-shake field of view of the second type of target jitter frame, anti-shake processing is performed on the video to be processed, including:
根据第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角,对第一视场角曲线进行角 度变换处理,得到第二视场角曲线,其中,第一视场角曲线是根据待处理视频中每一视频帧的出界角构建的;According to the anti-shake field of view angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame, the first field of view angle curve is angled. Degree transformation processing to obtain a second field of view angle curve, where the first field of view angle curve is constructed based on the out-of-bounds angle of each video frame in the video to be processed;
根据预设视场角区间,对第二视场角曲线中处于预设视场角区间以外的出界角进行调节,得到第三视场角曲线;According to the preset viewing angle interval, adjust the out-of-boundary angle in the second viewing angle curve that is outside the preset viewing angle interval to obtain a third viewing angle curve;
根据第三视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the third field of view curve.
当得到第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角后,可将第一视场角曲线中与第一类目标抖动帧对应的出界角调整为该第一类目标抖动帧的防抖视场角,将与第二类目标抖动帧对应的出界角调整为该第二类目标抖动帧的防抖视场角,从而得到第二视场角曲线。After obtaining the anti-shake field of view angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame, the out-of-bounds angle corresponding to the first type of target jitter frame in the first field of view angle curve can be adjusted is the anti-shake field of view angle of the jitter frame of the first type of target, and adjusts the out-of-bounds angle corresponding to the jitter frame of the second type of target to the anti-shake field of view angle of the jitter frame of the second type of target, thereby obtaining the second field of view angle curve.
如上述实施例提及的内容,可通过预设视场角区间对第二视场角曲线进行处理,使得第三视场角曲线中的所有视场角均处于预设视场角区间,进而保证视频的显示效果。As mentioned in the above embodiments, the second field of view angle curve can be processed through the preset field of view angle interval, so that all the field of view angles in the third field of view angle curve are within the preset field of view angle interval, and then Ensure the video display effect.
在一些实施例中,根据预设视场角区间,对第二视场角曲线中处于预设视场角区间以外的出界角进行调节之前,还包括:In some embodiments, before adjusting the out-of-view angle in the second viewing angle curve that is outside the preset viewing angle interval according to the preset viewing angle interval, the method further includes:
通过移动平均滤波器对第二视场角曲线进行迭代平滑滤波处理,直至满足第一预设条件,得到第三视场角曲线;Perform iterative smoothing filtering processing on the second field of view angle curve through a moving average filter until the first preset condition is met, and a third field of view angle curve is obtained;
根据第三视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the third field of view curve.
在一些实施例中,根据第三视场角曲线对待处理视频进行防抖处理,包括:In some embodiments, anti-shake processing is performed on the video to be processed according to the third field of view curve, including:
得到第三视场角曲线之后,将第三视场角曲线与第二视场角曲线进行对比,用第三视场角曲线中的每一视场角与第二视场角取值中对应的视场角求差值,进而从所有差值中选择最大差值,并将第三视场角曲线中每一视场角减去该最大差值。After obtaining the third field of view angle curve, compare the third field of view angle curve with the second field of view angle curve, and use each field angle in the third field of view angle curve to correspond to the value of the second field of view angle. Calculate the difference between the field of view angles, select the maximum difference value from all the differences, and subtract the maximum difference value from each field of view angle in the third field of view angle curve.
由上可知,本发明实施例提出的视频的防抖处理方法,能够通过获取拍摄装置拍摄待处理视频时的运动轨迹,并根据运动轨迹得到待处理视频中视频帧的出界角,从而根据出界角从待处理视频中确定出参照帧,以及参照帧对应的抖动帧,实现了从待处理视频中确定出在拍摄装置运动时发生了抖动的抖动帧,并根据抖动帧的运动情况适应性地调节该抖动帧的出界角,使得调节后的抖动帧的出界角能够适应拍摄装置的运动变化,即在运动变化小的情况下使用较大的角度,保证了视场角的利用率,在运动变化大的情况下使用较小的角度,提供防抖效果,再者,还通过对视场角曲线进行平滑处理,使相邻帧之间的不会出现突兀的角度变化。以此,在兼顾防抖效果和视频内容利用率的同时,也保证了对视场角的利用率的合理化,保证了视频显示效果,提高了视频质量。It can be seen from the above that the video anti-shake processing method proposed by the embodiment of the present invention can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle according to the out-of-bounds angle. Determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed, realize the jitter frame that jitters occur when the shooting device moves from the video to be processed, and adaptively adjust according to the movement of the jitter frame The out-of-bounds angle of the jitter frame enables the adjusted out-of-bounds angle of the jitter frame to adapt to the motion changes of the shooting device, that is, when the motion changes are small, a larger angle is used to ensure the utilization of the field of view angle. In large situations, a smaller angle is used to provide an anti-shake effect. Furthermore, the field of view angle curve is smoothed so that there will be no abrupt angle changes between adjacent frames. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
在一实施例中还提供一种视频的防抖处理装置200。请参阅图8,图8为本申请实施例提供的视频的防抖处理装置200的结构示意图。其中该视频的防抖处理装置200应用于电子设备,该视频的防抖处理装 置200包括:In one embodiment, a video anti-shake processing device 200 is also provided. Please refer to FIG. 8 , which is a schematic structural diagram of a video anti-shake processing device 200 provided by an embodiment of the present application. The video anti-shake processing device 200 is applied to electronic equipment, and the video anti-shake processing device 200 Set 200 includes:
第一数据获取模块201,用于获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹;The first data acquisition module 201 is used to acquire the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
第二数据获取模块202,用于根据运动轨迹,获取待处理视频中视频帧的出界角;The second data acquisition module 202 is used to obtain the out-of-bounds angle of the video frame in the video to be processed according to the motion trajectory;
视频处理模块203,用于根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧;The video processing module 203 is used to determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame;
视场角计算模块204,用于根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角;The field of view calculation module 204 is used to determine the anti-shake field of view angle of the jitter frame based on the out-of-bounds angle of the reference frame corresponding to the jitter frame;
防抖处理模块205,用于根据抖动帧的防抖视场角,对待处理视频进行防抖处理。The anti-shake processing module 205 is used to perform anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame.
在一些实施例中,视频处理模块203还用于:In some embodiments, the video processing module 203 is also used to:
将待处理视频中出界角小于预设视场角的视频帧,确定为参照帧;Determine the video frame whose out-of-bounds angle is smaller than the preset field of view angle in the video to be processed as the reference frame;
根据参照帧的出界角和预设视场角,确定参照帧对应的抖动帧的数量m;According to the out-of-boundary angle and the preset field of view angle of the reference frame, determine the number m of jitter frames corresponding to the reference frame;
将位于参照帧之前的m个视频帧以及位于参照帧之后的m个视频帧,确定为参照帧对应的抖动帧。The m video frames located before the reference frame and the m video frames located after the reference frame are determined as jitter frames corresponding to the reference frame.
在一些实施例中,视场角计算模块204还用于:In some embodiments, the field of view calculation module 204 is also used to:
确定抖动帧与其对应的参照帧的间隔帧数;Determine the number of frames between the jitter frame and its corresponding reference frame;
根据间隔帧数和抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角。According to the number of interval frames and the out-of-boundary angle of the reference frame corresponding to the jitter frame, the anti-shake field of view angle of the jitter frame is determined.
在一些实施例中,防抖处理模块205还用于:In some embodiments, the anti-shake processing module 205 is also used to:
根据抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,其中,第一视场角曲线是根据待处理视频中每一视频帧的出界角构建的;According to the anti-shake field of view of the shake frame, the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where the first field of view angle curve is based on the out-of-bounds value of each video frame in the video to be processed. angularly constructed;
根据第二视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the second field of view curve.
在一些实施例中,防抖处理模块205还用于:In some embodiments, the anti-shake processing module 205 is also used to:
通过移动平均滤波器对第二视场角曲线进行迭代平滑滤波处理,直至满足第一预设条件,得到第三视场角曲线;Perform iterative smoothing filtering processing on the second field of view angle curve through a moving average filter until the first preset condition is met, and a third field of view angle curve is obtained;
根据第三视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the third field of view curve.
在一些实施例中,视场角计算模块204还用于:In some embodiments, the field of view calculation module 204 is also used to:
将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除第一类参照帧之外的参照帧确定为第二类参照帧;Determine the reference frame whose interval between two adjacent reference frames meets the second preset condition as the first type of reference frame, and determine the reference frame other than the first type of reference frame as the second type of reference frame;
若参照帧为第一类参照帧,则将相邻两个第一类参照帧之间的视频帧,确定为与相邻两个第一类参照帧对应的抖动帧;If the reference frame is a first-type reference frame, then the video frame between two adjacent first-type reference frames is determined as a jitter frame corresponding to the two adjacent first-type reference frames;
若参照帧为第二类参照帧,则执行根据参照帧的出界角和预设视场角,确定参照帧对应的抖动帧的数量m的步骤。 If the reference frame is a second type of reference frame, then perform the step of determining the number m of jitter frames corresponding to the reference frame based on the out-of-boundary angle and the preset field of view angle of the reference frame.
在一些实施例中,将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除第一类参照帧之外的参照帧确定为第二类参照帧之前,视场角计算模块204还用于:In some embodiments, a reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as a first type of reference frame, and a reference frame other than the first type of reference frame is determined as a second type of reference frame. Before the class reference frame, the field of view angle calculation module 204 is also used to:
根据相邻两个参照帧的出界角和预设视场角,计算相邻两个参照帧之间的预测帧数,当预测帧数大于实际帧数时,判定相邻两个参照帧之间的间隔符合第二预设条件;Calculate the number of predicted frames between two adjacent reference frames based on the out-of-boundary angle and preset field of view angle of two adjacent reference frames. When the number of predicted frames is greater than the actual number of frames, determine the distance between two adjacent reference frames. The interval meets the second preset condition;
或者,当相邻两个参照帧之间的间隔不大于预设帧数时,判定相邻两个参照帧之间的间隔符合第二预设条件。Alternatively, when the interval between two adjacent reference frames is not greater than the preset number of frames, it is determined that the interval between two adjacent reference frames meets the second preset condition.
在一些实施例中,第一类参照帧对应的抖动帧为第一类抖动帧,第二类参照帧对应的抖动帧为第二类抖动帧;In some embodiments, the jitter frame corresponding to the first type of reference frame is the first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is the second type of jitter frame;
视场角计算模块204还用于:The field of view calculation module 204 is also used to:
根据第一类抖动帧对应的相邻两个第一类参照帧的出界角以及第一类抖动帧在子出界区中的帧序列,确定第一类抖动帧的防抖视场角,其中,子出界区由第一类抖动帧对应的相邻两个第一类参照帧之间的视频帧以及相邻两个第一类参照帧构成;According to the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the sub-out-of-bounds area, the anti-shake field of view angle of the first-type jitter frame is determined, where, The sub-out-of-bounds area is composed of the video frame between two adjacent first-category reference frames corresponding to the first-category jitter frame and the two adjacent first-category reference frames;
确定第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据间隔帧数和第二类抖动帧对应的第二类参照帧的出界角,确定第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type reference frame, and determine the anti-shake of the second type of jitter frame based on the number of interval frames and the out-of-boundary angle of the second type of reference frame corresponding to the second type of jitter frame Field of view.
在一些实施例中,视场角计算模块204还用于:In some embodiments, the field of view calculation module 204 is also used to:
根据第一类抖动帧对应的相邻两个第一类参照帧的出界角和实际帧数,确定偏移系数;Determine the offset coefficient based on the out-of-boundary angles and actual frame numbers of two adjacent first-type reference frames corresponding to the first-type jitter frame;
根据偏移系数,以及第一类抖动帧在子出界区中的帧序列,确定第一类抖动帧的防抖偏移量;Determine the anti-shake offset of the first type of jitter frame according to the offset coefficient and the frame sequence of the first type of jitter frame in the sub-outbound area;
根据防抖偏移量和第一类抖动帧对应的相邻两个第一类参照帧的出界角,确定第一类抖动帧的防抖视场角。The anti-shake field of view angle of the first-type jitter frame is determined based on the anti-shake offset and the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame.
在一些实施例中,视场角计算模块204还用于:In some embodiments, the field of view calculation module 204 is also used to:
对于第一类参照帧,将相邻两个第一类参照帧之间的视频帧以及相邻两个第一类参照帧确定为一个子出界区;For the first type of reference frame, the video frame between two adjacent first type reference frames and the two adjacent first type reference frames are determined as a sub-out-of-bounds area;
对于不存在相邻子出界区的子出界区,将子出界区内的两个第一类参照帧之间的视频帧,确定为与两个第一类参照帧对应的抖动帧;For a sub-out-of-bounds area that does not have adjacent sub-out-of-bounds areas, determine the video frame between two first-type reference frames in the sub-out-of-bounds area as a jitter frame corresponding to the two first-type reference frames;
对于存在相邻子出界区的子出界区,将相邻的多个子出界区合并为一个出界区,并将出界区划分为至少一个区间段,区间段的长度大于子出界区的长度;For sub-out-of-bounds areas with adjacent sub-out-of-bounds areas, merge the adjacent sub-out-of-bounds areas into one out-of-bounds area, and divide the out-of-bounds area into at least one interval segment, the length of which is greater than the length of the sub-out-of-bounds area;
对于每一区间段,根据区间段内首尾两个第一类参照帧的出界角,计算首尾两个第一类参照帧之间的第一类参照帧的预测出界角;For each interval segment, calculate the predicted out-of-bounds angle of the first-type reference frame between the first and last two first-type reference frames in the interval segment;
若预测出界角小于实际出界角,则将首尾两个第一类参照帧之间视频帧,确定为与首尾两个第一类 参照帧对应的抖动帧。If the predicted out-of-boundary angle is smaller than the actual out-of-bounds angle, the video frame between the first and last two first-category reference frames is determined to be the same as the first and last two first-category reference frames. The jitter frame corresponding to the reference frame.
在一些实施例中,第一类参照帧对应的抖动帧为第一类抖动帧,第二类参照帧对应的抖动帧为第二类抖动帧;In some embodiments, the jitter frame corresponding to the first type of reference frame is the first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is the second type of jitter frame;
视场角计算模块204还用于:The field of view calculation module 204 is also used to:
根据第一类抖动帧对应的首尾两个第一类参照帧的出界角以及第一类抖动帧在区间段内中的帧序列,确定第一类抖动帧的防抖视场角。The anti-shake field angle of the first-type jitter frame is determined based on the out-of-boundary angles of the first and last two first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame within the interval.
确定第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据间隔帧数和第二类抖动帧对应的第一参照帧的出界角,确定第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type reference frame, and determine the anti-shake visual angle of the second type of jitter frame based on the number of interval frames and the out-of-boundary angle of the first reference frame corresponding to the second type of jitter frame. Field angle.
在一些实施例中,防抖处理模块205还用于:In some embodiments, the anti-shake processing module 205 is also used to:
从第一类抖动帧中确定出防抖视场角不大于出界角的第一类目标抖动帧,从第二类抖动帧中确定出防抖视场角不大于出界角的第二类目标抖动帧;Determine the first type of target jitter frame whose anti-shake field angle is not larger than the out-of-bounds angle from the first type of jitter frame, and determine the second type of target jitter whose anti-shake field angle is not larger than the out-of-bounds angle from the second type of jitter frame frame;
根据第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角,对待处理视频进行防抖处理。According to the anti-shake field of view of the first type of target jitter frame and the anti-shake field of view of the second type of target jitter frame, anti-shake processing is performed on the video to be processed.
在一些实施例中,防抖处理模块205还用于:In some embodiments, the anti-shake processing module 205 is also used to:
根据第一类目标抖动帧的防抖视场角和第二类目标抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,其中,第一视场角曲线是根据待处理视频中每一视频帧的出界角构建的;According to the anti-shake field angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame, the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve, where, A field of view curve is constructed based on the out-of-bounds angle of each video frame in the video to be processed;
根据预设视场角区间,对第二视场角曲线中处于预设视场角区间以外的出界角进行调节,得到第三视场角曲线;According to the preset viewing angle interval, adjust the out-of-boundary angle in the second viewing angle curve that is outside the preset viewing angle interval to obtain a third viewing angle curve;
根据第三视场角曲线对待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the third field of view curve.
应当说明的是,本申请实施例提供的视频的防抖处理装置200与上文实施例中的视频的防抖处理方法属于同一构思,通过该视频的防抖处理装置200可以实现视频的防抖处理方法实施例中提供的任一方法,其具体实现过程详见视频的防抖处理方法实施例,此处不再赘述。It should be noted that the video anti-shake processing device 200 provided by the embodiment of the present application belongs to the same concept as the video anti-shake processing method in the above embodiment, and the video anti-shake processing device 200 can achieve video anti-shake. For any method provided in the processing method embodiment, the specific implementation process can be found in the video anti-shake processing method embodiment, and will not be described again here.
由上可知,本申请实施例提出的视频的防抖处理装置,能够通过获取拍摄装置拍摄待处理视频时的运动轨迹,并根据运动轨迹得到待处理视频中视频帧的出界角,从而根据出界角从待处理视频中确定出参照帧,以及参照帧对应的抖动帧,实现了从待处理视频中确定出在拍摄装置运动时发生了抖动的抖动帧,并根据抖动帧的运动情况适应性地调节该抖动帧的出界角,使得调节后的抖动帧的出界角能够适应拍摄装置的运动变化,即在运动变化小的情况下使用较大的角度,保证了视场角的利用率,在运动变化大的情况下使用较小的角度,提供防抖效果,再者,还通过对视场角曲线进行平滑处理,使相邻帧之间 的不会出现突兀的角度变化。以此,在兼顾防抖效果和视频内容利用率的同时,也保证了对视场角的利用率的合理化,保证了视频显示效果,提高了视频质量。It can be seen from the above that the video anti-shake processing device proposed in the embodiment of the present application can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle according to the out-of-bounds angle. Determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed, realize the jitter frame that jitters occur when the shooting device moves from the video to be processed, and adaptively adjust according to the movement of the jitter frame The out-of-bounds angle of the jitter frame enables the adjusted out-of-bounds angle of the jitter frame to adapt to the motion changes of the shooting device, that is, when the motion changes are small, a larger angle is used to ensure the utilization of the field of view angle. In large situations, a smaller angle is used to provide an anti-shake effect. Furthermore, the field of view curve is smoothed to smooth the gap between adjacent frames. There will be no abrupt angle changes. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
本申请实施例还提供一种电子设备,该电子设备可以是智能手机、平板电脑、掌上电脑、电视机、电影机、相机、摄像机、飞行器等设备。如图9所示,图9为本申请实施例提供的电子设备的结构示意图。该电子设备300包括有一个或者一个以上处理核心的处理器301、有一个或一个以上计算机可读存储介质的存储器302及存储在存储器302上并可在处理器上运行的计算机程序。其中,处理器301与存储器302电性连接。本领域技术人员可以理解,图中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。An embodiment of the present application also provides an electronic device. The electronic device may be a smart phone, a tablet computer, a handheld computer, a television, a movie player, a camera, a camcorder, an aircraft, or other equipment. As shown in Figure 9, Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device 300 includes a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, and a computer program stored on the memory 302 and executable on the processor. Among them, the processor 301 is electrically connected to the memory 302. Those skilled in the art can understand that the structure of the electronic device shown in the figures does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figures, or combine certain components, or arrange different components.
处理器301是电子设备300的控制中心,利用各种接口和线路连接整个电子设备300的各个部分,通过运行或加载存储在存储器302内的软件程序和/或模块,以及调用存储在存储器302内的数据,执行电子设备300的各种功能和处理数据,从而对电子设备300进行整体监控。The processor 301 is the control center of the electronic device 300, using various interfaces and lines to connect various parts of the entire electronic device 300, by running or loading software programs and/or modules stored in the memory 302, and calling the software programs and/or modules stored in the memory 302. data, perform various functions of the electronic device 300 and process the data, thereby overall monitoring the electronic device 300 .
在本申请实施例中,电子设备300中的处理器301会按照如下的步骤,将一个或一个以上的应用程序的进程对应的指令加载到存储器302中,并由处理器301来运行存储在存储器302中的应用程序,从而实现各种功能:In this embodiment of the present application, the processor 301 in the electronic device 300 will follow the following steps to load instructions corresponding to the processes of one or more application programs into the memory 302, and the processor 301 will run the instructions stored in the memory. 302 applications to achieve various functions:
获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹;Obtain the video to be processed and the movement trajectory of the shooting device when shooting the video to be processed;
根据运动轨迹,获取待处理视频中视频帧的出界角;According to the motion trajectory, obtain the out-of-bounds angle of the video frame in the video to be processed;
根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧;According to the out-of-bounds angle of the video frame, determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角;Determine the anti-shake field of view angle of the jitter frame according to the out-of-bounds angle of the reference frame corresponding to the jitter frame;
根据抖动帧的防抖视场角,对待处理视频进行防抖处理。According to the anti-shake field of view of the shake frame, anti-shake processing is performed on the video to be processed.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For the specific implementation of each of the above operations, please refer to the previous embodiments and will not be described again here.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above embodiments, each embodiment is described with its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
由上可知,本实施例提供的电子设备,能够通过获取拍摄装置拍摄待处理视频时的运动轨迹,并根据运动轨迹得到待处理视频中视频帧的出界角,从而根据出界角从待处理视频中确定出参照帧,以及参照帧对应的抖动帧,实现了从待处理视频中确定出在拍摄装置运动时发生了抖动的抖动帧,并根据抖动帧的运动情况适应性地调节该抖动帧的出界角,使得调节后的抖动帧的出界角能够适应拍摄装置的运动变化,即在运动变化小的情况下使用较大的角度,保证了视场角的利用率,在运动变化大的情况下使用较小的角度,提供防抖效果,再者,还通过对视场角曲线进行平滑处理,使相邻帧之间的不会出现突兀 的角度变化。以此,在兼顾防抖效果和视频内容利用率的同时,也保证了对视场角的利用率的合理化,保证了视频显示效果,提高了视频质量。It can be seen from the above that the electronic device provided in this embodiment can obtain the motion trajectory of the shooting device when shooting the video to be processed, and obtain the out-of-bounds angle of the video frame in the video to be processed based on the motion trajectory, so as to obtain the out-of-bounds angle from the video to be processed based on the out-of-bounds angle. Determining the reference frame and the jitter frame corresponding to the reference frame realizes the determination of the jitter frame that jittered when the shooting device moved from the video to be processed, and adaptively adjusts the out-of-bounds of the jitter frame according to the movement of the jitter frame. angle, so that the adjusted out-of-bounds angle of the jitter frame can adapt to the motion changes of the shooting device, that is, use a larger angle when the motion changes are small, ensuring the utilization of the field of view angle, and use it when the motion changes are large A smaller angle provides an anti-shake effect. Furthermore, by smoothing the field of view curve, there will be no abrupt blur between adjacent frames. angle changes. In this way, while taking into account the anti-shake effect and video content utilization, it also ensures the rational utilization of the field of view, ensures the video display effect, and improves the video quality.
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过指令来完成,或通过指令控制相关的硬件来完成,该指令可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. The instructions can be stored in a computer-readable storage medium, and loaded and executed by the processor.
为此,本申请实施例提供一种计算机可读存储介质,本领域普通技术人员可以理解实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件完成,的程序可以存储于一计算机可读取存储介质中,该程序在执行时,包括如下步骤:To this end, embodiments of the present application provide a computer-readable storage medium. Persons of ordinary skill in the art can understand that all or part of the steps in the method of implementing the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in In a computer-readable storage medium, when the program is executed, it includes the following steps:
获取待处理视频,以及拍摄待处理视频时拍摄装置的运动轨迹;Obtain the video to be processed and the movement trajectory of the shooting device when shooting the video to be processed;
根据运动轨迹,获取待处理视频中视频帧的出界角;According to the motion trajectory, obtain the out-of-bounds angle of the video frame in the video to be processed;
根据视频帧的出界角,从待处理视频中确定出参照帧以及参照帧对应的抖动帧;According to the out-of-bounds angle of the video frame, determine the reference frame and the jitter frame corresponding to the reference frame from the video to be processed;
根据抖动帧对应的参照帧的出界角,确定抖动帧的防抖视场角;Determine the anti-shake field of view angle of the jitter frame according to the out-of-bounds angle of the reference frame corresponding to the jitter frame;
根据抖动帧的防抖视场角,对待处理视频进行防抖处理。According to the anti-shake field of view of the shake frame, anti-shake processing is performed on the video to be processed.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For the specific implementation of each of the above operations, please refer to the previous embodiments and will not be described again here.
上述的存储介质可以为ROM/RAM、磁碟、光盘等。由于该存储介质中所存储的计算机程序,可以执行本申请实施例所提供的任一种视频的防抖处理方法中的步骤,因此,可以实现本申请实施例所提供的任一种视频的防抖处理方法所能实现的有益效果,详见前面的实施例,在此不再赘述。The above-mentioned storage media can be ROM/RAM, magnetic disk, optical disk, etc. Since the computer program stored in the storage medium can execute the steps in any video anti-shake processing method provided by the embodiments of the present application, it is possible to realize the anti-shake processing method of any video provided by the embodiments of the present application. The beneficial effects that can be achieved by the dither processing method are detailed in the previous embodiments and will not be described again here.
以上对本申请实施例所提供的一种视频的防抖处理方法、装置、介质及电子设备进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。 The above is a detailed introduction to a video anti-shake processing method, device, medium and electronic equipment provided by the embodiments of the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The above embodiments The description is only used to help understand the methods and core ideas of the present application; at the same time, for those skilled in the art, there will be changes in the specific implementation and application scope based on the ideas of the present application. In summary, this specification The contents should not be construed as limitations on this application.

Claims (16)

  1. 一种视频的防抖处理方法,其特征在于,所述方法包括:A video anti-shake processing method, characterized in that the method includes:
    获取待处理视频,以及拍摄所述待处理视频时拍摄装置的运动轨迹;Obtain the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
    根据所述运动轨迹,获取所述待处理视频中视频帧的出界角;According to the motion trajectory, obtain the out-of-bounds angle of the video frame in the video to be processed;
    根据所述视频帧的出界角,从所述待处理视频中确定出参照帧以及所述参照帧对应的抖动帧;According to the out-of-bounds angle of the video frame, determine a reference frame and a jitter frame corresponding to the reference frame from the video to be processed;
    根据所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角;Determine the anti-shake field of view angle of the shake frame according to the out-of-boundary angle of the reference frame corresponding to the shake frame;
    根据所述抖动帧的防抖视场角,对所述待处理视频进行防抖处理。Anti-shake processing is performed on the video to be processed according to the anti-shake field of view of the shake frame.
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述视频帧的出界角,从所述待处理视频中确定出参照帧以及所述参照帧对应的抖动帧的步骤,包括:The method according to claim 1, wherein the step of determining a reference frame and a jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame includes:
    将所述待处理视频中出界角小于预设视场角的视频帧,确定为参照帧;Determine the video frame whose out-of-bounds angle is smaller than the preset field of view angle in the video to be processed as a reference frame;
    根据所述参照帧的出界角和所述预设视场角,确定所述参照帧对应的抖动帧的数量m;Determine the number m of dither frames corresponding to the reference frame according to the out-of-bounds angle of the reference frame and the preset field of view angle;
    将位于所述参照帧之前的m个视频帧以及位于所述参照帧之后的m个视频帧,确定为所述参照帧对应的抖动帧。The m video frames located before the reference frame and the m video frames located after the reference frame are determined as jitter frames corresponding to the reference frame.
  3. 根据权利要求1所述的方法,其特征在于,所述根据所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角的步骤,包括:The method according to claim 1, wherein the step of determining the anti-shake field angle of the shake frame based on the out-of-boundary angle of the reference frame corresponding to the shake frame includes:
    确定所述抖动帧与其对应的参照帧的间隔帧数;Determine the number of frames between the jitter frame and its corresponding reference frame;
    根据所述间隔帧数和所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角。The anti-shake field of view angle of the shake frame is determined according to the number of interval frames and the out-of-boundary angle of the reference frame corresponding to the shake frame.
  4. 根据权利要求1所述的方法,其特征在于,所述根据所述抖动帧的防抖视场角,对所述待处理视频进行防抖处理的步骤,包括:The method according to claim 1, wherein the step of performing anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame includes:
    根据所述抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,其中,所述第一视场角曲线是根据所述待处理视频中每一视频帧的出界角构建的;According to the anti-shake field of view of the shake frame, perform angle transformation processing on the first field of view curve to obtain a second field of view curve, wherein the first field of view angle curve is based on the video to be processed. Constructed from the out-of-bounds angle of each video frame;
    根据所述第二视场角曲线对所述待处理视频进行防抖处理。Perform anti-shake processing on the video to be processed according to the second field of view curve.
  5. 根据权利要求4所述的方法,其特征在于,所述根据所述第二视场角曲线对所述待处理视频进行防抖处理的步骤,包括:The method of claim 4, wherein the step of performing anti-shake processing on the video to be processed according to the second field of view curve includes:
    通过移动平均滤波器对所述第二视场角曲线进行迭代平滑滤波处理,直至满足第一预设条件,得到第三视场角曲线;Perform iterative smoothing filtering processing on the second field of view angle curve through a moving average filter until the first preset condition is met, and a third field of view angle curve is obtained;
    根据所述第三视场角曲线对所述待处理视频进行防抖处理。Anti-shake processing is performed on the video to be processed according to the third field of view curve.
  6. 根据权利要求2所述的方法,其特征在于,所述将所述待处理视频中出界角小于预设视场角的视频帧,确定为参照帧的步骤之后,所述方法还包括:The method according to claim 2, characterized in that after the step of determining a video frame with an out-of-bounds angle smaller than a preset field of view angle in the video to be processed as a reference frame, the method further includes:
    将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除所述第一类参 照帧之外的参照帧确定为第二类参照帧;The reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as the first type of reference frame, and the first type of reference frame is The reference frame outside the frame is determined as the second type of reference frame;
    若所述参照帧为第一类参照帧,则将相邻两个第一类参照帧之间的视频帧,确定为与所述相邻两个第一类参照帧对应的抖动帧;If the reference frame is a first-type reference frame, then the video frame between two adjacent first-type reference frames is determined as a jitter frame corresponding to the two adjacent first-type reference frames;
    若所述参照帧为第二类参照帧,则执行根据所述参照帧的出界角和所述预设视场角,确定所述参照帧对应的抖动帧的数量m的步骤。If the reference frame is a second type of reference frame, then perform the step of determining the number m of dither frames corresponding to the reference frame based on the out-of-boundary angle of the reference frame and the preset field of view angle.
  7. 根据权利要求6所述的方法,其特征在于,所述将相邻两个参照帧之间的间隔符合第二预设条件的参照帧确定为第一类参照帧,将除所述第一类参照帧之外的参照帧确定为第二类参照帧之前,所述方法还包括:The method according to claim 6, characterized in that the reference frame whose interval between two adjacent reference frames meets the second preset condition is determined as the first type of reference frame, and the reference frame except the first type is determined as the first type of reference frame. Before the reference frame other than the reference frame is determined as the second type of reference frame, the method further includes:
    根据所述相邻两个参照帧的出界角和预设视场角,计算所述相邻两个参照帧之间的预测帧数,当所述预测帧数大于实际帧数时,判定所述相邻两个参照帧之间的间隔符合第二预设条件;According to the out-of-boundary angle and the preset field of view angle of the two adjacent reference frames, the number of predicted frames between the two adjacent reference frames is calculated. When the number of predicted frames is greater than the actual number of frames, it is determined that the The interval between two adjacent reference frames meets the second preset condition;
    或者,当相邻两个参照帧之间的间隔不大于预设帧数时,判定所述相邻两个参照帧之间的间隔符合第二预设条件。Alternatively, when the interval between two adjacent reference frames is not greater than the preset number of frames, it is determined that the interval between the two adjacent reference frames meets the second preset condition.
  8. 根据权利要求7所述的方法,其特征在于,所述第一类参照帧对应的抖动帧为第一类抖动帧,所述第二类参照帧对应的抖动帧为第二类抖动帧;The method according to claim 7, characterized in that the jitter frame corresponding to the first type of reference frame is a first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is a second type of jitter frame;
    所述根据所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角的步骤,包括:The step of determining the anti-shake field of view angle of the shake frame based on the out-of-boundary angle of the reference frame corresponding to the shake frame includes:
    根据所述第一类抖动帧对应的相邻两个第一类参照帧的出界角以及所述第一类抖动帧在子出界区中的帧序列,确定所述第一类抖动帧的防抖视场角,其中,所述子出界区由所述第一类抖动帧对应的相邻两个第一类参照帧之间的视频帧以及所述相邻两个第一类参照帧构成;Determine the anti-shake of the first type of jitter frame based on the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the sub-out-of-bounds area. Field of view, wherein the sub-out-of-bounds area is composed of a video frame between two adjacent first-type reference frames corresponding to the first-type jitter frame and the two adjacent first-type reference frames;
    确定所述第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据所述间隔帧数和所述第二类抖动帧对应的第二类参照帧的出界角,确定所述第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type of reference frame, and determine the said interval frame number based on the number of interval frames and the out-of-boundary angle of the second type of reference frame corresponding to the second type of jitter frame. The anti-shake field of view of the second type of jitter frame.
  9. 根据权利要求8所述的方法,其特征在于,所述根据所述第一类抖动帧对应的相邻两个第一类参照帧的出界角以及所述第一类抖动帧在所述子出界区中的帧序列,确定所述第一类抖动帧的防抖视场角,包括:The method according to claim 8, characterized in that the out-of-boundary angle of two adjacent first-type reference frames corresponding to the first-type jitter frame and the sub-out-of-boundary angle of the first-type jitter frame are The frame sequence in the area determines the anti-shake field of view of the first type of jitter frame, including:
    根据所述第一类抖动帧对应的相邻两个第一类参照帧的出界角和所述实际帧数,确定偏移系数;Determine the offset coefficient according to the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type jitter frame and the actual number of frames;
    根据所述偏移系数,以及所述第一类抖动帧在子出界区中的帧序列,确定所述第一类抖动帧的防抖偏移量;Determine the anti-shake offset of the first type of jitter frame according to the offset coefficient and the frame sequence of the first type of jitter frame in the sub-out-of-bounds area;
    根据所述防抖偏移量和所述第一类抖动帧对应的相邻两个第一类参照帧的出界角,确定所述第一类抖动帧的防抖视场角。The anti-shake field of view angle of the first-type shake frame is determined based on the anti-shake offset and the out-of-boundary angles of two adjacent first-type reference frames corresponding to the first-type shake frame.
  10. 根据权利要求6所述的方法,其特征在于,所述对于第一类参照帧,将相邻两个第一类参照帧 之间的视频帧,确定为与所述相邻两个第一类参照帧对应的抖动帧的步骤,包括:The method according to claim 6, characterized in that, for the first type reference frame, two adjacent first type reference frames are The step of determining the video frames between them as jitter frames corresponding to the two adjacent first-type reference frames includes:
    对于第一类参照帧,将相邻两个第一类参照帧之间的视频帧以及所述相邻两个第一类参照帧确定为一个子出界区;For the first type of reference frame, the video frame between two adjacent first type reference frames and the two adjacent first type reference frames are determined as a sub-out-of-bounds area;
    对于不存在相邻子出界区的子出界区,将所述子出界区内的两个第一类参照帧之间的视频帧,确定为与所述两个第一类参照帧对应的抖动帧;For a sub-out-of-bounds area that does not have adjacent sub-out-of-bounds areas, the video frame between two first-type reference frames in the sub-out-of-bounds area is determined as a jitter frame corresponding to the two first-type reference frames. ;
    对于存在相邻子出界区的子出界区,将相邻的多个子出界区合并为一个出界区,并将所述出界区划分为至少一个区间段,所述区间段的长度大于所述子出界区的长度;For a sub-out-of-bounds area with adjacent sub-out-of-bounds areas, merge the adjacent sub-out-of-bounds areas into one out-of-bounds area, and divide the out-of-bounds area into at least one interval segment, the length of the interval segment being greater than the length of the sub-out-of-bounds area. The length of the zone;
    对于每一区间段,根据所述区间段内首尾两个第一类参照帧的出界角,计算所述首尾两个第一类参照帧之间的第一类参照帧的预测出界角;For each interval segment, calculate the predicted out-of-boundary angle of the first-type reference frame between the first and last two first-type reference frames in the interval segment;
    若所述预测出界角小于实际出界角,则将所述首尾两个第一类参照帧之间的视频帧,确定为与所述首尾两个第一类参照帧对应的抖动帧。If the predicted out-of-boundary angle is smaller than the actual out-of-boundary angle, the video frame between the first and last two first-type reference frames is determined as a jitter frame corresponding to the first and last two first-type reference frames.
  11. 根据权利要求10所述的方法,其特征在于,所述第一类参照帧对应的抖动帧为第一类抖动帧,所述第二类参照帧对应的抖动帧为第二类抖动帧;The method according to claim 10, characterized in that the jitter frame corresponding to the first type of reference frame is a first type of jitter frame, and the jitter frame corresponding to the second type of reference frame is a second type of jitter frame;
    所述根据所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角的步骤,包括:The step of determining the anti-shake field of view angle of the shake frame based on the out-of-boundary angle of the reference frame corresponding to the shake frame includes:
    根据所述第一类抖动帧对应的首尾两个第一类参照帧的出界角以及所述第一类抖动帧在所述区间段内中的帧序列,确定所述第一类抖动帧的防抖视场角;According to the out-of-boundary angles of the first and last two first-type reference frames corresponding to the first-type jitter frame and the frame sequence of the first-type jitter frame in the interval section, the anti-shake resistance of the first-type jitter frame is determined. Shake the field of view;
    确定所述第二类抖动帧与其对应的第二类参照帧的间隔帧数,并根据所述间隔帧数和所述第二类抖动帧对应的第一参照帧的出界角,确定所述第二类抖动帧的防抖视场角。Determine the number of intervals between the second type of jitter frame and its corresponding second type of reference frame, and determine the third type of frame based on the number of interval frames and the out-of-bounds angle of the first reference frame corresponding to the second type of jitter frame. Anti-shake field of view for type II jitter frames.
  12. 根据权利要求6至11任一项所述的方法,其特征在于,所述根据所述抖动帧的防抖视场角,对所述待处理视频进行防抖处理,包括:The method according to any one of claims 6 to 11, characterized in that, performing anti-shake processing on the video to be processed according to the anti-shake field angle of the shake frame includes:
    从第一类抖动帧中确定出防抖视场角不大于出界角的第一类目标抖动帧,从第二类抖动帧中确定出防抖视场角不大于出界角的第二类目标抖动帧;Determine the first type of target jitter frame whose anti-shake field angle is not larger than the out-of-bounds angle from the first type of jitter frame, and determine the second type of target jitter whose anti-shake field angle is not larger than the out-of-bounds angle from the second type of jitter frame frame;
    根据所述第一类目标抖动帧的防抖视场角和所述第二类目标抖动帧的防抖视场角,对所述待处理视频进行防抖处理。Anti-shake processing is performed on the video to be processed according to the anti-shake field of view angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame.
  13. 根据权利要求12所述的方法,其特征在于,所述根据所述第一类目标抖动帧的防抖视场角和所述第二类目标抖动帧的防抖视场角,对所述待处理视频进行防抖处理,包括:The method according to claim 12, characterized in that, based on the anti-shake field of view angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame, the method to be treated is Process videos for anti-shake processing, including:
    根据所述第一类目标抖动帧的防抖视场角和所述第二类目标抖动帧的防抖视场角,对第一视场角曲线进行角度变换处理,得到第二视场角曲线,其中,所述第一视场角曲线是根据所述待处理视频中每一视频帧的出界角构建的; According to the anti-shake field of view angle of the first type of target jitter frame and the anti-shake field angle of the second type of target jitter frame, the first field of view angle curve is subjected to angle transformation processing to obtain the second field of view angle curve. , wherein the first field of view angle curve is constructed based on the out-of-bounds angle of each video frame in the video to be processed;
    根据预设视场角区间,对所述第二视场角曲线中处于所述预设视场角区间以外的出界角进行调节,得到第三视场角曲线;According to the preset viewing angle interval, adjust the out-of-view angle in the second viewing angle curve that is outside the preset viewing angle interval to obtain a third viewing angle curve;
    根据所述第三视场角曲线对所述待处理视频进行防抖处理。Anti-shake processing is performed on the video to be processed according to the third field of view curve.
  14. 一种视频的防抖处理装置,其特征在于,包括:A video anti-shake processing device, characterized by including:
    第一数据获取模块,用于获取待处理视频,以及拍摄所述待处理视频时拍摄装置的运动轨迹;The first data acquisition module is used to acquire the video to be processed and the motion trajectory of the shooting device when shooting the video to be processed;
    第二数据获取模块,用于根据所述运动轨迹,获取所述待处理视频中视频帧的出界角;A second data acquisition module, configured to acquire the out-of-bounds angle of the video frame in the video to be processed according to the motion trajectory;
    视频处理模块,用于根据所述视频帧的出界角,从所述待处理视频中确定出参照帧以及所述参照帧对应的抖动帧;A video processing module, configured to determine a reference frame and a jitter frame corresponding to the reference frame from the video to be processed according to the out-of-bounds angle of the video frame;
    视场角计算模块,用于根据所述抖动帧对应的参照帧的出界角,确定所述抖动帧的防抖视场角;A field of view calculation module, configured to determine the anti-shake field of view angle of the jitter frame based on the out-of-bounds angle of the reference frame corresponding to the jitter frame;
    防抖处理模块,用于根据所述抖动帧的防抖视场角,对所述待处理视频进行防抖处理。An anti-shake processing module is used to perform anti-shake processing on the video to be processed according to the anti-shake field of view of the shake frame.
  15. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,当所述计算机程序在计算机上运行时,使得所述计算机执行如权利要求1至13任一项所述的视频的防抖处理方法。A computer-readable storage medium with a computer program stored thereon, characterized in that when the computer program is run on a computer, it causes the computer to perform the video prevention method according to any one of claims 1 to 13. Jitter processing method.
  16. 一种电子设备,包括处理器和存储器,所述存储器存储有计算机程序,其特征在于,所述处理器通过调用所述计算机程序,用于执行如权利要求1至13任一项所述的视频的防抖处理方法。 An electronic device, including a processor and a memory, the memory storing a computer program, characterized in that the processor is used to execute the video as claimed in any one of claims 1 to 13 by calling the computer program anti-shake processing method.
PCT/CN2023/090288 2022-04-27 2023-04-24 Anti-shake processing method and apparatus for video, and storage medium and electronic device WO2023207899A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210467413.5A CN114866695B (en) 2022-04-27 2022-04-27 Anti-shake processing method and device for video, storage medium and electronic equipment
CN202210467413.5 2022-04-27

Publications (1)

Publication Number Publication Date
WO2023207899A1 true WO2023207899A1 (en) 2023-11-02

Family

ID=82636380

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/090288 WO2023207899A1 (en) 2022-04-27 2023-04-24 Anti-shake processing method and apparatus for video, and storage medium and electronic device

Country Status (2)

Country Link
CN (1) CN114866695B (en)
WO (1) WO2023207899A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114866695B (en) * 2022-04-27 2024-02-20 影石创新科技股份有限公司 Anti-shake processing method and device for video, storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104902142A (en) * 2015-05-29 2015-09-09 华中科技大学 Method for electronic image stabilization of video on mobile terminal
CN106204458A (en) * 2016-07-12 2016-12-07 北京理工大学 A kind of Video Stabilization cutting control method based on the constraint of kinematic geometry amount
US20170230581A1 (en) * 2014-09-19 2017-08-10 Intel Corporation Trajectory planning for video stabilization
CN112804444A (en) * 2020-12-30 2021-05-14 影石创新科技股份有限公司 Video processing method and device, computing equipment and storage medium
CN114866695A (en) * 2022-04-27 2022-08-05 影石创新科技股份有限公司 Anti-shake processing method and device for video, storage medium and electronic equipment

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7558405B2 (en) * 2005-06-30 2009-07-07 Nokia Corporation Motion filtering for video stabilization
EP2018768A2 (en) * 2006-05-09 2009-01-28 Nxp B.V. Processing device with jitter extraction and equipment comprising such a device
JP4178481B2 (en) * 2006-06-21 2008-11-12 ソニー株式会社 Image processing apparatus, image processing method, imaging apparatus, and imaging method
US9336460B2 (en) * 2013-05-31 2016-05-10 Intel Corporation Adaptive motion instability detection in video
CN110602393B (en) * 2019-09-04 2020-06-05 南京博润智能科技有限公司 Video anti-shake method based on image content understanding
CN112653842A (en) * 2020-12-23 2021-04-13 维沃移动通信有限公司 Video anti-shake method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170230581A1 (en) * 2014-09-19 2017-08-10 Intel Corporation Trajectory planning for video stabilization
CN104902142A (en) * 2015-05-29 2015-09-09 华中科技大学 Method for electronic image stabilization of video on mobile terminal
CN106204458A (en) * 2016-07-12 2016-12-07 北京理工大学 A kind of Video Stabilization cutting control method based on the constraint of kinematic geometry amount
CN112804444A (en) * 2020-12-30 2021-05-14 影石创新科技股份有限公司 Video processing method and device, computing equipment and storage medium
CN114866695A (en) * 2022-04-27 2022-08-05 影石创新科技股份有限公司 Anti-shake processing method and device for video, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN114866695A (en) 2022-08-05
CN114866695B (en) 2024-02-20

Similar Documents

Publication Publication Date Title
US8363116B2 (en) Image processing device, focal plane distortion component calculation method, image processing program, and recording medium
KR101725215B1 (en) Generic platform video image stabilization
US10848676B2 (en) Semiconductor device and electronic device
US20200077023A1 (en) Image stabilization using machine learning
US9888179B1 (en) Video stabilization for mobile devices
US9300871B2 (en) Stationary camera detection and virtual tripod transition for video stabilization
US20100208087A1 (en) Image processing device, camera motion component calculation method, image processing program, and recording medium
CN107624243B (en) Real-time hyper-lapse video creation through frame selection
WO2023207899A1 (en) Anti-shake processing method and apparatus for video, and storage medium and electronic device
WO2021115136A1 (en) Anti-shake method and apparatus for video image, electronic device, and storage medium
US11006044B1 (en) Power-efficient dynamic electronic image stabilization
TW201319954A (en) Image stabilization method and image stabilization device
US11683583B2 (en) Picture focusing method, apparatus, terminal, and corresponding storage medium
US7436984B2 (en) Method and system for stabilizing video data
CN111405187A (en) Image anti-shake method, system, device and storage medium for monitoring equipment
CN112653842A (en) Video anti-shake method and device
WO2018058476A1 (en) Image correction method and device
US20200286209A1 (en) System and method of reducing effects of turbulence in an image
US9374526B2 (en) Providing frame delay using a temporal filter
CN112804444B (en) Video processing method and device, computing equipment and storage medium
JP6766203B2 (en) Video optimization processing system and method
US7623184B2 (en) Apparatus and method for digital image stabilization
CN113099106B (en) Video processing method, device, equipment and storage medium
US12035044B2 (en) Methods and apparatus for re-stabilizing video in post-processing
US20240037793A1 (en) Systems, methods, and apparatus for piggyback camera calibration

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23795332

Country of ref document: EP

Kind code of ref document: A1