Automatic Bag-breaking Classification and Collection System for Kitchen Waste Based on OpenCV

: Traditional kitchen waste disposal requires manual separation of plastic bags from food waste, which is cumbersome and unhygienic. However, the capacity, shape, and size of the plastic bags used to hold kitchen waste are different, resulting in an unstable bottom position of the plastic bags when putting them in. Therefore, it is difficult to break plastic bags of any size by using traditional mechanical devices. This paper introduces a computer vision-based automatic bag-breaking classification and collection system for kitchen waste, which aims to solve various pain points in the process of food waste classification and placement. The system involves computer vision, single-chip microcomputer, and internet of things (IoT) technology. When residents dispose of kitchen waste, they only need to hang the bag on the device, the system will visually judge the size and position of the plastic bag, and then control the motor to adjust the plastic bag to the corresponding position to break the bag, and the kitchen waste will fall into the kitchen waste in the garbage bin, it is judged by visual inspection whether the bag breaking is completed, and if it is completed, the plastic bag is thrown into another garbage bin.


Introduction
In the classification of kitchen waste, the separation of plastic bags and kitchen waste has always been a difficult problem.Traditional classification method usually requires manual broken bag classification, which is not only troublesome and very unhygienic, but also easy to affect the enthusiasm of residents for classification.Therefore, this system aims to solve the problems such as the traditional classification and delivery process, low enthusiasm of the public classification and troublesome maintenance and management [1], to improve the convenience and enthusiasm of residents' kitchen waste classification, and further improve the utilization rate of kitchen waste resources.The kitchen waste automatic bag breaking classification and collection system realizes the automatic bag breaking and automatic separation function through computer vision, single-chip microcomputer, and automatic technology.Residents only need to hang the bag on the equipment, and the system can automatically break the bags and automatically separate the plastic bags, to separate the kitchen waste in one step.In addition, the system also realizes the overflow monitoring and oil-water separation function to avoid influence on the environment; intelligent weighing function can upload weight data to the cloud to provide the basis for data analysis; remote monitoring function can easily achieve remote monitoring and remote control.This system adopts computer vision, single-chip controller, and automation technologies to solve the practical problems of kitchen waste classification, and at the same time integrates various functions to further improve the kitchen waste classification effect from multiple dimensions.Its key technologies include computer vision detection, single microcontroller control, automatic control, sensor monitoring and internet of things data transmission.

Structural Design
This kitchen waste automatic broken bag classification collection system based on OpenCV using standard aluminum production frame, its structure composition is divided into A: broken bag mechanism, B: oil and water separation equipment, C: processing and control equipment, D: kitchen waste collection box, E: plastic bag collection box, the specifics are as shown in Figure 1, each module installation is simple and removable.

The System Composition
This system is mainly composed of visual module, control module and internet of things module.The system framework is shown in Figure 2.

System Process
When residents put kitchen waste, the kitchen waste bag classification system collects images in real time through the camera to identify and judge the size and position of the plastic bag, and then controls the motor to adjust the upper and lower dimensions of the plastic bag to the corresponding fixed position, providing the same conditions for each broken bag.After the location is determined, the mechanical arm with the blade moves to the bottom of the plastic bag, cuts the plastic bag from the bottom, and the kitchen waste flows into the bin.At the same time, through the visual identification the broken bag is judged to be the standard, otherwise the broken bag will be executed again, to avoid the failure of the broken bag as far as possible.If it is standard, the plastic bag will be moved to another dustbin, and the plastic bag will fall off to the dustbin, to realize the classification of kitchen waste and plastic bags.

Image Detection based on the OpenCV
The function of the visual module is mainly for image detection based on OpenCV.OpenCV contains a large number of image processing and computer vision algorithms, by calling the functions in it, it is convenient for image processing.OpenCV provides a variety of methods to achieve image detection, including the detection methods based on features and deep learning.Among them, the feature-based methods mainly use the traditional machine learning algorithms (such as SVM, AdaBoost, etc.) to train and classify by extracting the specific features in the image [2].Because the broken bag classification system of kitchen waste only needs to detect the size and position of plastic bags, and all kinds of plastic bags are relatively consistent in shape, the color is uniform, the shape difference is small, and the width is increasing from top to bottom, the feature-based detection method can meet the requirements of the system, and reduce the complexity of the system.The feature-based detection method mainly includes feature extraction and feature matching, with high recognition accuracy and robustness, especially suitable for the target object with obvious and stable features, and the target object (plastic bag) shape and color features detected by the system are obvious and stable.Feature extraction refers to converting the original image into a data form with a fixed structure and characteristics.Common features include edges, corners, textures, etc.In OpenCV, the commonly used feature extraction algorithms are SIFT (Scale-Invariant Feature Transform), SURF (Speeded up Robust Features), ORB (Oriented FAST and Rotated BRIEF), etc.In this system, the SURF algorithm is mainly used to transform the information in the image into the feature vector by extracting the key points and descriptors [3].The distance and similarity between feature points are calculated by feature matching algorithms such as FLANN (Fast Library for Approximate Nearest Neighbors) and violent matching (Brute-Force Matching).The image detection process is shown in Figure 3.

The Image Processing
Image preprocessing is a very important link in the field of computer vision.Its purpose is to improve the accuracy and reliability of image processing and analysis results, and to extract the features with differentiation and helpful for subsequent processing.Image preprocessing includes image denoising, image enhancement, image cropping and edge detection, and the specific process is shown in Figure 4.

Grayscale Processing
The purpose of grayscale processing is to convert color images into grayscale images for subsequent processing.In a grayscale image, each pixel has only one grayscale value, indicating the brightness level of that pixel.The grayscale implementation mainly adopts the average method, which means that the values of the red, green, and blue channels of each pixel in the color image are averaged to obtain the grayscale value.Grayscale processing can reduce the storage amount of image data, simplify processing complexity, and improve the efficiency and accuracy of image processing.In the grayed image, each pixel has only one grayscale value, so a one-dimensional array can be used for storage in the subsequent processing.

Smooth Processing
The purpose of smoothing processing is to reduce the noise in the image and remove unnecessary details in the image to achieve the effect that the image becomes smoother and continuous to facilitate the subsequent edge detection processing [4].The implementation of smoothing processing employs Gaussian filtering, by applying a Gaussian function to the image, weighted averaging the pixels around each pixel to achieve noise reduction and smoothing.In the Gaussian filter, for each pixel I (x, y), using a window centered on that pixel, the weighted average of the surrounding pixels according to the Gaussian distribution function is calculated to archive the new pixel value I'(x, y): In the expression, a and b are the radius of the window respectively; G (i, j) is a two-dimensional Gaussian distribution function.

Binarization Treatment
In binarization, each pixel in the original image is compared to a threshold, and if the luminance value of that pixel is greater than the threshold, the pixel is set to white, otherwise it is set to black.The realization of binarization uses the edge-based thresholding method, which determines the threshold by finding the difference in the gray value distribution of different areas of the image, which

Broken Bag Classification Control System
The control system is mainly composed of the control module and the internet of things module, which communicates with the vision module to realize the operation of controlled and feedback data.

Automatic Control Module
The control module adopts the MEGA2560 development board as the main control, and has more than 50 IO ports, which is fully enough to control three stepper motors, two servo steering engines, mechanical arms and multiple sensors, and can realize the functions of movement control, overflow monitoring and intelligent weighing.
The image detection is written in Python language and runs on the Raspberry PI Linux platform.The camera is connected to the Raspberry PI via USB, and the collected images are processed and detected by the Raspberry PI tree, and then communicated with the processing unit of the control module through I2C communication, to carry out a series of controls on hardware such as stepper motor, steering gear and ultrasonic sensor [6].The classification and collection of broken bags are completed, and the specific process is shown in Figure 5.When the system is triggered, the vision module works, controlling the stepper motor to move horizontally and vertically, adjusting the plastic bag to a fixed position.After the position is determined, the robot arm with a multi-angle blade is controlled along the horizontal and longitudinal movement, and then the plastic bag is sliced, and then the motor controls the plastic bag quickly shakes up and down, and the kitchen waste in the plastic bag is shed as much as possible.After the bag breaking operation is performed, the bag breaking condition is identified visually.If the bag breaking reaches the standard, the separation operation is performed.The motor moves the plastic bag in the horizontal direction, moves the plastic bag to the top of the plastic bag collection box, controls the hook to perform the falling action, and finally the plastic bag is separated.

Internet of Things Module
The IoT module is realized through the connection between the Raspberry PI and the blinker IoT platform, which is based on MQTT communication [7].The blinker client and the Raspberry PI send and receive data to each other, and the Raspberry receives the instructions and transfers them to the control module, while the control module also sends relevant sensor data to the blinker platform through the Raspberry PI.The combination of the IoT module and the control module can achieve the following functions: (1) Overflow monitoring function: the ultrasonic sensor monitors the distance between the garbage surface in the kitchen waste bin and the garbage bin opening, thus deducing the remaining capacity of the food waste bin, and sends the remaining capacity information to the Raspberry PI through I2C communication, and the Raspberry PI then forwards it to the blinker platform.If the remaining capacity is lower than the limit, a reminder message is pushed to the blinker platform to remind the staff to deal with it in time to avoid the overflow of food waste affecting the surrounding environment.
(2) Remote monitoring function: Raspberry PI connects to the wireless network, receives the control instructions sent by the blinker client through TCP communication, and then through MQTT communication after receiving the instructions, transfers to the control module main control unit to achieve remote control, reduce staff workload and improve management efficiency [8].
(3) Intelligent weighing function: high-precision strain gauge pressure sensor and 24-bit A/D converter module HX711 are used to obtain the weight of collected food waste and upload it to the cloud to provide data basis for later analysis of residents' kitchen waste disposal habits and kitchen waste distribution [9].

Conclusion
In this paper, we design an automatic system based on OpenCV, microcontroller and internet of things technology -kitchen waste broken bag classification and collection system.The system uses OpenCV to detect and judge the size and position of plastic bags, and adjusts the position of plastic bags by stepping motor to automatically break bags and collect them by classification, thus solving the problem of complicated and unsanitary traditional classification and release process of kitchen waste, and improving the convenience and enthusiasm of residents in classifying and releasing kitchen waste.At the same time, the internet of things technology is used to integrate overflow monitoring, remote monitoring, and intelligent weighing functions to achieve intelligent operation and management.
Under the background that the current global environmental protection situation is becoming more and more severe, the waste classification work has become a hot topic.The classification and collection system of broken kitchen waste bags designed by this research is an efficient and intelligent garbage classification system developed for practical application needs.The system simplifies the way of putting kitchen waste, optimizes the management mode, and provides a reliable technical support for the classification of urban kitchen waste.
However, there are still some limitations and deficiencies in the current classification and collection system of broken kitchen waste bags.For example, more types and more complex environmental scenarios need to be involved in practical applications, which puts forward higher requirements for our future research and improvement.We will continue to strengthen the optimization and improvement of the system, and constantly improve its stability and reliability, so that the system can better serve the people's lives and environmental protection work.

Figure 5 :
Figure 5: Classification and collection of broken bags.