Video processing method, device, electronic device and readable storage medium

By combining local optical flow and lightweight neural networks, motion and semantic features of video frames are extracted, solving the problem of low event detection efficiency in videos and achieving efficient event detection on various electronic devices, reducing the waste of storage and computing resources.

CN113286194BActive Publication Date: 2024-10-15BEIJING SAMSUNG TELECOM R&D CENT +1
View PDF 17 Cites 0 Cited by

Patent Information

Application Number
CN202010820606.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-02-20
Filing Date
2020-08-14
Publication Date
2024-10-15
Estimated Expiration
2040-08-14

AI Technical Summary

Technical Problem

Existing video processing methods are inefficient when detecting video segments where events occur, and commonly used electronic devices such as mobile phones are not equipped with event cameras, resulting in redundant information storage and large computational loads, making it difficult to meet the needs of real-time tasks.

Method used

By combining local optical flow and lightweight neural networks, event detection is performed based on the motion probability of frames. Motion features and semantic features in the video are extracted, fused, and weighted to improve detection accuracy.

Benefits of technology

It effectively detects video segments where events are occurring, reducing storage space and computational load. It is suitable for various electronic devices, including mobile phones, tablets, and servers, meeting the needs of real-time video processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113286194B_ABST
    Figure CN113286194B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a video processing method, device, electronic device and readable storage medium, which belong to the field of computer and artificial intelligence technology. The method includes: obtaining optical flow information of at least one frame of image in the video to be processed; extracting motion features of the at least one frame of image based on the at least one frame of image and the optical flow information of the at least one frame of image; determining the video segment where an event occurs in the video to be processed based on the motion features of the at least one frame of image; and performing corresponding processing on the video to be processed according to the video segment where the event occurs. Based on the method provided by the embodiments of the present application, it is possible to perform event detection on the video captured by an ordinary camera, that is, based on the concept of frames, to realize the detection of video segments where events occur in the video, so as to better meet the needs of event detection in the video in various actual application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and artificial intelligence technology. Specifically, the present application relates to a video processing method, device, electronic device and readable storage medium. Background Art

[0002] Event cameras record video information through event triggers, which can effectively reduce the storage of redundant information and facilitate the viewing of events. However, the cameras used for video acquisition in currently commonly used electronic devices (such as mobile phones, etc.) are not used for long-term monitoring, and due to various factors, the possibility of these commonly used electronic devices being equipped with event cameras in the short term is also low. In order to achieve functions similar to event cameras, in order to meet the requirements of reducing storage volume and reducing the amount of computation required for subsequent video analysis and interpretation, it is necessary to perform event detection on the image information collected by ordinary video acquisition cameras. Although there are already ways to detect events in videos, the detection effect still needs to be optimized. Summary of the invention

[0003] The purpose of the embodiment of the present application is to provide a solution. The solution provided by the embodiment of the present application is as follows:

[0004] In a first aspect, an embodiment of the present application provides a video processing method, the method comprising:

[0005] Obtaining optical flow information of at least one frame of image in the video to be processed;

[0006] Extracting motion features of at least one frame of image based on at least one frame of image and optical flow information of at least one frame of image;

[0007] Determining, based on motion features of at least one frame of image, a video segment in which an event occurs in the video to be processed;

[0008] According to the video clips where the events occur, the video to be processed is processed accordingly.

[0009] In a second aspect, an embodiment of the present application provides a video processing device, the device comprising:

[0010] An optical flow information acquisition module, used to acquire optical flow information of at least one frame of image in the video to be processed;

[0011] A motion feature extraction module, used to extract motion features of at least one frame of image based on at least one frame of image and optical flow information of at least one frame of image;

[0012] An event segment determination module, used for determining a video segment in which an event occurs in the video to be processed based on motion features of at least one frame of image;

[0013] The video processing module is used to process the video to be processed accordingly according to the video clip where the event occurs.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor; wherein a computer program is stored in the memory; and the processor is used to execute the method provided in the embodiment of the present application when running the computer program.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run by a processor, the method provided by the embodiment of the present application is executed.

[0016] The beneficial effects brought about by the technical solution provided in the embodiments of the present application will be described in detail in conjunction with various optional embodiments in the description of the specific implementation method section below and will not be explained again here. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0018] Figure 1 A schematic diagram of a process flow of a video processing method provided by an embodiment of the present application is shown;

[0019] Figure 2 A schematic diagram of the structure of a neural network for extracting image motion features provided in an optional embodiment of the present application is shown;

[0020] Figure 3 A schematic diagram of the fusion features of motion features and semantic features in an example of the present application;

[0021] Figure 4 A schematic diagram of the structure of a weight determination network provided in an optional embodiment of the present application;

[0022] Figure 5 This is a schematic diagram of weighted processing of fusion features through a weight determination network in an example of the present application;

[0023] Figure 6 A schematic diagram of a global pooling structure in an example of the present application;

[0024] Figure 7 A schematic diagram of the principle of video key frame selection in an example of the present application;

[0025] Figure 8 A schematic diagram of a flow chart of an existing method for motion compensation of an image is shown;

[0026] Fig. 9A schematic diagram of a flow chart of a motion compensation method provided in an embodiment of the present application is shown;

[0027] Fig.10 A schematic diagram showing matching pixel points of two frames of images in an example is shown;

[0028] Fig.11 A schematic diagram showing the effect of performing motion compensation processing on an image in an example of the present application is shown;

[0029] Fig.12a and Figure 12b Two schematic diagrams of the process of determining the optical flow information of an image provided by the present application are shown;

[0030] Fig.12c A schematic diagram showing the principle of determining image optical flow information in an example of the present application is shown;

[0031] Fig.13 A schematic diagram of a process for determining an image score based on optical flow information in an example of the present application is shown;

[0032] Fig.14a A schematic diagram of probability distribution of a single distribution Gaussian background model is shown;

[0033] Fig.14b A schematic diagram of probability distribution of a double-single distribution Gaussian background model is shown;

[0034] Fig.15 A schematic diagram showing a process of performing foreground image area detection based on a dual-single distribution Gaussian background model in an example of the present application;

[0035] Fig.16 A schematic diagram showing a mask image of an image in an example of the present application;

[0036] Fig.17 A schematic diagram showing the principle of obtaining an image score through a neural network model in an example of the present application is shown;

[0037] Fig.18a and Fig.18b A schematic diagram showing the principle of determining the motion state representation information of an image in an example of the present application is shown;

[0038] Fig.19 A schematic diagram of a pyramid score interval in an example of the present application is shown;

[0039] Fig.20a A schematic diagram of a pyramid score interval in an example of the present application is shown;

[0040] Fig.20b and Fig.20c Shown according to Fig.20aSchematic diagram of the principle of determining the interval of the video segment where the event occurs by the pyramid score interval in the video segment;

[0041] Fig.21a A schematic diagram showing the principle of detecting a video clip where an event occurs based on image scores in an example of the present application is shown;

[0042] Figure 21b A schematic diagram showing the principle of detecting a video clip where an event occurs based on image scores in another example of the present application is shown;

[0043] Fig.22a A schematic diagram showing an application scenario in an example of the present application is shown;

[0044] Figure 22b Shows Fig.22a A schematic diagram of the pyramid score interval corresponding to the video of the application scenario;

[0045] Fig.22c and 22d Shows the determination Figure 22b Schematic diagram of the principle of intervals where events occur in the second level of the pyramid score intervals;

[0046] Fig.23 A schematic diagram showing a flow chart of a video processing method in an example of the present application is shown;

[0047] Fig.24 A schematic diagram showing the principle of a video processing method in an example of the present application is shown;

[0048] Fig.25a A schematic diagram showing a flow chart of a video processing method in an example of the present application is shown;

[0049] Fig.25b A schematic diagram showing the principle of a video processing method in an example of the present application is shown;

[0050] Fig.26 A schematic diagram of the structure of a video processing device provided in an embodiment of the present application is shown;

[0051] Fig. 27 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] The embodiments of the present application are described in detail below. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application to help a comprehensive understanding of the embodiments of the present application defined by the claims and their equivalents, including various specific details to help understanding, but these examples and details are only considered to be exemplary and cannot be interpreted as limitations on the present application. Therefore, those of ordinary skill in the art will recognize that the described embodiments may be changed and modified without departing from the scope and spirit of the present application. In addition, for the sake of clarity and brevity, some descriptions of well-known functions and structures may be omitted in the following description.

[0053] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0054] In order to better illustrate and understand the solutions provided by the embodiments of the present application, the technologies related to the embodiments of the present application are first described below.

[0055] The event camera is a bio-inspired sensor, a neuromorphic visual sensor, also known as a dynamic visual sensor, which records and uploads video information through event triggers, thereby reducing the storage of redundant information and facilitating the viewing of events. Unlike traditional cameras, neuromorphic visual sensors do not have the concept of "frames". They capture dynamic changes in the scene in an event-driven manner. The sensor measures the intensity change at each pixel (if there is no object movement in the scene, there is no trigger event). The event stream encodes motion information through precise pixel-by-pixel intensity changes. When changes occur in the real scene, the neuromorphic visual sensor will generate some event outputs. Neuromorphic visual sensors have very small requirements for data storage and computing resources, and have very low latency (high-speed photography), which can reach microseconds.

[0056] Traditional camera video acquisition generates a series of images at a fixed frequency. The key problem is that there is a lot of redundant information between two adjacent frames, especially when the camera and the scene are stationary or change little, many frames or even all frames in the video are basically unchanged, resulting in too much redundancy in the entire video. Video information can be expressed with one or a few frames of images, and traditional cameras have excessive requirements for memory, energy loss and latency, which directly leads to very low real-time performance of many algorithms. Take deep learning as an example. In order to achieve environmental perception tasks such as target detection, expensive hardware (GPUs) platforms have to be used to provide computing power.

[0057] Currently, commonly used electronic devices with video shooting functions (such as mobile phones, tablets, etc.) are not equipped with event cameras. This is because installing new sensors requires consideration of multiple aspects such as appearance design, power consumption, cost, and application. In addition, commonly used electronic devices are not used for long-term monitoring. The output of event cameras is an event stream rather than a visual image frame. Therefore, the possibility of commonly used electronic devices being equipped with event cameras in the short term is relatively low.

[0058] In order to better meet the needs of practical applications, such as saving storage space, reducing the storage of redundant information, and reducing the amount of data for subsequent video analysis and interpretation, event detection is still required for the image information collected by the camera in many scenarios. At present, with the rapid development of hardware and software of electronic devices, some tasks in the field of computer vision that can be done by event cameras can also be achieved through ordinary sensors (i.e., ordinary camera sensors commonly used at present, such as cameras on smartphones, etc.), and even the algorithms applied to image frames are more mature. However, the inventors of this application have found through research that there are at least the following areas that need to be improved in the existing video processing methods:

[0059] (1) During the video recording process, the terminal device will record a lot of redundant invalid information, which not only increases the storage burden, but also adds a lot of invalid data and interference information for subsequent video analysis.

[0060] (2) Most of the current deep learning-based methods are designed for action recognition, which are usually based on the spatial and temporal features of the video. They often require high-level semantic features to classify the action, which results in a very large network design and requires a large amount of labeled data. Such a network structure is not suitable for real-time tasks on mobile terminals. In addition, some existing neural networks are not ideal for longer videos when detecting the motion state of images in the video. Therefore, there are also some restrictions on the length of the video to be processed.

[0061] (3) Many traditional motion detection methods are targeted at still cameras and are not suitable for motion cameras, and usually have low detection efficiency.

[0062] (4) When event detection relies solely on optical flow scores, it is difficult to select the threshold for determining whether an event exists, and the calculation speed of dense optical flow is slow.

[0063] (5) Many methods for action positioning and motion detection use the sliding window method. However, the existing method can only detect one event in a given time period. In reality, the event may occur in multiple segments or no event may occur. In order to use the sliding window to detect events of different lengths, the window size needs to be adjusted continuously, and a weight needs to be set to control the size. This threshold is difficult to match all videos. In addition, some methods will increase a lot of redundant calculations when using the sliding window, and ultimately need to use maximum value suppression to complete the extraction of the final result. The effect is not ideal.

[0064] In order to solve at least one of the above-mentioned technical problems existing in the prior art, the embodiments of the present application provide a video processing method, device, electronic device and readable storage medium capable of realizing event detection in a video. Based on this method, it is possible to well detect video clips in which events occur in the video, that is, video clips in which objects move and scene changes occur in the scene corresponding to the video.

[0065] The purpose of the present application is to provide an event search (event detection) system to capture meaningful short videos, which can be applied to mobile phones or other electronic devices. In an optional embodiment of the present application, local optical flow and lightweight neural networks are combined to score the motion probability of frames in the video, that is, the score of the frame represents the possibility of an event occurring in the image (that is, the motion probability), and explains the meaning of the frame, so that the motion probability of the frame can be used to select the segment in the video where the event exists.

[0066] The method of the present application is applicable to any scenario where it is necessary to detect video clips with scene changes in the video. For example, for the acquired video (which can be a video stored in the device, a video acquired by other means, or a video collected in real time), the video clips where the event occurs can be detected based on the method provided in the embodiment of the present application. Based on the detection result, only the video clips where the event occurs can be stored to save storage space; for another example, when other analysis of the video is required, since the video clip where the event occurs is a clip of the main content contained in the video, only the video clip where the event is detected to have occurred can be analyzed accordingly, thereby effectively reducing the subsequent data processing amount; for another example, in the application scenario of video transmission, the method provided in the embodiment of the present application can first be used to perform corresponding detection on the video to be transmitted, and the video clip where the event is detected to have occurred can be transmitted, thereby effectively reducing the amount of data to be transmitted and ensuring the main content of the transmitted video.

[0067] In addition, the video processing method provided in the embodiment of the present application can be used in any electronic device, such as smart phones, tablet computers and other hardware products with video recording functions. Of course, it can also be used in devices that do not have video recording functions, as long as the device has the corresponding data processing capabilities. For example, the method can also be applied to servers (including but not limited to physical servers and cloud servers). The server can perform corresponding processing on the acquired video based on the method provided in the embodiment of the present application, and only save the video clips in which events occur in the video, or send the detected video clips with events to other devices.

[0068] In order to make the purpose, technical solutions and advantages of the present application clearer, the following will be combined with specific embodiments and drawings to describe in detail how the various optional implementation methods of the present application and the technical solutions of the embodiments of the present application solve the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the drawings.

[0069] Figure 1 The flowchart of a video processing method provided by an embodiment of the present application is shown. As can be seen from the foregoing description, the method can be executed by any electronic device, such as a user's terminal device (such as a user's mobile phone, tablet computer, etc.) or a server. Figure 1 As shown in , the method may include the following steps:

[0070] Step S110: Obtaining optical flow information of at least one frame of the video to be processed;

[0071] Step S120: extracting motion features of the at least one frame of image based on the at least one frame of image and the optical flow information of the at least one frame of image;

[0072] Step S130: determining a video segment in which an event occurs in the video to be processed based on the motion features of the at least one frame of image;

[0073] Step S140: performing corresponding processing on the video to be processed according to the video segment where the event occurs.

[0074] The source of the video to be processed is not limited in the embodiment of the present application, such as a video collected in real time by a video acquisition device, a video received from other devices, a video downloaded from the Internet, a video stored in an electronic device, a video to be transmitted, etc. The video to be processed can be a complete video or a video segment in a video. For example, when processing a video that is being collected in real time by an electronic device, the video to be processed can be a video segment collected at each set time interval, such as a video segment collected every 10 seconds as a video to be processed.

[0075] In the embodiment of the present application, the video segment where an event occurs refers to the segment corresponding to each frame image in which scene information changes in the video. For each frame image in the video, the greater the change in the motion state of the image, that is, the more the scene information changes (image content changes) in the image, the greater the probability that an event occurs in the image. Therefore, the video segment where an event occurs in the video can be determined based on the motion characteristics of at least one frame image of the video.

[0076] As another optional scheme of the present application, when determining whether there is a video clip where an event occurs in the video to be processed, it can be determined based on at least one of the brightness information and optical flow information of the video to be processed to determine whether there is a video clip where an event occurs in the video to be processed. The brightness information of the image (usually in grayscale) reflects the brightness change of the pixels in the image, and the change in brightness can reflect whether the scene in the image has changed, that is, whether there is motion. Therefore, the brightness information of the image can be used to determine whether there is a video clip where an event occurs in the video to be processed. The optical flow is the instantaneous speed of the pixel movement of a spatial moving object on the observation imaging plane. The optical flow method uses the change of pixels in the time domain in the image sequence and the correlation between adjacent frames to find the corresponding relationship between the previous frame and the current frame. Therefore, the motion information of the object between adjacent frames can be calculated based on the optical flow information, and the motion information between adjacent frames of the image can effectively reflect the relative information change between adjacent frames. Therefore, the video clip where the event occurs in the video to be processed can be determined based on the optical flow information of the image.

[0077] Therefore, for a frame of image, the video segment where the event occurs in the video to be processed can be determined based on one or more of the brightness information of the frame of image and the optical flow information of the image. In practical applications, these pieces of information can be used alone or in combination.

[0078] The motion feature represents the change information of the pixels in the image, and the greater the change, the larger the motion feature value is. In an optional solution of the present application, when extracting the motion feature of the image, the image and the optical flow information of the image are integrated.

[0079] Optical flow is widely used to characterize motion information. Since events correspond to the motion caused by a moving target or a moving video acquisition device, optical flow is a very important feature in event detection. However, optical flow information only characterizes motion information. If only optical flow information is considered without considering the semantic information of the image, the reliability of motion information will decrease, and some exciting moments with smaller movements in the video will usually not be selected, such as the moment of shooting and scoring. Therefore, in order to improve the detection accuracy, in an embodiment of the present application, the image motion features are extracted by fusing the image information and the optical flow information of the image, so that the two types of information can better interact with each other.

[0080] After detecting a video segment where an event occurs in the video based on the motion features of at least one frame of image, the video to be processed can be processed accordingly according to the video segment where the event occurs, wherein the processing includes but is not limited to processing the video segment where the event occurs in the video to be processed and / or processing video segments other than the video segment where the event occurs. Optionally, processing the video segment where the event occurs in the video to be processed and / or processing video segments other than the video segment where the event occurs can include at least one of the following:

[0081] Store video footage of the incident;

[0082] Send video footage of the incident;

[0083] Using different video effects to play the video clips where events occur and the video clips other than the video clips where events occur;

[0084] Delete the video segments except the video segment where the event occurs in the video to be processed.

[0085] The video processing method provided in the embodiment of the present application can perform event detection on videos acquired by ordinary cameras, that is, based on the concept of frames, it can realize the detection of video clips in which events occur in the video, thereby better meeting the needs of event detection in videos in various actual application scenarios.

[0086] Optionally, in actual applications, since the video formats stored and played in electronic devices (such as mobile phones) are usually relatively fixed, ordinary cameras cannot record only the corresponding changed pixels like event cameras. In addition, considering the smoothness of video playback, the minimum unit of event detection should not be an image frame. Therefore, for terminal devices such as mobile phones, the event detection unit can be a time period. After detecting the video clip where the event occurred, only the image stream within the time period where the event occurred during the video recording process can be stored.

[0087] In addition, considering the data processing capability of the electronic device, the video length to be processed once can be configured according to the actual data processing capability of the electronic device. For example, for mobile terminals such as mobile phones, due to the limitation of factors such as memory, a relatively short video length can be set. If the video to be processed is long, the video to be processed can be divided into multiple video segments to be processed according to the length, and each video segment to be processed is processed separately, such as performing a time detection every 10 seconds. If the length of the video to be processed is not greater than 10 seconds, the video can be directly processed. If it is greater than 10 seconds, the video to be processed can be divided into multiple video segments not exceeding 10 seconds according to the length of 10 seconds; and for terminal devices with strong data processing capabilities such as personal computers and servers, the above video length can be not configured, or it can be configured as a relatively long video length, such as 30 seconds. Based on the above processing method, flexible processing of videos can be achieved according to actual needs under the premise of considering the actual data processing capabilities of various electronic devices.

[0088] In an optional embodiment of the present application, for any frame image of at least one frame image, extracting a motion feature of the frame image based on the frame image and the optical flow information of the frame image includes:

[0089] Based on the frame image, extracting semantic features of at least one level of the frame image via a plurality of cascaded first feature extraction layers;

[0090] Based on the optical flow information of the frame image, extracting at least one level of motion features of the frame image through a plurality of cascaded second feature extraction layers;

[0091] Among them, at least one second feature extraction layer fuses the motion features and semantic features of the corresponding level and outputs them.

[0092] The specific structure of the first feature extraction layer and the second feature extraction layer is not limited in the embodiment of the present application, and may include but is not limited to a convolutional network, etc. It should be noted that in practical applications, among the above-mentioned first feature extraction layers and second feature extraction layers, the number of feature extraction layers may also be one, or optionally, a plurality of layers are usually cascaded, so as to extract motion features with better feature expression capabilities and improve the accuracy of subsequent detection.

[0093] Optionally, when extracting motion features of at least one frame of the video to be processed, semantic features of at least one level of the image can be extracted by at least one feature extraction layer, and the extracted semantic features can be fused with the optical flow information of the image (or the optical flow features extracted based on the optical flow information), and the motion features of the image can be obtained based on the fusion result. As an optional method, for any frame of the at least one frame of the video to be processed, semantic features of multiple levels of the image can be extracted based on the image through several cascaded first feature extraction layers, and motion features of multiple levels of the image can be extracted based on the optical flow information through several cascaded second feature extraction layers, wherein the semantic features and motion features of corresponding levels can be fused with each other, and the fused features are input into the second feature extraction layer or the final motion features of the image are obtained based on the fused features, that is, the input of each second feature extraction layer except the first second feature extraction layer can include optical flow features and semantic features, wherein the input of the first second feature extraction layer can be optical flow information or optical flow information and image. Based on this optional solution, the two can be combined during the feature extraction process to better enable the two types of information to interact with each other, so as to obtain motion features with richer semantic information and stronger feature expression capabilities, providing a basis for subsequent more accurate and reliable event detection based on the motion features. Among them, the final motion features of the image can be obtained based on the motion features output by the last second feature extraction layer, such as using the output features of the last second feature extraction layer as the final motion features, or extracting features again based on the output features of the last second feature extraction layer, or obtaining the final motion features based on the semantic features of the last level and the motion features of the last level.

[0094] In an embodiment of the present application, the network for extracting motion features of an image may be referred to as a motion feature network (MFN), wherein the network includes the above two feature extraction branches, one branch being the above several first feature extraction layers of the cascade for extracting semantic features (Sematic feature), which branch may be referred to as a semantic feature extraction network, and the other branch being the above several second feature extraction layers of the cascade for extracting motion features (Motion feature), which branch may be referred to as a motion feature extraction network. Therefore, the MFN may also be referred to as a TMFN (two branch motion feature extraction network).

[0095] Optionally, the input of the semantic feature extraction network is an image, and the input of the motion feature extraction network includes optical flow information of the image.

[0096] In an optional embodiment of the present application, the number of output channels of the first feature extraction layer is less than the number of output channels of the second feature extraction layer of the corresponding level.

[0097] For at least one frame of the video, the generation of the motion features of the image, the optical flow information is relatively more important than the semantic features, and the semantic features of the image extracted by the first feature extraction layer are used to assist the second feature extraction layer to better extract the motion features of the image. Therefore, the network structure of the semantic feature extraction network can be relatively lighter, and the number of output channels of the first feature extraction layer of the corresponding level can be less than the number of output channels of the second feature extraction layer. Based on this optional solution, the complexity of the neural network can be reduced, making the structure of the neural network more lightweight, and the solution provided by the present application can be better deployed on a mobile terminal device.

[0098] In an optional embodiment of the present application, at least one second feature extraction layer fuses motion features and semantic features of corresponding levels and outputs them, which may include:

[0099] At least one second feature extraction layer fuses the motion features and semantic features of the corresponding level to obtain a fused feature;

[0100] Determine the weight information corresponding to the fusion feature through the weight determination network;

[0101] According to the weight information, the fused features are weighted to obtain weighted fused features; and the weighted fused features are output.

[0102] Since the importance of semantic features and motion features is different when determining the video clips where events occur in the video, even for the same feature, the importance of features in different channels in the feature is usually different. Therefore, after the motion features and semantic features are fused, such as after the motion features and semantic features are spliced, the weight information corresponding to the fused features can be determined through the weight determination network, and the fused features can be weighted according to the weight information to obtain the weighted fused features, so as to achieve adaptive adjustment of the features, so that more important features are given greater weights and play a greater role. Among them, the specific network structure form of the weight determination network is not limited in the embodiments of the present application.

[0103] In an optional embodiment of the present application, the weight information may include first weight information of motion features and second weight information of semantic features;

[0104] Correspondingly, the above-mentioned fusion features are weighted according to the weight information to obtain weighted fusion features, including:

[0105] The fused features are weighted according to the first weight information and the second weight information to obtain weighted fused features.

[0106] Among them, for semantic features and / or motion features, the feature weights of each channel of each feature can be the same or different, that is, the feature maps of each channel of the semantic feature / motion feature can correspond to the same weight, or the feature maps of each channel can correspond to their respective corresponding weights.

[0107] As an optional method, the weight determination network can use SENet (Squeeze and excitation network), which can assign corresponding weights to each channel according to the number of channels of the feature, and weight the features according to the weights to obtain weighted features.

[0108] In an optional embodiment of the present application, the method may further include:

[0109] Based on the optical flow information of at least one frame of image, obtaining a global optical flow feature of at least one frame of image;

[0110] The extracted motion features of at least one frame of image and the global optical flow features are fused, and the motion features of at least one frame of image are obtained based on the fused features.

[0111] That is to say, for any frame image in at least one frame of images, the motion features of the image can be obtained by fusing the motion features of the image and the global optical flow features, wherein the motion features of the image obtained based on the fused features can be obtained by using the fused features as the motion features of the image, or by performing feature extraction again based on the fused features and using the extracted features as the motion features of the frame image.

[0112] Combining the motion features of the image with the global optical flow features of the image can obtain the final motion features of the enhanced image. By adding the global optical flow features, the distance between the motion features of the frames with motion and the frames without motion can be increased. The larger motion feature distance represents a significant difference in the possibility of motion, and the possibility of motion reflects the possibility of an event occurring in the image. Therefore, the global optical flow features are very helpful for event detection and can improve the accuracy of detection.

[0113] Optionally, for any frame image of the at least one frame image, obtaining a global optical flow feature of the frame image based on the optical flow information of the frame image may include:

[0114] Based on the optical flow information of the frame image, the global optical flow features of the frame image are obtained through the pooling layer.

[0115] The specific pooling structure adopted by the pooling layer is not limited in the present application embodiment, for example, a global pooling structure may be adopted. Optionally, if the optical flow information of the image is based on the moving area of ​​the image and the optical flow information of the frame image obtained from the next frame image of the image (an optional solution described later), the pooling in the solution may refer to pooling the optical flow information of the moving area of ​​the image.

[0116] In an optional embodiment of the present application, the method may further include:

[0117] Sorting optical flow information of at least one frame of the video to be processed, and determining motion state representation information of the at least one frame of the image based on the sorted optical flow values ​​located in a set confidence interval;

[0118] Based on the motion state representation information of at least one frame of image, a video segment in which an event occurs in the video to be processed is determined.

[0119] That is to say, the video clips where events occur can be detected directly based on the optical flow information of the image, and this solution can be applied to application scenarios with high real-time requirements. Among them, in this optional solution, the optical flow information of the image can be the optical flow of the entire image. Since in this optional solution, the optical flow (specifically, the average value of the optical flow in the confidence interval can be used) is the only judgment criterion, in order to ensure that large action clips can be detected and possible noise interference can be removed, the optical flow can be sorted, such as taking the average value of the optical flow calculation of 60% to 95% of the confidence interval.

[0120] In order to better understand and illustrate the various optional implementation modes provided in the present application, the motion feature network and its principles provided in the present application are further described in detail below in conjunction with a specific optional embodiment.

[0121] As an optional implementation, Figure 2 A structural schematic diagram of a motion feature network, i.e., MFN, provided in an embodiment of the present application is shown in the figure. As shown in the figure, the MFN includes three branches, the upper branch is a semantic feature extraction network, the middle branch is a motion feature extraction network, and the lower branch is a global optical flow feature extraction network. In this example, the weight determination network adopts an SE network. The numbers in the figure are the number of output channels of the feature extraction layer of the network, that is, the number of output feature maps. As can be seen from the figure, in this example, the number of output channels of the semantic feature extraction layer (i.e., the first feature extraction layer) of the corresponding level is less than the number of output channels of the motion feature extraction layer (i.e., the second feature extraction layer). Taking the feature extraction layer of the first level as an example, the number of output channels of the semantic feature extraction layer is 16, and the number of output channels of the motion feature extraction layer is 32.

[0122] For a frame of image, the MFN fuses the grayscale image and optical flow information of the frame to obtain the motion features of the image. Among them, for the extraction of semantic features, the grayscale image is input into the semantic feature extraction network, and the semantic features of each level are extracted through each cascaded feature extraction layer (the feature extraction layer in this example includes convolution and pooling structures). Optionally, low-level semantic features (shallow features shown in the figure) express more of the spatial information of the image, and the size (i.e., the size of the feature map) is relatively large, and the number of channels of the corresponding feature extraction layer can be relatively small. High-level semantic features (deep features shown in the figure) better express the deep semantic information of the image, and the size is relatively small. The corresponding number of output channels can be relatively large, so as to obtain semantic information of images in more dimensions. Figure 2 As shown in , in this example, the number of output channels of each cascaded feature extraction layer increases successively.

[0123] For the extraction of motion features, the optical flow information of the image (optical flow image) is input into the motion feature extraction network, and the motion features of several levels of the image are extracted in sequence through several cascaded feature extraction layers of the network. Similarly, the shallow motion features are extracted first, and then the deep motion features are further extracted based on the shallow motion features.

[0124] In order to make the image features (i.e., semantic information / image information) and optical flow features (i.e., motion information) interact better, these two features are spliced ​​in the process of motion feature extraction. Optical flow features are relatively more important for the generation of motion features. Grayscale images are used as auxiliary information to enhance the expressive power of the extracted motion features (therefore, the semantic feature extraction network can be relatively simplified), making the obtained motion features more reliable.

[0125] like Figure 2 As shown in , after the first feature extraction layer of the motion feature extraction network obtains the motion features of the first level based on the optical flow information, the motion features and the semantic features of the first level can be spliced. The spliced ​​features (i.e., the fusion features mentioned above) are estimated through the SE network to obtain the importance of the features of each channel, i.e., the weight information. After weighting according to the weight information, the weighted spliced ​​features are input to the next feature extraction layer, and the feature extraction layer obtains the motion features of this level based on the weighted spliced ​​features. Similarly, the motion features of this level and the semantic features of the corresponding level are spliced ​​and input to the SE network. The weighted spliced ​​features output by the SE network are input to the next feature extraction layer.

[0126] For the global optical flow feature extraction network (global pooling of motion areas shown in the figure), the network in this example uses a global pooling structure. The optical flow information of the image is extracted through the network and then the global optical flow feature is output. The global optical flow feature is fused with the weighted splicing feature output by the last SE network (the fusion is performed by addition in this example). The fused feature is again extracted through the feature extraction layer to obtain the final motion feature of the image.

[0127] It is understandable that when features are fused, the scales of the features to be fused (ie, feature maps) should be consistent, that is, the sizes of the feature maps should be consistent. If they are different, a scale transformation can be performed first.

[0128] Figure 2In the MFN shown in , in the process of extracting motion features from an image, semantic features and motion features at different levels are spliced. Features at different levels have different information. For example, low-level features contain more spatial distribution information, and high-level features contain more semantic information. Splicing two types of features at different levels can better enable the two types of information to interact with each other. As an example, Figure 3 FIG. 1 shows a schematic diagram of fusing the semantic features and motion features of an image in a video of a basketball application scenario. At the moment of scoring a basketball shot, the hot spot in the semantic feature (the circle in the figure) is caused by the basket, and the hot spot in the motion feature is caused by the movement of the basketball. The two features influence each other in the spatial dimension. After the two features are spliced ​​together and feature extraction is performed again, the semantic feature can enhance the motion feature of the next level.

[0129] As an alternative, Figure 4 A schematic diagram of the structure of a SE network provided in an embodiment of the present application is shown in FIG. Figure 4 As shown in the figure, the input of the SE network (SE Net) is the concatenated features of motion features (features shown by horizontal filling in the figure) and semantic features (features shown by diagonal filling in the figure). After the concatenated features are input into the SE network, they are processed by the cascaded global pooling layer, fully connected layer, linear rectification function layer (Relu layer), fully connected layer, and Sigmoid activation function layer to obtain the weights of the feature maps of each channel in the concatenated features. After that, the feature maps of the corresponding channels are weighted based on the weights of the feature maps of each channel (the weight scale transformation shown in the figure is Scale) to obtain the weighted concatenated features.

[0130] Among them, for the semantic features and motion features in the spliced ​​features, the feature maps of each channel of each feature can correspond to the same weight, that is, the feature maps of each channel of the semantic features correspond to one weight, and the feature maps of each channel of the motion features correspond to one weight. It can also be that the feature maps of each channel in the spliced ​​features correspond to their own weights. In some extreme cases, if the weight of the feature map of a channel is 0, it means that the feature map of the channel is ineffective for the extraction of the final motion features of the image. For different application scenarios, the importance of semantic features and motion features for event detection is different, and the importance of the features of each channel of the same feature is also likely to be different. Even in the same application scenario, the importance of semantic features and motion features (or the features of each channel of the same feature) at different times is different. The weight determination network is used to achieve adaptive adjustment of semantic features and motion features.

[0131] As an example, Figure 5FIG. 4 shows a schematic diagram of the effect of weighting the splicing features of the motion features and semantic features of an image of an application scene of playing basketball. Figure 5 As shown in the figure, the image shows a person shooting a basketball. In this example, the weights of the feature maps of each channel in the spliced ​​feature are the same before passing through SE Net, which are all 0.083. After the spliced ​​feature passes through SE Net, the weights of the feature maps of each channel change, which are 0.05, 0.05, ..., 0.20, ..., 0.20, 0.10, respectively. Among them, the feature map with a larger weight value in the motion feature is the feature map corresponding to the hotspot in the motion feature (the basketball in the image (the white rectangular box area in the figure)), and the feature map with a larger weight value in the semantic feature is the feature map corresponding to the hotspot in the semantic feature (the basketball frame in the image (the white rectangular box area in the figure)). Since the event in the image in this example is a shooting event, the basketball and the basketball frame are crucial to event detection. Accordingly, the features of these two parts are given greater weights through SE Net.

[0132] As an alternative, Figure 6 , a schematic diagram of the structure of a global optical flow feature extraction network provided in an embodiment of the present application is shown in FIG. 1 , in which the number of feature graphs of the weighted splicing feature is 512 as an example. Figure 6 As shown in , the network includes a cascaded global pooling layer (global pooling of motion areas shown in the figure), a scale change layer, and a repeated expansion layer. The input of the network is the optical flow information of the image. After the optical flow information passes through the global pooling layer, a 1×1 tensor, i.e., an eigenvalue, is obtained. The eigenvalue is processed by the scale transformation layer to be an eigenvalue of the same magnitude as the weighted splicing feature mentioned above, and the proportion of the global pooling result in the motion feature of the image can also be adjusted through the scale transformation. After that, the eigenvalue is expanded to a 1*512 eigenvector (i.e., global optical flow feature) through the repeated expansion layer, i.e., a row vector containing 512 eigenvalues, and all eigenvalues ​​are the same, and each eigenvalue corresponds to a feature map in the spliced ​​feature map. When the weighted splicing feature is fused with the global optical flow feature, each eigenvalue can be added to each eigenvalue in a feature map.

[0133] In an optional embodiment of the present application, the video to be processed is obtained by:

[0134] Select video frames from the original video according to the set frame rate;

[0135] The key frames in the selected video frames are determined by repeatedly performing the following operations, and the video stream corresponding to the determined key frames is used as the video to be processed:

[0136] The scene change information between adjacent frames in the selected video frames is determined, and based on the scene change information, the selected adjacent frames are determined as key frames, or video frames are selected from the video frames between the adjacent frames.

[0137] In order to provide smoother images on terminal devices (especially mobile terminals, such as smart phones), the screen display of the terminal device needs to have a higher refresh rate, such as 90Hz (hertz) or 120Hz, etc. Correspondingly, the video acquisition device (such as a camera) needs to use a higher frame rate for video shooting. However, most existing algorithms applied to video are usually suitable for 30fps (Frame per second). Directly processing high frame rate videos requires double the amount of calculation and processing time to process each frame.

[0138] In order to reduce the efficiency of video processing while meeting the needs of high screen refresh frequency and high frame rate video acquisition, this optional embodiment of the present application provides a key frame selection scheme that can be adaptively adjusted. The scheme can select key frames based on the scene change information of the image in the video, select key frames with relatively large scene change information in the video, and use each key frame in the original video selected based on the scene change information as the video to be processed for subsequent processing, which can effectively reduce the time of subsequent calculation and processing, greatly improve the processing efficiency of the video, and ensure a good event detection effect, even events with longer duration can be detected. Among them, the specific representation method of scene change information is not limited in the embodiment of the present application, as long as it is information that can represent the scene change between adjacent frames.

[0139] The end conditions of the above-mentioned repeated execution operations can be configured according to application requirements, such as the number of selected video frames is greater than the set number, or the scene change information between adjacent frames in the selected video frames is less than the change information threshold, or the frame rate corresponding to the selected video frames is equal to the frame rate of the original video, etc. The video frame selected at the end will be used as the key frame.

[0140] The above-mentioned set frame rate can be configured according to application requirements and / or experience, such as 30fps. The set frame rate is not greater than the frame rate of the original video.

[0141] Optionally, in order to avoid selecting too many key frames and increasing redundant information, when selecting frames, equal intervals (ie, equal time intervals, that is, the selected frames are separated by the same number of frames) may be used.

[0142] Optionally, the greater the scene change information corresponding to the video, the more key frames can be selected. For different videos, the key frames selected based on this solution have an adaptive frame rate.

[0143] In an optional embodiment of the present application, based on the scene change information, the selected adjacent frames are determined as key frames, or video frames are selected from video frames between adjacent frames, including:

[0144] If the scene change information is less than the change information threshold, the selected adjacent frame is determined as a key frame;

[0145] If the scene change information is not less than the change information threshold, a video frame is selected from the video frames between adjacent frames.

[0146] That is to say, for adjacent frames in the selected video frames, if the scene change information corresponding to the adjacent frames is less than the change information threshold, it means that the image information between the adjacent frames has changed little, and there is no need to add new frames between the adjacent frames. The adjacent frames can be directly determined as key frames; if the scene change information between the selected adjacent frames is not less than the change information threshold, it means that the image information between the adjacent frames has changed greatly, the probability of an event occurring is relatively large, and more video frames are needed. One or more frames can be selected again from the adjacent frames, and the above-mentioned operation of determining the key frames can be repeated based on the adjacent frames and the frames selected from the adjacent frames. Optionally, a frame can be selected between adjacent frames in an equal interval manner. For example, the adjacent frames are the 1st and 5th frames in the original video. When the scene change information corresponding to the 1st and 5th frames is not less than the change information threshold, the 3rd frame of the video can be selected, and the above-mentioned operation can be repeated for the 1st, 3rd and 5th frames.

[0147] Optionally, the scene change information may be the number of points satisfying a preset condition in the sparse optical flow corresponding to the selected adjacent frames;

[0148] The preset condition is that the optical flow in the horizontal direction is greater than a preset first threshold, and / or the optical flow in the vertical direction is greater than a preset second threshold.

[0149] That is to say, the scene change information can be represented by the number of optical flow points with larger optical flow values ​​in the sparse optical flow between adjacent frames. The change information threshold corresponding to the horizontal direction (x direction) and the change information threshold corresponding to the vertical direction (y direction) can be the same or different.

[0150] Optionally, the first threshold may be w / s, and the second threshold may be h / s, wherein w and h represent the width and height of the frame respectively, and s is a setting value, which may be set according to an empirical value and / or an experimental value, such as 5. Correspondingly, at this time, for any two adjacent frames in the selected video frames, the scene change information is not less than the change information threshold, which means that the number of optical flow points in the sparse optical flow corresponding to the adjacent frames whose optical flow in the x direction is greater than w / s is not less than the change information threshold, and / or the number of optical flow points in the y direction whose optical flow is greater than h / s is not less than the change information threshold.

[0151] As an optional embodiment, obtaining the video to be processed may include:

[0152] Obtain the original video; select video frames from the original video at equal time intervals according to the set frame rate;

[0153] The key frames in the selected video frames are determined by repeatedly performing the following operations until the scene change information between adjacent frames in the selected video frames is less than the change information threshold, or the frame rate corresponding to the selected key frames is equal to the frame rate of the original video, and the video stream corresponding to the determined key frames is used as the video to be processed:

[0154] Determine the scene change information between adjacent frames in the selected video frames; if the scene change information is less than the change information threshold, determine the adjacent frames corresponding to the scene change information as key frames; if the scene change information is not less than the change information threshold, select a video frame at equal intervals between adjacent frames corresponding to the scene change information in the original video, and use the selected video frame and the adjacent frame corresponding to the scene change information as new selected video frames.

[0155] In order to better understand and illustrate the key frame selection scheme provided by this application, Figure 7 An example shown in further illustrates this approach.

[0156] like Figure 7 As shown in , the acquisition frame rate of the original video in this example is 120FPS, wherein the original video shown in the figure includes 5 frames of images, namely, 5 images numbered ①-⑤ in the figure. It should be noted that Figure 7 The images in the figure are only schematic images. The specific contents in the images do not affect the description of this example, and the contents in the images do not constitute any limitation to this application.

[0157] Combination Figure 7, when performing key frame extraction, first, the original video can be selected in an evenly spaced manner according to the set frame rate 30FPS (the extraction 30FPS shown in the figure). The images initially extracted according to the set frame rate are the 1st frame and the 5th frame, that is, image ① and image ⑤. Then, the sparse optical flow between image ① and image ⑤ is calculated, and the number of points in the sparse optical flow whose optical flow value in the x direction is greater than w / s and the number of points in the y direction whose optical flow value is greater than h / s are counted. If the above points in both directions are less than the set number, the 1st frame and the 5th frame are the final key frames. If the above points in one of the two directions are greater than or equal to the set number, it is necessary to select a frame at an equal interval between the 1st frame and the 5th frame, that is, the 3rd frame, and use the 1st frame, the 3rd frame and the 5th frame as the new selected video frames (corresponding to the extraction 60FPS in the figure, the selected video frames at this time include 3 frames. Relative to the original video, the corresponding frame rate of the selected video frames at this time is 6 0FPS), and repeat the above steps of calculating the sparse optical flow between adjacent frames, counting the number of optical flow points that meet the conditions, and judging whether the number of points is greater than or equal to the set number in these 3 frames. As shown in the figure, the above process is repeated for the 1st and 3rd frames, and the above process is repeated for the 3rd and 5th frames. If the number of points in the above two directions corresponding to the 1st and 3rd frames are less than the set number (the condition is met as shown in the figure, that is, the branch with the condition being yes), and the number of points in the above two directions corresponding to the 3rd and 5th frames are less than the set number, then the final key frames are the 1st, 3rd and 5th frames. If the number of points in one of the directions corresponding to the 1st and 3rd frames is not less than the set number (the condition is not met as shown in the figure, that is, the branch with the condition being no), and the number of points in the above two directions corresponding to the 3rd and 5th frames are less than the set number, then it is necessary to select another frame between the 1st and 3rd frames, and the final key frames are the 1st, 2nd, 3rd and 5th frames. If a new frame needs to be added between the 1st frame and the 3rd frame, and between the 3rd frame and the 5th frame, the final video to be processed is the original video.

[0158] In an optional embodiment of the present application, determining a key frame in the selected video frame may include:

[0159] Preprocessing the selected video frame, wherein the preprocessing may include at least one of image scale reduction processing, image grayscale processing, and image denoising processing;

[0160] Determine key frames in the preprocessed video frames.

[0161] That is, after selecting video frames (including the initial selection of video frames from the original video, and the subsequent selection of video frames from adjacent frames), the selected video frames can be preprocessed first, and then the above-mentioned operation of determining key frames is repeated based on the preprocessed frames. By reducing the image scale, the amount of subsequent data processing can be greatly reduced, and the amount of data processing can also be reduced by graying the image. By image denoising, the effect of subsequent image processing can be improved. For example, in the method of determining the motion area of ​​the image described later, the denoising process can make the determined motion area have better robustness.

[0162] It can be understood that if the selected key frames are used as the video to be processed, that is, the optional scheme of key frame selection is adopted, the subsequent processing steps can be based on the pre-processed key frame images, such as obtaining the optical flow information of each frame image, extracting the motion features of each frame image, etc.

[0163] In addition, in practical applications, since key frame selection is an optional implementation step, if the key frame selection scheme is not adopted, before the video to be processed is subsequently processed, the above-mentioned preprocessing can also be performed on each frame image in the video to be processed to reduce the amount of subsequent data processing. If the key frame selection scheme is adopted, the preprocessing process can be to preprocess the selected video frames, and it is not necessary to preprocess all the images of the original video.

[0164] Among them, if the preprocessing includes multiple preprocessing methods, such as image scale reduction and image grayscale, the processing order between the multiple preprocessing methods can be configured according to the actual application scenario and requirements. For example, the processing order can be determined under the premise of minimizing the amount of data processing or other factors. For example, if the video to be processed is in YUV (Luma Chroma) format (the video shot by the camera may be in this format), the grayscale image directly corresponds to the image of the Y channel, so at this time, the image can be grayscaled first and then the image scale can be reduced to reduce the amount of data processing.

[0165] In an optional embodiment of the present application, before obtaining the optical flow information of at least one frame of image in the video to be processed, the following steps may also be included:

[0166] Determine the movement type of the video acquisition device of the video to be processed when acquiring the video to be processed;

[0167] If the movement type is unconscious movement of the user, motion compensation is performed on each frame image in the video to be processed.

[0168] The scheme of the embodiment of the present application is applicable to the scene in which the mobile phone is relatively still, the shooting object is in motion and / or there is a moving subject in the scene during the acquisition process of the video to be processed, that is, the scene of target motion, and is also applicable to the scene in which the shooter moves the video acquisition device, that is, the device is moved consciously by humans. The unconscious movement of the user refers to the movement of the acquisition device that is not moved by the user autonomously, such as the user's hand shaking. The motion compensation scheme provided by the present application can first be processed according to the movement type of the video acquisition device when the video is collected. If it is the unconscious movement of the user, the frame images in the video to be processed are subjected to motion compensation processing, and the video clips in which the event occurs in the video to be processed are determined based on the frame images after motion compensation. Through motion compensation, the problem of inaccurate event boundary interception caused by unconscious user movement such as shaking of the video shooting device can be solved. Specifically, for event cameras, since they are generally stationary during the monitoring process, the so-called events are generally caused by moving objects in the monitoring scene. For ordinary video acquisition devices (such as cameras in mobile phones), there are generally two main factors that cause changes in video information: the presence of moving objects in the shooting scene and the movement of the shooting device. Regarding the movement of the shooting device, when a user shoots a video through a common video acquisition device such as a mobile phone, the movement may also be the unconscious movement of the user or other structures that carry the video acquisition device, such as the camera movement caused by human shaking or shaking, and this movement will cause the image to move in space, which will cover up the information of the object movement event in the scene. In other words, the movement of the shooting device may be regular or irregular, and irregular movement, that is, the user's unconscious movement, will affect the detection results.

[0169] In response to the above-mentioned problem, the above-mentioned optional scheme provided in the embodiment of the present application can first determine the movement type of the video acquisition device of the video to be processed when acquiring the video before processing the video to be processed. If the movement type is unconscious movement of the user, motion compensation can be performed on each frame image. Based on each frame image after motion compensation, the video segment where the event occurs in the video to be processed is determined, thereby removing the influence of the movement of the shooting device caused by unconscious movement through motion compensation.

[0170] Specifically, as an optional method, the judgment of the movement type can be achieved through the IMU (Inertial Measurement Unit) of the video acquisition device. IMU is a device that measures the three-axis attitude angle and acceleration of an object. Generally, IMU includes a three-axis gyroscope and a three-axis accelerometer, which can judge whether the video acquisition device is moving through the angular acceleration and motion acceleration in three directions, and whether the movement is regular or irregular. Among them, irregular movement is considered to be the movement of the video acquisition device caused by the unconscious movement of a person or other structure that carries the video acquisition device.

[0171] It can be understood that in actual applications, if the movement type of the video acquisition device can be obtained, a solution for motion compensation for each frame of the image can be executed. For example, in the process of video acquisition through a terminal device, the terminal device can obtain the movement type of the terminal device in real time, and determine whether to perform motion compensation based on the movement type. If the movement type of the video acquisition device cannot be obtained, the solution for motion compensation for each frame of the image may not be executed.

[0172] Currently, many motion compensation methods are based on sparse optical flow (such as KLT (Kanade-Lucas-Tomasi)). As an example, Figure 8 A schematic diagram of the principle of an existing method for realizing image motion compensation is shown in FIG. Figure 8 As shown in , for two adjacent frames in the video (image t and image t+1 shown in the figure, image t is the previous frame of image t+1), the KLT method can be used to extract and track feature points first, and based on the feature point extraction and tracking results, the homography matrix between the two images is calculated, and then image t+1 is transformed to the coordinate system of image t based on the homography matrix to achieve motion compensation for image t+1.

[0173] Although motion compensation can be achieved by using the above method, the premise of the applicability of the homography matrix is ​​that the same camera is used to shoot the same plane at different positions. However, in real scenes, the depth of not all objects is on the same plane. Coordinate transformation through the homography matrix will lead to deviations in motion compensation.

[0174] In view of the above problems existing in the prior art, in an optional embodiment of the present application, for any frame of the at least one frame of images, motion compensation is performed on the frame of images, which may specifically include:

[0175] Determine the depth information of the previous frame image of the frame image;

[0176] Determine matching pixels between the frame image and a frame image preceding the frame image;

[0177] Determine a projection matrix from the previous frame image to the current frame image based on the depth information and image coordinates of each matching pixel point in the previous frame image and the image coordinates of each matching pixel point in the current frame image;

[0178] Based on the image coordinates and depth information of each pixel point of the previous frame image and the above-mentioned projection matrix, determine the transformation relationship from the previous frame image to the current frame image;

[0179] Based on the above transformation, the frame image is reprojected to the image coordinates of the previous frame image to obtain the frame image after motion compensation.

[0180] Since the depth of each pixel in the image may be different, the depth information of the image may be taken into account when performing motion compensation on each frame of the image, thereby solving the problem of motion compensation deviation caused by coordinate transformation through the homography matrix.

[0181] Among them, the specific method of determining the depth information of each frame image is not limited in the embodiments of the present application. As an optional method, for a video acquisition device with a telephoto lens and a wide-angle lens, the depth value of the image can be estimated by combining the telephoto lens and the wide-angle lens, and motion compensation is achieved based on the estimated depth information of the image and the matching points between adjacent images. Specifically, taking a mobile phone as an example, a mobile phone usually has a telephoto lens and a wide-angle lens. When performing video acquisition, the video frames captured by the telephoto lens are usually saved and used. However, in actual applications, the wide-angle lens can also be used for synchronous image acquisition. Therefore, the depth information of the image can be obtained based on the images captured by the wide-angle lens and the telephoto lens at the same time t, and the depth information can be integrated into the motion compensation processing process of the image at time t+1 to improve the motion compensation effect of the image.

[0182] In addition, in practical applications, in order to better improve the effect of image processing, when performing motion compensation processing on the image, the image can also be subjected to fuzzy denoising processing to reduce the influence of noise in the image on the image processing effect. Of course, in other optional schemes provided in the present application, each frame image after fuzzy denoising processing can also be processed. Among them, the specific processing method for fuzzy denoising is not limited in the embodiment of the present application, such as Gaussian blur, median filtering and other processing methods can be used.

[0183] As an example, Fig. 9A flow chart of a motion compensation method provided by the present application is shown in the figure, in which two adjacent frames of images in a video captured by a mobile phone's camera are used as an example for explanation, wherein image t+1 shown in the figure is the image captured at time t+1, and image t is the image captured at time t, that is, image t+1 is the image that needs to be motion compensated in this example, image t is the previous frame, image t+1 and image t are video frames captured by the mobile phone's telephoto lens, and the wide-angle image t shown in the figure is the video frame captured by the mobile phone's wide-angle lens at time t. Fig. 9 As shown in , the process of performing motion compensation processing on image t+1 in this example may include:

[0184] a. Based on the wide-angle image t and the image t, the depth value (ie, depth information) of each pixel of the image t is estimated;

[0185] b. Based on image t and image t+1, obtain matching pixel pairs in image t and image t+1 through feature point extraction and tracking;

[0186] It should be noted that the execution order of step a and step b can also be reversed or performed simultaneously.

[0187] As an example, Fig.10 , a schematic diagram for determining matching pixel pairs in image t and image t+1 is shown in the figure, the plane where a, b, c are located represents image t, the plane where a', b', c' are located represents image t+1, the points corresponding to image t and image t+1 represent the center of the telephoto lens (i.e., the camera coordinate origin of the telephoto lens), the three pixel points a, b, c in image t and the three pixel points a', b', c' in image t+1 are pixel coordinate pairs of the same name points in image t and image t+1, i.e., matching pixel points, wherein a and a' are a pair of matching pixel points, b and b' are a pair of matching pixel points, c and c' are a pair of matching pixel points, and points A, B, and C in the figure are the coordinate points in the world coordinates corresponding to the three pairs of coordinate points, respectively.

[0188] c. Calculate the projection matrix between the two images based on the matching pixels and depth information

[0189] In this step, based on the depth value and image coordinates of each matching pixel point in image t, the three-dimensional coordinates (i.e., the coordinates in the world coordinate system) of each matching pixel point can be obtained. According to the 3D-2D PnP (3dimensional-2VPerspective-n-Point, 3D to 2D perspective N-point projection) method, based on the three-dimensional coordinates of each matching pixel point and the image coordinates of each matching pixel point in image t+1, the projection matrix of image t+1 can be solved, that is, the projection matrix from image t to image t+1.

[0190] Specifically, for a pixel point P on the image, assuming that its coordinates in the world coordinate system and the image coordinate system are represented by M and m respectively, then:

[0191]

[0192] Among them, s is the scale factor, A is the intrinsic parameter matrix of the camera, and [R, t] is collectively referred to as the extrinsic parameter matrix of the camera, which is expanded as follows:

[0193]

[0194] Among them, u and v are the coordinates of P in the image coordinate system, X, Y, and Z represent the three-dimensional coordinates of P in the world coordinate system, and r 1 、r 2 、r 3 are the 3x3 rotation matrices of the external parameter matrices, t is the 3x1 translation matrix, and [R,t] is the projection matrix of the image.

[0195] In this step, based on the two-dimensional coordinates and depth values ​​of the matching pixel points in image t in the image coordinate system of image t, the world coordinates of each matching pixel point can be obtained. Then, using the above formula (2), based on the world coordinates of each matching pixel point and the two-dimensional image coordinates of each matching pixel point in image t+1, the projection matrix of image t+1 can be calculated.

[0196] For the above formula (2), if all pixels are in the same plane, let z = 0, and we get:

[0197]

[0198] Where H = A[r 1 r 2 t], then H is the homography matrix, and the above formula (1) can be expressed as

[0199] It can be seen that the difference between the homography matrix and the projection matrix lies in whether the depth information is considered.

[0200] d. Based on the depth information and the above projection matrix, calculate the transformation relationship from image t to image t+1

[0201] e. Based on the above transformation relationship, reproject image t+1 to the image coordinate system of image t.

[0202] In practical applications, based on the above depth information and projection matrix, if the transformation relationship from image t+1 to image t is directly calculated, it is very likely that some pixels will not be projected and have no value. For example, if multiple pixels in image t+1 correspond to the same pixel in image t, when image t+1 is reprojected to the image coordinate system of image t, some pixels in the reprojected image will have no value. To solve this problem, the transformation relationship from image t to image t+1 can be calculated first, and then image t+1 can be reprojected (remap) to the image coordinate system of image t.

[0203] Among them, the specific implementation of calculating the transformation relationship from image t to image t+1 according to the depth information and the above-mentioned projection matrix, and reprojecting image t+1 to the image coordinate system of image t based on the transformation relationship from image t to image t+1 can be achieved using existing technologies and will not be elaborated here.

[0204] The above motion compensation scheme provided in the embodiment of the present application can effectively reduce the impact of unconscious motion on event detection. As an example, Fig.11 , a schematic diagram of a motion compensation result is shown in the figure. In this example, for image t and image t+1, image t+1 can first be blurred and denoised to obtain the processed image at time t+1 (the blurred image t+1 shown in the figure). Then, motion compensation calculation can be performed on the blurred image t+1 based on image t and depth information of image t (not shown in the figure) to obtain a motion compensated image (the motion compensated image t+1 shown in the figure).

[0205] It should be noted that, in practical applications, when performing motion compensation processing on an image, each frame image in the video may be first subjected to blur denoising processing, and image compensation may be performed based on each frame image after the processing, such as Fig.11 In the example shown in , the image t can also be subjected to blur denoising, and the images after blur denoising can be used in motion compensation processing. For different application scenarios, it can be selected whether to perform blur denoising on all frames as needed. For example, if the device storage space is limited, blur denoising can be performed on all frames or only on the next frame. If the device configuration is high, blur denoising can also be performed on all frames.

[0206] As can be seen from the foregoing description, the video processing method provided in the embodiments of the present application is also applicable to the scenario where the video shooter autonomously and consciously moves the video acquisition device, that is, the scenario where the device is moved artificially. For example, if the user uses a mobile phone to shoot scenes from multiple perspectives or of a target object, at this time, the movement of the acquisition device is controlled by the user, not unconscious movement of the user. For this situation, when it is determined (such as can be determined by IMU data) that the user's movement type is a conscious movement of the user, an optional solution is to directly use the solution provided by any optional embodiment of the present application to process the video without performing motion compensation, and determine the video segment in which the event occurs. As another optional solution, the video segment corresponding to the user's conscious movement can be directly determined as the video segment in which the event occurs.

[0207] For another application scenario, if the video to be processed contains both segments in which the user moves consciously and segments in which the user moves unconsciously, this application also provides the following optional processing methods:

[0208] a. Regardless of the type of movement involved, the video can be processed by obtaining optical flow information, extracting motion features, and detecting segments where events occur based on motion features to determine the segments where events occur. Of course, if the user moves unconsciously, the video can also be processed by motion compensation before processing.

[0209] b. Divide the video into segments according to the set duration, and determine the movement type of each segment. For segments with unconscious movement, adopt the corresponding processing method, and for segments with conscious movement, adopt the corresponding processing method. If the divided segments also have two types of movement, they can be further divided, or the main movement type can be determined based on the duration corresponding to the two types of movement, and then the processing method corresponding to the main movement type is adopted.

[0210] c. Directly extract the segment corresponding to the conscious movement in the video as the segment where the event occurred, and perform Figure 1 If the remaining part contains unconscious movement, motion compensation processing can be performed first.

[0211] In an optional embodiment of the present application, determining whether there is a video clip in which an event occurs in the video to be processed may include:

[0212] Obtaining optical flow information of at least one frame of image in the video to be processed;

[0213] Extracting motion features of at least one frame of image based on at least one frame of image and optical flow information of the at least one frame of image;

[0214] Based on the motion features of at least one frame of image, determining the motion state representation information of at least one frame of image;

[0215] Based on the motion state representation information of at least one frame of image, a video segment in which an event occurs in the video to be processed is determined.

[0216] In another optional embodiment of the present application, based on at least one of brightness information and optical flow information of the video to be processed, determining a video segment in which an event occurs in the video to be processed includes:

[0217] Determine the motion state representation information of each frame image based on at least one of the brightness information and the optical flow information of each frame image of the video to be processed;

[0218] Based on the motion state representation information of each frame image, a video segment in which an event occurs in the video to be processed is determined.

[0219] Among them, for a frame of image, the motion state characterization information is used to characterize the amount of change in the scene information or image content of the image. The specific representation method of the motion state characterization information is not limited in the embodiment of the present application. As an optional method, the information can be a quantified value, such as a score or probability. For the convenience of description, in the example description below, the motion state characterization information will be represented by the image score as an example. The higher the image score, the more the motion state of the image changes.

[0220] In the following, several different optional methods will be combined to specifically explain how to determine various information (including optical flow information and image motion state representation information) of video clips where events occur in the video to be processed, and how to implement event detection in the video based on various information.

[0221] 1. Optical flow information

[0222] Optical flow is an important feature used to analyze time-series images. The change of optical flow largely reflects the movement of objects, and the occurrence of events is generally accompanied by the movement of objects. Therefore, when detecting event clips in the video based on the optical flow information of the image, how to quickly and accurately calculate the optical flow of each frame of the image is a problem that must be solved.

[0223] As an optional method, when determining the optical flow information of an image, in order to achieve super real-time or at least real-time performance on a mobile terminal, a sparse optical flow strategy can be adopted: that is, first calculate the corner points on the current image, and then calculate the pixel movement for each corner point based on the previous and next frames. However, sparse optical flow not only has a relatively low accuracy, but more importantly, in the event detection task, we mainly focus on the movement of the target subject and do not care about the movement of the background. If the background is complex and the foreground lacks texture, it is very likely that all the corner points fall on the background. The optical flow calculated in this way cannot represent the movement of the target subject in the image at all, and even if part of it falls on the foreground, the effect will be greatly reduced due to the interference of the background, which is obviously unreasonable.

[0224] In order to improve the detection performance, as another optional method, dense optical flow can be used, which can obtain higher accuracy and avoid the problem of not being able to obtain the foreground optical flow at all. For example, the Farneback algorithm can be used to calculate the dense optical flow algorithm of the image.

[0225] Although dense optical flow has higher accuracy than sparse optical flow, it still does not completely solve the problem of background optical flow interference. In addition, the calculation speed of dense optical flow is slower than that of sparse optical flow, making it more difficult to achieve real-time calculation.

[0226] In view of the above problems existing in the above two optional methods, an optional method for determining the optical flow information of the image is provided in an optional embodiment of the present application. For any frame image of the above at least one frame image, obtaining the optical flow information of the frame image may include:

[0227] Determine the motion area of ​​the frame image;

[0228] Based on the motion region in the frame image and a subsequent frame image of the frame image, a dense optical flow of the frame image is determined.

[0229] Optionally, for any of the above frame images, determining the dense optical flow of the frame image based on the motion region in the frame image and a frame image subsequent to the frame image may include at least one of the following:

[0230] Based on the motion region in the frame image and the image region corresponding to the motion region in the next frame image of the frame image, dense optical flow calculation is performed to obtain the dense optical flow of the frame image;

[0231] Based on the frame image and a frame image subsequent to the frame image, a dense optical flow corresponding to the frame image is calculated; and the optical flow of the motion area part of the frame image in the calculated dense optical flow is used as the dense optical flow of the frame image.

[0232] In the scheme of the present application, when calculating the dense optical flow of an image, only the optical flow within the motion area (also referred to as the foreground image area) in the image that can characterize the motion of the target subject can be calculated. That is to say, the motion area can be used as a mask image of the image, and only the dense optical flow within the mask range can be used as the dense optical flow of the image. While retaining the advantage of high precision of the dense optical flow, it not only reduces the amount of calculation, but also can well avoid the influence of the background optical flow on the final result and avoid the loss of the foreground optical flow.

[0233] The dense optical flow determination scheme provided in the embodiment of the present application, for a frame image, when determining the motion area of ​​the frame image, the moving target in the frame image can be detected based on the frame image and at least one frame image after the frame image (such as a set number of adjacent images after the frame image), and the pixel points corresponding to the moving target are marked in the frame image as the motion mask of the image, and further, the motion area is determined in the frame image and the frame image after the frame image based on the motion mask, so as to obtain the dense optical flow of the frame image corresponding to the motion area based on the motion area of ​​the frame image and the frame image after the frame image. If there are multiple moving targets in the image, there can be multiple moving areas. When there are multiple moving areas, the dense optical flow of the image is calculated based on the corresponding moving areas in the two adjacent frames of images, or the dense optical flow of the entire image is calculated based on the two adjacent frames of images, and then the dense optical flow corresponding to each moving area is selected from the dense optical flow of the entire image to obtain the final dense optical flow image of the image.

[0234] Fig.12a and Figure 12b 2 shows two schematic diagrams of the process of calculating dense optical flow of an image. In this example, the video to be processed is a video stream determined by selecting key frames. One method is as follows: Fig.12a As shown in FIG. 1 , for at least one key frame, the motion region of the frame can be first determined (motion mask detection), and then the corresponding region in the frame and the next frame of the frame can be selected based on the motion region (motion region selection), and then the dense optical flow can be calculated based on the corresponding regions in the two frames to obtain the dense optical flow of the frame. Another method, such as Figure 12b As shown in, for at least one key frame, the motion area of ​​the frame is determined, and the dense optical flow of the entire image can be calculated based on the frame and the frame after the frame, and then the optical flow corresponding to the motion area in the dense optical flow of the entire image is used as the dense optical flow of the frame.

[0235] Optionally, in practical applications, it is assumed that a frame of image is an image at time t, and the next frame of image of the frame is an image at time t+1. Since the image at time t+1 is used in the above-mentioned motion mask detection and optical flow detection, the motion information of the image at time t+1 has been fully utilized. Therefore, for the video to be processed, when calculating the optical flow information of each frame of the video, the optical flow information can be calculated every other frame. For example, in the above example, the optical flow information of the image at time t+1 can be omitted. After the optical flow information of the image at time t is calculated, the optical flow information of the image at time t+2 is calculated next time, which can further reduce the amount of calculation and reduce the data processing time. Of course, the optical flow information of each frame can also be calculated. Among them, for the optional scheme of calculating the optical flow information every other frame, for the frame without calculating the optical flow information, optionally, its optical flow information can use the optical flow information of the previous frame, or a preconfigured optical flow value, such as zero or other values, or only the frames of images for which the optical flow information is calculated can be processed in the subsequent processing steps.

[0236] Optionally, when determining the dense optical flow of a frame image based on the foreground image area (i.e., the motion area) in the frame image and the subsequent frame image of the frame image (or the image area corresponding to the foreground image area in the subsequent frame image of the frame image), in order to avoid the target being lost in the next frame image due to the movement of the target, after determining the corresponding area in the previous and next frames based on the mask (which can be simply referred to as the mask area, i.e., the mask area), such as determining the mask area in the previous and next frames based on the minimum circumscribed rectangle of the mask, for the subsequent frame image, a certain number of pixels of boundaries can be additionally added to the determined mask area, that is, pixels can be expanded on the basis of the mask area, such as expanding the boundaries of a set pixel width all around to ensure that the target will not be lost in the next frame image, and then the dense optical flow of the previous frame image is calculated based on the mask area determined in the previous frame and the expanded mask area in the subsequent frame. Among them, when extending the pixel boundary, the specific amount of boundary to be added can be configured according to the empirical value, that is, the pixel width to be expanded can be pre-configured, and the area (the minimum circumscribed rectangle of the mask) can be expanded in four directions during expansion. The number of moving pixels in the image can also be considered, and a certain number of additional pixel boundaries can be added.

[0237] Optionally, when expanding, the expansion may be performed in the horizontal and / or vertical directions, and the inertia of the object's movement may also be considered (because the movement is continuous and has a certain inertia, if the object moves 10 pixels at time t-2, then it is very likely that it also moves 10 pixels at time t), and the direction of expansion is determined according to the direction of movement of the object in the image. For example, if the object's movement direction is determined to be rightward according to the current frame image and the next frame image of the frame, the direction of expansion may be rightward expansion, or both the object's movement direction and non-movement direction may be expanded, but the expansion width in the movement direction and non-movement direction may be different. For example, for the movement direction, it may be determined according to the distance moved by the moving pixels, such as determining the number of expanded pixels according to the distance moved by the moving pixels and the set expansion coefficient. Optionally, the expansion coefficient may be a value not less than 1 to avoid missing pixels that have moved. For example, if the object moves a distance of 10 pixels at time t-2 and the expansion coefficient is 1.1, the expanded pixel width may be 11. For the non-movement direction, it may be expanded according to the set value. In addition, if the object moves in an irregular direction, such as a non-horizontal or vertical direction (such as a diagonal direction of the image), it can be expanded in the horizontal and vertical directions.

[0238] As an optional solution, the size of the expanded area can be determined based on the optical flow of the current frame image. For any motion area, the number of expanded pixels can be expressed as:

[0239] max(expansion factor * average optical flow of motion area, threshold)

[0240] Among them, the expansion coefficient is a set coefficient. If the expansion is performed in the horizontal direction, the size can be the width of the minimum circumscribed rectangle of the motion area. The average optical flow of the motion area is the average of the optical flow of the motion area in the next frame image. The threshold is a set value, which can be an empirical value and / or an experimental value. If the expansion is performed in the vertical direction, the size can be the height of the above-mentioned minimum circumscribed rectangle. The thresholds corresponding to the horizontal and vertical directions can be different.

[0241] As an example, Fig.12c FIG. 4 is a flow chart of calculating dense optical flow of an image based on the method provided in the embodiment of the present application. Fig.12c As shown in the figure, in order to calculate the optical flow of a frame of image t acquired at time t, the corresponding area can be cropped on image t based on the minimum circumscribed rectangle of the mask area in the mask image of image t to obtain mask area t, and the corresponding area can be intercepted on the next frame image of image t (image t+1 shown in the figure), and the mask area t+1 can be obtained after a certain area is expanded outward on the basis of the area, and the optical flow information of image t is calculated based on mask area t and mask area t+1.

[0242] It should be noted that when calculating the optical flow information of the current frame image based on the mask area of ​​the current frame image and the mask area of ​​the frame image after the current frame, if an expansion processing method is adopted, the expansion can be to expand the mask areas of both the current frame image and the frame image after the current frame, that is, the mask areas in the two images are of the same size.

[0243] In an optional embodiment of the present application, determining whether there is a video clip in which an event occurs in the video to be processed may include:

[0244] Determine the optical flow information of at least one frame of the video to be processed;

[0245] For any one of the at least one frame of images, sort the optical flow information of the frame of images in ascending order of optical flow values, and determine the motion state representation information of the at least one frame of images based on the optical flow values ​​in the set confidence interval after sorting;

[0246] Based on the motion state representation information of the at least one frame of image, it is determined that a video segment in which an event occurs in the video to be processed.

[0247] After determining the optical flow information of the image, as an optional solution, the image score can be determined based on the optical flow information. As an example, Fig.13 FIG. 4 shows a schematic diagram of a process for determining an image score based on image optical flow information provided by an embodiment of the present application. Fig.13 As shown in , the method may include the following steps:

[0248] For the current frame (i.e., the previous frame between two adjacent frames), based on the determined target mask (i.e., the motion area) of the current frame, the target area in the grayscale images of the previous and next frames (i.e., the mask area in the previous text) can be obtained, and the mask area in the two frames can be calculated. The Farneback optical flow algorithm can be used to calculate the dense optical flow of the previous frame to obtain an optical flow matrix, wherein the size of the optical flow matrix is ​​the same as the mask area of ​​the previous frame image, and each element in the matrix is ​​two values, which respectively represent the motion amount (offset or movement value) of the corresponding pixel point in the x direction and the y direction.

[0249] Since the optical flow is composed of the movement values ​​in the x and y directions, and event detection only cares about whether there is motion, not the direction of motion, for each pixel, the optical flow value f of the point can be obtained by summing the absolute value of the optical flow value f_x in the x direction and the absolute value of the optical flow value f_y in the y direction, that is, let f = |f_x| + |f_y|. When determining the image score based on the optical flow information, in order to ensure that large action fragments can be detected and to remove possible noise interference, the optical flow values ​​of each pixel are sorted in order from small to large, and the optical flow values ​​in the confidence interval (60% to 95% interval) can be averaged as the result of scoring the possibility of frame motion.

[0250] This method is used to determine the image score, which is fast to calculate and does not rely on any additional data. However, this method only uses the statistical information of optical flow, and the optical flow reflects the motion relationship between two frames of images, and cannot consider the information of previous images to score the motion results.

[0251] 2. Motion area, also known as the foreground image area, i.e. the mask area mentioned above

[0252] The embodiment of the present application also provides a solution for determining the foreground image area (i.e., the motion area) in the image. When calculating the image optical flow information, the method for determining the foreground image area provided by the solution can be used. Of course, in practical applications, the existing method for determining the foreground image area can also be used.

[0253] Since event detection is to detect each video segment with motion in the video, the present application can detect the brightness change (I t+1 (x,y)-I t (x, y)) to determine whether an event occurs at the pixel, where I t+1 (x, y) represents the brightness information of the pixel at the (x, y) coordinate in the image frame at time t+1, I t (x,y) identifies the brightness information of the pixel at the (x,y) coordinate in the image frame at time t.

[0254] Due to factors such as the inability of the video acquisition device (such as the user's mobile phone) to remain absolutely still and the automatic adjustment of the aperture during the video recording process, the reliability of the result of motion discrimination of the pixel using only the corresponding pixels of two frames of images at adjacent moments is not high. In response to this problem, in an optional embodiment of the present application, for any frame of the at least one frame of images, determining the motion area of ​​the frame of image may specifically include:

[0255] Based on the brightness information of the frame image and the brightness information of images of a set number of frames after the frame image, the motion area in the frame image is determined.

[0256] Among them, the specific value of the above-mentioned set frame number is not limited in the embodiment of the present application and can be configured according to actual needs. For example, it can be set to 4, so that the motion area of ​​the first frame image in these 5 consecutive frames can be determined.

[0257] The solution provided in the embodiment of the present application can integrate image information at more moments when determining the motion area of ​​an image, thereby improving the accuracy of the determined motion area.

[0258] Optionally, for any one of the at least one frame of images, determining the motion region of the frame of image based on brightness information of the frame of image and brightness information of a set number of frames of image after the frame of image includes:

[0259] Dividing the frame image and a set number of frame images after the frame image into a plurality of image blocks respectively;

[0260] The motion area of ​​the frame image is determined based on the brightness information of each image block at the same position in the frame image and a set number of frame images after the frame image.

[0261] At the same time, the neighborhood information of the pixel point (x, y) can be added to establish a Gaussian background model for the neighborhood block of the pixel point (x, y), that is, the Gaussian background model can be established in units of image blocks. The addition of more information enhances the robustness of the model, reduces the amount of calculation (no need to build a Gaussian background model for each pixel), and is more tolerant to slight offsets between images (motion compensation errors) and brightness deviations between images caused by automatic adjustment of ISO (International Standardization Organization, sensitivity).

[0262] As an optional manner, for an image block of a frame image, based on brightness information of the image block at the same position in the frame image and images of a set number of frames after the frame image, determining the motion area in the frame image includes:

[0263] For at least one image block obtained by division, based on brightness information of the image block in the frame image and a set number of frame images after the frame image, determine the brightness mean and brightness variance of the Gaussian background model corresponding to the image block through the Gaussian background model;

[0264] Based on the brightness information of each pixel of the image block in the frame image, and the brightness mean and brightness variance of the Gaussian background model corresponding to the image block, determine whether each pixel in the image block is a moving pixel in the frame image or whether the image block is a moving area in the frame image.

[0265] Background modeling is also called background estimation. Its main purpose is to transform the problem of moving target detection in sequence images into a binary classification problem based on the current background estimation, and to divide all pixels into two categories: background and moving foreground. Then, the classification results are post-processed to obtain the final detection results. The single distribution Gaussian background model believes that for a background image, the distribution of the brightness of a specific pixel or image block (usually the grayscale value of the pixel or the grayscale mean of the image block) satisfies the Gaussian distribution, that is, for the background image B, the brightness mean of each image block (x, y) (such as a rectangular box containing 3*3 pixels) satisfies B(x, y)~N(μ, d) (that is, B(x, y) satisfies the Gaussian distribution with a mean of μ and a variance of d):

[0266]

[0267] Where B(x,y) represents the brightness value of the pixel with the mark (x,y) or the mean brightness of the pixels in the image block (x,y), P(B(x,y)) represents the Gaussian distribution probability of B(x,y), μ represents the image block (x,y) where the coordinate point (x,y) in the background image B is located or the mean brightness of the image block (x,y), and d is the brightness variance of the image block (x,y).

[0268] When detecting foreground or background areas, the mean u and variance d of each image block at the same position in a video sequence image over a period of time can be calculated as a background model. For an arbitrary image G containing a foreground, the brightness of the pixel (x, y) in the corresponding pixel block on the image or the mean brightness of the pixel in the image block (x, y) is calculated if:

[0269]

[0270] Wherein, T is a constant threshold, then the point is considered to be a background point (it can also be considered that the corresponding image block is a background image block), otherwise it is a foreground point (it can also be considered that the corresponding image block is a foreground image block).

[0271] Among them, G(x,y) in the above formula represents the brightness value of the pixel at the coordinate point (x,y) in the image G or the mean brightness of the pixels in the image block (x,y), and μ and d represent the brightness mean and brightness variance of the Gaussian background model corresponding to the frame image at the current moment in the video sequence image, respectively.

[0272] For the solution provided in the embodiment of the present application, for a frame of image, when the motion area in the frame of image is determined by the Gaussian background model based on the brightness information of the image block at the same position in the frame of image and the image of the set number of frames after the frame of image, the brightness information of the image block corresponding to the same position in the frame of image and the image of the set number of frames after the frame of image can be used to determine whether the area corresponding to the image block is a motion area (i.e., whether all pixels in the area corresponding to the image block are foreground points), or whether each pixel in the area corresponding to the image block is a motion pixel (also called foreground point / foreground pixel). Specifically, taking the setting of the number of frames as 4 as an example, the motion area of ​​the current frame can be determined based on the current frame of image and the 4 frames of images after the current frame. At this time, for an image block, the grayscale mean (i.e., brightness mean) and grayscale variance (brightness variance) of the Gaussian background model of the image block in the current frame can be determined based on the grayscale values ​​of each pixel in the image block in the 5 frames of image.

[0273] For example, for the above five frames of images, assuming that the image at time t is the current frame image, for time t, μ is the brightness mean of the image block (x, y) in the image at time t, for time t+1, μ is the brightness mean of the two image blocks (x, y) in the image at time t and the image at time t+1, and so on. For the image at the last moment, the mean μ is the brightness mean of the corresponding image blocks in the five frames of images. Assuming that the size of the image block (x, y) is 3 pixels * 3 pixels, when determining whether the image block (x, y) in the image at time t is the foreground image area, or determining whether each pixel in the image block is a foreground pixel, the brightness mean and brightness variance of the Gaussian background model can use the mean and variance of the image block corresponding to the fifth frame of the above five images. Specifically, if the brightness value G(x, y) of any pixel (x, y) in the image block at time t or the mean value G(x, y) of the pixel brightness in the image block (x, y) satisfies:

[0274]

[0275] Then the pixel point (x, y) can be considered to be a background point in the image at time t, or the image block (x, y) in the image at time t can be considered to be a background image block, that is, a background image area, otherwise it is a foreground point or a foreground image area.

[0276] In practical applications, in order to meet the needs of different scenes, the required image processing granularity can be selected as needed. For example, if the coarse-grained processing method is used, in the above formula, if it is greater than T, the image block where the point is located can be considered as a background block. For the fine-grained processing method, if it is greater than T, it can be considered that each pixel in the image block is a background point. Among them, when the coarse-grained processing method is used, for an image block, the above G(x,y) represents the brightness mean of each pixel in the image block, and when the fine-grained processing method is used, G(x,y) represents the brightness value of a pixel in the image block.

[0277] The specific model form of the Gaussian background model is not limited in the present embodiment, for example, a single distribution Gaussian background model or a double-single distribution Gaussian model can be used. The following takes these two models as examples for further explanation.

[0278] A. Single distribution Gaussian background model (can be referred to as single Gaussian model, single Gaussian background model, etc.):

[0279] For video sequence images (such as the current frame image and the 4 frames after the current frame image), the input image is first divided into blocks, such as blocks of N*N size, and the Gaussian model of each block is calculated, and the Gaussian model is determined by the mean variance. The key to establishing a Gaussian model is to update the mean and variance of the model according to time.

[0280] For an image block i (referred to as block i), the gray value (that is, brightness value) of pixel j at time t (that is, the frame image at time t) is and represents all pixels of block i at time t. The number of pixels in the block can be expressed as The grayscale mean and variance of block i at time t are expressed as and The mean, variance, and age of the Gaussian model of block i at time t are Then the grayscale mean and variance of the image block at time t can be expressed as:

[0281]

[0282] The mean update, variance update, and age update of the Gaussian model of the image block at time t can be expressed as:

[0283]

[0284]

[0285]

[0286] It can be seen that for an image block at the same position in multiple consecutive frames of images, the grayscale mean value of the Gaussian model corresponding to the image block in the current frame image is determined based on the grayscale mean value of the Gaussian model corresponding to the image block in the previous frame image and the grayscale mean value of the image block in the current frame image. Similarly, the grayscale variance is based on the same principle.

[0287] Based on the above single Gaussian distribution model, for each image block at the same position in multiple consecutive frames of images, the grayscale mean and grayscale variance corresponding to the image block in the last frame of image can be used as the grayscale mean and grayscale variance of the Gaussian model corresponding to the image block in the first frame of image.

[0288] B. Double-single distribution Gaussian background model (called double-single Gaussian model):

[0289] For a single distribution Gaussian model, using both foreground information and background information to build the Gaussian model will cause the Gaussian model to have a centered mean and too large a variance, which is not conducive to foreground judgment. Fig.14a The probability distribution diagram of the single Gaussian model shown in the figure, in which the horizontal axis represents the grayscale value in the image, and the vertical axis represents the distribution probability corresponding to the grayscale value. It can be seen from the figure that when judging whether a pixel point or an image block is a foreground point based on the above threshold T, the probabilities of the foreground (FG shown in the figure) and the background (i.e., background, BG shown in the figure) on the Gaussian model are the same.

[0290] In order to overcome this difficulty of the distribution Gaussian model, two single distribution Gaussian models, namely a dual-single Gaussian model, can be used, one is a Gaussian model representing the image block (apparent), namely the existing Gaussian model currently used, and the other is an alternative Gaussian model (candidate).

[0291] Based on the dual-single Gaussian model, we continue to use the image block i in the previous text as an example to explain that the condition for image block i to be classified into the existing Gaussian model, namely, apparent, is:

[0292]

[0293] Among them, θ s is the preset threshold coefficient, Respectively represent the grayscale mean and variance of the existing Gaussian model of block i at time t. If this condition is met, the existing Gaussian model is updated according to the single Gaussian model step.

[0294] The condition for image block i to be included in the alternative Gaussian model:

[0295]

[0296] Likewise, Respectively represent the grayscale mean and variance of the candidate Gaussian model of block i at time t. If this condition is met, the candidate Gaussian model is updated according to the single Gaussian model step.

[0297] Conditions for the alternative Gaussian model to replace the existing Gaussian model:

[0298]

[0299] in, They represent the ages of the existing Gaussian model and the alternative Gaussian model respectively, which can also be understood as the number of times the model has been updated.

[0300] That is to say, only when the age of the alternative Gaussian model exceeds that of the existing Gaussian model will the alternative model replace the existing model, that is, the more times it appears, the greater the possibility of the background. Fig.14b The probability distribution curve of the double-single Gaussian model is shown. The solid line in the figure corresponds to the existing Gaussian model, and the dotted line corresponds to the backup Gaussian model. By comparison Fig.14a and Fig.14b It can be seen that for background pixels with a grayscale value of 1 and foreground pixels with a grayscale value of 2.5, for the existing Gaussian model, background pixels with a grayscale value of 1 will be determined as background points, and foreground pixels with a grayscale value of 2.5 will be determined as foreground points, so as to effectively solve the problem of the single distribution Gaussian background mode.

[0301] As an example, Fig.15 , a schematic diagram of a process for detecting motion regions based on a dual-single Gaussian model provided by an embodiment of the present application is shown in FIG. 1 , wherein, during initialization, both the existing Gaussian model and the candidate Gaussian model of the dual-single Gaussian model have an initialized mean and variance. Fig.15 As shown in , for a frame of image (the input image shown in the figure), the detection process may include:

[0302] For the input image, firstly, based on the conditions for being included in the existing Gaussian model and the conditions for being included in the alternative Gaussian model (the potential Gaussian model shown in the figure) described in the previous article, model matching is performed to determine the Gaussian model currently used, and based on the determined Gaussian model, the updated mean, variance and model age corresponding to the image are determined. After that, the Gaussian distribution probability value corresponding to the pixel point or image block of the image can be determined based on the brightness information of the image, as well as the updated mean and variance. Based on the probability value and the above-mentioned threshold T, it can be determined whether the pixel point or image block is the foreground or background.

[0303] As an example, take the 5-frame continuous image sequence described in the previous text as an example, combined with Fig.15The flowchart shown in further illustrates the method of determining the foreground image area of ​​the first frame image among the five frames of images based on the five frames of images. Specifically, for an image block a at the same position in the five frames of images, first determine the model to which the image block a in the first frame image belongs. Assuming it is an existing Gaussian model, the mean, variance and age of the existing Gaussian model are updated according to the single Gaussian model update step. For the image block a in the second frame image, it is also necessary to first determine the model to which it belongs. If it is classified into the existing Gaussian model, the mean, variance and age of the existing Gaussian model are continued to be updated. If it is classified into the alternative Gaussian model, the mean, variance and age of the alternative Gaussian model are updated. Of course, in the updating process, it is also necessary to determine whether to exchange the two (model exchange shown in the figure) based on the age of the existing Gaussian model (the existing age shown in the figure) and the age of the alternative Gaussian model (the potential age shown in the figure). The above method is repeatedly executed until the mean and variance of the Gaussian model corresponding to the image block a in the fifth frame image are obtained, and the mean and variance are used as the mean and variance of the final Gaussian model corresponding to the first frame image, which are used to determine whether the image block a in the first frame image is a foreground area, or to determine whether each pixel in the image block a in the first frame image is a foreground pixel.

[0304] In practical applications, after obtaining the mask image of the image (ie, the foreground image area), image processing methods such as erosion and dilation can be used to eliminate detected noise points to obtain a more accurate mask image.

[0305] Fig.16 A schematic diagram of the effect of determining the mask image in an image based on the solution provided in an embodiment of the present application is shown in the figure. As shown in the figure, in the schematic diagram, 5 frames of continuous adjacent images are used to obtain the mask image of the first frame image (the image on the right side of the arrow in the figure) through motion mask detection. The white area in the mask image is the mask area.

[0306] For a frame of image in a video, after the foreground image region of the frame of image is determined, the optical flow information of the image can be calculated based on the region of the frame of image, and the score of the image can be determined based on the optical flow information.

[0307] It can be seen that when calculating the optical flow of an image based on the image foreground area, if the image foreground area is obtained using the above-mentioned method of determining the image foreground image area provided in the embodiment of the present application, the optical flow information calculated at this time can reduce the influence of the slight offset between images (motion compensation error) and the brightness deviation between images caused by ISO automatic adjustment on the final detection result. Of course, it can be seen from the foreground description that when calculating the optical flow, the existing method of determining the foreground image area can also be used.

[0308] After determining the optical flow information of the image, the motion state representation information of the image can be determined based on the image and the optical flow information of the image, thereby determining the video segment where the event occurred in the video to be processed based on the motion state representation information. The following is an explanation of the centralized optional method for determining the motion state representation information of the image provided by the present application.

[0309] In an optional embodiment of the present application, for a frame of image, based on at least one of brightness information and optical flow information of the frame of image, determining the motion state representation information of the frame of image includes at least one of the following:

[0310] Determine first motion state representation information of the frame image based on the optical flow information of the frame image;

[0311] Based on the brightness information of the frame image and the optical flow information of the frame image, image features of the frame image are extracted, and based on the extracted image features, second motion state representation information of the frame image is obtained.

[0312] For the convenience of description, the motion state representation information will be described below in terms of image scores. Accordingly, the first motion state representation information is the first image score, and the second motion state representation information is the second image score.

[0313] Among them, the specific method of determining the score of the first image based on the optical flow information can refer to the description of the optical flow information part in the previous article, that is, the optical flow value of each pixel point can be obtained based on f=|f_x|+|f_y|, and the optical flow value of each pixel point can be sorted in ascending order, and the optical flow value of the confidence interval is selected to find the average, which is the result of scoring the possibility of frame motion, that is, the first image score.

[0314] As for the method of determining the score of the second image, deep learning is used to implement it. With the rapid development of deep learning technology, various neural networks are increasingly used to solve practical problems. For example, the widely used convolutional neural networks and recurrent neural networks are suitable for image tasks and speech tasks, respectively. In the process of implementing deep learning methods, performance has become a very important obstacle, especially for methods that require a lot of calculations such as video processing deployed on mobile devices. In view of the areas that need improvement in current deep learning methods, as an optional solution, the present application can make full use of the above-mentioned traditional methods to quickly extract the optical flow information of the image, and then combine the excellent feature representation capabilities of deep learning to calculate the score for each frame of the image. Among them, when a neural network is used to determine the score of the second image, the specific network structure of the neural network used is not limited in the embodiment of this application and can be selected according to actual needs.

[0315] The neural network model may include a first network for extracting image features and a second network for determining motion state representation information of the image. Accordingly, for a frame of image, the second motion state representation information of the frame of image is obtained through the neural network model based on the brightness information of the frame of image and the optical flow information of the frame of image, including:

[0316] Based on the brightness information of the frame image and the optical flow information of the image, an image feature of the frame image is obtained through a first network;

[0317] Based on the image features of the frame image, motion state representation information of the frame image is obtained through the second network.

[0318] Among them, the specific network structure form of the first network and the second network mentioned above is not limited in the embodiment of this application and can be configured according to actual application requirements. The first network can be called SMFN (single branch motion feature extraction network), the input of which includes the brightness information and optical flow information of the image, and the output is the image feature. The second network can be called TSMP (Time Series Motion Possibility) network, and the image features of each frame image of the video to be processed are input into the network to obtain the score of each frame image.

[0319] As an optional solution, the first network may include at least one layer of depth-wise separable convolutional module.

[0320] Optionally, the second network may be a neural network based on LSTM (Long short term memory).

[0321] Specifically, when using brightness information and optical flow information to determine the second image score of an image, the single-channel grayscale image of the image and the dual-channel optical flow (motion images of the optical flow in the x and y directions) can be composed of a three-channel input. Among them, if the optical flow used is the optical flow obtained based on the mask area (that is, the optical flow may contain implicit mask information), since only the optical flow of the foreground part is calculated at this time, in order to ensure the consistency of the size of the optical flow image and the grayscale image, the rest of the optical flow channel can be filled with 0 values. This also brings an additional benefit, which is to implicitly send the position of the foreground area to the neural network model, so that the model can better learn the image information of the foreground area and improve the subsequent detection effect.

[0322] As an optional solution, the optional solution of the present application adopts depthwise separable convolution in the design of convolutional network. A depthwise separable convolution module can split ordinary convolution into depthwise (spatial depth) convolution and pointwise (channel) convolution. Through the depthwise separable convolution module, the amount of calculation can be greatly reduced when extracting image features.

[0323] Specifically, the calculation of traditional convolution is to multiply each convolution kernel with each feature map bit by bit and then add them together, and the calculation amount is D F1 *D F2 *D K *D K *M*N, where D F1 and D F2 Indicates the input feature map size, specifically the width and height of the feature map, D K is the convolution kernel size, M is the number of input channels, and N is the number of output channels. For depthwise separable convolution, firstly, bitwise multiplication is performed according to the input channels, and the number of channels does not change at this time; then the result obtained in the first step is used to perform traditional convolution operation using a 1*1 convolution kernel, and the number of channels can be changed as needed. Depthwise separable convolution is used, and the amount of calculation is D K *D K *M*D F1 *D F2 +1*1*M*N*D K *D K , compared with ordinary convolution, the amount of calculation is greatly reduced.

[0324] Through depth-wise separable convolution, the amount of computation is reduced When D K = 3, the computational complexity of depthwise separable convolution is 8 to 9 times less than that of traditional convolution. Therefore, in practical applications, a multi-layer convolutional network can be designed by stacking the above depthwise separable convolution structure to extract the features of the input image and then obtain the image score based on the extracted features.

[0325] As an example, assuming that the size of a frame of the video to be processed after preprocessing is 160×160, when performing feature extraction, the initial input size of the convolution structure is 160×160×3, where 160×160 is the image size and 3 is the number of input channels, namely the grayscale image and the optical flow images in two directions. As an optional structure, feature extraction of the input image can be achieved through the convolution structure shown in Table 1:

[0326] Table 1

[0327]

[0328] Specifically, the parameters shown in the first column of Table 1 are the structure type and convolution step of the convolution network, where Conv represents ordinary convolution. When the convolution kernel size is 1×1, Conv is pointwise convolution, Conv dw represents depthwise convolution, S1 and S2 represent convolution step sizes of 1 or 2 respectively, Avg Pool represents average pooling, and 3× in the first column represents 3 identical structures cascaded in sequence. The parameters shown in the second column of Table 1 are convolution parameters or pooling parameters. For Conv, the first two data of the convolution parameter represent the convolution kernel size, the third value represents the number of input channels, and the fourth value represents the number of output channels. For example, the convolution structure of 3×3×3×32 has a convolution kernel size of 3×3, an input channel number of 3, and an output channel number of 32; for Conv dw, the first two data of the convolution parameter represent the convolution kernel size, and the third value represents the number of input channels. For AvgPool, the pooling parameter is the number of element points corresponding to one pooling when 5×5 is average pooling. The parameters shown in the third column of Table 1 are the input feature map sizes of each layer structure. Among them, the above convolution structures shown in Table 1 are cascaded once in the order from top to bottom in the table. For an image with an initial input size of 160×160×3, after completing feature extraction through the above structure, a 1×1×512 feature map can be obtained, that is, a 512-dimensional column vector.

[0329] For each frame image in the video, after obtaining the image features of each image, the image score of each frame image can be obtained based on the features. The specific network structure of the neural network model for predicting the image score based on the extracted features is not limited in the embodiments of the present application.

[0330] As an example, Fig.17 A structural schematic diagram of a neural network model for scoring each frame image provided by an embodiment of the present application is shown in the figure. As shown in the figure, the neural network model may include a convolution structure (i.e., a first network) for image feature extraction. The convolution structure may specifically adopt a depth-separable convolution structure. A TSMP network is connected after the convolution structure, such as a score prediction structure based on an LSTM network. As an example, as shown in the figure, the prediction structure may include a LSTM network, a fully connected layer, and an output layer cascaded in sequence, wherein the output layer may adopt a sigmoid activation function, and the output of the output layer may be used as the image score.

[0331] Specifically, for a frame of image (the image at time t is taken as an example in this example), the grayscale image of the frame of image (the first image from top to bottom on the left) and the optical flow image (the third image on the left, the optical flow image in this example is fused with mask information, that is, the optical flow image obtained based on the mask area (the second image on the left is the mask image)) are spliced ​​as input information and input into the convolution structure. The network based on the depthwise separable convolution structure is used to extract the feature map of the frame of image, as shown in the figure t, (the dotted lines t-1 and t+1 in the figure represent the feature maps corresponding to the previous frame and the next frame, respectively. The image processing method at time t is also applicable to other frame images). For a frame of image, the 512-dimensional feature obtained above is For example, these features can be input into the LSTM network, and a layer of LSTM containing 512 hidden nodes can be used to process the above series of CNN features to obtain the output of 512-dimensional features, where the output of the 512-dimensional features can be input into the fully connected layer structure containing 512 hidden nodes, and the fully connected layer will process it again and output a value, and finally input this value into the sigmoid activation function to obtain the probability of whether the image is an event, that is, the score of the frame image. As shown in the figure, Pt represents the probability of the frame image, that is, the score. Similarly, when processing the image at time t-1 or time t+1, the score Pt-1 of the image at time t-1 and the score Pt+1 of the image at time t+1 can be obtained. Using the method in this example, the score of each frame image in the video to be processed can be obtained based on the model output.

[0332] It is clear to those skilled in the art that when using a neural network model to predict image scores, it is necessary to pre-train the neural network model based on training samples, and use the trained model to predict image scores. Wherein, during training, the training samples may include each sample video, and each frame image of the sample video corresponds to a labeling score. Optionally, the labeling result may include 1 or 0. If an event exists in a frame image, the labeling result may be labeled as 1, and if not, it may be labeled as 0. When the model is trained based on each sample video, the model outputs the prediction score corresponding to each frame image of the sample video. For example, in the above-mentioned LSTM-based neural network model, for each sample video, the model can output the prediction probability value of each frame in the video, and the probability value can be used as the prediction score. Based on the prediction score and labeling result of each frame image of each sample video, the model is continuously trained until the loss function of the model converges, so that the prediction result of the model approaches the labeling result. As an optional method, the loss function can use binary cross entropy as the loss function, and its formula can be expressed as:

[0333]

[0334] Where n represents the number of sample images, t[i] represents the annotation result of sample image i, and o[i] represents the prediction score corresponding to image i.

[0335] After determining the image score of each frame of the video to be processed, the video segment in which the event occurs in the video to be processed can be determined based on the image score of each frame of the video. Wherein, when the image score includes a first image score and a second image score, the final score of the image can be obtained based on the two scores of each frame of the image, such as by weighted summing or other processing methods of the first image score and the second image score to obtain the final score.

[0336] In an optional embodiment of the present application, for any one of the at least one frame of images, determining the motion state representation information of the frame of image based on the motion features of the frame of image includes:

[0337] Based on the motion features of the frame image, the motion state representation information of the frame image is determined through a neural network.

[0338] Optionally, the motion state characterization information can be represented by an image score. The neural network used to determine the motion state characterization information of an image can be called a TSMP (Time Series Motion Possibility) network, wherein the specific network structure of the network is not limited in the embodiment of the present application, such as a LSTM-based network, where the motion features of each frame of at least one frame of image (output features of the MF network) are input into the TSMP to obtain the score of each frame of image.

[0339] As an alternative, Fig.18a and Fig.18b FIG. 1 shows a schematic diagram of the principle of determining an image score by a neural network provided by the present application. In this example, the image is a grayscale image, such as Fig.18a and Fig.18bAs shown in , for a frame of image, the input of the MF network includes the grayscale image and the optical flow image (optical flow information) of the image. The grayscale image is extracted through the MF network to obtain the motion features of the image. Specifically, the MF network includes a semantic feature extraction network (semantic network, also called spatial network), a motion feature extraction network (motion network) and a global pooling feature extraction network (global pooling). The input of the semantic network is the grayscale image, and the semantic features (spatial features) of the image are extracted. The input of the motion network includes the optical flow image and the semantic features, and the motion features of the image are extracted. In the process of feature extraction, the semantic features and motion features are spliced ​​so that the two types of information can better interact with each other, thereby obtaining better motion features. The input of global pooling is the optical flow image of the image, which can be the optical flow information of the motion area of ​​the image, or the optical flow value in the optical flow information of the motion area, which is sorted in order from small to large and is located in a set confidence interval, such as the optical flow whose optical flow value is in the range of 60% to 90% after sorting, and the global optical flow feature is obtained through global pooling. The MF network obtains the final motion features of the image by fusing the motion features extracted by the motion features and the global optical flow features. The image motion features extracted by the MF network are input into the TSMP network to obtain the image score (motion score), as shown in Fig.18a The Pt shown in the figure represents the score of the image at time t, P t-n is the score of the image at time tn, P t+n is the score of the image at time t+n, such as Fig.18b P shown in t-2 is the score of the image at time t-2, P t+2 is the score of the image at time t+2, and the ellipsis represents the process of obtaining the scores of other frames of images using the same processing method. Fig.18b The image at time t (time stamp t shown in the figure) is used as an example for schematic explanation.

[0340] As can be seen from the description of the various optional embodiments of the present application, the present application provides a variety of optional methods for determining the motion state representation information of an image. The principle of each method includes extracting image features / motion features of an image, and determining the motion state representation information of the image based on the extracted features. The specific implementation can be achieved through a neural network. One of the methods (such as Fig.17 The example shown in FIG. 1 can be to input the image and the optical flow information of the image into the SMFN to obtain the image features, and based on the features, the TSMP network obtains the image score. Another method (such as Fig.18a and Fig.18bThe example shown in the figure can be to input the image and its optical flow information into TMFN, extract semantic features through one branch of TMFN, and extract motion features through another branch, and then use TSMP network to obtain image scores based on the motion features extracted by TMFN. The specific network structure of TSMP network in different schemes can be the same or different.

[0341] In an optional embodiment of the present application, determining a video segment in which an event occurs in the video to be processed based on the motion state representation information of at least one frame of image may include:

[0342] Performing at least one interval merging on the motion state representation information of at least one frame of image to obtain a pyramid candidate event interval containing at least two levels;

[0343] Determine the motion state representation information of each candidate event interval based on the motion state representation information of each frame image corresponding to each candidate event interval;

[0344] Based on the motion state representation information of each candidate event interval, a video segment in which an event occurs in the video to be processed is determined.

[0345] When determining the motion state representation information of an image, although motion compensation and two single Gaussian models based on image blocks can be used for modeling and other processing methods. But it is inevitable that there will still be certain noise and errors, as well as interference from irrelevant background factors. In addition, in actual scenes, there may be multiple events in the video to be processed (such as a 10-second video). In order to support multiple events, integrate timing information, suppress noise, etc., the scheme of the embodiment of the present application can perform pyramid sampling on the motion state representation information of each image, that is, the motion representation state of each image is merged at multiple levels, and multiple levels of candidate event intervals in the shape of a pyramid are obtained, that is, the above-mentioned pyramid candidate event intervals. When merging, the interval of the upper level is obtained by merging the interval of the lower level according to the preset interval step.

[0346] Similarly, for the convenience of description, the motion state representation information will be explained in terms of image scores below. Accordingly, the pyramid candidate event interval is recorded as a pyramid score interval, a candidate event interval is recorded as a score interval, and the target candidate interval (described later) is recorded as a target score interval. The motion state representation information of the candidate event interval is the score of the interval, wherein, for an interval, the score of the interval can be specifically calculated based on the scores of each image contained in the interval. For example, the average of the scores of each image contained in the interval is obtained, and the tie value is the score of the interval.

[0347] As an illustrative example, Fig.19As shown in the example, a three-layer pyramid is shown. It is assumed that the bottom layer of the pyramid, i.e., the first layer, contains 4 image scores, i.e., the motion state representation information corresponding to 4 frames of images, and the preset step size during merging is 2. The second layer is obtained by merging every two image scores of the first layer to obtain two intervals. The score of the first interval of the second layer can be the average of the scores of the first two images of the first layer, and the second interval of the second layer can be the average of the scores of the last two images of the first layer, and so on.

[0348] Specifically, when performing pyramid sampling, for the first layer of the pyramid, that is, the first level, the score of each frame image can be obtained, that is, each interval corresponds to a score. For each subsequent level, the interval of the previous level can be merged according to a preset step size (equal to a set multiple) on the basis of the previous level. Based on this merging method, pyramid intervals of multiple levels can be obtained.

[0349] As an example, assuming that the video to be processed contains 300 frames of images, the 300 frames of images can be merged according to the preset step size to obtain a pyramid video segment of a set number of layers. If the step size is 2, the score interval of the first layer contains 300 intervals, each interval corresponds to the score of one frame of image, and the score interval of the second layer corresponds to 150 intervals, each interval corresponds to 2 frames of image, such as the first interval of the second layer for the score of the first frame of image and the second frame of image in 300 frames, the second interval corresponds to the score of the third frame and the score of the fourth frame of image, the third layer is merged on the basis of the second layer, and 75 intervals can be obtained, each interval corresponds to 4 frames of image, and so on, so as to obtain the score interval of the set number of layers.

[0350] After obtaining the score intervals of each level, it is possible to determine whether the video segment intervals corresponding to each score interval are intervals where events have occurred, based on the scores of each interval. Since each score interval is obtained by merging intervals, a high-level interval corresponds to at least two intervals of the next level of the level. Therefore, when determining whether the video segment intervals corresponding to each score interval are intervals where events have occurred, a coarse-to-fine granularity approach can be adopted, first determining the intervals where events have occurred in the intervals of the current level, and then judging the intervals corresponding to these intervals where events have occurred in the next level.

[0351] Intervals at different levels correspond to information of different scales. High-level intervals correspond to the global information of the video, which can reduce the impact of motion noise / error and automatically merge adjacent areas with smaller intervals. Low-level intervals correspond to local information of the video, with more detailed information, which is conducive to the selection of precise event boundaries. The judgment method from high level to low level and from coarse to fine can reduce the amount of calculation, make the detected events more robust to noise, and make the boundaries between each event interval more precise.

[0352] Optionally, based on the motion state representation information of each candidate event interval, determining a video segment in which an event occurs in the video to be processed includes:

[0353] For the candidate event intervals at each level, determine the target candidate interval at the current level;

[0354] Based on the motion state representation information of each target candidate interval at the current level, determining a video segment interval where an event occurs in the video segment intervals corresponding to each target candidate interval at the current level;

[0355] Each video segment interval where an event occurs determined in the lowest level is determined as a video segment where the event occurs in the video to be processed.

[0356] Optionally, for the candidate event intervals at each level, determining a target candidate interval at the current level includes:

[0357] For the highest level among the candidate event intervals, each candidate event interval of the current level is determined as a target candidate interval;

[0358] For the other levels except the highest level, the candidate event intervals in the current level corresponding to the video segment intervals in the previous level where events occur are determined as target candidate intervals.

[0359] After obtaining the score intervals of each level, the order from high level to low level can be used to detect whether the video segment intervals corresponding to each score interval of each level are intervals where events occur. For the current level, only the score intervals corresponding to the score intervals with event occurrence detected in the previous level can be detected. For example, the highest level is the 4th level, which contains 4 score intervals. It is determined that the video segment intervals corresponding to the 1st and 3rd score intervals of this level are video segment intervals where events occur, and the video segment intervals corresponding to the 2nd and 4th score intervals are video segment intervals where no events occur. When detecting the score intervals of the 3rd level, it can be that the intervals in the 3rd level corresponding to the 1st and 3rd score intervals of the 4th level are detected. If each score interval of the 4th level corresponds to two score intervals of the 3rd level, event detection can be performed only on the video segment intervals corresponding to the 1st and 2nd score intervals of the 3rd level and the 5th and 6th score intervals.

[0360] Based on the solution provided in the embodiment of the present application, a coarse to fine strategy can be adopted, based on the results of the previous layer of the pyramid (it can also be expanded to a certain interval, which will be described in detail later) as the initial value of the next layer of event detection. On the basis of effectively improving the detection efficiency, when there are multiple video segments corresponding to multiple events in the video to be processed, through this solution, multiple video segments where events occur can be detected separately, which is more in line with actual application needs.

[0361] In an optional embodiment of the present application, the method may further include:

[0362] For the highest level in the candidate event intervals, if the video segment intervals corresponding to the target candidate intervals of the current level contain adjacent intervals in the video segment intervals where the event occurs, the target candidate intervals corresponding to the adjacent intervals are merged; and / or,

[0363] For the levels other than the highest level, if each target candidate interval of the current level contains adjacent intervals, the adjacent target candidate intervals are merged; and / or,

[0364] Each target candidate interval of the current level is expanded to the adjacent candidate event interval.

[0365] In practical applications, for each event, the time of occurrence can be long or short. Accordingly, when detecting each video segment where an event occurs, the video segment should also be a long video segment or a short video segment. For this situation, in the scheme of the embodiment of the present application, if multiple (including) score intervals are all detected intervals corresponding to the occurrence of an event, it can be considered that these multiple score intervals are likely to correspond to the same event. Therefore, intervals can be merged and detection can be performed based on the merged intervals. As in the example described above, the highest level is level 4, which contains 4 scoring intervals. If it is determined that the video segment intervals corresponding to the 1st, 2nd and 4th scoring intervals of this level are video segment intervals where events occur, then the 1st and 2nd scoring intervals can be considered to be intervals corresponding to the same event, and these two scoring intervals can be merged into one interval. The first four scoring intervals of the 3rd level corresponding to the merged interval and the two intervals corresponding to the 4th scoring interval in the 3rd level are target candidate intervals of the 3rd level. For the 3rd level, the 4 target candidate intervals of this level corresponding to the above merged interval are adjacent intervals, then these four intervals can be merged, and event detection can be performed on the merged interval and the two intervals corresponding to the 4th scoring interval of the 4th level in the 3rd level respectively.

[0366] It can be understood that when performing event detection on the merged interval, the motion state characterization information of the merged interval can be determined based on the motion state characterization information of each target candidate interval contained in the merged interval, and then based on the motion state characterization information of the merged interval, it can be determined whether an event occurs in the video segment interval corresponding to the merged interval.

[0367] Regarding the expansion of event intervals, in practical applications, for example, to avoid missing frames in the event interval, when performing event detection on the video segments corresponding to each score interval of each layer, the score interval of the layer can be expanded. For example, assuming that the highest layer is the 4th layer, which contains 4 score intervals, if it is determined that the video segment interval corresponding to the 2nd score interval of the layer is a video segment interval where an event occurs, then the 3rd and 4th score intervals of the 3rd layer are the target score intervals of the third layer, and when detecting the 3rd and 4th score intervals of the 3rd layer, they can be expanded. Specifically, one interval can be expanded forward and backward, that is, the 3rd and 4th score intervals can be expanded to the 2nd to 5th score intervals, and event detection can be performed on each video segment interval corresponding to the 3rd layer based on the interval scores of the expanded 5 score intervals.

[0368] Among them, when expanding the interval, the specific number of intervals to be expanded can be configured according to actual needs, and can also be related to the sampling step of the above-mentioned pyramid sampling, that is, it can be determined according to the set step size during merging. Generally, the larger the set step size, the more intervals can be expanded.

[0369] For each target candidate interval, when determining whether the video segment interval corresponding to the target candidate interval is a video segment interval where an event occurs, the interval score corresponding to the target candidate interval can be compared with a set threshold. If the interval score is greater than or equal to the threshold, it is considered that an event has occurred in the corresponding video segment interval; otherwise, it is considered that no event has occurred.

[0370] As an example, Figures 20a to 20c FIG. 4 is a schematic diagram showing a principle of a method for detecting a video segment interval where an event occurs provided by an optional embodiment of the present application. Fig.20a As shown, level 0 is the first level, and an interval of this level (a rectangle in the figure, i.e., a candidate event interval) corresponds to a frame of image, an interval of level 1 is obtained by merging two intervals of level 0, and level 2 is obtained by merging two intervals corresponding to level 1. In this example, the numbers displayed in the intervals represent the interval scores. In this example, the score of each interval in level 1 is the average of the scores (schematic scores) of the two intervals in level 0 to which it corresponds, and the score of each interval in level 2 is the average of the scores of the two intervals in level 1 to which it corresponds. Optionally, the score threshold for determining whether an event has occurred is: image score average * 0.8 (set coefficient), and the image score average is 4 / 8 = 0.5.

[0371] In the candidate event intervals of each level, event detection is performed from high level to low level. When the event interval is not expanded, it corresponds to Fig.20a and Fig.20b , each interval of level 2 is a target candidate interval, the score of interval ① of level 2 is 0.25, which is less than the threshold, and no event occurs in the corresponding video segment interval. The score of interval ② of level 2 is 1.25, which is greater than the threshold, and an event occurs in the corresponding video segment interval. Therefore, the two intervals of level 1 corresponding to interval ② of level 2 (intervals ③ and ④ of level 1) are target candidate intervals of level 1. Similarly, the scores of intervals ③ and ④ of level 1 are 1 and 0.5 respectively, which are greater than the threshold. The four intervals of level 0 corresponding to these two intervals are target candidate intervals of level 0. Among these four intervals of level 0, three intervals have scores greater than the threshold. Therefore, the video segment in the to-be-processed video corresponding to the 5th to 7th frames of images of level 0 in this example is a video segment interval where an event occurs.

[0372] It should be noted that, in actual applications, as an optional scheme, when determining the video segment interval where an event occurs, if the video segment interval is determined directly based on the motion state representation information of the target candidate intervals at each level, then each level may adopt the above-mentioned threshold judgment method, that is, if the score of the interval is greater than or equal to the threshold, then an event occurs, otherwise, no event occurs, wherein the thresholds corresponding to each level may be the same or different. As another optional method, in the scheme of determining the video segment interval using a sliding window method provided later in this application, the above-mentioned threshold judgment method may be used only at the highest level, and at each level other than the highest level, the sliding window-based method described below may be used to determine the video segment interval where the event occurs at each level (described in detail later).

[0373] When the event interval is expanded, corresponding to Fig.20a and Fig.20b In this example, one interval is expanded for each of the adjacent intervals on both sides of the interval. Similarly, intervals ③ and ④ of level 1 corresponding to interval ② of level 2 are target candidate intervals of level 1. The target candidate interval is expanded. In this example, interval ③ of level 1 is expanded to the left by one interval, that is, the target candidate interval includes intervals ②, ③ and ④ after expansion. The interval scores of these three intervals are all greater than the threshold. The six intervals of level 0 corresponding to these three intervals are target candidate intervals of level 0. The scores of four intervals of these six target candidate intervals are greater than the threshold, and an event occurs in the corresponding video segment. Therefore, the video segment in the video to be processed corresponding to the 4th to 7th frame images is a video segment interval where an event occurs.

[0374] By comparison Fig.20b and Fig.20c It can be seen that by expanding the event interval, interval ② of level 1 will also be detected, avoiding event omission.

[0375] It can be understood that in practical applications, if the frames of images ultimately used for event detection are images that have been processed from the original video, for example, the video to be processed is a video stream containing key frames obtained by selecting key frames from the original video, or when calculating the optical flow information of the image, it is calculated every one or more frames, then the final existing video segment interval should be the video segment interval corresponding to the target candidate interval where the event occurs in the original video.

[0376] In an optional embodiment of the present application, determining a video segment in which an event occurs in the video to be processed based on the motion state representation information of at least one frame of image may specifically include:

[0377] Using at least two sliding windows of set sizes to detect the video to be processed, and determining initial motion state representation information of each window under each sliding window size based on motion state representation information of each frame image corresponding to each window under each sliding window size;

[0378] For each sliding window size, based on the initial motion state representation information of each window under the sliding window size, determine the final motion state representation information corresponding to the sliding window of the size;

[0379] Based on the final motion state representation information corresponding to the sliding window of each size, the video segment where the event occurs in the video to be processed is determined.

[0380] In an optional embodiment of the present application, for a sliding window of a certain size, determining the final motion state representation information corresponding to the sliding window of the certain size based on the motion state representation information of each window under the sliding window of the certain size includes:

[0381] Determine the motion state representation information of the video to be processed, determine the final motion state representation information of each window based on the initial motion state representation information of each window under the sliding window of the size and the motion state representation information of the video to be processed; determine the final motion state representation information corresponding to the sliding window of the size based on the final motion state representation information of each window;

[0382] and / or,

[0383] Based on the initial motion state representation information of each window under the sliding window of the size and whether each frame image corresponding to each window includes a designated image, the final motion state representation information corresponding to the sliding window of the size is determined.

[0384] First of all, it should be explained that the above-mentioned scheme of using at least two sliding windows of set sizes to detect the video to be processed provided in the embodiment of the present application can be applicable to the entire video to be processed, or it can be applied to the video segment intervals corresponding to the various score intervals described above, that is, the video segment corresponding to each score interval can be treated as a video to be processed and processed accordingly, wherein the score interval is the target score interval of other levels except the highest level, such as the highest level is the 4th level, a score interval of the 4th level corresponds to two score intervals of the 3rd level, assuming that the 1st score interval of the 4th level is determined to be the interval where an event occurs, then the 1st and 2nd score intervals of the third level are a target score interval, at this time, a target candidate interval is the interval that needs to be detected based on the sliding window, each score interval contained in the target score interval is processed as a frame of image, and the score of a score interval is processed as a frame of image.

[0385] That is to say, when the entire video to be processed is processed, the image that appears in the above detection process represents a frame of image in the video to be processed. If it is a target score interval (it can also be an interval that has been expanded or adjacent intervals merged), the image that appears in the above detection process corresponds to a score interval, and the above designated image is the designated score interval. For example, for the entire video, the designated image can be the frame of image with the highest score. For a target score interval, the designated image represents the interval with the highest score among the score intervals contained in the target score interval. Similarly, the score of the above video, for the entire video, can be calculated based on the image score of each frame of image contained in the entire video, and for the target score interval, it can be calculated based on each score interval contained in the target score interval.

[0386] In practical applications, for the pyramid intervals mentioned above, for the highest level score intervals, when performing event detection on the video segments corresponding to the score intervals of this layer, the above sliding window method can be used, or the sliding window method can not be used. Optionally, the detection of each score interval at the highest level can be configured with a detection threshold, and based on whether the score of each score interval is greater than the threshold, it is determined whether an event has occurred in the corresponding video segment interval. For each score interval at other levels, the above sliding window method can be used for detection. Of course, the detection of each target score interval at other levels except the highest level can also be carried out in the above threshold method, and the thresholds at each level can be different. Among them, the threshold setting can be an empirical value, or it can be determined based on the score of the entire video. For example, the threshold used can be: 0.8*the average value of the score of the entire video.

[0387] For each size of sliding window, the initial motion state representation information of a window under the sliding window of the size, i.e., the initial score, can be the average of the image scores of each frame image contained in the window (for the entire video), or the average of the scores of each score interval contained in the window (for the target score interval). When determining the final score of the window based on the initial score of a window of the sliding window of the size and the score of the video to be processed (or the target score interval), the final score can be obtained based on the difference between the initial score and the score of the video to be processed (or the target score interval). Of course, the weight of the initial score can also be determined based on the difference, and the initial score is weighted based on the weight to obtain the final score.

[0388] When determining the final score corresponding to the sliding window of the size based on the initial score of each window and whether the frame images (or score intervals) corresponding to the window contain the specified image (or the specified score interval), one method is to determine the score weight corresponding to each window based on whether the frame images corresponding to each window under the sliding window of the size are contained, if they are contained, a higher weight (such as a weight greater than 1) may be corresponding, and if they are not contained, a lower weight (such as a weight equal to 1) may be corresponding, and each window is weighted by the determined weight to obtain the final score of each window, and the highest score among the final scores of each window is determined as the final score corresponding to the sliding window of the size; another method is to select the highest score based on the initial score of each window, and based on whether the window with the highest score contains the specified image, if it is contained, a higher weight may be corresponding, and if it is not contained, a lower weight may be corresponding, and the selected highest score is weighted based on the determined weight, and the weighted result is determined as the final score corresponding to the sliding window of the size.

[0389] As can be seen from the foregoing description, the scheme of the embodiment of the present application can be directly applied to the video to be processed, or it can be applied to each score interval of each level determined based on the pyramid sampling method described in the foregoing. Specifically, when applied to each score interval, for any score interval of any level, the scheme can be used for event detection, that is, a sliding window corresponding to at least two set sizes can be used to detect the video interval segments corresponding to the score interval. When the sliding window detection method is applied to the score interval (such as the target score interval in the foregoing), each score interval corresponds to a video clip that may contain an event. After that, the sliding window can be used to detect each score interval that may contain an event to extract a more accurate event clip. Based on this method, one or more video clips in which an event may occur that may exist in the entire video to be processed can be detected.

[0390] For the convenience of description, the following description will be based on a sliding window detection scheme, which is applied to the entire video to be processed as an example.

[0391] When applying a sliding window, if a fixed-length sliding window is used, the calculation formula can be expressed as:

[0392]

[0393] Among them, Event represents the video segment where the event occurs in the video segment, that is, a more accurate segment interval, L is the total length of the video (total number of frames), for the pyramid candidate event interval, L can be expressed as the number of target candidate intervals, D is the window size (the number of frames the window contains), that is, the number of scores corresponding to each window, which is equal to the number of frames contained in the window, L-D+1 represents the number of sliding windows, X ij is the score of the jth frame image contained in the i-th window. Based on the principle of the above formula, the video segment corresponding to the window with the largest score among the L-D+1 windows is determined as the segment where the event actually occurred.

[0394] However, in practical applications, the above solution with a fixed window size has the problem that the detected fragments cannot match events of different lengths well. To address this problem, an optional approach is to use a variable-length window for detection, with the following formula:

[0395]

[0396] Among them, Dmin and Dmax represent the minimum window size and the maximum window size respectively, D k Represents the kth window size. Based on this scheme, for each window size, a segment with an event of corresponding length can be detected, that is, for each window size, the highest score among the sliding windows corresponding to the window size is taken as the segment containing the event corresponding to the window size, and finally, the mean score corresponding to the segment containing the event in the detection results corresponding to the windows of each size is multiplied by the window size to obtain the final score corresponding to the window of each size, and the segment corresponding to the maximum value among the final scores of multiple sizes is determined as the final segment containing the event.

[0397] Although this solution improves the accuracy of detecting events of arbitrary length by using sliding windows of different sizes, the implementation is rather mechanical and it is difficult to achieve good generalization performance. Fig.21a It is shown in Figure 1 that using sliding windows of different sizes can cause a problem, such as Fig.21aAs shown in the figure, the video clip corresponding to the interval T marked by the two vertical solid lines in the figure is the real target interval, that is, the real event interval (that is, the part corresponding to the label in the figure). If a variable-length sliding window is used directly, the smallest window will tend to be selected. This is because the smallest window often contains the largest score mean, such as the clip corresponding to the interval marked by the two vertical dotted lines in the figure (that is, the interval corresponding to the prediction / detection). To solve this problem, an optional approach is to add a weight that is positively correlated with the window size to the mean obtained by each size of sliding window, but this weight is difficult to select and is basically impossible to apply to all situations, which will cause the detected target area to be too large or too small.

[0398] The inventor of the present application has analyzed and studied the scoring curves of a large number of videos, such as Fig.21a and Figure 21b The score curve diagram shown in the figure, the horizontal axis represents each frame image, and the vertical axis represents the image score ( Figure 21b In the schematic diagram shown, the dotted line on the left side of the prediction interval coincides with the solid line on the left side of the interval corresponding to the label), and two statistical laws were found: ① Many event score curves approximately conform to a Gaussian distribution, so we can get the priori that "in most cases the point with the highest score should be included in the event interval", that is, the frame with the highest image score should be included in the video clip where the event is finally determined; ② Under normal circumstances, the mean of the event interval should be greater than the mean of the entire video.

[0399] For the first conclusion above, we can try to weight the area containing the maximum score to obtain a higher interval score. However, there is still a problem here: even if the image score of each frame is calculated by using the weighted sum of the score of the first image obtained based on the optical flow and the second score obtained by the neural network model, there are still some outliers that inevitably interfere with the final result. For this problem, as an optional solution, the embodiment of the present application determines the video clip where the event occurs in the video to be processed based on the motion state representation information of each frame image, which can specifically include:

[0400] Smoothing the motion state representation information of each frame image;

[0401] Based on the motion state representation information of each frame image after smoothing, a video segment in which an event occurs in the video to be processed is determined.

[0402] That is to say, before processing based on the sliding window, the score image of each frame image in the video can be smoothed to remove some unreasonable disturbances and increase the robustness of the event detection method provided in the embodiment of the present application. Among them, the specific method of smoothing is not limited in the embodiment of the present application. For example, a window of a set size can be used to smooth the scores of each image first, such as a window with a window size of 5 can be used to perform median filtering on the scores of each frame image of the video. Specifically, at this time, the 5 scores of every 5 frames of images in the video can be sorted in turn, and the score of the third frame image in the 5 frames of images is replaced with the score in the middle of the sorted 5 scores.

[0403] For the second conclusion, the existing variable-length sliding window applies a weight that is positively correlated with the window length to the mean in the entire window, which makes the lengths of the event intervals corresponding to windows of different sizes more uniform, or when the camera moves at a constant speed, the predicted event interval will be larger than the actual interval. In response to this problem, the above-mentioned scheme for determining the final score of each window based on the initial score of the window and the score of the video to be processed provided in the embodiment of the present application can use the incremental part of the window score mean (i.e., the initial score of the window) relative to the overall video mean as the basis to apply a weight, thereby ensuring that the mean of the target interval is greater than the overall mean. Corresponding to this scheme, the formula for determining the event interval can be expressed as:

[0404]

[0405] Where Mean is the mean of the entire video score (which can be obtained by averaging the image scores of all frames (which can be the scores after smoothing)), W max It refers to the additional weight that the interval can obtain when the maximum score falls within the interval, W max >1.

[0406] That is to say, for each size of window, when performing sliding detection based on the size of window, the mean of the scores of each frame image contained in each window is calculated. (i.e. the initial score of each window), based on the mean and Mean as the final score of the window, the window with the highest score among the final scores of the windows under this size is After the corresponding window, a weight D positively correlated with the window size can be configured for the score of the window k In addition, if the window with the highest score contains the frame with the highest score in the video, an additional weight W can be added to the window max If the highest-scoring window does not contain the highest-scoring frame in the video, there is no additional weight W. max, and finally the final score of the window of this size can be calculated, that is,

[0407] Based on the above method, the final scores corresponding to the windows of various sizes can be calculated, and the interval corresponding to the highest value in the final scores corresponding to the window sizes can be determined as the event interval. In this way, when the video segments (which can be called initial target segments) where events occur are determined based on the multi-level pyramid score intervals, one or more video segments where the events may occur can be detected more accurately. Wherein, when the sliding window detection method is adopted for each target score interval, the maximum sliding window size or the minimum sliding window size adopted can be determined according to the number of score intervals contained in the target score interval (which can be expanded and / or merged), such as, if the expanded target score interval contains 5 score intervals, the minimum sliding window size can be the number of the score intervals minus a set value, generally the minimum sliding window size can correspond to at least two score intervals, and the maximum sliding window size can be a value not greater than the number of the score intervals, that is, the number of score intervals corresponding to the maximum sliding window size does not exceed 5.

[0408] In addition, for each optional solution provided in this application, in actual implementation, taking into account the amount of calculation and the timeliness of calculation, as an optional method, the size of each frame image in the video can be reduced before processing, that is, event detection can be performed on a small-size image.

[0409] The following describes the coarse-to-fine event detection method and the sliding window-based event detection method provided by the embodiment of the present application in conjunction with a specific application scenario. It should be noted that in actual applications, these two methods can also be implemented separately.

[0410] Fig.22a An application scenario is shown in FIG. 1 . As shown in the figure, in this application scenario, a person raises his arm, makes a heart shape with his fingers, and then puts his arm down. An original video can be obtained by shooting with a mobile phone. The corresponding video to be processed can be obtained by selecting key frames. Assuming that the video to be processed contains 28 frames of images, the image score of each frame can be determined by any optional embodiment of the present application. By merging the image scores of each frame of the image for multiple times, the corresponding pyramid candidate event intervals can be obtained. Figure 22b As shown in , in this example, the pyramid interval has four levels, level 0 is the first level, and levels 1 to 3 are obtained by merging two intervals of the previous level, and the numerical values ​​in the levels represent the scores of the levels.

[0411] Assume that the threshold for determining whether an interval is an event interval is 0.34. Starting from level 3, the two intervals with scores of 0.625 and 0.750 are event intervals. These two intervals correspond to the four intervals with scores of 0.75, 0.5, 1 and 0.5 at level 2. The following takes level 2 as an example to illustrate the specific process of determining event intervals using a multi-size sliding window method. Fig.22c As shown, the process may include the following steps:

[0412] First, we can expand the interval, such as Fig.22c The extended area shown in FIG is expanded from 4 intervals to 6 intervals, that is, L = 6. Various sizes of sliding windows can be used for detection in these 6 intervals. The average score of these 6 intervals is In this example, the sliding window size range is [2,6]. Based on the motion state information of each window under each sliding window size, the intervals where events occur in these 6 intervals are determined. In this example, the formula for determining the event interval ignoring the weight is used for explanation, that is, the formula for determining the event interval is:

[0413]

[0414] In this formula, the dimension D k The window score of the sliding window (the final motion state representation information) is:

[0415]

[0416] For each size of sliding window, first determine the score of each window under the sliding window of this size (initial motion state representation information). Take the sliding window of size 2 as an example. The first window of this size contains the first and second intervals after expansion. The score of this window is: [(0+0.75) / 2-0.458]×2=-0.17. Then slide back one interval. The second window corresponds to the second and third intervals. The scores of each window under this size can be calculated in the same way. Among them, the window with the highest score is the two windows containing scores of 0.5 and 1. The scores of these two windows are 0.58. Then the score of the window corresponding to this size is 0.5, such as Fig.22d The window size shown in = 2, window fraction = 0.58.

[0417] For each size of sliding window, the above method can be used to calculate the window score corresponding to the sliding window of each size, such as Fig.22dIn the figure, the window scores corresponding to the sliding windows of sizes 2-6 are 0.58, 0.87, 0.91, 0.46 and 0 respectively. The intervals corresponding to the scores are shown by the dotted lines in the figure. Based on the above formula, the window score with the largest score is the window score of the sliding window size of 4. The intervals corresponding to the window score of this size are the four intervals with scores of 0.75, 0.5, 1 and 0.5 in the figure. Therefore, these four intervals are the event intervals corresponding to level 2.

[0418] For level 1 and level 0, the same method as above can be used to determine the event interval corresponding to level 1, and then determine the event interval corresponding to level 0. The video clip in the original video corresponding to the event interval corresponding to level 0 is the video clip where the event occurs.

[0419] In order to have a more systematic understanding of the various optional methods provided in the embodiments of the present application, the method is further described below with reference to examples. Fig.23 and Fig.24 The flowchart and principle diagram in an example are shown in FIG. The image sequence in the figure is the video to be processed. When the video is collected in real time by a mobile phone, the image sequence can be a video collected at a set time interval, such as a video collected every 10 seconds as the video to be processed. For the convenience of description, this example takes the video collected by the mobile phone as an example. Fig.23 and Fig.24 The video processing method in this example is described. The processing flow may include:

[0420] For an image sequence, such as Fig.24 The sequence shown in FIG. 1 contains 250 frames of images (not all of them are shown). The corresponding number under each frame of the image indicates the frame number of the image in the sequence. If the image is a color image, the color image can be converted to a grayscale image first, and the image size can also be reduced ( Fig.24 The grayscale resizing steps shown in ) are performed to reduce the amount of subsequent calculations and improve processing efficiency.

[0421] After completing the above preprocessing, the IMU of the mobile phone can be used to detect whether the mobile phone has unconscious movement when acquiring the image sequence. If so, ( Fig.23 If yes is set in , motion compensation is performed on each frame of the image sequence ( Fig.24 The motion compensation combined with IMU steps shown in the figure above can obtain the processed image sequence. If there is no unconscious movement ( Fig.23 If you click "no" in the pop-up window, you can go directly to the next step.

[0422] After that, motion mask detection can be performed, that is, the step of determining the foreground image area of ​​each frame image and obtaining the mask image. As described above, after determining the foreground image area of ​​each frame, image erosion and dilation can be used to eliminate the detected noise. Fig.24 The processing steps of mask detection (double Gaussian + erosion and dilation) shown in the figure can use the double-single Gaussian model to determine the foreground image area of ​​each frame, and perform erosion and dilation processing on the detected area, and use the processed area as the final foreground image area. Fig.24 The example shown in is a schematic diagram of the mask detection results for 5 frames of images, wherein the middle 3 frames of the 5 frames have mask areas (the actual mask area may be the area corresponding to the minimum circumscribed rectangle of the detected foreground image area), while the other two do not.

[0423] After completing the mask detection, the optical flow information of each frame image can be calculated based on the mask area of ​​each frame image, such as Fig.24 In the above method, only the optical flow of the mask area of ​​each frame image can be calculated (which can be a dense optical flow). In practical applications, if a frame image does not have a mask area, that is, the mask area is not detected, the calculation of the optical flow of the frame can be omitted. In the next step, the optical flow score of the frame image, that is, the first score, can be determined to be 0.

[0424] After completing the optical flow calculation steps, you can execute Fig.24 The step of obtaining the score shown in , which can be implemented in combination with the optical flow and neural network models. Specifically, based on the optical flow information of each frame, some maximum and minimum values ​​of the optical flow values ​​of each pixel point of each frame image are discarded (the optical flow values ​​of each point are sorted and the optical flow values ​​within the confidence interval are taken) and then the average is calculated to obtain the first image score of each frame image. For each frame image, the corresponding resized grayscale image and optical flow image of the frame image are input into the neural network model for predicting the second image score ( Fig.24 In the model based on convolution and long short-term memory network shown in ), the second image score corresponding to each frame image is obtained based on the model output. Then, the first image score and the second image score can be weighted to obtain the final score of each frame image, such as Fig.24 The score values ​​of each scoring step are obtained as shown in .

[0425] After obtaining the final score of each frame image, video segment selection can be performed based on the score of each frame, that is, the video segments where events occur in the video can be determined. Fig.24As shown in , a pyramid sampling method can be used to merge the scores of each frame image to obtain multiple levels of score intervals. Each score corresponds to a respective video segment interval, and multiple video clips that may contain events can be obtained. According to the order of the levels from high to low, for the highest level, the comparison result of the score of each interval with the threshold can be used to determine the interval where the event occurs. For each target score interval of each level except the highest level (which can be the target score interval after merging adjacent target score intervals, or the target score interval after expansion), the event detection method based on sliding window described above can be used to obtain the detection result of the video segment where the event occurs in the video (which can be referred to as the event segment for short). After obtaining the event segment, the image stream in the event segment can be stored as a video.

[0426] Fig.25a and Fig.25b A schematic flow chart of a solution for determining a video segment in which an event occurs in a video provided in another example of the present application is shown in FIG. Fig.25a and Fig.25b As shown in Fig.25a The image sequences and Fig.25b The frame sequence in is the original video. For the original video, key frames can be selected first, and the selected key frames are used as the video to be processed. Before or after the key frames are selected, each frame image of the video or the selected key frame image can be preprocessed ( Fig.25a The image preprocessing in the video to be processed may include graying, denoising, etc., or the selected video frame may be preprocessed before determining whether the selected video frame is a key frame. As shown in the figure, for each frame image in the video to be processed, image blur denoising and motion compensation (blur denoising + motion compensation) processing may also be performed. For example, if the video acquisition device has unconscious movement of the user when capturing the original video, motion compensation processing may be performed on each frame image in the video to be processed.

[0427] Then, motion region detection, i.e., motion mask detection, is performed on each frame image to determine the motion region of each frame image (the dotted area in the figure). For each frame image, the dense optical flow of the frame image is calculated based on the motion region of the frame image and the next frame image of the frame image ( Fig.25a Optical flow generation with motion mask as shown in Fig.25bAs shown in the figure, if there is no moving area in the image, the amount of calculation will be greatly reduced, and the optical flow information of the frame image is 0. As can be seen from the previous description, when calculating the optical flow information of the image, for the current frame image and the next frame image of the image, only the optical flow information of the frame image can be calculated, such as the optical flow information of the image at time t, time t+2, time t+4, etc. Afterwards, based on the grayscale image and optical flow information of each frame image, the image score of each frame image (corresponding to Fig.25a and 25b Then, the event interval (corresponding to Fig.25a The event segment in the original video is selected to determine the video segment where the event occurs. Optionally, after the event segment is determined, the image stream in the time period can be stored as a video.

[0428] Based on the video processing solution provided in the embodiment of the present application, it is possible to conveniently and effectively detect video clips in which events occur in the video, thereby providing technical support for recording, storing or transmitting videos based on event triggering mechanisms. From the description of each optional embodiment above, it can be seen that compared with the prior art, the solution provided in the embodiment of the present application has at least the following improvements in technical implementation:

[0429] (1) Use IMU to determine the type of camera movement and perform motion compensation for unconscious camera movement.

[0430] (2) By detecting the changes in image brightness, the motion mask of the image is calculated.

[0431] (3) For areas where the motion mask has values, the optical flow is further calculated.

[0432] (4) Score each frame of the image based on the optical flow information to obtain the possibility of motion for each frame of the image.

[0433] (5) Find the time period when the event occurs based on the motion probability time series.

[0434] (6) If an event occurs, the image stream within the corresponding time period is recorded and stored.

[0435] Accordingly, the solution provided in the embodiment of the present application has at least the following beneficial effects:

[0436] (1) The “event camera” working mode is realized by using traditional camera sensors (such as mobile phone camera sensors), which enables the detection of video clips where events occur.

[0437] (2) This method detects events based on image frames, reducing the reliance on data and making the event detection method more universal. Moreover, for events, we do not need to know the corresponding semantic information. For commonly used electronic devices such as mobile phone cameras, we only need to know whether a change event occurs.

[0438] (3) In the scoring stage (i.e., determining the image score (a representation of the image motion state information)), the network model can also be used to make full use of the image and optical flow information. Since semantic information is not required, a relatively shallow network can be designed. Shallow networks have the characteristics of small model, fast speed, few parameters, and few training samples.

[0439] (4) In order to deal with the mobility of electronic devices, IMU information can be added for judgment. Motion compensation is used to remove the impact of unconscious movement of the mobile phone. The impact of motion compensation errors is also considered when building the model (dual-SGM (dual-semi-global matching) uses image blocks for modeling), and the size of the optical flow value can be used to eliminate small disturbances.

[0440] (5) In the optional solution of the present application, a simpler Gaussian model can be used to detect changed pixels, and these changed pixels are used as masks to calculate the optical flow values, thereby reducing the amount of optical flow calculation.

[0441] (6) In order to detect the occurrence of multiple events, the present invention uses a pyramid to extract the event interval. In order to extract the event interval more accurately, the present invention refines the result boundary based on the pyramid and the sliding window. Since the mainstream variable-length sliding window only uses the size information of the window and does not use the characteristics of the image itself, it is difficult to set a weight to meet the requirements of all images. In order to solve this problem, the present invention uses the mean and maximum information of the image score when calculating the score of each window to obtain a more reasonable result.

[0442] Based on the same principle as the method provided in the embodiment of the present application, the embodiment of the present application also provides a video processing device, such as Fig.26 As shown in , the video processing device 100 may include an optical flow information acquisition module 110, a motion feature extraction module 120, an event segment determination module 130 and a video processing module 140, wherein:

[0443] An optical flow information acquisition module 110 is used to acquire optical flow information of at least one frame of an image in a video to be processed;

[0444] A motion feature extraction module 120, configured to extract motion features of at least one frame of image based on at least one frame of image and optical flow information of at least one frame of image;

[0445] An event segment determination module 130 is used to determine a video segment in which an event occurs in the video to be processed based on motion features of at least one frame of image;

[0446] The video processing module 140 is used to process the video to be processed accordingly according to the video segment where the event occurs.

[0447] Optionally, for any frame image of the at least one frame image, when the motion feature extraction module 120 extracts the motion feature of the frame image based on the frame image and the optical flow information of the frame image, it is configured to:

[0448] Based on the frame image, extracting semantic features of at least one level of the frame image through a plurality of cascaded first feature extraction layers;

[0449] Based on the optical flow information of the frame image, extracting at least one level of motion features of the frame image through a plurality of cascaded second feature extraction layers;

[0450] Among them, at least one second feature extraction layer fuses the motion features and semantic features of the corresponding level and outputs them.

[0451] Optionally, the number of output channels of the first feature extraction layer is smaller than the number of output channels of the second feature extraction layer of the corresponding level.

[0452] Optionally, when at least one second feature extraction layer fuses the motion features and semantic features of the corresponding level and outputs them, it is used to:

[0453] At least one second feature extraction layer fuses the motion features and semantic features of the corresponding level to obtain a fused feature;

[0454] Determine the weight information corresponding to the fusion feature through the weight determination network;

[0455] According to the weight information, the fusion features are weighted to obtain the weighted fusion features;

[0456] Output weighted fusion features.

[0457] Optionally, the weight information includes first weight information of the motion feature and second weight information of the semantic feature;

[0458] The weight determination network performs weighted processing on the fusion features according to the weight information to obtain the weighted fusion features, which is used to:

[0459] The fused features are weighted according to the first weight information and the second weight information to obtain weighted fused features.

[0460] Optionally, the device further comprises a global feature extraction module, which is used to:

[0461] Based on the optical flow information of at least one frame of image, obtaining a global optical flow feature of at least one frame of image;

[0462] The motion feature extraction module is used to fuse the extracted motion features of at least one frame of image with the global optical flow features, and obtain the motion features of at least one frame of image based on the fused features.

[0463] Optionally, for any frame image in the at least one frame image, when acquiring the optical flow information of the frame image, the optical flow information acquisition module 110 is used to:

[0464] Determine the motion area of ​​the frame image;

[0465] Based on the motion region in the frame image and the image region corresponding to the motion region in the next frame image of the frame image, dense optical flow calculation is performed to obtain the dense optical flow of the frame image; or,

[0466] Based on the frame image and a frame image subsequent to the frame image, a dense optical flow corresponding to the frame image is calculated, and the optical flow of the motion area part of the frame image in the calculated dense optical flow is used as the dense optical flow of the frame image.

[0467] Optionally, for any frame image of the at least one frame image, when determining the motion area of ​​the frame image, the optical flow information acquisition module 110 is used to:

[0468] The motion region of the frame is determined based on the brightness information of the frame image and brightness information of a set number of frame images after the frame image.

[0469] Optionally, when determining the motion area of ​​the frame image based on the brightness information of the frame image and the brightness information of a set number of frames of images after the frame image, the optical flow information acquisition module 110 is used to:

[0470] Dividing the frame image and a set number of frame images after the frame image into a plurality of image blocks respectively;

[0471] The motion area of ​​the frame image is determined based on the brightness information of each image block at the same position in the frame image and a set number of frame images after the frame image.

[0472] Optionally, when the optical flow information acquisition module 110 determines the motion area of ​​the frame image based on the brightness information of each image block at the same position in the frame image and a set number of frame images after the frame image, it is used to:

[0473] For at least one image block obtained by division, based on brightness information of the image block in the frame image and a set number of frame images after the frame image, determine the brightness mean and brightness variance of the Gaussian background model corresponding to the image block through the Gaussian background model;

[0474] Based on the brightness information of each pixel of the image block in the frame image, and the brightness mean and brightness variance of the Gaussian background model corresponding to the image block, determine whether each pixel in the image block is a moving pixel in the frame image or whether the image block is a moving area in the frame image.

[0475] Optionally, when the event segment determination module 130 determines that there is a video segment where an event occurs in the video to be processed based on the motion feature of at least one frame of image, it is configured to:

[0476] Determine motion state representation information of at least one frame of image based on motion features of at least one frame of image;

[0477] Based on the motion state representation information of at least one frame of image, a video segment in which an event occurs in the video to be processed is determined.

[0478] Optionally, when determining that there is a video segment where an event occurs in the video to be processed based on the motion state representation information of at least one frame of image, the event segment determination module 130 is configured to:

[0479] Performing at least one interval merging on the motion state representation information of at least one frame of image to obtain a pyramid candidate event interval containing at least two levels;

[0480] Determine the motion state representation information of each candidate event interval based on the motion state representation information of each frame image corresponding to each candidate event interval;

[0481] Based on the motion state representation information of each candidate event interval, a video segment in which an event occurs in the video to be processed is determined.

[0482] Optionally, when determining that there is a video segment where an event occurs in the video to be processed based on the motion state representation information of each candidate event interval, the event segment determination module 130 is configured to:

[0483] For the candidate event intervals at each level, determine the target candidate interval at the current level;

[0484] Based on the motion state representation information of each target candidate interval at the current level, determining a video segment interval where an event occurs in the video segment intervals corresponding to each target candidate interval at the current level;

[0485] Each video segment interval where an event occurs determined in the lowest level is determined as a video segment where the event occurs in the video to be processed.

[0486] Optionally, for the candidate event intervals at each level, when determining the target candidate interval at the current level, the event segment determination module 130 is configured to:

[0487] For the highest level among the candidate event intervals, each candidate event interval of the current level is determined as a target candidate interval;

[0488] For the other levels except the highest level, the candidate event intervals in the current level corresponding to the video segment intervals in the previous level where events occur are determined as target candidate intervals.

[0489] Optionally, the event segment determination module 130 is further configured to:

[0490] For the highest level in the candidate event intervals, if the video segment intervals corresponding to the target candidate intervals of the current level contain adjacent intervals in the video segment intervals where the event occurs, the target candidate intervals corresponding to the adjacent intervals are merged; and / or,

[0491] For other levels except the highest level, if each target candidate interval of the current level contains adjacent intervals, the adjacent target candidate intervals are merged; and / or

[0492] Each target candidate interval of the current level is expanded to the adjacent candidate event interval.

[0493] Optionally, when determining that there is a video segment where an event occurs in the video to be processed based on the motion state representation information of at least one frame of image, the event segment determination module 130 is configured to:

[0494] Using at least two sliding windows of set sizes to detect the video to be processed, and determining initial motion state representation information of each window under each sliding window size based on motion state representation information of each frame image corresponding to each window under each sliding window size;

[0495] For each sliding window size, based on the initial motion state representation information of each window under the sliding window size, determine the final motion state representation information corresponding to the sliding window of the size;

[0496] Based on the final motion state representation information corresponding to the sliding window of each size, the video segment where the event occurs in the video to be processed is determined.

[0497] Optionally, the device further includes a video to be processed acquisition module, which is used to:

[0498] Select video frames from the original video according to the set frame rate;

[0499] The key frames in the selected video frames are determined by repeatedly performing the following operations, and the video stream corresponding to the determined key frames is used as the video to be processed:

[0500] The scene change information between adjacent frames in the selected video frames is determined, and based on the scene change information, the selected adjacent frames are determined as key frames, or video frames are selected from the video frames between the adjacent frames.

[0501] Optionally, when the to-be-processed video acquisition module determines the selected adjacent frames as key frames based on the scene change information, or selects video frames from video frames between adjacent frames, it is used to:

[0502] If the scene change information is less than the change information threshold, the selected adjacent frame is determined as a key frame;

[0503] If the scene change information is not less than the change information threshold, a video frame is selected from the video frames between adjacent frames.

[0504] Optionally, the scene change information is the number of points satisfying a preset condition in the sparse optical flow corresponding to the selected adjacent frames;

[0505] The preset condition is that the optical flow in the horizontal direction is greater than a preset first threshold, and / or the optical flow in the vertical direction is greater than a preset second threshold.

[0506] Optionally, the device further includes a motion compensation module, which is used to:

[0507] Before obtaining the optical flow information of at least one frame of the video to be processed, determining the movement type of the video acquisition device of the video to be processed when acquiring the video to be processed;

[0508] If the movement type is unconscious movement of the user, motion compensation is performed on at least one frame of the video to be processed.

[0509] The device provided in the embodiment of the present application can implement at least one module among the multiple modules through an AI model. Functions associated with AI can be executed through a non-volatile memory, a volatile memory, and a processor.

[0510] The processor may include one or more processors. In this case, the one or more processors may be general-purpose processors, such as a central processing unit (CPU), an application processor (AP), etc., or pure graphics processing units, such as a graphics processing unit (GPU), a visual processing unit (VPU), and / or an AI-specific processor, such as a neural processing unit (NPU).

[0511] The one or more processors control the processing of input data according to predefined operating rules or artificial intelligence (AI) models stored in non-volatile memory and volatile memory. The predefined operating rules or artificial intelligence models are provided by training or learning.

[0512] Here, providing by learning means obtaining a predefined operating rule or an AI model with desired characteristics by applying a learning algorithm to a plurality of learning data. The learning can be performed in the device itself in which the AI ​​according to the embodiment is executed, and / or can be implemented by a separate server / system.

[0513] The AI ​​model may include multiple neural network layers. Each layer has multiple weight values, and the calculation of one layer is performed by the calculation result of the previous layer and the multiple weights of the current layer. Examples of neural networks include, but are not limited to, convolutional neural networks (CNNs), deep neural networks (DNNs), recurrent neural networks (RNNs), restricted Boltzmann machines (RBMs), deep belief networks (DBNs), bidirectional recurrent deep neural networks (BRDNNs), generative adversarial networks (GANs), and deep Q networks.

[0514] A learning algorithm is a method of using a plurality of learning data to train a predetermined target device (e.g., a robot) to enable, allow, or control the target device to make a determination or prediction. Examples of the learning algorithm include, but are not limited to, supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning.

[0515] Based on the same principles as the methods and devices provided in the embodiments of the present application, the embodiments of the present application also provide an electronic device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor is used to execute the method shown in any optional embodiment of the present application when running the computer program.

[0516] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method shown in any optional embodiment of the present application can be executed.

[0517] As an example, Fig. 27 A schematic diagram of the structure of an electronic device applicable to an embodiment of the present application is shown in FIG. Fig. 27 As shown, Fig. 27The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0518] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0519] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 27 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0520] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0521] The memory 4003 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the application code stored in the memory 4003 to implement the content shown in any of the above method embodiments.

[0522] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0523] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method performed by an electronic device, It is characterized in that include: Acquire first optical flow information of at least one frame of an image in a video, wherein the video includes a frame image sequence; Extracting motion features of the at least one frame of image based on the frame image sequence and the first optical flow information of the at least one frame of image; Determine, based on the motion features of the at least one frame of image, a first video segment in which an event occurs in the video, wherein the frame image sequence includes the first video segment; According to the first video clip, the video is processed accordingly; The step of extracting the motion features of the at least one frame of image includes: Extracting at least one level of semantic features of any first frame image in the frame image sequence via a first cascade of feature extraction layers; Based on the first optical flow information of the first frame of image, extracting at least one level of motion features of the first frame of image via a second cascaded feature extraction layer; The motion features and semantic features of the corresponding level are fused through at least one second feature extraction layer in the second cascade of feature extraction layers to provide fused features of the corresponding level.

2. The method according to claim 1, It is characterized in that A first number of output channels of the first cascaded feature extraction layer is smaller than a second number of output channels of the second cascaded feature extraction layer of the corresponding level.

3. The method according to claim 1, It is characterized in that The fusion of motion features and semantic features at corresponding levels includes: Determine first weight information corresponding to the fusion feature through a weight determination network; Weighting the fused feature according to the first weight information to obtain a weighted fused feature; Output weighted fusion features.

4. The method according to claim 3, It is characterized in that The first weight information includes the second weight information of the motion feature and the third weight information of the semantic feature; The weighting of the fusion features includes: The fused feature is weighted according to the second weight information and the third weight information to obtain a weighted fused feature.

5. The method according to any one of claims 1 to 4, It is characterized in that Also includes: Based on the first optical flow information of the first frame of image, obtaining a global optical flow feature of the first frame of image; Fusing the motion feature of the first frame image with the global optical flow feature to obtain a second motion feature; The step of determining the first video segment in which an event occurs in the video based on the motion feature of the at least one frame of image includes: Based on the second motion feature of the at least one frame of image, a first video segment in which an event occurs in the video is determined.

6. The method according to claim 1, It is characterized in that Obtaining the first optical flow information includes: Determining a motion region of a first frame image in the frame image sequence; Based on the motion region and an image region in a second frame image corresponding to the motion region, dense optical flow calculation is performed to obtain a dense optical flow of any frame image, wherein the second frame image is a next frame image corresponding to the first frame image; or, Based on the first frame image and the second frame image, a dense optical flow corresponding to the first frame image is calculated, and an optical flow of a moving area of ​​the first frame image in the calculated dense optical flow is used as the dense optical flow of the first frame image.

7. The method according to claim 6, It is characterized in that Determining a motion region of a first frame image in the frame image sequence includes: The motion region of the first frame image is determined based on the first brightness information of the first frame image and the second brightness information of a set number of frame images after the first frame image.

8. The method according to claim 7, It is characterized in that Determining a motion area based on the first brightness information and the second brightness information includes: Dividing the first frame image and the set number of frame images into a plurality of image blocks; The motion area of ​​the first frame image is determined based on first brightness information of an image block in the first frame image evaluated at a first position of the first frame image and second brightness information of an image block in each frame image of a set number of frame images after the first frame image evaluated at the first position.

9. The method according to claim 8, It is characterized in that Determine the motion area of ​​the first frame image, including: For at least one image block, based on first brightness information of the at least one image block in the first frame image and second brightness information of the at least one image block in a set number of frame images after the first frame image, determine a first brightness mean and a first brightness variance of a Gaussian background model corresponding to the at least one image block; Based on the third brightness information of the first pixel point of the at least one image block in the first frame image and the Gaussian background model, determine whether the first pixel point in the at least one image block is a moving pixel point in the first frame image or whether the at least one image block corresponds to a moving area of ​​the first frame image.

10. The method according to claim 1, It is characterized in that Identify the first video clip where the incident occurred, including: Based on the motion feature, determining motion state representation information of at least one frame of image in the video; The first video segment is determined based on the motion state representation information of the at least one frame of image.

11. The method according to claim 10, It is characterized in that The determining, based on the motion feature, motion state representation information of at least one frame of image in the video includes: For any frame image in the video, based on the motion features of the frame image, a neural network is used to determine the motion state representation information of the frame image.

12. The method according to claim 10 or 11, It is characterized in that The determining the first video segment based on the motion state representation information of the at least one frame of image includes: Performing at least one interval merging on the motion state representation information to obtain a pyramid candidate event interval containing at least two levels; Determining motion state representation information of each candidate event interval of each level in the at least two levels based on motion state representation information of each frame image corresponding to each level in the at least two levels; The first video segment is determined based on the motion state representation information of each candidate event interval in each level of the at least two levels.

13. The method according to claim 12, It is characterized in that The determining the first video segment based on the motion state representation information of the at least one frame of image includes: For the candidate event intervals at each level of the at least two levels, determining a target candidate interval at the current level; Determine, based on the motion state representation information of the target candidate interval at the current level, a video segment interval in which an event occurs in a video segment interval corresponding to the target candidate interval at the current level; The video segment where the event occurs determined in the lowest level is determined as the first video segment.

14. The method according to claim 13, It is characterized in that Determine the target candidate interval of the current level, including: For the highest level in the candidate event intervals, the candidate event interval of the current level is determined as the target candidate interval; For the other levels except the highest level, the candidate event intervals in the current level corresponding to the video segment intervals in which the events occurred in the previous level are determined as the target candidate intervals.

15. The method according to claim 13, It is characterized in that Also includes: For the highest level in the candidate event intervals, if the video segment interval corresponding to the target candidate interval of the current level contains an adjacent interval in the video segment interval where the event occurs, the target candidate intervals corresponding to the adjacent intervals are merged; and / or, For other levels except the highest level, if the target candidate interval of the current level contains adjacent intervals, the adjacent target candidate intervals are merged; and / or The target candidate interval of the current level is expanded to the adjacent candidate event interval.

16. The method according to claim 10 or 11, It is characterized in that The determining the first video segment based on the motion state representation information of the at least one frame of image includes: Using at least two sliding windows of set sizes to detect the video, and determining initial motion state representation information of each window under each sliding window size based on motion state representation information of each frame image corresponding to each window under each sliding window size; For each sliding window size, based on the initial motion state representation information of each window under the sliding window size, determine the final motion state representation information corresponding to the sliding window of the size; The first video segment is determined based on the final motion state representation information corresponding to the sliding window of each size.

17. The method according to claim 16, It is characterized in that For each sliding window size, the determining of the final motion state representation information corresponding to the sliding window of the size based on the initial motion state representation information of each window under the sliding window of the size includes: Determine the motion state representation information of the video, determine the final motion state representation information of each window based on the initial motion state representation information of each window under the sliding window of the size and the motion state representation information of the video; determine the final motion state representation information corresponding to the sliding window of the size based on the final motion state representation information of each window; and / or, Based on the initial motion state representation information of each window under the sliding window of the size and whether each frame image corresponding to each window includes a designated image, the final motion state representation information corresponding to the sliding window of the size is determined.

18. The method according to claim 1, It is characterized in that The video was obtained in the following way: Select video frames from the original video according to the set frame rate; The key frames in the selected video frames are determined by repeatedly performing the following operations, and the video stream corresponding to the determined key frames is used as the video: The scene change information between adjacent frames in the selected video frames is determined, and based on the scene change information, the selected adjacent frames are determined as key frames, or video frames are selected from the video frames between the adjacent frames.

19. The method according to claim 18, It is characterized in that Based on the scene change information, the selected adjacent frames are determined as key frames, or video frames are selected from video frames between adjacent frames, including: If the scene change information is less than the change information threshold, the selected adjacent frame is determined as a key frame; If the scene change information is not less than the change information threshold, a video frame is selected from the video frames between adjacent frames.

20. The method according to claim 18 or 19, It is characterized in that The scene change information is the number of points that meet preset conditions in the sparse optical flow corresponding to the selected adjacent frames; The preset condition is that the optical flow in the horizontal direction is greater than a preset first threshold, and / or the optical flow in the vertical direction is greater than a preset second threshold.

21. The method according to claim 1, It is characterized in that Before obtaining the first optical flow information of the video, it also includes: Determining a type of movement of a video capture device of the video when capturing the video; If the movement type is unconscious movement of the user, motion compensation is performed on at least one frame of the video.

22. The method according to any one of claims 1 to 4, 6 to 11, 18, 19 and 21, It is characterized in that The step of processing the video accordingly according to the first video segment includes: A second video segment is generated based on the first video segment.

23. An electronic device, It is characterized in that Including processors; The processor is configured to perform the method of any one of claims 1 to 22.

24. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 22 is executed.

Citation Information

Patent Citations

  • Travelling record video concentrating method based on learning

    CN103886089A

  • Traffic event detection method and system

    CN105809954A

  • Video splicing method based on adaptive key frame sampling

    CN105957017A

  • Action detection model based on convolutional neural network

    CN106650655A

  • Key frame selection method and system

    CN107135401A