A VR video stabilization method based on optical flow
By using an optical flow-based method to detect and correct fisheye lens jitter in helicopter aerial videos, and using a generative model to repair the missing area, the problem of jitter processing and missing area repair in the existing technology is solved, and a more stable video output is achieved. .
Patent Information
- Application Number
- CN202210732589.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-06-27
AI Technical Summary
The existing technology is difficult to effectively remove the shake of fisheye lens shooting in helicopter aerial videos, and fails when the image distortion is severe, and cannot repair the missing area.
Adopting a VR video stabilization method based on optical flow, by obtaining the image frame sequence, detecting key points, calculating the affine matrix, decomposing the rotation matrix, finding the offset angle, using Fourier transform for jitter smoothing, and correcting the image through the compensation angle, The missing region is repaired by combining a generative model that fuses adjacent frames.
Effectively removes jitter from videos shot with a fisheye lens and repairs missing areas, improving video stability and viewing experience.
Smart Images

Figure CN115103084B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of video stabilization processing, and in particular relates to a VR video stabilization method based on optical flow. Background Art
[0002] In the field of video stabilization, the de-shaking method is a technology that effectively improves the video viewing experience, and the same is true for VR panoramic video applications. In most cases, VR video shooting usually uses aerial photography, that is, using a helicopter equipped with a fisheye lens. However, during the shooting process, the helicopter does not fly in a straight line and at a constant speed. During the flight, the helicopter's own frequency vibration, change of direction and other factors will cause the video after shooting to shake.
[0003] At present, there are two main methods for de-shaking helicopter aerial photography. One is physical de-shaking, which is to install a multi-axis stabilizer on the shooting equipment and use the real-time measurement of inertial sensors to correct the offset of the pitch, roll and heading axes during flight. This method is more suitable for removing the jitter caused by helicopter changes of direction or external environmental factors at low speeds. The second is the image registration method, which calculates the affine transformation matrix by obtaining matching feature point pairs in consecutive frames to remove the jitter phenomenon. However, this method fails when the image is severely distorted. At the same time, due to the special nature of fisheye lenses, missing areas will be generated after the angle is corrected.
[0004] In view of this, a VR panoramic video stabilization method based on optical flow is proposed to remove video jitter and repair missing areas. Summary of the invention
[0005] To this end, the present invention provides a VR video stabilization method based on optical flow, which is used to remove video jitter in fisheye lens shooting and repair missing areas at the same time.
[0006] The VR video stabilization method based on optical flow of the present invention comprises:
[0007] Step 1: Get VR panoramic video and decode it horizontally into image frame sequence V O , then from V O Select an image frame sequence V with jitter;
[0008] Step 2: From the image frame sequence V with jitter, cut out the area from 0° to 40° according to the corresponding mark in the fisheye lens imaging to form the image frame sequence V P ;
[0009] Step 3: Detect sequence V P All key points in each image region are denoted as set KP{KP i ,…,KP k};
[0010] KP i {kpoint 1 ,…,kpoint m}=Fkeypoint(I Pi );
[0011] KP i Represents image I Pi The set of all key points in , kpoint m Indicates I Pi The mth key point in ;
[0012] Step 4: Match V P The key points in the adjacent images are denoted as set PP{PP i ,…,PP k}.
[0013] PP i {kpoint a i :kpoint b i+1}=Fmatch(KP i ,KP i+1 )
[0014] PP i Indicates I Pi and I Pi+1 The set of point pairs on the key point matching, kpoint a i :kpoint b i+1 Indicates I Pi The ath key point in matches I Pi+1 The bth key point in ;
[0015] Step 5: Use the key point pairs matched in all adjacent images in the set PP to calculate the affine matrix M between adjacent frames, decompose the affine matrix M into the rotation matrix R, and then normalize the rotation matrix R to obtain an orthogonal matrix R with a determinant of 1. N , R N Satisfies the following relationship:
[0016]
[0017] Then from R N The deviation angle θ is obtained from the equation, and is recorded as the set θ{θ i , ..., θ k}, and obtain the variation function F of the offset angle for time t (the value range is from i to k) θ (t);
[0018] Step 6: Calculate each moment relative to the starting time t i The cumulative deviation angle value is recorded as set θ t {sum(θ i ),su m (θ i ,θ i+1 ), ..., sum(θ i ,θ i+1, …, θ k )}, that is, the cumulative change function of the offset angle at time t
[0019] Step 7: Use Fourier transform to transform the cumulative change function Convert to frequency domain function Set the frequency range threshold [freq 1 ,freq 2 ], filter and smooth the jitter within the target frequency range, such as Figure 6 As shown. Get a smooth frequency domain function
[0020]
[0021] Step 8: Perform inverse Fourier transform to obtain the smoothed cumulative change function for time t calculate and The difference between the two values is used to obtain the final compensation angle value {θ i ′,...,θ k '};
[0022] Step 9: Based on the compensation angle value {θ i ′,...,θ k ′} for V{I i ,…,I k Each image in} is rotated counterclockwise with the center of the circle formed by the fisheye lens as the rotation center, and finally the frame sequence V after de-jittering is obtained. de .
[0023] Furthermore, after step 9, the method further includes:
[0024] The frame sequence V after generating and de-jittering based on the positive and negative compensation angle de One-to-one correspondence mask de ;
[0025] From the frame set V de Select a frame of image I de i And the corresponding Mask dei , and from the frame sequence V O The n frames forward and backward are selected from the image, and the missing area is repaired using a generative model that fuses the target area contents of multiple adjacent frames.
[0026] Furthermore, key point detection is performed using the ORB operator through the Fkeypoint function.
[0027] Furthermore, paired point matching is performed using LK sparse optical flow through the Fmatch function.
[0028] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is used to execute any of the above-mentioned optical flow-based VR video stabilization methods.
[0029] The present invention also provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; and the processor is used to execute any of the above-mentioned optical flow-based VR video stabilization methods.
[0030] The above technical solution of the present invention has the following advantages compared with the prior art:
[0031] The present invention decodes the jittery video clip into an image frame sequence, sequentially intercepts the area within the incident angle of 0° to 40° in each frame and detects the feature points in the area, tracks the feature points by the Lucas-Kanade sparse optical flow method, and obtains a set of feature point pair sequences that are matched in pairs between adjacent image frames. According to these feature points in pairs, the affine transformation matrix from the previous frame to the next frame is calculated in sequence and the offset angle is decomposed to obtain the variation function of the offset angle of the clip for time t (each pole represents the angle value of the offset). The offset angles of all previous moments are accumulated by the next moment t_i to obtain the cumulative function of the offset angle for time t (each pole represents the cumulative offset angle from the beginning to the moment t_i). The transformation function of the cumulative function for frequency f is obtained by Fourier transform, and then the jitter within the target frequency range is smoothed and the smoothed transformation function is inversely Fourier transformed to obtain the smoothed cumulative function, and the error between the smoothed cumulative function and the previous cumulative function is calculated, and the error is the final compensation angle. This solves the imaging jitter problem of the fisheye lens. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of a method provided by an embodiment of the present invention;
[0033] Figure 2 is a schematic diagram of fisheye lens imaging in the method provided by an embodiment of the present invention;
[0034] Figure 3is a schematic diagram of key point pairing in the method provided by an embodiment of the present invention;
[0035] Figure 4 is a function of the variation of the offset angle at time t in the method provided by the embodiment of the present invention;
[0036] Figure 5 is a cumulative change function of the offset angle at time t in the method provided in an embodiment of the present invention;
[0037] Figure 6 is a function diagram of the variation of the frequency f with respect to the offset angle in the method provided by the embodiment of the present invention;
[0038] Figure 7 is a schematic diagram of mask area determination in the method provided by an embodiment of the present invention;
[0039] Figure 8 is a network structure diagram of a generation model for fusing target region contents of adjacent multiple frames provided by an embodiment of the present invention;
[0040] Fig. 9 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] The VR video stabilization method based on optical flow in this embodiment is as follows: Figure 1 As shown, the following steps are included:
[0043] Step 1: VR panoramic video is horizontally decoded into image frame sequence V O {I 1 ,…,I i ,…,I k ,…,I max}, then from V O Select the image frame sequence V{I i ,…,I k};
[0044] Step 2: All images in the image frame sequence V are cut out from the area of 0° to 40° according to the corresponding marks in the fisheye lens imaging diagram to form a new image frame sequence V. P {I Pi ,…,I Pk};
[0045] Step 3: Use the ORB operator to detect the sequence V through the Fkeypoint function P All key points in each image region are denoted as set KP{KP i ,…,KP k};
[0046] KP i {kpoint 1 ,…,kpoint m}=Fkeypoint(I Pi )
[0047] KP i Represents image I Pi The set of all key points in , kpoint m Indicates I Pi The mth key point in ;
[0048] Step 4: Use LK sparse optical flow to match V through the Fmatch function P The key points in the adjacent images are denoted as set PP{PP i ,…,PP k}.
[0049] PP i {kpoint a i :kpoint b i+1}=Fmatch(KP i ,KP i+1 )
[0050] PP i Indicates I Pi and I Pi+1 The set of point pairs on the key point matching, kpoint a i :kpoint b i+1 Indicates I Pi The ath key point in matches I Pi+1 The bth key point in .
[0051] In this embodiment, the specific process of performing detection using the ORB operator through the Fkeypoint function can be found in the document Rublee, E., et al. "ORB: an efficient alternative to SIFT or SURF." IEEE International Conference on Computer Vision, ICCV 2011, Barcelona, Spain, November 6-13, 2011 IEEE, 2011.
[0052] In this embodiment, the specific process of performing matching using LK sparse optical flow through the Fmatch function can be found in Lucas, BD, and T. Kanade. "An Iterative Image Registration Technique with an Application to Stereo Vision." Proceedings of the $7^th$ International Joint Conference on Artificial Intelligence Morgan Kaufmann Publishers Inc. 1997.
[0053] Step 5: Use the key point pairs matched in all adjacent images in the set PP to calculate the affine matrix M between adjacent frames through the PPestimate function, decompose the affine matrix M into the rotation matrix R, and then normalize the rotation matrix R to obtain an orthogonal matrix R with a determinant of 1. N , R N Satisfies the following relationship:
[0054]
[0055] Then from R N The deviation angle θ is obtained from the equation, and is recorded as the set θ{θ i , ..., θ k}, so we get the variation function F of the offset angle for time t (value range is from i to k) θ (t);
[0056] Step 6: Calculate each moment relative to the starting time t i The cumulative deviation angle value is recorded as set θ t {sum(θ i ), sum(θ i ,θ i+1 ),…,sum(θ i ,θi+1 , ..., θ k )}, that is, the cumulative change function of the offset angle at time t
[0057] Step 7: Use Fourier transform to transform the cumulative change function Convert to frequency domain function Set the frequency range threshold [freq 1 ,freq 2 ], filter and smooth the jitter within the target frequency range, such as Figure 6 As shown. Get a smooth frequency domain function
[0058]
[0059] Step 8: Perform inverse Fourier transform to obtain the smoothed cumulative change function for time t calculate and The difference between the two values is used to obtain the final compensation angle value {θ i ′,...,θ k '};
[0060] Step 9: Based on the compensation angle value {θ i ′,...,θ k ′} for V{I i ,…,I k Each image in} is rotated counterclockwise with the center of the circle formed by the fisheye lens as the rotation center, and finally the frame sequence V after de-jittering is obtained. de At the same time, a mask Mask corresponding to the compensation angle is generated based on its positive and negative value (positive indicates that there is a missing area on the right, and negative indicates that there is a missing area on the left). de , the schematic diagram is as follows Figure 7 As shown;
[0061] Step 10: From the frame set V de Select a frame of image I de i And the corresponding Mask de i , and from the frame sequence V O (As in V de In the de The corresponding frame instead of V O The corresponding frames in the image are selected from the forward and backward n frames (n is generally 10), and the generative model trained for fusing the target area content of adjacent multiple frames is used to repair the missing area. The overall network structure is as follows Figure 8As shown. The network structure described in this embodiment takes the description in Liu, YL, et al. "Hybrid Neural Fusion for Full-frame Video Stabilization." 2021 as an example, and the warping part uses the adaptive warping module with a variable interpolation kernel in Bao, W., et al. "MEMC-Net: Motion Estimation and Motion Compensation Driven Neural Network for Video Interpolation and Enhancement." IEEE 3 (2021).
[0062] In this embodiment, the jittery video clip is decoded into an image frame sequence, and the area within the incident angle of 0° to 40° in each frame is intercepted in turn and the feature points are detected in the area. The feature points are tracked by the Lucas-Kanade sparse optical flow method to obtain a set of feature point pair sequences that are matched in pairs between adjacent image frames. According to these feature points in pairs, the affine transformation matrix from the previous frame to the next frame is calculated in turn and the offset angle is decomposed to obtain the variation function of the offset angle of the clip for time t (each pole represents the angle value of the offset). The offset angles of all previous moments are accumulated by the next moment t_i to obtain the cumulative function of the offset angle for time t (each pole represents the cumulative offset angle from the beginning to the moment t_i). The transformation function of the cumulative function for frequency f is obtained by Fourier transform, and then the jitter within the target frequency range is smoothed and the smoothed transformation function is inversely Fourier transformed to obtain the smoothed cumulative function, and the error between the smoothed cumulative function and the previous cumulative function is calculated, and the error is the final compensation angle.
[0063] After using the compensation angle to correct the shake, there are missing areas above the image, mainly on the left or right side. The missing area is marked as a mask, and then the content of the area is generated through a pre-trained network model. The design idea of this network model is to use optical flow estimation to align the current frame and multiple adjacent frames, and then fuse the content of adjacent frames by extracting context features, and finally use it to repair the missing area. However, due to the distortion of the fisheye lens, the interpolation function using a fixed interpolation kernel will cause the content of the repaired area to be distorted, so it is also necessary to train a variable interpolation kernel to fit the distortion function of the fisheye lens itself.
[0064] Below, reference Fig. 9 To describe an electronic device according to an embodiment of the present application. Fig. 9 A block diagram of an electronic device according to an embodiment of the present application is illustrated.
[0065] like Fig. 9 As shown, the electronic device 10 includes one or more processors 11 and a memory 12 .
[0066] The processor 11 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 10 to perform desired functions.
[0067] The memory 12 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 11 may run the program instructions to implement the optical flow-based VR video stabilization method of each embodiment of the present application described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0068] In one example, the electronic device 10 may further include: an input device 13 and an output device 14, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0069] When the electronic device is a stand-alone device, the input device 13 may be a communication network connector, which is used to receive the collected input signals from the first device and the second device.
[0070] In addition, the input device 13 may also include, for example, a keyboard, a mouse, and the like.
[0071] The output device 14 can output various information to the outside, including determined distance information, direction information, etc. The output device 14 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0072] Of course, to simplify, Figure 8 Only some of the components related to the present application in the electronic device 10 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 10 may also include any other appropriate components.
[0073] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method for predicting infection categories according to various embodiments of the present application described in the above-mentioned "Exemplary Method" section of this specification.
[0074] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0075] In addition, an embodiment of the present application may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, cause the processor to execute the steps of the method for predicting infection categories according to various embodiments of the present application described in the above “Exemplary Method” section of this specification.
[0076] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0077] The basic principles of the present application are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present application are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present application. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, not for limitation, and the above details do not limit the present application to being implemented by adopting the above specific details.
[0078] The block diagrams of the devices, apparatuses, equipment, and systems involved in this application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.
[0079] It should also be noted that in the apparatus, device and method of the present application, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present application.
[0080] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0081] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A VR video stabilization method based on optical flow, characterized in that: The steps include: Step 1: Get VR panoramic video and decode it horizontally into image frame sequence V O , then from V O Select an image frame sequence V with jitter; Step 2: From the image frame sequence V with jitter, cut out the area from 0° to 40° according to the corresponding mark in the fisheye lens imaging to form the image frame sequence V P ; Step 3: Detect sequence V P All key points in each image region are denoted as set KP{KP i ,…,KP k }; KP i {kpoint1,…,kpoint m }=Fkeypoint(I Pi ); KP i Represents image I Pi The set of all key points in , kpoint m Indicates I Pi The mth key point in ; Step 4: Match V P The key points in the adjacent images are denoted as set PP{PP i ,…,PP k }; PP i {kpoint a i :kpoint b i+1 }=Fmatch(KP i ,KP i+1 ) PP i I Pi and I Pi+1 The set of point pairs on the key point matching, kpoint a i :kpoint b i+1 I Pi The ath key point in matches I Pi+1 The bth key point in ; Step 5: Use the key point pairs matched in all adjacent images in the set PP to calculate the affine matrix M between adjacent frames, decompose the affine matrix M into the rotation matrix R, and then normalize the rotation matrix R to obtain an orthogonal matrix R with a determinant of 1. N , R N Satisfies the following relationship: Then from R N The deviation angle θ is obtained from the equation, and is recorded as the set θ{θ i , ..., θ k }, and obtain the variation function F of the offset angle for time t θ (t), the value of t ranges from i to k; Step 6: Calculate each moment relative to the starting time t i The cumulative deviation angle value is recorded as set θ t {sum(θ i ), sum(θ i ,θ i+1 ), ..., sum(θ i ,θ i+1 , ..., θ k )}, that is, the cumulative change function of the offset angle at time t Step 7: Use Fourier transform to transform the cumulative change function Convert to frequency domain function Set the frequency range threshold [freq1, freq2] to filter and smooth the jitter within the target frequency range to obtain a smooth frequency domain function Step 8: Perform inverse Fourier transform to obtain the smoothed cumulative change function for time t calculate and The difference between the two values is used to obtain the final compensation angle value {θ i ′,...,θ k '}; Step 9: Based on the compensation angle value {θ t ′,...,θ k ′} for V{I i ,…,I k Each image in} is rotated counterclockwise with the center of the circle formed by the fisheye lens as the rotation center, and finally the frame sequence V after de-jittering is obtained. de ; Paired point matching is performed using LK sparse optical flow via the Fmatch function.
2. The VR video stabilization method based on optical flow according to claim 1, characterized in that: After step 9, the method further includes: The frame sequence V after generating and de-jittering based on the positive and negative compensation angle de One-to-one correspondence mask de ; From the frame set V de Select a frame of image I de i And the corresponding Mask de i , and from the frame sequence V O The n frames forward and backward are selected from the image, and the missing area is repaired using a generative model that fuses the target area contents of multiple adjacent frames.
3. The VR video stabilization method based on optical flow according to claim 1, characterized in that: In step 3, key point detection is performed using the ORB operator through the Fkeypoint function.
4. A computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program is used to execute the optical flow-based VR video stabilization method described in any one of claims 1 to 3.
5. An electronic device, comprising: processor; a memory for storing instructions executable by the processor; The processor is used to execute the optical flow-based VR video stabilization method described in any one of claims 1 to 3.
