A video transition analysis method and system based on optical flow trajectory

Through the optical flow trajectory analysis method, the sparse optical flow algorithm and the DBSCAN clustering algorithm are used to accurately determine the transition between video frames, which solves the problem of inaccurate video transition judgment in the existing technology and improves the reliability of video review. and robustness.

CN118692011BActive Publication Date: 2024-10-22海看网络科技(山东)股份有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411162399.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-10-22
Estimated Expiration
2044-08-23

AI Technical Summary

Technical Problem

The existing technology makes it difficult to accurately judge video transitions during video review, making it difficult to ensure the integrity and compliance of video content.

Method used

A video transition analysis method based on optical flow trajectories is used to determine whether a transition occurs between video frames by preprocessing video frames, key point detection, sparse optical flow algorithm calculation, DBSCAN clustering and entropy calculation.

Benefits of technology

It improves the accuracy of video transition detection and the reliability of the system, reduces misjudgments, and improves the overall robustness of video review.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118692011B_ABST
    Figure CN118692011B_ABST
Patent Text Reader

Abstract

The present invention discloses a video transition analysis method and system based on optical flow trajectory, which mainly relates to the field of video transition technology. The method includes: by combining an optical flow algorithm, a Shi-Tomasi corner detector and a clustering algorithm (such as DBSCAN), the dynamic changes in the video can be accurately captured, so as to more accurately judge the timing of the video transition. Through stable tracking and clustering analysis of feature points in the video, the present invention can reduce erroneous transition judgments and improve the reliability and robustness of the overall system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video transition, and in particular to a video transition analysis method and system based on optical flow trajectory. Background Art

[0002] Video transitions refer to the process of switching between two video clips. These transition effects not only have a significant impact on the visual effect of the video3, but may also contain specific information conveyed by the video producer. Therefore, in video review, identifying and judging video transitions is an important means to ensure the correctness of video content. Video review is an indispensable link in modern video content production and dissemination. Especially in the fields of content security, copyright protection, and advertising monitoring, video review usually determines whether a video has transitioned and then segments the video. Accurately judging whether a transition has occurred in a video is crucial to ensuring the integrity and compliance of the video content.

[0003] Therefore, there is an urgent need for a video transition analysis method and system based on optical flow trajectories to solve the above problems. Summary of the invention

[0004] The purpose of the present invention is to provide a video transition analysis method and system based on optical flow trajectory, which can reduce erroneous transition judgments and improve the reliability and robustness of the overall system through stable tracking and cluster analysis of feature points in the video.

[0005] In order to achieve the above object, the present invention is implemented through the following technical solutions:

[0006] On the one hand, the present application proposes a video transition analysis method based on optical flow trajectory, comprising the following steps:

[0007] S1: Capture a target video and preprocess the target video, wherein the preprocessing specifically decomposes the video into a frame sequence and performs grayscale processing on each frame;

[0008] S2: Detect key points on the preprocessed target video to obtain the key point coordinates , and the coordinates of all key points form a coordinate set ;

[0009] S3: Use the sparse optical flow algorithm of OpenCV to calculate the flow vectors between adjacent frames obtained in step S1;

[0010] S4: Based on the width and height of the target video frame in step S1, the coordinate set in step S2 is All key points in Axis coordinates and The axis coordinates are normalized to obtain a coordinate set , and keep the coordinates always in Inside;

[0011] S5: Use sklearn's DBSCAN clustering algorithm to cluster the coordinates in step S4 Perform clustering and output as classified subsets;

[0012] S6: Calculate whether each classification subset set vector obtained in step S5 intersects and record the number of intersection points of this set;

[0013] S7: Calculate the entropy of the distribution of each classification set vector obtained in step S5;

[0014] S8: Count all cluster weighted entropies H_total and perform weighted evaluation. If the value exceeds the set threshold, it is determined that a transition has occurred;

[0015] S9: Repeat steps S2-S8 to traverse all adjacent frame sequences in the target video in step S1 to determine whether the target video has a transition.

[0016] Preferably, the step S3 is specifically: using the sparse optical flow algorithm of the third-party library OpenCV to calculate the streamer vector between adjacent frames obtained in step S1, wherein the input is: the first frame image, the second frame image, the coordinates of the key points in the first frame, and the optical flow algorithm parameters, and the output result is: the coordinate position of the first key point in step S2 in the second frame of the target video, that is, .

[0017] Preferably, the neighborhood radius of the DBSCAN clustering algorithm in step S5 is set to 0.05 and the minimum number of samples is 2.

[0018] Preferably, the step S6 specifically includes the following steps:

[0019] S61: Get vector The starting coordinates and end coordinates , take the vector The starting coordinates and end coordinates ;

[0020] S62: Calculate vector Directions , calculate the vector Directions ;

[0021] S63: Calculate vector for arrive The vector of ;

[0022] S64: Calculate vector The product, that is ;

[0023] S65: Calculate vector and vector The product of ;

[0024] S66: Calculate vector and vector The product of ;

[0025] S67: If is equal to 0, then the vector Collinear or parallel;

[0026] S68: If If it is not equal to 0, then you need to judge the vector ,vector Respectively with vector Whether the intersection point of is inside the vector;

[0027] S69: Take , ,if and , then the vector intersect, otherwise they do not intersect;

[0028] S610: Traverse all vectors in the classification subset to determine whether there are intersection points, and count the number of intersection points and record them as .

[0029] Preferably, the step S7 specifically includes the following steps:

[0030] S71: According to the entropy calculation formula , Calculate the angular entropy of each set of classification subsets;

[0031] S72: According to the entropy calculation formula , Calculate the length entropy of each set of classification subsets;

[0032] S73: Calculate the sum of angle entropy and length entropy, that is: = + ;

[0033] S74: Perform weighted calculation on the entropy of each classification subset and the number of intersection points to obtain the weighted entropy H_total= * .

[0034] On the other hand, the present application also proposes a video transition analysis system based on optical flow trajectory, which is used to implement the above-mentioned video transition analysis method based on optical flow trajectory.

[0035] Compared with the prior art, the beneficial effects of the present invention are:

[0036] 1. Using advanced computer vision technology and machine learning algorithms, it can achieve efficient and accurate transition detection in the field of video editing and processing.

[0037] 2. It can accurately capture dynamic changes in the video, so as to more accurately judge the timing of video transitions.

[0038] 3. Reduce erroneous transition judgments and improve the reliability and robustness of the overall system. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 is a flow chart of the method of the present invention;

[0040] Figure 2 (a) and (b) are two frames captured from the first target video of the present invention;

[0041] Figure 3 It is a schematic diagram of the vector set after the sparse streamer algorithm is applied to Figure 2 (a) and (b);

[0042] Figure 4 (a), (b), (c), (d), (e) are Figure 3 Schematic diagram of the vector after clustering algorithm;

[0043] Figure 5 (a) and (b) are two frames captured from the second target video of the present invention;

[0044] Figure 6 It is a schematic diagram of the vector set after the sparse streamer algorithm is applied to Figure 5 (a) and (b);

[0045] Figure 7 (a), (b), (c), (d) are Figure 6 Schematic diagram of the vector after clustering algorithm;

[0046] Figure 8 (a) and (b) are two frames captured from the third target video of the present invention;

[0047] Fig. 9 It is a schematic diagram of the vector set after the sparse streamer algorithm is applied to Figure 8 (a) and (b);

[0048] Figure 10 (a), (b), (c), (d), (e) are Fig. 9 Schematic diagram of the vector after clustering algorithm;

[0049] Figure 11 (a) and (b) are two frames captured from the fourth target video of the present invention;

[0050] Fig.12 It is a schematic diagram of the vector set after the sparse streamer algorithm is applied to Figure 11 (a) and (b);

[0051] Figure 13 (a), (b), (c), (d) are Fig.12 Schematic diagram of the vector after clustering algorithm. DETAILED DESCRIPTION

[0052] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the application equally.

[0053] In the present invention, terms such as "upper", "lower", "left", "right", "front", "back", "vertical", "horizontal", "side", "bottom", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings. They are relational words determined only for the convenience of describing the structural relationships of the various parts or elements of the present invention, and do not specifically refer to any part or element in the present invention and should not be understood as limitations on the present invention.

[0054] In the present invention, terms such as "fixed connection", "connected", "connection", etc. should be understood in a broad sense, indicating that it can be fixedly connected, integrally connected or detachably connected; it can be directly connected or indirectly connected through an intermediate medium. Relevant scientific research or technical personnel in this field can determine the specific meanings of the above terms in the present invention according to specific circumstances, and they should not be understood as limiting the present invention.

[0055] The basic principle of the present invention is that the angle and intensity of the optical flow in the same area of ​​two adjacent frames should be similar. If there is a drastic change in the intensity of the optical flow or an uneven distribution of angles in the same area, it means that a video transition has occurred. For example, the movement of a person's hand in the two frames before and after should be in the same direction and the movement distance (discrete degree) should be the same, and the angle should be similar. If in the same area, the discrete degree of the movement distance is inconsistent, the angle changes dramatically, and the two frames before and after should have undergone a relatively large change, then it is considered that a transition has occurred.

[0056] Because Python provides commonly used general algorithms, the present invention uses Python as a programming language and the third-party library it provides as a tool to illustrate the invention idea. The present invention extracts key points through the Shi-Tomasi corner detector. DBSCAN is selected as the clustering algorithm, and the sparse optical flow algorithm is used. In Python, the third-party library OpenCV provides basic image processing tools (algorithms), such as corner detector (goodFeaturesToTrack), sparse optical flow (calcOpticalFlowPyrLK), and the third-party library sklearn provides the DBSCAN clustering algorithm. The third-party library npmpy is used for vector matrix calculations.

[0057] Embodiment 1:

[0058] In this embodiment, an analysis method for judging video transitions in complex scenes is proposed, such as Figure 1 As shown, the following steps are included:

[0059] S1: Capture a target video and preprocess the target video, wherein the preprocessing specifically decomposes the video into a frame sequence and performs grayscale processing on each frame;

[0060] S2: Detect key points on the preprocessed target video to obtain the key point coordinates , and the coordinates of all key points form a coordinate set ;

[0061] S3: Use the sparse optical flow algorithm of OpenCV to calculate the flow vectors between adjacent frames obtained in step S1;

[0062] S4: Based on the width and height of the target video frame in step S1, the coordinate set in step S2 is All key points in Axis coordinates and The axis coordinates are normalized to obtain a coordinate set , and keep the coordinates always in Inside;

[0063] S5: Use sklearn's DBSCAN clustering algorithm to cluster the coordinates in step S4 Perform clustering and output as classified subsets;

[0064] S6: Calculate whether each classification subset set vector obtained in step S5 intersects and record the number of intersection points of this set;

[0065] S7: Calculate the entropy of the distribution of each classification set vector obtained in step S5;

[0066] S8: Count all cluster weighted entropies H_total and perform weighted evaluation. If the entropy exceeds a set threshold, it is determined that a transition has occurred. The threshold is usually set to 100.

[0067] S9: Repeat steps S2-S8 to traverse all adjacent frame sequences in the target video in step S1 to determine whether the target video has a transition.

[0068] Since the optical flow calculation is usually performed on a grayscale image, the grayscale processing of each frame of the target video is performed in step S1;

[0069] The step S3 is specifically: using the sparse optical flow algorithm of the third-party library OpenCV to calculate the light flow vector between adjacent frames obtained in step S1, wherein the input is: the first frame image, the second frame image, the coordinates of the key points in the first frame, and the optical flow algorithm parameters, and the output result is: the coordinate position of the first key point in step S2 in the second frame of the target video, that is, ;

[0070] The neighborhood radius of the DBSCAN clustering algorithm in step S5 is set to 0.05, and the minimum number of samples is 2.

[0071] The step S6 specifically comprises the following steps:

[0072] S61: Get vector The starting coordinates and end coordinates , take the vector The starting coordinates and end coordinates ;

[0073] S62: Calculate vector Directions , calculate the vector Directions ;

[0074] S63: Calculate vector for arrive The vector of ;

[0075] S64: Calculate vector The product, that is ;

[0076] S65: Calculate vector and vector The product of ;

[0077] S66: Calculate vector and vector The product of ;

[0078] S67: If is equal to 0, then the vector Collinear or parallel;

[0079] S68: If If it is not equal to 0, then you need to judge the vector ,vector Respectively with vector Whether the intersection point of is inside the vector;

[0080] S69: Take , ,if and , then the vector intersect, otherwise they do not intersect;

[0081] S610: Traverse all vectors in the classification subset to determine whether there are intersection points, and count the number of intersection points and record them as .

[0082] The step S7 specifically includes the following steps:

[0083] S71: According to the entropy calculation formula , Calculate the angular entropy of each set of classification subsets;

[0084] S72: According to the entropy calculation formula , Calculate the length entropy of each set of classification subsets;

[0085] S73: Calculate the sum of angle entropy and length entropy, that is: = + ;

[0086] S74: Perform weighted calculation on the entropy of each classification subset and the number of intersection points to obtain the weighted entropy H_total= * .

[0087] The above steps are used to determine whether a video transition occurs in the two frames of the target video shown in Figure 2 (a) and Figure 2 (b). Through the sparse optical flow algorithm, the following can be obtained: Figure 3 The vector set shown is then clustered into the following according to the vector's actual coordinate axes X and Y using a clustering algorithm:

[0088] As shown in Figure 4 (a): the number of intersections is 38 and the entropy is 12.3697;

[0089] As shown in Figure 4 (b): the number of intersections is 0 and the entropy is 6.8178;

[0090] As shown in Figure 4 (c): the number of intersections is 1 and the entropy is 3.9839;

[0091] As shown in Figure 4 (d): the number of intersections is 1 and the entropy is 6.3564;

[0092] As shown in Figure 4 (e): the number of intersections is 0 and the entropy is 0.5668;

[0093] The weighted entropy is calculated as (38×12.6397+0×6.8178+1×3.9869+1×6.3564+0×0.5668) = 490.6519. By comparing it with the threshold of 100, it can be determined that a video transition has occurred.

[0094] The above steps are used to determine whether a video transition occurs in the two frames of the target video shown in Figure 5 (a) and Figure 5 (b). Through the sparse optical flow algorithm, the following can be obtained: Figure 6 The vector set shown is then clustered into the following according to the vector's actual coordinate axes X and Y using a clustering algorithm:

[0095] As shown in Figure 7 (a): the number of intersections is 1 and the entropy is 3.2654;

[0096] As shown in Figure 7(b): the number of intersections is 2 and the entropy is 4.5226;

[0097] As shown in Figure 7 (c): the number of intersections is 0 and the entropy is 0.4236;

[0098] As shown in Figure 7 (d): the number of intersections is 0 and the entropy is 1.2655;

[0099] The weighted entropy is calculated as (1×3.2654+2×4.5226+0×0.4236+0×1.2655) = 12.3106. By comparing the threshold value of 100, it can be determined that no video transition occurs.

[0100] Embodiment 2:

[0101] In this embodiment, an analysis method for judging video transition under the condition of similar colors is proposed. The method steps in Embodiment 1 are used to judge whether video transition occurs for two frames in the target video as shown in FIG8 (a) and FIG8 (b). By using the sparse optical flow algorithm, the following can be obtained: Fig. 9 The vector set shown is then clustered into the following according to the vector's actual coordinate axes X and Y using a clustering algorithm:

[0102] As shown in Figure 10 (a): the number of intersections is 216 and the entropy is 19.5563;

[0103] As shown in Figure 10 (b): the number of intersections is 4 and the entropy is 6.32;

[0104] As shown in Figure 10 (c): the number of intersections is 9 and the entropy is 6.8354;

[0105] As shown in Figure 10 (d): the number of intersections is 0 and the entropy is 5.6423;

[0106] As shown in Figure 10 (e): the number of intersections is 4 and the entropy is 8.6345;

[0107] The weighted entropy is calculated as (216×19.5563+4×6.32+9×6.8354+0×5.6423)=4310.9594. By comparing it with the threshold of 100, it can be determined that a video transition has occurred.

[0108] The steps in Example 1 are used to determine whether a video transition occurs in two frames of the target video as shown in FIG. 11 (a) and FIG. 11 (b). The sparse optical flow algorithm is used to obtain the following: Fig.12 The vector set shown is then clustered into the following according to the vector's actual coordinate axes X and Y using a clustering algorithm:

[0109] As shown in Figure 13 (a): the number of intersections is 0 and the entropy is 0.5563;

[0110] As shown in Figure 13 (b): the number of intersections is 0 and the entropy is 0.9324;

[0111] As shown in Figure 13 (c): the number of intersections is 0 and the entropy is 0.3354;

[0112] As shown in Figure 13 (d): the number of intersections is 0 and the entropy is 0.6423;

[0113] The weighted entropy is calculated as (0×0.5563+0×0.9324+0×0.3354+0×0.6423) = 0. By comparing the threshold value of 100, it can be determined that no video transition occurs.

Claims

1. A video transition analysis method based on optical flow trajectory, It is characterized in that The following steps are involved: S1: Capture a target video and preprocess the target video, wherein the preprocessing specifically decomposes the video into a frame sequence and performs grayscale processing on each frame; S2: Detect key points on the preprocessed target video to obtain the key point coordinates , and the coordinates of all key points form a coordinate set ; S3: Use the sparse optical flow algorithm of OpenCV to calculate the flow vectors between adjacent frames obtained in step S1; S4: Based on the width and height of the target video frame in step S1, the coordinate set in step S2 is All key points in Axis coordinates and The axis coordinates are normalized to obtain a coordinate set , and keep the coordinates always in Inside; S5: Use sklearn's DBSCAN clustering algorithm to cluster the coordinates in step S4 Perform clustering and output as classified subsets; S6: Calculate whether each classification subset set vector obtained in step S5 intersects and record the number of intersection points of this set; S7: Calculate the entropy of the distribution of each classification set vector obtained in step S5; S8: Count all cluster weighted entropies H_total and perform weighted evaluation. If the value exceeds the set threshold, it is determined that a transition has occurred; S9: repeat steps S2-S8, traverse all adjacent frame sequences in the target video in step S1, and determine whether the target video has a transition; The step S6 specifically comprises the following steps: S61: Get vector The starting coordinates and end coordinates , take the vector The starting coordinates and end coordinates ; S62: Calculate vector Directions , calculate the vector Directions ; S63: Calculate vector for arrive The vector of ; S64: Calculate vector The product, that is ; S65: Calculate vector and vector The product of ; S66: Calculate vector and vector The product of ; S67: If is equal to 0, then the vector Collinear or parallel; S68: If If it is not equal to 0, then you need to judge the vector ,vector Respectively with vector Whether the intersection point of is inside the vector; S69: Take , ,if and , then the vector intersect, otherwise they do not intersect; S610: Traverse all vectors in the classification subset to determine whether there are intersection points, and count the number of intersection points and record them as ; The step S7 specifically includes the following steps: S71: According to the entropy calculation formula , Calculate the angular entropy of each set of classification subsets; S72: According to the entropy calculation formula , Calculate the length entropy of each set of classification subsets; S73: Calculate the sum of angle entropy and length entropy, that is: = + ; S74: Perform weighted calculation on the entropy of each classification subset and the number of intersection points to obtain the weighted entropy H_total= * .

2. According to the video transition analysis method based on optical flow trajectory described in claim 1, It is characterized in that The step S3 is specifically: using the sparse optical flow algorithm of the third-party library OpenCV to calculate the light flow vector between adjacent frames obtained in step S1, wherein the input is: the first frame image, the second frame image, the coordinates of the key points in the first frame, and the optical flow algorithm parameters, and the output result is: the coordinate position of the first key point in step S2 in the second frame of the target video, that is, .

3. According to the video transition analysis method based on optical flow trajectory described in claim 1, It is characterized in that The neighborhood radius of the DBSCAN clustering algorithm in step S5 is set to 0.05, and the minimum number of samples is 2.

4. A video transition analysis system based on optical flow trajectory, It is characterized in that Implement any one of the video transition analysis methods based on optical flow trajectories described in claims 1-3 above.

Citation Information

Patent Citations

  • Video structuring method based on multi-dimensional segmentation

    CN110197135A

  • Multi-video-frame black smoke diesel vehicle detection method and system based on space-time optical flow network

    CN113221976A

  • Assembly line action video key frame extraction method based on optical flow estimation and ORB

    CN118470604A

  • Video semantic segmentation method based on active learning

    US20220215662A1

  • Complex scene-based human body key point detection system and method

    WO2019232894A1