WO2022214037A1 - Video anti-shake processing method and apparatus, electronic device, and storage medium - Google Patents

Video anti-shake processing method and apparatus, electronic device, and storage medium Download PDF

Info

Publication number
WO2022214037A1
WO2022214037A1 PCT/CN2022/085634 CN2022085634W WO2022214037A1 WO 2022214037 A1 WO2022214037 A1 WO 2022214037A1 CN 2022085634 W CN2022085634 W CN 2022085634W WO 2022214037 A1 WO2022214037 A1 WO 2022214037A1
Authority
WO
WIPO (PCT)
Prior art keywords
video
image frames
different image
shooting position
target
Prior art date
Application number
PCT/CN2022/085634
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 WO2022214037A1 publication Critical patent/WO2022214037A1/en
Priority to US18/472,001 priority Critical patent/US20240013347A1/en

Links

Images

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/2622Signal amplitude transition in the zone between image portions, e.g. soft edges

Definitions

  • the present disclosure relates to the technical field of video processing, and in particular, to a video anti-shake processing method, device, electronic device and storage medium.
  • the embodiments of the present disclosure provide a video anti-shake processing method, apparatus, electronic device, and storage medium.
  • an embodiment of the present disclosure provides a video anti-shake processing method, including:
  • the initial change amount of the shooting position between different image frames in the video is determined based on the initial transformation method
  • the target variation of the shooting position between different image frames in the video is determined by adopting a target transformation method that matches the fitting error
  • the video is deformed to obtain an anti-shake processed video.
  • an embodiment of the present disclosure further provides a video anti-shake processing device, including:
  • an initial change amount determination module configured to determine the initial change amount of the shooting position between different image frames in the video based on the initial transformation method by tracking feature points between different image frames in the video;
  • a target variation determination module configured to determine, based on the fitting error corresponding to the initial variation, the target variation of the shooting position between different image frames in the video by adopting a target transformation method that matches the fitting error;
  • a movement trajectory generation module configured to form a movement trajectory of the shooting position of the video based on the target change amount of the shooting position between different image frames in the video, wherein the movement trajectory is used to indicate different images in the video the shooting position of the frame;
  • a smooth trajectory determination module configured to perform smooth processing on the shooting positions of different image frames in the moving trajectory respectively to obtain a smooth trajectory
  • a video anti-shake processing module configured to deform the video based on the difference between the smooth track and the moving track to obtain a video that has undergone anti-shake processing.
  • embodiments of the present disclosure further provide an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device is made to The device implements any of the video anti-shake processing methods provided in the embodiments of the present disclosure.
  • an embodiment of the present disclosure further provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a computing device, the computing device enables the computing device to implement the embodiment of the present disclosure Any of the provided video anti-shake processing methods.
  • a computer program product comprising computer program instructions that cause a computer to perform a method as in the first aspect or implementations thereof.
  • a computer program causing a computer to perform the method as in the first aspect or implementations thereof.
  • the technical solutions provided by the embodiments of the present disclosure have at least the following advantages: in the embodiments of the present disclosure, the initial change amount of the shooting position between different image frames in the video is first determined based on the initial transformation method, and then based on the initial change
  • the fitting error corresponding to the fitting error is used to determine the target variation of the shooting position between different image frames in the video by using the target transformation method that matches the fitting error, that is, the fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable.
  • the target change amount of the shooting position between different image frames in the video forms the movement trajectory of the shooting position of the video.
  • the video anti-shake processing effect is realized through the trajectory smoothing processing and video deformation processing.
  • the embodiment of the present disclosure realizes the effect of dynamically determining the target transformation mode between different image frames in the video based on the fitting error corresponding to the initial change of the shooting position between different image frames in the video, and ensures the processing effect of video anti-shake. , which avoids the introduction of excessive fitting errors and effectively improves the video quality.
  • FIG. 1 is a flowchart of a video anti-shake processing method provided by an embodiment of the present disclosure
  • FIG. 2 is a flowchart of another video anti-shake processing method provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic structural diagram of a video anti-shake processing apparatus according to an embodiment of the present disclosure
  • FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
  • FIG. 1 is a flowchart of a video anti-shake processing method provided by an embodiment of the present disclosure, which can be applied to a situation of performing anti-shake processing on a video.
  • the method can be performed by a video anti-shake processing apparatus, which can be implemented by software and/or hardware, and can be integrated on any electronic device with computing capability, such as a terminal or a server.
  • the video to be processed may be a video being shot or a video that has been shot, that is, the embodiment of the present disclosure may perform anti-shake processing on the shot video in real time during the video shooting process, or the video may be Anti-shake processing is performed on the video after shooting, which can improve the quality of the video.
  • the video anti-shake processing method may include:
  • matching feature points between different image frames in the video By tracking feature points between different image frames in the video, matching feature points between different image frames can be determined (referring to the feature points of the same object in different image frames, the number of matching feature points can be determined according to the situation) , and then based on the initial transformation method and the matching feature points, the initial variation of the shooting position between different image frames can be determined.
  • the feature point tracking may be implemented with reference to the prior art, which is not specifically limited in the embodiment of the present disclosure.
  • the different image frames in the video may be two adjacent frames of images in the video, or may be images separated by at least two frames, such as the current frame and the first frame of images in the video.
  • the initial transformation method is a calculation method that is used by default and is used to calculate the amount of change in the shooting position between different image frames.
  • the initial transformation method can be implemented by, for example, an initial transformation matrix used to characterize the change of the shooting position, for example, it can be Homography matrix, etc. It should be understood that, in the actual processing process, the initial transformation mode may be flexibly selected from multiple available transformation modes according to processing requirements, which is not specifically limited in the embodiment of the present disclosure.
  • the initial change amount of the shooting position between different image frames may be, for example, the change amount of the shooting position of the following frame image relative to the previous frame image.
  • the initial change amount of the shooting position between different image frames may be a transformation matrix from the previous frame image to the subsequent frame image.
  • the video anti-shake processing method provided by the embodiment of the present disclosure further includes: calculating a fitting corresponding to the initial variation of the shooting position between different image frames based on the initial transformation method and the feature points that are successfully matched between different image frames. error.
  • the fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable, and then determine the influence of the initial transformation method on the anti-shake processing effect in the video anti-shake processing process.
  • the initial transformation method can be used to perform coordinate transformation on the feature points on the previous frame image, or the inverse transformation of the initial transformation method can be used to perform coordinate transformation on the feature points on the subsequent frame image, and then It is compared with the image coordinates of the feature points on the remaining image of another frame, so as to calculate the fitting error corresponding to the initial change of the shooting position between different image frames.
  • calculating the fitting error corresponding to the initial variation of the shooting position between different image frames may include:
  • the fitting error corresponding to the initial variation of the shooting position between different image frames is calculated.
  • the initial transformation method is implemented by using an initial transformation matrix.
  • Different image frames in the video refer to two adjacent frames of images in the video as an example.
  • the motion fitting effect of the image frame is poor, and the initial transformation matrix needs to be dynamically replaced, that is, the initial transformation method needs to be dynamically replaced.
  • the specific calculation method for obtaining the fitting error by using the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image can be flexibly determined in actual processing.
  • the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image can be calculated according to the corresponding relationship between the feature points on the two frames of images.
  • Each difference value or each quotient value is summed (including weighted summation) to obtain the fitting error corresponding to the initial change of the shooting position between different image frames, and the average value of each difference value or the average value of each quotient value can also be calculated. value, as the fitting error corresponding to the initial variation of the shooting position between different image frames.
  • a target transformation mode matching the fitting error can be determined, so as to improve the processing effect of video anti-shake.
  • the error threshold can be set to a value. At this time, if the fitting error is less than the error threshold, the initial transformation method can be determined as the target transformation method that matches the fitting error.
  • the matching The transformation methods with different degrees of freedom of the initial transformation method are used as the target transformation method to achieve the effect of reducing the fitting error of the shooting position between different image frames;
  • the error threshold can also be hierarchically set to multiple values, and each threshold corresponds to a
  • the degrees of freedom between the multiple optional transformation modes are different, and the fitting errors corresponding to the initial changes of the shooting positions between different image frames obtained by each transformation mode are also different.
  • each threshold mentioned in the implementation of the present disclosure can be flexibly set in the actual processing process, which is not specifically limited in the embodiment of the present disclosure.
  • the error threshold includes a first error threshold and a second error threshold, and the value of the first error threshold is less than the second error threshold, if the fitting error corresponding to the initial variation of the shooting position between different image frames in the video is less than If the first error threshold is set, the initial transformation mode is determined as the target transformation mode that matches the fitting error, and the target transformation mode is used to determine the target change amount of the shooting position between different image frames in the video; or
  • the first transformation with a degree of freedom smaller than the initial transformation is determined as the target transformation that matches the fitting error, and Determine the amount of target change in the shooting position between different image frames in the video by means of target transformation;
  • the second transformation method with a degree of freedom smaller than the first transformation method is determined as the target transformation method matching the fitting error, and the target transformation method is used to determine the video The amount of target change in the shooting position between different image frames in .
  • the initial transformation mode includes a homography transformation mode
  • the first transformation mode includes an affine transformation mode
  • the second transformation mode includes a similarity transformation mode
  • the homography transformation is the transformation relationship from one plane to another plane, with a total of eight degrees of freedom
  • the affine transformation is a linear transformation from two-dimensional coordinates to two-dimensional coordinates, which maintains the two-dimensional graphics.
  • "Flatness” and “parallelism” mainly include translation transformation, rotation transformation, scale transformation, tilt transformation (or called staggered transformation, shear transformation, offset transformation), flip transformation, a total of six degrees of freedom ;
  • staggered transformation, shear transformation, offset transformation or called staggered transformation, shear transformation, offset transformation
  • flip transformation a total of six degrees of freedom
  • affine transformation there is no oblique transformation and flip transformation in similarity transformation, and there are a total of four degrees of freedom.
  • a transformation relationship corresponds to a motion model.
  • a motion model with a higher degree of freedom ie, a transformation matrix with a higher degree of freedom
  • a motion model with a low degree of freedom replaces a motion model with a high degree of freedom, so as to avoid introducing large fitting errors while reducing the smoothing effect, to achieve a balance between motion smoothing and fitting errors between different image frames, and to ensure the final Video stabilization effect.
  • a movement track of the shooting position of the video is formed, wherein the movement track is used to indicate the shooting position of different image frames in the video.
  • one frame of image in the video can be selected as the reference frame image, and the reference frame image can be determined adaptively, and then the target variation of the shooting position between different image frames can be used to obtain the relative value of each frame of image in the video relative to the reference frame.
  • the target change amount of the shooting position of the image, and then the movement trajectory of the shooting position of the video (or the movement trajectory of the shooting device for shooting the video) is obtained based on the multiple target changes.
  • the initial change amount or the target change amount may be represented by a transformation matrix
  • the movement track includes multiple transformation matrices, that is, different transformation matrices in the movement track may respectively represent different image frames in the video.
  • the movement trajectory of the shooting position of the video is formed, including:
  • the movement track of the shooting position of the video is formed.
  • the target transformation matrix of the shooting position between the i-th frame image f i and the i+1-th frame image f i+1 in the video is represented as T i
  • the i-th frame image f i and the different images before the i-th frame can be expressed as T i .
  • the target transformation matrix of the shooting position between the frames (for example, each adjacent two frame images) is accumulated and processed, for example, the cumulative multiplication calculation (specifically can be determined according to the actual processing), and the difference between the i-th frame image f i relative to the first frame image is obtained.
  • the transformation matrix of the shooting position expressed as follows:
  • the movement trajectory of the shooting position of the video is obtained, that is, the shaking trend of the shooting position of the video is determined.
  • Any available smoothing algorithm in the prior art such as Gaussian smoothing algorithm, etc., can be used to shoot different image frames in the moving trajectory.
  • the position is smoothed to obtain a smooth trajectory.
  • the smooth trajectory can be expressed as, for example, Smoothing tracks are used to indicate where different image frames were taken in the smoothed video.
  • n represents the number of image frames included in the video; then, according to the corresponding relationship between each sub-value in the adjustment parameter and each frame of image in the video, the corresponding image frame can be deformed based on each sub-value in the adjustment parameter, so as to obtain anti-shake processed video.
  • the deformation processing process it involves the rotation, translation, scaling or cropping of a specific frame image, which can be performed according to actual processing requirements.
  • the initial change amount of the shooting position between different image frames in the video is first determined based on the initial transformation method, and then based on the fitting error corresponding to the initial change amount, the target transformation method that matches the fitting error is used to determine the video
  • the target change of the shooting position between different image frames in the video that is, the fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable, and then the shooting position of the video is formed based on the target change of the shooting position between different image frames in the video.
  • the embodiment of the present disclosure realizes the effect of dynamically determining the target transformation mode between different image frames in the video based on the fitting error corresponding to the initial change of the shooting position between different image frames in the video, and ensures the processing effect of video anti-shake. , which avoids the introduction of excessive fitting errors and effectively improves the video quality.
  • FIG. 2 is a flowchart of another video anti-shake processing method provided by an embodiment of the present disclosure, which is further optimized and expanded based on the foregoing technical solution, and may be combined with the foregoing optional implementation manners.
  • the video anti-shake processing method may include:
  • the number of successfully matched feature points on these two frame images is represented as M i
  • the i-th frame image f i The j-th feature point on is represented as Then the transformed coordinates corresponding to the jth feature point can be expressed as T i represents the initial change of the shooting position between the i-th frame image f i and the i+1-th frame image f i +1
  • the j-th feature point on the i+1-th frame image f i+1 is expressed as Then the cumulative error corresponding to the initial change of the shooting position between the i-th frame image f i and the i+1-th frame image f i+1 can be expressed as
  • the mean value can be calculated based on the accumulated error and the number of feature points on the previous frame image (equal to the number of successfully matched feature points between different image frames) M i to obtain the shooting position between different image frames.
  • the fitting error E i corresponding to the initial variation of can be expressed as follows:
  • the fitting error corresponding to the initial variation of the shooting position between different image frames is determined, which ensures the accuracy of the fitting error calculation.
  • a movement track of the shooting position of the video is formed, wherein the movement track is used to indicate the shooting position of different image frames in the video.
  • smoothing processing may be performed on the shooting positions of different image frames in the moving track respectively to obtain a smooth track.
  • the value of the preset smoothing radius determines the number of image frames involved in the smoothing process, and its specific value can be flexibly determined in the actual processing process, which is not specifically limited in the embodiment of the present disclosure.
  • an image with a preset number of frames participating in the smoothing process may be determined based on a preset smoothing radius;
  • a weighted sum calculation can be performed on the corresponding shooting positions of the images with a preset number of frames in the moving trajectory to obtain the smoothed shooting position corresponding to each frame of image;
  • the smoothed shooting position of the image is obtained to obtain a smooth trajectory.
  • determining the images of the preset number of frames participating in the smoothing process may include: for each frame of the image in the video, based on the preset smoothing radius, determining the first preset before each frame of the image. Set the previous frame image of the frame number; determine each frame image and the previous frame image of the first preset frame number (the value of which is the value of the preset smoothing radius at this time) as the preset frame participating in the smoothing process or, based on the preset smoothing radius, determine the previous frame image of the second preset number of frames before each frame of image (the value of which is the value of the preset smoothing radius at this time), and determine each frame of image.
  • the subsequent frame images of the second preset frame number after the frame image; each frame image, the previous frame image of the second preset frame number, and the subsequent frame image of the second preset frame number are determined to participate in the smoothing process the preset number of frames of the image.
  • the smoothing of each frame of image f i is taken as an example.
  • the matrix can be represented as follows:
  • r is the preset smoothing radius
  • C t is the corresponding transformation matrix (ie shooting position) of each frame of image participating in the smoothing process in the moving track C
  • w i ⁇ t is the weight of each frame of the image participating in the smoothing process.
  • the value can be set adaptively, which is not specifically limited in the embodiment of the present disclosure.
  • the corresponding image frame can be deformed based on each sub-value in the adjustment parameter, so as to obtain the video after anti-shake processing.
  • the dynamic determination of the available transformation modes between different image frames according to the fitting error is realized, ensuring that The processing effect of video anti-shake avoids the introduction of excessive fitting errors and effectively improves the video quality.
  • FIG. 3 is a schematic structural diagram of a video anti-shake processing apparatus according to an embodiment of the present disclosure, which can be applied to a situation of performing anti-shake processing on a video.
  • the apparatus can be implemented by software and/or hardware, and can be integrated on any electronic device with computing capability, such as a terminal or a server.
  • the video anti-shake processing apparatus 300 may include an initial change amount determination module 301, a target change amount determination module 302, a movement trajectory generation module 303, a smooth trajectory determination module 304, and video anti-shake processing.
  • Module 305 where:
  • the initial change amount determination module 301 is used to determine the initial change amount of the shooting position between different image frames in the video based on the initial transformation method by performing feature point tracking between different image frames in the video;
  • the target change amount determination module 302 is used for determining the target change amount of the shooting position between different image frames in the video based on the fitting error corresponding to the initial change amount by adopting a target transformation method that matches the fitting error;
  • the movement trajectory generation module 303 is used to form the movement trajectory of the shooting position of the video based on the target variation of the shooting position between different image frames in the video, wherein the movement trajectory is used to indicate the shooting position of different image frames in the video;
  • the smooth trajectory determination module 304 is configured to perform smoothing processing on the shooting positions of different image frames in the moving trajectory respectively to obtain a smooth trajectory;
  • the video anti-shake processing module 305 is configured to deform the video based on the difference between the smooth track and the moving track, so as to obtain a video that has undergone anti-shake processing.
  • the video anti-shake processing apparatus 300 provided in this embodiment of the present disclosure further includes:
  • the transformation coordinate determination module is used to perform coordinate transformation on the feature points on the previous frame image in different image frames by using the initial transformation method, so as to obtain the transformed coordinates of the feature points on the previous frame image;
  • the fitting error calculation module is used to calculate the corresponding value of the initial change of the shooting position between different image frames based on the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames. Fitting error.
  • the fitting error calculation module includes:
  • the cumulative error calculation unit is used to calculate the cumulative corresponding to the initial change of the shooting position between different image frames by using the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames error;
  • the fitting error calculation unit is configured to calculate the fitting error corresponding to the initial variation of the shooting position between different image frames based on the accumulated error and the number of feature points on the previous frame image.
  • the target variation determination module 302 includes:
  • a first determining unit configured to determine the initial transformation mode as a target transformation mode matching the fitting error if the fitting error corresponding to the initial change amount is smaller than the first error threshold, and use the target transformation mode to determine different image frames in the video The amount of target change between shooting positions; or
  • a second determining unit configured to determine the first transformation mode with the degree of freedom smaller than the initial transformation mode as the fitting error if the fitting error corresponding to the initial change amount is greater than or equal to the first error threshold and less than the second error threshold
  • the matching target transformation method, and the target transformation method is used to determine the target change amount of the shooting position between different image frames in the video;
  • a second determining unit configured to determine a second transformation mode with a degree of freedom smaller than the first transformation mode as a target transformation mode matching the fitting error if the fitting error corresponding to the initial change amount is greater than or equal to the second error threshold, And adopt the target transformation method to determine the target change amount of the shooting position between different image frames in the video.
  • the initial transformation mode includes a homography transformation mode
  • the first transformation mode includes an affine transformation mode
  • the second transformation mode includes a similarity transformation mode
  • the initial change amount or the target change amount is represented by a transformation matrix
  • the movement trajectory generation module 303 includes:
  • a transformation matrix determining unit for determining the transformation matrix of each frame of image relative to the first frame of image in the video based on the target transformation matrix of the shooting position between different image frames in the video;
  • the movement trajectory generation unit is configured to form the movement trajectory of the shooting position of the video based on the transformation matrix of each frame of image in the video relative to the first frame of image.
  • the video anti-shake processing module 305 includes:
  • an adjustment parameter determination unit for determining an adjustment parameter based on the difference between the smooth trajectory and the moving trajectory
  • the video deformation unit is used to deform the video by using the adjustment parameters to obtain the video that has undergone anti-shake processing.
  • the video anti-shake processing apparatus provided by the embodiment of the present disclosure can execute any video anti-shake processing method provided by the embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.
  • any video anti-shake processing method provided by the embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.
  • FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, which is used to exemplarily describe an electronic device that implements the video anti-shake processing method provided by the embodiment of the present disclosure.
  • the electronic devices in the embodiments of the present disclosure may include, but are not limited to, such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (eg, Mobile terminals such as car navigation terminals), etc., and stationary terminals such as digital TVs, desktop computers, smart home devices, wearable electronic devices, servers, and the like.
  • the electronic device shown in FIG. 4 is only an example, and should not impose any limitation on the functions and occupancy scope of the embodiments of the present disclosure.
  • electronic device 400 includes one or more processors 401 and memory 402 .
  • Processor 401 may be a central processing unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in electronic device 400 to perform desired functions.
  • CPU central processing unit
  • Processor 401 may be a central processing unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in electronic device 400 to perform desired functions.
  • Memory 402 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory.
  • Volatile memory may include, for example, random access memory (RAM) and/or cache memory, among others.
  • Non-volatile memory may include, for example, read only memory (ROM), hard disk, flash memory, and the like.
  • One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 401 may execute the program instructions to implement the video anti-shake processing method provided by the embodiments of the present disclosure, and may also implement other desired functions.
  • Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
  • the video anti-shake processing method may include: by tracking feature points between different image frames in the video, determining the initial change amount of the shooting position between different image frames in the video based on an initial transformation method; The fitting error corresponding to the initial variation is determined by the target transformation method that matches the fitting error to determine the target variation of the shooting position between different image frames in the video; based on the target variation of the shooting position between different image frames in the video, the The moving track of the shooting position of the video, wherein the moving track is used to indicate the shooting position of different image frames in the video; the shooting positions of different image frames in the moving track are respectively smoothed to obtain a smooth track; based on the difference between the smooth track and the moving track The difference between the video and the video is deformed to obtain an anti-shake video.
  • the electronic device 400 may also perform other optional implementations provided by the method embodiments of the present disclosure.
  • the electronic device 400 may also include an input device 403 and an output device 404 interconnected by a bus system and/or other form of connection mechanism (not shown).
  • the input device 403 may also include, for example, a keyboard, a mouse, and the like.
  • the output device 404 can output various information to the outside, including the determined distance information, direction information, and the like.
  • the output devices 404 may include, for example, displays, speakers, printers, and communication networks and their connected remote output devices, among others.
  • the electronic device 400 may also include any other appropriate components according to the specific application.
  • the embodiments of the present disclosure may also be computer program products, which include computer programs or computer program instructions, which, when executed by a processor, cause a computing device to implement what is provided by the embodiments of the present disclosure. Any video anti-shake processing method.
  • the computer program product may write program code for performing operations of embodiments of the present disclosure in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., as well as conventional procedural programming language, such as "C" language or similar programming language.
  • the program code may execute entirely on the user electronic device, partly on the user electronic device, as a stand-alone software package, partly on the user electronic device and partly on the remote electronic device, or entirely on the remote electronic device execute on.
  • embodiments of the present disclosure may further provide a computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by the processor, the computer program instructions enable the computing device to implement any video anti-shake processing provided by the embodiments of the present disclosure method.
  • the video anti-shake processing method may include: by tracking feature points between different image frames in the video, determining the initial change amount of the shooting position between different image frames in the video based on an initial transformation method; The fitting error corresponding to the initial variation is determined by the target transformation method that matches the fitting error to determine the target variation of the shooting position between different image frames in the video; based on the target variation of the shooting position between different image frames in the video, the The moving track of the shooting position of the video, wherein the moving track is used to indicate the shooting position of different image frames in the video; the shooting positions of different image frames in the moving track are respectively smoothed to obtain a smooth track; based on the difference between the smooth track and the moving track
  • the video is deformed to obtain an anti-shake processed video.
  • a computer-readable storage medium can employ any combination of one or more readable media.
  • the readable medium may be a readable signal medium or a readable storage medium.
  • a readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples (non-exhaustive list) of readable storage media include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

Landscapes

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

Abstract

Embodiments of the present disclosure relate to a video anti-shake processing method and apparatus, an electronic device, and a storage medium. The method comprises: by means of performing feature point tracking between different image frames in a video, and on the basis of an initial transformation mode, determining an initial amount of variation in video-recording positions in respect of different image frames in the video; on the basis of a fitting error corresponding to the initial amount of variation, using a target transformation mode matching the fitting error in order to determine the target amount of variation in the video-recording positions in respect of different image frames in the video; and on the basis of the target amount of variation, forming a movement trajectory in respect of the video-recording positions of the video; performing smoothing on each of the video-recording positions in respect of different image frames in the movement trajectory; and, on the basis of the difference between a smooth trajectory and the movement trajectory, performing shaping on the video to obtain an anti-shake-processed video. In the embodiments of the present disclosure, the target transformation mode with respect to different image frames in the video is dynamically determined according to the fitting error, ensuring the video anti-shake processing effect, and avoiding the introduction of excessively large fitting errors.

Description

视频防抖处理方法、装置、电子设备和存储介质Video anti-shake processing method, device, electronic device and storage medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2021年04月08日提交的,申请号为202110379651.6、发明名称为“视频防抖处理方法、装置、电子设备和存储介质”的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on April 8, 2021 with the application number of 202110379651.6 and the invention titled "video anti-shake processing method, device, electronic device and storage medium". The entire content of the application is approved by Reference is incorporated in this application.
技术领域technical field
本公开涉及视频处理技术领域,尤其涉及一种视频防抖处理方法、装置、电子设备和存储介质。The present disclosure relates to the technical field of video processing, and in particular, to a video anti-shake processing method, device, electronic device and storage medium.
背景技术Background technique
随着短视频的兴起,视频拍摄变得越来越重要。目前,用户一般都是使用手持设备进行视频拍摄,这很容易造成视频的抖动,导致视频质量欠佳。因此,如何对视频进行防抖处理,提高视频质量仍是当前待解决的问题。With the rise of short videos, video shooting has become more and more important. At present, users generally use handheld devices to shoot video, which can easily cause video jitter, resulting in poor video quality. Therefore, how to perform anti-shake processing on the video and improve the video quality is still a problem to be solved at present.
发明内容SUMMARY OF THE INVENTION
为了解决上述技术问题或者至少部分地解决上述技术问题,本公开实施例提供了一种视频防抖处理方法、装置、电子设备和存储介质。In order to solve the above technical problem or at least partially solve the above technical problem, the embodiments of the present disclosure provide a video anti-shake processing method, apparatus, electronic device, and storage medium.
第一方面,本公开实施例提供了一种视频防抖处理方法,包括:In a first aspect, an embodiment of the present disclosure provides a video anti-shake processing method, including:
通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定所述视频中不同图像帧之间拍摄位置的初始变化量;By tracking feature points between different image frames in the video, the initial change amount of the shooting position between different image frames in the video is determined based on the initial transformation method;
基于所述初始变化量对应的拟合误差,采用与所述拟合误差匹配的目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量;Based on the fitting error corresponding to the initial variation, the target variation of the shooting position between different image frames in the video is determined by adopting a target transformation method that matches the fitting error;
基于所述视频中不同图像帧之间拍摄位置的目标变化量,形成所述视频的拍摄位置的移动轨迹,其中,所述移动轨迹用于指示所述视频中不同图像帧的拍摄位置;forming a moving track of the shooting position of the video based on the target change amount of the shooting position between different image frames in the video, wherein the moving track is used to indicate the shooting position of different image frames in the video;
分别对所述移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;respectively smoothing the shooting positions of different image frames in the moving track to obtain a smooth track;
基于所述平滑轨迹和所述移动轨迹之间的差异,对所述视频进行形变,以得到经过防抖处理的视频。Based on the difference between the smooth trajectory and the moving trajectory, the video is deformed to obtain an anti-shake processed video.
第二方面,本公开实施例还提供了一种视频防抖处理装置,包括:In a second aspect, an embodiment of the present disclosure further provides a video anti-shake processing device, including:
初始变化量确定模块,用于通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定所述视频中不同图像帧之间拍摄位置的初始变化量;an initial change amount determination module, configured to determine the initial change amount of the shooting position between different image frames in the video based on the initial transformation method by tracking feature points between different image frames in the video;
目标变化量确定模块,用于基于所述初始变化量对应的拟合误差,采用与所述拟合误差匹配的目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量;A target variation determination module, configured to determine, based on the fitting error corresponding to the initial variation, the target variation of the shooting position between different image frames in the video by adopting a target transformation method that matches the fitting error;
移动轨迹生成模块,用于基于所述视频中不同图像帧之间拍摄位置的目标变化量,形成所述视频的拍摄位置的移动轨迹,其中,所述移动轨迹用于指示所述视频中不同图像帧的拍摄位置;a movement trajectory generation module, configured to form a movement trajectory of the shooting position of the video based on the target change amount of the shooting position between different image frames in the video, wherein the movement trajectory is used to indicate different images in the video the shooting position of the frame;
平滑轨迹确定模块,用于分别对所述移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;a smooth trajectory determination module, configured to perform smooth processing on the shooting positions of different image frames in the moving trajectory respectively to obtain a smooth trajectory;
视频防抖处理模块,用于基于所述平滑轨迹和所述移动轨迹之间的差异,对所述视频进行形变,以得到经过防抖处理的视频。A video anti-shake processing module, configured to deform the video based on the difference between the smooth track and the moving track to obtain a video that has undergone anti-shake processing.
第三方面,本公开实施例还提供了一种电子设备,包括存储器和处理器,其中,所述存储器中存储有计算机程序,当所述计算机程序被所述处理器执行时,使得所述电子设备实现本公开实施例提供的任一所述的视频防抖处理方法。In a third aspect, embodiments of the present disclosure further provide an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device is made to The device implements any of the video anti-shake processing methods provided in the embodiments of the present disclosure.
第四方面,本公开实施例还提供了一种计算机可读存储介质,所述存储介质中存储有计算机程序,当所述计算机程序被计算设备执行时,使得所述计算设备实现本公开实施例提供的任一所述的视频防抖处理方法。In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a computing device, the computing device enables the computing device to implement the embodiment of the present disclosure Any of the provided video anti-shake processing methods.
第五方面,提供一种计算机程序产品,包括计算机程序指令,该计算机程序指令使得计算机执行如第一方面或其各实现方式中的方法。In a fifth aspect, there is provided a computer program product comprising computer program instructions that cause a computer to perform a method as in the first aspect or implementations thereof.
第六方面,提供一种计算机程序,计算机程序使得计算机执行如第一方面或其各实现方式中的方法。In a sixth aspect, there is provided a computer program, the computer program causing a computer to perform the method as in the first aspect or implementations thereof.
本公开实施例提供的技术方案与现有技术相比至少具有如下优点:在本公开实施例中,首先基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量,然后基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量,即拟合误差可以用于评估初始变换方式的选用是否合理,其次基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,最后通过轨迹平滑处理和视频形变处理,实现视频防抖处理效果。本公开实施例实现了基于视频中不同图像帧之间拍摄位置的初始变化量对应的拟合误差,动态确定视频中不同图像帧之间的目标变换方式的效果,保证了视频防抖的处理效果,避免了引入过大的拟合误差,有效改善了视频质量。Compared with the prior art, the technical solutions provided by the embodiments of the present disclosure have at least the following advantages: in the embodiments of the present disclosure, the initial change amount of the shooting position between different image frames in the video is first determined based on the initial transformation method, and then based on the initial change The fitting error corresponding to the fitting error is used to determine the target variation of the shooting position between different image frames in the video by using the target transformation method that matches the fitting error, that is, the fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable. The target change amount of the shooting position between different image frames in the video forms the movement trajectory of the shooting position of the video. Finally, the video anti-shake processing effect is realized through the trajectory smoothing processing and video deformation processing. The embodiment of the present disclosure realizes the effect of dynamically determining the target transformation mode between different image frames in the video based on the fitting error corresponding to the initial change of the shooting position between different image frames in the video, and ensures the processing effect of video anti-shake. , which avoids the introduction of excessive fitting errors and effectively improves the video quality.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description serve to explain the principles of the disclosure.
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the accompanying drawings that are required to be used in the description of the embodiments or the prior art will be briefly introduced below. In other words, on the premise of no creative labor, other drawings can also be obtained from these drawings.
图1为本公开实施例提供的一种视频防抖处理方法的流程图;1 is a flowchart of a video anti-shake processing method provided by an embodiment of the present disclosure;
图2为本公开实施例提供的另一种视频防抖处理方法的流程图;2 is a flowchart of another video anti-shake processing method provided by an embodiment of the present disclosure;
图3为本公开实施例提供的一种视频防抖处理装置的结构示意图;3 is a schematic structural diagram of a video anti-shake processing apparatus according to an embodiment of the present disclosure;
图4为本公开实施例提供的一种电子设备的结构示意图。FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
具体实施方式Detailed ways
为了能够更清楚地理解本公开的上述目的、特征和优点,下面将对本公开的方案进行进一步描述。需要说明的是,在不冲突的情况下,本公开的实施例及实施例中的特征可以相互组合。In order to more clearly understand the above objects, features and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments may be combined with each other under the condition of no conflict.
在下面的描述中阐述了很多具体细节以便于充分理解本公开,但本公开还可以采用其他不同于在此描述的方式来实施;显然,说明书中的实施例只是本公开的一部分实施例,而不是全部的实施例。Many specific details are set forth in the following description to facilitate a full understanding of the present disclosure, but the present disclosure can also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of the present disclosure, and Not all examples.
图1为本公开实施例提供的一种视频防抖处理方法的流程图,可以适用于对视频进行防抖处理的情况。该方法可以由视频防抖处理装置执行,该装置可以采用软件和/或硬件实现,并可集成在任意具有计算能力的电子设备上,例如终端或者服务器等。FIG. 1 is a flowchart of a video anti-shake processing method provided by an embodiment of the present disclosure, which can be applied to a situation of performing anti-shake processing on a video. The method can be performed by a video anti-shake processing apparatus, which can be implemented by software and/or hardware, and can be integrated on any electronic device with computing capability, such as a terminal or a server.
在本公开实施例中,待处理视频可以是拍摄中的视频,也可以是拍摄完成的视频,即本公开实施例可以在视频拍摄过程中实时对拍摄的视频进行防抖处理,也可以在视频拍摄完成后对视频进行防抖处理,均可达到改善视频质量的效果。In the embodiment of the present disclosure, the video to be processed may be a video being shot or a video that has been shot, that is, the embodiment of the present disclosure may perform anti-shake processing on the shot video in real time during the video shooting process, or the video may be Anti-shake processing is performed on the video after shooting, which can improve the quality of the video.
如图1所示,本公开实施例提供的视频防抖处理方法可以包括:As shown in FIG. 1 , the video anti-shake processing method provided by the embodiment of the present disclosure may include:
S101、通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量。S101 , by tracking feature points between different image frames in the video, and based on an initial transformation method, determine an initial change amount of shooting positions between different image frames in the video.
通过对视频中不同图像帧之间进行特征点追踪,可以确定不同图像帧之间的匹配特征点(指不同图像帧中针对同一拍摄对象的特征点,匹配特征点的数量可以视情况而定),进而基于初始变换方式和匹配特征点可以确定出不同图像帧之间拍摄位置的初始变化量。特征点追踪可以参考现有技术实现,本公开实施例不作具体限定。其中,视频中的不同图像帧可以是视频中相邻的两帧图像,也可以是间隔至少两帧的图像,例如视频中的当前帧与第一帧图像。初始变换方式是默认使用的、用于计算不同图像帧之间拍摄位置的变化量的一种计算方式,初始变换方式例如可以采用用于表征拍摄位置的变化的初始变换矩阵实现,具体例如可以是单应变换(homography)矩阵等。应当理解,在实际处理过程中,初始变 换方式可以根据处理需求从多个可用的变换方式中灵活选择,本公开实施例不作具体限定。By tracking feature points between different image frames in the video, matching feature points between different image frames can be determined (referring to the feature points of the same object in different image frames, the number of matching feature points can be determined according to the situation) , and then based on the initial transformation method and the matching feature points, the initial variation of the shooting position between different image frames can be determined. The feature point tracking may be implemented with reference to the prior art, which is not specifically limited in the embodiment of the present disclosure. The different image frames in the video may be two adjacent frames of images in the video, or may be images separated by at least two frames, such as the current frame and the first frame of images in the video. The initial transformation method is a calculation method that is used by default and is used to calculate the amount of change in the shooting position between different image frames. The initial transformation method can be implemented by, for example, an initial transformation matrix used to characterize the change of the shooting position, for example, it can be Homography matrix, etc. It should be understood that, in the actual processing process, the initial transformation mode may be flexibly selected from multiple available transformation modes according to processing requirements, which is not specifically limited in the embodiment of the present disclosure.
不同图像帧之间的拍摄位置的初始变化量例如可以是在后帧图像相对在前帧图像的拍摄位置的变化量。以初始变换方式采用初始变换矩阵实现为例,不同图像帧之间拍摄位置的初始变化量可以是在前帧图像到在后帧图像的变换矩阵。The initial change amount of the shooting position between different image frames may be, for example, the change amount of the shooting position of the following frame image relative to the previous frame image. Taking the implementation of the initial transformation method using an initial transformation matrix as an example, the initial change amount of the shooting position between different image frames may be a transformation matrix from the previous frame image to the subsequent frame image.
可选地,本公开实施例提供的视频防抖处理方法还包括:基于初始变换方式和不同图像帧之间匹配成功的特征点,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。拟合误差可以用于评估初始变换方式的选用是否合理,进而确定初始变换方式在视频防抖处理过程中对防抖处理效果的影响。在计算拟合误差的过程中,可以利用初始变换方式对在前帧图像上的特征点进行坐标变换,或者利用该初始变换方式的逆变换对在后帧图像上的特征点进行坐标变换,然后与剩余的另一帧图像上特征点的图像坐标进行比对,从而计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。Optionally, the video anti-shake processing method provided by the embodiment of the present disclosure further includes: calculating a fitting corresponding to the initial variation of the shooting position between different image frames based on the initial transformation method and the feature points that are successfully matched between different image frames. error. The fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable, and then determine the influence of the initial transformation method on the anti-shake processing effect in the video anti-shake processing process. In the process of calculating the fitting error, the initial transformation method can be used to perform coordinate transformation on the feature points on the previous frame image, or the inverse transformation of the initial transformation method can be used to perform coordinate transformation on the feature points on the subsequent frame image, and then It is compared with the image coordinates of the feature points on the remaining image of another frame, so as to calculate the fitting error corresponding to the initial change of the shooting position between different image frames.
进一步地,基于初始变换方式和不同图像帧之间匹配成功的特征点,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差,可以包括:Further, based on the initial transformation method and the feature points that are successfully matched between different image frames, calculating the fitting error corresponding to the initial variation of the shooting position between different image frames may include:
利用初始变换方式对不同图像帧中在前帧图像上的特征点进行坐标变换,得到在前帧图像上特征点的变换坐标;Use the initial transformation method to perform coordinate transformation on the feature points on the previous frame image in different image frames, and obtain the transformed coordinates of the feature points on the previous frame image;
基于不同图像帧中在后帧图像上特征点的图像坐标、以及在前帧图像上特征点的变换坐标,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。Based on the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames, the fitting error corresponding to the initial variation of the shooting position between different image frames is calculated.
示例性地,以初始变换方式采用初始变换矩阵实现,视频中的不同图像帧指视频中相邻的两帧图像为例,对拟合误差的计算进行示例性说明,但不应理解为对本公开实施例的具体限定。假设视频V共包含n帧图像,记第i帧图像为f i,则视频V={f 1,f 2,…,f n-1,f n,},依次对视频的每一帧图像进行以下处理: Exemplarily, the initial transformation method is implemented by using an initial transformation matrix. Different image frames in the video refer to two adjacent frames of images in the video as an example. The calculation of the fitting error is exemplified, but should not be construed as a reference to the present disclosure. Specific limitations of the examples. Assuming that the video V contains n frames of images in total, denote the i-th frame image as f i , then the video V={f 1 ,f 2 ,...,f n-1 ,f n, } The following processing:
1)对于第i帧图像f i,进行特征点提取,记为p i1) For the i-th frame image f i , extract feature points, denoted as p i .
2)在第i+1帧图像f i+1上对上一帧图像的特征点p i进行跟踪,跟踪到的特征点记为p i~i+1,即p i和p i~i+1分别为第i帧图像f i和第i+1帧图像f i+1上的匹配特征点; 2) Track the feature point p i of the previous frame image on the i+1th frame image f i+1 , and the tracked feature points are recorded as p i~i+1 , namely p i and p i~i+ 1 are the matching feature points on the i-th frame image f i and the i+1-th frame image f i+1 ;
3)根据p i和p i~i+1的对应关系,拟合出第i帧图像f i到第i+1帧图像f i+1的初始变换矩阵(即拍摄位置的的初始变化量),记为T i3) According to the corresponding relationship between p i and p i~i+1 , fit the initial transformation matrix from the i-th frame image f i to the i+1-th frame image f i+1 (that is, the initial change of the shooting position) , denoted as T i ;
4)利用初始变换矩阵T i对匹配特征点p i进行坐标变换,得到变换坐标,记为T i*p i4) Utilize the initial transformation matrix T i to carry out coordinate transformation to the matching feature point p i , obtain the transformed coordinates, and denote it as T i * pi ;
5)将T i*p i与p i~i+1进行对比,计算相邻两帧图像之间拍摄位置的初始变化量对应的拟合误差。 5) Compare T i *pi with pi ~ i +1 , and calculate the fitting error corresponding to the initial change of the shooting position between two adjacent frames of images.
理论上,T i*p i与p i~i+1之间的差异越小,即拟合误差越小,初始变换矩阵针对不同图像帧的运动拟合效果越佳,否则初始变换矩阵针对不同图像帧的运动拟合效果较差,需要对初始变换矩阵进行动态替换,也即需要对初始变换方式进行动态替换。 Theoretically, the smaller the difference between T i *pi and p i ~i+1 , the smaller the fitting error, the better the motion fitting effect of the initial transformation matrix for different image frames, otherwise the initial transformation matrix is suitable for different image frames. The motion fitting effect of the image frame is poor, and the initial transformation matrix needs to be dynamically replaced, that is, the initial transformation method needs to be dynamically replaced.
关于利用在后帧图像上特征点的图像坐标和在前帧图像上特征点的变换坐标,得到拟合误差的具体计算方式,在实际处理中可以灵活确定。例如,可以将在后帧图像上特征点的图像坐标和在前帧图像上特征点的变换坐标,按照两帧图像上特征点的对应关系,分别进行求差计算或者求商计算,将得到的各个差值或者各个商值进行求和(包括加权求和),得到不同图像帧之间拍摄位置的初始变化量对应的拟合误差,还可以计算各个差值的平均值或者各个商值的平均值,作为不同图像帧之间拍摄位置的初始变化量对应的拟合误差。The specific calculation method for obtaining the fitting error by using the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image can be flexibly determined in actual processing. For example, the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image can be calculated according to the corresponding relationship between the feature points on the two frames of images. Each difference value or each quotient value is summed (including weighted summation) to obtain the fitting error corresponding to the initial change of the shooting position between different image frames, and the average value of each difference value or the average value of each quotient value can also be calculated. value, as the fitting error corresponding to the initial variation of the shooting position between different image frames.
S102、基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量。S102. Based on the fitting error corresponding to the initial variation, determine the target variation of the shooting position between different image frames in the video by adopting a target transformation method that matches the fitting error.
其中,可以根据拟合误差与误差阈值的关系,确定与拟合误差匹配的目标变换方式,以提高视频防抖的处理效果。误差阈值可以设置为一个值,此时如果拟合误差小于误差阈值,则可以将初始变换方式确定为与拟合误差匹配的目标变换方式,如果拟合误差大于或者等于误差阈值,则可以将与初始变换方式的自由度不同的变换方式,作为目标变换方式,以实现减少不同图像帧之间拍摄位置的拟合误差的效果;误差阈值也可以层次化设置为多个值,每个阈值对应一种变换方式,多个可选变换方式之间的自由度不同,利用每个变换方式得到的不同图像帧之间拍摄位置的初始变化量对应的拟合误差也不同。需要说明的是,本公开实施中提及的各个阈值,在实际处理过程中均可以灵活取值,本公开实施例不作具体限定。Wherein, according to the relationship between the fitting error and the error threshold, a target transformation mode matching the fitting error can be determined, so as to improve the processing effect of video anti-shake. The error threshold can be set to a value. At this time, if the fitting error is less than the error threshold, the initial transformation method can be determined as the target transformation method that matches the fitting error. If the fitting error is greater than or equal to the error threshold, the matching The transformation methods with different degrees of freedom of the initial transformation method are used as the target transformation method to achieve the effect of reducing the fitting error of the shooting position between different image frames; the error threshold can also be hierarchically set to multiple values, and each threshold corresponds to a There are different transformation modes, the degrees of freedom between the multiple optional transformation modes are different, and the fitting errors corresponding to the initial changes of the shooting positions between different image frames obtained by each transformation mode are also different. It should be noted that, each threshold mentioned in the implementation of the present disclosure can be flexibly set in the actual processing process, which is not specifically limited in the embodiment of the present disclosure.
示例性地,误差阈值包括第一误差阈值和第二误差阈值,第一误差阈值的取值小于第二误差阈值,如果视频中不同图像帧之间拍摄位置的初始变化量对应的拟合误差小于第一误差阈值,则将初始变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;或者Exemplarily, the error threshold includes a first error threshold and a second error threshold, and the value of the first error threshold is less than the second error threshold, if the fitting error corresponding to the initial variation of the shooting position between different image frames in the video is less than If the first error threshold is set, the initial transformation mode is determined as the target transformation mode that matches the fitting error, and the target transformation mode is used to determine the target change amount of the shooting position between different image frames in the video; or
如果初始变化量对应的拟合误差大于或等于第一误差阈值,且小于第二误差阈值,则将自由度小于初始变换方式的第一变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;或者If the fitting error corresponding to the initial variation is greater than or equal to the first error threshold and less than the second error threshold, the first transformation with a degree of freedom smaller than the initial transformation is determined as the target transformation that matches the fitting error, and Determine the amount of target change in the shooting position between different image frames in the video by means of target transformation; or
如果初始变化量对应的拟合误差大于或等于第二误差阈值,则将自由度小于第一变换方式的第二变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量。If the fitting error corresponding to the initial change amount is greater than or equal to the second error threshold, the second transformation method with a degree of freedom smaller than the first transformation method is determined as the target transformation method matching the fitting error, and the target transformation method is used to determine the video The amount of target change in the shooting position between different image frames in .
进一步地,初始变换方式包括单应变换方式,第一变换方式包括仿射变换(affine transformation)方式,第二变换方式包括相似变换(similaritytransformation)方式。Further, the initial transformation mode includes a homography transformation mode, the first transformation mode includes an affine transformation mode, and the second transformation mode includes a similarity transformation mode.
其中,单应性变换是一个平面到另一个平面的变换关系,一共有八个自由度;仿射变换是一种二维坐标到二维坐标之间的线性变换,它保持了二维图形的“平直性”和“平行性”,主要包括平移变换、旋转变换、尺度变换、倾斜变换(或称为错切变换、剪切变换、偏移 变换)、翻转变换,一共有六个自由度;相比于仿射变换,相似变换中不存在倾斜变换、翻转变换,一共有四个自由度。Among them, the homography transformation is the transformation relationship from one plane to another plane, with a total of eight degrees of freedom; the affine transformation is a linear transformation from two-dimensional coordinates to two-dimensional coordinates, which maintains the two-dimensional graphics. "Flatness" and "parallelism" mainly include translation transformation, rotation transformation, scale transformation, tilt transformation (or called staggered transformation, shear transformation, offset transformation), flip transformation, a total of six degrees of freedom ; Compared with affine transformation, there is no oblique transformation and flip transformation in similarity transformation, and there are a total of four degrees of freedom.
一种变换关系即对应一种运动模型,自由度越高的运动模型(即自由度高的变换矩阵)拟合能力越强,但更容易引入拟合错误,因此,在视频防抖处理过程中可以首先使用自由度高的运动模型来拟合视频中不同图像帧之间的运动,然后根据拟合误差动态调整不同图像帧之间的运动模型类型,即如果拟合误差过大,则使用自由度低的运动模型替换自由度高的运动模型,这样可以在降低平滑效果的情况下,避免引入较大的拟合错误,实现不同图像帧之间运动平滑与拟合误差的平衡,确保最终的视频防抖处理效果。A transformation relationship corresponds to a motion model. A motion model with a higher degree of freedom (ie, a transformation matrix with a higher degree of freedom) has better fitting ability, but it is easier to introduce fitting errors. Therefore, in the process of video anti-shake processing You can first use a motion model with a high degree of freedom to fit the motion between different image frames in the video, and then dynamically adjust the motion model type between different image frames according to the fitting error, that is, if the fitting error is too large, use the free A motion model with a low degree of freedom replaces a motion model with a high degree of freedom, so as to avoid introducing large fitting errors while reducing the smoothing effect, to achieve a balance between motion smoothing and fitting errors between different image frames, and to ensure the final Video stabilization effect.
S103、基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,其中,移动轨迹用于指示视频中不同图像帧的拍摄位置。S103. Based on the target variation of the shooting position between different image frames in the video, a movement track of the shooting position of the video is formed, wherein the movement track is used to indicate the shooting position of different image frames in the video.
示例性的,可以在视频中选择一帧图像作为参考帧图像,该参考帧图像可以适应性确定,然后利用不同图像帧之间拍摄位置的目标变化量,得到视频中每帧图像相对于参考帧图像的拍摄位置的目标变化量,进而基于多个目标变化量得到视频的拍摄位置的移动轨迹(或称为用于拍摄视频的拍摄装置的移动轨迹)。Exemplarily, one frame of image in the video can be selected as the reference frame image, and the reference frame image can be determined adaptively, and then the target variation of the shooting position between different image frames can be used to obtain the relative value of each frame of image in the video relative to the reference frame. The target change amount of the shooting position of the image, and then the movement trajectory of the shooting position of the video (or the movement trajectory of the shooting device for shooting the video) is obtained based on the multiple target changes.
可选地,在本公开实施例中,初始变化量或目标变化量可以采用变换矩阵表示,进而,移动轨迹包括多个变换矩阵,即移动轨迹中的不同变换矩阵可以分别表示视频中不同图像帧的拍摄位置;相应地,以参考帧图像为视频中的第一帧图像为例,基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,包括:Optionally, in this embodiment of the present disclosure, the initial change amount or the target change amount may be represented by a transformation matrix, and further, the movement track includes multiple transformation matrices, that is, different transformation matrices in the movement track may respectively represent different image frames in the video. Correspondingly, taking the reference frame image as the first frame image in the video as an example, based on the target variation of the shooting position between different image frames in the video, the movement trajectory of the shooting position of the video is formed, including:
基于视频中不同图像帧之间拍摄位置的目标变换矩阵,确定视频中每帧图像相对第一帧图像的变换矩阵;Determine the transformation matrix of each frame image in the video relative to the first frame image based on the target transformation matrix of the shooting position between different image frames in the video;
基于视频中每帧图像相对第一帧图像的变换矩阵,形成视频的拍摄位置的移动轨迹。Based on the transformation matrix of each frame of image in the video relative to the first frame of image, the movement track of the shooting position of the video is formed.
假设视频中第i帧图像f i与第i+1帧图像f i+1之间拍摄位置的目标变换矩阵表示为T i,则可以将第i帧图像f i以及第i帧之前的不同图像帧(例如各个相邻两帧图像)之间拍摄位置的目标变换矩阵进行累积处理,例如进行累乘计算(具体可以根据实际处理而定),得到第i帧图像f i相对第一帧图像的拍摄位置的变换矩阵,表示如下: Assuming that the target transformation matrix of the shooting position between the i-th frame image f i and the i+1-th frame image f i+1 in the video is represented as T i , then the i-th frame image f i and the different images before the i-th frame can be expressed as T i . The target transformation matrix of the shooting position between the frames (for example, each adjacent two frame images) is accumulated and processed, for example, the cumulative multiplication calculation (specifically can be determined according to the actual processing), and the difference between the i-th frame image f i relative to the first frame image is obtained. The transformation matrix of the shooting position, expressed as follows:
Figure PCTCN2022085634-appb-000001
Figure PCTCN2022085634-appb-000001
依次得到视频中每帧图像相对第一帧图像的拍摄位置的变换矩阵,则视频的拍摄位置的移动轨迹可以表示为C={C 1,C 2,…,C n-1,C n},n表示视频中包括的图像帧数。 The transformation matrix of the shooting position of each frame of image in the video relative to the first frame of image is obtained in turn, then the movement trajectory of the shooting position of the video can be expressed as C={C 1 ,C 2 ,...,C n-1 ,C n }, n represents the number of image frames included in the video.
S104、分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹。S104 , performing smoothing processing on the shooting positions of different image frames in the moving track respectively to obtain a smooth track.
得到视频的拍摄位置的移动轨迹,也即确定了视频的拍摄位置的抖动趋势,可以利用现有技术中任意可用的平滑处理算法,例如高斯平滑处理算法等,对移动轨迹中不同图像 帧的拍摄位置进行平滑处理,得到平滑轨迹,平滑轨迹例如可以表示为
Figure PCTCN2022085634-appb-000002
平滑轨迹用于指示平滑处理后的视频中不同图像帧的拍摄位置。
The movement trajectory of the shooting position of the video is obtained, that is, the shaking trend of the shooting position of the video is determined. Any available smoothing algorithm in the prior art, such as Gaussian smoothing algorithm, etc., can be used to shoot different image frames in the moving trajectory. The position is smoothed to obtain a smooth trajectory. The smooth trajectory can be expressed as, for example,
Figure PCTCN2022085634-appb-000002
Smoothing tracks are used to indicate where different image frames were taken in the smoothed video.
S105、基于平滑轨迹和移动轨迹之间的差异,对视频进行形变,以得到经过防抖处理的视频。S105 , deforming the video based on the difference between the smooth track and the moving track to obtain a video that has undergone anti-shake processing.
将平滑轨迹
Figure PCTCN2022085634-appb-000003
和平滑前的移动轨迹C进行比对,可以确定移动轨迹的调整参数W={W 1,W 2,…,W n-1,W n},调整参数W中的各个子值
Figure PCTCN2022085634-appb-000004
n表示视频中包括的图像帧数;然后可以按照调整参数中各个子值与视频中每帧图像的对应关系,基于调整参数中的每个子值对相应的图像帧进行形变处理,从而得到防抖处理后的视频。在形变处理过程中,涉及对特定帧图像的旋转、平移、缩放或者裁剪等处理,可以根据实际处理需求来执行。
will smooth the trajectory
Figure PCTCN2022085634-appb-000003
Comparing with the moving trajectory C before smoothing, the adjustment parameter W={W 1 ,W 2 ,...,W n-1 ,W n } of the moving trajectory can be determined, and each sub-value in the adjustment parameter W can be determined.
Figure PCTCN2022085634-appb-000004
n represents the number of image frames included in the video; then, according to the corresponding relationship between each sub-value in the adjustment parameter and each frame of image in the video, the corresponding image frame can be deformed based on each sub-value in the adjustment parameter, so as to obtain anti-shake processed video. In the deformation processing process, it involves the rotation, translation, scaling or cropping of a specific frame image, which can be performed according to actual processing requirements.
在本公开实施例中,首先基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量,然后基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量,即拟合误差可以用于评估初始变换方式的选用是否合理,其次基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,最后通过轨迹平滑处理和视频形变处理,实现视频防抖处理效果。本公开实施例实现了基于视频中不同图像帧之间拍摄位置的初始变化量对应的拟合误差,动态确定视频中不同图像帧之间的目标变换方式的效果,保证了视频防抖的处理效果,避免了引入过大的拟合误差,有效改善了视频质量。In the embodiment of the present disclosure, the initial change amount of the shooting position between different image frames in the video is first determined based on the initial transformation method, and then based on the fitting error corresponding to the initial change amount, the target transformation method that matches the fitting error is used to determine the video The target change of the shooting position between different image frames in the video, that is, the fitting error can be used to evaluate whether the selection of the initial transformation method is reasonable, and then the shooting position of the video is formed based on the target change of the shooting position between different image frames in the video. Finally, through the trajectory smoothing and video deformation processing, the video anti-shake processing effect is realized. The embodiment of the present disclosure realizes the effect of dynamically determining the target transformation mode between different image frames in the video based on the fitting error corresponding to the initial change of the shooting position between different image frames in the video, and ensures the processing effect of video anti-shake. , which avoids the introduction of excessive fitting errors and effectively improves the video quality.
图2为本公开实施例提供的另一种视频防抖处理方法的流程图,基于上述技术方案进一步优化与扩展,并可以与上述各个可选实施方式进行结合。FIG. 2 is a flowchart of another video anti-shake processing method provided by an embodiment of the present disclosure, which is further optimized and expanded based on the foregoing technical solution, and may be combined with the foregoing optional implementation manners.
如图2所示,本公开实施例提供的视频防抖处理方法可以包括:As shown in FIG. 2 , the video anti-shake processing method provided by the embodiment of the present disclosure may include:
S201、通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量。S201 , by tracking feature points between different image frames in the video, and based on an initial transformation method, determine the initial change amount of the shooting position between different image frames in the video.
S202、利用初始变换方式对不同图像帧中在前帧图像上的特征点进行坐标变换,得到在前帧图像上特征点的变换坐标。S202 , using an initial transformation method to perform coordinate transformation on the feature points on the previous frame image in different image frames, to obtain transformed coordinates of the feature points on the previous frame image.
S203、利用不同图像帧中在后帧图像上特征点的图像坐标、以及在前帧图像上特征点的变换坐标,计算不同图像帧之间拍摄位置的初始变化量对应的累计误差。S203 , using the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames to calculate the cumulative error corresponding to the initial variation of the shooting position between different image frames.
示例性地,以视频中第i帧图像f i与第i+1帧图像f i+1为例,这两帧图像上匹配成功的特征点的数量表示为M i,第i帧图像f i上的第j个特征点表示为
Figure PCTCN2022085634-appb-000005
则该第j个特征点对应的变换坐标可以表示为
Figure PCTCN2022085634-appb-000006
T i表示第i帧图像f i与第i+1帧图像f i+1之间拍摄位置的初始 变化量,第i+1帧图像f i+1上的第j个特征点表示为
Figure PCTCN2022085634-appb-000007
则第i帧图像f i与第i+1帧图像f i+1之间拍摄位置的初始变化量对应的累计误差可以表示为
Figure PCTCN2022085634-appb-000008
Exemplarily, taking the i-th frame image f i and the i+1-th frame image f i+1 as an example, the number of successfully matched feature points on these two frame images is represented as M i , and the i-th frame image f i The j-th feature point on is represented as
Figure PCTCN2022085634-appb-000005
Then the transformed coordinates corresponding to the jth feature point can be expressed as
Figure PCTCN2022085634-appb-000006
T i represents the initial change of the shooting position between the i-th frame image f i and the i+1-th frame image f i +1 , and the j-th feature point on the i+1-th frame image f i+1 is expressed as
Figure PCTCN2022085634-appb-000007
Then the cumulative error corresponding to the initial change of the shooting position between the i-th frame image f i and the i+1-th frame image f i+1 can be expressed as
Figure PCTCN2022085634-appb-000008
S204、基于累计误差和在前帧图像上特征点的数量,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。S204 , based on the accumulated error and the number of feature points on the image of the previous frame, calculate the fitting error corresponding to the initial variation of the shooting position between different image frames.
继续以上述示例为例,可以基于累计误差和在前帧图像上特征点的数量(等于不同图像帧之间匹配成功的特征点的数量)M i进行均值计算,得到不同图像帧之间拍摄位置的初始变化量对应的拟合误差E i,可以表示如下: Continuing to take the above example as an example, the mean value can be calculated based on the accumulated error and the number of feature points on the previous frame image (equal to the number of successfully matched feature points between different image frames) M i to obtain the shooting position between different image frames. The fitting error E i corresponding to the initial variation of , can be expressed as follows:
Figure PCTCN2022085634-appb-000009
Figure PCTCN2022085634-appb-000009
通过针对多个匹配成功的特征点进行均值计算,确定不同图像帧之间拍摄位置的初始变化量对应的拟合误差,保证了拟合误差计算的准确性。By calculating the mean value of multiple successfully matched feature points, the fitting error corresponding to the initial variation of the shooting position between different image frames is determined, which ensures the accuracy of the fitting error calculation.
S205、基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量。S205. Based on the fitting error corresponding to the initial variation, determine the target variation of the shooting position between different image frames in the video by adopting a target transformation method that matches the fitting error.
S206、基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,其中,移动轨迹用于指示视频中不同图像帧的拍摄位置。S206 . Based on the target variation of the shooting position between different image frames in the video, a movement track of the shooting position of the video is formed, wherein the movement track is used to indicate the shooting position of different image frames in the video.
S207、分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹。S207 , performing smoothing processing on the shooting positions of different image frames in the moving track respectively to obtain a smooth track.
示例性地,可以基于预设平滑半径,分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹。其中,预设平滑半径的取值决定了参与平滑处理的图像帧数,其具体取值可以在实际处理过程中灵活确定,本公开实施例不作具体限定。示例性的,针对视频中的每帧图像,可以基于预设平滑半径,确定参与平滑处理的预设帧数的图像;然后基于预设帧数的图像在移动轨迹中对应的拍摄位置,确定对应每帧图像的平滑后的拍摄位置,例如可以对预设帧数的图像在移动轨迹中对应的拍摄位置进行加权求和计算,得到对应每帧图像的平滑后的拍摄位置;进而基于对应每帧图像的平滑后的拍摄位置,得到平滑轨迹。Exemplarily, based on a preset smoothing radius, smoothing processing may be performed on the shooting positions of different image frames in the moving track respectively to obtain a smooth track. The value of the preset smoothing radius determines the number of image frames involved in the smoothing process, and its specific value can be flexibly determined in the actual processing process, which is not specifically limited in the embodiment of the present disclosure. Exemplarily, for each frame of image in the video, an image with a preset number of frames participating in the smoothing process may be determined based on a preset smoothing radius; For the smoothed shooting position of each frame of image, for example, a weighted sum calculation can be performed on the corresponding shooting positions of the images with a preset number of frames in the moving trajectory to obtain the smoothed shooting position corresponding to each frame of image; The smoothed shooting position of the image is obtained to obtain a smooth trajectory.
可选的,基于预设平滑半径,确定参与平滑处理的预设帧数的图像,可以包括:针对视频中的每帧图像,可以基于该预设平滑半径,确定每帧图像之前的第一预设帧数的在前帧图像;将每帧图像以及第一预设帧数(此时其取值即为预设平滑半径的值)的在前帧图像,确定为参与平滑处理的预设帧数的图像;或者,可以基于该预设平滑半径,确定每帧图像之前的第二预设帧数(此时其取值即为预设平滑半径的值)的在前帧图像,以及确定每帧图像之后的第二预设帧数的在后帧图像;将每帧图像、第二预设帧数的在前帧图像以及第二预设帧数的在后帧图像,确定为参与平滑处理的预设帧数的图像。Optionally, based on the preset smoothing radius, determining the images of the preset number of frames participating in the smoothing process may include: for each frame of the image in the video, based on the preset smoothing radius, determining the first preset before each frame of the image. Set the previous frame image of the frame number; determine each frame image and the previous frame image of the first preset frame number (the value of which is the value of the preset smoothing radius at this time) as the preset frame participating in the smoothing process or, based on the preset smoothing radius, determine the previous frame image of the second preset number of frames before each frame of image (the value of which is the value of the preset smoothing radius at this time), and determine each frame of image. The subsequent frame images of the second preset frame number after the frame image; each frame image, the previous frame image of the second preset frame number, and the subsequent frame image of the second preset frame number are determined to participate in the smoothing process the preset number of frames of the image.
以按照预设平滑半径的取值,分别在每帧图像之前和之后取相同帧数的图像,且对应每帧图像的平滑后的拍摄位置采用平滑矩阵表示为例,每帧图像f i的平滑矩阵可以表示如下: Taking the value of the preset smoothing radius, the images of the same number of frames are taken before and after each frame of image, and the smoothed shooting position corresponding to each frame of image is represented by a smoothing matrix as an example, the smoothing of each frame of image f i is taken as an example. The matrix can be represented as follows:
Figure PCTCN2022085634-appb-000010
Figure PCTCN2022085634-appb-000010
其中,r为预设平滑半径,C t为参与平滑处理的每帧图像在移动轨迹C中对应的变换矩阵(即拍摄位置),w i~t为参与平滑处理的每帧图像的权重,权重取值可以适应性设置,本公开实施例不作具体限定。得到每帧图像的平滑矩阵后,平滑轨迹可以表示为
Figure PCTCN2022085634-appb-000011
Among them, r is the preset smoothing radius, C t is the corresponding transformation matrix (ie shooting position) of each frame of image participating in the smoothing process in the moving track C, and w i~t is the weight of each frame of the image participating in the smoothing process. The value can be set adaptively, which is not specifically limited in the embodiment of the present disclosure. After obtaining the smoothing matrix of each frame of image, the smoothed trajectory can be expressed as
Figure PCTCN2022085634-appb-000011
S208、基于平滑轨迹和移动轨迹之间的差异,确定调整参数。S208. Determine the adjustment parameter based on the difference between the smooth track and the moving track.
示例性的,可以将拍摄装置的平滑轨迹
Figure PCTCN2022085634-appb-000012
与平滑前的移动轨迹C相减,得到调整参数W={W 1,W 2,…,W n-1,W n},调整参数W中的各个子值可以表示为
Figure PCTCN2022085634-appb-000013
Exemplarily, the smooth trajectory of the photographing device can be
Figure PCTCN2022085634-appb-000012
Subtract it from the moving trajectory C before smoothing to obtain the adjustment parameter W={W 1 ,W 2 ,...,W n-1 ,W n }, and each sub-value in the adjustment parameter W can be expressed as
Figure PCTCN2022085634-appb-000013
S209、利用调整参数对视频进行形变,以得到经过防抖处理的视频。S209. Transform the video by using the adjustment parameters to obtain a video that has undergone anti-shake processing.
可以按照调整参数中各个子值与视频中每帧图像的对应关系,基于调整参数中的每个子值对相应的图像帧进行形变处理,从而得到防抖处理后的视频。According to the correspondence between each sub-value in the adjustment parameter and each frame of image in the video, the corresponding image frame can be deformed based on each sub-value in the adjustment parameter, so as to obtain the video after anti-shake processing.
在本公开实施例中,通过计算视频中不同图像帧之间拍摄位置的初始变化量对应的拟合误差,实现了根据拟合误差对不同图像帧之间可用的变换方式的动态确定,保证了视频防抖的处理效果,避免了引入过大的拟合误差,有效改善了视频质量。In the embodiment of the present disclosure, by calculating the fitting error corresponding to the initial variation of the shooting position between different image frames in the video, the dynamic determination of the available transformation modes between different image frames according to the fitting error is realized, ensuring that The processing effect of video anti-shake avoids the introduction of excessive fitting errors and effectively improves the video quality.
图3为本公开实施例提供的一种视频防抖处理装置的结构示意图,可以适用于对视频进行防抖处理的情况。该装置可以采用软件和/或硬件实现,并可集成在任意具有计算能力的电子设备上,例如终端或者服务器等。FIG. 3 is a schematic structural diagram of a video anti-shake processing apparatus according to an embodiment of the present disclosure, which can be applied to a situation of performing anti-shake processing on a video. The apparatus can be implemented by software and/or hardware, and can be integrated on any electronic device with computing capability, such as a terminal or a server.
如图3所示,本公开实施例提供的视频防抖处理装置300可以包括初始变化量确定模块301、目标变化量确定模块302、移动轨迹生成模块303、平滑轨迹确定模块304和视频防抖处理模块305,其中:As shown in FIG. 3 , the video anti-shake processing apparatus 300 provided by the embodiment of the present disclosure may include an initial change amount determination module 301, a target change amount determination module 302, a movement trajectory generation module 303, a smooth trajectory determination module 304, and video anti-shake processing. Module 305, where:
初始变化量确定模块301,用于通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量;The initial change amount determination module 301 is used to determine the initial change amount of the shooting position between different image frames in the video based on the initial transformation method by performing feature point tracking between different image frames in the video;
目标变化量确定模块302,用于基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;The target change amount determination module 302 is used for determining the target change amount of the shooting position between different image frames in the video based on the fitting error corresponding to the initial change amount by adopting a target transformation method that matches the fitting error;
移动轨迹生成模块303,用于基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,其中,移动轨迹用于指示视频中不同图像帧的拍摄位置;The movement trajectory generation module 303 is used to form the movement trajectory of the shooting position of the video based on the target variation of the shooting position between different image frames in the video, wherein the movement trajectory is used to indicate the shooting position of different image frames in the video;
平滑轨迹确定模块304,用于分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理, 得到平滑轨迹;The smooth trajectory determination module 304 is configured to perform smoothing processing on the shooting positions of different image frames in the moving trajectory respectively to obtain a smooth trajectory;
视频防抖处理模块305,用于基于平滑轨迹和移动轨迹之间的差异,对视频进行形变,以得到经过防抖处理的视频。The video anti-shake processing module 305 is configured to deform the video based on the difference between the smooth track and the moving track, so as to obtain a video that has undergone anti-shake processing.
可选地,本公开实施例提供的视频防抖处理装置300还包括:Optionally, the video anti-shake processing apparatus 300 provided in this embodiment of the present disclosure further includes:
变换坐标确定模块,用于利用初始变换方式对不同图像帧中在前帧图像上的特征点进行坐标变换,得到在前帧图像上特征点的变换坐标;The transformation coordinate determination module is used to perform coordinate transformation on the feature points on the previous frame image in different image frames by using the initial transformation method, so as to obtain the transformed coordinates of the feature points on the previous frame image;
拟合误差计算模块,用于基于不同图像帧中在后帧图像上特征点的图像坐标、以及在前帧图像上特征点的变换坐标,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。The fitting error calculation module is used to calculate the corresponding value of the initial change of the shooting position between different image frames based on the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames. Fitting error.
可选地,拟合误差计算模块包括:Optionally, the fitting error calculation module includes:
累计误差计算单元,用于利用不同图像帧中在后帧图像上特征点的图像坐标、以及在前帧图像上特征点的变换坐标,计算不同图像帧之间拍摄位置的初始变化量对应的累计误差;The cumulative error calculation unit is used to calculate the cumulative corresponding to the initial change of the shooting position between different image frames by using the image coordinates of the feature points on the subsequent frame image and the transformed coordinates of the feature points on the previous frame image in different image frames error;
拟合误差计算单元,用于基于累计误差和在前帧图像上特征点的数量,计算不同图像帧之间拍摄位置的初始变化量对应的拟合误差。The fitting error calculation unit is configured to calculate the fitting error corresponding to the initial variation of the shooting position between different image frames based on the accumulated error and the number of feature points on the previous frame image.
可选地,目标变化量确定模块302包括:Optionally, the target variation determination module 302 includes:
第一确定单元,用于如果初始变化量对应的拟合误差小于第一误差阈值,则将初始变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;或者a first determining unit, configured to determine the initial transformation mode as a target transformation mode matching the fitting error if the fitting error corresponding to the initial change amount is smaller than the first error threshold, and use the target transformation mode to determine different image frames in the video The amount of target change between shooting positions; or
第二确定单元,用于如果初始变化量对应的拟合误差大于或等于第一误差阈值,且小于第二误差阈值,则将自由度小于初始变换方式的第一变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;或者a second determining unit, configured to determine the first transformation mode with the degree of freedom smaller than the initial transformation mode as the fitting error if the fitting error corresponding to the initial change amount is greater than or equal to the first error threshold and less than the second error threshold The matching target transformation method, and the target transformation method is used to determine the target change amount of the shooting position between different image frames in the video; or
第二确定单元,用于如果初始变化量对应的拟合误差大于或等于第二误差阈值,则将自由度小于第一变换方式的第二变换方式确定为与拟合误差匹配的目标变换方式,并采用目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量。a second determining unit, configured to determine a second transformation mode with a degree of freedom smaller than the first transformation mode as a target transformation mode matching the fitting error if the fitting error corresponding to the initial change amount is greater than or equal to the second error threshold, And adopt the target transformation method to determine the target change amount of the shooting position between different image frames in the video.
可选地,初始变换方式包括单应变换方式,第一变换方式包括仿射变换方式,第二变换方式包括相似变换方式。Optionally, the initial transformation mode includes a homography transformation mode, the first transformation mode includes an affine transformation mode, and the second transformation mode includes a similarity transformation mode.
可选地,初始变化量或目标变化量采用变换矩阵表示;Optionally, the initial change amount or the target change amount is represented by a transformation matrix;
移动轨迹生成模块303包括:The movement trajectory generation module 303 includes:
变换矩阵确定单元,用于基于视频中不同图像帧之间拍摄位置的目标变换矩阵,确定视频中每帧图像相对第一帧图像的变换矩阵;A transformation matrix determining unit, for determining the transformation matrix of each frame of image relative to the first frame of image in the video based on the target transformation matrix of the shooting position between different image frames in the video;
移动轨迹生成单元,用于基于视频中每帧图像相对第一帧图像的变换矩阵,形成视频的拍摄位置的移动轨迹。The movement trajectory generation unit is configured to form the movement trajectory of the shooting position of the video based on the transformation matrix of each frame of image in the video relative to the first frame of image.
可选地,视频防抖处理模块305包括:Optionally, the video anti-shake processing module 305 includes:
调整参数确定单元,用于基于平滑轨迹和移动轨迹之间的差异,确定调整参数;an adjustment parameter determination unit for determining an adjustment parameter based on the difference between the smooth trajectory and the moving trajectory;
视频形变单元,用于利用调整参数对视频进行形变,以得到经过防抖处理的视频。The video deformation unit is used to deform the video by using the adjustment parameters to obtain the video that has undergone anti-shake processing.
本公开实施例所提供的视频防抖处理装置可执行本公开实施例所提供的任意视频防抖处理方法,具备执行方法相应的功能模块和有益效果。本公开装置实施例中未详尽描述的内容可以参考本公开任意方法实施例中的描述。The video anti-shake processing apparatus provided by the embodiment of the present disclosure can execute any video anti-shake processing method provided by the embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method. For the content that is not described in detail in the apparatus embodiment of the present disclosure, reference may be made to the description in any method embodiment of the present disclosure.
图4为本公开实施例提供的一种电子设备的结构示意图,用于对实现本公开实施例提供的视频防抖处理方法的电子设备进行示例性说明。本公开实施例中的电子设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机、智能家居设备、可穿戴电子设备、服务器等等的固定终端。图4示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和占用范围带来任何限制。FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, which is used to exemplarily describe an electronic device that implements the video anti-shake processing method provided by the embodiment of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (eg, Mobile terminals such as car navigation terminals), etc., and stationary terminals such as digital TVs, desktop computers, smart home devices, wearable electronic devices, servers, and the like. The electronic device shown in FIG. 4 is only an example, and should not impose any limitation on the functions and occupancy scope of the embodiments of the present disclosure.
如图4所示,电子设备400包括一个或多个处理器401和存储器402。As shown in FIG. 4 , electronic device 400 includes one or more processors 401 and memory 402 .
处理器401可以是中央处理单元(CPU)或者具有数据处理能力和/或指令执行能力的其他形式的处理单元,并且可以控制电子设备400中的其他组件以执行期望的功能。 Processor 401 may be a central processing unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in electronic device 400 to perform desired functions.
存储器402可以包括一个或多个计算机程序产品,计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。易失性存储器例如可以包括随机存取存储器(RAM)和/或高速缓冲存储器(cache)等。非易失性存储器例如可以包括只读存储器(ROM)、硬盘、闪存等。在计算机可读存储介质上可以存储一个或多个计算机程序指令,处理器401可以运行程序指令,以实现本公开实施例提供的视频防抖处理方法,还可以实现其他期望的功能。在计算机可读存储介质中还可以存储诸如输入信号、信号分量、噪声分量等各种内容。 Memory 402 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and/or cache memory, among others. Non-volatile memory may include, for example, read only memory (ROM), hard disk, flash memory, and the like. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 401 may execute the program instructions to implement the video anti-shake processing method provided by the embodiments of the present disclosure, and may also implement other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
其中,本公开实施例提供的视频防抖处理方法可以包括:通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量;基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,其中,移动轨迹用于指示视频中不同图像帧的拍摄位置;分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;基于平滑轨迹和移动轨迹之间的差异,对视频进行形变,以得到经过防抖处理的视频。应当理解,电子设 备400还可以执行本公开方法实施例提供的其他可选实施方案。Wherein, the video anti-shake processing method provided by the embodiment of the present disclosure may include: by tracking feature points between different image frames in the video, determining the initial change amount of the shooting position between different image frames in the video based on an initial transformation method; The fitting error corresponding to the initial variation is determined by the target transformation method that matches the fitting error to determine the target variation of the shooting position between different image frames in the video; based on the target variation of the shooting position between different image frames in the video, the The moving track of the shooting position of the video, wherein the moving track is used to indicate the shooting position of different image frames in the video; the shooting positions of different image frames in the moving track are respectively smoothed to obtain a smooth track; based on the difference between the smooth track and the moving track The difference between the video and the video is deformed to obtain an anti-shake video. It should be understood that the electronic device 400 may also perform other optional implementations provided by the method embodiments of the present disclosure.
在一个示例中,电子设备400还可以包括:输入装置403和输出装置404,这些组件通过总线系统和/或其他形式的连接机构(未示出)互连。In one example, the electronic device 400 may also include an input device 403 and an output device 404 interconnected by a bus system and/or other form of connection mechanism (not shown).
此外,该输入装置403还可以包括例如键盘、鼠标等等。In addition, the input device 403 may also include, for example, a keyboard, a mouse, and the like.
该输出装置404可以向外部输出各种信息,包括确定出的距离信息、方向信息等。该输出装置404可以包括例如显示器、扬声器、打印机、以及通信网络及其所连接的远程输出设备等等。The output device 404 can output various information to the outside, including the determined distance information, direction information, and the like. The output devices 404 may include, for example, displays, speakers, printers, and communication networks and their connected remote output devices, among others.
当然,为了简化,图4中仅示出了该电子设备400中与本公开有关的组件中的一些,省略了诸如总线、输入/输出接口等等的组件。除此之外,根据具体应用情况,电子设备400还可以包括任何其他适当的组件。Of course, for simplicity, only some of the components in the electronic device 400 related to the present disclosure are shown in FIG. 4 , and components such as buses, input/output interfaces, and the like are omitted. Besides, the electronic device 400 may also include any other appropriate components according to the specific application.
除了上述方法和设备以外,本公开的实施例还可以是计算机程序产品,其包括计算机程序或计算机程序指令,计算机程序或计算机程序指令在被处理器执行时使得计算设备实现本公开实施例所提供的任意视频防抖处理方法。In addition to the above-mentioned methods and devices, the embodiments of the present disclosure may also be computer program products, which include computer programs or computer program instructions, which, when executed by a processor, cause a computing device to implement what is provided by the embodiments of the present disclosure. Any video anti-shake processing method.
计算机程序产品可以以一种或多种程序设计语言的任意组合来编写用于执行本公开实施例操作的程序代码,程序设计语言包括面向对象的程序设计语言,诸如Java、C++等,还包括常规的过程式程序设计语言,诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户电子设备上执行、部分地在用户电子设备上执行、作为一个独立的软件包执行、部分在用户电子设备上且部分在远程电子设备上执行、或者完全在远程电子设备上执行。The computer program product may write program code for performing operations of embodiments of the present disclosure in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., as well as conventional procedural programming language, such as "C" language or similar programming language. The program code may execute entirely on the user electronic device, partly on the user electronic device, as a stand-alone software package, partly on the user electronic device and partly on the remote electronic device, or entirely on the remote electronic device execute on.
此外,本公开实施例还可以提供一种计算机可读存储介质,其上存储有计算机程序指令,计算机程序指令在被处理器运行时使得计算设备实现本公开实施例所提供的任意视频防抖处理方法。In addition, the embodiments of the present disclosure may further provide a computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by the processor, the computer program instructions enable the computing device to implement any video anti-shake processing provided by the embodiments of the present disclosure method.
其中,本公开实施例提供的视频防抖处理方法可以包括:通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定视频中不同图像帧之间拍摄位置的初始变化量;基于初始变化量对应的拟合误差,采用与拟合误差匹配的目标变换方式确定视频中不同图像帧之间拍摄位置的目标变化量;基于视频中不同图像帧之间拍摄位置的目标变化量,形成视频的拍摄位置的移动轨迹,其中,移动轨迹用于指示视频中不同图像帧的拍摄位置;分别对移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;基于平滑轨迹和移动轨迹之间的差异,对视频进行形变,以得到经过防抖处理的视频。应当理解,计算机程序指令在被处理器运行时,还可以使得计算设备实现本公开方法实施例提供的其他可选实施方案。Wherein, the video anti-shake processing method provided by the embodiment of the present disclosure may include: by tracking feature points between different image frames in the video, determining the initial change amount of the shooting position between different image frames in the video based on an initial transformation method; The fitting error corresponding to the initial variation is determined by the target transformation method that matches the fitting error to determine the target variation of the shooting position between different image frames in the video; based on the target variation of the shooting position between different image frames in the video, the The moving track of the shooting position of the video, wherein the moving track is used to indicate the shooting position of different image frames in the video; the shooting positions of different image frames in the moving track are respectively smoothed to obtain a smooth track; based on the difference between the smooth track and the moving track The video is deformed to obtain an anti-shake processed video. It should be understood that, when the computer program instructions are executed by the processor, the computer program instructions can also cause the computing device to implement other optional implementations provided by the method embodiments of the present disclosure.
计算机可读存储介质可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以包括但不限于电、磁、光、电磁、红 外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。A computer-readable storage medium can employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples (non-exhaustive list) of readable storage media include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as "first" and "second" etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is no such actual relationship or sequence between entities or operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article, or device that includes the element.
以上仅是本公开的具体实施方式,使本领域技术人员能够理解或实现本公开。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本公开的精神或范围的情况下,在其它实施例中实现。因此,本公开将不会被限制于本文的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not to be limited to the embodiments herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (11)

  1. 一种视频防抖处理方法,其特征在于,包括:A video anti-shake processing method, comprising:
    通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定所述视频中不同图像帧之间拍摄位置的初始变化量;By tracking feature points between different image frames in the video, the initial change amount of the shooting position between different image frames in the video is determined based on the initial transformation method;
    基于所述初始变化量对应的拟合误差,采用与所述拟合误差匹配的目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量;Based on the fitting error corresponding to the initial variation, the target variation of the shooting position between different image frames in the video is determined by adopting a target transformation method that matches the fitting error;
    基于所述视频中不同图像帧之间拍摄位置的目标变化量,形成所述视频的拍摄位置的移动轨迹,其中,所述移动轨迹用于指示所述视频中不同图像帧的拍摄位置;forming a moving track of the shooting position of the video based on the target change amount of the shooting position between different image frames in the video, wherein the moving track is used to indicate the shooting position of different image frames in the video;
    分别对所述移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;respectively smoothing the shooting positions of different image frames in the moving track to obtain a smooth track;
    基于所述平滑轨迹和所述移动轨迹之间的差异,对所述视频进行形变,以得到经过防抖处理的视频。Based on the difference between the smooth trajectory and the moving trajectory, the video is deformed to obtain an anti-shake processed video.
  2. 根据权利要求1所述的方法,其特征在于,还包括:The method of claim 1, further comprising:
    利用所述初始变换方式对所述不同图像帧中在前帧图像上的特征点进行坐标变换,得到所述在前帧图像上特征点的变换坐标;Using the initial transformation method to perform coordinate transformation on the feature points on the previous frame image in the different image frames, to obtain the transformed coordinates of the feature points on the previous frame image;
    基于所述不同图像帧中在后帧图像上特征点的图像坐标、以及所述在前帧图像上特征点的变换坐标,计算所述不同图像帧之间拍摄位置的初始变化量对应的拟合误差。Based on the image coordinates of the feature points on the subsequent frame image in the different image frames and the transformed coordinates of the feature points on the previous frame image, a fit corresponding to the initial change of the shooting position between the different image frames is calculated error.
  3. 根据权利要求2所述的方法,其特征在于,基于所述不同图像帧中在后帧图像上特征点的图像坐标、以及所述在前帧图像上特征点的变换坐标,计算所述不同图像帧之间拍摄位置的初始变化量对应的拟合误差,包括:The method according to claim 2, wherein the different images are calculated based on the image coordinates of the feature points on the subsequent frame image in the different image frames and the transformed coordinates of the feature points on the previous frame image The fitting error corresponding to the initial change in shooting position between frames, including:
    利用所述不同图像帧中在后帧图像上特征点的图像坐标、以及所述在前帧图像上特征点的变换坐标,计算所述不同图像帧之间拍摄位置的初始变化量对应的累计误差;Using the image coordinates of the feature points on the next frame image in the different image frames and the transformed coordinates of the feature points on the previous frame image, calculate the cumulative error corresponding to the initial change of the shooting position between the different image frames ;
    基于所述累计误差和所述在前帧图像上特征点的数量,计算所述不同图像帧之间拍摄位置的初始变化量对应的拟合误差。Based on the accumulated error and the number of feature points on the previous frame image, a fitting error corresponding to the initial variation of the shooting position between the different image frames is calculated.
  4. 根据权利要求1所述的方法,其特征在于,基于所述初始变化量对应的拟合误差,采用与所述拟合误差匹配的目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量,包括:The method according to claim 1, characterized in that, based on the fitting error corresponding to the initial change amount, a target transformation method matching the fitting error is used to determine the difference between shooting positions between different image frames in the video. Target Variation, including:
    如果所述初始变化量对应的拟合误差小于第一误差阈值,则将所述初始变换方式确定为与所述拟合误差匹配的目标变换方式,并采用所述目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量;或者If the fitting error corresponding to the initial change amount is smaller than the first error threshold, the initial transformation method is determined as a target transformation method matching the fitting error, and the target transformation method is used to determine the The amount of target change in shooting position between different image frames; or
    如果所述初始变化量对应的拟合误差大于或等于所述第一误差阈值,且小于第二误差阈值,则将自由度小于所述初始变换方式的第一变换方式确定为与所述拟合误差匹配的目标变换方式,并采用所述目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变 化量;或者If the fitting error corresponding to the initial change amount is greater than or equal to the first error threshold and less than the second error threshold, the first transformation method with a degree of freedom smaller than the initial transformation method is determined to be the same as the fitting The target transformation method for error matching, and the target transformation method is used to determine the target change amount of the shooting position between different image frames in the video; or
    如果所述初始变化量对应的拟合误差大于或等于所述第二误差阈值,则将自由度小于所述第一变换方式的第二变换方式确定为与所述拟合误差匹配的目标变换方式,并采用所述目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量。If the fitting error corresponding to the initial change amount is greater than or equal to the second error threshold, a second transformation method with a degree of freedom smaller than the first transformation method is determined as a target transformation method matching the fitting error , and use the target transformation method to determine the target change amount of the shooting position between different image frames in the video.
  5. 根据权利要求4所述的方法,其特征在于,所述初始变换方式包括单应变换方式,所述第一变换方式包括仿射变换方式,所述第二变换方式包括相似变换方式。The method according to claim 4, wherein the initial transformation mode includes a homography transformation mode, the first transformation mode includes an affine transformation mode, and the second transformation mode includes a similarity transformation mode.
  6. 根据权利要求1至5中任一所述的方法,其特征在于,所述初始变化量或所述目标变化量采用变换矩阵表示;The method according to any one of claims 1 to 5, wherein the initial change amount or the target change amount is represented by a transformation matrix;
    基于所述视频中不同图像帧之间拍摄位置的目标变化量,形成所述视频的拍摄位置的移动轨迹,包括:Based on the target variation of the shooting position between different image frames in the video, the movement trajectory of the shooting position of the video is formed, including:
    基于所述视频中不同图像帧之间拍摄位置的目标变换矩阵,确定所述视频中每帧图像相对第一帧图像的变换矩阵;Based on the target transformation matrix of the shooting positions between different image frames in the video, determine the transformation matrix of each frame of image in the video relative to the first frame of image;
    基于所述视频中每帧图像相对第一帧图像的变换矩阵,形成所述视频的拍摄位置的移动轨迹。Based on the transformation matrix of each frame of image in the video relative to the first frame of image, a movement track of the shooting position of the video is formed.
  7. 根据权利要求1所述的方法,其特征在于,基于所述平滑轨迹和所述移动轨迹之间的差异,对所述视频进行形变,以得到经过防抖处理的视频,包括:The method according to claim 1, wherein the video is deformed based on the difference between the smooth trajectory and the moving trajectory to obtain an anti-shake processed video, comprising:
    基于所述平滑轨迹和所述移动轨迹之间的差异,确定调整参数;determining an adjustment parameter based on the difference between the smooth trajectory and the moving trajectory;
    利用所述调整参数对所述视频进行形变,以得到经过防抖处理的视频。The video is deformed by using the adjustment parameter to obtain an anti-shake processed video.
  8. 一种视频防抖处理装置,其特征在于,包括:A video anti-shake processing device, comprising:
    初始变化量确定模块,用于通过对视频中不同图像帧之间进行特征点追踪,基于初始变换方式确定所述视频中不同图像帧之间拍摄位置的初始变化量;an initial change amount determination module, configured to determine the initial change amount of the shooting position between different image frames in the video based on the initial transformation method by tracking feature points between different image frames in the video;
    目标变化量确定模块,用于基于所述初始变化量对应的拟合误差,采用与所述拟合误差匹配的目标变换方式确定所述视频中不同图像帧之间拍摄位置的目标变化量;A target variation determination module, configured to determine, based on the fitting error corresponding to the initial variation, the target variation of the shooting position between different image frames in the video by adopting a target transformation method that matches the fitting error;
    移动轨迹生成模块,用于基于所述视频中不同图像帧之间拍摄位置的目标变化量,形成所述视频的拍摄位置的移动轨迹,其中,所述移动轨迹用于指示所述视频中不同图像帧的拍摄位置;a movement trajectory generation module, configured to form a movement trajectory of the shooting position of the video based on the target change amount of the shooting position between different image frames in the video, wherein the movement trajectory is used to indicate different images in the video the shooting position of the frame;
    平滑轨迹确定模块,用于分别对所述移动轨迹中不同图像帧的拍摄位置进行平滑处理,得到平滑轨迹;a smooth trajectory determination module, configured to perform smooth processing on the shooting positions of different image frames in the moving trajectory respectively to obtain a smooth trajectory;
    视频防抖处理模块,用于基于所述平滑轨迹和所述移动轨迹之间的差异,对所述视频进行形变,以得到经过防抖处理的视频。A video anti-shake processing module, configured to deform the video based on the difference between the smooth track and the moving track, so as to obtain a video that has undergone anti-shake processing.
  9. 一种电子设备,其特征在于,包括存储器和处理器,其中,所述存储器中存储有计算机程序,当所述计算机程序被所述处理器执行时,使得所述电子设备实现权利要求1-7 中任一项所述的视频防抖处理方法。An electronic device, characterized by comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device is made to implement claims 1-7 The video anti-shake processing method described in any one.
  10. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有计算机程序,当所述计算机程序被计算设备执行时,使得所述计算设备实现权利要求1-7中任一项所述的视频防抖处理方法。A computer-readable storage medium, characterized in that, a computer program is stored in the storage medium, and when the computer program is executed by a computing device, the computing device is made to implement any one of claims 1-7. The video anti-shake processing method.
  11. 一种包含指令的计算机程序产品,其特征在于,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行权利要求1-7中任一项所述的视频防抖处理方法。A computer program product comprising instructions, characterized in that, when the computer program product is run on an electronic device, the electronic device is caused to execute the video anti-shake processing method according to any one of claims 1-7.
PCT/CN2022/085634 2021-04-08 2022-04-07 Video anti-shake processing method and apparatus, electronic device, and storage medium WO2022214037A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/472,001 US20240013347A1 (en) 2021-04-08 2023-09-21 Method for video anti-shake processing, electronic apparatus, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110379651.6A CN115209031B (en) 2021-04-08 2021-04-08 Video anti-shake processing method and device, electronic equipment and storage medium
CN202110379651.6 2021-04-08

Related Child Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/085382 Continuation-In-Part WO2022214001A1 (en) 2021-04-08 2022-04-06 Video image stabilization method and apparatus, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
WO2022214037A1 true WO2022214037A1 (en) 2022-10-13

Family

ID=83545102

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/085634 WO2022214037A1 (en) 2021-04-08 2022-04-07 Video anti-shake processing method and apparatus, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN115209031B (en)
WO (1) WO2022214037A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115988317A (en) * 2022-12-12 2023-04-18 Oppo广东移动通信有限公司 Image processing method, image processing device, image processing chip, communication device, and storage medium
CN116506732A (en) * 2023-06-26 2023-07-28 浙江华诺康科技有限公司 Image snapshot anti-shake method, device and system and computer equipment
CN116614706A (en) * 2023-05-19 2023-08-18 北京源音文创科技股份有限公司 Method and device for adaptively maintaining picture level in real time in rotary shooting

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116112761B (en) * 2023-04-12 2023-06-27 海马云(天津)信息技术有限公司 Method and device for generating virtual image video, electronic equipment and storage medium
CN116797497B (en) * 2023-08-24 2023-11-14 摩尔线程智能科技(北京)有限责任公司 Image processing method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050275727A1 (en) * 2004-06-15 2005-12-15 Shang-Hong Lai Video stabilization method
CN103139568A (en) * 2013-02-05 2013-06-05 上海交通大学 Video image stabilizing method based on sparseness and fidelity restraining
CN103813099A (en) * 2013-12-13 2014-05-21 中山大学深圳研究院 Video anti-shake method based on feature point matching
US20140362240A1 (en) * 2013-06-07 2014-12-11 Apple Inc. Robust Image Feature Based Video Stabilization and Smoothing
CN105450907A (en) * 2014-07-31 2016-03-30 北京展讯高科通信技术有限公司 Intelligent terminal and video image stabilization system model parameter calibration method and device thereof
CN110047091A (en) * 2019-03-14 2019-07-23 河海大学 One kind is based on the estimation of camera track and the matched digital image stabilization method of characteristic block

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
BR112015010384A2 (en) * 2012-11-12 2017-07-11 Behavioral Recognition Sys Inc image stabilization techniques for video surveillance systems
US9854168B2 (en) * 2014-03-07 2017-12-26 Futurewei Technologies, Inc. One-pass video stabilization
US10074015B1 (en) * 2015-04-13 2018-09-11 Google Llc Methods, systems, and media for generating a summarized video with video thumbnails
CN105049678B (en) * 2015-08-17 2018-08-03 成都鹰眼视觉科技有限公司 It is a kind of based on the video anti-fluttering method optimized around loop self-adaptive camera path
CN105791705B (en) * 2016-05-26 2019-06-11 厦门美图之家科技有限公司 Video anti-fluttering method, system and camera terminal suitable for mobile time-lapse photography
CN106878612B (en) * 2017-01-05 2019-05-31 中国电子科技集团公司第五十四研究所 A kind of video stabilizing method based on the optimization of online total variation
CN109089015B (en) * 2018-09-19 2020-12-22 厦门美图之家科技有限公司 Video anti-shake display method and device
CN110415186B (en) * 2019-07-05 2021-07-20 浙江大华技术股份有限公司 Method and equipment for image de-jittering
CN110753181A (en) * 2019-09-29 2020-02-04 湖北工业大学 Video image stabilization method based on feature tracking and grid path motion
CN111225155B (en) * 2020-02-21 2021-09-28 Oppo广东移动通信有限公司 Video anti-shake method, video anti-shake device, electronic equipment, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050275727A1 (en) * 2004-06-15 2005-12-15 Shang-Hong Lai Video stabilization method
CN103139568A (en) * 2013-02-05 2013-06-05 上海交通大学 Video image stabilizing method based on sparseness and fidelity restraining
US20140362240A1 (en) * 2013-06-07 2014-12-11 Apple Inc. Robust Image Feature Based Video Stabilization and Smoothing
CN103813099A (en) * 2013-12-13 2014-05-21 中山大学深圳研究院 Video anti-shake method based on feature point matching
CN105450907A (en) * 2014-07-31 2016-03-30 北京展讯高科通信技术有限公司 Intelligent terminal and video image stabilization system model parameter calibration method and device thereof
CN110047091A (en) * 2019-03-14 2019-07-23 河海大学 One kind is based on the estimation of camera track and the matched digital image stabilization method of characteristic block

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115988317A (en) * 2022-12-12 2023-04-18 Oppo广东移动通信有限公司 Image processing method, image processing device, image processing chip, communication device, and storage medium
CN116614706A (en) * 2023-05-19 2023-08-18 北京源音文创科技股份有限公司 Method and device for adaptively maintaining picture level in real time in rotary shooting
CN116506732A (en) * 2023-06-26 2023-07-28 浙江华诺康科技有限公司 Image snapshot anti-shake method, device and system and computer equipment
CN116506732B (en) * 2023-06-26 2023-12-05 浙江华诺康科技有限公司 Image snapshot anti-shake method, device and system and computer equipment

Also Published As

Publication number Publication date
CN115209031A (en) 2022-10-18
CN115209031B (en) 2024-03-29

Similar Documents

Publication Publication Date Title
WO2022214037A1 (en) Video anti-shake processing method and apparatus, electronic device, and storage medium
CN108694700B (en) System and method for deep learning image super-resolution
CN109344755B (en) Video action recognition method, device, equipment and storage medium
US9697587B2 (en) Adaptive path smoothing for video stabilization
US9953400B2 (en) Adaptive path smoothing for video stabilization
WO2020140976A1 (en) Image acquisition method, device, point-reading device, electronic device and storage medium
WO2021114990A1 (en) Method and apparatus for correcting face distortion, electronic device, and storage medium
WO2013087003A1 (en) Nonlocality-based super-resolution reconstruction method and device
WO2018050128A1 (en) Target tracking method, electronic device and storage medium
US8873811B2 (en) Method and apparatus for face tracking utilizing integral gradient projections
WO2018058476A1 (en) Image correction method and device
CN110956131A (en) Single-target tracking method, device and system
WO2022214001A1 (en) Video image stabilization method and apparatus, electronic device, and storage medium
CN115705651A (en) Video motion estimation method, device, equipment and computer readable storage medium
CN111966473B (en) Operation method and device of linear regression task and electronic equipment
WO2024021504A1 (en) Facial recognition model training method and apparatus, recognition method, and device and medium
CN110223220B (en) Method and device for processing image
CN116934591A (en) Image stitching method, device and equipment for multi-scale feature extraction and storage medium
US8872832B2 (en) System and method for mesh stabilization of facial motion capture data
CN116129228A (en) Training method of image matching model, image matching method and device thereof
CN116012418A (en) Multi-target tracking method and device
CN114827567B (en) Video quality analysis method, apparatus and readable medium
WO2022222922A1 (en) Voice signal processing method and apparatus
CN113065585B (en) Training method and device of image synthesis model and electronic equipment
US20240013347A1 (en) Method for video anti-shake processing, electronic apparatus, and storage medium

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: 22784103

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22784103

Country of ref document: EP

Kind code of ref document: A1