Video processing method and device, equipment, storage medium and program product
Through automated video processing methods, the pose key points of video frames are used to align portrait video clips, which solves the problem of smooth connection between different action clips and improves alignment efficiency and accuracy.
Patent Information
- Application Number
- CN202410499593.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-24
- Publication Date
- 2024-09-17
AI Technical Summary
It is difficult to achieve smooth transitions between different action clips in portrait videos with the existing technology, and portrait alignment processing often requires manual operations, which is time-consuming and ineffective.
By determining the first video clip and the second video clip of video clips with similar portrait postures in the portrait video, the reference video frame is determined based on the posture key point distance of the video frame, and the portrait key point position coordinates of the reference video frame are used for portrait alignment processing. , to achieve automated alignment.
It improves the alignment efficiency and accuracy between different video clips in portrait videos, avoids portrait deformation and distortion, and ensures smooth transitions between video clips.
Smart Images

Figure CN118657818A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a video processing method, device, equipment, storage medium and program product. Background Art
[0002] In some business scenarios, in order to ensure the richness or semantics of the action, in the process of generating a portrait video, it is usually necessary to shoot different action clips of the person through different lenses, and then splice these action clips to form a portrait video. Although from the perspective of lens language, the portrait can appear in different positions when switching lenses, in many cases it is still necessary to make the portraits of different action clips smoothly connected and transitioned. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a video processing method, device, equipment, storage medium and program product for realizing automatic alignment between portraits in different video clips in a portrait video, improving the alignment efficiency and accuracy, and thus achieving smooth connection and transition between portraits in different video clips.
[0004] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions:
[0005] In a first aspect, an embodiment of the present application provides a video processing method, including:
[0006] Determine a first posture key point of a video frame in a first video clip and a second posture key point of a video frame in a second video clip, wherein the first video clip and the second video clip are video clips with similar portrait postures in a portrait video;
[0007] Determining a first reference video frame in the first video clip and a second reference video frame in the second video clip based on a distance between the first posture key point and the second posture key point;
[0008] Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, portrait alignment processing is performed on the first video clip and the second video clip.
[0009] In a second aspect, an embodiment of the present application provides a video processing device, including:
[0010] A first determining unit is used to determine a first posture key point of a video frame in a first video segment and a second posture key point of a video frame in a second video segment, wherein the first video segment and the second video segment are video segments with similar portrait postures in a portrait video;
[0011] a second determining unit, which determines a first reference video frame in the first video segment and a second reference video frame in the second video segment based on a distance between the first posture key point and the second posture key point;
[0012] An alignment unit is used to perform portrait alignment processing on the first video segment and the second video segment based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0014] processor;
[0015] a memory for storing instructions executable by the processor;
[0016] The processor is configured to execute the instructions to implement the video processing method as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can perform the video processing method described in the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the video processing method described in the first aspect.
[0019] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0020] Considering that the portrait alignment between two video clips with greatly different portrait postures will cause the portraits in the video clips to be greatly deformed and distorted, it is difficult to ensure the smooth transition of the portraits in the two video clips. Therefore, the first video clip and the second video clip are determined from the video clips with similar portrait postures in the portrait video to perform portrait alignment processing, which can avoid the problems of portrait deformation and distortion caused by the portrait alignment processing and ensure the smooth transition of the portraits in the two video clips to a certain extent; secondly, since the posture key points of the video frames can objectively and accurately describe the posture of the portrait in the video frames, and then the distance between the posture key points of the two video frames can reflect the difference in portrait posture between the two video frames, providing support for portrait alignment processing. Provide reliable data support; further, based on the distance between the first posture key point of the video frame in the first video clip and the second posture key point of the video frame in the second video clip, reference video frames are determined from the two video clips respectively, and the position coordinates of the posture key points in the two reference video frames can reflect the portrait difference between the two video clips as a whole, and then use the position coordinates of the posture key points in the two reference video frames to perform portrait alignment processing on the first video clip and the second video clip as a whole, so that all video frames in the two are aligned according to a unified standard, so that the two video clips after the portrait alignment are closer as a whole, avoiding the problem of inconsistent parameters such as the size, position and angle of the portrait, thereby improving the alignment accuracy. In addition, the entire processing process only needs to provide video clips of the portrait video to achieve automatic portrait alignment between different video clips, and the alignment efficiency is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 A schematic diagram of a flow chart of a video processing method provided for one embodiment of the present application;
[0023] Figure 2 A schematic diagram of posture key points of a video frame provided for one embodiment of the present application;
[0024] Figure 3 A schematic flow chart of a video processing method provided for another embodiment of the present application;
[0025] Figure 4 A schematic diagram of the structure of a video processing device provided by an embodiment of the present application;
[0026] Figure 5 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0028] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0029] Some concept descriptions:
[0030] Video clip: It is the original video shot at one end or several video clips cut by finding several cutting points. The content of this video cannot be changed and is an atomic unit of the entire portrait video.
[0031] Standard video frame: also known as reference video frame, usually includes two video frames with similar postures, which can be used for height comparison, etc.
[0032] Frame group to be cut: also called candidate segment, including several video frames with small changes during video recording, which can be cut.
[0033] Cut point: also known as a cut video frame, is a video frame in the frame group to be cut, which is used to divide the frame group to be cut into multiple video segments so that different video segments can be connected and transitioned through transitions and other methods.
[0034] Transition video frames: a set of video frames generated to connect and transition different video clips.
[0035] Semantic action: refers to an action with a specific meaning, such as the 1, 2, 3 gesture, the goodbye gesture, etc.
[0036] As mentioned above, in the process of generating a portrait video, it is usually necessary to shoot different action clips of the person through different lenses, and then stitch these action clips together to form a portrait video. Although from the perspective of lens language, the portrait can appear in different positions when switching lenses, in many cases it is still necessary to make the portraits of different action clips smoothly connected and transitioned.
[0037] Aligning the portraits of different action clips is a key technology to ensure smooth transition of the portraits of different action clips. However, in the related art, the portraits of different action clips are usually aligned manually, such as by manually dragging the portrait area of each video frame of the action clip, or manually inputting parameters for each video frame of the action clip. This method is not only time-consuming, but also has poor alignment effect.
[0038] In view of this, an embodiment of the present application proposes a video processing method, taking into account that after portrait alignment processing is performed between two video clips with greatly different portrait postures, the portraits in the video clips will be greatly deformed and distorted, and it will be difficult to ensure smooth connection and transition of the portraits in the two video clips. Therefore, a first video clip and a second video clip are determined from video clips with similar portrait postures in the portrait video to perform portrait alignment processing, which can avoid problems such as portrait deformation and distortion caused by the portrait alignment processing, and to a certain extent ensure smooth connection and transition of the portraits in the two video clips; secondly, since the posture key points of the video frame can objectively and accurately describe the posture of the portrait in the video frame, and then the distance between the posture key points of the two video frames can reflect the portrait posture between the two video frames. The difference between the first posture key point of the video frame in the first video clip and the second posture key point of the video frame in the second video clip is used to provide reliable data support for the portrait alignment process; further, based on the distance between the first posture key point of the video frame in the first video clip and the second posture key point of the video frame in the second video clip, the reference video frames are determined from the two video clips respectively, and the position coordinates of the posture key points in the two reference video frames can reflect the portrait difference between the two video clips as a whole, and then the position coordinates of the posture key points in the two reference video frames are used to perform portrait alignment processing on the first video clip and the second video clip as a whole, so that all video frames in the two are aligned according to a unified standard, so that the two video clips after the portrait alignment are closer as a whole, avoiding the problem of inconsistent parameters such as the size, position and angle of the portrait, thereby improving the alignment accuracy. In addition, the entire processing process only needs to provide video clips of the portrait video to realize automatic portrait alignment between different video clips, and the alignment efficiency is higher.
[0039] It should be understood that the video processing method provided in the embodiment of the present application can be executed by an electronic device. The electronic device referred to here may include a terminal device, such as a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance, a smart watch, a vehicle terminal, an aircraft, etc.; or, the electronic device may also include a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The electronic device is independent of the backend server.
[0040] It is worth noting that the video processing method provided in the embodiment of the present application can be applied to various business fields. As an example, the video processing method provided in the embodiment of the present application can be applied to 2D digital human scenes. 2D digital humans have been widely used as a digital human with real-life effects. For example, some digital humans have been employed in the fields of corporate digital employees, cultural and tourism tour guides, product tour guides, and public services. The essence of 2D digital humans is a re-editing of the video. Only the area of the lower half of the face is generated by the algorithm, and the other non-generated areas are taken from the original video material, and then the generated part is merged with the original video material. In the process of generating 2D digital human videos, the digital human needs to switch different actions to ensure the richness or semantics of the actions.
[0041] Through the video processing method provided in the embodiment of the present application, portrait alignment processing of video clips with similar portrait postures in a 2D digital human video can be implemented, thereby achieving a smooth connection and transition between these video clips.
[0042] It should be understood that the application of this method to a digital human scenario is only an exemplary description and should not be understood as a limitation on the usage scenario of the method.
[0043] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0044] See also Figure 1 , is a flow chart of a video processing method provided by an embodiment of the present application, the method comprising the following steps:
[0045] S102: Determine a first posture key point of a video frame in a first video segment and a second posture key point of a video frame in a second video segment.
[0046] The portrait video includes a plurality of video clips arranged in time sequence, and each video clip includes a plurality of video frames arranged in time sequence. Each video frame has a plurality of posture key points, and the posture key points are obtained by performing posture key point detection on the video frame. The posture key points of the video frame are used to describe the posture of the portrait in the video frame. Specifically, the image data of the video frame is input into the posture key point model for posture key point detection, and the information of the posture key points of the video frame can be determined, for example, including but not limited to the position coordinates of the posture key points.
[0047] The pose key point model can adopt various appropriate artificial intelligence models with pose key point detection capabilities. For example, the pose key point model can adopt the VGGNet model, which can detect multiple 2D pose key points from a video frame, such as Figure 2As another example, the pose key point model may adopt the BlazePose model, which is a lightweight convolutional neural network architecture suitable for key point detection of a single person and can detect multiple 3D pose key points from a video frame.
[0048] In practical applications, considering that the human body is quite flexible, various postures and shapes will appear. A slight change in any part of the human body will produce a new posture. At the same time, the visibility of its posture key points is greatly affected by clothing, posture, viewing angle, etc., and is also affected by environmental factors such as occlusion, lighting, rain and fog. Compared with 2D posture key points, 3D posture key points can better describe the new postures produced by slight changes in human body parts, and are not affected by the above factors, which helps to better align portraits. Based on this, in a more preferred solution, the posture key points of each video frame in the portrait video use 3D posture key points.
[0049] The first video clip and the second video clip are video clips with similar portrait postures in the portrait video. The first video clip and the second video clip are determined from the video clips with similar portrait postures in the portrait video to perform portrait alignment processing, which can avoid the problems of portrait deformation and distortion caused by the portrait alignment processing, and to a certain extent ensure the smooth connection and transition of the portraits in the two video clips.
[0050] For each video frame in the first video clip, its first posture key point may include some or all of the posture key points in the video frame. For each video frame in the second video clip, its second posture key point may include some or all of the posture key points in the video frame. In addition, the number of the first posture key points is the same as the number of the second posture key points, both of which are n, and n is an integer greater than 1. The n first posture key points correspond to the n second posture key points. The correspondence here means that the two are derived from the same part, and more specifically, the position coordinates of the two are close, such as both are located at the center of the neck.
[0051] S104: Determine a first reference video frame in the first video segment and a second reference video frame in the second video segment based on the distance between the first posture key point and the second posture key point.
[0052] Since the posture key points of the video frame can objectively and accurately describe the posture of the portrait in the video frame, the distance between the posture key points of the two video frames can reflect the difference in the posture of the portrait between the two video frames, providing reliable data support for portrait alignment processing. If the distance between the posture key points of the two video frames is larger, it means that the posture difference of the portrait in the two video frames is larger; if the distance between the posture key points of the two video frames is smaller, it means that the posture difference of the portrait in the two video frames is smaller, that is, the posture of the portrait is more similar.
[0053] The first reference video frame refers to a video frame selected from the first video clip and used to represent the portrait posture of the first video clip as a whole. The second reference video frame refers to a video frame selected from the second video clip and used to represent the portrait posture of the second video clip as a whole. The first reference video frame and the second reference video frame can be determined by various appropriate methods, and can be selected according to actual needs.
[0054] In one embodiment, the above S104 includes the following steps: selecting a video frame from the first video clip as a first reference video frame; determining the distance between the posture key points of the first reference video frame and the posture key points of each video frame in the second video clip, that is, the posture key point distance between the first reference video frame and each video frame in the second video clip; further, selecting a video frame in the second video clip whose posture key point distance with the first reference video frame is less than a preset threshold as the second reference video frame.
[0055] In another embodiment, the above S104 includes the following steps:
[0056] S141: Combine video frames in the first video segment and video frames in the second video segment to obtain a plurality of video frame groups.
[0057] Each video frame group includes a video frame from the first video segment and a video frame from the second video segment. For example, the first video segment includes n video frames, the second video segment includes m video frames, and n video frames and m video frames are combined to obtain n×m video frame groups.
[0058] S142, determining a reference key point distance of the video frame group based on a distance between a first posture key point and a second posture key point in the video frame group.
[0059] The reference key point distance of the video frame group is used to represent the difference in portrait posture between two video frames in the video frame group. If the reference key point distance is smaller, the difference in portrait posture between the two video frames in the video frame group is smaller, that is, the portrait postures of the two are more similar; if the reference key point distance is larger, the difference in portrait posture between the two video frames in the video frame group is greater.
[0060] As an example, the distance between each first posture key point and the corresponding second posture key point can be determined, and the sum of the distances between n first posture key points and the corresponding second posture key points is determined as the reference key point distance of the video frame group. That is:
[0061]
[0062] Among them, D crepresents the reference key distance of the video frame group, (x i ,y i ) represents the position coordinates of the i-th first posture key point, P c represents the set of pose key points contained in the video frame from the first video clip in the video frame group, (u i ,v i ) represents the position coordinates of the second posture key point corresponding to the i-th first posture key point, P l The video frame from the second video clip in the video frame group represents a set of pose key points.
[0063] It is understandable that in the above method, the sum of the distances between the n first posture key points and the corresponding second posture key points in the video frame group can better reflect the difference in the overall portrait posture between the two video frames in the video frame group. In this way, the first reference video frame and the second reference video frame selected based on the determined reference key point distance can more accurately reflect the difference in the overall portrait posture between the first video clip and the second video clip as a whole, which helps to improve the portrait alignment effect between the two and avoid problems such as portrait deformation.
[0064] As another example, the distance between each first posture key point and the corresponding second posture key point may also be determined, and the average of the distances between n first posture key points and the corresponding second posture key points may be determined as the reference key point distance of the video frame group.
[0065] S143, selecting a target video frame group whose reference key point distance is less than a preset threshold from the multiple video frame groups.
[0066] S144: Use the video frames in the target video frame group that belong to the first video segment as first reference video frames, and use the video frames in the target video frame group that belong to the second video segment as second reference video frames.
[0067] Since the smaller the distance between the reference key points of the video frame group, the smaller the difference in the portrait posture between the two video frames in the video frame group, that is, the more similar the portrait postures of the two are, by selecting the target video frame group whose reference key point distance is less than the preset threshold, it is determined based on this that the first reference video frame and the second reference video frame are the two video frames with the most similar portrait postures in the first video clip and the second video clip. Further, using these two most similar reference video frames as a unified adjustment basis, the portrait alignment processing is performed on the two video clips, which can ensure that the two video clips after the portrait alignment are closer as a whole, avoid the problem of inconsistent parameters such as the size, position and angle of the portrait, and thus improve the alignment accuracy.
[0068] The embodiment of the present application shows some implementations of the above S104. Of course, it should be understood that the above S104 can also be implemented in other ways, which are not limited in the embodiment of the present application.
[0069] S106: Perform portrait alignment processing on the first video clip and the second video clip based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame.
[0070] Since the position coordinates of the posture key points of the two reference video frames can reflect the portrait differences between the two video clips as a whole, the position coordinates of the key points of the two reference video frames are used to perform portrait alignment on the first video clip and the second video clip as a whole, so that all video frames in the two are aligned with the portrait according to a unified standard, so that the two video clips after the portrait alignment are closer as a whole, avoiding the problem of inconsistent parameters such as the size, position and angle of the portrait, thereby improving the alignment accuracy.
[0071] The portrait alignment process in S106 refers to aligning the portrait in the video frame of the first video clip with the portrait in the video frame of the second video clip so that the two are consistent in parameters such as size, position and angle, thereby achieving a smooth transition of the portrait between the first video clip and the second video clip.
[0072] The portrait alignment processing of the first video clip and the second video clip may be implemented in various appropriate ways, which may be selected according to actual needs.
[0073] In one embodiment, the portrait alignment process includes portrait scaling, portrait translation, and portrait rotation. Portrait scaling refers to adjusting the size of the portrait area of the video frame, portrait translation refers to adjusting the position of the portrait area of the video frame, and portrait rotation refers to adjusting the angle of the portrait area of the video frame. In this case, the above S106 includes the following steps:
[0074] S161, determining a target scaling ratio based on the position coordinates of a first posture key point in a first reference video frame and the position coordinates of a second posture key point in a second reference video frame, and performing portrait scaling on video frames in a second video clip based on the target scaling ratio.
[0075] As an example, the target scaling ratio includes a width scaling ratio and a height scaling ratio, the width scaling ratio is used to adjust the width of the portrait area of the video frame, and the height scaling ratio is used to adjust the height of the portrait area of the video frame. In this case, the target scaling ratio can be determined in the following manner: step A1, based on the position coordinates of the first posture key point in the first reference video frame, determine the first portrait width and the first portrait height of the first reference video frame; step A2, based on the position coordinates of the second posture key point in the second reference video frame, determine the second portrait width and the second portrait height of the second reference video frame; step A3, based on the ratio between the first portrait width and the second portrait width, determine the width scaling ratio; step A4, based on the ratio between the first portrait height and the second portrait height, determine the height scaling ratio.
[0076] The maximum value of the distance in the width direction of the posture key points of each video frame can reflect the width of the portrait of the video frame, and then the ratio between the portrait widths of two video frames can reflect the overall difference in the portrait width between the two video clips. Based on this difference in the portrait width, the proportion of portrait width scaling can be accurately determined. Similarly, the maximum value of the distance in the height direction of the posture key points of each video frame can reflect the height of the portrait of the video frame, and then the ratio between the portrait heights of the two video frames can reflect the overall difference in the portrait height between the two video clips. Based on this difference in the portrait height, the proportion of portrait degree adjustment can be accurately determined.
[0077] For example, the width of the first portrait can be determined by the following formula (1), the height of the first portrait can be determined by the following formula (2), the width of the second portrait can be determined by the following formula (3), and the height of the second portrait can be determined by the following formula (4).
[0078] Dist xf,max =max(x f1 ,x f2 ,...,x fn )-min(x f1 ,x f2 ,...,x fn ) (1)
[0079] Dist yf,max =max(y f1 ,y f2 ,...,y fn )-min(y f1 ,y f2 ,...,y fn )(2)
[0080] Dist xl,max =max(x l1 ,xl2 ,...,x ln )-min(x l1 ,x l2 ,...,x ln ) (3)
[0081] Dist yl,max =max(y l1 ,y l2 ,...,y ln )-min(y l1 ,y l2 ,...,y ln ) (4)
[0082] Among them, Dist xf,max represents the width of the first portrait, f1, f2, ..., fn represent the n first posture key points in the first reference video frame, x f1 ,x f2 ,...,x fn Represents the x-axis coordinates of n first posture key points; Dist yf,max Indicates the height of the first portrait, y f1 ,y f2 ,...,y fn Represents the y-axis coordinates of the n first posture key points; Dist xl,max represents the width of the second portrait, l1, l2, ..., ln represent the n second posture key points in the second reference video frame, x l1 ,x l2 ,...,x ln Represents the x-axis coordinates of n second posture key points; Dist yl,max Indicates the height of the second portrait, y l1 ,y l2 ,...,y ln Represents the y-axis coordinates of the n second posture key points.
[0083] Further, the width scaling ratio can be determined as Height scaling is In this case, the first video segment can be fixed unchanged, and for each video frame in the second video segment, the portrait area of the portrait area of the video frame is adjusted based on the width scaling ratio and the height scaling ratio, and the width of the adjusted portrait area is The height of the adjusted portrait area is Wherein, w' represents the adjusted width of the portrait area, w represents the width of the portrait area before adjustment, h' represents the height of the portrait area before adjustment, and h represents the height of the portrait area after adjustment.
[0084] In practical applications, for each video frame in the second video clip, the width of the portrait area of the video frame can be adjusted based on the width scaling ratio; then, when the aspect ratio of the portrait area is fixed, the height of the portrait area of the video frame can be adjusted based on the height scaling ratio. Alternatively, the height of the portrait area of the video frame can be adjusted based on the height scaling ratio; then, when the aspect ratio of the portrait area is fixed, the width of the portrait area of the video frame can be adjusted based on the width scaling ratio. In this way, it can be ensured that the portrait in the video frame does not deform.
[0085] In the above method, it is considered that the portraits cannot be aligned due to inconsistent sizes, for example, the portraits in different video clips are sometimes large and sometimes small. When splicing different video clips, this sudden change makes the spliced portrait video discontinuous; secondly, it is also considered that if each video frame in the second video clip is scaled to different scales, it is difficult to ensure that the portraits in each video frame in the second video clip are smooth, but the portraits will be caused to be sometimes large and sometimes small. Based on this, according to the ratio of the portrait width and the portrait height between the posture key points of the two reference video frames, the uniform scaling ratio is determined, and the height and width of the portrait area of all video frames in the second video clip are adjusted, which can ensure that the portraits in each video frame in the second video clip are smooth, and make the first video clip and the second video clip closer in portrait size, thereby improving the accuracy of portrait alignment.
[0086] S162, determining a target translation distance based on the position coordinates of a first posture key point in the first reference video frame and the position coordinates of a second posture key point in the second reference video frame, and performing portrait translation on the video frames in the second video clip based on the target translation distance.
[0087] As another example, the target translation distance includes a width translation distance and a height translation distance. In this case, the target translation distance can be determined as follows: Step B1, determine the first posture key point located at the first part in the first reference video frame to obtain the first part key point, and determine the second posture key point located at the first part in the second reference video frame to obtain the second part key point; Step B2, based on the position coordinates of the first part key point and the position coordinates of the second part key point, determine the first reference distance in the width direction and the second reference distance in the height direction between the first part key point and the second part key point; Step B3, determine the first reference distance as the width translation distance; Step B4, determine the second reference distance as the height translation distance.
[0088] The first part may be, for example, the waist, back, legs, etc. In a more preferred solution, the first part is the waist.
[0089] For example, Figure 2As an example, the posture key point 8 is a posture key point located at the waist, and the position coordinates of the first part key point are (x f,8 ,y f,8 ), the position coordinates of the second key point are (x l,8 ,y l,8 ). In this case, the first reference distance may be determined by the following formula (5), and the second reference distance and may be determined by the following formula (6).
[0090] Δx=x f,8 -x l,8 (5)
[0091] Δy=y f,8 -y l,8 (6)
[0092] Wherein, Δx represents the first reference distance, and Δy represents the second reference distance.
[0093] Furthermore, for each video frame in the second video segment, the portrait area of the video frame is translated by Δx in the width direction (i.e., the x-axis direction), and the portrait area of the video frame is translated by Δy in the height direction (i.e., the y-axis direction), so as to complete the adjustment of the portrait position of the video frame.
[0094] It is worth noting that, in actual applications, the number of first part key points and first part key points can be multiple. In this case, the average of the distances between all first part key points and their corresponding second part key points in the width direction can be used as the first reference distance. Similarly, the average of the distances between all first part key points and their corresponding second part key points in the height direction can be used as the second reference distance. In addition, whether it is a 2D posture key point or a 3D posture key point, the width translation distance and the height translation distance can be determined in the above manner, that is, for the 3D posture key point, only the position of the portrait area in the x-axis and y-axis directions is adjusted, and the position of the z-axis is not adjusted. This is because the adjustment of the z-axis position has actually been reflected in the portrait scaling process.
[0095] In the above method, since a mass point can be seen in the human body, the center of gravity of the human body is usually near the waist, and the center of gravity can represent this mass point, so the position coordinates of the posture key point located at the waist in the video frame can reflect the center of gravity of the portrait in the video frame. Based on this, based on the distance between the posture key points located at the waist in the two video frames in the width direction and the height direction respectively, the difference between the center of gravity of the portrait in the two video frames can be reflected, and then the portrait in the video frame in the second video clip is translated based on the distance, which can ensure that the position of the portrait in each video frame in the second video clip is consistent with the position of the portrait in the first video clip, so that the portraits in the two video clips can be smoothly connected and transitioned.
[0096] As another example, the width translation distance and the height translation distance may also be determined based on the position coordinates of all first posture key points in the first reference video frame and the position coordinates of all second posture key points in the second reference video frame. For example, the average value of the distances in the width direction between all first posture key points and the corresponding second posture key points is determined as the width translation distance, and the average value of the distances in the height direction between all first posture key points and the corresponding second posture key points is determined as the height translation distance.
[0097] S163, determining a target rotation angle based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, and performing portrait rotation on the video frame in the second video clip based on the target rotation angle.
[0098] As an example, the target selection angle can be determined in the following manner: Step C1, determine the first posture key point located at the second part in the first reference video frame to obtain the third part key point, and determine the second posture key point located at the second part in the second reference video frame to obtain the fourth part key point; Step C2, based on the position coordinates of the third part key point, generate a first line segment for representing the second part in the first reference video frame, and determine the slope of the first line segment; Step C3, based on the position coordinates of the fourth part key point, generate a second line segment for representing the second part in the second reference video frame, and determine the slope of the second line segment; Step C4, determine the target rotation angle based on the slope of the first line segment and the slope of the second line segment.
[0099] More specifically, in step C3, the target rotation angle is determined by: determining the difference between the slope of the first line segment and the slope of the second line segment; determining the product between the slope of the first line segment and the slope of the second line segment; performing an inverse tangent calculation based on the difference and the product to obtain the target rotation angle.
[0100] The second part can be the spine, lumbar spine, cervical spine, etc. In a more preferred solution, the second part is the spine.
[0101] For example, Figure 2 Taking the posture key points shown in FIG. 1 as an example, the posture key points located at the spine include posture key point 1 and posture key point 8, and the line segment representing the spine of the portrait is the line segment formed by connecting posture key point 1 and posture key point 8. In this case, the slope of the line segment representing the spine of the portrait in each reference video frame can be determined by the following formula (7).
[0102]
[0103] Among them, k represents the slope of the line segment, (x1, y1) represents the position coordinates of posture key point 0, and (x2, y2) represents the position coordinates of posture key point 8.
[0104] Furthermore, the target rotation angle can be determined by the following formula (8).
[0105]
[0106] Wherein, θ represents the target rotation angle, which is equal to the angle between the first line segment and the second line segment; k1 represents the slope of the first line segment, k2 represents the slope of the second line segment, and tan -1 Represents the inverse tangent calculation.
[0107] In the above method, considering that sometimes the portrait video is obtained by shooting with multiple sets of lenses, the lens angle and the character's standing posture may cause slight deviations, and such slight deviations will cause the character to rotate, so the portrait needs to be straightened, and the degree of rotation of the character can be intuitively reflected by the second part. Based on this, the position coordinates of the key points of the posture located in the second part in the two reference video frames can reflect the difference in angles of the portraits in the two video clips as a whole, and then determine the target rotation angle based on this difference, and rotate the portraits of the video frames in the second video clip based on the target rotation angle, which can ensure that the angle of the portrait in each video frame in the second video clip is consistent with the angle of the portrait in the first video clip, so that the portraits in the two video clips can be smoothly connected and transitioned.
[0108] As another example, the target rotation angle may also be determined based on the position coordinates of all first posture key points in the first reference video and the position coordinates of all second posture key points in the second reference video frame. For example, the slope of the first line segment between all first posture key points is determined, and the slope of the second line segment between all second posture key points corresponding to the first posture key points is determined; for each first line segment, a rotation angle is calculated based on the slope of the first line segment and the slope of the corresponding second line segment; finally, the average of all rotation angles is determined as the target rotation angle.
[0109] It is worth noting that the three operations of portrait zooming, portrait translation and portrait rotation do not affect each other and can be performed in any order. In addition, no perspective correction is performed during the portrait rotation process. This is because perspective correction will change the posture of the portrait in the second video clip, such as causing the portrait in the second video clip to be deformed or magnified and blurred.
[0110] In another embodiment, the portrait alignment process includes affine transformation. In this case, the above S106 includes the following steps: determining an affine transformation matrix based on the position coordinates of the first posture key point in the first reference video and the position coordinates of the second posture key point in the second reference video frame; and performing an affine transformation on the video frame in the second video segment based on the affine transformation matrix.
[0111] Affine transformation is a linear transformation that integrates the adjustment of the size, position and angle of the image. Therefore, by performing affine transformation on the video frames in the second video clip, the effect of aligning the posture of the portrait in the second video clip with the portrait in the first video clip can also be achieved, and the implementation is more convenient and efficient.
[0112] As an example, a first posture key point located at the shoulder and a first posture key point located at the waist can be selected from the first reference video frame as the first reference key point, and a second posture key point corresponding to the first reference key point can be selected from the second reference video frame as the second reference key point; then, the affine transformation matrix is calculated by the following formula (9).
[0113]
[0114] Where (x1, y1) represents the position coordinates of the first reference key point, (x2, y2) represents the position coordinates of the second reference key point, Represents an affine transformation matrix.
[0115] In another embodiment of the present application, considering that a video frame is usually composed of multiple layers, the portrait area is usually located in the top layer, and the pixels at the edge of the video frame are usually located in the bottom layer as the background. In this case, after the video frame is affine transformed, the pixels at the edge will appear black, that is, the RGB value is 0, resulting in poor visual effects of the video frame. In order to facilitate the subsequent improvement of the visual effects of the video frame by background filling, after the video frame in the second video clip is affine transformed based on the affine transformation matrix, these pixels are transparently processed.
[0116] Specifically, after performing affine transformation on the video frame in the second video clip based on the affine transformation matrix, the above-mentioned video processing method may also include: determining the target pixel whose RGB value in the video frame after the affine transformation meets the preset filling condition; adding a transparent channel in the RGB color space of the target pixel, and assigning a preset value to the transparent channel, thereby realizing transparent processing of the target pixel.
[0117] The preset filling condition can be set according to actual needs, for example, the RGB value of the pixel is 0 or less than the preset value, etc., which is not limited in the embodiment of the present application.
[0118] In another embodiment of the present application, considering that the portrait in the video clip will change after the portrait alignment process is performed on the video clip, in order to better connect and transition between the two video clips with changed portraits, after the above S106, the video processing method provided in the embodiment of the present application may also include: determining the last video frame of the first video clip after the alignment process and the first video frame of the second video clip after the alignment process; generating a transition video frame based on the interpolation algorithm, the position coordinates of the first posture key point in the last video frame, and the position coordinates of the second posture key point in the first video frame; inserting the transition video frame between the last video frame and the first video frame. The first video clip is located before the second video clip in terms of timing.
[0119] The interpolation algorithm can adopt various interpolation algorithms commonly used in the field, such as an interpolation algorithm based on deep learning, which takes the last video frame and the first video frame as the input of the neural network, and combines the optical flow neural network, occlusion estimation technology, etc. to predict the transition video frame between the two video frames. In this method, the interpolation algorithm based on deep learning can extract semantic information from the video frame, so it performs well in occlusion estimation and other aspects; the optical flow neural network can calculate the dense optical flow between the two video frames, and based on the optical flow information, the two video frames can be transformed to the middle time, thereby synthesizing the transition video frame.
[0120] See also Figure 3 , is a flow chart of a video processing method provided by another embodiment of the present application, the method comprising the following steps:
[0121] S302, determining the posture similarity between the video frames in the portrait video and the portrait action information of the video frames based on the posture key points of the video frames in the portrait video.
[0122] The posture similarity between two video frames can be determined by comparing the position coordinates of the corresponding posture key points in the two video frames. The specific comparison method can be set according to actual needs, and the embodiment of the present application does not limit this. As an example, the distance between the corresponding posture key points in the two video frames is calculated, and the distance is used as the posture similarity between the two. As another example, the position coordinates of the corresponding posture key points in the two video frames are input into a pre-trained similarity detection model to obtain the posture similarity between the two.
[0123] The portrait action information of the video frame is used to describe the type of semantic action of the portrait in the video frame, such as waving, bowing, etc. The portrait action information of the video frame can be determined in various ways, which can be selected according to actual needs, and the embodiments of the present application are not limited to this. As an example, the posture similarity between the video frame and the video frames of multiple portrait action information is calculated, and then the portrait action information corresponding to the video frame with the highest posture similarity is selected. As another example, the position coordinates of the posture key points of the video frame are input into a pre-trained semantic action recognition model to obtain the portrait action information of the video frame.
[0124] S304: Cut the portrait video based on posture similarity to obtain at least one candidate segment.
[0125] The portrait similarity between different candidate segments is less than the preset similarity threshold. For example, a portrait video includes 100 video frames, and the portrait postures of the first 50 video frames are all standing, and the posture similarity between these video frames is high, while the portrait postures of the last 50 video frames are all sitting, and the posture similarity between these video frames is high, but the posture similarity between the first 50 video frames and the last 50 video frames is low, so the portrait video is divided into two candidate segments, the first 50 video frames belong to the first candidate segment, and the last 50 video frames belong to the second candidate segment.
[0126] S306: Divide the candidate segment into at least one video segment based on the portrait action information of the video frames in the candidate segment.
[0127] The portrait action information of video frames in different video clips is different. Considering that the video frames in the candidate clips have high posture similarity, they may contain different semantic actions. For example, the portrait postures of the video frames in the candidate clips are all standing, but they may contain multiple semantic actions such as greeting, welcoming, and silence. Video frames with different semantic actions usually require smooth connection and transition. To this end, for each candidate clip, based on the portrait action information of the video frames in the candidate clip, the candidate backend is divided into at least one video clip, so that each video clip corresponds to a semantic action, and then by performing portrait alignment processing on different video clips, a smooth connection and transition between video frames with different semantic actions can be achieved.
[0128] For example, if a candidate segment includes 50 video frames, the portrait semantic action of the first 10 video frames is silence, the portrait semantic action of the middle 30 video frames is greeting, and the portrait semantic action of the last 10 video frames is silence, then the candidate segment is divided into 3 video segments, that is, the first 10 video frames belong to the first video segment, the middle 30 video frames belong to the second video segment, and the last 10 video frames belong to the third video segment.
[0129] S308: From at least one video segment, select a video segment that is adjacent in time sequence and is earlier in time sequence as a first video segment, and select a video segment that is later in time sequence as a second video segment.
[0130] For example, for each candidate segment, three video segments are obtained by segmenting the candidate segment. In this case, the first video segment is used as the first video segment, the second video segment is used as the second video segment, and the two are subjected to portrait alignment processing through subsequent steps S310 to S314; then, the second video segment is used as the first video segment, the third video segment is used as the second video segment, and the two are subjected to portrait alignment processing through subsequent steps S310 to S314. At this point, the portrait alignment processing of the three video segments is completed.
[0131] It can be understood that by taking the video clip that is adjacent and in front in time sequence as the first video clip and the video clip that is behind in time sequence as the second video clip, and performing portrait alignment processing based on this, a smooth connection and transition between video clips with similar portrait postures in the portrait video can be achieved, thereby improving the alignment accuracy.
[0132] S310: Determine a first posture key point of a video frame in a first video segment and a second posture key point of a video frame in a second video segment.
[0133] The specific implementation of S310 is Figure 1 The specific implementation of S102 in the illustrated embodiment is similar and will not be described in detail.
[0134] S312: Determine a first reference video frame in the first video segment and a second reference video frame in the second video segment based on the distance between the first posture key point and the second posture key point.
[0135] The specific implementation method of S312 is Figure 1 The specific implementation of S104 in the illustrated embodiment is similar and will not be described in detail.
[0136] S314: Perform portrait alignment processing on the first video clip and the second video clip based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame.
[0137] The specific implementation method of S314 is Figure 1 The specific implementation of S106 in the illustrated embodiment is similar and will not be described in detail.
[0138] The video processing method provided by one or more embodiments of the present application takes into account that after portrait alignment processing is performed between two video clips with greatly different portrait postures, the portraits in the video clips will be greatly deformed and distorted, and it is difficult to ensure smooth connection and transition of the portraits in the two video clips. Therefore, the first video clip and the second video clip are determined from the video clips with similar portrait postures in the portrait video to perform portrait alignment processing, which can avoid the problems of portrait deformation and distortion caused by the portrait alignment processing and ensure smooth connection and transition of the portraits in the two video clips to a certain extent; secondly, because the posture key points of the video frame can objectively and accurately describe the posture of the portrait in the video frame, and then the distance between the posture key points of the two video frames can reflect the portrait posture between the two video frames. The difference between the first posture key point of the video frame in the first video clip and the second posture key point of the video frame in the second video clip is used to provide reliable data support for the portrait alignment process; further, based on the distance between the first posture key point of the video frame in the first video clip and the second posture key point of the video frame in the second video clip, the reference video frames are determined from the two video clips respectively, and the position coordinates of the posture key points in the two reference video frames can reflect the portrait difference between the two video clips as a whole, and then the position coordinates of the posture key points in the two reference video frames are used to perform portrait alignment processing on the first video clip and the second video clip as a whole, so that all video frames in the two are aligned according to a unified standard, so that the two video clips after the portrait alignment are closer as a whole, avoiding the problem of inconsistent parameters such as the size, position and angle of the portrait, thereby improving the alignment accuracy. In addition, the entire processing process only needs to provide video clips of the portrait video to realize automatic portrait alignment between different video clips, and the alignment efficiency is higher.
[0139] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0140] Based on the same inventive concept, the present application also provides a video processing device. Figure 4 , is a schematic diagram of a structure of a video processing device provided by an embodiment of the present application. In a software implementation, the video processing device 400 may include: a first determination unit 410 , a second determination unit 420 , and an alignment unit 430 .
[0141] The first determining unit 410 is used to determine a first posture key point of a video frame in a first video segment and a second posture key point of a video frame in a second video segment, wherein the first video segment and the second video segment are video segments with similar portrait postures in a portrait video.
[0142] The determination unit 420 is configured to determine a first reference video frame in the first video segment and a second reference video frame in the second video segment based on the distance between the first posture key point and the second posture key point.
[0143] The alignment unit 430 is used to perform portrait alignment processing on the first video segment and the second video segment based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame.
[0144] In another embodiment, the second determining unit is used to:
[0145] Combining video frames in the first video segment and video frames in the second video segment to obtain a plurality of video frame groups;
[0146] Determining a reference key point distance of the video frame group based on a distance between a first posture key point and a second posture key point in the video frame group;
[0147] Selecting a target video frame group whose reference key point distance is less than a preset threshold from the multiple video frame groups;
[0148] The video frames in the target video frame group that belong to the first video segment are used as the first reference video frames, and the video frames in the target video frame group that belong to the second video segment are used as the second reference video frames.
[0149] In another embodiment, the number of the first posture key points is n, the number of the second posture key points is n, and the n first posture key points correspond one to one with the n second posture key points;
[0150] The second determining unit performs the following steps when determining the reference key point distance of the video frame group based on the distance between the first posture key point and the second posture key point in the video frame group:
[0151] The sum of the distances between the n first posture key points and the corresponding second posture key points is determined as the reference key point distance of the video frame group.
[0152] In another embodiment, the portrait alignment process includes portrait scaling, portrait translation, and portrait rotation;
[0153] The alignment unit is used for:
[0154] Determining a target scaling ratio based on the position coordinates of a first posture key point in the first reference video frame and the position coordinates of a second posture key point in the second reference video frame, and performing portrait scaling on the video frames in the second video clip based on the target scaling ratio;
[0155] Determining a target translation distance based on position coordinates of a first posture key point in the first reference video frame and position coordinates of a second posture key point in the second reference video frame, and performing portrait processing on a video frame in the second video clip based on the target translation distance;
[0156] Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, a target rotation angle is determined, and based on the target rotation angle, a portrait rotation is performed on the video frame in the second video clip.
[0157] In another embodiment, the target scaling ratio includes a width scaling ratio and a height scaling ratio;
[0158] The alignment unit performs the following steps when determining the target scaling ratio based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame:
[0159] Determine a first portrait width and a first portrait height of the first reference video frame based on the position coordinates of the first posture key point in the first reference video frame;
[0160] Determine a second portrait width and a second portrait height of the second reference video frame based on the position coordinates of the second posture key point in the second reference video frame;
[0161] Determining the width scaling ratio based on a ratio between the first portrait width and the second portrait width;
[0162] The height scaling ratio is determined based on a ratio between the first portrait height and the second portrait height.
[0163] In another embodiment, the target translation distance includes a width translation distance and a height translation distance;
[0164] The alignment unit performs the following steps when determining the target translation distance based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame:
[0165] Determine a first posture key point located at a first part in the first reference video frame to obtain a first part key point, and determine a second posture key point located at the first part in the second reference video frame to obtain a second part key point;
[0166] Determine a first reference distance in a width direction and a second reference distance in a height direction between the first part key point and the second part key point based on the position coordinates of the first part key point and the position coordinates of the second part key point;
[0167] determining the first reference distance as the width translation distance;
[0168] The second reference distance is determined as the height translation distance.
[0169] In another embodiment, the alignment unit performs the following steps when determining the target rotation angle based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame:
[0170] Determine a first posture key point located at a second part in the first reference video frame to obtain a third part key point, and determine a second posture key point located at the second part in the second reference video frame to obtain a fourth part key point;
[0171] Based on the position coordinates of the key point of the third part, generating a first line segment for representing the second part in the first reference video frame, and determining the slope of the first line segment;
[0172] Based on the position coordinates of the key point of the fourth part, generating a second line segment for representing the second part in the second reference video frame, and determining the slope of the second line segment;
[0173] The target rotation angle is determined based on the slope of the first line segment and the slope of the second line segment.
[0174] In another embodiment, the alignment unit performs the following steps when determining the target rotation angle based on the slope of the first line segment and the slope of the second line segment:
[0175] determining a difference between a slope of the first line segment and a slope of the second line segment;
[0176] determining a product between a slope of the first line segment and a slope of the second line segment;
[0177] An arc tangent calculation is performed based on the difference and the product to obtain the target rotation angle.
[0178] In another embodiment, the portrait alignment process includes an affine transformation;
[0179] The alignment unit is used for:
[0180] Determining an affine transformation matrix based on the position coordinates of a first posture key point in the first reference video and the position coordinates of a second posture key point in the second reference video frame;
[0181] Perform an affine transformation on the video frames in the second video segment based on the affine transformation matrix.
[0182] In another embodiment, the video processing device further includes:
[0183] The filling unit is used to determine the target pixel whose RGB value meets the preset filling condition in the video frame after affine transformation, add a transparent channel in the RGB color space of the target pixel, and assign a preset value to the transparent channel.
[0184] In another embodiment, the first video segment is located before the second video segment in time sequence;
[0185] The video processing device also includes:
[0186] Interpolation unit, used for:
[0187] Determine the last video frame of the first video segment after the alignment process and the first video frame of the second video segment after the alignment process;
[0188] Generate a transition video frame based on the interpolation algorithm, the position coordinates of the first posture key point in the last video frame, and the position coordinates of the second posture key point in the first video frame;
[0189] The transition video frame is inserted between the last video frame and the first video frame.
[0190] In another embodiment, the second determining unit is further used to: determine the posture similarity between the video frames in the portrait video and the portrait action information of the video frames based on the posture key points of the video frames in the portrait video;
[0191] The video processing device also includes:
[0192] A first cutting unit is used to cut the portrait video based on the posture similarity to obtain at least one candidate segment, and the portrait similarity between different candidate segments is less than a preset similarity threshold;
[0193] A second cutting unit, configured to divide the candidate segment into at least one video segment based on the portrait action information of the video frames in the candidate segment, wherein the portrait action information of the video frames in different video segments is different;
[0194] The second determining unit is further configured to: select, from the at least one video segment, a video segment that is adjacent in time sequence and is earlier in time sequence as the first video segment, and a video segment that is later in time sequence as the second video segment.
[0195] Obviously, the video processing device provided in the embodiment of the present application can be used as Figure 1 The execution subject of the video processing method shown, for example Figure 1 In the video processing method shown in FIG. 1 , step S102 may be performed by Figure 4 The first determining unit 410 in the video processing device shown in FIG. 1 is executed, and step S104 can be performed by Figure 4 The second determining unit 420 in the video processing device shown in FIG. 1 is executed, and step S106 can be performed by Figure 4 The alignment unit 430 in the video processing device is shown to perform.
[0196] According to another embodiment of the present application, Figure 4 The various modules in the video processing device shown can be separately or all merged into one or several other modules to constitute, or some of the modules can also be split into multiple smaller modules in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the functions of one module can also be realized by multiple modules, or the functions of multiple modules can be realized by one module. In the embodiments of the present application, the video processing device may also include other modules. In practical applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of multiple modules.
[0197] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 1 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 4 The video processing device shown in the figure is used to implement the video processing method of the embodiment of the present application. The computer program can be recorded on a computer-readable storage medium, for example, and transferred to an electronic device through the computer-readable storage medium and run therein.
[0198] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 5 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0199] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0200] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0201] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a video processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0202] Determine a first posture key point of a video frame in a first video clip and a second posture key point of a video frame in a second video clip, wherein the first video clip and the second video clip are video clips with similar portrait postures in a portrait video;
[0203] Determining a first reference video frame in the first video clip and a second reference video frame in the second video clip based on a distance between the first posture key point and the second posture key point;
[0204] Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, portrait alignment processing is performed on the first video clip and the second video clip.
[0205] The above application Figure 1 The method performed by the video processing device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0206] The electronic device may also perform Figure 1 The method and the video processing device are implemented in Figure 1 , Figure 3 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0207] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0208] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:
[0209] Determine a first posture key point of a video frame in a first video clip and a second posture key point of a video frame in a second video clip, wherein the first video clip and the second video clip are video clips with similar portrait postures in a portrait video;
[0210] Determining a first reference video frame in the first video clip and a second reference video frame in the second video clip based on a distance between the first posture key point and the second posture key point;
[0211] Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, portrait alignment processing is performed on the first video clip and the second video clip.
[0212] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0213] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0214] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0215] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0216] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A video processing method, characterized in that: include: Determine a first posture key point of a video frame in a first video clip, and a second posture key point of a video frame in a second video clip, wherein the first video clip and the second video clip are video clips with similar portrait postures in a portrait video; Determining a first reference video frame in the first video clip and a second reference video frame in the second video clip based on a distance between the first posture key point and the second posture key point; Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, portrait alignment processing is performed on the first video clip and the second video clip.
2. The method according to claim 1, characterized in that The determining, based on the distance between the first posture key point and the second posture key point, a first reference video frame in the first video clip and a second reference video frame in the second video clip comprises: Combining video frames in the first video segment and video frames in the second video segment to obtain a plurality of video frame groups; Determining a reference key point distance of the video frame group based on a distance between a first posture key point and a second posture key point in the video frame group; Selecting a target video frame group whose reference key point distance is less than a preset threshold from the multiple video frame groups; The video frames in the target video frame group that belong to the first video segment are used as the first reference video frames, and the video frames in the target video frame group that belong to the second video segment are used as the second reference video frames.
3. The method according to claim 2, characterized in that The number of the first posture key points is n, the number of the second posture key points is n, and the n first posture key points correspond one to one with the n second posture key points; The determining the reference key point distance of the video frame group based on the distance between the first posture key point and the second posture key point in the video frame group includes: The sum of the distances between the n first posture key points and the corresponding second posture key points is determined as the reference key point distance of the video frame group.
4. The method according to claim 1, characterized in that: The portrait alignment process includes portrait scaling, portrait translation and portrait rotation; The performing portrait alignment processing on the first video clip and the second video clip based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame includes: Determining a target scaling ratio based on the position coordinates of a first posture key point in the first reference video frame and the position coordinates of a second posture key point in the second reference video frame, and performing portrait scaling on the video frames in the second video clip based on the target scaling ratio; Determine a target translation distance based on the position coordinates of a first posture key point in the first reference video frame and the position coordinates of a second posture key point in the second reference video frame, and perform portrait translation on the video frame in the second video clip based on the target translation distance; Based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, a target rotation angle is determined, and based on the target rotation angle, a portrait rotation is performed on the video frame in the second video clip.
5. The method according to claim 4, characterized in that The target scaling ratio includes a width scaling ratio and a height scaling ratio; The determining the target scaling ratio based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame includes: Determine a first portrait width and a first portrait height of the first reference video frame based on the position coordinates of the first posture key point in the first reference video frame; Determine a second portrait width and a second portrait height of the second reference video frame based on the position coordinates of the second posture key point in the second reference video frame; Determining the width scaling ratio based on a ratio between the first portrait width and the second portrait width; The height scaling ratio is determined based on a ratio between the first portrait height and the second portrait height.
6. The method according to claim 4, characterized in that The target translation distance includes a width translation distance and a height translation distance; The determining the target translation distance based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame includes: Determine a first posture key point located at a first part in the first reference video frame to obtain a first part key point, and determine a second posture key point located at the first part in the second reference video frame to obtain a second part key point; Determine a first reference distance in a width direction and a second reference distance in a height direction between the first part key point and the second part key point based on the position coordinates of the first part key point and the position coordinates of the second part key point; determining the first reference distance as the width translation distance; The second reference distance is determined as the height translation distance.
7. The method according to claim 4, characterized in that The determining the target rotation angle based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame includes: Determine a first posture key point located at a second part in the first reference video frame to obtain a third part key point, and determine a second posture key point located at the second part in the second reference video frame to obtain a fourth part key point; Based on the position coordinates of the key point of the third part, generating a first line segment for representing the second part in the first reference video frame, and determining the slope of the first line segment; Based on the position coordinates of the key point of the fourth part, generating a second line segment for representing the second part in the second reference video frame, and determining the slope of the second line segment; The target rotation angle is determined based on the slope of the first line segment and the slope of the second line segment.
8. The method according to claim 7, characterized in that The determining the target rotation angle based on the slope of the first line segment and the slope of the second line segment includes: determining a difference between a slope of the first line segment and a slope of the second line segment; determining a product between a slope of the first line segment and a slope of the second line segment; An arc tangent calculation is performed based on the difference and the product to obtain the target rotation angle.
9. The method according to claim 1, characterized in that: The portrait alignment process includes affine transformation; The performing portrait alignment processing on the first video clip and the second video clip based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame includes: Determining an affine transformation matrix based on the position coordinates of a first posture key point in the first reference video and the position coordinates of a second posture key point in the second reference video frame; Perform an affine transformation on the video frames in the second video segment based on the affine transformation matrix.
10. The method according to claim 9, characterized in that After performing affine transformation on the video frames in the second video segment based on the affine transformation matrix, the method further includes: Determine a target pixel whose RGB value satisfies a preset filling condition in the video frame after affine transformation; A transparent channel is added in the RGB color space of the target pixel, and a preset value is assigned to the transparent channel.
11. The method according to any one of claims 1 to 10, characterized in that The first video segment is located before the second video segment in time sequence; After performing portrait alignment processing on the first video clip and the second video clip based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame, the method further includes: Determine the last video frame of the first video segment after the alignment process and the first video frame of the second video segment after the alignment process; Generate a transition video frame based on the interpolation algorithm, the position coordinates of the first posture key point in the last video frame, and the position coordinates of the second posture key point in the first video frame; The transition video frame is inserted between the last video frame and the first video frame.
12. The method according to any one of claims 1 to 10, characterized in that Before determining the first posture key points of the video frames in the first video clip and the second posture key points of the video frames in the second video clip, the method further includes: Determining, based on the posture key points of the video frames in the portrait video, the posture similarity between the video frames in the portrait video and the portrait action information of the video frames; Cutting the portrait video based on the posture similarity to obtain at least one candidate segment, wherein the portrait similarity between different candidate segments is less than a preset similarity threshold; Based on the portrait action information of the video frames in the candidate segments, the candidate segments are divided into at least one video segment, where the portrait action information of the video frames in different video segments is different; From the at least one video segment, a video segment that is adjacent in time sequence and is earlier in time sequence is selected as the first video segment, and a video segment that is later in time sequence is selected as the second video segment.
13. A video processing device, characterized in that: include: A first determining unit is used to determine a first posture key point of a video frame in a first video segment and a second posture key point of a video frame in a second video segment, wherein the first video segment and the second video segment are video segments with similar portrait postures in a portrait video; a second determining unit, which determines a first reference video frame in the first video segment and a second reference video frame in the second video segment based on a distance between the first posture key point and the second posture key point; An alignment unit is used to perform portrait alignment processing on the first video segment and the second video segment based on the position coordinates of the first posture key point in the first reference video frame and the position coordinates of the second posture key point in the second reference video frame.
14. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video processing method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the video processing method as claimed in any one of claims 1 to 12.
16. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps in the video processing method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Face key point tracking model training and tracking method and system
CN112017212A
Video processing method and device, electronic equipment and readable storage medium
CN113542855A
Human body matting and background changing method and device and computer readable storage medium
CN115423891A
Video frame alignment method and device based on human body key points, equipment and medium
CN116016810A
Video editing method and device and storage medium
CN116634234A
Cited By
Universal action recognition method and device based on semantic feature and structural feature matching, computer equipment and readable storage medium
CN119274237A
