WO2018223381A1 - Video shake-prevention method and mobile device - Google Patents

Video shake-prevention method and mobile device Download PDF

Info

Publication number
WO2018223381A1
WO2018223381A1 PCT/CN2017/087754 CN2017087754W WO2018223381A1 WO 2018223381 A1 WO2018223381 A1 WO 2018223381A1 CN 2017087754 W CN2017087754 W CN 2017087754W WO 2018223381 A1 WO2018223381 A1 WO 2018223381A1
Authority
WO
WIPO (PCT)
Prior art keywords
video frame
time
motion trajectory
rotation angle
video
Prior art date
Application number
PCT/CN2017/087754
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 厦门美图之家科技有限公司
Priority to CN201780091696.5A priority Critical patent/CN110678898B/en
Priority to PCT/CN2017/087754 priority patent/WO2018223381A1/en
Publication of WO2018223381A1 publication Critical patent/WO2018223381A1/en

Links

Images

Classifications

    • G06T5/73
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration by the use of more than one image, e.g. averaging, subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/20Analysis of motion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20172Image enhancement details
    • G06T2207/20201Motion blur correction

Definitions

  • the present invention relates to the field of image processing technologies, and in particular, to a video anti-shake method and a mobile device.
  • mobile devices with cameras such as smart phones and tablet computers enable users to take video images they want at any time and increase the user experience.
  • the captured video image is shaken, thereby reducing User's perception.
  • the present invention provides a video anti-shake method and mobile device in an effort to solve or at least alleviate at least one of the problems present above.
  • a video anti-shake method for performing anti-shake processing on a video captured by a mobile device, the method comprising the steps of: obtaining a three-axis angular velocity of the gyroscope of the mobile device during shooting Data and captured video frame image data; calculating the rotation angle of the corresponding axis according to the angular velocity of the gyroscope in the adjacent time interval; for each video frame captured: calculating the three-axis rotation angle corresponding to the video frame Calculating a first motion trajectory of the video frame according to a three-axis rotation angle of the video frame and a camera calibration matrix; and smoothing the first motion trajectory of the video frame according to at least one reference frame adjacent to the video frame to obtain the video
  • the motion track of the frame; the video frame is subjected to block processing, and the motion track of each block is calculated according to the motion track of the video frame; and the image data in each block is adjusted according to the motion track of each block, and the image stabilization is output.
  • the step of acquiring the triaxial angular velocity data of the gyroscope during the photographing process of the mobile device further comprises: constraining the acquired gyroscope triaxial angular velocity value into a predetermined interval; And using a predetermined kernel function to smooth the corresponding axial angular velocity of the current moment gyroscope and the corresponding axial angular velocity of the plurality of gyroscopes in the preceding and following time periods, to obtain the triaxial angular velocity of the gyroscope.
  • the step of calculating the rotation angle of the corresponding axis according to the angular velocity of the gyroscope in the adjacent time interval further comprises: time stamp information in the adjacent time interval of the gyroscope Timestamp information characterizing the three-axis rotation angle is determined as the first time.
  • the video frame image data is acquired, and the system time corresponding to the video frame is also acquired as the second time.
  • the step of calculating a three-axis rotation angle corresponding to the video frame comprises: matching the correspondence between the first time and the three-axis rotation angle by using the second time of the video frame The three-axis rotation angle of the video frame.
  • the method further includes the step of correcting the second time in advance: correcting the second time of the video frame according to the exposure time of the video frame, and obtaining the corrected second time.
  • the second time after the correction is:
  • Frame_time2 frame_time1+base_val+(0.03-exp_Time) ⁇ 0.5
  • frame_time1 is the second time of the video frame
  • frame_time2 is the corrected video frame.
  • base_val is the reference correction value
  • exp_Time is the exposure time of the video frame.
  • the step of matching the three-axis rotation angle of the current video frame according to the correspondence between the first time and the three-axis rotation angle comprises: finding whether there is correction from the first time The second time after the second time, if present, the three-axis rotation angle corresponding to the first time found is taken as the three-axis rotation angle of the video frame; and if not, the three-axis rotation of the video frame is calculated according to a predetermined condition. angle.
  • the step of calculating a three-axis rotation angle of the video frame according to a predetermined condition comprises: extracting from the first time two before and after the corrected second time Time; and calculating a three-axis rotation angle of the video frame based on the two times taken and their corresponding three-axis rotation angles.
  • the three-axis rotation angle ⁇ i of the video frame is:
  • Gyro(k)_ ⁇ i and gyro(k+1)_ ⁇ i represent the three-axis rotation angles corresponding to the two times.
  • the camera of the mobile device is calibrated by using the Zhang Zhengyou calibration algorithm, and the camera focal length is obtained.
  • the first motion trajectory H KR
  • K is the camera calibration matrix and R is the rotation matrix.
  • ⁇ x , ⁇ y , and ⁇ z represent the rotation angles of the three axes x, y, and z, respectively.
  • the smoothing processing of the first motion trajectory includes:
  • H(t) represents the motion trajectory of the t-th frame
  • H(r) represents the motion trajectory of the r-th frame
  • P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing
  • Gt represents the weight of the rth frame at the frame sequence level for the tth frame
  • Gm represents the weight of the rth frame for the tth frame at the motion trajectory level.
  • the step of smoothing the first motion trajectory of the video frame to obtain a motion trajectory of the video frame comprises: smoothing the first motion trajectory to obtain a second motion Tracking, adjusting the second motion trajectory to obtain a motion trajectory of the video frame, that is, calculating a difference value between the first motion trajectory and the second motion trajectory; if the difference value is greater than the threshold value, adjusting the second motion trajectory according to the difference value Until the difference value is less than the threshold, the adjusted second motion trajectory is taken as the motion trajectory of the video frame; and if the difference value is smaller than the threshold value, the second motion trajectory is used as the motion trajectory of the video frame.
  • the calculating the difference value of the first motion trajectory and the second motion trajectory comprises: defining initial coordinates of four corner points of the effective region according to image data of the video frame Calculating a first coordinate set of four corner points under the first motion trajectory; calculating a second coordinate set of the four corner points under the second motion trajectory; and calculating a rectangular area respectively determined by the first coordinate set and the second coordinate set The area difference is used as the difference value between the two motion trajectories.
  • the first coordinate X t H t X of the corner point of the first motion track
  • the second coordinate X s H s X of the corner point of the second motion track
  • H t is the homography matrix of the first motion trajectory
  • H s is the homography matrix of the second motion trajectory
  • X is the initial coordinate of the corner point
  • the difference value diff Area t -Area s ,
  • Area t and Area s represent the area of the rectangular area respectively determined by the first coordinate set and the second coordinate set.
  • the step of adjusting the second motion trajectory according to the difference value comprises: calculating an interpolation ratio according to the difference value; and linearly according to the interpolation ratio The interpolation method adjusts the second motion trajectory.
  • the interpolation ratio radio Area t /diff.
  • the threshold is:
  • Threshold cos(atan2(min(width,height)/2,f)
  • width and height represent the width and height of the video frame, respectively, and f is the nominal camera focal length.
  • the step of performing block processing on the video frame comprises: segmenting the video frame in order from top to bottom according to the characteristics of the rolling shutter.
  • the step of calculating each block motion trajectory according to the motion trajectory of the video frame comprises: calculating the system time of each block according to the shutter time; calculating according to the system time of each block The three-axis rotation angle corresponding to each block; the initial motion trajectory of each block is calculated according to the three-axis rotation angle of each block and the camera calibration matrix; and the initial motion trajectory of each block and the motion track of the video frame are calculated Obtain the motion trajectory of each block.
  • the system time of each partition is defined as:
  • the motion trajectory of each block is:
  • H' is the motion trajectory of the video frame
  • H(y) is the initial motion trajectory of each block.
  • the predetermined interval is [-4, 4].
  • a mobile device comprising: a camera subsystem adapted to acquire video image data; a gyroscope; one or more processors; a memory; one or more programs, wherein the one Or a plurality of programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing any of the methods described above.
  • a computer readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by a mobile device, cause the mobile device to perform the above Any of the methods described.
  • a gyroscope is used to obtain a mobile device during a video capture process.
  • the three-axis rotation angle and then obtain the motion trajectory of a certain frame of the mobile device; and then use the characteristics of the rolling shutter to block the video frame and transform each block according to the motion trajectory of the block And finally output a stable video.
  • the scheme is not only simple in algorithm, fast in calculation speed, but also does not depend on the quality of the video image itself, and is particularly suitable for scenes in which the quality of the captured video image itself is not high, for example, anti-shake processing of a video shot in an indoor low-light environment.
  • FIG. 1 shows a schematic configuration of a mobile device 100 in accordance with one embodiment of the present invention
  • FIG. 2 shows a flow chart of a video anti-shake method 200 in accordance with one embodiment of the present invention.
  • FIG. 1 shows a schematic configuration of a mobile device 100 in accordance with one embodiment of the present invention.
  • mobile device 100 includes a memory interface 102, one or more data processors, an image processor and/or central processing unit 104, and a peripheral interface 106.
  • Memory interface 102, one or more processors 104, and/or peripheral interface 106 can be either discrete components or integrated into one or more integrated circuits.
  • various components may be coupled by one or more communication buses or signal lines.
  • Sensors, devices, and subsystems can be coupled to the peripheral interface 106 to help implement a variety of functions.
  • motion sensor 110, light sensor 112, and distance sensor 114 can be coupled to peripheral interface 106 to facilitate functions such as orientation, illumination, and ranging.
  • the other sensor 116 includes at least one angular velocity sensor, that is, a gyroscope, which is different from the acceleration sensor (G-sensor), and the gyroscope is mainly used to measure the rotational angular velocity of the mobile device 100 when the deflection and tilt occur.
  • the gyroscope is arranged as a three-axis gyroscope, and the three-axis rotational angular velocity data can be simultaneously measured.
  • Camera subsystem 120 and optical sensor 122 may be used to facilitate implementation of camera functions such as recording photos and video clips, where the camera subsystem and optical sensor may be, for example, a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) optics. sensor.
  • CCD charge coupled device
  • CMOS complementary metal oxide semiconductor
  • the video image is acquired by the camera subsystem 120, and the video data with good anti-shake effect is obtained after post-processing.
  • wireless communication subsystems 124 may include radio frequency receivers and transmitters and/or optical (e.g., infrared) receivers and transmitters.
  • the particular design and implementation of wireless communication subsystem 124 may depend on one or more communication networks supported by mobile device 100.
  • the mobile device 100 may include a network is designed to support GSM, GPRS communication network, EDGE network, Wi-Fi or WiMax network, and the network subsystem 124 Bluebooth TM.
  • the audio subsystem 126 can be coupled to the speaker 128 and the microphone 130 to assist in implementing voice-enabled functions such as voice recognition, voice replication, digital recording, and telephony functions.
  • I/O subsystem 140 may include touch screen controller 142 and/or one or more other input controllers 144.
  • Touch screen controller 142 can be coupled to touch screen 146.
  • the touch screen 146 and the touch screen controller 142 can detect contact and movement or pause with any of a variety of touch sensing technologies, including but not limited to capacitive, Resistive, infrared and surface acoustic wave technology.
  • One or more other input controllers 144 may be coupled to other input/control devices 148, such as one or more buttons, rocker switches, thumb wheels, infrared ports, USB ports, and/or pointing devices such as styluses .
  • One or more buttons may include up/down buttons for controlling the volume of the speaker 128 and/or the microphone 130.
  • Memory interface 102 can be coupled to memory 150.
  • the memory 150 can include high speed random access memory and/or nonvolatile memory, such as one or more magnetic disk storage devices, one or more optical storage devices, and/or flash memory (eg, NAND, NOR).
  • the memory 150 can To store an operating system 152, such as an operating system such as Android, IOS, or Windows Phone.
  • the operating system 152 can include instructions for processing basic system services and performing hardware dependent tasks.
  • the memory 150 can also store the application 154. These applications, when operational, are loaded from the memory 150 onto the processor 104 and run on top of the operating system already run by the processor 104, and utilize the interface provided by the operating system and the underlying hardware to implement various user desired functions. Such as instant messaging, web browsing, photo management, and so on. Applications can be either independent of the operating system or native to the operating system. In some implementations, the application 154 can be one or more programs.
  • the present invention provides a video anti-shake solution that achieves the above functionality by storing a corresponding one or more programs in memory 150 of mobile device 100.
  • the mobile device 100 referred to in the present invention may be a mobile phone, a tablet, a camera, or the like having the above configuration.
  • FIG. 2 shows a flow chart of a video anti-shake method 200 in accordance with one embodiment of the present invention.
  • the method begins at step S210, the mobile device 100 acquired triaxial gyro angular velocity data during recording (referred to as w x, w y, w z ) and video frames of the photograph image data.
  • w x, w y, w z triaxial gyro angular velocity data during recording
  • the acquired triaxial angular velocity data of the gyroscope is further corrected and smoothed.
  • the gyroscope triaxial angular velocity is corrected according to the camera direction. Specifically, the triaxial angular velocity is adjusted according to the direction of the mobile device 100 (horizontal or vertical), and finally adjusted to w x represents the angular velocity of the pitch, w y represents the angular velocity of the heading angle (yaw), and w z represents The angular velocity of the roll. That is, the acquired gyroscope triaxial angular velocity values are constrained to a predetermined interval. Generally, according to the empirical value, the predetermined interval is taken between [-4, 4].
  • the corresponding angular velocity of the gyroscope at the current time and the corresponding angular angular velocity of the plurality of gyroscopes in the adjacent time period (that is, the gyro collected in a certain time interval) by using a predetermined kernel function
  • the corresponding angular velocity of the instrument is smoothed.
  • the corresponding angular velocity of the plurality of gyroscopes in the adjacent time interval is:
  • Kernel0, Kernel1, Kernel2, Kernel3, Kernel4, Kernel5, Kernel6, Kernel7 smoothes it and outputs the triaxial angular velocity value as the triaxial angular velocity of the gyroscope.
  • the system time corresponding to each video frame is also acquired as the second time, which is recorded as frame_time1.
  • step S220 the rotation angle of the corresponding axis is calculated based on the angular velocity of the gyroscope in the adjacent time interval and the time interval.
  • the rotation angle of each axis is calculated by performing uniform motion calculation on the average value of the corresponding angular velocity of the gyroscope in the time interval.
  • the timestamp information characterizing the three-axis rotation angle is determined as the first time by the timestamp information in the adjacent time interval of the gyroscope.
  • the first time takes the mean of the two timestamps in the adjacent time interval.
  • each of the calculated three-axis rotation angles has a corresponding first time corresponding thereto.
  • each video frame in the captured video (ie, the image frame, for the unified description, the video frame referred to below refers to the image frame in the captured video) is subjected to anti-shake processing. .
  • step S230 a three-axis rotation angle corresponding to the current video frame is calculated.
  • the corrected second time frame_time2 is:
  • Frame_time2 frame_time1+base_val+(0.03-exp_Time) ⁇ 0.5
  • frame_time1 is the second time of the video frame (ie, obtained in step S210)
  • frame_time2 is the second time of the corrected video frame
  • base_val is the reference correction value
  • exp_Time is the exposure time of the video frame. In particular, when the exposure time of a video frame cannot be acquired, exp_Time is set to zero.
  • the second time after the correction After the second time after the correction is obtained, it is searched from the first time whether there is a second time after the correction, and if present, the three-axis rotation angle corresponding to the first time found is used as the three axes of the video frame. Rotation angle.
  • the three-axis rotation angle of the video frame is calculated according to predetermined conditions. Specifically, two times before and after the corrected second time are taken out from the first time, and then the three-axis rotation angle ⁇ of the video frame is calculated according to the two times taken and their corresponding three-axis rotation angles. i , such as:
  • Gyro(k)_ ⁇ i and gyro(k+1)_ ⁇ i represent the three-axis rotation angles corresponding to the two times.
  • the three-axis rotation angle corresponding to each video frame can be calculated.
  • step S240 the first motion trajectory of the video frame is calculated from the three-axis rotation angle of the video frame and the camera calibration matrix.
  • the first motion trajectory H is calculated as follows:
  • K is the camera calibration matrix
  • R is the rotation matrix
  • ⁇ x , ⁇ y , and ⁇ z represent the rotation angles of the three axes x, y, and z, respectively.
  • the camera of the mobile device 100 is calibrated using the Zhang Zhengyou calibration algorithm, and the camera focal length is obtained, denoted as f.
  • Zhang Zhengyou calibration algorithm is an algorithm generally known to those skilled in the art and is not the focus of the present invention, the description will not be repeated here.
  • step S250 the first motion trajectory of the video frame is smoothed according to the transformation trend of the motion trajectory of the at least one reference frame adjacent to the video frame and the space-time distance of the reference frame from the current video frame (that is, Referring to the motion track of multiple frames before and after the current video frame, smoothing the current video frame, fitting the second motion track of the video frame, and then adjusting the second motion track to obtain the video frame. Movement track.
  • smoothing the first motion trajectory includes:
  • t is the current image frame and r is the front/back reference frame adjacent to t.
  • H(t) represents the motion trajectory of the t-th frame
  • H(r) represents the motion trajectory of the r-th frame
  • P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing.
  • G t denotes the weight of the rth frame at the frame sequence level for the tth frame
  • G m denotes the weight of the rth frame for the tth frame at the motion trajectory level
  • G t makes the reference frame closer to the current video frame larger
  • the weight, G m ensures the change of the trajectory of the two video frames.
  • the difference is compared according to the first motion trajectory and the second motion trajectory, and if the difference produces a black edge effect, the black edge suppression operation is performed, that is, the second motion trajectory is adjusted. It is judged whether a black edge effect is generated, that is, a difference value between the first motion trajectory and the second motion trajectory is calculated, and whether the difference value is compared within a threshold range is compared.
  • the flow of calculating the difference value of the first motion trajectory and the second motion trajectory is:
  • the formula for calculating the corner coordinate X t (x', y') of the first motion trajectory is:
  • h t1 , h t2 , h t3 represent the first, second, and third rows of the homography matrix H t
  • T represents the transpose of the matrix
  • the first coordinates of each of the four corner points can be calculated to obtain the first coordinate set.
  • h s1 , h s2 , h s3 represent the first, second , and third rows of the homography matrix H s
  • T represents the transposition of the matrix
  • a rectangle can be determined.
  • a rectangle can be determined according to the four corner points in the second coordinate set, and the area difference of the two rectangular areas is calculated as The difference between these two motion trajectories, ie,
  • the difference value diff Area t -Area s ,
  • Area t and Area s represent the area of the rectangular area respectively determined by the first coordinate set and the second coordinate set.
  • the difference values of the first motion trajectory and the second motion trajectory can be calculated through the above steps a, b, c, d, and then the magnitude of the difference value and the threshold value are compared to determine whether a black edge effect is generated.
  • the threshold is calculated from the camera focal length obtained by calibration:
  • Threshold cos(atan2(min(width,height)/2,f)
  • width and height respectively represent the width and height of the video frame
  • f is the calibrated camera focal length
  • f has been obtained in step S240.
  • the second motion trajectory is adjusted according to the difference value until the difference value is smaller than the threshold value (ie, the black edge suppression operation), and the adjusted second motion trajectory is used as the motion of the video frame. Trajectory; conversely, if the comparison results in a difference value that is less than the threshold, the second motion trajectory is taken as the motion trajectory of the video frame.
  • the second motion trajectory is approached to the first motion trajectory by radio in a linear interpolation manner.
  • step S260 the video frame is subjected to blocking processing, and according to the motion trajectory of the video frame Calculate the motion trajectory of each block.
  • video frames are segmented in order from top to bottom according to the characteristics of the rolling shutter, that is, the video frames are divided into rows.
  • the step of calculating each block motion trajectory according to the motion trajectory of the video frame includes:
  • j denotes the row index number of each partition
  • t s denotes the shutter time
  • frame_time 2 has been calculated in step S230.
  • the three-axis rotation angle corresponding to each block can be interpolated in the cumulatively recorded three-axis rotation angle of the gyroscope (obtained in the above step S220), optionally, linearly interpolated
  • the method interpolates the corresponding three-axis rotation angle of each block, wherein the linear ratio is calculated based on the system time of each block and the system time of the corresponding gyroscope.
  • H' is the motion trajectory of the video frame
  • H(j) is the initial motion trajectory of each block.
  • the final motion trajectory of each block of the video frame is determined according to the final motion trajectory of the video frame.
  • step S270 the image data in each of the blocks is adjusted according to the motion track H'(j) of each block, and a stable video frame is output.
  • the image pixels of the block are affine or projected transformed according to the obtained motion trajectory of each block, and the frame data after the anti-shake is output.
  • the video anti-shake solution uses the gyroscope to obtain the three-axis rotation angle of the mobile device 100 during the video acquisition process, and then acquires the motion trajectory of a certain video frame of the mobile device, and obtains the defense according to the trajectory smoothing algorithm and the suppression black-side operation.
  • the motion track of the shaken video frame then, using the characteristics of the rolling shutter, the video frame is divided into blocks, and each block is transformed according to the motion track of the block,
  • the final output is a stable video.
  • the video anti-shake scheme according to the present invention not only has a simple algorithm, a fast calculation speed, but also does not depend on the quality of the video image itself, and is particularly suitable for a scene in which the quality of the captured video image itself is not high, for example, shooting in an indoor low-light environment.
  • the video is anti-shake.
  • the various techniques described herein can be implemented in conjunction with hardware or software, or a combination thereof.
  • the methods and apparatus of the present invention may take the form of program code embedded in a tangible medium, such as a floppy disk, CD-ROM, hard disk drive, or any other machine-readable storage medium.
  • the form of (i.e., instruction) wherein when a program is loaded into, and executed by, a machine such as a computer, the machine becomes a device embodying the present invention.
  • the computing device typically includes a processor, a processor readable storage medium (including volatile and nonvolatile memory and/or storage elements), at least one input device, And at least one output device.
  • the memory is configured to store program code; the processor is configured to perform the video image stabilization method of the present invention in accordance with instructions in the program code stored in the memory.
  • the computer readable media includes computer storage media and communication media by way of example and not limitation.
  • Computer readable media includes both computer storage media and communication media.
  • Computer storage media stores information such as computer readable instructions, data structures, program modules or other data.
  • Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
  • modules or singles of the devices in the examples disclosed herein The elements or components may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices that are different from the devices in this example.
  • the modules in the foregoing examples may be combined into one module or may be further divided into a plurality of sub-modules.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the invention also discloses:
  • A9 The method of A8, wherein the calculating the three-axis rotation angle of the video frame according to a predetermined condition comprises: extracting two times before and after the second time after the correction from the first time; The two times taken out and their corresponding three-axis rotation angles calculate the three-axis rotation angle of the video frame.
  • Gyro(k)_ ⁇ i and gyro(k+1)_ ⁇ i represent the three-axis rotation angles corresponding to the two times.
  • step of calculating a first motion trajectory of the video frame according to a three-axis rotation angle of the video frame and a camera calibration matrix further comprises: using a Zhang Zhengyou calibration algorithm on the mobile device The camera is calibrated and the camera focal length is determined.
  • K is the camera calibration matrix and R is the rotation matrix.
  • ⁇ x , ⁇ y , and ⁇ z represent the rotation angles of the three axes x, y, and z, respectively.
  • A13 The method of any of A1-12, wherein smoothing the first motion trajectory comprises:
  • H(t) represents the motion trajectory of the t-th frame
  • H(r) represents the motion trajectory of the r-th frame
  • P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing
  • Gt represents the weight of the rth frame at the frame sequence level for the tth frame
  • Gm represents the weight of the rth frame for the tth frame at the motion trajectory level.
  • step of smoothing the first motion trajectory of the video frame to obtain a motion trajectory of the video frame comprises: smoothing the first motion trajectory to obtain a first a moving track, adjusting a second moving track to obtain a motion track of the video frame: calculating a difference value between the first motion track and the second motion track; and if the difference value is greater than the threshold, the second motion track according to the difference value The adjustment is performed until the difference value is smaller than the threshold, the adjusted second motion trajectory is taken as the motion trajectory of the video frame; and if the difference value is smaller than the threshold value, the second motion trajectory is used as the motion trajectory of the video frame.
  • calculating the difference value of the first motion trajectory and the second motion trajectory comprises: defining initial coordinates of four corner points of the effective region according to image data of the video frame; calculating the first motion a first coordinate set of the four corner points under the track; a second coordinate set of four corner points under the second motion track; and an area difference of the rectangular area respectively determined by the first coordinate set and the second coordinate set respectively As the difference value of these two motion trajectories.
  • the method of A18, wherein the adjusting the second motion trajectory according to the difference value comprises: calculating an interpolation ratio according to the difference value; and adjusting the second motion trajectory by a linear interpolation method according to the interpolation ratio.
  • Threshold cos(atan2(min(width,height)/2,f)), where width and height represent the width and height of the video frame, respectively, and f is the nominal camera focal length.
  • A22 The method of any of A1-20, wherein the step of performing a block processing on the video frame comprises: segmenting the video frame in a top-to-bottom order according to characteristics of the rolling shutter.
  • step of calculating each of the block motion trajectories according to the motion trajectory of the video frame comprises: calculating a system time of each block according to a shutter time; Calculating the corresponding three-axis rotation angle of each block; calculating the initial motion trajectory of each block according to the three-axis rotation angle of each block and the camera calibration matrix; and combining the initial motion trajectory of each block and the motion of the video frame The trajectory calculation obtains the motion trajectory of each block.
  • t(y) frame_time2+t s *y/height, where y represents the row index number of each partition and t s represents the shutter time.
  • A26 The method of any of A1-25, wherein the predetermined interval is [-4, 4].

Abstract

Disclosed is a video shake-prevention method. The method comprises: acquiring tri-axial angular velocity data of a gyroscope and photographed video frame image data of a mobile device during a photographing process; according to the axial angular velocity of the gyroscope within adjacent time intervals, obtaining, by means of calculation, a rotation angle of a corresponding axis; for each photographed video frame, calculating a tri-axial rotation angle corresponding to the video frame; calculating a first motion trajectory of the video frame according to the tri-axial rotation angle of the video frame and a camera calibration matrix; according to at least one reference frame adjacent to the video frame, smoothing the first motion trajectory of the video frame, so as to obtain a motion trajectory of the video frame; carrying out block segmentation processing on the video frame, and calculating a motion trajectory of each sub-block according to the motion trajectory of the video frame; and according to the motion trajectory of each sub-block, adjusting image data within each sub-block, so as to output the video frame after being subjected to shake-prevention processing. Also disclosed is a corresponding mobile device.

Description

一种视频防抖方法及移动设备Video anti-shake method and mobile device 技术领域Technical field
本发明涉及图像处理技术领域,尤其是一种视频防抖方法及移动设备。The present invention relates to the field of image processing technologies, and in particular, to a video anti-shake method and a mobile device.
背景技术Background technique
随着科学技术的飞速发展,各种移动设备不断地丰富并方便了大众生活,因其具有方便快捷、节省资源等优势,已经成为人们生活中不可或缺的一部分。With the rapid development of science and technology, various mobile devices are continuously enriched and convenient for the public life. Because of its advantages of convenience, saving resources, etc., it has become an indispensable part of people's lives.
其中,智能手机、平板电脑等具有摄像头的移动设备使得用户可以随时拍摄自身想要的视频图像,增加用户体验。但是,在视频拍摄过程中,由于环境因素或其他因素,例如,在行走、行车过程中拍摄时,由于设备跟随移动造成拍摄目标无规律的抖动,导致所拍摄的视频图像发生抖动现象,进而降低用户的观感。Among them, mobile devices with cameras such as smart phones and tablet computers enable users to take video images they want at any time and increase the user experience. However, during the video shooting process, due to environmental factors or other factors, for example, during shooting during walking or driving, due to the irregular shaking of the shooting target caused by the following movement of the device, the captured video image is shaken, thereby reducing User's perception.
可见,为提高拍摄效果,需要对获取到的视频进行防抖处理。现有的视频防抖技术主要有两种:一是利用运动传感器检测相机的运动矢量再转换为图像的运动量从而进行防抖;另一种是直接利用数字图像处理技术,通过确定图像间的运动量而进行补偿达到防抖的目的。基于数字图像处理技术的防抖方法依赖于图像的质量,容易出现运动量估计误差大的情况,并且在大幅度快速移动、拍摄环境昏暗等情况下防抖效果不理想。It can be seen that in order to improve the shooting effect, it is necessary to perform anti-shake processing on the acquired video. There are two main types of video anti-shake technology: one is to use the motion sensor to detect the motion vector of the camera and then convert it into the motion amount of the image to perform anti-shake; the other is to directly use the digital image processing technology to determine the amount of motion between the images. The compensation is achieved to achieve the purpose of anti-shake. The anti-shake method based on digital image processing technology depends on the quality of the image, and it is prone to a situation in which the estimation error of the motion amount is large, and the anti-shake effect is not ideal under the conditions of large rapid movement and dim shooting environment.
因此,如何有效降低由于视频拍摄过程中移动设备不稳定所造成的视频抖动是一个亟待解决的问题。Therefore, how to effectively reduce the video jitter caused by the instability of mobile devices during video shooting is an urgent problem to be solved.
发明内容Summary of the invention
为此,本发明提供了一种视频防抖方法及移动设备,以力图解决或者至少缓解上面存在的至少一个问题。 To this end, the present invention provides a video anti-shake method and mobile device in an effort to solve or at least alleviate at least one of the problems present above.
根据本发明的一个方面,提供了一种视频防抖方法,该方法用于对通过移动设备采集的视频进行防抖处理,该方法包括步骤:获取移动设备在拍摄过程中陀螺仪的三轴角速度数据和所拍得的视频帧图像数据;根据相邻时间间隔内陀螺仪的轴角速度计算得到对应轴的旋转角度;;对于所拍得的每一视频帧:计算视频帧对应的三轴旋转角度;根据视频帧的三轴旋转角度和相机标定矩阵计算该视频帧的第一运动轨迹;根据与视频帧相邻的至少一个参考帧对该视频帧的第一运动轨迹进行平滑处理,得到该视频帧的运动轨迹;对视频帧进行分块处理,并根据视频帧的运动轨迹计算出各分块的运动轨迹;以及根据各分块的运动轨迹对各分块内图像数据进行调整,输出防抖处理后的视频帧。According to an aspect of the present invention, a video anti-shake method is provided for performing anti-shake processing on a video captured by a mobile device, the method comprising the steps of: obtaining a three-axis angular velocity of the gyroscope of the mobile device during shooting Data and captured video frame image data; calculating the rotation angle of the corresponding axis according to the angular velocity of the gyroscope in the adjacent time interval; for each video frame captured: calculating the three-axis rotation angle corresponding to the video frame Calculating a first motion trajectory of the video frame according to a three-axis rotation angle of the video frame and a camera calibration matrix; and smoothing the first motion trajectory of the video frame according to at least one reference frame adjacent to the video frame to obtain the video The motion track of the frame; the video frame is subjected to block processing, and the motion track of each block is calculated according to the motion track of the video frame; and the image data in each block is adjusted according to the motion track of each block, and the image stabilization is output. The processed video frame.
可选地,在根据本发明的视频防抖方法中,获取移动设备在拍摄过程中陀螺仪的三轴角速度数据的步骤还包括:将所获取的陀螺仪三轴角速度值约束到预定区间内;以及利用预定的核函数对当前时刻陀螺仪的对应轴角速度及其前后时间段内多个陀螺仪的对应轴角速度进行平滑处理,得到该陀螺仪的三轴角速度。Optionally, in the video anti-shake method according to the present invention, the step of acquiring the triaxial angular velocity data of the gyroscope during the photographing process of the mobile device further comprises: constraining the acquired gyroscope triaxial angular velocity value into a predetermined interval; And using a predetermined kernel function to smooth the corresponding axial angular velocity of the current moment gyroscope and the corresponding axial angular velocity of the plurality of gyroscopes in the preceding and following time periods, to obtain the triaxial angular velocity of the gyroscope.
可选地,在根据本发明的视频防抖方法中,根据相邻时间间隔内陀螺仪的轴角速度计算得到对应轴的旋转角度的步骤还包括:以陀螺仪相邻时间间隔内的时间戳信息确定表征该三轴旋转角度的时间戳信息,作为第一时间。Optionally, in the video image stabilization method according to the present invention, the step of calculating the rotation angle of the corresponding axis according to the angular velocity of the gyroscope in the adjacent time interval further comprises: time stamp information in the adjacent time interval of the gyroscope Timestamp information characterizing the three-axis rotation angle is determined as the first time.
可选地,在根据本发明的视频防抖方法中,获取视频帧图像数据的同时,还获取了视频帧对应的系统时间,作为第二时间。Optionally, in the video anti-shake method according to the present invention, the video frame image data is acquired, and the system time corresponding to the video frame is also acquired as the second time.
可选地,在根据本发明的视频防抖方法中,计算视频帧对应的三轴旋转角度的步骤包括:利用视频帧的第二时间、根据第一时间与三轴旋转角度的对应关系匹配到该视频帧的三轴旋转角度。Optionally, in the video anti-shake method according to the present invention, the step of calculating a three-axis rotation angle corresponding to the video frame comprises: matching the correspondence between the first time and the three-axis rotation angle by using the second time of the video frame The three-axis rotation angle of the video frame.
可选地,在根据本发明的视频防抖方法中,还包括预先对第二时间进行校正的步骤:根据视频帧的曝光时间对视频帧的第二时间进行校正,得到校正后的第二时间。Optionally, in the video anti-shake method according to the present invention, the method further includes the step of correcting the second time in advance: correcting the second time of the video frame according to the exposure time of the video frame, and obtaining the corrected second time. .
可选地,在根据本发明的视频防抖方法中,校正后的第二时间为:Optionally, in the video anti-shake method according to the present invention, the second time after the correction is:
frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5Frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5
其中,frame_time1为视频帧的第二时间,frame_time2为校正后的视频帧 的第二时间,base_val为基准校正值,exp_Time为视频帧的曝光时间,当无法获取视频帧的曝光时间时,exp_Time为0。Where frame_time1 is the second time of the video frame, and frame_time2 is the corrected video frame. The second time, base_val is the reference correction value, and exp_Time is the exposure time of the video frame. When the exposure time of the video frame cannot be obtained, exp_Time is 0.
可选地,在根据本发明的视频防抖方法中,根据第一时间与三轴旋转角度的对应关系匹配到当前视频帧的三轴旋转角度的步骤包括:从第一时间中查找是否存在校正后的第二时间,若存在则将所查找到的第一时间对应的三轴旋转角度作为该视频帧的三轴旋转角度;以及若不存在则按照预定条件计算出该视频帧的三轴旋转角度。Optionally, in the video anti-shake method according to the present invention, the step of matching the three-axis rotation angle of the current video frame according to the correspondence between the first time and the three-axis rotation angle comprises: finding whether there is correction from the first time The second time after the second time, if present, the three-axis rotation angle corresponding to the first time found is taken as the three-axis rotation angle of the video frame; and if not, the three-axis rotation of the video frame is calculated according to a predetermined condition. angle.
可选地,在根据本发明的视频防抖方法中,按照预定条件计算该视频帧的三轴旋转角度的步骤包括:从第一时间中取出与校正后的第二时间相邻的前后两个时间;以及根据所取出的两个时间及其对应的三轴旋转角度计算该视频帧的三轴旋转角度。Optionally, in the video image stabilization method according to the present invention, the step of calculating a three-axis rotation angle of the video frame according to a predetermined condition comprises: extracting from the first time two before and after the corrected second time Time; and calculating a three-axis rotation angle of the video frame based on the two times taken and their corresponding three-axis rotation angles.
可选地,在根据本发明的视频防抖方法中,视频帧的三轴旋转角度θi为:Optionally, in the video anti-shake method according to the present invention, the three-axis rotation angle θ i of the video frame is:
Figure PCTCN2017087754-appb-000001
Figure PCTCN2017087754-appb-000001
其中,i=x,y,z分别代表x,y,z三个坐标轴,gyro(k)_time和gyro(k+1)_time表示与校正后第二时间frame_time2相邻的前后两个时间,gyro(k)_θi和gyro(k+1)_θi表示这两个时间对应的三轴旋转角度。Where i=x, y, z represent the three coordinate axes x, y, z, respectively, and gyro(k)_time and gyro(k+1)_time represent two times before and after the second time frame_time2 after correction, Gyro(k)_θ i and gyro(k+1)_θ i represent the three-axis rotation angles corresponding to the two times.
可选地,在根据本发明的视频防抖方法中,利用张正友标定算法对移动设备的相机进行标定,并求得相机焦距。Optionally, in the video anti-shake method according to the present invention, the camera of the mobile device is calibrated by using the Zhang Zhengyou calibration algorithm, and the camera focal length is obtained.
可选地,在根据本发明的视频防抖方法中,第一运动轨迹H=KR,Optionally, in the video anti-shake method according to the present invention, the first motion trajectory H=KR,
其中,K为相机标定矩阵,R为旋转矩阵,Where K is the camera calibration matrix and R is the rotation matrix.
Figure PCTCN2017087754-appb-000002
Figure PCTCN2017087754-appb-000002
其中,θxyz分别表示x,y,z三轴的旋转角度。Where θ x , θ y , and θ z represent the rotation angles of the three axes x, y, and z, respectively.
可选地,在根据本发明的视频防抖方法中,对第一运动轨迹进行平滑处理包括: Optionally, in the video anti-shake method according to the present invention, the smoothing processing of the first motion trajectory includes:
Figure PCTCN2017087754-appb-000003
Figure PCTCN2017087754-appb-000003
Figure PCTCN2017087754-appb-000004
Figure PCTCN2017087754-appb-000004
其中,t为当前图像帧,r为与t相邻的前/后参考帧。H(t)表示第t帧的运动轨迹,H(r)表示第r帧的运动轨迹,P(t)表示经过轨迹平滑后第t帧的运动轨迹。Gt表示帧序列层面上第r帧对于第t帧的权重,Gm表示在运动轨迹层面上第r帧对于第t帧的权重。Where t is the current image frame and r is the front/back reference frame adjacent to t. H(t) represents the motion trajectory of the t-th frame, H(r) represents the motion trajectory of the r-th frame, and P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing. Gt represents the weight of the rth frame at the frame sequence level for the tth frame, and Gm represents the weight of the rth frame for the tth frame at the motion trajectory level.
可选地,在根据本发明的视频防抖方法中,对该视频帧的第一运动轨迹进行平滑处理得到该视频帧的运动轨迹的步骤包括:对第一运动轨迹进行平滑处理得到第二运动轨迹、调整第二运动轨迹得到该视频帧的运动轨迹的步骤,即:计算第一运动轨迹和第二运动轨迹的差异值;若差异值大于阈值则根据该差异值对第二运动轨迹进行调整,直到差异值小于阈值,将调整后的第二运动轨迹作为该视频帧的运动轨迹;以及若差异值小于阈值则将第二运动轨迹作为该视频帧的运动轨迹。Optionally, in the video anti-shake method according to the present invention, the step of smoothing the first motion trajectory of the video frame to obtain a motion trajectory of the video frame comprises: smoothing the first motion trajectory to obtain a second motion Tracking, adjusting the second motion trajectory to obtain a motion trajectory of the video frame, that is, calculating a difference value between the first motion trajectory and the second motion trajectory; if the difference value is greater than the threshold value, adjusting the second motion trajectory according to the difference value Until the difference value is less than the threshold, the adjusted second motion trajectory is taken as the motion trajectory of the video frame; and if the difference value is smaller than the threshold value, the second motion trajectory is used as the motion trajectory of the video frame.
可选地,在根据本发明的视频防抖方法中,计算第一运动轨迹和第二运动轨迹的差异值的步骤包括:根据该视频帧的图像数据定义有效区域的四个角点的初始坐标;计算第一运动轨迹下四个角点的第一坐标集合;计算第二运动轨迹下四个角点的第二坐标集合;以及计算第一坐标集合和第二坐标集合分别确定的矩形区域的面积差值作为这两个运动轨迹的差异值。Optionally, in the video image stabilization method according to the present invention, the calculating the difference value of the first motion trajectory and the second motion trajectory comprises: defining initial coordinates of four corner points of the effective region according to image data of the video frame Calculating a first coordinate set of four corner points under the first motion trajectory; calculating a second coordinate set of the four corner points under the second motion trajectory; and calculating a rectangular area respectively determined by the first coordinate set and the second coordinate set The area difference is used as the difference value between the two motion trajectories.
可选地,在根据本发明的视频防抖方法中,第一运动轨迹下角点的第一坐标Xt=HtX,第二运动轨迹下角点的第二坐标Xs=HsX,其中,Ht为第一运动轨迹的单应性矩阵,Hs为第二运动轨迹的单应性矩阵,X为角点的初始坐标。Optionally, in the video anti-shake method according to the present invention, the first coordinate X t = H t X of the corner point of the first motion track, and the second coordinate X s = H s X of the corner point of the second motion track, wherein H t is the homography matrix of the first motion trajectory, H s is the homography matrix of the second motion trajectory, and X is the initial coordinate of the corner point.
可选地,在根据本发明的视频防抖方法中,差异值diff=Areat-AreasOptionally, in the video anti-shake method according to the present invention, the difference value diff=Area t -Area s ,
其中,Areat和Areas代表第一坐标集合和第二坐标集合所分别确定的矩形区域的面积。Where Area t and Area s represent the area of the rectangular area respectively determined by the first coordinate set and the second coordinate set.
可选地,在根据本发明的视频防抖方法中,根据该差异值对第二运动轨迹进行调整的步骤包括:根据该差异值计算插值比;以及根据插值比以线性 插值方法对第二运动轨迹进行调整。Optionally, in the video anti-shake method according to the present invention, the step of adjusting the second motion trajectory according to the difference value comprises: calculating an interpolation ratio according to the difference value; and linearly according to the interpolation ratio The interpolation method adjusts the second motion trajectory.
可选地,在根据本发明的视频防抖方法中,插值比radio=Areat/diff。Alternatively, in the video anti-shake method according to the present invention, the interpolation ratio radio=Area t /diff.
可选地,在根据本发明的视频防抖方法中,阈值为:Optionally, in the video anti-shake method according to the present invention, the threshold is:
threshold=cos(atan2(min(width,height)/2,f)),Threshold=cos(atan2(min(width,height)/2,f)),
其中,width和height分别代表视频帧的宽和高,f为标定的相机焦距。Where width and height represent the width and height of the video frame, respectively, and f is the nominal camera focal length.
可选地,在根据本发明的视频防抖方法中,对视频帧进行分块处理的步骤包括:根据卷帘式快门的特点、按从上到下的顺序对视频帧进行分块。Optionally, in the video anti-shake method according to the present invention, the step of performing block processing on the video frame comprises: segmenting the video frame in order from top to bottom according to the characteristics of the rolling shutter.
可选地,在根据本发明的视频防抖方法中,根据视频帧的运动轨迹计算各分块运动轨迹的步骤包括:根据快门时间计算各分块的系统时间;根据各分块的系统时间计算出各分块对应的三轴旋转角度;根据各分块的三轴旋转角度和相机标定矩阵计算各分块的初始运动轨迹;以及结合各分块的初始运动轨迹和该视频帧的运动轨迹计算得到各分块的运动轨迹。Optionally, in the video anti-shake method according to the present invention, the step of calculating each block motion trajectory according to the motion trajectory of the video frame comprises: calculating the system time of each block according to the shutter time; calculating according to the system time of each block The three-axis rotation angle corresponding to each block; the initial motion trajectory of each block is calculated according to the three-axis rotation angle of each block and the camera calibration matrix; and the initial motion trajectory of each block and the motion track of the video frame are calculated Obtain the motion trajectory of each block.
可选地,在根据本发明的视频防抖方法中,各分块的系统时间定义为:Optionally, in the video anti-shake method according to the present invention, the system time of each partition is defined as:
t(y)=frame_time2+ts*y/height,t(y)=frame_time2+t s *y/height,
其中,y表示各分块的行索引号,ts表示快门时间。Where y represents the row index number of each partition and t s represents the shutter time.
可选地,在根据本发明的视频防抖方法中,各分块的运动轨迹为:Optionally, in the video anti-shake method according to the present invention, the motion trajectory of each block is:
H'(y)=H'*H(y)-1H'(y)=H'*H(y) -1 ,
其中,H'为视频帧的运动轨迹,H(y)为各分块的初始运动轨迹。Where H' is the motion trajectory of the video frame, and H(y) is the initial motion trajectory of each block.
可选地,在根据本发明的视频防抖方法中,预定区间为[-4,4]。Alternatively, in the video image stabilization method according to the present invention, the predetermined interval is [-4, 4].
根据本发明的又一方面,提供了一种移动设备,包括:相机子系统,适于采集视频图像数据;陀螺仪;一个或多个处理器;存储器;一个或多个程序,其中所述一个或多个程序存储在存储器中并被配置为由所述一个或多个处理器执行,一个或多个程序包括用于执行如上所述方法中的任一方法的指令。According to still another aspect of the present invention, a mobile device is provided, comprising: a camera subsystem adapted to acquire video image data; a gyroscope; one or more processors; a memory; one or more programs, wherein the one Or a plurality of programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing any of the methods described above.
根据本发明的又一方面,提供了一种存储一个或多个程序的计算机可读存储介质,所述一个或多个程序包括指令,所述指令当移动设备执行时,使得移动设备执行如上所述的方法中的任一方法。According to still another aspect of the present invention, a computer readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by a mobile device, cause the mobile device to perform the above Any of the methods described.
根据本发明的视频防抖方案,利用陀螺仪得到移动设备在视频采集过程 中的三轴旋转角度、进而获取该移动设备某一帧视频的运动轨迹;再利用卷帘式快门的特点对视频帧进行分块操作、并根据分块的运动轨迹对每个分块进行变换,最终输出稳定的视频。本方案不仅算法简单、运算速度快,而且不依赖于视频图像本身的质量,特别适用于拍摄的视频图像本身质量不高的场景,例如,对室内低光环境下拍摄的视频进行防抖处理。According to the video anti-shake scheme of the present invention, a gyroscope is used to obtain a mobile device during a video capture process. The three-axis rotation angle, and then obtain the motion trajectory of a certain frame of the mobile device; and then use the characteristics of the rolling shutter to block the video frame and transform each block according to the motion trajectory of the block And finally output a stable video. The scheme is not only simple in algorithm, fast in calculation speed, but also does not depend on the quality of the video image itself, and is particularly suitable for scenes in which the quality of the captured video image itself is not high, for example, anti-shake processing of a video shot in an indoor low-light environment.
附图说明DRAWINGS
为了实现上述以及相关目的,本文结合下面的描述和附图来描述某些说明性方面,这些方面指示了可以实践本文所公开的原理的各种方式,并且所有方面及其等效方面旨在落入所要求保护的主题的范围内。通过结合附图阅读下面的详细描述,本公开的上述以及其它目的、特征和优势将变得更加明显。遍及本公开,相同的附图标记通常指代相同的部件或元素。In order to achieve the above and related objects, certain illustrative aspects are described herein in conjunction with the following description and the accompanying drawings. Within the scope of the claimed subject matter. The above as well as other objects, features and advantages of the present invention will become more apparent from the Detailed Description Throughout the disclosure, the same reference numbers generally refer to the same parts or elements.
图1示出了根据本发明一个实施例的移动设备100的构造示意图;以及FIG. 1 shows a schematic configuration of a mobile device 100 in accordance with one embodiment of the present invention;
图2示出了根据本发明一个实施例的视频防抖方法200的流程图。FIG. 2 shows a flow chart of a video anti-shake method 200 in accordance with one embodiment of the present invention.
具体实施方式detailed description
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
图1示出了根据本发明一个实施例的移动设备100的构造示意图。参照图1,移动设备100包括:存储器接口102、一个或多个数据处理器、图像处理器和/或中央处理单元104,以及外围接口106。存储器接口102、一个或多个处理器104和/或外围接口106既可以是分立元件,也可以集成在一个或多个集成电路中。在移动设备100中,各种元件可以通过一条或多条通信总线或信号线来耦合。传感器、设备和子系统可以耦合到外围接口106,以便帮助实现多种功能。例如,运动传感器110、光传感器112和距离传感器114可以耦合到外围接口106,以方便定向、照明和测距等功能。其他传感器116同样 可以与外围接口106相连,例如定位系统(例如GPS接收机)、温度传感器、生物测定传感器或其他感测设备,由此可以帮助实施相关的功能。根据本发明的实现方式,其他传感器116中包含至少一个角速度传感器,即,陀螺仪,不同于加速度传感器(G-sensor),陀螺仪主要用于测量移动设备100在发生偏转、倾斜时的转动角速度。根据本发明的实施例,陀螺仪布置为三轴陀螺仪,可同时测定三轴的旋转角速度数据。FIG. 1 shows a schematic configuration of a mobile device 100 in accordance with one embodiment of the present invention. Referring to FIG. 1, mobile device 100 includes a memory interface 102, one or more data processors, an image processor and/or central processing unit 104, and a peripheral interface 106. Memory interface 102, one or more processors 104, and/or peripheral interface 106 can be either discrete components or integrated into one or more integrated circuits. In mobile device 100, various components may be coupled by one or more communication buses or signal lines. Sensors, devices, and subsystems can be coupled to the peripheral interface 106 to help implement a variety of functions. For example, motion sensor 110, light sensor 112, and distance sensor 114 can be coupled to peripheral interface 106 to facilitate functions such as orientation, illumination, and ranging. Other sensors 116 are the same It may be coupled to a peripheral interface 106, such as a positioning system (e.g., a GPS receiver), a temperature sensor, a biometric sensor, or other sensing device, thereby helping to implement related functions. According to an implementation of the present invention, the other sensor 116 includes at least one angular velocity sensor, that is, a gyroscope, which is different from the acceleration sensor (G-sensor), and the gyroscope is mainly used to measure the rotational angular velocity of the mobile device 100 when the deflection and tilt occur. . According to an embodiment of the present invention, the gyroscope is arranged as a three-axis gyroscope, and the three-axis rotational angular velocity data can be simultaneously measured.
相机子系统120和光学传感器122可以用于方便诸如记录照片和视频剪辑的相机功能的实现,其中相机子系统和光学传感器例如可以是电荷耦合器件(CCD)或互补金属氧化物半导体(CMOS)光学传感器。在本发明中,对于相机子系统120采集视频图像,经后期处理后得到防抖效果良好的视频数据。 Camera subsystem 120 and optical sensor 122 may be used to facilitate implementation of camera functions such as recording photos and video clips, where the camera subsystem and optical sensor may be, for example, a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) optics. sensor. In the present invention, the video image is acquired by the camera subsystem 120, and the video data with good anti-shake effect is obtained after post-processing.
可以通过一个或多个无线通信子系统124来帮助实现通信功能,其中无线通信子系统可以包括射频接收机和发射机和/或光(例如红外)接收机和发射机。无线通信子系统124的特定设计和实施方式可以取决于移动设备100所支持的一个或多个通信网络。例如,移动设备100可以包括被设计成支持GSM网络、GPRS网络、EDGE网络、Wi-Fi或WiMax网络以及BlueboothTM网络的通信子系统124。音频子系统126可以与扬声器128以及麦克风130相耦合,以便帮助实施启用语音的功能,例如语音识别、语音复制、数字记录和电话功能。Communication functions may be facilitated by one or more wireless communication subsystems 124, which may include radio frequency receivers and transmitters and/or optical (e.g., infrared) receivers and transmitters. The particular design and implementation of wireless communication subsystem 124 may depend on one or more communication networks supported by mobile device 100. For example, the mobile device 100 may include a network is designed to support GSM, GPRS communication network, EDGE network, Wi-Fi or WiMax network, and the network subsystem 124 Bluebooth TM. The audio subsystem 126 can be coupled to the speaker 128 and the microphone 130 to assist in implementing voice-enabled functions such as voice recognition, voice replication, digital recording, and telephony functions.
I/O子系统140可以包括触摸屏控制器142和/或一个或多个其他输入控制器144。触摸屏控制器142可以耦合到触摸屏146。举例来说,该触摸屏146和触摸屏控制器142可以使用多种触摸感测技术中的任何一种来检测与之进行的接触和移动或是暂停,其中感测技术包括但不局限于电容性、电阻性、红外和表面声波技术。一个或多个其他输入控制器144可以耦合到其他输入/控制设备148,例如一个或多个按钮、摇杆开关、拇指旋轮、红外端口、USB端口、和/或指示笔之类的指点设备。一个或多个按钮(未显示)可以包括用于控制扬声器128和/或麦克风130音量的向上/向下按钮。I/O subsystem 140 may include touch screen controller 142 and/or one or more other input controllers 144. Touch screen controller 142 can be coupled to touch screen 146. For example, the touch screen 146 and the touch screen controller 142 can detect contact and movement or pause with any of a variety of touch sensing technologies, including but not limited to capacitive, Resistive, infrared and surface acoustic wave technology. One or more other input controllers 144 may be coupled to other input/control devices 148, such as one or more buttons, rocker switches, thumb wheels, infrared ports, USB ports, and/or pointing devices such as styluses . One or more buttons (not shown) may include up/down buttons for controlling the volume of the speaker 128 and/or the microphone 130.
存储器接口102可以与存储器150相耦合。该存储器150可以包括高速随机存取存储器和/或非易失性存储器,例如一个或多个磁盘存储设备,一个或多个光学存储设备,和/或闪存存储器(例如NAND,NOR)。存储器150可 以存储操作系统152,例如Android、IOS或是Windows Phone之类的操作系统。该操作系统152可以包括用于处理基本系统服务以及执行依赖于硬件的任务的指令。存储器150还可以存储应用154。这些应用在操作时,会从存储器150加载到处理器104上,并在已经由处理器104运行的操作系统之上运行,并利用操作系统以及底层硬件提供的接口实现各种用户期望的功能,如即时通信、网页浏览、图片管理等。应用可以是独立于操作系统提供的,也可以是操作系统自带的。在一些实现方式中,应用154可以是一个或多个程序。 Memory interface 102 can be coupled to memory 150. The memory 150 can include high speed random access memory and/or nonvolatile memory, such as one or more magnetic disk storage devices, one or more optical storage devices, and/or flash memory (eg, NAND, NOR). The memory 150 can To store an operating system 152, such as an operating system such as Android, IOS, or Windows Phone. The operating system 152 can include instructions for processing basic system services and performing hardware dependent tasks. The memory 150 can also store the application 154. These applications, when operational, are loaded from the memory 150 onto the processor 104 and run on top of the operating system already run by the processor 104, and utilize the interface provided by the operating system and the underlying hardware to implement various user desired functions. Such as instant messaging, web browsing, photo management, and so on. Applications can be either independent of the operating system or native to the operating system. In some implementations, the application 154 can be one or more programs.
本发明提供了视频防抖方案,通过在移动设备100的存储器150中存储相应的一个或多个程序来实现上述功能。需要说明的是,本发明所指的移动设备100可以是具有上述构造的手机、平板、相机等。The present invention provides a video anti-shake solution that achieves the above functionality by storing a corresponding one or more programs in memory 150 of mobile device 100. It should be noted that the mobile device 100 referred to in the present invention may be a mobile phone, a tablet, a camera, or the like having the above configuration.
图2示出了根据本发明一个实施例的视频防抖方法200的流程图。如图2所示,该方法始于步骤S210,获取移动设备100在拍摄过程中陀螺仪的三轴角速度数据(设为wx、wy、wz)和所拍得的视频帧图像数据。FIG. 2 shows a flow chart of a video anti-shake method 200 in accordance with one embodiment of the present invention. 2, the method begins at step S210, the mobile device 100 acquired triaxial gyro angular velocity data during recording (referred to as w x, w y, w z ) and video frames of the photograph image data.
根据本发明的一个实施例,对所获取到的陀螺仪的三轴角速度数据还要进行校正和平滑处理。According to an embodiment of the present invention, the acquired triaxial angular velocity data of the gyroscope is further corrected and smoothed.
在校正处理时,根据相机方向对陀螺仪三轴角速度进行校正。具体地,根据移动设备100的方向(横屏或竖屏)来调整三轴角速度,最终调整为wx代表俯仰角(pitch)的角速度,wy代表航向角(yaw)的角速度,wz代表横滚角(roll)的角速度。也就是说,将所获取的陀螺仪三轴角速度值约束到预定区间内。一般地,根据经验值,预定区间取[-4,4]之间。During the correction process, the gyroscope triaxial angular velocity is corrected according to the camera direction. Specifically, the triaxial angular velocity is adjusted according to the direction of the mobile device 100 (horizontal or vertical), and finally adjusted to w x represents the angular velocity of the pitch, w y represents the angular velocity of the heading angle (yaw), and w z represents The angular velocity of the roll. That is, the acquired gyroscope triaxial angular velocity values are constrained to a predetermined interval. Generally, according to the empirical value, the predetermined interval is taken between [-4, 4].
然后,在进行平滑处理时,利用预定的核函数对当前时刻陀螺仪的对应轴角速度及其前后相邻时间段内多个陀螺仪的对应轴角速度(即,在一定时间间隔内采集到的陀螺仪的对应轴角速度)进行平滑处理,以第α时刻陀螺仪某个轴的角速度dataα为例,设其相邻时间间隔内的多个陀螺仪的对应轴角速度为:Then, when performing the smoothing process, the corresponding angular velocity of the gyroscope at the current time and the corresponding angular angular velocity of the plurality of gyroscopes in the adjacent time period (that is, the gyro collected in a certain time interval) by using a predetermined kernel function The corresponding angular velocity of the instrument is smoothed. Taking the angular velocity data α of a certain axis of the gyroscope at the moment α as an example, the corresponding angular velocity of the plurality of gyroscopes in the adjacent time interval is:
{dataα-4,dataα-3,dataα-2,dataα-1,dataα,dataα+1,dataα+2,dataα+3},{data α-4 ,data α-3 ,data α-2 ,data α-1 ,data α ,data α+1 ,data α+2 ,data α+3 },
根据预定的核函数[Kernel0,Kernel1,Kernel2,Kernel3,Kernel4,Kernel5, Kernel6,Kernel7]对其进行平滑计算,输出的三轴角速度值作为该陀螺仪的三轴角速度。According to the predetermined kernel function [Kernel0, Kernel1, Kernel2, Kernel3, Kernel4, Kernel5, Kernel6, Kernel7] smoothes it and outputs the triaxial angular velocity value as the triaxial angular velocity of the gyroscope.
根据本发明的一个实施方式,在获取视频帧图像数据的同时,还获取了每一视频帧对应的系统时间作为第二时间,记作frame_time1。According to an embodiment of the present invention, while acquiring the video frame image data, the system time corresponding to each video frame is also acquired as the second time, which is recorded as frame_time1.
随后在步骤S220中,根据相邻时间间隔内陀螺仪的轴角速度和该时间间隔计算得到对应轴的旋转角度。可选地,以该时间间隔内陀螺仪的对应轴角速度均值做匀速运动计算得到各轴旋转角度。Then in step S220, the rotation angle of the corresponding axis is calculated based on the angular velocity of the gyroscope in the adjacent time interval and the time interval. Optionally, the rotation angle of each axis is calculated by performing uniform motion calculation on the average value of the corresponding angular velocity of the gyroscope in the time interval.
同时,以陀螺仪相邻时间间隔内的时间戳信息确定表征该三轴旋转角度的时间戳信息,作为第一时间。可选地,第一时间取相邻时间间隔内前后两个时间戳的均值。At the same time, the timestamp information characterizing the three-axis rotation angle is determined as the first time by the timestamp information in the adjacent time interval of the gyroscope. Optionally, the first time takes the mean of the two timestamps in the adjacent time interval.
这样,在拍摄视频过程中,对每一个计算出的三轴旋转角度,都有一个相应的第一时间与之对应。Thus, during the video capture, each of the calculated three-axis rotation angles has a corresponding first time corresponding thereto.
接下来的步骤中,要对所拍得的视频中的每一视频帧(即,图像帧,为统一描述,下文中所指的视频帧都是指拍摄视频中的图像帧)进行防抖处理。In the next step, each video frame in the captured video (ie, the image frame, for the unified description, the video frame referred to below refers to the image frame in the captured video) is subjected to anti-shake processing. .
在步骤S230中,计算当前视频帧对应的三轴旋转角度。在本步骤中,需要利用当前视频帧的第二时间(经步骤S210求得)、根据第一时间与三轴旋转角度的对应关系(经步骤S220求得)匹配到该视频帧的三轴旋转角度。In step S230, a three-axis rotation angle corresponding to the current video frame is calculated. In this step, it is necessary to use the second time of the current video frame (determined in step S210) to match the three-axis rotation of the video frame according to the correspondence between the first time and the three-axis rotation angle (determined in step S220). angle.
根据本发明的实施例,在计算视频帧的三轴旋转角度前,需要根据视频帧的曝光时间对其第二时间进行校正,得到校正后的第二时间frame_time2为:According to the embodiment of the present invention, before calculating the three-axis rotation angle of the video frame, it is necessary to correct the second time according to the exposure time of the video frame, and the corrected second time frame_time2 is:
frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5Frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5
其中,frame_time1为视频帧的第二时间(即,步骤S210所得),frame_time2为校正后的视频帧的第二时间,base_val为基准校正值,exp_Time为视频帧的曝光时间。特别地,当无法获取视频帧的曝光时间时,exp_Time设为0。Where frame_time1 is the second time of the video frame (ie, obtained in step S210), frame_time2 is the second time of the corrected video frame, base_val is the reference correction value, and exp_Time is the exposure time of the video frame. In particular, when the exposure time of a video frame cannot be acquired, exp_Time is set to zero.
在得到校正后的第二时间后,从第一时间中查找是否存在该校正后的第二时间,若存在则将所查找到的第一时间对应的三轴旋转角度作为该视频帧的三轴旋转角度。After the second time after the correction is obtained, it is searched from the first time whether there is a second time after the correction, and if present, the three-axis rotation angle corresponding to the first time found is used as the three axes of the video frame. Rotation angle.
若没有查找到该校正后的第二时间,则按照预定条件计算出该视频帧的三轴旋转角度。具体地,从第一时间中取出与校正后的第二时间相邻的前后 两个时间,然后根据所取出的两个时间及其对应的三轴旋转角度计算该视频帧的三轴旋转角度θi,如:If the second time after the correction is not found, the three-axis rotation angle of the video frame is calculated according to predetermined conditions. Specifically, two times before and after the corrected second time are taken out from the first time, and then the three-axis rotation angle θ of the video frame is calculated according to the two times taken and their corresponding three-axis rotation angles. i , such as:
Figure PCTCN2017087754-appb-000005
Figure PCTCN2017087754-appb-000005
其中,i=x,y,z分别代表x,y,z三个坐标轴,gyro(k)_time和gyro(k+1)_time表示与校正后第二时间frame_time2相邻的前后两个时间,gyro(k)_θi和gyro(k+1)_θi表示这两个时间对应的三轴旋转角度。Where i=x, y, z represent the three coordinate axes x, y, z, respectively, and gyro(k)_time and gyro(k+1)_time represent two times before and after the second time frame_time2 after correction, Gyro(k)_θ i and gyro(k+1)_θ i represent the three-axis rotation angles corresponding to the two times.
依照本步骤,可以计算出每一视频帧对应的三轴旋转角度。According to this step, the three-axis rotation angle corresponding to each video frame can be calculated.
随后在步骤S240中,根据视频帧的三轴旋转角度和相机标定矩阵计算该视频帧的第一运动轨迹。根据本发明的实施方式,假定相机进行纯旋转运动,采用如下方法计算第一运动轨迹H:Then in step S240, the first motion trajectory of the video frame is calculated from the three-axis rotation angle of the video frame and the camera calibration matrix. According to an embodiment of the present invention, assuming that the camera performs a pure rotational motion, the first motion trajectory H is calculated as follows:
H=KR,H=KR,
其中,K为相机标定矩阵,R为旋转矩阵,且Where K is the camera calibration matrix, R is the rotation matrix, and
Figure PCTCN2017087754-appb-000006
Figure PCTCN2017087754-appb-000006
其中,θxyz分别表示x,y,z三轴的旋转角度。Where θ x , θ y , and θ z represent the rotation angles of the three axes x, y, and z, respectively.
可选地,利用张正友标定算法对移动设备100的相机进行标定,并求得相机焦距,记作f。鉴于张正友标定算法是本领域技术人员普遍了解的一种算法,且不是本发明的重点,故此处不再展开描述。Optionally, the camera of the mobile device 100 is calibrated using the Zhang Zhengyou calibration algorithm, and the camera focal length is obtained, denoted as f. Since the Zhang Zhengyou calibration algorithm is an algorithm generally known to those skilled in the art and is not the focus of the present invention, the description will not be repeated here.
随后在步骤S250中,根据与视频帧相邻的至少一个参考帧的运动轨迹的变换趋势及参考帧距离当前视频帧的时空距离,对该视频帧的第一运动轨迹进行平滑处理(也就是说,参考当前某一视频帧前后多帧的运动轨迹,对当前的这一视频帧进行平滑处理),拟合得到该视频帧的第二运动轨迹,而后,调整第二运动轨迹得到该视频帧的运动轨迹。Then, in step S250, the first motion trajectory of the video frame is smoothed according to the transformation trend of the motion trajectory of the at least one reference frame adjacent to the video frame and the space-time distance of the reference frame from the current video frame (that is, Referring to the motion track of multiple frames before and after the current video frame, smoothing the current video frame, fitting the second motion track of the video frame, and then adjusting the second motion track to obtain the video frame. Movement track.
可选地,对第一运动轨迹进行平滑处理包括: Optionally, smoothing the first motion trajectory includes:
Figure PCTCN2017087754-appb-000007
Figure PCTCN2017087754-appb-000007
Figure PCTCN2017087754-appb-000008
Figure PCTCN2017087754-appb-000008
其中,t为当前图像帧,r为与t相邻的前/后参考帧。H(t)表示第t帧的运动轨迹,H(r)表示第r帧的运动轨迹,P(t)表示经过轨迹平滑后第t帧的运动轨迹。Gt表示帧序列层面上第r帧对于第t帧的权重,Gm表示在运动轨迹层面上第r帧对于第t帧的权重,Gt使得距离当前视频帧越近的参考帧具有越大的权重,Gm确保两个视频帧轨迹的变化。更详细的内容,可参见论文“MeshFlow:Minimum Latency Online Video Stabilization,S Liu,P Tan,L Yuan,et al,Springer International Publishing,2016”,由于篇幅有限,此处不再展开赘述。Where t is the current image frame and r is the front/back reference frame adjacent to t. H(t) represents the motion trajectory of the t-th frame, H(r) represents the motion trajectory of the r-th frame, and P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing. G t denotes the weight of the rth frame at the frame sequence level for the tth frame, G m denotes the weight of the rth frame for the tth frame at the motion trajectory level, and G t makes the reference frame closer to the current video frame larger The weight, G m ensures the change of the trajectory of the two video frames. For more details, please refer to the paper "MeshFlow: Minimum Latency Online Video Stabilization, S Liu, P Tan, L Yuan, et al, Springer International Publishing, 2016". Due to limited space, it will not be repeated here.
接着,根据第一运动轨迹和第二运动轨迹比较差异,若差异产生黑边效应则进行黑边抑制操作,即,调整第二运动轨迹。判断是否产生黑边效应,也就是计算第一运动轨迹和第二运动轨迹的差异值、比较该差异值是否在阈值范围内。Then, the difference is compared according to the first motion trajectory and the second motion trajectory, and if the difference produces a black edge effect, the black edge suppression operation is performed, that is, the second motion trajectory is adjusted. It is judged whether a black edge effect is generated, that is, a difference value between the first motion trajectory and the second motion trajectory is calculated, and whether the difference value is compared within a threshold range is compared.
更具体地,计算第一运动轨迹和第二运动轨迹的差异值的流程为:More specifically, the flow of calculating the difference value of the first motion trajectory and the second motion trajectory is:
a.根据该视频帧的图像数据定义有效区域的四个角点的初始坐标。a. Defining the initial coordinates of the four corner points of the active area based on the image data of the video frame.
b.计算第一运动轨迹下四个角点各自的第一坐标,作为第一坐标集合。假设四个角点中其中一个角点的初始坐标为X(x,y),那么,第一运动轨迹下该角点的第一坐标Xt=HtX,其中,Ht为第一运动轨迹的单应性矩阵。b. Calculate the first coordinate of each of the four corner points under the first motion trajectory as the first coordinate set. Assuming that the initial coordinate of one of the four corner points is X(x, y), then the first coordinate X t = H t X of the corner point under the first motion trajectory, where H t is the first motion The homography matrix of the trajectory.
换种表达方式,第一运动轨迹下角点坐标Xt(x',y')的计算公式为:In other forms, the formula for calculating the corner coordinate X t (x', y') of the first motion trajectory is:
Figure PCTCN2017087754-appb-000009
Figure PCTCN2017087754-appb-000009
Figure PCTCN2017087754-appb-000010
Figure PCTCN2017087754-appb-000010
其中,ht1、ht2、ht3表示单应性矩阵Ht的第1、2、3行,T表示矩阵的转置。Where h t1 , h t2 , h t3 represent the first, second, and third rows of the homography matrix H t , and T represents the transpose of the matrix.
同理,可计算出4个角点各自的第一坐标,得到第一坐标集合。Similarly, the first coordinates of each of the four corner points can be calculated to obtain the first coordinate set.
c.计算第二运动轨迹下所述四个角点各自的第二坐标,作为第二坐标集合。与上述步骤b中的计算方式相同,第二运动轨迹下某一角点的第二坐标Xs=HsX,其中,Hs为第二运动轨迹的单应性矩阵。即,第一运动轨迹下角 点坐标Xs(x”,y”)的计算公式为:c. Calculating a second coordinate of each of the four corner points under the second motion trajectory as a second coordinate set. In the same manner as in the above step b, the second coordinate X s = H s X of a corner point under the second motion trajectory, where H s is the homography matrix of the second motion trajectory. That is, the calculation formula of the corner coordinate X s (x", y") of the first motion locus is:
Figure PCTCN2017087754-appb-000011
Figure PCTCN2017087754-appb-000011
Figure PCTCN2017087754-appb-000012
Figure PCTCN2017087754-appb-000012
其中,hs1、hs2、hs3表示单应性矩阵Hs的第1、2、3行,T表示矩阵的转置。Where h s1 , h s2 , h s3 represent the first, second , and third rows of the homography matrix H s , and T represents the transposition of the matrix.
同样地,据此计算出4个角点各自的第二坐标,得到第二坐标集合。Similarly, the second coordinates of the four corner points are calculated accordingly, and the second coordinate set is obtained.
d.根据第一坐标集合中的4个角点可以确定出一个矩形,同样,根据第二坐标集合中的4个角点也可以确定出一个矩形,计算这两个矩形区域的面积差值作为这两个运动轨迹的差异值,即,d. According to the four corner points in the first coordinate set, a rectangle can be determined. Similarly, a rectangle can be determined according to the four corner points in the second coordinate set, and the area difference of the two rectangular areas is calculated as The difference between these two motion trajectories, ie,
差异值diff=Areat-AreasThe difference value diff=Area t -Area s ,
其中,Areat和Areas代表第一坐标集合和第二坐标集合所分别确定的矩形区域的面积。Where Area t and Area s represent the area of the rectangular area respectively determined by the first coordinate set and the second coordinate set.
至此,通过上述步骤a、b、c、d即可计算出第一运动轨迹和第二运动轨迹的差异值,接下来就是比较该差异值与阈值的大小,以确定是否产生黑边效应。So far, the difference values of the first motion trajectory and the second motion trajectory can be calculated through the above steps a, b, c, d, and then the magnitude of the difference value and the threshold value are compared to determine whether a black edge effect is generated.
根据本发明的一个实施例,阈值根据标定得到的相机焦距计算得出:According to an embodiment of the invention, the threshold is calculated from the camera focal length obtained by calibration:
threshold=cos(atan2(min(width,height)/2,f)),Threshold=cos(atan2(min(width,height)/2,f)),
其中,width和height分别代表视频帧的宽和高,f为标定的相机焦距,f在步骤S240中已经得出。Wherein, width and height respectively represent the width and height of the video frame, f is the calibrated camera focal length, and f has been obtained in step S240.
若比较得出差异值大于阈值,则根据该差异值对第二运动轨迹进行调整,直到差异值小于阈值(即,黑边抑制操作),将调整后的第二运动轨迹作为该视频帧的运动轨迹;反之,若比较得出差异值小于阈值,则将第二运动轨迹作为该视频帧的运动轨迹。If the comparison result is that the difference value is greater than the threshold, the second motion trajectory is adjusted according to the difference value until the difference value is smaller than the threshold value (ie, the black edge suppression operation), and the adjusted second motion trajectory is used as the motion of the video frame. Trajectory; conversely, if the comparison results in a difference value that is less than the threshold, the second motion trajectory is taken as the motion trajectory of the video frame.
具体地,根据差异值对第二运动轨迹进行调整的步骤可以分为两步:先是根据该差异值计算插值比,可选地,插值比定义为radio=Areat/diff。Specifically, the step of adjusting the second motion trajectory according to the difference value may be divided into two steps: first, the interpolation ratio is calculated according to the difference value, and optionally, the interpolation ratio is defined as radio=Area t /diff.
然后再根据计算出的插值比radio,以线性插值的方法按radio将第二运动轨迹向第一运动轨迹靠近。Then, according to the calculated interpolation ratio radio, the second motion trajectory is approached to the first motion trajectory by radio in a linear interpolation manner.
随后在步骤S260中,对视频帧进行分块处理,并根据视频帧的运动轨迹 计算出各分块的运动轨迹。根据本发明的实施例,根据卷帘式快门的特点、按从上到下的顺序对视频帧进行分块,即,按行对视频帧进行分块。Then in step S260, the video frame is subjected to blocking processing, and according to the motion trajectory of the video frame Calculate the motion trajectory of each block. According to an embodiment of the present invention, video frames are segmented in order from top to bottom according to the characteristics of the rolling shutter, that is, the video frames are divided into rows.
根据一种实现方式,根据视频帧的运动轨迹计算各分块运动轨迹的步骤包括:According to an implementation, the step of calculating each block motion trajectory according to the motion trajectory of the video frame includes:
1)根据快门时间计算各分块的系统时间。例如,定义各分块的系统时间为:1) Calculate the system time of each block according to the shutter time. For example, the system time to define each partition is:
t(j)=frame_time2+ts*j/height,t(j)=frame_time2+t s *j/height,
其中,j表示各分块的行索引号,ts表示快门时间,frame_time2已经在步骤S230中计算得出。Where j denotes the row index number of each partition, t s denotes the shutter time, and frame_time 2 has been calculated in step S230.
2)根据各分块的系统时间,即可在累计记录的陀螺仪的三轴旋转角度(上述步骤S220所得)中插值出各分块对应的三轴旋转角度,可选地,以线性插值的方式插值出各块对应的三轴旋转角度,其中,线性比例是基于各分块的系统时间和对应的陀螺仪的系统时间计算得到。2) According to the system time of each block, the three-axis rotation angle corresponding to each block can be interpolated in the cumulatively recorded three-axis rotation angle of the gyroscope (obtained in the above step S220), optionally, linearly interpolated The method interpolates the corresponding three-axis rotation angle of each block, wherein the linear ratio is calculated based on the system time of each block and the system time of the corresponding gyroscope.
3)根据各分块的三轴旋转角度和相机标定矩阵计算各分块的初始运动轨迹,计算各分块初始运动轨迹H(j)的方法同步骤S240,此处不再赘述。3) Calculating the initial motion trajectory of each block according to the triaxial rotation angle of each block and the camera calibration matrix, and calculating the initial motion trajectory H(j) of each block is the same as step S240, and details are not described herein again.
4)结合各分块的初始运动轨迹H(j)和该视频帧的运动轨迹(经步骤S250求得)计算得到各分块的运动轨迹,定义各分块的运动轨迹为:4) Combining the initial motion trajectory H(j) of each block and the motion trajectory of the video frame (determined by step S250), the motion trajectory of each block is calculated, and the motion trajectory of each block is defined as:
H'(j)=H'*H(j)-1H'(j)=H'*H(j) -1 ,
其中,H'为视频帧的运动轨迹,H(j)为各分块的初始运动轨迹。Where H' is the motion trajectory of the video frame, and H(j) is the initial motion trajectory of each block.
至此,根据视频帧最终的运动轨迹确定出了该视频帧各分块最终的运动轨迹。So far, the final motion trajectory of each block of the video frame is determined according to the final motion trajectory of the video frame.
随后在步骤S270中,根据各分块的运动轨迹H'(j)对各分块内图像数据进行调整,输出稳定的视频帧。可选地,根据得到的各分块的运动轨迹对该分块的图像像素进行仿射或者投影变换,输出防抖后的帧数据。Then, in step S270, the image data in each of the blocks is adjusted according to the motion track H'(j) of each block, and a stable video frame is output. Optionally, the image pixels of the block are affine or projected transformed according to the obtained motion trajectory of each block, and the frame data after the anti-shake is output.
综上,本视频防抖方案利用陀螺仪得到移动设备100在视频采集过程中的三轴旋转角度、进而获取该移动设备某一视频帧的运动轨迹,根据轨迹平滑算法和抑制黑边操作获取防抖后的视频帧的运动轨迹;再利用卷帘式快门的特点对视频帧进行分块操作、并根据分块的运动轨迹对每个分块进行变换, 最终输出稳定的视频。In summary, the video anti-shake solution uses the gyroscope to obtain the three-axis rotation angle of the mobile device 100 during the video acquisition process, and then acquires the motion trajectory of a certain video frame of the mobile device, and obtains the defense according to the trajectory smoothing algorithm and the suppression black-side operation. The motion track of the shaken video frame; then, using the characteristics of the rolling shutter, the video frame is divided into blocks, and each block is transformed according to the motion track of the block, The final output is a stable video.
根据本发明的视频防抖方案,不仅算法简单、运算速度快,而且不依赖于视频图像本身的质量,特别适用于拍摄的视频图像本身质量不高的场景,例如,对室内低光环境下拍摄的视频进行防抖处理。The video anti-shake scheme according to the present invention not only has a simple algorithm, a fast calculation speed, but also does not depend on the quality of the video image itself, and is particularly suitable for a scene in which the quality of the captured video image itself is not high, for example, shooting in an indoor low-light environment. The video is anti-shake.
这里描述的各种技术可结合硬件或软件,或者它们的组合一起实现。从而,本发明的方法和设备,或者本发明的方法和设备的某些方面或部分可采取嵌入有形媒介,例如软盘、CD-ROM、硬盘驱动器或者其它任意机器可读的存储介质中的程序代码(即指令)的形式,其中当程序被载入诸如计算机之类的机器,并被所述机器执行时,所述机器变成实践本发明的设备。The various techniques described herein can be implemented in conjunction with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions of the methods and apparatus of the present invention, may take the form of program code embedded in a tangible medium, such as a floppy disk, CD-ROM, hard disk drive, or any other machine-readable storage medium. The form of (i.e., instruction), wherein when a program is loaded into, and executed by, a machine such as a computer, the machine becomes a device embodying the present invention.
在程序代码在可编程计算机上执行的情况下,计算设备一般包括处理器、处理器可读的存储介质(包括易失性和非易失性存储器和/或存储元件),至少一个输入装置,和至少一个输出装置。其中,存储器被配置用于存储程序代码;处理器被配置用于根据该存储器中存储的所述程序代码中的指令,执行本发明的视频防抖方法。Where the program code is executed on a programmable computer, the computing device typically includes a processor, a processor readable storage medium (including volatile and nonvolatile memory and/or storage elements), at least one input device, And at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the video image stabilization method of the present invention in accordance with instructions in the program code stored in the memory.
以示例而非限制的方式,计算机可读介质包括计算机存储介质和通信介质。计算机可读介质包括计算机存储介质和通信介质。计算机存储介质存储诸如计算机可读指令、数据结构、程序模块或其它数据等信息。通信介质一般以诸如载波或其它传输机制等已调制数据信号来体现计算机可读指令、数据结构、程序模块或其它数据,并且包括任何信息传递介质。以上的任一种的组合也包括在计算机可读介质的范围之内。The computer readable media includes computer storage media and communication media by way of example and not limitation. Computer readable media includes both computer storage media and communication media. Computer storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。It is to be understood that the various features of the present invention are sometimes grouped together in a single embodiment, figure, or In the description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those recited in the claims. Rather, as the following claims reflect, inventive aspects reside in less than all features of the single embodiments disclosed herein. Therefore, the claims following the specific embodiments are hereby explicitly incorporated into the embodiments, and each of the claims as a separate embodiment of the invention.
本领域那些技术人员应当理解在本文所公开的示例中的设备的模块或单 元或组件可以布置在如该实施例中所描述的设备中,或者可替换地可以定位在与该示例中的设备不同的一个或多个设备中。前述示例中的模块可以组合为一个模块或者此外可以分成多个子模块。Those skilled in the art will appreciate the modules or singles of the devices in the examples disclosed herein. The elements or components may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices that are different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into a plurality of sub-modules.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined. Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
本发明还公开了:The invention also discloses:
A9、如A8所述的方法,其中,按照预定条件计算该视频帧的三轴旋转角度的步骤包括:从第一时间中取出与校正后的第二时间相邻的前后两个时间;以及根据所取出的两个时间及其对应的三轴旋转角度计算该视频帧的三轴旋转角度。A9. The method of A8, wherein the calculating the three-axis rotation angle of the video frame according to a predetermined condition comprises: extracting two times before and after the second time after the correction from the first time; The two times taken out and their corresponding three-axis rotation angles calculate the three-axis rotation angle of the video frame.
A10、如A9所述的方法,其中,视频帧的三轴旋转角度θi为:A10. The method of A9, wherein the three-axis rotation angle θ i of the video frame is:
Figure PCTCN2017087754-appb-000013
Figure PCTCN2017087754-appb-000013
其中,i=x,y,z分别代表x,y,z三个坐标轴,gyro(k)_time和gyro(k+1)_time表示与校正后第二时间frame_time2相邻的前后两个时间,gyro(k)_θi和gyro(k+1)_θi表示这两个时间对应的三轴旋转角度。Where i=x, y, z represent the three coordinate axes x, y, z, respectively, and gyro(k)_time and gyro(k+1)_time represent two times before and after the second time frame_time2 after correction, Gyro(k)_θ i and gyro(k+1)_θ i represent the three-axis rotation angles corresponding to the two times.
A11、如A1-10中任一项所述的方法,其中,根据视频帧的三轴旋转角度和相机标定矩阵计算该视频帧的第一运动轨迹的步骤还包括:利用张正友标定算法对移动设备的相机进行标定,并求得相机焦距。The method of any one of A1-10, wherein the step of calculating a first motion trajectory of the video frame according to a three-axis rotation angle of the video frame and a camera calibration matrix further comprises: using a Zhang Zhengyou calibration algorithm on the mobile device The camera is calibrated and the camera focal length is determined.
A12、如A11所述的方法,其中,第一运动轨迹H=KR,A12. The method of A11, wherein the first motion trajectory H=KR,
其中,K为相机标定矩阵,R为旋转矩阵, Where K is the camera calibration matrix and R is the rotation matrix.
Figure PCTCN2017087754-appb-000014
Figure PCTCN2017087754-appb-000014
其中,θxyz分别表示x,y,z三轴的旋转角度。Where θ x , θ y , and θ z represent the rotation angles of the three axes x, y, and z, respectively.
A13、如A1-12中任一项所述的方法,其中对第一运动轨迹进行平滑处理包括:A13. The method of any of A1-12, wherein smoothing the first motion trajectory comprises:
Figure PCTCN2017087754-appb-000015
Figure PCTCN2017087754-appb-000015
Figure PCTCN2017087754-appb-000016
Figure PCTCN2017087754-appb-000016
其中,t为当前图像帧,r为与t相邻的前/后参考帧。H(t)表示第t帧的运动轨迹,H(r)表示第r帧的运动轨迹,P(t)表示经过轨迹平滑后第t帧的运动轨迹。Gt表示帧序列层面上第r帧对于第t帧的权重,Gm表示在运动轨迹层面上第r帧对于第t帧的权重。Where t is the current image frame and r is the front/back reference frame adjacent to t. H(t) represents the motion trajectory of the t-th frame, H(r) represents the motion trajectory of the r-th frame, and P(t) represents the motion trajectory of the t-th frame after the trajectory smoothing. Gt represents the weight of the rth frame at the frame sequence level for the tth frame, and Gm represents the weight of the rth frame for the tth frame at the motion trajectory level.
A14、如A1-13中任一项所述的方法,其中,对该视频帧的第一运动轨迹进行平滑处理得到该视频帧的运动轨迹的步骤包括:对第一运动轨迹进行平滑处理得到第二运动轨迹、调整第二运动轨迹得到该视频帧的运动轨迹的步骤:计算第一运动轨迹和第二运动轨迹的差异值;若差异值大于阈值则根据该差异值对所述第二运动轨迹进行调整,直到差异值小于阈值,将调整后的第二运动轨迹作为该视频帧的运动轨迹;以及若差异值小于阈值则将第二运动轨迹作为该视频帧的运动轨迹。The method of any one of A1-13, wherein the step of smoothing the first motion trajectory of the video frame to obtain a motion trajectory of the video frame comprises: smoothing the first motion trajectory to obtain a first a moving track, adjusting a second moving track to obtain a motion track of the video frame: calculating a difference value between the first motion track and the second motion track; and if the difference value is greater than the threshold, the second motion track according to the difference value The adjustment is performed until the difference value is smaller than the threshold, the adjusted second motion trajectory is taken as the motion trajectory of the video frame; and if the difference value is smaller than the threshold value, the second motion trajectory is used as the motion trajectory of the video frame.
A15、如A14所述的方法,其中计算第一运动轨迹和第二运动轨迹的差异值的步骤包括:根据该视频帧的图像数据定义有效区域的四个角点的初始坐标;计算第一运动轨迹下所述四个角点的第一坐标集合;计算第二运动轨迹下四个角点的第二坐标集合;以及计算第一坐标集合和第二坐标集合分别确定的矩形区域的面积差值作为这两个运动轨迹的差异值。A15. The method of A14, wherein calculating the difference value of the first motion trajectory and the second motion trajectory comprises: defining initial coordinates of four corner points of the effective region according to image data of the video frame; calculating the first motion a first coordinate set of the four corner points under the track; a second coordinate set of four corner points under the second motion track; and an area difference of the rectangular area respectively determined by the first coordinate set and the second coordinate set respectively As the difference value of these two motion trajectories.
A16、如A15所述的方法,其中,第一运动轨迹下角点的第一坐标Xt=HtX,其中,Ht为第一运动轨迹的单应性矩阵,X为角点的初始坐标。A16. The method of A15, wherein the first coordinate X t = H t X of the corner point of the first motion trajectory, wherein H t is a homography matrix of the first motion trajectory, and X is an initial coordinate of the corner point .
A17、如A16所述的方法,其中,第二运动轨迹下角点的第二坐标Xs=HsX,其中,Hs为第二运动轨迹的单应性矩阵,X为角点的初始坐标。 A17. The method of A16, wherein the second coordinate X s = H s X of the corner point of the second motion trajectory, wherein H s is a homography matrix of the second motion trajectory, and X is an initial coordinate of the corner point .
A18、如A15-17中任一项所述的方法,其中,差异值diff=Areat-Areas,其中,Areat和Areas代表第一坐标集合和第二坐标集合所分别确定的矩形区域的面积。A18. The method of any of A15-17, wherein the difference value diff=Area t -Area s , wherein Area t and Area s represent a rectangular area respectively determined by the first coordinate set and the second coordinate set Area.
A19、如A18所述的方法,其中,根据该差异值对第二运动轨迹进行调整的步骤包括:根据该差异值计算插值比;以及根据插值比以线性插值方法对第二运动轨迹进行调整。A19. The method of A18, wherein the adjusting the second motion trajectory according to the difference value comprises: calculating an interpolation ratio according to the difference value; and adjusting the second motion trajectory by a linear interpolation method according to the interpolation ratio.
A20、如A19所述的方法,其中,插值比radio=Areat/diff。A20. The method of A19, wherein the interpolation ratio is radio=Area t /diff.
A21、如A14-20中任一项所述的方法,其中,阈值为:The method of any of A14-20, wherein the threshold is:
threshold=cos(atan2(min(width,height)/2,f)),其中,width和height分别代表视频帧的宽和高,f为标定的相机焦距。Threshold=cos(atan2(min(width,height)/2,f)), where width and height represent the width and height of the video frame, respectively, and f is the nominal camera focal length.
A22、如A1-20中任一项所述的方法,其中,对视频帧进行分块处理的步骤包括:根据卷帘式快门的特点、按从上到下的顺序对视频帧进行分块。A22. The method of any of A1-20, wherein the step of performing a block processing on the video frame comprises: segmenting the video frame in a top-to-bottom order according to characteristics of the rolling shutter.
A23、如A1-22中任一项所述的方法,其中,根据视频帧的运动轨迹计算各分块运动轨迹的步骤包括:根据快门时间计算各分块的系统时间;根据各分块的系统时间计算出各分块对应的三轴旋转角度;根据各分块的三轴旋转角度和相机标定矩阵计算各分块的初始运动轨迹;以及结合各分块的初始运动轨迹和该视频帧的运动轨迹计算得到各分块的运动轨迹。The method of any of A1-2, wherein the step of calculating each of the block motion trajectories according to the motion trajectory of the video frame comprises: calculating a system time of each block according to a shutter time; Calculating the corresponding three-axis rotation angle of each block; calculating the initial motion trajectory of each block according to the three-axis rotation angle of each block and the camera calibration matrix; and combining the initial motion trajectory of each block and the motion of the video frame The trajectory calculation obtains the motion trajectory of each block.
A24、如A23所述的方法,其中,各分块的系统时间为:A24. The method of A23, wherein the system time of each partition is:
t(y)=frame_time2+ts*y/height,其中,y表示各分块的行索引号,ts表示快门时间。t(y)=frame_time2+t s *y/height, where y represents the row index number of each partition and t s represents the shutter time.
A25、如A24所述的方法,其中,各分块的运动轨迹H'(y)=H'*H(y)-1,其中,H'为视频帧的运动轨迹,H(y)为各分块的初始运动轨迹。A25. The method of A24, wherein the motion trajectory H'(y)=H'*H(y) -1 of each block, wherein H' is a motion trajectory of the video frame, and H(y) is each The initial motion trajectory of the block.
A26、如A1-25中任一项所述的方法,其中,预定区间为[-4,4]。A26. The method of any of A1-25, wherein the predetermined interval is [-4, 4].
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features that are included in other embodiments and not in other features, combinations of features of different embodiments are intended to be within the scope of the present invention. Different embodiments are formed and formed. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
此外,所述实施例中的一些在此被描述成可以由计算机系统的处理器或者 由执行所述功能的其它装置实施的方法或方法元素的组合。因此,具有用于实施所述方法或方法元素的必要指令的处理器形成用于实施该方法或方法元素的装置。此外,装置实施例的在此所述的元素是如下装置的例子:该装置用于实施由为了实施该发明的目的的元素所执行的功能。Moreover, some of the described embodiments are described herein as being operative by a processor of a computer system or A method or combination of method elements implemented by other means performing the described functions. Accordingly, a processor having the necessary instructions for implementing the method or method elements forms a means for implementing the method or method elements. Furthermore, the elements described herein of the device embodiments are examples of means for performing the functions performed by the elements for the purpose of carrying out the invention.
如在此所使用的那样,除非另行规定,使用序数词“第一”、“第二”、“第三”等等来描述普通对象仅仅表示涉及类似对象的不同实例,并且并不意图暗示这样被描述的对象必须具有时间上、空间上、排序方面或者以任意其它方式的给定顺序。As used herein, the use of the ordinal "first", "second", "third", etc., to describe a generic object merely means a different instance referring to a similar object, and is not intended to imply such The objects being described must have a given order in time, space, ordering, or in any other way.
尽管根据有限数量的实施例描述了本发明,但是受益于上面的描述,本技术领域内的技术人员明白,在由此描述的本发明的范围内,可以设想其它实施例。此外,应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。 While the present invention has been described in terms of a limited number of embodiments, it will be understood by those skilled in the art that In addition, it should be noted that the language used in the specification has been selected primarily for the purpose of readability and teaching, and is not intended to be interpreted or limited. Therefore, many modifications and changes will be apparent to those skilled in the art without departing from the scope of the invention. The disclosure of the present invention is intended to be illustrative, and not restrictive, and the scope of the invention is defined by the appended claims.

Claims (10)

  1. 一种视频防抖方法,该方法用于对通过移动设备采集的视频进行防抖处理,该方法包括步骤:A video anti-shake method for performing anti-shake processing on a video captured by a mobile device, the method comprising the steps of:
    获取移动设备在拍摄过程中陀螺仪的三轴角速度数据和所拍得的视频帧图像数据;Obtaining three-axis angular velocity data of the gyroscope and captured video frame image data of the mobile device during shooting;
    根据相邻时间间隔内陀螺仪的轴角速度计算得到对应轴的旋转角度;Calculating the rotation angle of the corresponding axis according to the angular velocity of the gyroscope in the adjacent time interval;
    对于所拍得的每一视频帧:For each video frame taken:
    计算视频帧对应的三轴旋转角度;Calculating a three-axis rotation angle corresponding to the video frame;
    根据所述视频帧的三轴旋转角度和相机标定矩阵计算该视频帧的第一运动轨迹;Calculating a first motion trajectory of the video frame according to a three-axis rotation angle of the video frame and a camera calibration matrix;
    根据与视频帧相邻的至少一个参考帧对该视频帧的第一运动轨迹进行平滑处理,得到该视频帧的运动轨迹;Smoothing a first motion trajectory of the video frame according to at least one reference frame adjacent to the video frame, to obtain a motion trajectory of the video frame;
    对视频帧进行分块处理,并根据视频帧的运动轨迹计算出各分块的运动轨迹;以及Performing block processing on the video frame, and calculating a motion trajectory of each block according to the motion trajectory of the video frame;
    根据各分块的运动轨迹对各分块内图像数据进行调整,输出防抖处理后的视频帧。The image data in each block is adjusted according to the motion track of each block, and the video frame after the anti-shake process is output.
  2. 如权利要求1所述的方法,其中所述获取移动设备在拍摄过程中陀螺仪的三轴角速度数据的步骤还包括:The method of claim 1 wherein said step of obtaining three-axis angular velocity data of the gyroscope during the photographing of the mobile device further comprises:
    将所获取的陀螺仪三轴角速度值约束到预定区间内;以及Constraining the acquired gyroscope triaxial angular velocity values to a predetermined interval;
    利用预定的核函数对当前时刻陀螺仪的对应轴角速度及其前后时间段内多个陀螺仪的对应轴角速度进行平滑处理,得到该陀螺仪的三轴角速度。The predetermined angular function of the gyroscope at the current time and the corresponding angular velocity of the plurality of gyroscopes in the preceding and following time periods are smoothed by a predetermined kernel function to obtain the triaxial angular velocity of the gyroscope.
  3. 如权利要求1或2所述的方法,其中,所述根据相邻时间间隔内陀螺仪的轴角速度计算得到对应轴的旋转角度的步骤还包括:The method according to claim 1 or 2, wherein the step of calculating the rotation angle of the corresponding axis based on the angular velocity of the gyroscope in the adjacent time interval further comprises:
    以陀螺仪相邻时间间隔内的时间戳信息确定表征该三轴旋转角度的时间戳信息,作为第一时间。The timestamp information characterizing the three-axis rotation angle is determined as the first time by the timestamp information in the adjacent time interval of the gyroscope.
  4. 如权利要求3所述的方法,其中,所述获取视频帧图像数据的步骤还包括: The method of claim 3, wherein the step of acquiring video frame image data further comprises:
    获取视频帧对应的系统时间,作为第二时间。Get the system time corresponding to the video frame as the second time.
  5. 如权利要求4所述的方法,其中,所述计算视频帧对应的三轴旋转角度的步骤包括:The method of claim 4 wherein said step of calculating a corresponding three-axis rotation angle of the video frame comprises:
    利用视频帧的第二时间、根据所述第一时间与三轴旋转角度的对应关系匹配到该视频帧的三轴旋转角度。The three-axis rotation angle of the video frame is matched according to the second time of the video frame according to the correspondence between the first time and the three-axis rotation angle.
  6. 如权利要求5所述的方法,还包括预先对第二时间进行校正的步骤:The method of claim 5 further comprising the step of correcting the second time in advance:
    根据视频帧的曝光时间对视频帧的第二时间进行校正,得到校正后的第二时间。The second time of the video frame is corrected according to the exposure time of the video frame, and the corrected second time is obtained.
  7. 如权利要求6所述的方法,其中,校正后的第二时间为:The method of claim 6 wherein the corrected second time is:
    frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5Frame_time2=frame_time1+base_val+(0.03-exp_Time)×0.5
    其中,frame_time1为视频帧的第二时间,frame_time2为校正后的视频帧的第二时间,base_val为基准校正值,exp_Time为视频帧的曝光时间,当无法获取视频帧的曝光时间时,exp_Time为0。Where frame_time1 is the second time of the video frame, frame_time2 is the second time of the corrected video frame, base_val is the reference correction value, and exp_Time is the exposure time of the video frame. When the exposure time of the video frame cannot be obtained, exp_Time is 0. .
  8. 如权利要求6或7所述的方法,其中,根据第一时间与三轴旋转角度的对应关系匹配到当前视频帧的三轴旋转角度的步骤包括:The method according to claim 6 or 7, wherein the step of matching the three-axis rotation angle of the current video frame according to the correspondence between the first time and the three-axis rotation angle comprises:
    从第一时间中查找是否存在校正后的第二时间,若存在则将所查找到的第一时间对应的三轴旋转角度作为该视频帧的三轴旋转角度;以及Finding from the first time whether there is a second time after the correction, if present, the three-axis rotation angle corresponding to the first time found is taken as the three-axis rotation angle of the video frame;
    若不存在则按照预定条件计算出该视频帧的三轴旋转角度。If not, the three-axis rotation angle of the video frame is calculated according to predetermined conditions.
  9. 一种移动设备,包括:A mobile device comprising:
    相机子系统,适于采集视频图像数据;a camera subsystem adapted to capture video image data;
    陀螺仪;Gyro;
    一个或多个处理器;One or more processors;
    存储器;Memory
    一个或多个程序,其中所述一个或多个程序存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序包括用于执行根据权利要求1-8所述方法中的任一方法的指令。One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including for performing according to claim 1 -8 instructions of any of the methods described.
  10. 一种存储一个或多个程序的计算机可读存储介质,所述一个或多个程序包括指令,所述指令当移动设备执行时,使得所述移动设备执行根据权利要求1-8所述的方法中的任一方法。 A computer readable storage medium storing one or more programs, the one or more programs comprising instructions that, when executed by a mobile device, cause the mobile device to perform the method of claims 1-8 Any of the methods.
PCT/CN2017/087754 2017-06-09 2017-06-09 Video shake-prevention method and mobile device WO2018223381A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201780091696.5A CN110678898B (en) 2017-06-09 2017-06-09 Video anti-shake method and mobile device
PCT/CN2017/087754 WO2018223381A1 (en) 2017-06-09 2017-06-09 Video shake-prevention method and mobile device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/087754 WO2018223381A1 (en) 2017-06-09 2017-06-09 Video shake-prevention method and mobile device

Publications (1)

Publication Number Publication Date
WO2018223381A1 true WO2018223381A1 (en) 2018-12-13

Family

ID=64565660

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/087754 WO2018223381A1 (en) 2017-06-09 2017-06-09 Video shake-prevention method and mobile device

Country Status (2)

Country Link
CN (1) CN110678898B (en)
WO (1) WO2018223381A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112712543A (en) * 2019-10-25 2021-04-27 北京京东振世信息技术有限公司 Article transport trajectory detection method, article transport trajectory detection device, and storage medium
CN113014823A (en) * 2021-03-25 2021-06-22 苏州科达科技股份有限公司 Anti-shake processing method, system, device and storage medium for image pickup apparatus
CN114208164A (en) * 2019-08-16 2022-03-18 影石创新科技股份有限公司 Method for dynamically controlling video coding rate, intelligent equipment and motion camera
CN114531549A (en) * 2022-04-22 2022-05-24 浙江大华技术股份有限公司 Image acquisition method, electronic device, and computer-readable storage medium
CN115209030A (en) * 2021-04-08 2022-10-18 北京字跳网络技术有限公司 Video anti-shake processing method and device, electronic equipment and storage medium
CN115546042A (en) * 2022-03-31 2022-12-30 荣耀终端有限公司 Video processing method and related equipment
CN116934654A (en) * 2022-03-31 2023-10-24 荣耀终端有限公司 Image ambiguity determining method and related equipment thereof

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111641835B (en) * 2020-05-19 2023-06-02 Oppo广东移动通信有限公司 Video processing method, video processing device and electronic equipment
CN114979456B (en) * 2021-02-26 2023-06-30 影石创新科技股份有限公司 Anti-shake processing method and device for video data, computer equipment and storage medium
CN113556464B (en) * 2021-05-24 2023-02-03 维沃移动通信有限公司 Shooting method and device and electronic equipment
CN113596327B (en) * 2021-07-21 2024-01-23 维沃移动通信(杭州)有限公司 Shooting method, shooting device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100103096A1 (en) * 2007-07-06 2010-04-29 Sony Corporation Input apparatus, control apparatus, control system, control method, and handheld apparatus
US20140036101A1 (en) * 2011-04-12 2014-02-06 Fujifilm Corporation Image pickup apparatus
CN105069753A (en) * 2015-07-30 2015-11-18 华中科技大学 Mobile-terminal-oriented method for restoring blurred image caused by jitter
CN106027852A (en) * 2016-06-24 2016-10-12 西北工业大学 Video image stabilization method for micro/nano-satellite

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100103096A1 (en) * 2007-07-06 2010-04-29 Sony Corporation Input apparatus, control apparatus, control system, control method, and handheld apparatus
US20140036101A1 (en) * 2011-04-12 2014-02-06 Fujifilm Corporation Image pickup apparatus
CN105069753A (en) * 2015-07-30 2015-11-18 华中科技大学 Mobile-terminal-oriented method for restoring blurred image caused by jitter
CN106027852A (en) * 2016-06-24 2016-10-12 西北工业大学 Video image stabilization method for micro/nano-satellite

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114208164A (en) * 2019-08-16 2022-03-18 影石创新科技股份有限公司 Method for dynamically controlling video coding rate, intelligent equipment and motion camera
CN114208164B (en) * 2019-08-16 2024-02-09 影石创新科技股份有限公司 Method for dynamically controlling video coding rate, intelligent device and moving camera
CN112712543A (en) * 2019-10-25 2021-04-27 北京京东振世信息技术有限公司 Article transport trajectory detection method, article transport trajectory detection device, and storage medium
CN113014823A (en) * 2021-03-25 2021-06-22 苏州科达科技股份有限公司 Anti-shake processing method, system, device and storage medium for image pickup apparatus
CN115209030A (en) * 2021-04-08 2022-10-18 北京字跳网络技术有限公司 Video anti-shake processing method and device, electronic equipment and storage medium
CN115209030B (en) * 2021-04-08 2024-02-27 北京字跳网络技术有限公司 Video anti-shake processing method and device, electronic equipment and storage medium
CN115546042A (en) * 2022-03-31 2022-12-30 荣耀终端有限公司 Video processing method and related equipment
CN115546042B (en) * 2022-03-31 2023-09-29 荣耀终端有限公司 Video processing method and related equipment thereof
CN116934654A (en) * 2022-03-31 2023-10-24 荣耀终端有限公司 Image ambiguity determining method and related equipment thereof
CN114531549A (en) * 2022-04-22 2022-05-24 浙江大华技术股份有限公司 Image acquisition method, electronic device, and computer-readable storage medium

Also Published As

Publication number Publication date
CN110678898B (en) 2022-03-18
CN110678898A (en) 2020-01-10

Similar Documents

Publication Publication Date Title
WO2018223381A1 (en) Video shake-prevention method and mobile device
US10200613B2 (en) Video stabilization for mobile devices
US8687070B2 (en) Image capture device having tilt and/or perspective correction
CN113454982B (en) Electronic device for stabilizing image and method of operating the same
US20150123990A1 (en) Image processing device, image processing method, image processing program, and storage medium
KR101856947B1 (en) Photographing apparatus, motion estimation apparatus, method for image compensation, method for motion estimation, computer-readable recording medium
CN113436113B (en) Anti-shake image processing method, device, electronic equipment and storage medium
JP2014519739A (en) Position sensor assisted image registration for panoramic photography
TWI700000B (en) Image stabilization method and apparatus for panoramic video, and method for evaluating image stabilization algorithm
WO2017128750A1 (en) Image collection method and image collection device
JP6098873B2 (en) Imaging apparatus and image processing apparatus
TW201836345A (en) Camera device and method for camera device
CN109690568A (en) A kind of processing method and mobile device
CN101895783A (en) Detection device for stability of digital video camera and digital video camera
WO2023072088A1 (en) Focusing method and apparatus
CN111669499B (en) Video anti-shake method and device and video acquisition equipment
WO2019000664A1 (en) Information processing method and electronic device
US10911677B1 (en) Multi-camera video stabilization techniques
CN113438409B (en) Delay calibration method, delay calibration device, computer equipment and storage medium
TW201536050A (en) Image-capturing method for correcting deviation-viewing angle, its computer program product, and image-capturing device for correcting deviation viewing angle
JP6152991B2 (en) Image generation apparatus, camera apparatus, image display apparatus, and image generation method
WO2023241495A1 (en) Photographic method and apparatus
CN111955005B (en) Method and system for processing 360-degree image content
US20160373648A1 (en) Methods and systems for capturing frames based on device information
TWI768630B (en) Movable photographing system and photography composition control method

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

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

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 23.04.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17912663

Country of ref document: EP

Kind code of ref document: A1