Shielding detection algorithm based on lightweight neural network
Through an occlusion detection method based on a lightweight neural network, the image entropy value and fuzziness judgment are used, combined with a lightweight convolutional neural network for feature extraction, to solve the problems of complexity of the occlusion detection algorithm and false alarms in the existing technology. Efficient and accurate occlusion detection is achieved.
Patent Information
- Application Number
- CN202410886384.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-03
AI Technical Summary
Existing occlusion detection algorithms have complex feature engineering and heavy calculations, making it difficult to meet the needs of real-time monitoring and prone to misjudgment when the camera moves or the features are insufficient.
An occlusion detection method based on a lightweight neural network is adopted. By calculating the image entropy value as the initial judgment condition, combined with the fuzziness judgment and regional occlusion status, a lightweight convolutional neural network is used for feature extraction and occlusion detection to reduce unnecessary Calculations and false alarms.
It improves the efficiency and accuracy of occlusion detection, reduces power consumption, reduces false alarms caused by camera movement or single features, and achieves more stable real-time monitoring.
Abstract
Description
Technical Field
[0001] The invention relates to an occlusion detection algorithm based on a lightweight neural network. Background Art
[0002] Current occlusion detection algorithms are usually based on traditional algorithms, that is, manually extracting features to determine pixel consistency and pixel intensity, and using preset logic to determine whether the camera is blocked. However, when this method is used on actual surveillance cameras, the following problems may arise: 1. Traditional algorithm feature engineering is complex, the amount of feature extraction calculations is large, and the algorithm running speed does not meet the requirements; 2. When the camera is facing a wall with insufficient features, it is easy to be misjudged as occlusion. Summary of the invention
[0003] The purpose of the present invention is to provide an occlusion detection method based on a lightweight neural network to solve the problems raised in the above background technology. To achieve the above purpose, the present invention provides the following technical solutions:
[0004] A light-weight neural network-based occlusion detection method, comprising the following steps:
[0005] S1: The camera acquires a frame of image, which is used as a scene anchor map and the entropy value of the image is calculated;
[0006] The process of calculating image entropy is as follows:
[0007] Calculate the histogram of the image, that is, count the frequency of occurrence of each pixel value;
[0008] Normalize the histogram and convert the frequency into the probability distribution of pixel values;
[0009] Calculate the entropy of the image, that is, according to the formula of probability distribution and information entropy, calculate the information contribution of each pixel value and add it to the total image entropy. The processing formula is as follows:
[0010] The entropy of the image is calculated using the information entropy formula: H = -Σp(i)*log2(p(i)), where i ranges from [0,255]. The entropy value of the anchor image is calculated every 200ms:
[0011] S2: If the new anchor image entropy value increases, the anchor image entropy value is updated to the entropy value, and the occlusion detection effect is not triggered. If the anchor image entropy value decreases, the occlusion detection function is triggered;
[0012] S3: When the occlusion detection function is triggered, the newly collected image is sent to the detection model for inference, and the model will output three data: the occlusion situation of each part, the occlusion rate, and the blur;
[0013] S4: Determine whether there is overall motion blur in the blur image; if so, no other judgment is required and no alarm is issued; if not, check whether blur is detected in the previous frame. If so, the current frame is considered to be an anchor image after the camera moves, and the entropy of the current image is calculated without issuing an alarm; if not, determine whether an alarm is to be triggered based on the occlusion status of each area and the overall occlusion degree. If so, the alarm is triggered.
[0014] The steps of acquiring the detection model include S21:
[0015] S21: Use a lightweight model backbone network to create a model and perform model training to obtain a detection model, wherein the detection model uses three detection heads, which are used to output the occlusion status of each part of the image, the overall occlusion rate of the image, and the overall blurriness of the image.
[0016] Among them, the occlusion detection head corresponding to each part of the output image processes the feature map processed by the backbone network, uses the flatten operator to quantize the feature map, and then connects the feature vector to the same number of fully connected layers. Each neuron in the fully connected layer is connected to the sigmoid operator to normalize the result to form the output occlusion probability. In the process of training the network, the output of each neuron and the label of whether the corresponding partition is occluded are constructed into a binary cross entropy loss function L = -(Yc*log(p)+(1-Yc)*log(1-p)), where Yc is the true label of the occlusion classification and p is the model prediction probability, to optimize the state prediction of each partition.
[0017] Among them, the overall occlusion rate detection head of the output image connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result, and uses the predicted value and occlusion rate to construct the mean square error to form the L2 loss function Among them, Ya is the true label of the occlusion degree, is the value predicted by the model, predicting the overall occlusion rate of the image.
[0018] Among them, the image overall blur detection head connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result. The mean square error is constructed using the predicted value and blur to form a binary cross entropy loss function L = -(Ym*log(p)+(1-Ym)*log(1-p)), where Ym is the true label of motion blur, and p is the model prediction probability, which predicts whether the image has overall motion blur.
[0019] Yc is the real label of occlusion classification, Ya is the real label of occlusion degree, and Ym is the real label of motion blur. The acquisition steps include:
[0020] S211: Obtain scene data atlas;
[0021] S212: partition each image in the scene data atlas, and calculate stddev_g and stddev_l for each area;
[0022] Among them, stddev_g=sqrt((Σ(x-μ)2) / N),
[0023] Among them, stddev_l = sqrt(1 / N*∑(L(i)-μ)^2), where: x represents the grayscale value of each pixel, μ represents the average grayscale value of all pixels, N represents the total number of pixels, stddev_g is the standard deviation of the grayscale value distribution of the specified area in the original image, reflecting the degree of grayscale change in the original image, and L is the Laplace transform function.
[0024] Determine whether stddev_g < 20 and stddev_l < 5. If so, it is considered to be occluded. If not, it is considered to be not occluded. The occlusion situation is marked to obtain the true label Yc of the occlusion classification.
[0025] S213: Calculate the occlusion degree occ_ratio of the whole image, and obtain the true label Ya of the occlusion degree, where occ_ratio = occ_areas / areas; occ_areas is the number of areas determined to be occluded in the divided areas, and areas is the total number of divided areas;
[0026] S214: Obtain a motion blur data atlas, and annotate the motion blur data atlas to obtain a motion blur true label Ym;
[0027] The scene data atlas is a data atlas that is close to the scene in actual use; it includes data atlases for different lighting environments and indoor and outdoor scenes.
[0028] Beneficial effects: The present invention proposes a method that uses a newly designed lightweight convolutional neural network to extract image features and determine whether scene features meet occlusion conditions. At the same time, based on the background image anchoring method, the features are fused to update the background image when certain conditions are met, thereby reducing the false triggering of occlusion alarms caused by camera movement or single monitoring scene features. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. 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.
[0030] In the present invention, the directions or positional relationships indicated by the terms "upper", "lower", "left", "right", "front", "back", "top", "bottom", "inner", "outer", "middle", "vertical", "horizontal", "lateral", "longitudinal" and the like are based on the directions or positional relationships shown in the drawings. These terms are mainly used to better describe the present invention and its embodiments, and are not used to limit the indicated devices, elements or components to have a specific direction, or to be constructed and operated in a specific direction.
[0031] In addition, some of the above terms may be used to express other meanings in addition to indicating orientation or positional relationship. For example, the term "on" may also be used to express a certain dependency or connection relationship in some cases. For those skilled in the art, the specific meanings of these terms in the present invention can be understood according to specific circumstances.
[0032] In addition, the terms "installed", "set", "provided with", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral structure; it can be a mechanical connection, or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be an internal connection between two devices, elements, or components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0033] In addition, the terms "first", "second", etc. are mainly used to distinguish different devices, elements or components (the specific types and structures may be the same or different), and are not used to indicate or imply the relative importance and quantity of the indicated devices, elements or components. Unless otherwise specified, "plurality" means two or more.
[0034] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0035] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0036] The present invention provides an occlusion detection method based on a lightweight neural network, comprising the following steps:
[0037] S1: The camera acquires a frame of image and uses it as a scene anchor image, that is, the anchor image is considered to be a non-occluded scene that the user wants to detect, and the entropy value of the image is calculated;
[0038] The process of calculating image entropy is as follows:
[0039] Calculate the histogram of the image, that is, count the frequency of occurrence of each pixel value;
[0040] Normalize the histogram and convert the frequency into the probability distribution of pixel values;
[0041] Calculate the entropy of the image, that is, according to the formula of probability distribution and information entropy, calculate the information contribution of each pixel value and add it to the total image entropy. The processing formula is as follows:
[0042] The entropy of the image is calculated using the information entropy formula: H = -Σp(i)*log2(p(i)), where i ranges from [0,255]. The entropy value of the anchor image is calculated every 200ms:
[0043] S2: If the new anchor graph entropy value becomes larger, the anchor graph entropy value is updated to the entropy value, and the occlusion detection effect is not triggered (no neural network model inference is required). If the anchor graph entropy value becomes smaller, the occlusion detection function is triggered;
[0044] Specifically, entropy will be used as the basis for judging the richness of image information in the future: Specifically, for an image, the higher the entropy, the richer the information contained in the image and the more diverse the changes, and vice versa, the information is relatively simple or highly repetitive. Relatively speaking, calculating entropy is a relatively simple and efficient traditional way to calculate the complexity of the image, so it can be used as an initial judgment condition to determine whether the subsequent more complex and accurate occlusion detection is triggered, making the judgment process smoother and removing redundant judgment steps.
[0045] S3: When the occlusion detection function is triggered, the newly acquired image is sent to the detection model for inference. The model will output three data: the occlusion status of each part, the occlusion rate, and the blurriness.
[0046] S4: Check whether there is overall motion blur in the blur image; if so, no other judgment is required and no alarm is issued; if not, check whether blur is detected in the previous frame. If so, the current frame is considered to be an anchor image after the camera moves, and the entropy of the current image is calculated without issuing an alarm; if not, judge based on the occlusion status of each area and the overall occlusion degree to determine whether an alarm is to be triggered. If so, the alarm is triggered, preferably, the alarm lasts for five seconds.
[0047] As an example: if 40%-70% of the area is judged to be occluded (based on the overall occlusion judgment) and each small area judged to be occluded belongs to one or two connected domains, an alarm is triggered. If 40%-70% of the area is judged to be occluded, but each small area judged to be occluded forms more than two (not including) connected domains, no alarm is triggered. 3. If 70% of the area (or more) is judged to be occluded, an alarm is directly triggered. The acquisition step of the detection model includes S21:
[0048] S21: Use a lightweight model backbone network to create a model and perform model training to obtain a detection model, wherein the detection model uses three detection heads, which are used to output the occlusion status of each part of the image, the overall occlusion rate of the image, and the overall blurriness of the image.
[0049] Specifically, the backbone network of the lightweight model is mobilenetv4. During training, the backbone network must be downsampled 5 times. This setting corresponds to partitioning each image in the training data set. After downsampling five times, the length and width of the feature map obtained are 1 / 32 of the original length and width. Each pixel point of the feature map corresponds to the area position of each partition on the original image. By directly processing the result of the point, the occlusion status corresponding to each area can be output. The model requires three detection heads, which are used to output: the occlusion status of each part of the image; the overall occlusion rate of the image; and the overall blurriness of the image.
[0050] Among them, the occlusion detection head corresponding to each part of the output image processes the feature map processed by the backbone network, uses the flatten operator to quantize the feature map, and then connects the feature vector to the same number of fully connected layers. Each neuron in the fully connected layer is connected to the sigmoid operator to normalize the result to form the output occlusion probability. In the process of training the network, the output of each neuron and the label of whether the corresponding partition is occluded are constructed into a binary cross entropy loss function L = -(Yc*log(p)+(1-Yc)*log(1-p)), where Yc is the true label of the occlusion classification and p is the model prediction probability, to optimize the state prediction of each partition.
[0051] Among them, the overall occlusion rate detection head of the output image connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result, and uses the predicted value and occlusion rate to construct the mean square error to form the L2 loss function Among them, Ya is the true label of the occlusion degree, is the value predicted by the model, predicting the overall occlusion rate of the image.
[0052] Among them, the image overall blur detection head connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result. The mean square error is constructed using the predicted value and blur to form a binary cross entropy loss function L = -(Ym*log(p)+(1-Ym)*log(1-p)), where Ym is the true label of motion blur, and p is the model prediction probability, which predicts whether the image has overall motion blur.
[0053] Yc is the real label of occlusion classification, Ya is the real label of occlusion degree, and Ym is the real label of motion blur. The acquisition steps include:
[0054] S211: Obtain scene data atlas;
[0055] Specifically, the scene data atlas is a data atlas close to the scene during actual use;
[0056] As an example: a data set containing different lighting environments, indoor and outdoor scenes requires about 50,000 images, and the image size is uniformly 640*480;
[0057] S212: partition each image in the scene data atlas, and calculate stddev_g and stddev_l for each area;
[0058] Among them, stddev_g=sqrt((Σ(x-μ)2) / N),
[0059] Among them, stddev_l = sqrt(1 / N*∑(L(i)-μ)^2), where: x represents the grayscale value of each pixel, μ represents the average grayscale value of all pixels, N represents the total number of pixels, stddev_g is the standard deviation of the grayscale value distribution of the specified area in the original image, reflecting the degree of grayscale change in the original image, and L is the Laplace transform function.
[0060] Determine whether stddev_g < 20 and stddev_l < 5. If so, it is considered to be occluded. If not, it is considered to be not occluded. The occlusion situation is marked to obtain the true label Yc of the occlusion classification.
[0061] As an example: the image is divided into 32*32 squares.
[0062] S213: Calculate the occlusion degree occ_ratio of the whole image, and obtain the true label Ya of the occlusion degree, where occ_ratio = occ_areas / areas; occ_areas is the number of areas determined to be occluded in the divided areas, and areas is the total number of divided areas;
[0063] S214: Obtain a motion blur data atlas, and annotate the motion blur data atlas to obtain a motion blur true label Ym;
[0064] Blurred data can be directly used from open source datasets with full-image motion blur, and about 20,000 such images are prepared. This batch of data is needed to train the model to determine whether the camera is rotating.
[0065] In the model, we calculate the overall occlusion rate of the image and the occlusion of each part separately. First, in order to make the two losses complement each other in training, if one content is predicted incorrectly, the other prediction can guide the correction and form a constraint. Second, in actual usage scenarios, we can form more complex logical judgment conditions based on these two values to meet the different needs of more customers. For example, the need to determine whether a specified area is occluded.
[0066] First, determine whether the image has overall motion blur based on the blurriness. If there is overall motion blur, no other judgment is required, no alarm is issued, and the blur detection is recorded. If the blurriness determines that there is no motion blur in the current picture, check the previous detection status to see whether blur was detected the previous time. If blur was detected the previous time, it is considered that the current image is an anchor image after the camera moved, and the entropy of the current image is calculated, and no alarm is issued. If blur was not detected the previous time and there is no blur in the current frame, the occlusion status of each area and the overall occlusion degree are combined to determine whether an alarm should be triggered. If the alarm is triggered, the alarm will continue for five seconds and then stop. Update the entropy of the anchor image to the entropy of the current picture.
[0067] According to the above process, during occlusion detection, you can avoid:
[0068] 1. Additional computing power. We only call the neural network model for occlusion inference when the image entropy decreases. Therefore, it can run stably in low-power mode for a long time, and additional computing power is called only when necessary.
[0069] 2. False alarms are triggered when the camera moves or rotates. This is because after the camera rotates, it may be rotated to a scene with low image entropy and very similar to occlusion (such as a white wall). At this time, other occlusion detection algorithms are prone to false alarms. We consider that the picture will have overall motion blur when the camera moves, so based on the inference of the model, we can avoid the false alarms generated by the algorithm in this case.
[0070] 3. Even in the above situation, if a false alarm still occurs, the number of false alarms will be reduced as much as possible. After the alarm is triggered, the entropy value of the anchor graph will be updated and the alarm will be stopped. The current scene will be set as the scene the user wants to detect and continue monitoring.
[0071] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. The protection scope of the present invention shall be subject to the protection scope of the claims. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical content disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.
Claims
1. An occlusion detection method based on lightweight neural network, It is characterized in that The following steps are involved: S1: The camera acquires a frame of image, which is used as a scene anchor map and the entropy value of the image is calculated; The process of calculating the image entropy value is as follows: Calculate the histogram of the image, that is, count the frequency of occurrence of each pixel value; Normalize the histogram and convert the frequency into the probability distribution of pixel values; Calculate the entropy of the image, that is, according to the formula of probability distribution and information entropy, calculate the information contribution of each pixel value and add it to the total image entropy. The processing formula is as follows: The entropy of the image is calculated using the information entropy formula: H = -Σp(i)*log2(p(i)), where i ranges from [0,255]. The entropy value of the anchor image is calculated every 200ms: S2: If the new anchor image entropy value increases, the anchor image entropy value is updated to the entropy value, and the occlusion detection effect is not triggered. If the anchor image entropy value decreases, the occlusion detection function is triggered; S3: When the occlusion detection function is triggered, the newly collected image is sent to the detection model for inference, and the model will output three data: the occlusion situation of each part, the occlusion rate, and the blur; S4: Determine whether there is overall motion blur in the blur image; if so, no other judgment is required and no alarm is issued; if not, check whether blur is detected in the previous frame. If so, consider that the current frame is an anchor image after the camera moves, calculate the entropy of the current image, and do not issue an alarm; if not, determine whether to trigger an alarm based on the occlusion status of each area and the overall occlusion degree. If so, the alarm is triggered.
2. According to claim 1, a light-weight neural network-based occlusion detection method, Features: The steps of acquiring the detection model include S21: S21: Use a lightweight model backbone network to create a model and perform model training to obtain a detection model, wherein the detection model uses three detection heads, which are used to output the occlusion status of each part of the image, the overall occlusion rate of the image, and the overall blurriness of the image.
3. A method for synchronously controlling multiple motors according to claim 2, Features: in, The occlusion detection head corresponding to each part of the output image processes the feature map processed by the backbone network, uses the flatten operator to vectorize the feature map, and then connects the feature vector to the same number of fully connected layers. Each neuron in the fully connected layer is connected to the sigmoid operator to normalize the result to form the output occlusion probability. In the process of training the network, the output of each neuron and the label of whether the corresponding partition is occluded are constructed into a binary cross entropy loss function L = -(Yc*log(p)+(1-Yc)*log(1-p)), where Yc is the true label of the occlusion classification and p is the model prediction probability, to optimize the state prediction of each partition. Among them, the overall occlusion rate detection head of the output image connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result, and uses the predicted value and occlusion rate to construct the mean square error to form the L2 loss function Among them, Ya is the true label of the occlusion degree, is the value predicted by the model, predicting the overall occlusion rate of the image. Among them, the image overall blur detection head connects the feature vector flattened by the flatten operator to a short fully connected layer for compression, and then uses a single binary classification to output the result. The mean square error is constructed using the predicted value and blur to form a binary cross entropy loss function L = -(Ym*log(p)+(1-Ym)*log(1-p)), where Ym is the true label of motion blur, and p is the model prediction probability, which predicts whether the image has overall motion blur.
4. The occlusion detection method based on a lightweight neural network according to claim 3, It is characterized in that Yc is the real label of occlusion classification, Ya is the real label of occlusion degree, and Ym is the real label of motion blur. The acquisition steps include: S211: Obtain scene data atlas; S212: partition each image in the scene data atlas, and calculate stddev_g and stddev_l for each area; Among them, stddev_g=sqrt((Σ(x-μ)2) / N), Among them, stddev_l = sqrt(1 / N*∑(L(i)-μ)^2), where: x represents the grayscale value of each pixel, μ represents the average grayscale value of all pixels, N represents the total number of pixels, stddev_g is the standard deviation of the grayscale value distribution of the specified area in the original image, reflecting the degree of grayscale change in the original image, and L is the Laplace transform function. Determine whether stddev_g < 20 and stddev_l < 5. If so, it is considered to be occluded. If not, it is considered to be not occluded. The occlusion situation is marked to obtain the true label Yc of the occlusion classification. S213: Calculate the occlusion degree occ_ratio of the whole image, and obtain the true label Ya of the occlusion degree, where occ_ratio = occ_areas / areas; occ_areas is the number of areas determined to be occluded in the divided areas, and areas is the total number of divided areas; S214: Obtain a motion blur data atlas, and annotate the motion blur data atlas to obtain the motion blur true label Ym.
5. The occlusion detection method based on a lightweight neural network according to claim 4, It is characterized in that The scene data atlas is a data atlas that is close to the scene in actual use; it includes data atlases for different lighting environments and indoor and outdoor scenes.
Citation Information
Patent Citations
Animal detection method based on entropy and motion offset
CN109657577A
Camera blocking area detection method and device, equipment and storage medium
CN111932596A
Lightweight real-time face detection method based on multiple tasks
CN113158862A
Camera shielding detection method
CN117576389A
Method and Apparatus for Depth Image Estimation of Light Fields
KR1020180131787A
Cited By
Image occlusion detection method and device
CN120783057A
