Fast video clip matching method

By extracting frames and hash values ​​for video clips, and building strings based on character pools for matching, the problem of slow video clip search speed is solved, fast video clip matching is achieved, and efficiency is improved.

CN119202330AInactive Publication Date: 2024-12-27CHENGDOU HUAQIYUN TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411747621.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, video clip search speed is slow and takes a long time, which cannot meet the rapid demand for opening and ending editing in the radio and television field.

Method used

By extracting frames of the target video clip and the input video clip, the hash value of each frame is calculated, and the string is constructed based on the character pool, and the differential hash algorithm and XOR operation are used to match, improving the efficiency of video clip matching.

Benefits of technology

It greatly reduces the time of video clip matching, improves matching efficiency, and solves the problem of slow video search speed. Compared with the matching method of character-by-character comparison, the matching efficiency of strings is significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202330A_ABST
    Figure CN119202330A_ABST
Patent Text Reader

Abstract

The invention discloses a fast video clip matching method, and belongs to the field of video retrieval. The fast video clip matching method comprises the following steps: respectively performing frame extraction on a target video clip and an input video clip to obtain a plurality of first image frames and a plurality of second image frames; respectively calculating hash values of each first image frame and each second image frame; creating a character pool; constructing a first character string based on the character pool and the hash value of the first image frame; constructing a second character string based on the character pool and the hash value of the second image frame; determining whether the target video clip is matched with the input video clip according to a matching result of the first character string and the second character string; wherein the number of the first image frames is smaller than that of the second image frames, and the number of the characters in the character pool is larger than or equal to that of the first image frames. According to the invention, the video matching speed is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of video retrieval, and in particular relates to a fast video segment matching method. Background Art

[0002] As an important research issue in the field of computer vision, content-based video retrieval has attracted extensive attention from scholars at home and abroad. Content-based video retrieval matches the frame images of the short video to be retrieved to obtain the accurate location in the video library. Performing a series of editing operations on the opening and ending of the video clip to be retrieved, such as adding, deleting, and editing the opening and ending on the basis of finding and locating the opening and ending, is a basic requirement in the field of radio and television. However, the general method of searching for video opening and ending is to compare the video frame by frame, which is slow and time-consuming. Summary of the invention

[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a fast video clip matching method.

[0004] The objective of the present invention is achieved through the following technical solution: a fast video clip matching method, comprising: Extracting frames from the target video segment and the input video segment respectively to obtain a plurality of first image frames and a plurality of second image frames; Calculate hash values ​​of the first image frame and the second image frame for each frame respectively; Create a character pool; constructing a first string based on the character pool and the hash value of the first image frame; constructing a second string based on the character pool and the hash value of the second image frame; Determining whether the target video segment matches the input video segment according to the matching result of the first character string and the second character string; The number of the first image frames is less than the number of the second image frames, and the number of characters in the character pool is greater than or equal to the number of the first image frames.

[0005] Furthermore, when extracting frames from the target video segment and the input video segment, the frames are extracted according to a preset frame extraction interval.

[0006] Furthermore, a differential hash algorithm is used to calculate hash values ​​of the first image frame and the second image frame.

[0007] Furthermore, the characters in the character pool include one or more of uppercase and lowercase letters, numbers, punctuation marks and special symbols; Among them, if the number of characters in the character pool composed of individual characters is less than the number of the first image frames, the individual characters are combined in pairs to form new characters. If the number of characters in the character pool is still less than the number of the first image frames, three individual characters are combined to form new characters, and so on, until the number of characters in the character pool is greater than or equal to the number of the first image frames.

[0008] Further, when the number of different hash values ​​in the hash values ​​of all the second image frames is greater than the number of characters in the character pool, all hash values ​​in the second image frames that cannot be matched to characters in the character pool are matched to a character that is not in the character pool.

[0009] Further, constructing a first character string based on the character pool and the hash value of the first image frame includes: matching a character in the character pool for each hash value of the first image frame, and the characters corresponding to the hash values ​​of all the first image frames constitute the first character string; Constructing a second character string based on the character pool and the hash value of the second image frame, including: matching a character in the character pool for the hash value of each second image frame, so that the characters corresponding to the hash values ​​of all the second image frames constitute the second character string; Among them, the same hash value corresponds to the same character.

[0010] Furthermore, the method for determining whether two hash values ​​are the same includes: performing an XOR operation on the two hash values ​​to obtain a difference value, counting the number of 1s in the difference value, if the number of 1s in the difference value is less than a preset hash threshold, the two hash values ​​are the same, otherwise the two hash values ​​are different.

[0011] Further, matching the first string and the second string includes: Step S610. Align the left ends of the second character string and the first character string to check whether they match. If so, return the matching result. Otherwise, execute step S620. Step S620. Detect whether the next character in the second string appears in the first string. If so, execute step S630. Otherwise, execute step S640 to define the position of the next character in the second string as pos_b1. Step S630. Define the position where the next character in the second string appears in the first string as pos_a1, move the first string so that pos_a1 in the first string is aligned with pos_b1 in the second string, and check whether they match. If they match, return the matching result. If not, execute step S650; Step S640. Move the first string to the next position of the second string and check whether it matches. If it matches, return the matching result. If it does not match, execute step SS650; Step S650: Check whether the second string has been reached. If so, the matching of the first string and the second string ends. Otherwise, execute step S620.

[0012] Further, when the next character in the second character string appears in multiple places in the first character string, the last character position is determined as pos_a1.

[0013] The beneficial effects of the present invention are: (1) The present invention calculates the hash values ​​of the first image frame and the second image frame to establish a mapping relationship between the hash values ​​and the characters in the character pool, converts the hash values ​​into characters, and thus converts the video matching into the string matching, which greatly reduces the time of video segment matching, improves the efficiency of video segment matching, and solves the problem of slow video search speed in the prior art; (2) Compared with the character-by-character matching method, the matching method of the first character string and the second character string in the present invention greatly improves the matching efficiency of the character strings. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A flow chart of the video clip matching method of the present invention; Figure 2 A schematic diagram of the first step of matching a first string with a second string in an example; Figure 3 A schematic diagram of the second step of matching a first string with a second string in an example; Figure 4 A schematic diagram of the third step of matching the first string and the second string in an example; Figure 5 This is a schematic diagram of the fourth step of matching the first string and the second string in an example. DETAILED DESCRIPTION

[0015] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0016] See also Figures 1 to 5 , the present invention provides a fast video clip matching method: like Figure 1 As shown, a fast video segment matching method includes steps S100 to S600.

[0017] Step S100: Frame extraction is performed on the target video segment and the input video segment respectively to obtain a plurality of first image frames and a plurality of second image frames, wherein the number of the first image frames is less than the number of the second image frames.

[0018] For example, the target video segment is subjected to frame extraction, the number of frames extracted is N, and N frames of first image frames are obtained, where N is a natural number greater than 0; the input video segment is subjected to frame extraction, the number of frames extracted is M, and M frames of second image frames are obtained, where M is a natural number greater than N.

[0019] In one embodiment, when extracting frames from the target video segment and the input video segment, the frames are extracted according to a preset frame extraction interval.

[0020] Since the similarity between adjacent frames of a video clip is very high, extracting video frames one by one will cause a large amount of data redundancy. Therefore, we extract a picture every few frames, traverse the entire video clip, and use the video frame library composed of the extracted frames as the video frame library for retrieval. This reduces data redundancy and improves the efficiency of frame matching while ensuring robustness.

[0021] In one embodiment, the frame decimation interval has a value range of [1,6], in seconds. For example, the frame decimation interval has a value of 2 seconds.

[0022] Step S200: Calculate the hash value of each frame of the first image frame and the second image frame respectively.

[0023] For example, the hash value of each first image frame is calculated respectively, and the hash value of the first image frame is stored in the first hash table. The hash value of each second image frame is calculated respectively, and the hash value of the second image frame is stored in the second hash table.

[0024] In one embodiment, a differential hash algorithm is used to calculate the hash values ​​of the first image frame and the second image frame. In other embodiments, other algorithms may also be used to calculate the hash values ​​of the first image frame and the second image frame.

[0025] Specifically, the first image frame or the second image frame is reduced to a size of I*J, where I and J are both natural numbers greater than 2; the reduced first image frame or the second image frame is converted into a grayscale image; the difference in grayscale values ​​of two adjacent pixels is calculated, if the grayscale value of the pixel in the first direction is greater than the grayscale value of the pixel in the second direction, it is recorded as 1, otherwise it is recorded as 0, each value in the difference value sequence is regarded as a bit, every 8 bits form a hexadecimal value, the hexadecimal values ​​are connected and converted into a string, and the hash value of the first image frame or the second image frame is obtained.

[0026] For example, the first image frame or the second image frame is reduced to a size of 9*8, with a total of 72 pixels; the reduced first image frame or the second image frame is converted into a 256-level grayscale image; when calculating the difference value, 8 different differences are generated between 9 pixels in each row, and a total of 8 rows, resulting in 64 difference values; if the grayscale value of the pixel on the left is higher than the grayscale value of the pixel on the right, it is recorded as 1, otherwise it is 0; each value in the difference value sequence is regarded as a bit, and every 8 bits form a hexadecimal value. The hexadecimal values ​​are connected and converted into a string to obtain the hash value of the first image frame or the second image frame.

[0027] Step S300: Create a character pool, the number of characters in the character pool being greater than or equal to the number of the first image frame.

[0028] The characters in the character pool include one or more of uppercase and lowercase letters, numbers, punctuation marks and special symbols. The number of characters in the character pool is K, K is a natural number greater than N, and the characters in the character pool are not repeated. If the number of characters in the character pool composed of individual characters is less than N, the individual characters are combined in pairs to form new characters. If the number of characters in the character pool is still less than N, three individual characters are combined to form new characters, and so on, until the number of characters in the character pool is greater than or equal to N.

[0029] Step S400: Construct a first character string based on the character pool and the hash value of the first image frame.

[0030] Specifically, a character in a character pool is matched for the hash value of each first image frame, and the characters corresponding to the hash values ​​of all first image frames constitute a first character string, wherein the same hash value corresponds to the same character; by matching a character for the hash value of each first image frame, a one-to-one mapping relationship is formed between the hash value of the first image frame and the character in the character pool.

[0031] Step S500: Construct a second character string based on the character pool and the hash value of the second image frame.

[0032] Specifically, a character in a character pool is matched for each hash value of the second image frame, and the characters corresponding to the hash values ​​of all the second image frames constitute a second character string, wherein the same hash value corresponds to the same character. By matching a character for the hash value of each second image frame, a one-to-one mapping relationship is formed between the hash value of the second image frame and the characters in the character pool.

[0033] In one embodiment, when the number of different hash values ​​in the hash values ​​of all the second image frames is greater than the number of characters in the character pool, some of the hash values ​​in the second image frames cannot match the corresponding characters in the character pool. At this time, the corresponding hash value matches a character that is not in the character pool. For example, assuming that the space character is not in the character pool, all hash values ​​that cannot match the corresponding characters in the character pool are matched as the space character. Since K is greater than N, the space character is not in the first character string. Only when M is greater than K can some hash values ​​correspond to the space character.

[0034] In one embodiment, a method for determining whether two hash values ​​are the same includes: performing an XOR operation on the two hash values ​​to obtain a difference value, counting the number of 1s in the difference value, and if the number of 1s in the difference value is less than a preset hash threshold, the two hash values ​​are the same, otherwise the two hash values ​​are different.

[0035] In one embodiment, the hash threshold value ranges from [8, 12]. For example, the hash threshold value is 10.

[0036] Step S600: Determine whether the target video segment matches the input video segment according to the matching result of the first character string and the second character string.

[0037] Specifically, the first character string and the second character string are matched, and if a character string identical to the first character string is detected in the second character string, a video segment matching the target video segment is found in the input video segment.

[0038] In one embodiment, matching the first string and the second string includes steps S610 to S650.

[0039] Step S610: Align the left ends of the second character string and the first character string to check whether they match. If so, return the matching result; otherwise, execute step S620.

[0040] Step S620: Detect whether the next character in the second string appears in the first string. If so, execute step S630; otherwise, execute step S640 to define the position of the next character in the second string as pos_b1.

[0041] Step S630. Define the position where the next character in the second string appears in the first string as pos_a1, move the first string to align pos_a1 in the first string with pos_b1 in the second string, and check whether they match. If so, return the matching result. If not, execute step S650.

[0042] When the next character in the second character string appears in multiple places in the first character string, the last character position is determined as pos_a1.

[0043] Step S640: Move the first character string to the next position of the second character string and check whether it matches. If it matches, return the matching result. If it does not match, execute step SS650.

[0044] Move the first character string to the next position of the second character string, that is, align the left end of the first character string with the character position pos_b1+1 of the second character string.

[0045] Step S650: Check whether the second string has been reached. If so, the matching of the first string and the second string ends. Otherwise, execute step S620.

[0046] For example, the first string is "EXAMPLE" and the second string is "THIS IS A SIMLIE EXAMPLE". Figure 2 As shown, first align the left ends of the first string and the second string. After finding that "T" and "E" do not match, check whether the next character in the second string (the space after "IS" in this example) appears in the first string. If it does, move the first string to align the two. If it does not appear, move the first string directly to the next position. In this example, the space does not appear in the first string, so move the first string to the next position "A" of the space. Figure 3 As shown in the figure, it is found that "A" and "E" do not match, but the next character "E" in the second string appears in the first string, and both the first character and the last character appear. So first move the characters at the end of the first string to align with the second string. Figure 4 As shown in the figure, it is found that the space and "E" do not match, and the next character "space" in the second string does not appear in the first string, so the first string is directly moved to the next character "E" of the space. Figure 5 As shown, the match is successful.

[0047] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A fast video clip matching method, characterized in that: include: Extracting frames from the target video segment and the input video segment respectively to obtain a plurality of first image frames and a plurality of second image frames; Calculate hash values ​​of the first image frame and the second image frame for each frame respectively; Create a character pool; constructing a first string based on the character pool and the hash value of the first image frame; constructing a second string based on the character pool and the hash value of the second image frame; Determining whether the target video segment matches the input video segment according to the matching result of the first character string and the second character string; The number of the first image frames is less than the number of the second image frames, and the number of characters in the character pool is greater than or equal to the number of the first image frames.

2. A fast video clip matching method according to claim 1, characterized in that: When extracting frames from the target video segment and the input video segment, the frames are extracted according to a preset frame extraction interval.

3. A fast video clip matching method according to claim 1, characterized in that: A differential hash algorithm is used to calculate hash values ​​of the first image frame and the second image frame.

4. A fast video clip matching method according to claim 1, characterized in that: The characters in the character pool include one or more of uppercase and lowercase letters, numbers, punctuation marks and special symbols; Among them, if the number of characters in the character pool composed of individual characters is less than the number of the first image frames, the individual characters are combined in pairs to form new characters. If the number of characters in the character pool is still less than the number of the first image frames, three individual characters are combined to form new characters, and so on, until the number of characters in the character pool is greater than or equal to the number of the first image frames.

5. A fast video segment matching method according to claim 4, characterized in that: When the number of different hash values ​​in the hash values ​​of all the second image frames is greater than the number of characters in the character pool, all hash values ​​in the second image frames that cannot be matched to characters in the character pool are matched to a character that is not in the character pool.

6. A fast video clip matching method according to claim 1, characterized in that: Constructing a first character string based on the character pool and the hash value of the first image frame, including: matching a character in the character pool for each hash value of the first image frame, so that the characters corresponding to the hash values ​​of all the first image frames constitute the first character string; Constructing a second character string based on the character pool and the hash value of the second image frame, including: matching a character in the character pool for the hash value of each second image frame, so that the characters corresponding to the hash values ​​of all the second image frames constitute the second character string; Among them, the same hash value corresponds to the same character.

7. A fast video segment matching method according to claim 6, characterized in that: The method for determining whether two hash values ​​are the same includes: performing an XOR operation on the two hash values ​​to obtain a difference value, counting the number of 1s in the difference value, and if the number of 1s in the difference value is less than a preset hash threshold, the two hash values ​​are the same, otherwise the two hash values ​​are different.

8. A fast video segment matching method according to claim 1, characterized in that: Matches the first string and the second string, including: Step S610. Align the left ends of the second character string and the first character string to check whether they match. If so, return the matching result. Otherwise, execute step S620. Step S620. Detect whether the next character in the second string appears in the first string. If so, execute step S630. Otherwise, execute step S640 to define the position of the next character in the second string as pos_b1. Step S630. Define the position where the next character in the second string appears in the first string as pos_a1, move the first string so that pos_a1 in the first string is aligned with pos_b1 in the second string, and check whether they match. If they match, return the matching result. If not, execute step S650; Step S640. Move the first string to the next position of the second string and check whether it matches. If it matches, return the matching result. If it does not match, execute step SS650; Step S650: Check whether the second string has been reached. If so, the matching of the first string and the second string ends. Otherwise, execute step S620.

9. A fast video segment matching method according to claim 8, characterized in that: When the next character in the second character string appears in multiple places in the first character string, the last character position is determined as pos_a1.

Citation Information

Patent Citations

  • Method and device for detecting video frame, and electronic equipment

    CN108924586A

  • Character string matching search method and device and terminal

    CN112069303A

  • Video processing method and device, readable storage medium and program product

    CN113705314A

  • Video content detection method and device, equipment and storage medium

    CN115103223A

  • Data alignment method and system, electronic equipment and readable storage medium

    CN115878862A