Image detection method, system, storage medium and electronic device

Determining image changes through pixel subtraction and binarization processing, combined with the improved Faster R-CNN model, solves the problem of high computational power consumption in image detection in massive monitoring information, reducing the amount of calculation and improving detection accuracy.

CN113159001BActive Publication Date: 2024-09-06STATE GRID INFORMATION & TELECOMM GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110579035.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-26
Publication Date
2024-09-06
Estimated Expiration
2041-05-26

AI Technical Summary

Technical Problem

When existing technology processes massive amounts of monitoring information, the computing power required for image detection is huge, resulting in increased costs that are difficult to effectively reduce.

Method used

Use the pixel subtraction method to obtain the difference image, perform binarization processing, determine whether the pixel value is less than the preset threshold to determine the image change, extract the video stream before the change moment, and use the improved Faster R-CNN model for target detection to reduce calculations quantity.

Benefits of technology

It effectively reduces the amount of calculation during image detection, saves the cost of computing power consumption, improves detection accuracy, and prevents the omission of slow changes or long-interval changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113159001B
    Figure CN113159001B
Patent Text Reader

Abstract

The embodiment of the present invention provides an image detection method, system, storage medium and electronic device. The method includes: using the pixel value change of the differential image after binarization to determine whether there is a changed image in the video stream, for the image that has been detected to have changed, extracting the video stream of the first preset time before the moment of change; for the image that has not been detected to have changed, extracting the video stream of the second time period in the video stream of the first time period; using the extracted video stream as the video stream to be detected, inputting the image to be detected in the video stream to be detected into the trained target detection model, and obtaining abnormal information of the image to be detected. Compared with detecting all images in the video stream, the present invention greatly reduces the amount of calculation during image detection and saves the cost caused by computing power consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent monitoring technology, and in particular to an image detection method, system, storage medium and electronic equipment. Background Art

[0002] With the deployment of a large number of monitoring equipment, full-range monitoring of the monitoring area has been achieved. At present, intelligent detection methods are used to identify, classify, analyze and process monitoring information, realizing intelligent image monitoring. However, a large number of monitoring equipment generates a large amount of monitoring information. To achieve image detection, a large number of intelligent computing devices are required, which results in a huge waste of computing power. Therefore, it is very necessary to reduce computing power consumption for image detection of massive monitoring information. Summary of the invention

[0003] The purpose of the embodiments of the present invention is to provide an image detection method, system, storage medium and electronic device, which can reduce the amount of calculation during image detection and save the cost caused by computing power consumption. The specific technical solution is as follows:

[0004] The present invention provides an image detection method, comprising:

[0005] Adjacent frames in the video stream are subtracted by pixels to obtain a differential image;

[0006] Binarizing the difference image to obtain a binarized difference image;

[0007] Determine whether the pixel value of the binarized differential image is less than a preset pixel threshold, if so, determine that the image in the video stream has not changed, if not, determine that the image in the video stream has changed;

[0008] When it is determined that the image in the video stream has changed, extracting a video stream of a first preset time length before the moment when the change occurs, and / or when no image change in the video stream in the first time period is detected, extracting a video stream of a second time period in the video stream in the first time period, the length of the first time period is a second preset time length, the length of the second time period is less than the length of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period;

[0009] The extracted video stream is used as the video stream to be detected, and the image to be detected in the video stream to be detected is input into the trained target detection model to obtain abnormal information of the image to be detected; the abnormal information of the image to be detected is the probability that the image to be detected represents the existence of an abnormal situation.

[0010] Optionally, the target detection model is obtained by training an improved Faster R-CNN model using labeled image samples, wherein the improved Faster R-CNN model includes a backbone network, a feature pyramid network, a convolutional layer, and a fully connected layer, and the backbone network is a ResNet convolutional neural network with the fully connected layer removed;

[0011] The training method of the target detection model specifically includes:

[0012] Acquire an image sample, and mark the image sample to obtain the marked image sample;

[0013] Inputting the labeled image sample into the backbone network for feature extraction to obtain a feature map;

[0014] The feature map is merged with the feature pyramid network to obtain a feature layer;

[0015] Inputting the feature layer into the convolution layer to obtain a convolution output result, and inputting the convolution output result into the fully connected layer to obtain a predicted image abnormality probability;

[0016] The weights of the improved Faster R-CNN model are adjusted until the deviation between the predicted image anomaly probability and the actual image anomaly probability is within an allowable range, and the training is completed to obtain a trained target detection model.

[0017] Optionally, the step of inputting the labeled image sample into the backbone network for feature extraction to obtain a feature map specifically includes:

[0018] The labeled image samples are input into the backbone network, and after feature extraction is performed using the convolution modules of each stage of the backbone network, feature maps of multiple stages are obtained; wherein the size of the feature map of the latter stage is smaller than the size of the feature map of the previous stage, the number of semantic features of the feature map of the latter stage is larger than the number of semantic features of the feature map of the previous stage, and the resolution of the feature map of the latter stage is smaller than the resolution of the feature map of the previous stage.

[0019] Optionally, fusing the feature map with the feature pyramid network to obtain a feature layer specifically includes:

[0020] The feature maps of each stage are corresponded to the layers of the feature pyramid network in the order that the feature map of the last stage corresponds to the top layer of the feature pyramid network and the feature map of the second stage corresponds to the bottom layer of the feature pyramid network;

[0021] Inputting the feature map of the last stage into the top layer of the feature pyramid for feature fusion to obtain the output result of the top layer of the feature pyramid;

[0022] The second layer of the feature pyramid network is used as the current layer, and the output result of the previous layer of the current layer is compared with the feature corresponding to the current layer. Figure 1 The current layer is inputted for processing to obtain the output result of the current layer;

[0023] If the current layer has a next layer, the next layer is used as the current layer, and the process returns to step "combining the output result of the previous layer of the current layer with the feature map corresponding to the current layer". Figure 1 The step of inputting the feature layer into the convolution layer to obtain the convolution output result, and inputting the convolution output result into the fully connected layer to obtain the predicted image abnormality probability is performed; wherein the output result of each layer of the feature pyramid network is the feature layer.

[0024] Optionally, the step of inputting the feature layer into the convolution layer to obtain a convolution output result, and inputting the convolution output result into the fully connected layer to obtain a predicted image abnormality probability specifically includes:

[0025] Using the convolutional layer to process the feature layer, a confidence of a candidate box is obtained; the confidence of the candidate box is a probability that the candidate box contains a target;

[0026] When the confidence of the candidate box is greater than a preset confidence threshold, the fully connected layer is used to process the feature map area corresponding to the candidate box to obtain a predicted image abnormality probability.

[0027] Optionally, after obtaining the abnormal information of the image to be detected, the method further includes:

[0028] Determine the image that meets the probability requirement as an abnormal image;

[0029] Determine an abnormal target in the abnormal image; the abnormal target is obtained after inputting the abnormal image into the trained target detection model and using the fully connected layer to perform feature extraction.

[0030] Optionally, after obtaining the video stream to be detected, the method further includes:

[0031] Performing frame extraction processing on the video stream to be detected to obtain multiple frames of images to be detected;

[0032] The image to be detected is packaged to obtain a packaged image to be detected.

[0033] The present invention also provides an image detection system, comprising:

[0034] The differential image generation module is used to obtain a differential image by using a pixel subtraction method for adjacent frames in the video stream;

[0035] A binarization processing module, used for performing binarization processing on the difference image to obtain a binarized difference image;

[0036] An image change detection module, used to determine whether the pixel value of the binarized differential image is less than a preset pixel threshold, if so, determining that the image in the video stream has not changed, if not, determining that the image in the video stream has changed;

[0037] a video stream extraction module, configured to extract a video stream of a first preset time length before the moment of change when it is determined that an image in the video stream has changed, and / or to extract a video stream of a second time period in the video stream of the first time period when no image change in the video stream of the first time period is detected, wherein the length of the first time period is a second preset time length, the length of the second time period is less than the length of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period;

[0038] The image detection module is used to use the extracted video stream as the video stream to be detected, input the image to be detected in the video stream to be detected into the trained target detection model, and obtain abnormal information of the image to be detected; the abnormal information of the image to be detected is the probability that the image to be detected represents the existence of an abnormal situation.

[0039] The present invention also provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the above-mentioned image detection method is implemented.

[0040] The present invention also provides an electronic device, comprising:

[0041] At least one processor, and at least one memory and bus connected to the processor;

[0042] The processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the above-mentioned image detection method.

[0043] An embodiment of the present invention provides an image detection method, system, storage medium and electronic device. The image detection method uses the change in pixel values ​​of a differential image after binarization to determine whether there is a changed image in a video stream. For an image that has been detected to have changed, a video stream of a first preset time period before the moment of change is extracted, which can reduce the number of images during image detection; when an image change in a video stream of a first time period is not detected, a video stream of a second time period in the video stream of the first time period is extracted, which can reduce the number of images during image detection and prevent the omission of images that change slowly or have a long time interval between changes; in addition, since only video streams with and without image changes within a period of time are retained, compared with detecting all images in the video stream, the amount of calculation during image detection is greatly reduced, saving the cost caused by computing power consumption.

[0044] In addition, frame extraction of the video stream to be detected can further reduce the computational complexity of image detection; and the use of the improved Faster R-CNN model can improve the accuracy of image detection.

[0045] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 A flow chart of an image detection method provided by an embodiment of the present invention;

[0048] Figure 2 A schematic diagram of a multi-channel video stream processing process provided by an embodiment of the present invention;

[0049] Figure 3 A schematic diagram of an image detection process provided by an embodiment of the present invention;

[0050] Figure 4 A schematic diagram of the backbone network structure provided by an embodiment of the present invention;

[0051] Figure 5 A schematic diagram of the fusion process of the feature graph and feature pyramid network provided by an embodiment of the present invention;

[0052] Figure 6 A structural diagram of an image detection system provided by an embodiment of the present invention;

[0053] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] The present invention provides an image detection method, such as Figure 1 As shown, the method includes:

[0056] Step 101: Adjacent frames in a video stream are subjected to pixel subtraction to obtain a differential image.

[0057] The difference image is obtained by subtracting the pixels of adjacent frames. The area with 0 pixels in the difference image indicates that the image has not changed, and the area with non-0 pixels in the difference image indicates that the image has changed. The difference image can clearly reflect whether the image has changed and the location of the changed area in the changed image. Optionally, the difference image is obtained by subtracting the corresponding pixels of two or three adjacent frames in the image sequence in the video stream.

[0058] Step 102: binarize the difference image to obtain a binarized difference image.

[0059] In an optional embodiment, the present invention can perform binarization processing on the differential image through a preset threshold value to obtain a binarized differential image. After the differential image is binarized, the binarized differential image presents an obvious black and white effect, simplifies the image and can highlight the changed area, which is convenient for subsequent processing of the image.

[0060] Step 103: Determine whether the pixel value of the binarized differential image is less than a preset pixel threshold. If so, determine that the image in the video stream has not changed; if not, determine that the image in the video stream has changed.

[0061] In an optional embodiment, the pixel value of the differential image after binarization is 0 or 255. If the grayscale values ​​of all pixels in the binarized differential image are all 0 (0 is less than a preset pixel threshold), it is determined that the image in the video stream has not changed. If there are pixels with a pixel value of 255 in the binarized differential image (255 exceeds the preset pixel threshold), it is determined that the image in the video stream has changed.

[0062] In another optional embodiment, the pixel points corresponding to the pixel value of 255 in the binary differential image are changed to 1, and the pixel points corresponding to the pixel value of 0 in the binary differential image are changed to 0, that is, the changed area is 1, and the unchanged area is 0; then the number of 1s is calculated, and if the number of 1s exceeds the preset number, it is determined that the image in the video stream has changed; if the number of 1s does not exceed the preset number, it is determined that the image in the video stream has not changed.

[0063] Step 104: When it is determined that the image in the video stream has changed, extract the video stream of the first preset duration before the change occurs, and / or when no image change is detected in the video stream of the first time period, extract the video stream of the second time period in the video stream of the first time period, the duration of the first time period is the second preset duration, the duration of the second time period is less than the duration of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period.

[0064] Before determining the image change, the image may have already started to change, so it is necessary to extract images taken within a period of time before the image change. When no image change is detected after a period of time, the image may have changed slowly or the interval between changes is long, so it is also necessary to extract some images within this period when no image change is detected. When extracting, the closer to the latest moment in this period, the greater the possibility of extracting the changed image.

[0065] For example, if the first preset duration is 1 second, the duration of the first time period is 10 minutes, and the duration of the second time period is 1 second, then, when it is determined that the image in the video stream has changed, if the video stream of 1 second before the change occurs is extracted, 60 frames of images will be obtained. If no image change is detected in the video stream of the first time period, the video stream of the time period from 9 minutes 59 seconds to 10 minutes will be extracted to obtain 60 frames of images.

[0066] The present invention takes into account the situations where an image has changed and an image has not changed for a long time. For an image that has not changed, subsequent image detection is also necessary. This is because when the differential images of adjacent frames are used for binarization processing, images with a long time interval between changes or images that change slowly will be omitted.

[0067] For example, the needle of an instrument may change rapidly or slowly. When the needle moves rapidly, the image can be determined to have changed by ensuring that the pixel value of the binary differential image is not less than the preset pixel threshold. However, when the needle moves slowly, the pixel change is not large, so the threshold setting will result in the image not changing. However, this situation also requires image detection. For another example, under certain conditions, the color of silicone will change from blue to transparent, but this change is slow, so image detection is also necessary.

[0068] Step 105: The extracted video stream is used as the video stream to be detected, and the image to be detected in the video stream to be detected is input into the trained target detection model to obtain abnormal information of the image to be detected; the abnormal information of the image to be detected is the probability that the image to be detected represents the existence of abnormal conditions.

[0069] After obtaining the abnormal information of the image to be detected, the method further includes: determining the image that meets the probability requirement as an abnormal image; determining the abnormal target in the abnormal image; the abnormal target is obtained after inputting the abnormal image into the trained target detection model and extracting features using the fully connected layer. Among them, the image that meets the probability requirement refers to the image to be detected whose probability of representing the existence of an abnormal situation is greater than the image corresponding to the preset probability.

[0070] In order to further reduce the amount of calculation during image detection, the present invention performs frame extraction processing on the video stream to be detected to obtain multiple frames of images to be detected; then the images to be detected are packaged to obtain packaged images to be detected. Specifically, Figure 2 As shown, the video shot by a camera is a video stream (the video shot by camera 1 is video stream 1, ..., the video shot by camera N is video stream A), for each video stream, the video stream is extracted by the method of steps 101-104 to obtain multiple video streams to be detected (video stream 1 to video stream B); for the video stream to be detected, sampling is performed according to the method of extracting 1 frame per N frames, and the extracted video frames are packaged into a batch process per M frames in combination with the storage of the computing card and the image size; the batch process is assigned to a computing card with computing power for image detection processing. The present invention uses the HiSilicon Hi3516AV300 video processor to connect with the camera.

[0071] The target detection model is obtained by training the improved Faster R-CNN model with labeled image samples. The improved Faster R-CNN model includes a backbone network, a feature pyramid network, a convolutional layer, and a fully connected layer. The backbone network is a ResNet convolutional neural network with the fully connected layer removed.

[0072] like Figure 3 As shown in Figure 1, the training method of the target detection model specifically includes:

[0073] (1) Obtain image samples, mark the image samples, and obtain marked image samples.

[0074] The labelImg labeling software is used to manually label the image samples, and the minimum inscribed rectangle containing all the targets in each calibration image is determined, and the target category label is given. For example, in the images taken from closed factory areas such as substations and data centers, when the object to be detected is a meter, when marking the image samples, the minimum inscribed rectangle of the meter in the calibration image whose pointer exceeds the specified range is determined, and the target category label is given as meter. For another example, when the object to be detected is silicone, the minimum inscribed rectangle of the silicone that becomes transparent in the calibration image is determined, and the target category label is given as silicone.

[0075] (2) Input the labeled image samples into the backbone network for feature extraction to obtain a feature map.

[0076] Before inputting the labeled image samples into the backbone network, the image size needs to be adjusted first. Preferably, the image samples with a resolution of 1920×1080 are adjusted to images with a resolution of 608×608.

[0077] The labeled image samples are input into the backbone network, and the convolution modules of each stage of the backbone network are used to extract features, thereby obtaining feature maps of multiple stages; wherein the number of semantic features of the feature map of the latter stage is greater than the number of semantic features of the feature map of the previous stage, and the resolution of the feature map of the latter stage is less than the resolution of the feature map of the previous stage. The size of the feature map of the latter stage is smaller than the size of the feature map of the previous stage, and preferably, the length and width of the feature map of the latter stage of the backbone network are reduced to 1 / 2 of the feature map of the previous stage.

[0078] The backbone network used in the present invention is a ResNet convolutional neural network with the fully connected layer removed. Figure 4 As shown in the figure, the backbone network includes 5 stages of convolution modules. The first stage convolution module includes 1 7×7 convolution layer, the second stage convolution module includes 6 1×1 convolution layers and 3 3×3 convolution layers, the third stage convolution module includes 8 1×1 convolution layers and 4 3×3 convolution layers, the fourth stage convolution module includes 46 1×1 convolution layers and 23 3×3 convolution layers, and the fifth stage convolution module includes 6 1×1 convolution layers and 3 3×3 convolution layers. The backbone network has a total of 100 convolution layers, and each convolution layer is followed by a batch normalization layer to prevent gradient disappearance and a RELU activation layer to increase nonlinearity. The backbone network increases the number of feature map channels from 3 to 64 in the first stage, and expands the number of channels to 4 times that of the previous stage in each subsequent stage.

[0079] In the case where the backbone network includes 5-stage convolution modules, the marked image samples are input into the backbone network, and the second-stage convolution module of the backbone network is used to perform feature extraction to obtain the feature map of the second stage, the third-stage convolution module of the backbone network is used to perform feature extraction to obtain the feature map of the third stage, the fourth-stage convolution module of the backbone network is used to perform feature extraction to obtain the feature map of the fourth stage, and the fifth-stage convolution module of the backbone network is used to perform feature extraction to obtain the feature map of the fifth stage.

[0080] (3) The feature map is integrated with the feature pyramid network to obtain the feature layer.

[0081] Specifically, Figure 5 As shown, the feature maps of each stage are corresponded to the layers of the feature pyramid network in the order that the feature map of the last stage corresponds to the top layer of the feature pyramid network and the feature map of the second stage corresponds to the bottom layer of the feature pyramid network.

[0082] The feature map of the last stage is input into the top layer of the feature pyramid for feature fusion to obtain the output result of the top layer of the feature pyramid. Among them, the feature map of the last stage is the feature map of the fifth stage.

[0083] The second layer of the feature pyramid network is used as the current layer, and the output result of the previous layer of the current layer is compared with the feature corresponding to the current layer. Figure 1 The data is input into the current layer for processing to obtain the output result of the current layer.

[0084] If the current layer has a next layer, take the next layer as the current layer and return to step "combine the output result of the previous layer of the current layer with the feature corresponding to the current layer" Figure 1 Input the feature layer into the convolution layer to obtain the convolution output result, input the convolution output result into the fully connected layer to obtain the predicted image abnormality probability"; the output result of each layer of the feature pyramid network is the feature layer.

[0085] That is, for the second layer of the feature pyramid, when the size of the output result of the top layer of the feature pyramid is enlarged to be consistent with the size of the second layer of the feature pyramid, the enlarged output result of the top layer of the feature pyramid and the feature map of the fourth stage are input into the second layer of the feature pyramid for feature fusion to obtain the output result of the second layer of the feature pyramid;

[0086] For the third layer of the feature pyramid, when the size of the output result of the second layer of the feature pyramid is enlarged to be consistent with the size of the third layer of the feature pyramid, the enlarged output result of the second layer of the feature pyramid and the feature map of the third stage are input into the third layer of the feature pyramid for feature fusion to obtain the output result of the third layer of the feature pyramid;

[0087] For the fourth layer of the feature pyramid, when the size of the output result of the third layer of the feature pyramid is enlarged to be consistent with the size of the fourth layer of the feature pyramid, the enlarged output result of the third layer of the feature pyramid and the feature map of the second stage are input into the fourth layer of the feature pyramid for feature fusion to obtain the output result of the fourth layer of the feature pyramid.

[0088] Based on this, the feature pyramid network fuses the top-level semantic features and the bottom-level high-resolution features, and the feature pyramid network outputs feature maps of different resolutions.

[0089] (4) The feature layer is input into the convolution layer to obtain the convolution output result, and the convolution output result is input into the fully connected layer to obtain the predicted image abnormality probability.

[0090] The feature layer is processed using a convolutional layer to obtain the confidence of the candidate box; the confidence of the candidate box is the probability that the candidate box contains the target.

[0091] The present invention determines whether there is a target based on RPN (Region Proposal Network). For instruments as the detection object, after being processed by the convolution layer, it is obtained whether there is an instrument in the image corresponding to the feature layer. The confidence of the candidate box represents the probability value of the instrument in the candidate box. The greater the confidence, the higher the possibility that the candidate box contains the instrument. In addition, after processing the feature layer using the convolution layer, in addition to obtaining the confidence of the candidate box, the position information of the candidate box can also be generated, and the position information of the candidate box reflects the coordinates of the instrument.

[0092] When the confidence of the candidate box is greater than the preset confidence threshold, the fully connected layer is used to process the feature map area corresponding to the candidate box to obtain the predicted image abnormality probability.

[0093] Optionally, when the confidence of the candidate box is greater than a preset confidence threshold, the corresponding feature map area is converted into a fixed-size feature map through the ROI Align algorithm. Then, the fixed-size feature map is further extracted and abstracted through two fully connected layers, and the extracted and abstracted results are input into two different fully connected layers for processing, one of which outputs the target box coordinate information, and the other fully connected layer outputs the confidence that the target box contains the detected target. If the detected target is an instrument, the final output is the probability of the instrument being abnormal and the location of the abnormal instrument; if the detected target is silicone, the final output is the probability of silicone discoloration and the location of the discolored silicone.

[0094] (5) The weights of the improved Faster R-CNN model are adjusted until the deviation between the predicted image anomaly probability and the actual image anomaly probability is within an allowable range. The training is completed and a trained object detection model is obtained.

[0095] During the training process, the total number of training iterations is 60,000 times, the initial learning rate is 0.01, and the decay coefficient is 0.0005. The difference between the target frame coordinate information obtained by step (4) and the position of the calibrated target minimum inscribed rectangular frame, as well as the difference between the confidence of the detected target obtained by step (4) and the preset confidence, is used to calculate the loss value, and the gradient value is calculated after partial derivative of the loss value. The gradient value is used to update the weight of the target detection model using the mini-batch gradient descent method.

[0096] After obtaining the trained target detection model, the image to be detected in the video stream to be detected is input into the trained target detection model to obtain abnormal information of the image to be detected; the abnormal information of the image to be detected is the probability that the image to be detected represents an abnormal situation. Among them, the abnormal information of the image to be detected is, for example, the needle of the instrument exceeds the specified range or the silicone becomes transparent. After the abnormality is detected, the abnormal situation can be warned in time.

[0097] The present invention utilizes the pixel value change of the differential image after binarization to determine whether there is a changed image in the video stream. For the image detected to have changed, the video stream within a period of time before the change moment is extracted, which can reduce the number of images during image detection; for the image not detected to have changed, the video stream within the end time period of the preset time length is extracted, which can reduce the number of images during image detection while preventing the omission of images that change slowly or have a long time interval between changes; in addition, since only the video streams with and without image changes within the preset time period are retained, compared with detecting all images of the video stream, the amount of calculation during image detection is greatly reduced, saving the cost caused by computing power consumption. In addition, the frame extraction processing of the video stream to be detected can further reduce the amount of calculation for image detection; and the use of the improved Faster R-CNN model can improve the accuracy of image detection.

[0098] like Figure 6 As shown, the present invention also provides an image detection system, comprising:

[0099] The differential image generation module 601 is used to obtain a differential image by using a pixel subtraction method for adjacent frames in a video stream.

[0100] The binarization processing module 602 is used to perform binarization processing on the difference image to obtain a binarized difference image.

[0101] The image change detection module 603 is used to determine whether the pixel value of the binarized differential image is less than a preset pixel threshold. If so, it is determined that the image in the video stream has not changed; if not, it is determined that the image in the video stream has changed.

[0102] The video stream extraction module 604 is used to extract a video stream of a first preset time length before the moment when it is determined that an image in the video stream has changed, and / or to extract a video stream of a second time period in the video stream of the first time period when no image change is detected in the video stream of the first time period, wherein the length of the first time period is a second preset time length, the length of the second time period is less than the length of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period.

[0103] The image detection module 605 is used to use the extracted video stream as the video stream to be detected, input the image to be detected in the video stream to be detected into the trained target detection model, and obtain abnormal information of the image to be detected; the abnormal information of the image to be detected is the probability that the image to be detected represents the existence of an abnormal situation.

[0104] Among them, the target detection model is obtained by training the improved Faster R-CNN model with labeled image samples. The improved Faster R-CNN model includes a backbone network, a feature pyramid network, a convolutional layer and a fully connected layer. The backbone network is a ResNet convolutional neural network with the fully connected layer removed.

[0105] The image detection module 605 specifically includes:

[0106] The target detection model training submodule is used to train the target detection model. The target detection model training submodule specifically includes:

[0107] The marking unit is used to obtain image samples, mark the image samples, and obtain marked image samples.

[0108] The feature extraction unit is used to input the labeled image samples into the backbone network for feature extraction to obtain a feature map.

[0109] The feature fusion unit is used to fuse the feature map with the feature pyramid network to obtain the feature layer.

[0110] The image anomaly probability generating unit is used to input the feature layer into the convolution layer to obtain the convolution output result, and input the convolution output result into the fully connected layer to obtain the predicted image anomaly probability.

[0111] The model generation unit is used to adjust the weights of the improved Faster R-CNN model until the deviation between the predicted image anomaly probability and the actual image anomaly probability is within an allowable range, and the training is completed to obtain a trained target detection model.

[0112] in,

[0113] The feature extraction unit specifically includes:

[0114] The feature extraction subunit is used to input the marked image samples into the backbone network, and obtain feature maps of multiple stages after using the convolution modules of each stage of the backbone network to extract features; wherein the size of the feature map of the latter stage is smaller than the size of the feature map of the previous stage, the number of semantic features of the feature map of the latter stage is greater than the number of semantic features of the feature map of the previous stage, and the resolution of the feature map of the latter stage is smaller than the resolution of the feature map of the previous stage.

[0115] Feature fusion unit, specifically including:

[0116] The layer correspondence subunit is used to correspond the feature maps of each stage to the layers of the feature pyramid network in the order that the feature map of the last stage corresponds to the top layer of the feature pyramid network and the feature map of the second stage corresponds to the bottom layer of the feature pyramid network;

[0117] The top-level processing subunit is used to input the feature map of the last stage into the top level of the feature pyramid for feature fusion, and obtain the output result of the top level of the feature pyramid;

[0118] The current layer processing subunit is used to take the second layer of the feature pyramid network as the current layer, and compare the output result of the previous layer of the current layer with the feature corresponding to the current layer. Figure 1 Input the current layer for processing to obtain the output result of the current layer;

[0119] The result output unit is used to, if the current layer has a next layer, use the next layer as the current layer and execute the current layer processing sub-unit; if the current layer does not have a next layer, output the output results of each layer of the feature pyramid network, and then execute the image abnormality probability generation unit; wherein, the output results of each layer of the feature pyramid network are the feature layer.

[0120] The image abnormality probability generating unit specifically includes:

[0121] The convolutional layer processing subunit is used to process the feature layer using the convolutional layer to obtain the confidence of the candidate box; the confidence of the candidate box is the probability that the candidate box contains the target;

[0122] The image anomaly probability generation subunit is used to use the fully connected layer to process the feature map area corresponding to the candidate box when the confidence of the candidate box is greater than a preset confidence threshold to obtain the predicted image anomaly probability.

[0123] The image detection system also includes:

[0124] The abnormal image determination module is used to determine the image that meets the probability requirement as an abnormal image after obtaining the abnormal information of the image to be detected.

[0125] The abnormal target determination module is used to determine the abnormal targets in the abnormal images; the abnormal targets are obtained after the abnormal images are input into the trained target detection model and the features are extracted using the fully connected layer.

[0126] The image detection system also includes:

[0127] The frame extraction module is used to extract frames from the video stream to be detected to obtain multiple frames of images to be detected.

[0128] The encapsulation module is used to encapsulate the image to be detected to obtain the encapsulated image to be detected.

[0129] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the image detection method is implemented.

[0130] An embodiment of the present invention provides an electronic device, such as Figure 7As shown, the electronic device 70 includes at least one processor 701, at least one memory 702 and a bus 703 connected to the processor 701; wherein the processor 701 and the memory 702 communicate with each other through the bus 703; the processor 701 is used to call the program instructions in the memory 702 to execute the above-mentioned image detection method. The electronic device in this article can be a server, a PC, a PAD, a mobile phone, etc.

[0131] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the steps included in the above-mentioned image detection method.

[0132] The present application is described with reference to the flowcharts and / or block diagrams of the methods, systems and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0133] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.

[0134] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.

[0135] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0136] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0137] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0138] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0139] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. An image detection method, characterized in that: include: Adjacent frames in the video stream are subtracted by pixels to obtain a differential image; Binarizing the difference image to obtain a binarized difference image; Determine whether the pixel value of the binarized differential image is less than a preset pixel threshold, if so, determine that the image in the video stream has not changed, if not, determine that the image in the video stream has changed; When it is determined that the image in the video stream has changed, extracting a video stream of a first preset time length before the moment when the change occurs, and / or when no image change in the video stream in the first time period is detected, extracting a video stream of a second time period in the video stream in the first time period, the length of the first time period is a second preset time length, the length of the second time period is less than the length of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period; The extracted video stream is used as the video stream to be detected, and the image to be detected in the video stream to be detected is input into the trained target detection model to obtain abnormal information of the image to be detected; The abnormal information of the image to be detected is the probability that the image to be detected represents the existence of an abnormal situation; After obtaining the video stream to be detected, the method further includes: Performing frame extraction processing on the video stream to be detected to obtain multiple frames of images to be detected; The image to be detected is packaged to obtain a packaged image to be detected.

2. The image detection method according to claim 1, characterized in that: The target detection model is obtained by training an improved Faster R-CNN model using labeled image samples, wherein the improved Faster R-CNN model includes a backbone network, a feature pyramid network, a convolutional layer, and a fully connected layer, wherein the backbone network is a ResNet convolutional neural network with the fully connected layer removed; The training method of the target detection model specifically includes: Acquire an image sample, and mark the image sample to obtain the marked image sample; Inputting the labeled image sample into the backbone network for feature extraction to obtain a feature map; The feature map is merged with the feature pyramid network to obtain a feature layer; Inputting the feature layer into the convolution layer to obtain a convolution output result, and inputting the convolution output result into the fully connected layer to obtain a predicted image abnormality probability; The weights of the improved Faster R-CNN model are adjusted until the deviation between the predicted image anomaly probability and the actual image anomaly probability is within an allowable range, and the training is completed to obtain a trained target detection model.

3. The image detection method according to claim 2, characterized in that: The step of inputting the labeled image sample into the backbone network for feature extraction to obtain a feature map specifically includes: The labeled image samples are input into the backbone network, and after feature extraction is performed using the convolution modules of each stage of the backbone network, feature maps of multiple stages are obtained; wherein the size of the feature map of the latter stage is smaller than the size of the feature map of the previous stage, the number of semantic features of the feature map of the latter stage is larger than the number of semantic features of the feature map of the previous stage, and the resolution of the feature map of the latter stage is smaller than the resolution of the feature map of the previous stage.

4. The image detection method according to claim 3, characterized in that: The fusing the feature map with the feature pyramid network to obtain a feature layer specifically includes: The feature graphs of each stage are corresponded to the layers of the feature pyramid network in the order that the feature graph of the last stage corresponds to the top layer of the feature pyramid network and the feature graph of the second stage corresponds to the bottom layer of the feature pyramid network; Inputting the feature map of the last stage into the top layer of the feature pyramid for feature fusion to obtain the output result of the top layer of the feature pyramid; The second layer of the feature pyramid network is used as the current layer, and the output result of the previous layer of the current layer and the feature map corresponding to the current layer are input into the current layer for processing to obtain the output result of the current layer; If the current layer has a next layer, the next layer is used as the current layer, and the process returns to step "inputting the output result of the previous layer of the current layer together with the feature map corresponding to the current layer into the current layer for processing to obtain the output result of the current layer"; if the current layer does not have a next layer, the output results of each layer of the feature pyramid network are output, and then the step of "inputting the feature layer into the convolution layer to obtain the convolution output result, and inputting the convolution output result into the fully connected layer to obtain the predicted image abnormality probability" is executed; wherein, the output result of each layer of the feature pyramid network is the feature layer.

5. The image detection method according to claim 2, characterized in that: The step of inputting the feature layer into the convolution layer to obtain a convolution output result, and inputting the convolution output result into the fully connected layer to obtain a predicted image abnormality probability specifically includes: Using the convolutional layer to process the feature layer, a confidence of a candidate box is obtained; the confidence of the candidate box is a probability that the candidate box contains a target; When the confidence of the candidate box is greater than a preset confidence threshold, the fully connected layer is used to process the feature map area corresponding to the candidate box to obtain a predicted image abnormality probability.

6. The image detection method according to claim 2, characterized in that: After obtaining the abnormal information of the image to be detected, the method further includes: Determine the image that meets the probability requirement as an abnormal image; Determine an abnormal target in the abnormal image; the abnormal target is obtained after inputting the abnormal image into the trained target detection model and using the fully connected layer to perform feature extraction.

7. An image detection system, characterized in that: include: The differential image generation module is used to obtain a differential image by using a pixel subtraction method for adjacent frames in the video stream; A binarization processing module, used for performing binarization processing on the difference image to obtain a binarized difference image; An image change detection module, used to determine whether the pixel value of the binarized differential image is less than a preset pixel threshold, if so, determining that the image in the video stream has not changed, if not, determining that the image in the video stream has changed; a video stream extraction module, configured to extract a video stream of a first preset time length before the moment of change when it is determined that an image in the video stream has changed, and / or to extract a video stream of a second time period in the video stream of the first time period when no image change in the video stream of the first time period is detected, wherein the length of the first time period is a second preset time length, the length of the second time period is less than the length of the first time period, and the latest moment of the second time period is the same as the latest moment of the first time period; An image detection module is used to use the extracted video stream as a video stream to be detected, input the image to be detected in the video stream to be detected into a trained target detection model, and obtain abnormal information of the image to be detected; The abnormal information of the image to be detected is the probability that the image to be detected represents the existence of an abnormal situation; The image detection system further comprises: A frame extraction module is used to extract frames from the video stream to be detected to obtain multiple frames of images to be detected; The encapsulation module is used to encapsulate the image to be detected to obtain an encapsulated image to be detected.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed by a processor, the image detection method according to any one of claims 1 to 6 is implemented.

9. An electronic device, characterized in that: include: At least one processor, and at least one memory and bus connected to the processor; The processor and the memory communicate with each other via the bus; The processor is used to call the program instructions in the memory to execute the image detection method according to any one of claims 1 to 6.