Method for detecting moving objects based on multi-frame spatial attention mechanism

By employing a moving target detection method based on a multi-frame spatial attention mechanism, and utilizing attention gate networks and feature aggregation networks, the problem of poor performance of deep learning models in new video scenes is solved, achieving high-precision and efficient moving target detection.

CN117541854BActive Publication Date: 2026-11-27NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311443240.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-01
Publication Date
2026-11-27
Estimated Expiration
2043-11-01

AI Technical Summary

Technical Problem

Existing deep learning models perform poorly in new scene video detection, struggle to adapt quickly to complex scenes, and traditional methods suffer from issues such as empty targets and false targets.

Method used

A moving target detection method based on multi-frame spatial attention mechanism is adopted. The method uses a pre-trained model and performs secondary training. The attention gate network is used to perform spatial attention calculation on the features between different frames. Combined with feature extraction and aggregation networks, salient region features are generated.

Benefits of technology

While saving training costs and time, it significantly improves the accuracy and adaptability of moving target detection in new scene videos, and reduces false targets and voids.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117541854B_ABST
    Figure CN117541854B_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the technical field of computer vision, and disclose a moving target detection method based on a multi-frame spatial attention mechanism, which comprises the following steps: pre-training a pre-constructed detection model by using a preset first training set, wherein the pre-constructed detection model is composed of a feature extraction network, an attention gate network, a feature aggregation network and a foreground classification network; performing moving target labeling on part of video frames intercepted from a video to be detected to generate a second training set; freezing the feature extraction network, the attention gate network and the feature aggregation network, and performing secondary training on the pre-trained detection model by using the second training set; inputting the video to be detected into the secondary trained detection model to obtain a moving target detection result of the video to be detected, thereby realizing the concentration of limited attention on important information areas, obtaining better feature extraction and feature aggregation effects, and accurately detecting moving targets in a new scene video.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer vision technology, and in particular to a moving target detection method based on a multi-frame spatial attention mechanism. Background Technology

[0002] Moving target detection technology is an important research area in computer vision applications. This technology is widely used in fields such as natural disaster emergency response, intelligent traffic detection, human motion recognition, and security monitoring of major projects, and its application scope continues to expand with the development of computer and information technology. With the increasing demand for intelligent applications in society, moving target detection technology can provide data for further target detection, target tracking, and other vision tasks, enabling real-time monitoring of specific targets, improving the level of intelligence in various industries, and better serving social development.

[0003] Currently, the most commonly used moving target detection techniques are frame difference, optical flow, and background modeling. These three traditional methods can separate moving targets from the background image, thereby extracting the motion region in consecutive frames. However, due to the diverse types of videos that need to be detected, which may contain a lot of noise, excessively slow or rapid target motion, large contrast ratios, or changes in lighting, the detection results of these traditional methods may exhibit problems such as target holes and false targets, failing to meet the requirements of the detection task.

[0004] With the development of deep learning technology, an increasing number of computer vision tasks can be accomplished using deep learning, often with better results than traditional algorithms. Deep learning utilizes multi-layered neural networks to simulate the human brain's recognition and cognition processes, autonomously learning patterns and features from data, eliminating the need for manual design, and enabling end-to-end implementation of various computer vision tasks. Using deep learning for moving object detection achieves higher accuracy compared to traditional algorithms, better handling detection in complex scenes.

[0005] However, deep learning technology requires a large amount of data to pre-train the model, and there is limited room for improvement in detection accuracy. It performs poorly in detecting new video sequences that have not been trained, making it difficult to directly and quickly apply to the detection of moving targets in new scenes. Summary of the Invention

[0006] The purpose of this application is to provide a moving target detection method based on a multi-frame spatial attention mechanism. By performing secondary training, the detection model is adapted to new scenes. By using attention gates, limited attention is focused on important information regions to obtain better feature extraction and feature aggregation effects, thereby accurately detecting moving targets in new scene videos.

[0007] To address the aforementioned technical problems, embodiments of this application provide a moving target detection method based on a multi-frame spatial attention mechanism, comprising the following steps: pre-training a pre-constructed detection model using a preset first training set; wherein the pre-constructed detection model consists of a feature extraction network, an attention gate network, a feature aggregation network, and a foreground classification network; extracting a portion of video frames from the video to be detected for moving target annotation to generate a second training set; freezing the feature extraction network, the attention gate network, and the feature aggregation network, and using the second training set to perform secondary training on the pre-trained detection model; inputting the video to be detected into the secondary-trained detection model to obtain the moving target detection result of the video to be detected; wherein the attention gate network is used to perform spatial attention calculation on features between different frames to obtain salient region features.

[0008] Embodiments of this application also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described moving target detection method based on a multi-frame spatial attention mechanism.

[0009] Embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described moving target detection method based on a multi-frame spatial attention mechanism.

[0010] The moving target detection method based on a multi-frame spatial attention mechanism provided in this application extracts salient regions of features between different frames through an attention gate network. This reduces the overall size of the network model and saves resources while concentrating limited attention on important information regions, resulting in better feature extraction and aggregation. When performing moving target detection on a video, several frames are first manually labeled to generate a second training set for fine-tuning the foreground classification network of the detection model. This secondary training can, to some extent, address the problem of poor detection performance of deep learning models on new scene videos. Fine-tuning with a small number of samples is sufficient to achieve generalization and universality of the detection model, thereby significantly improving the accuracy of the detection model in moving target detection in new scene videos while saving model training costs and shortening training time.

[0011] In some optional embodiments, inputting the video to be detected into the retrained detection model includes: selecting n consecutive frames from the video to be detected, performing pixel value averaging on the n consecutive frames to obtain an estimated background frame; wherein n is an integer greater than 1; starting from the first frame of the video to be detected, using three consecutive frames from the video to be detected and the estimated background frame as input images, and sliding backward according to a preset step size until the entire video to be detected is input into the retrained detection model. Using consecutive frames and the estimated background frame as model input can further improve the adaptability of the detection model to the scene to which the video to be detected belongs, and further improve the accuracy of the detection model in detecting moving targets in new scene videos.

[0012] In some optional embodiments, the step of inputting the video to be detected into the detection model after secondary training to obtain the moving target detection result of the video to be detected includes: inputting the input image into the detection model after secondary training; the feature extraction network extracting features of the input image at three scales respectively; and inputting the four sets of features at each scale as a feature block into the attention gate network respectively; wherein, the three scales include a first scale, a second scale, and a third scale, the second scale being half of the first scale, and the third scale being half of the second scale; the attention gate network includes three attention gates, which respectively receive feature blocks at the first scale, the second scale, and the third scale; each attention gate extracts the salient region features of the received feature blocks, and inputs the feature blocks after extracting the salient region features into the feature aggregation network; the feature aggregation network concatenates the feature blocks after extracting the salient region features at different scales, and inputs the concatenated feature blocks into the foreground classification network; the foreground classification network outputs the moving target detection result based on the concatenated feature blocks. Feature extraction networks and attention gate networks extract features from input images at different scales, ensuring that the extracted features are scientific and comprehensive. Feature aggregation networks stitch together features from different scales, and then the foreground classification network outputs the detection results, effectively improving the speed and accuracy of moving target detection.

[0013] In some optional embodiments, the feature extraction network is composed of consecutive 3×3 convolutional layers and pooling layers, with a total of six convolutional layers and three pooling layers; the first pooling layer is placed after the first and second convolutional layers, and outputs feature blocks at the first scale, and is also connected to the third convolutional layer; the second pooling layer is placed after the third and fourth convolutional layers, and outputs feature blocks at the second scale, and is also connected to the fifth convolutional layer; the third pooling layer is placed after the fifth and sixth convolutional layers, and outputs feature blocks at the third scale; each convolutional layer and each pooling layer is followed by a ReLU activation function layer, and each pooling layer is followed by a BN normalization layer.

[0014] In some optional embodiments, the input image is three-channel. The attention gate uses a 1×1 convolutional layer to further extract features from each frame of the received feature block, reducing the number of channels to half. Spatial attention is calculated on the extraction results of adjacent frames, and the results are aggregated according to a preset ratio to obtain a single-channel salient region map. The single-channel salient region map is multiplied with each channel of the feature block to obtain a feature block with three channels after extracting salient region features. It is stipulated that the estimated background frame is adjacent to the third frame of the three consecutive frames. Each attention gate further extracts features from the feature block, focusing attention on important information. The aggregated single-channel salient region map, obtained according to a preset ratio, can effectively represent important information in the input image. Multiplication with each channel of the feature block yields an output with the original number of channels and unchanged scale, facilitating subsequent processing by the feature aggregation network.

[0015] In some optional embodiments, the feature aggregation network is composed of consecutive 3×3 deconvolutional layers and depooling layers, with a total of six deconvolutional layers and three depooling layers; the first deconvolutional layer receives the feature blocks after extracting salient region features at the third scale; the first depooling layer is disposed after the first and second deconvolutional layers, and the first depooling layer is also connected to the third deconvolutional layer; the third deconvolutional layer receives the feature blocks after extracting salient region features at the second scale, and concatenates the feature blocks after extracting salient region features at the second scale with the output of the first depooling layer; the second depooling layer is disposed after... After the third and fourth deconvolutional layers, the second depooling layer is also connected to the fifth deconvolutional layer; the fifth deconvolutional layer receives the feature block after extracting salient region features at the first scale, and concatenates the feature block after extracting salient region features at the first scale with the output of the second depooling layer; the third depooling layer is set after the fifth and sixth deconvolutional layers, and the third depooling layer outputs the concatenated feature block; each deconvolutional layer and each depooling layer is connected to a ReLU activation function layer, and each depooling layer is connected to a BN normalization layer.

[0016] In some optional embodiments, the foreground classification network consists of two sequentially connected 1×1 convolutional layers, a ReLU activation function layer, and a Sigmoid activation function layer. The first 1×1 convolutional layer receives the concatenated feature blocks, and the Sigmoid activation function layer outputs the moving target detection result.

[0017] In some optional embodiments, for each input image, the moving target detection result is a moving target detection result image, in which the pixel value of the region where the moving target is located is 1, and the pixel value of other regions is 0. The moving target detection result image is a binary image, which can intuitively show the position of the moving target. Attached Figure Description

[0018] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrative descriptions do not constitute a limitation on the embodiments.

[0019] Figure 1 This is a flowchart of a moving target detection method based on a multi-frame spatial attention mechanism provided in one embodiment of this application;

[0020] Figure 2 This is a schematic diagram of the structure of the detection model provided in one embodiment of this application;

[0021] Figure 3This is a flowchart illustrating, in one embodiment of this application, the input of the video to be detected into the detection model after secondary training;

[0022] Figure 4 This is a flowchart of an embodiment of the present application, in which the video to be detected is input into the detection model after secondary training to obtain the moving target detection result of the video to be detected;

[0023] Figure 5 This is a schematic diagram of the structure of a feature extraction network provided in one embodiment of this application;

[0024] Figure 6 This is a schematic diagram of the attention gate structure provided in one embodiment of this application;

[0025] Figure 7 This is a schematic diagram of the structure of a feature aggregation network provided in one embodiment of this application;

[0026] Figure 8 This is a schematic diagram of the structure of a foreground segmentation network provided in one embodiment of this application;

[0027] Figure 9 This is a comparison image of the input image and the moving target detection result image provided in one embodiment of this application;

[0028] Figure 10 This is a schematic diagram of the structure of an electronic device provided in another embodiment of this application. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to help readers better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.

[0030] The paper "A Deep Learning-Based Post-Processing Method for Moving Target Detection" proposes a moving target detection method that combines deep learning with traditional algorithms. First, a preliminary binarized image is obtained using traditional algorithms. This image is then combined with the current frame to form a four-channel image, which is input into a FegNet neural network for computation to obtain the final result. Further post-processing of the traditional algorithm's results using deep learning significantly improves upon issues such as ghosting and holes, and also demonstrates a noticeable improvement in accuracy. However, this deep learning technique requires extensive pre-training of the model, has limited room for improvement in detection accuracy, performs poorly on untrained new video sequences, and is difficult to directly and quickly apply to moving target detection in new scenes.

[0031] To address the technical problem of poor performance of deep learning models in detecting new video scenes, one embodiment of this application proposes a moving target detection method based on a multi-frame spatial attention mechanism, applied to an electronic device. The electronic device can be a terminal or a server; in this embodiment and the following embodiments, the electronic device is described using a server as an example. The implementation details of the moving target detection method based on the multi-frame spatial attention mechanism in this embodiment are described below. These details are provided for ease of understanding and are not essential for implementing this solution.

[0032] The specific process of the moving target detection method based on multi-frame spatial attention mechanism in this embodiment can be described as follows: Figure 1 As shown, it includes:

[0033] Step 101: Pre-train the pre-built detection model using a preset first training set. The pre-built detection model consists of a feature extraction network, an attention gate network, a feature aggregation network, and a foreground classification network.

[0034] In the specific implementation, the pre-training process mainly adopts the backpropagation algorithm. The server uses a preset first training set to pre-train the pre-built detection model, that is, iteratively updates the parameters in the feature extraction network, attention gate network, feature aggregation network and foreground classification network using the backpropagation algorithm until the detection model converges, and obtains the pre-trained detection model. The pre-trained detection model has the standard moving target detection capability.

[0035] Step 102: Extract a portion of video frames from the video to be detected and label the moving targets to generate a second training set.

[0036] Step 103: Freeze the feature extraction network, attention gate network, and feature aggregation network, and use the second training set to perform secondary training on the pre-trained detection model.

[0037] In its implementation, when a moving target detection model is needed, the server first manually labels moving targets in a subset of video frames from the video to be detected, generating a second training set. Then, the parameters of the feature extraction network, attention gate network, and feature aggregation network in the pre-trained detection model are frozen, and only the parameters of the foreground classification network in the pre-trained detection model are updated. This process continues until the detection model converges, resulting in the second-trained detection model. In other words, after pre-training, the server needs to fine-tune the foreground classification network based on the scene of the video to be detected, achieving generalization and universality of the detection model and improving its adaptability to the scene of the video. This eliminates the need for retraining with massive amounts of samples, effectively saving model training costs and shortening training time.

[0038] In some cases, the server randomly selects 50 consecutive frames from the video to be detected, performs manual motion target annotation on these 50 consecutive frames, generates a second training set, and then performs secondary training on the pre-trained detection model.

[0039] In some cases, regardless of whether the scene to be detected belongs to a scene that the detection model has seen, the server selects some frames from the video to be detected for secondary training, which can greatly improve the accuracy of moving target detection.

[0040] Step 104: Input the video to be detected into the detection model after secondary training to obtain the motion target detection result of the video to be detected. The attention gate network is used to perform spatial attention calculation on the features between different frames to obtain salient region features.

[0041] In the specific implementation, after the server obtains the detection model after secondary training, it can input the video to be detected into the secondary training detection model to obtain the moving target detection result of the video. The feature extraction network extracts features from each frame of the video to be detected, and the attention gate network performs spatial attention calculation on the features between different frames extracted by the feature extraction network to obtain salient region features. Then, through the feature aggregation network and the foreground segmentation network, the moving target detection result of the video to be detected is finally obtained.

[0042] In some examples, the structure of the detection model is as follows: Figure 2 As shown, the feature extraction network, attention gate network, feature aggregation network, and foreground classification network are all derived from convolutional neural networks. The feature extraction network can extract features at three scales from the video to be detected. Correspondingly, the attention gate network has three attention gates to receive features at these three scales respectively. Similarly, the feature aggregation network also has at least three deconvolutional layers to receive the outputs of the three attention gates.

[0043] In this embodiment, an attention-gating network is used to extract salient regions of features between different frames. This reduces the overall size of the network model and saves resources, while focusing limited attention on important information regions to achieve better feature extraction and aggregation results. When performing moving target detection on the video to be detected, several frames are first extracted from the video for manual annotation to generate a second training set for fine-tuning the foreground classification network of the detection model. This secondary training can, to some extent, solve the problem of poor detection performance of deep learning models in new scene videos. Fine-tuning with a small number of samples can achieve generalization of the detection model, thereby saving model training costs and shortening model training time while significantly improving the accuracy of the detection model in moving target detection in new scene videos.

[0044] In some embodiments, the server inputs the video to be detected into the detection model after secondary training, which can be achieved through methods such as... Figure 3 The steps shown are implemented as follows:

[0045] Step 201: Select n consecutive frames from the video to be detected, and perform pixel value averaging on the n consecutive frames to obtain the estimated background frames.

[0046] In the specific implementation, before the video to be detected is input into the detection model, it needs to be preprocessed. First, n consecutive frames need to be selected from the video to be detected, and the pixel values ​​of the n consecutive frames are averaged to obtain the estimated background frame. Here, n is an integer greater than 1, and the specific value can be set by those skilled in the art according to actual needs. In other words, the server needs to calculate the average pixel values ​​of pixels at the same position in the n consecutive frames of the video to be detected, and obtain the estimated background frame based on the average pixel value of each pixel.

[0047] In some cases, n is typically 50, meaning that 50 consecutive frames are selected from the video to be detected, and the pixel values ​​of these 50 consecutive frames are averaged to obtain the estimated background frames.

[0048] Step 202: Starting from the first frame of the video to be detected, take three consecutive frames in the video to be detected and the estimated background frame as input images, and slide backward according to a preset step size until the entire video to be detected is input into the detection model after secondary training.

[0049] In the specific implementation, the server starts from the first frame of the video to be detected, taking three consecutive frames from the video and the estimated background frame as input images, and slides forward according to a preset step size until the entire video to be detected is input into the detection model after secondary training. That is, the first input image is a 4-frame three-channel image, including the first, second, and third frames of the video to be detected and the estimated background frame. The preset step size is usually set to 1, meaning the second input image is a 4-frame three-channel image, including the second, third, and fourth frames of the video to be detected and the estimated background frame.

[0050] In some cases, the scale of the three consecutive frames in the video to be detected and the estimated background frame are all 360×240.

[0051] In this embodiment, by using consecutive frames and estimated background frames as model input, the adaptability of the detection model to the scene to which the video to be detected belongs can be further improved, and the accuracy of the detection model in detecting moving targets in new scene videos can be further improved.

[0052] In some embodiments, the server inputs the video to be detected into a detection model that has undergone secondary training to obtain the motion target detection result of the video to be detected, which can be achieved through methods such as... Figure 4 The steps shown are implemented as follows:

[0053] Step 301: Input the input image into the detection model after secondary training. The feature extraction network extracts features from the input image at three scales respectively. The four sets of features extracted at each scale are used as a feature block and input into the attention gate network respectively.

[0054] In the specific implementation, the four-frame, three-channel input image first enters the feature extraction network. The feature extraction network extracts features at three scales of the input image. One feature is extracted from each scale of the four-frame, three-channel input image, resulting in twelve sets of features across the three scales, with four sets at each scale. The server then uses the four sets of features extracted at each scale as a feature block and inputs them into the attention gate network. The three scales include the first scale, the second scale, and the third scale, where the second scale is half the size of the first scale, and the third scale is half the size of the second scale.

[0055] In some examples, the first scale is 32×180×120, the second scale is 128×90×60, and the third scale is 256×45×30.

[0056] In some examples, the feature extraction network consists of consecutive stacked 3×3 convolutional layers and pooling layers, such as... Figure 5As shown, a total of six convolutional layers and three pooling layers are configured. The first pooling layer is placed after the first and second convolutional layers, outputting feature blocks at a first scale, and is also connected to the third convolutional layer. The second pooling layer is placed after the third and fourth convolutional layers, outputting feature blocks at a second scale, and is also connected to the fifth convolutional layer. The third pooling layer is placed after the fifth and sixth convolutional layers, outputting feature blocks at a third scale. Each convolutional layer and each pooling layer is followed by a ReLU activation function layer, and each pooling layer is followed by a Batch Normalization (BN) layer.

[0057] Step 302: The attention gate network includes three attention gates, which respectively receive feature blocks at the first scale, the second scale, and the third scale. Each attention gate extracts the salient region features of the received feature blocks and inputs the feature blocks after extracting the salient region features into the feature aggregation network.

[0058] In its implementation, the attention-gating network comprises three attention gates, designated as the first, second, and third attention gates. These gates receive feature blocks at three different scales: a first-scale feature block, a second-scale feature block, and a third-scale feature block, respectively. The first attention gate extracts the salient region features of the first-scale feature block, the second attention gate extracts the salient region features of the second-scale feature block, and the third attention gate extracts the salient region features of the third-scale feature block. After each attention gate extracts the salient region features of its received feature block, the extracted feature block can be input into the feature aggregation network. The input and output scales of each attention gate remain unchanged.

[0059] In some examples, the input image is a 4-frame, three-channel image, and the internal structure of the attention gate can be as follows: Figure 6 As shown, the attention gate uses a 1×1 convolutional layer to further extract features from each frame of the received feature block, reducing the number of channels to half. Spatial attention is calculated on the extraction results of adjacent frames, and the results are aggregated according to a preset ratio to obtain a single-channel salient region map. This single-channel salient region map is then multiplied by each channel of the feature block to obtain a three-channel feature block after extracting salient region features. The detection model specifies that the estimated background frame is adjacent to the third frame out of three consecutive frames. For Figure 6The attention gate shown has a preset aggregation ratio of 0.2 corresponding to the spatial attention calculation result obtained from the extraction results of the first frame and the second frame, a preset aggregation ratio of 0.3 corresponding to the spatial attention calculation result obtained from the extraction results of the second frame and the third frame, and a preset aggregation ratio of 0.5 corresponding to the spatial attention calculation result obtained from the extraction results of the third frame and the estimated background frame.

[0060] Understandably, each attention gate performs further feature extraction on the feature block, that is, it focuses attention on important information and aggregates them according to a preset ratio to obtain a single-channel salient region map. The aggregated single-channel salient region map can well represent the important information in the input image. Then, it is multiplied with each channel of the feature block to obtain an output with the original number of channels and scale unchanged, which is convenient for subsequent processing by the feature aggregation network.

[0061] Step 303: The feature aggregation network splices the feature blocks after extracting salient region features at different scales, and inputs the spliced ​​feature blocks into the foreground classification network.

[0062] In its implementation, the feature aggregation network adopts a U-shaped network architecture. The feature blocks after extracting salient region features at each scale are combined with the feature blocks after extracting salient region features at the previous scale after being processed by the deconvolution layer, and then input into the next deconvolution layer. This achieves the concatenation of feature blocks after extracting salient region features at different scales, and the concatenated feature blocks are then input into the foreground classification network.

[0063] In some examples, the feature aggregation network is composed of consecutive 3×3 deconvolutional layers and unpooling layers, such as... Figure 7 As shown, a total of six deconvolutional layers and three unpooling layers are configured. The first deconvolutional layer receives feature blocks after extracting salient region features at the third scale. The first unpooling layer is placed after the first and second deconvolutional layers and is also connected to the third deconvolutional layer. The third deconvolutional layer receives feature blocks after extracting salient region features at the second scale and concatenates these feature blocks with the output of the first unpooling layer. The second unpooling layer is placed after the third and fourth deconvolutional layers and is also connected to the fifth deconvolutional layer. The fifth deconvolutional layer receives feature blocks after extracting salient region features at the first scale and concatenates these feature blocks with the output of the second unpooling layer. The third unpooling layer is placed after the fifth and sixth deconvolutional layers and outputs the concatenated feature block. Each deconvolutional layer and each unpooling layer is followed by a ReLU activation function layer, and each unpooling layer is followed by a BN normalization layer.

[0064] Step 304: The foreground classification network outputs the moving target detection results based on the spliced ​​feature blocks.

[0065] In its implementation, the foreground classification network consists of two sequentially connected 1×1 convolutional layers, a ReLU activation function layer, and a Sigmoid activation function layer, as follows: Figure 8 As shown, the first 1×1 convolutional layer receives the concatenated feature blocks, and the Sigmoid activation function layer outputs the motion target detection results of the video to be detected.

[0066] In some examples, for each input image, the moving target detection result is a moving target detection result image, in which the pixel value of the region where the moving target is located is 1, and the pixel value of other regions is 0. For example... Figure 9 As shown, the moving target detection result image is a binary image, which can intuitively show the position of the moving target.

[0067] In this embodiment, the feature extraction network and the attention gate network extract features from the input image at different scales, ensuring that the extracted features are scientific and comprehensive. The feature aggregation network stitches together features at different scales, and then the foreground classification network outputs the detection results, effectively improving the speed and accuracy of moving target detection.

[0068] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0069] Another embodiment of this application relates to an electronic device, such as... Figure 10 As shown, it includes: at least one processor 401; and a memory 402 communicatively connected to the at least one processor 401; wherein the memory 402 stores instructions executable by the at least one processor 401, the instructions being executed by the at least one processor 401 to enable the at least one processor 401 to execute the moving target detection method based on the multi-frame spatial attention mechanism in the above embodiments.

[0070] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.

[0071] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.

[0072] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method embodiments described above.

[0073] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0074] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.

Claims

1. A moving target detection method based on a multi-frame spatial attention mechanism, characterized in that, include: The pre-built detection model is pre-trained using a preset first training set; wherein the pre-built detection model consists of a feature extraction network, an attention gate network, a feature aggregation network, and a foreground classification network; A portion of video frames is extracted from the video to be detected and labeled with moving targets to generate a second training set; Freeze the feature extraction network, the attention gate network, and the feature aggregation network, and use the second training set to perform secondary training on the pre-trained detection model; The video to be detected is input into the detection model after secondary training to obtain the moving target detection result of the video to be detected; wherein, the attention gate network is used to perform spatial attention calculation on the features between different frames to obtain salient region features; The step of inputting the video to be detected into the detection model after secondary training includes: Select n consecutive frames from the video to be detected, and perform pixel value averaging on the n consecutive frames to obtain the estimated background frame; wherein, n is an integer greater than 1; Starting from the first frame of the video to be detected, three consecutive frames in the video to be detected and the estimated background frame are used as input images, and the process is slid backward according to a preset step size until the entire video to be detected is input into the detection model after secondary training. The step of inputting the video to be detected into the detection model after secondary training to obtain the moving target detection result of the video to be detected includes: The input image is input into the detection model after secondary training. The feature extraction network extracts features from the input image at three scales respectively. The four sets of features extracted at each scale are used as a feature block and input into the attention gate network respectively. The three scales include a first scale, a second scale, and a third scale. The second scale is half of the first scale, and the third scale is half of the second scale. The attention gate network includes three attention gates, which respectively receive feature blocks at the first scale, the second scale, and the third scale. Each attention gate extracts the salient region features of the received feature blocks and inputs the feature blocks after extracting the salient region features into the feature aggregation network. The feature aggregation network concatenates feature blocks extracted from salient regions at different scales and inputs the concatenated feature blocks into the foreground classification network. The foreground classification network outputs the moving target detection result based on the stitched feature blocks; The input image is a three-channel image. The attention gate uses a 1×1 convolutional layer to further extract features from each frame of the received feature block, reducing the number of channels to half of the original. Spatial attention is calculated on the extraction results of two adjacent frames, and the results are aggregated according to a preset ratio to obtain a single-channel salient region map. The single-channel salient region map is multiplied with each channel of the feature block to obtain a feature block with three channels after extracting salient region features. It is specified that the estimated background frame is adjacent to the third frame in the three consecutive frames.

2. The moving target detection method based on multi-frame spatial attention mechanism according to claim 1, characterized in that, The feature extraction network is composed of consecutive 3×3 convolutional layers and pooling layers, with a total of six convolutional layers and three pooling layers. The first pooling layer is placed after the first convolutional layer and the second convolutional layer. The first pooling layer outputs the feature block of the first scale. The first pooling layer is also connected to the third convolutional layer. The second pooling layer is placed after the third and fourth convolutional layers. The second pooling layer outputs feature blocks of the second scale. The second pooling layer is also connected to the fifth convolutional layer. The third pooling layer is placed after the fifth and sixth convolutional layers, and the third pooling layer outputs the feature block of the third scale; Each convolutional layer and each pooling layer is followed by a ReLU activation function layer, and each pooling layer is followed by a BN normalization layer.

3. The moving target detection method based on multi-frame spatial attention mechanism according to claim 1, characterized in that, The feature aggregation network is composed of consecutive 3×3 deconvolution layers and depooling layers, with a total of six deconvolution layers and three depooling layers. The first deconvolutional layer receives the feature blocks after extracting salient region features at the third scale. The first depooling layer is disposed after the first deconvolutional layer and the second deconvolutional layer. The first depooling layer is also connected to the third deconvolutional layer. The third deconvolutional layer receives the feature block after extracting salient region features at the second scale, and concatenates the feature block after extracting salient region features at the second scale with the output of the first depooling layer. The second depooling layer is set after the third and fourth deconvolutional layers, and the second depooling layer is also connected to the fifth deconvolutional layer. The fifth deconvolutional layer receives the feature block after extracting salient region features at the first scale, and concatenates the feature block after extracting salient region features at the first scale with the output of the second depooling layer. The third depooling layer is set after the fifth and sixth deconvolutional layers, and the third depooling layer outputs the concatenated feature block. Each deconvolutional layer and each unpooling layer is followed by a ReLU activation function layer, and each unpooling layer is followed by a BN normalization layer.

4. The moving target detection method based on multi-frame spatial attention mechanism according to claim 1, characterized in that, The foreground classification network consists of two sequentially connected 1×1 convolutional layers, a ReLU activation function layer, and a Sigmoid activation function layer. The first 1×1 convolutional layer receives the concatenated feature blocks, and the Sigmoid activation function layer outputs the moving target detection result.

5. The moving target detection method based on multi-frame spatial attention mechanism according to any one of claims 2 to 4, characterized in that, For each input image, the moving target detection result is a moving target detection result image, in which the pixel value of the region where the moving target is located is 1, and the pixel value of other regions is 0.

6. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the moving target detection method based on a multi-frame spatial attention mechanism as described in any one of claims 1 to 5.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the moving target detection method based on the multi-frame spatial attention mechanism as described in any one of claims 1 to 5.