Garbage can cover opening and closing detection method, device and equipment and storage medium
By using different models to process daytime and nighttime images in trash can lid detection, and combining the nighttime multi-level enhancement network and the improved detection model, the problem of misjudgment and missed detection under low light conditions at night is solved and the detection accuracy is improved. and supervisory capabilities, reducing labor costs.
Patent Information
- Application Number
- CN202311616708.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2024-10-18
AI Technical Summary
The existing technology has problems of misjudgment and missed judgment in the detection of opening and closing of trash can lids. The accuracy decreases especially under low-light conditions at night, resulting in false alarms and increased labor costs. The sensor is also costly and complex to install.
Different models are used to process daytime and nighttime images respectively, combined with the nighttime multi-level enhancement network and the improved yolov5 model, through the bucket lid sorting strategy and post-processing logic to improve detection accuracy and reduce false detections and missed detections.
Under low-light conditions at night, it significantly improves the accuracy of opening and closing detection of trash can lids, reduces false alarms and missed alarms, improves supervision capabilities in restaurants and kitchen scenes, and reduces labor costs.
Smart Images

Figure CN118799709A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for detecting the opening and closing of a trash can lid. Background Art
[0002] In recent years, with the continuous development of society, people's pace of life has become faster and faster. Ordering takeout and dining out have gradually become people's daily lives, and food hygiene and safety have also become the focus of social attention. At present, consumers can only view the basic information of the merchant's qualifications and store environment pictures through the ordering platform to determine whether the food sold by the merchant is safe and qualified. The ability to detect the opening and closing of the trash can lid is a very important ability for food hygiene and safety. There are often trash cans in restaurants and back kitchens. If the trash can lid is not closed properly, it will cause the garbage to overflow and emit an unpleasant odor, affecting the environmental sanitation of the entire restaurant. At the same time, the garbage leakage problem also brings food safety risks.
[0003] Existing technologies usually use manual inspections or sensors, artificial intelligence target detection and other technologies to detect the opening and closing of trash can lids. However, the manual inspection method is labor-intensive, costly, and cannot achieve seamless detection 24 hours a day. The sensor detection method is easily affected by factors such as humidity, temperature, and dust, which will lead to a decrease in detection accuracy. The sensor cost is high, the installation is complicated, and additional hardware equipment is usually required. The artificial intelligence target detection method is similar to the characteristics of the trash cans. There are many factors such as the influence of low-light images at night in actual scenes, which will lead to a large number of misjudgments, resulting in an increase in false alarms and indirectly increasing labor costs. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method, device, equipment and storage medium for detecting the opening and closing of a trash can lid, which takes into account the difference in light between nighttime images and daytime images, and uses different models for detection respectively, thereby effectively improving the accuracy of detecting the opening and closing of the trash can lid in low light conditions at night. At the same time, the detection strategy of lid separation is adopted, which effectively reduces the situation of false detection and missed detection, and improves the accuracy of detection.
[0005] In order to achieve the above object, an embodiment of the present invention provides a method for detecting the opening and closing of a trash can lid, comprising:
[0006] Acquire an image to be detected based on the target scene, and preprocess the image to be detected;
[0007] Input the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model;
[0008] Determine, according to the trash can detection frame and the non-trash can detection frame in the initial detection result, a lid detection frame that matches the trash can detection frame;
[0009] The opening and closing state of the trash can lid is obtained according to the trash can detection frame and the lid detection frame.
[0010] As an improvement of the above solution, the training method of the trash can detection model specifically includes:
[0011] Collect historical images of the target site, and annotate the historical images according to preset barrel cover sorting and annotation rules to obtain annotated images as a data set;
[0012] Classifying the images in the data set, dividing the images in the data set into daytime images and nighttime images;
[0013] Input the daytime image into the improved yolov5 model for training to obtain a daytime image detection model;
[0014] Input the night image into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model;
[0015] The trash can detection model is obtained according to the daytime image detection model and the nighttime image detection model.
[0016] As an improvement of the above scheme, the improved method of improving the yolov5 model specifically includes:
[0017] Based on the yolov5 model, the convolutional attention module is integrated to reorganize the feature map through the channel submodule and the spatial submodule;
[0018] Combined with the weighted bidirectional feature pyramid network, the top-down and bottom-up deep and shallow features are bidirectionally fused;
[0019] The non-maximum suppression NMS algorithm is replaced by the DIOU-NMS algorithm, and the detection frames are screened by the intersection-over-union ratio and the distance between the center points of two detection frames.
[0020] As an improvement of the above scheme, the night image is input into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model, which specifically includes:
[0021] Inputting the night image into each level of enhancement network for feature enhancement to obtain multiple initial enhanced images;
[0022] Performing concat and convolution operations on the multiple initial enhanced images to obtain an enhanced image;
[0023] Input the enhanced image into the improved yolov5 model to obtain the actual detection result;
[0024] Iterative training is performed according to the actual detection results and the target detection results until a preset iteration condition is met to obtain a trained night image detection model.
[0025] As an improvement of the above solution, the night image is input into each level enhancement network for feature enhancement to obtain multiple initial enhanced images, specifically including:
[0026] Inputting the nighttime image into the enhancement filter of each level of enhancement network to perform first feature enhancement, thereby obtaining a plurality of first enhanced images;
[0027] The width and height of each of the first enhanced images are scaled using a bilinear interpolation method, and the scaled images are subjected to a second feature enhancement through a detail processing module and a low-frequency enhancement module to obtain a plurality of initial enhanced images.
[0028] As an improvement of the above solution, the detail processing module includes a global understanding branch and an edge enhancement branch;
[0029] The global understanding branch obtains global information by capturing long-range dependencies, and sets residual modules before and after the capture to transmit low-frequency information through skip connections for global enhancement.
[0030] The edge enhancement branch calculates the image gradient by using two Sobel operators in different directions, then re-extracts the edge information by convolution, and uses a residual module to enhance the information flow to enhance the edge details.
[0031] As an improvement of the above solution, the processing process of the low-frequency enhancement module includes:
[0032] Through convolution operations and channel separation operations, the input features are divided into different scales;
[0033] Adaptive average pooling and bilinear interpolation upsampling are performed for each scale to filter high-frequency information and restore all tensors to the size of the original image;
[0034] The outputs of multiple scales are concat-concatenated and convolved to obtain output features.
[0035] As an improvement of the above solution, the step of determining a lid detection frame matching the trash can detection frame according to the trash can detection frame and the non-trash can detection frame in the initial detection result specifically includes:
[0036] Calculating an intersection-over-union ratio according to a trash can detection frame and a non-trash can detection frame in the initial detection result;
[0037] The non-trash can detection frames are screened according to the intersection-and-union ratio, and the non-trash can detection frames whose intersection-and-union ratios do not meet a preset intersection-and-union ratio condition are deleted to obtain a candidate bucket cover detection frame;
[0038] Calculate the center point coordinates of the trash can detection frame and the candidate lid detection frame respectively;
[0039] The candidate barrel cover detection frames are screened according to the center point coordinates, and the candidate barrel cover detection frames whose center point coordinates do not meet the preset conditions are deleted to obtain the target barrel cover detection frame;
[0040] The confidence of the target bucket cover detection frame is calculated, and the target bucket cover detection frame with the highest confidence is the bucket cover detection frame that matches the trash can detection frame.
[0041] As an improvement of the above solution, the calculation formula of the intersection-over-union ratio is:
[0042]
[0043] Where IOU represents intersection over union; A represents the trash can detection box; B represents the non-trash can detection box.
[0044] The embodiment of the present invention further provides a garbage can lid opening and closing detection device, comprising:
[0045] An image acquisition module is used to acquire an image to be detected based on the target scene and pre-process the image to be detected;
[0046] A trash can detection module, used to input the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model;
[0047] A detection frame matching module, configured to determine a lid detection frame that matches the trash can detection frame based on the trash can detection frame and the non-trash can detection frame in the initial detection result;
[0048] The lid opening and closing detection module is used to obtain the opening and closing status of the lid of the trash can according to the trash can detection frame and the lid detection frame.
[0049] An embodiment of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any of the above-mentioned methods for detecting the opening and closing of a trash can lid when executing the computer program.
[0050] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned methods for detecting the opening and closing of a trash can lid.
[0051] Compared with the prior art, the beneficial effects of a method, device, equipment and storage medium for detecting the opening and closing of a trash can lid provided by an embodiment of the present invention are as follows: comprehensively considering the deficiencies and defects of the trash can lid opening and closing ability algorithm in actual application scenarios, such as many false alarms, and false alarms and missed reports and missed judgments caused by insensitivity to low-light images at night, by adopting a lid sorting detection strategy and corresponding post-processing logic, the false detection and missed detection in actual scenarios are effectively reduced, and the detection accuracy is improved; by using a combination of a night multi-level enhancement network and a detector, different models are used to detect daytime images and nighttime images respectively, which greatly improves the accuracy of trash can lid opening and closing detection in low-light conditions at night, thereby improving the overall supervision ability of backstage staff over back kitchen and restaurant scenes, promoting the promotion and use of artificial intelligence technology in this field, and overcoming the deficiencies of the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flow chart of a preferred embodiment of a method for detecting the opening and closing of a garbage can lid provided by the present invention;
[0053] Figure 2 It is a structural schematic diagram of a night image detection model in a method for detecting the opening and closing of a trash can lid provided by the present invention;
[0054] Figure 3 It is a structural schematic diagram of a detail processing module in a method for detecting the opening and closing of a trash can lid provided by the present invention;
[0055] Figure 4 It is a structural schematic diagram of a low-frequency enhancement module in a method for detecting the opening and closing of a trash can lid provided by the present invention;
[0056] Figure 5 It is a schematic diagram of the process of post-processing the initial detection result in a method for detecting the opening and closing of a trash can lid provided by the present invention;
[0057] Figure 6 It is a structural schematic diagram of a preferred embodiment of a garbage can lid opening and closing detection device provided by the present invention;
[0058] Figure 7 It is a structural schematic diagram of a preferred embodiment of a terminal device provided by the present invention. DETAILED DESCRIPTION
[0059] 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.
[0060] See also Figure 1 , Figure 1 The figure is a flow chart of a preferred embodiment of a method for detecting the opening and closing of a trash can lid provided by the present invention. The method for detecting the opening and closing of a trash can lid comprises:
[0061] S1, acquiring an image to be detected based on a target scene, and preprocessing the image to be detected;
[0062] S2, inputting the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model;
[0063] S3, determining a lid detection frame that matches the trash can detection frame according to the trash can detection frame and the non-trash can detection frame in the initial detection result;
[0064] S4, obtaining the opening and closing state of the trash can lid according to the trash can detection frame and the lid detection frame.
[0065] Specifically, the embodiment of the present invention obtains the image to be detected based on the target scene, such as the kitchen or restaurant, and pre-processes the image to be detected. The pre-processed image to be detected is input into the preset trash can detection model to obtain the initial detection result output by the trash can detection model. Among them, the trash can detection model includes a daytime image detection model and a nighttime image detection model. When the image to be detected is input into the preset trash can detection model, it will automatically distinguish between daytime images and nighttime images. If it is a daytime image, the daytime image detection model is used for reasoning; if it is a nighttime image, the nighttime image detection model is used for reasoning. Then, the reasoning result is processed according to the lid inspection post-processing logic to complete the detection of the opening and closing of the trash can lid. That is, according to the trash can detection frame and the non-trash can detection frame in the initial detection result, the lid detection frame matching the trash can detection frame is determined. According to the trash can detection frame and the lid detection frame, the opening and closing state of the trash can lid is obtained. The embodiment of the present invention samples the video stream once every 5 minutes. When the same trash can is detected to be uncovered in the sampled images for 15 consecutive minutes, the alarm system will be triggered to remind the relevant staff to handle it in time.
[0066] It should be noted that the data collected by the camera is bright during the day. The visible light such as sunlight or lamplight will illuminate objects and reflect light. The camera can collect the reflected visible light to present a colorful world and restore the real scene color. Therefore, the images collected during the day are color images in RGB format. However, at night, there is less visible light, and the camera uses infrared light to fill in the light. The images collected at night are infrared images. After encoding and decoding during the transmission process, the infrared images with the same three channels will be obtained. Whether the values of the three channels of the input image are consistent is used as the basis for judging whether the image is daytime or nighttime. The images are sent to the two models for inference and output results.
[0067] The embodiment of the present invention takes into account the difference in light between nighttime images and daytime images, and uses different models for detection, thereby effectively improving the accuracy of garbage can lid opening and closing detection in low light conditions at night. At the same time, the detection strategy of lid separation inspection effectively reduces the situation of false detection and missed detection, and improves the detection accuracy.
[0068] In another preferred embodiment, the training method of the trash can detection model specifically includes:
[0069] Collect historical images of the target site, and annotate the historical images according to preset barrel cover sorting and annotation rules to obtain annotated images as a data set;
[0070] Classifying the images in the data set, dividing the images in the data set into daytime images and nighttime images;
[0071] Input the daytime image into the improved yolov5 model for training to obtain a daytime image detection model;
[0072] Input the night image into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model;
[0073] The trash can detection model is obtained according to the daytime image detection model and the nighttime image detection model.
[0074] Specifically, the embodiment of the present invention collects pictures related to the trash cans in the kitchen or restaurant as a data set, and the collected data can be pictures or videos collected by video surveillance equipment. For video data, a frame can be extracted every certain number of frames, and then the collected data can be labeled according to a specially preset bucket cover sorting and labeling rule to construct a data set. Among them, the bucket cover sorting and labeling rule is specifically as follows: all trash cans in the image are labeled with picture frames, regardless of whether the trash can is open or closed, the label is uniformly trash can; each trash can lid part is labeled, and the labels are open and closed respectively. The images in the data set are classified and divided into daytime images and nighttime images. The improved yolov5 model is trained using the daytime images in the data set, and the nighttime images are used to train the combination of nighttime multi-level enhancement and the improved yolov5 model to obtain two models, namely the daytime image model and the nighttime image model, and the two trained models are deployed on the server.
[0075] It should be noted that, when collecting historical images of the target scene, the embodiments of the present invention can, in addition to collecting through video surveillance equipment, also utilize some public data sets on the Internet; crawl the Internet according to keywords, and then filter out some data that meets the usage conditions; find professional collectors to collect data, etc. to collect data.
[0076] In another preferred embodiment, the improved method of improving the yolov5 model specifically includes:
[0077] Based on the yolov5 model, the convolutional attention module is integrated to reorganize the feature map through the channel submodule and the spatial submodule;
[0078] Combined with the weighted bidirectional feature pyramid network, the top-down and bottom-up deep and shallow features are bidirectionally fused;
[0079] The non-maximum suppression NMS algorithm is replaced by the DIOU-NMS algorithm, and the detection frames are screened by the intersection-over-union ratio and the distance between the center points of two detection frames.
[0080] Specifically, for ordinary daytime scenes, the mainstream technology of target detection in the field of deep learning is generally represented by two directions of network architecture, one is the R-CNN series algorithm based on the two-stage deep network structure of the candidate box; the other is the YOLO series algorithm based on the single-stage deep network structure of the regression target box. The YOLO series algorithm has achieved a good balance between speed and accuracy. With the launch of the YOLOv5 series algorithm, it has been widely used in academia and industry. The embodiment of the present invention comprehensively considers the advantages and applicable scenarios of the two architectures, and finally selects YOLOv5 as the detection model, and makes certain improvements on its basis. In order to target the complex characteristics of scene environments such as restaurant kitchens, the embodiment of the present invention takes the YOLOv5 model as the basic model, integrates the convolution attention module, combines the spatial and channel attention information, reorganizes the feature map through the two sub-modules of channel and space, enhances the importance of spatial position information and channel information features, and suppresses useless information, so as to achieve the purpose of improving the target detection effect of the YOLOv5 algorithm model. Combined with the weighted bidirectional feature pyramid network and the new feature fusion method, the bidirectional fusion of deep and shallow features from top to bottom and bottom to top is realized, the transmission of feature information between different network layers is enhanced, and the detection accuracy of the YOLOv5 algorithm is significantly improved. In the NMS stage, the DIOU-NMS algorithm is used to replace the ordinary NMS algorithm. Because in actual application scenarios, when two different objects are very close, the intersection-over-union (IOU) value is relatively large. Often after NMS processing, only one detection frame is left, which often leads to missed detection errors. Based on this, DIOU-NMS not only considers IOU, but also the distance between the center points of the two detection frames, which can significantly reduce the number of missed detections. The improved yolov5 model is used to identify the opening and closing of trash can lids during the day. Compared with the basic yolov5 model, it has higher accuracy and better detection effect.
[0081] In another preferred embodiment, the night image is input into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model, specifically including:
[0082] Inputting the night image into each level of enhancement network for feature enhancement to obtain multiple initial enhanced images;
[0083] Performing concat and convolution operations on the multiple initial enhanced images to obtain an enhanced image;
[0084] Input the enhanced image into the improved yolov5 model to obtain the actual detection result;
[0085] Iterative training is performed according to the actual detection results and the target detection results until a preset iteration condition is met to obtain a trained night image detection model.
[0086] Specifically, for low-light scenes at night, we use a combination of a nighttime multi-level enhancement network and an improved yolov5 model. After the input image is enhanced by the multi-level enhancement network to obtain a nighttime image, it is input into the improved yolov5 model used during the day to finally obtain the detection result. Figure 2 , Figure 2 It is a structural schematic diagram of a night image detection model in a method for detecting the opening and closing of a trash can lid provided by the present invention. In the embodiment of the present invention, the night image detection model includes a multi-level enhancement network and an improved yolov5 model. The night image is input into each level of the enhancement network for feature enhancement to obtain multiple initial enhanced images. Concat splicing and convolution operations are performed on the multiple initial enhanced images to obtain an enhanced image. The enhanced image is input into the improved yolov5 model to obtain an actual detection result. Iterative training is performed according to the actual detection result and the target detection result until the preset iteration conditions are met to obtain a trained night image detection model.
[0087] In another preferred embodiment, the step of inputting the nighttime image into each level of enhancement network for feature enhancement to obtain a plurality of initial enhanced images specifically includes:
[0088] Inputting the nighttime image into the enhancement filter of each level of enhancement network to perform first feature enhancement, thereby obtaining a plurality of first enhanced images;
[0089] The width and height of each of the first enhanced images are scaled using a bilinear interpolation method, and the scaled images are subjected to a second feature enhancement through a detail processing module and a low-frequency enhancement module to obtain a plurality of initial enhanced images.
[0090] Specifically, the embodiment of the present invention inputs the night image into the enhancement filter of each level of enhancement network for first feature enhancement, improves the contrast of the object in the image, is beneficial to subsequent target detection, and obtains multiple first enhanced images. Then the width and height of each first enhanced image are scaled using a bilinear interpolation method. In order to restore the original high-resolution image after upsampling, the lost information is required, and the lost information constitutes the Laplacian pyramid. When reconstructing the image, only the corresponding reverse operation needs to be performed to restore the high-resolution image, and the lost information is the object enhanced by the enhancement network. The scaled image (lost information) is subjected to a second feature enhancement through a parallel detail processing module and a low-frequency enhancement module to improve the performance of the subsequent detector and obtain multiple initial enhanced images.
[0091] It should be noted that the enhanced filter includes the following filters:
[0092] 1. Mean Filter: Used to smooth images by replacing the value of the central pixel by calculating the average value of the neighborhood around the pixel.
[0093] 2. Gaussian Filter: It is also used to smooth images, but unlike the mean filter, the Gaussian filter uses a weighted average to perform Gaussian weighted calculations on pixels near the center pixel.
[0094] 3. Median Filter: Used to remove salt and pepper noise in the image by calculating the median of the neighborhood around the pixel to replace the value of the central pixel.
[0095] 4. Bilateral Filter: It can smooth the image while retaining edge information by weighting the spatial distance of pixels and the similarity of pixel values.
[0096] 5. Sharpening Filter: It is used to enhance the edges and details of the image by performing high-pass filtering on the image to highlight the high-frequency information in the image.
[0097] 6.Sobel filter: used for edge detection, finding edges in an image by calculating the gradient of pixels in the image.
[0098] 7.Laplacian filter: It is also used for edge detection, which finds the edges in the image by calculating the second-order derivative of the pixels in the image.
[0099] 8.Scharr filter: Also used for edge detection, similar to the Sobel filter, but more sensitive to edges.
[0100] In yet another preferred embodiment, the detail processing module includes a global understanding branch and an edge enhancement branch;
[0101] The global understanding branch obtains global information by capturing long-range dependencies, and sets residual modules before and after the capture to transmit low-frequency information through skip connections for global enhancement.
[0102] The edge enhancement branch calculates the image gradient by using two Sobel operators in different directions, then re-extracts the edge information by convolution, and uses a residual module to enhance the information flow to enhance the edge details.
[0103] For details, please refer to Figure 3 , Figure 31 is a schematic diagram of the structure of a detail processing module in a method for detecting the opening and closing of a trash can lid provided by the present invention. In the embodiment of the present invention, the detail processing module is divided into two branches, namely a global understanding branch and an edge enhancement branch. Figure 3 The left half is the global understanding branch, which obtains global information by capturing long-range dependencies. At the same time, there is a residual structure before and after the capture, which transmits low-frequency information through jump connections for global enhancement, because capturing global information is beneficial for low-level visual tasks such as low-light image enhancement. The right half is the edge enhancement branch, which calculates the image gradient using two Sobel operators in different directions, then re-extracts the edge information through convolution, and uses the residual to enhance the information flow, which can enhance the edge details. Finally, the outputs of the two branches are concat spliced to obtain the output features.
[0104] In another preferred embodiment, the processing of the low frequency enhancement module includes:
[0105] Through convolution operations and channel separation operations, the input features are divided into different scales;
[0106] Adaptive average pooling and bilinear interpolation upsampling are performed for each scale to filter high-frequency information and restore all tensors to the size of the original image;
[0107] The outputs of multiple scales are concat-concatenated and convolved to obtain output features.
[0108] For details, please refer to Figure 4 , Figure 4 It is a structural schematic diagram of a low-frequency enhancement module in a method for detecting the opening and closing of a trash can lid provided by the present invention. The main purpose of the low-frequency enhancement module in the embodiment of the present invention is to capture the low-frequency information in the image, because the low-frequency information contains a large amount of semantic information of the image. First, the input features are divided into different scales by convolution operations and channel separation operations, and then all tensors are restored to the size of the original image by adaptive average pooling and bilinear interpolation upsampling for each scale. Since the adaptive average pooling layer is equivalent to a low-frequency filter, high-frequency information can be filtered out. Because high-frequency information generally contains noise, blur, etc. of the image, after performing an adaptive average pooling operation, denoising can be performed while retaining most of the semantic information of the image. After that, the outputs of multiple scales are concat spliced and convolution operations are performed to obtain output features. The enhanced image through the multi-level enhancement network at night is input into the improved yolov5 detector to finally form the entire network structure. An end-to-end training method is adopted during training to obtain a model with strong low-light resistance.
[0109] In another preferred embodiment, the step S3, determining a lid detection frame that matches the trash can detection frame according to the trash can detection frame and the non-trash can detection frame in the initial detection result, specifically includes:
[0110] S301, calculating an intersection-over-union ratio according to a trash can detection frame and a non-trash can detection frame in the initial detection result;
[0111] S302, screening the non-trash can detection frames according to the IoU ratio, deleting the non-trash can detection frames whose IoU ratios do not meet a preset IoU ratio condition, and obtaining a candidate bucket cover detection frame;
[0112] S303, respectively calculating the center point coordinates of the trash can detection frame and the candidate trash can cover detection frame;
[0113] S304, screening the candidate barrel cover detection frames according to the center point coordinates, deleting the candidate barrel cover detection frames whose center point coordinates do not meet the preset conditions, and obtaining the target barrel cover detection frame;
[0114] S305, calculating the confidence of the target bucket cover detection frame, and the target bucket cover detection frame with the highest confidence is the bucket cover detection frame that matches the trash can detection frame.
[0115] For details, please refer to Figure 5 , Figure 5 It is a flow chart of the post-processing of the initial detection result in a method for detecting the opening and closing of a trash can lid provided by the present invention. First, the labels of all detection frames are screened. If the labels of all detection frames do not have the trash can attribute, it is considered that no trash can is detected in this image, and no result is output for this image. If there is a detection frame with a trash can label, special IOU calculations are performed on the other detection frames except the trash can and the trash can detection frame respectively, and those that meet the conditions will be paired. Next, the center coordinates of the paired trash can detection frame and the candidate lid detection frame (the lid detection frame, i.e., the lid or no lid detection frame) are calculated. Since the center point of the candidate lid detection frame must be above the center point of the trash can, the center point of the frame is judged, and the candidate lid detection frames that do not meet the conditions are removed to obtain the target lid detection frame. Finally, the lid detection frame with the highest confidence is selected from all the target lid detection frames paired with a certain trash can detection frame, that is, the lid detection frame that matches the trash can detection frame, which is used to replace the trash can label, and the detection frame of this trash can and the replaced label are output.
[0116] Compared with directly marking trash cans as covered or uncovered and then conducting inspections, the embodiment of the present invention uses such a post-processing method, which has the advantages of greatly reducing false recalls and improving accuracy, thereby avoiding false alarms and increasing unnecessary labor costs.
[0117] In another preferred embodiment, the calculation formula of the intersection-over-union ratio is:
[0118]
[0119] Where IOU represents intersection over union; A represents the trash can detection box; B represents the non-trash can detection box.
[0120] It should be noted that, since the trash can detection frame generally includes a large area of the covered and uncovered detection frame, the embodiment of the present invention needs to make certain changes when calculating the IOU, and uses the following calculation formula:
[0121]
[0122] If the union of the two detection frames is used as the denominator, these numerical results will generally be very small and cannot be screened, so the area of the covered and uncovered detection frames (i.e., non-trash can detection frames) is used as the denominator.
[0123] Correspondingly, the present invention also provides a garbage can lid opening and closing detection device, which can implement all processes of the garbage can lid opening and closing detection method in the above embodiment.
[0124] See also Figure 6 , Figure 6 The figure is a schematic diagram of a preferred embodiment of a garbage can lid opening and closing detection device provided by the present invention. The garbage can lid opening and closing detection device comprises:
[0125] The image acquisition module 601 is used to acquire the image to be detected based on the target scene and pre-process the image to be detected;
[0126] The trash can detection module 602 is used to input the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model;
[0127] A detection frame matching module 603 is used to determine a lid detection frame that matches the trash can detection frame according to the trash can detection frame and the non-trash can detection frame in the initial detection result;
[0128] The lid opening and closing detection module 604 is used to obtain the opening and closing status of the trash can lid according to the trash can detection frame and the lid detection frame.
[0129] Preferably, the training method of the trash can detection model specifically includes:
[0130] Collect historical images of the target site, and annotate the historical images according to preset barrel cover sorting and annotation rules to obtain annotated images as a data set;
[0131] Classifying the images in the data set, dividing the images in the data set into daytime images and nighttime images;
[0132] Input the daytime image into the improved yolov5 model for training to obtain a daytime image detection model;
[0133] Input the night image into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model;
[0134] The trash can detection model is obtained according to the daytime image detection model and the nighttime image detection model.
[0135] Preferably, the improved method of improving the yolov5 model specifically includes:
[0136] Based on the yolov5 model, the convolutional attention module is integrated to reorganize the feature map through the channel submodule and the spatial submodule;
[0137] Combined with the weighted bidirectional feature pyramid network, the top-down and bottom-up deep and shallow features are bidirectionally fused;
[0138] The non-maximum suppression NMS algorithm is replaced by the DIOU-NMS algorithm, and the detection frames are screened by the intersection-over-union ratio and the distance between the center points of two detection frames.
[0139] Preferably, the step of inputting the night image into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model specifically includes:
[0140] Inputting the night image into each level of enhancement network for feature enhancement to obtain multiple initial enhanced images;
[0141] Performing concat and convolution operations on the multiple initial enhanced images to obtain an enhanced image;
[0142] Input the enhanced image into the improved yolov5 model to obtain the actual detection result;
[0143] Iterative training is performed according to the actual detection results and the target detection results until a preset iteration condition is met to obtain a trained night image detection model.
[0144] Preferably, the step of inputting the nighttime image into each level of enhancement network for feature enhancement to obtain a plurality of initial enhanced images specifically includes:
[0145] Inputting the nighttime image into the enhancement filter of each level of enhancement network to perform first feature enhancement, thereby obtaining a plurality of first enhanced images;
[0146] The width and height of each of the first enhanced images are scaled using a bilinear interpolation method, and the scaled images are subjected to a second feature enhancement through a detail processing module and a low-frequency enhancement module to obtain a plurality of initial enhanced images.
[0147] Preferably, the detail processing module includes a global understanding branch and an edge enhancement branch;
[0148] The global understanding branch obtains global information by capturing long-range dependencies, and sets residual modules before and after the capture to transmit low-frequency information through skip connections for global enhancement.
[0149] The edge enhancement branch calculates the image gradient by using two Sobel operators in different directions, then re-extracts the edge information by convolution, and uses a residual module to enhance the information flow to enhance the edge details.
[0150] Preferably, the processing process of the low frequency enhancement module includes:
[0151] Through convolution operations and channel separation operations, the input features are divided into different scales;
[0152] Adaptive average pooling and bilinear interpolation upsampling are performed for each scale to filter high-frequency information and restore all tensors to the size of the original image;
[0153] The outputs of multiple scales are concat-concatenated and convolved to obtain output features.
[0154] Preferably, the detection frame matching module 603 is specifically used for:
[0155] Calculating an intersection-over-union ratio according to a trash can detection frame and a non-trash can detection frame in the initial detection result;
[0156] The non-trash can detection frames are screened according to the intersection-and-union ratio, and the non-trash can detection frames whose intersection-and-union ratios do not meet a preset intersection-and-union ratio condition are deleted to obtain a candidate bucket cover detection frame;
[0157] Calculate the center point coordinates of the trash can detection frame and the candidate lid detection frame respectively;
[0158] The candidate barrel cover detection frames are screened according to the center point coordinates, and the candidate barrel cover detection frames whose center point coordinates do not meet the preset conditions are deleted to obtain the target barrel cover detection frame;
[0159] The confidence of the target bucket cover detection frame is calculated, and the target bucket cover detection frame with the highest confidence is the bucket cover detection frame that matches the trash can detection frame.
[0160] Preferably, the calculation formula of the intersection-over-union ratio is:
[0161]
[0162] Where IOU represents intersection over union; A represents the trash can detection box; B represents the non-trash can detection box.
[0163] In specific implementations, the working principle, control process and technical effects achieved by the garbage can lid opening and closing detection device provided in the embodiment of the present invention are the same as those of the garbage can lid opening and closing detection method in the above-mentioned embodiment, and will not be repeated here.
[0164] See also Figure 7 , Figure 7 7 is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 701, a memory 702, and a computer program stored in the memory 702 and configured to be executed by the processor 701. When the processor 701 executes the computer program, the method for detecting the opening and closing of the lid of a trash can described in any of the above embodiments is implemented.
[0165] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 702 and executed by the processor 701 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0166] The processor 701 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor, or the processor 701 can be any conventional processor. The processor 701 is the control center of the terminal device, and various parts of the terminal device are connected using various interfaces and lines.
[0167] The memory 702 mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 702 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory 702 can also be other volatile solid-state storage devices.
[0168] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 7 The structural diagram is only an example of the above-mentioned terminal device and does not constitute a limitation of the above-mentioned terminal device. It may include more or less components than shown in the figure, or combine certain components, or different components.
[0169] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the trash can lid opening and closing detection method described in any of the above embodiments.
[0170] The embodiments of the present invention provide a method, device, equipment and storage medium for detecting the opening and closing of a trash can lid, which comprehensively considers the deficiencies and defects of the trash can lid opening and closing capability algorithm in actual application scenarios, such as many false alarms, and false alarms and missed reports and missed judgments caused by insensitivity to low-light images at night, and effectively reduces the false detection and missed detection in actual scenarios by adopting a lid classification detection strategy and corresponding post-processing logic, and improves the detection accuracy; by using a combination of a night multi-level enhancement network and a detector, different models are used to detect daytime images and nighttime images respectively, which greatly improves the accuracy of trash can lid opening and closing detection in low-light conditions at night, thereby improving the overall supervision ability of backstage staff over back kitchen and restaurant scenes, promoting the promotion and use of artificial intelligence technology in this field, and overcoming the deficiencies of the prior art.
[0171] It should be noted that the system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the system embodiment provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0172] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for detecting the opening and closing of a trash can lid, characterized in that: include: Acquire an image to be detected based on the target scene, and preprocess the image to be detected; Input the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model; Determine, according to the trash can detection frame and the non-trash can detection frame in the initial detection result, a lid detection frame that matches the trash can detection frame; The opening and closing state of the trash can lid is obtained according to the trash can detection frame and the lid detection frame.
2. The method for detecting the opening and closing of a trash can lid according to claim 1, characterized in that: The training method of the trash can detection model specifically includes: Collect historical images of the target site, and annotate the historical images according to preset barrel cover sorting and annotation rules to obtain annotated images as a data set; Classifying the images in the data set, dividing the images in the data set into daytime images and nighttime images; Input the daytime image into the improved yolov5 model for training to obtain a daytime image detection model; Input the night image into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model; The trash can detection model is obtained according to the daytime image detection model and the nighttime image detection model.
3. The method for detecting the opening and closing of a trash can lid as claimed in claim 2, characterized in that: The improved method of improving the yolov5 model specifically includes: Based on the yolov5 model, the convolutional attention module is integrated to reorganize the feature map through the channel submodule and the spatial submodule; Combined with the weighted bidirectional feature pyramid network, the top-down and bottom-up deep and shallow features are bidirectionally fused; The non-maximum suppression NMS algorithm is replaced by the DIOU-NMS algorithm, and the detection frames are screened by the intersection-over-union ratio and the distance between the center points of two detection frames.
4. The method for detecting the opening and closing of a trash can lid as claimed in claim 3, characterized in that: The night image is input into the night multi-level enhancement network and the improved yolov5 model for training to obtain a night image detection model, specifically including: Inputting the night image into each level of enhancement network for feature enhancement to obtain multiple initial enhanced images; Performing concat and convolution operations on the multiple initial enhanced images to obtain an enhanced image; Input the enhanced image into the improved yolov5 model to obtain the actual detection result; Iterative training is performed according to the actual detection results and the target detection results until a preset iteration condition is met to obtain a trained night image detection model.
5. The method for detecting the opening and closing of a trash can lid as claimed in claim 4, characterized in that: The step of inputting the nighttime image into each level of enhancement network for feature enhancement to obtain a plurality of initial enhanced images specifically includes: Inputting the nighttime image into the enhancement filter of each level of enhancement network to perform first feature enhancement, thereby obtaining a plurality of first enhanced images; The width and height of each of the first enhanced images are scaled using a bilinear interpolation method, and the scaled images are subjected to a second feature enhancement through a detail processing module and a low-frequency enhancement module to obtain a plurality of initial enhanced images.
6. The method for detecting the opening and closing of a trash can lid as claimed in claim 5, characterized in that: The detail processing module includes a global understanding branch and an edge enhancement branch; The global understanding branch obtains global information by capturing long-range dependencies, and sets residual modules before and after the capture to transmit low-frequency information through skip connections for global enhancement. The edge enhancement branch calculates the image gradient by using two Sobel operators in different directions, then re-extracts the edge information by convolution, and uses a residual module to enhance the information flow to enhance the edge details.
7. The method for detecting the opening and closing of a trash can lid as claimed in claim 6, characterized in that: The processing process of the low frequency enhancement module includes: Through convolution operations and channel separation operations, the input features are divided into different scales; Adaptive average pooling and bilinear interpolation upsampling are performed for each scale to filter high-frequency information and restore all tensors to the size of the original image; The outputs of multiple scales are concat-concatenated and convolved to obtain output features.
8. The method for detecting the opening and closing of a trash can lid according to any one of claims 1 to 7, characterized in that: The determining, according to the trash can detection frame and the non-trash can detection frame in the initial detection result, a lid detection frame matching the trash can detection frame specifically includes: Calculating an intersection-over-union ratio according to a trash can detection frame and a non-trash can detection frame in the initial detection result; The non-trash can detection frames are screened according to the intersection-and-union ratio, and the non-trash can detection frames whose intersection-and-union ratios do not meet a preset intersection-and-union ratio condition are deleted to obtain a candidate bucket cover detection frame; Calculate the center point coordinates of the trash can detection frame and the candidate lid detection frame respectively; The candidate barrel cover detection frames are screened according to the center point coordinates, and the candidate barrel cover detection frames whose center point coordinates do not meet the preset conditions are deleted to obtain the target barrel cover detection frame; The confidence of the target bucket cover detection frame is calculated, and the target bucket cover detection frame with the highest confidence is the bucket cover detection frame that matches the trash can detection frame.
9. The method for detecting the opening and closing of a trash can lid as claimed in claim 8, characterized in that: The calculation formula of the intersection-over-union ratio is: Where IOU represents intersection over union; A represents the trash can detection box; B represents the non-trash can detection box.
10. A garbage can lid opening and closing detection device, characterized in that: include: An image acquisition module is used to acquire an image to be detected based on the target scene and pre-process the image to be detected; A trash can detection module, used to input the preprocessed image to be detected into a preset trash can detection model to obtain an initial detection result output by the trash can detection model; wherein the trash can detection model includes a daytime image detection model and a nighttime image detection model; A detection frame matching module, configured to determine a lid detection frame that matches the trash can detection frame based on the trash can detection frame and the non-trash can detection frame in the initial detection result; The lid opening and closing detection module is used to obtain the opening and closing status of the trash can lid according to the trash can detection frame and the lid detection frame.
11. A terminal device, characterized in that: It includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is configured to be executed by the processor, and when the processor executes the computer program, the method for detecting the opening and closing of a trash can lid as described in any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the method for detecting the opening and closing of the trash can lid as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Image target detection method, system and device and storage medium
CN114581744A
Target detection method and device, equipment and storage medium
CN114882233A
Garbage classified collection and transportation supervision method based on deep learning
CN116030376A
Remote sensing image change detection method based on local-global Transform network
CN116434069A
Target detection method under low illumination based on pyramid enhanced network
CN117058019A
Cited By
Cover opening alarm method and system for intelligent electric meter in industrial scene
CN120254363A
