Method and system for identifying food waste amount in catering based on machine vision
By constructing a three-view, grayscale, binarized, and hierarchical model of food in catering, the amount of food waste in catering is identified and calculated, which solves the problem of inaccurate statistics on food waste in catering in existing technologies and achieves high-precision identification of food waste.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF GEOGRAPHICAL SCI & NATURAL RESOURCE RES CAS
- Filing Date
- 2026-04-16
- Publication Date
- 2026-07-21
AI Technical Summary
In existing technologies, the statistics on food waste in the catering industry rely on manual observation and estimation, which is inefficient and inaccurate. Machine vision methods rely solely on area estimation, resulting in low accuracy and difficulty in distinguishing between edible and inedible residues, thus affecting the reliability of the statistical results.
By constructing an image acquisition scene, three views of food residue in the plate are obtained, grayscale and binarization are performed, and edible parts are identified after noise reduction. A hierarchical model is constructed to calculate the volume of edible parts and exclude inedible parts, thereby improving accuracy.
It enables accurate calculation of food waste in catering, reduces stacking height errors, improves the accuracy and robustness of food waste calculation, and ensures the reliability of statistical results.
Smart Images

Figure CN122435008A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food waste identification technology, specifically to a machine vision-based method and system for identifying food waste in the catering industry. Background Technology
[0002] In the catering industry, food waste has always been a global concern. Traditional methods for counting food waste in the catering industry mainly rely on manual observation and estimation. This method is not only inefficient and time-consuming, but also easily affected by subjective factors, resulting in inaccurate statistical results. For example, manual recording requires staff to check each plate after the meal to make a rough judgment on the type and quantity of leftover food. This judgment often lacks precision and makes it difficult to quantify the specific volume of leftover food, thus failing to provide accurate data support for catering companies to formulate reasonable procurement and cooking plans, as well as for policymakers. With the rapid development of computer technology, machine vision technology has gradually become a powerful tool for solving this problem. However, existing machine vision methods for estimating food waste in the catering industry estimate food waste by area. But the amount of food waste is also affected by the stacking height of the food. Therefore, the accuracy of estimating food waste by area alone is low. For example, in the patent application with publication number CN114926525A, a food waste assessment method and system based on image method is disclosed. This scheme uses area size to estimate food waste, but fails to consider that the amount of food waste is also affected by the stacking height, resulting in low accuracy of obtaining the amount of food waste. That is, the existing technology uses area size to estimate food waste, resulting in low accuracy of obtaining the amount of food waste.
[0003] In addition, existing technologies often use RGB grayscale thresholds to segment food waste, which makes it difficult to further distinguish between edible and inedible waste (such as bones, fruit peels, fish bones, etc.), resulting in inaccurate data on "food waste" and affecting the reliability and comparability of statistical results. Summary of the Invention
[0004] This invention aims to at least partially solve one of the technical problems in the prior art by constructing an image acquisition scene; acquiring three views of food residue in a plate based on the image acquisition scene and labeling them as food images; performing grayscale processing on the food images to obtain food grayscale images; performing binarization processing on the food grayscale images to obtain initial food binarized images; denoising the initial food binarized images to obtain final food binarized images; performing edible and inedible part identification on each of the final food binarized images to obtain edible part binarized images; constructing a food model based on the three edible part binarized images; dividing the food model into layers to obtain layered models; obtaining the food volume of the layered models; and calculating the sum of the food volumes of each layered model to obtain the total food waste volume of the edible parts. This addresses the problem in the prior art that relying solely on RGB grayscale segmentation makes it difficult to distinguish between edible and inedible residues and that using area size to estimate food waste results in low accuracy in obtaining the amount of food waste.
[0005] Furthermore, after obtaining the denoised binarized image of the food, this invention adds an edible part identification step to distinguish between edible and inedible parts (such as bones, fruit peels, etc.) in the residue, and excludes inedible parts from the waste statistics. This step solves the problem that it is difficult to distinguish the edible attributes of residue using only RGB grayscale information, and improves the accuracy of food waste volume calculation.
[0006] To achieve the above objectives, this application provides a machine vision-based method for identifying food waste in the catering industry, comprising the following steps: Construct an image acquisition scenario; based on the image acquisition scenario, obtain the three views of food residue in the plate and label them as food images; The food image is converted to grayscale to obtain a grayscale image of the food. Binarize the grayscale image of the food to obtain the initial binary image of the food; The initial food binarized image is denoised to obtain the final food binarized image; Perform edible and inedible part identification on each of the final food binarized images to obtain an edible part binarized image that retains only the edible part; A food model is constructed based on the binarized images of three edible food parts; The food model is layered to obtain a layered model; Obtain the food volume of the layered model; sum the food volumes of each layered model to obtain the total food waste volume of the edible portion.
[0007] Further, an image acquisition scenario is constructed; based on the image acquisition scenario, three views of the food residue in the plate are obtained and labeled as food images, including the following sub-steps: The image acquisition scene includes a white plate placement area. A camera is placed on the front, side, and top of the plate placement area, and a white background is installed on the three cameras. The three cameras acquire three views of the food residue in the plate and label them as food images.
[0008] Further, the process of converting the food image to grayscale to obtain a grayscale image of the food includes the following sub-steps: Obtain the RGB value of each pixel in the food image and label it as the food RGB value; convert the food RGB value to grayscale value using a grayscale conversion formula and label it as the food grayscale value; replace the food RGB value of each pixel in the food image with the food grayscale value to obtain the food grayscale image.
[0009] Further, the process of binarizing the food grayscale image to obtain the initial food binarized image includes the following sub-steps: Divide the gray values from 0 to 255 into a range of equal intervals, and mark them as interval ranges; Get the number of grayscale values of food within each division range and mark it as the number of food items; A histogram is plotted with grayscale values on the X-axis, the number of food items on the Y-axis, and the interval range as the histogram interval. This histogram is then labeled as the food grayscale histogram.
[0010] Furthermore, the process of binarizing the food grayscale image to obtain the initial food binarized image also includes the following sub-steps: Mark the median of the interval range as the representative value of the range; The interval range in the food grayscale histogram where the number of food items is greater than the number of adjacent divisions on the left and right sides is marked as the peak range; Get the smallest representative value in the peak range and mark it as the left representative value; get the largest representative value in the peak range and mark it as the right representative value. Obtain the minimum interval range of the number of food items between the left representative value and the right representative value, and mark it as the binarization threshold range; Obtain the median value of the binarization threshold range and mark it as the binarization threshold; Set the grayscale value of food that is greater than or equal to the binarization threshold to 0, and set the grayscale value of food that is less than the binarization threshold to 255 to obtain the initial binarized image of food.
[0011] Further, denoising the initial food binarized image to obtain the final food binarized image includes the following sub-steps: The initial food binarized image is scanned from top to bottom and from left to right to obtain pixels whose grayscale value changes from 255 to 0 and are marked as target pixels. It is then determined whether there are any pixels with a grayscale value of 0 among the eight pixels surrounding the target pixel. If not, the grayscale value of the target pixel is set to 255. If so, the scanning continues until the entire food binarized image is scanned to obtain the intermediate food binarized image. Obtain the continuous region consisting of all pixels with a grayscale value of 0 in the binarized image of the intermediate food, and mark it as the filtering region; Obtain the number of pixels in each filtered region and mark it as the monitoring count; Get a first number of images containing only stains and mark them as stain images; get the number of pixels contained in the stains in the stain images and mark them as the number of stains; Get the maximum number of all stains and mark it as the stain threshold; Set the grayscale value of all screened areas with a number of monitored samples less than the stain threshold to 255 to obtain the final food binarized image.
[0012] Further, after obtaining the final food binarized image, edible and inedible parts are identified on each of the final food binarized images to obtain an edible part binarized image; wherein, food waste refers to the volume of edible parts in the plate residue, and inedible parts are not included in the statistics; the edible / inedible identification includes: mapping the final food binarized image back to the original food image to limit the identification area to obtain the food ROI; segmenting connected components within the food ROI and extracting color statistics, texture features and shape features; judging edible / inedible based on a preset threshold rule or a lightweight classifier, and removing connected components judged as inedible from the food ROI to obtain an edible part binarized image.
[0013] Furthermore, the process of stratifying the food model to obtain a stratified model includes the following sub-steps: Establish a three-dimensional coordinate system, labeled as the food coordinate system; place the three-dimensional food model within the food coordinate system; The plane containing both the X-axis and Y-axis is designated as the reference plane; the plane parallel to the reference plane is designated as the dividing plane. The dividing plane that has the smallest Z-axis value in the 3D food model is obtained and marked as the starting plane; Starting from the initial plane, with an interval of m and the direction being the positive direction of the Z-axis, n dividing planes are used to divide the space in the food coordinate system to obtain a space, which is marked as the layer dividing space; Obtain the 3D model of the food within each layer's spatial division and label it as a layered model.
[0014] Furthermore, obtaining the food volume of the layered model includes the following sub-steps: The layer partitioning space is then divided into cubic spaces with length, width, and height all being m, and this is marked as the first cubic space; Obtain the number of layered models that fill the first cubic space, and label it as K1; Obtain the layered model that is not filled in the first cubic space and mark it as the second cubic space.
[0015] Furthermore, obtaining the food volume of the layered model also includes the following steps: Divide each second cubic space into p equal cubic spaces, and label them as third cubic spaces; Obtain the number of all third-party volumes filled with hierarchical models, and label it K2; The food volume of the layered model is calculated as: Tf = m³ × K1 + (m³ ÷ p) × K2; where Tf is the food volume of the layered model.
[0016] This application also provides a machine vision-based food waste identification system, including an image acquisition module, a grayscale processing module, a binarization module, a noise reduction module, an edible part identification module, a model building module, a layering module, and a volume calculation module. The image acquisition module is used to construct an image acquisition scene; based on the image acquisition scene, it acquires three views of food residue in the plate and marks them as food images; The grayscale processing module is used to convert food images to grayscale to obtain a grayscale image of the food. The binarization module is used to binarize the grayscale image of the food to obtain an initial binarized image of the food. The denoising module is used to denoise the initial food binarized image to obtain the final food binarized image; The edible portion recognition module is used to perform edible and inedible portion recognition on each of the final food binarization images to obtain an edible portion binarization image that retains only the edible portion. The model building module is used to construct a food model based on the binarized images of three edible parts; The layering module is used to layer the food model to obtain a layered model; The volume calculation module is used to obtain the food volume of the layered model; the total food waste volume of the edible portion is obtained by summing the food volumes of each layered model.
[0017] The beneficial effects of this invention are as follows: This invention constructs an image acquisition scene and obtains three views of food residue in the plate. Based on grayscale, binarization, and denoising, a three-dimensional food model is constructed, and the model is layered to achieve approximate volume calculation, avoiding the stacking height error caused by estimating only the two-dimensional area. At the same time, after obtaining the final binarized food image after denoising, an edible part identification step / module is added to filter out inedible residues such as bones, fruit peels, and fish bones, so that the volume calculation is only performed on the edible part, thereby improving the accuracy of the "food waste amount" caliber and the precision and robustness of obtaining the food waste amount.
[0018] This invention obtains a layered model by dividing a food model into layers; the volume of food in the layered model is obtained. The advantage is that, since the obtained food is irregularly shaped, it is difficult to directly obtain the volume of the food. This method can approximately estimate the volume of wasted food, thus improving the accuracy of obtaining the amount of wasted food. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the system of the present invention; Figure 2 This is a schematic diagram of the food grayscale histogram of the present invention; Figure 3 This is a schematic diagram of the layer division space of the present invention; Figure 4 This is a schematic diagram of the first cuboid space of the present invention; Figure 5 This is a flowchart of the steps of the method of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Example 1, please refer to Figure 1 As shown, this application provides a machine vision-based food waste identification system, including an image acquisition module, a grayscale processing module, a binarization module, a noise reduction module, an edible part identification module, a model building module, a layering module, and a volume calculation module. The image acquisition module is used to construct an image acquisition scene; based on the image acquisition scene, it acquires three views of food residue in the plate and marks them as food images; The image acquisition module is configured with an image acquisition strategy, which includes: The image acquisition scenario includes a white plate placement area. A camera is placed at the front, side, and top of this area, with a white background installed on each camera. The three cameras capture three views of food residue within the plate, which are then labeled as food images. This image acquisition scenario is designed to facilitate food identification and reduce interference from the background image. The background color can also be other colors, as long as it effectively distinguishes the food. Acquiring the three views allows for the modeling of wasted food.
[0022] The grayscale processing module is used to convert food images to grayscale to obtain a grayscale image of the food. The grayscale processing module is configured with grayscale processing strategies, which include: Take the RGB value of each pixel in the food image and mark it as the food RGB value; convert the food RGB value to grayscale value using the grayscale conversion formula and mark it as the food grayscale value; replace the food RGB value of each pixel in the food image with the food grayscale value to obtain the food grayscale image; In practical applications, grayscale conversion formulas include various methods, such as the simple averaging method and the weighted averaging method. Here, the simple averaging method is sufficient. For example, if the RGB value of a food is (235, 236, 237), then the grayscale value of the food is: (235+236+237)÷3=236.
[0023] The binarization module is used to binarize the grayscale image of food to obtain the initial binarized image of food; The binarization module is configured with binarization strategies, which include: Divide the grayscale values from 0 to 255 into a equal intervals, and mark them as interval ranges. To observe the distribution of grayscale values in food, the value of a should not be too large or too small, for example, a is 8. Get the number of grayscale values of food within each division range and mark it as the number of food items; A histogram is plotted with grayscale values on the X-axis, the number of food items on the Y-axis, and the interval range as the histogram interval. This histogram is then labeled as the food grayscale histogram. For practical applications, please refer to Figure 2 As shown, a grayscale histogram of the food was drawn.
[0024] Mark the median of the interval range as the representative value of the range; The interval range in the food grayscale histogram where the number of food items is greater than the number of adjacent divisions on the left and right sides is marked as the peak range; Get the smallest representative value in the peak range and mark it as the left representative value; get the largest representative value in the peak range and mark it as the right representative value. Obtain the minimum interval range of the number of food items between the left representative value and the right representative value, and mark it as the binarization threshold range; Obtain the median value of the binarization threshold range and mark it as the binarization threshold; Set the grayscale value of food that is greater than or equal to the binarization threshold to 0, and set the grayscale value of food that is less than the binarization threshold to 255 to obtain the initial binarized image of food; For practical applications, please refer to Figure 2 As shown, the peak ranges are 95 to 127 and 223 to 255. The representative values for the ranges of 95 to 127 and 223 to 255 are 111 and 239, respectively. The smallest representative value in the peak range is 111, so the left representative value is 111. The largest representative value in the peak range is 239, so the right representative value is 239. The smallest interval between the number of food items between 111 and 239 is 159 to 191. The median value between 159 and 191 is 175, so the binarization threshold is 175.
[0025] The denoising module is used to denoise the initial food binarized image to obtain the final food binarized image; The noise reduction module is configured with noise reduction strategies, which include: The initial food binarized image is scanned from top to bottom and left to right to obtain pixels whose grayscale value changes from 255 to 0, and these pixels are marked as target pixels. It is then determined whether any of the eight pixels surrounding the target pixel contain a pixel with a grayscale value of 0. If not, the grayscale value of the target pixel is set to 255; otherwise, the scanning continues until the entire food binarized image is scanned, resulting in an intermediate food binarized image. This method can remove independent interfering pixels from the image itself, making subsequent food modeling more accurate.
[0026] Obtain the continuous region consisting of all pixels with a grayscale value of 0 in the binarized image of the intermediate food, and mark it as the filtering region; Obtain the number of pixels in each filtered region and mark it as the monitoring count; Obtain a first number of images containing only stains and mark them as stain images; obtain the number of pixels contained in the stains in the stain images and mark them as the number of stains; the number of pixels occupied by the stains can be obtained through multiple stain images, for example, the first number is 20; The maximum number of all stains is obtained and marked as the stain threshold. Compared with the remaining food, the number of pixels in the stained spot is much smaller than the number of pixels in the remaining food, so the stained spot is filtered out. Set the grayscale value of all filtered areas with a number of monitored items less than the stain threshold to 255 to obtain the final food binarized image; when placing and removing the plate, splashes of food juice may occur, and these small stains will affect the food model, so they need to be filtered out; In practical applications, for example, if the total number of stains is 621, then the stain threshold is 621. For example, if the number of monitored stains is 121, then the grayscale value of all 121 filtered areas is set to 255.
[0027] The process of identifying edible portions in the final binarized food image includes the following sub-steps: First, using morphological methods or deep learning-based image segmentation techniques, the final binarized food image is segmented to identify edible and inedible regions within the food residue. Second, based on the identification results, an edible portion binarized image is generated, retaining only the edible parts and labeling them as the edible portion binarized image. This step filters out inedible parts such as bones and peels from the food residue, ensuring that subsequent volume calculations are performed only on the edible parts, thereby improving recognition accuracy.
[0028] The edible portion recognition module is used to perform edible and inedible portion recognition on each of the final food binarization images to obtain an edible portion binarization image that retains only the edible portion. The model building module is used to construct food models based on binary images of three edible parts; objects can be modeled using three-view diagrams. In some embodiments, the model building module uses a voxel sculpting algorithm to construct a three-dimensional food model: the food coordinate system is discretized into a voxel grid; each voxel is projected onto the binarized image of the edible part corresponding to the three views; if the projection points of the voxel in the three views all fall within the edible part area, the voxel is retained; otherwise, the voxel is discarded; the retained voxel set is reconstructed in three dimensions to obtain a three-dimensional food model.
[0029] The layering module is used to layer the food model to obtain a layered model; The layered module is configured with a layering strategy, which includes: Establish a three-dimensional coordinate system, labeled as the food coordinate system; place the three-dimensional food model within the food coordinate system; The plane containing both the X-axis and Y-axis is designated as the reference plane; the plane parallel to the reference plane is designated as the dividing plane. The dividing plane that has the smallest Z-axis value in the 3D food model is obtained and marked as the starting plane; Starting from the initial plane, with an interval of m and the direction being the positive Z-axis, n dividing planes are used to divide the space in the food coordinate system, resulting in a space labeled as the layer partition space. This layer partition space facilitates step-by-step analysis of the food model. A smaller value for m results in more accurate subsequent food volume measurements, but increases computational complexity; therefore, a compromise can be made, for example, m = 0.10 cm. The value of n must ensure that the layer partition space encompasses the entire food model; therefore, n can be based on the height of the food model's Z-axis. For example, if the height of the food model's Z-axis is 2.10 cm, then n = 21. (See also...) Figure 3 As shown, the layer partitioning space is drawn; Obtain the 3D model of the food within each layer's spatial division and label it as a layered model.
[0030] The volume calculation module is used to obtain the food volume of the layered model; the total food waste volume of the edible portion is obtained by summing the food volumes of each layered model. The volume calculation module is configured with volume calculation strategies, which include: The layer partitioning space is then divided into cubic spaces with length, width, and height all being m, and this is labeled as the first cubic space; please refer to [link to relevant documentation]. Figure 4 As shown, the first cubic space is drawn; Obtain the number of layered models that fill the first cubic space, and label it as K1; Obtain the layered model that is not fully filled in the first cubic space and mark it as the second cubic space; Each second cubic space is divided into p equal cubic spaces, which are labeled as third cubic spaces. The smaller the value of p, the more accurate the food volume will be, but the computational load will increase. Therefore, p can be considered as a compromise, for example, p = 27. Obtain the number of all third-party volumes filled with hierarchical models, and label it K2; The food volume of the layered model is calculated as: Tf = m³ × K1 + (m³ ÷ p) × K2; where Tf is the food volume of the layered model. In practical applications, the layering space is further divided into cubic spaces with length, width, and height all equal to 0.1 cm, labeled as the first cubic space. The number of layered models filling the first cubic space is 3612, and the number of layered models filling all the third cubic spaces is 2912. The food volume of the layered models is calculated as: Tf = 0.1³ × 3612 + (0.1³ ÷ 27) × 2912 = 3.7198 cm³. The result is rounded to four decimal places: 3.7198 cm³. 3 Given the food volume of one layered model, the sum of the food volumes of all layered models is 59.213 cm³. 3 Therefore, the volume of the edible food wasted on the plate is 59.213 cm³. 3 .
[0031] Example 2, please refer to Figure 5 As shown, this application provides a machine vision-based method for identifying food waste in the catering industry, including the following steps: Step S1: Construct an image acquisition scene; acquire three views of food residue in the plate based on the image acquisition scene, and label them as food images; Step S1 includes the following sub-steps: Step S101: The image acquisition scene includes a plate placement area, which is white. A camera is placed on the front, side, and top of the plate placement area, and a white background is installed on the three cameras. The three views of the food residue in the plate are acquired through the three cameras and marked as food images.
[0032] Step S2 involves converting the food image to grayscale to obtain a grayscale image of the food. Step S2 includes the following sub-steps: Step S201: Obtain the RGB value of each pixel in the food image and mark it as the food RGB value; convert the food RGB value into a grayscale value using a grayscale conversion formula and mark it as the food grayscale value; replace the food RGB value of each pixel in the food image with the food grayscale value to obtain the food grayscale image.
[0033] Step S3 involves binarizing the food grayscale image to obtain an initial food binarized image; Step S3 includes the following sub-steps: Step S301: Divide the gray values from 0 to 255 into a range of equal intervals, and mark them as interval ranges; Step S302: Obtain the number of grayscale values of food within each division range and mark it as the number of food items; Step S303: Draw a histogram with grayscale values on the X-axis, the number of food items on the Y-axis, and the interval range as the histogram interval, and mark it as the food grayscale histogram; Step S304: Mark the median value of the interval range as the representative value of the range; Step S305: Mark the interval range in the food grayscale histogram where the number of food items is greater than the number of adjacent divisions on the left and right sides as the peak range. Step S306: Obtain the smallest representative value in the peak range and mark it as the left representative value; obtain the largest representative value in the peak range and mark it as the right representative value; Step S307: Obtain the minimum interval range of the number of food items between the left representative value and the right representative value, and mark it as the binarization threshold range; Step S308: Obtain the median of the binarization threshold range and mark it as the binarization threshold; Step S309: Set the grayscale values of food that are greater than or equal to the binarization threshold to 0, and set the grayscale values of food that are less than the binarization threshold to 255 to obtain the initial binarized food image.
[0034] Step S4: Denoise the initial food binarized image to obtain the final food binarized image; Step S4 includes the following sub-steps: Step S401: Scan the initial food binarized image from top to bottom and from left to right to obtain pixels whose grayscale value changes from 255 to 0 and mark them as target pixels; determine whether there are pixels with a grayscale value of 0 among the eight pixels surrounding the target pixel. If not, set the grayscale value of the target pixel to 255. If yes, continue scanning until the food binarized image is completely scanned to obtain the intermediate food binarized image. Step S402: Obtain the continuous region composed of all pixels with a gray value of 0 in the binarized image of the intermediate food, and mark it as the filtering region; Step S403: Obtain the number of pixels in each filtered region and mark it as the number of monitored pixels; Step S404: Obtain a first number of images containing only stains and mark them as stain images; obtain the number of pixels contained in the stains in the stain images and mark them as the number of stains; Step S405: Obtain the maximum value of the total number of stains and mark it as the stain threshold; Step S406: Set the grayscale value of all screened areas with a number of monitored items less than the stain threshold to 255 to obtain the final food binarized image.
[0035] Step S5: Perform edible and inedible part identification on each of the final food binarized images to obtain an edible part binarized image that retains only the edible parts; wherein, the final food binarized image is mapped back to the original food image to limit the recognition area to obtain the food ROI; within the food ROI, the connected components are segmented and color statistics, texture features and shape features are extracted; based on a preset threshold rule or a lightweight classifier, edible / inedible discrimination is performed, and connected components determined to be inedible are removed from the food ROI to obtain the edible part binarized image.
[0036] Step S6: Construct a food model based on the binarized images of the three edible parts.
[0037] Step S7: Layer the food model to obtain a layered model; Step S6 includes the following sub-steps: Step S701: Establish a three-dimensional coordinate system, labeled as the food coordinate system; place the three-dimensional food model in the food coordinate system; Step S702: The plane containing both the X-axis and Y-axis is marked as the reference plane; the plane parallel to the reference plane is marked as the dividing plane. Step S703: Obtain the dividing plane that passes through the coordinate point with the smallest Z-axis value in the 3D food model and mark it as the starting plane; Step S704: Starting from the initial plane, with an interval of m and the direction being the positive direction of the Z-axis, n dividing planes are used to divide the space in the food coordinate system to obtain space, which is marked as layer dividing space; Step S705: Obtain the 3D model of the food within the space of each layer and mark it as a layered model.
[0038] Step S8: Obtain the food volume of the layered model; calculate the sum of the food volumes of each layered model to obtain the total food waste volume of the edible portion; Step S7 includes the following sub-steps: Step S801: Divide the layer partitioning space into cubic spaces with length, width and height all being m, and mark them as the first cubic space. Step S802: Obtain the number of layered models that fill the first cube space, and mark it as K1; Step S803: Obtain the layered model that is not fully filled in the first cubic space and mark it as the second cubic space; Step S804: Divide each second cube space into p equal cube spaces, and mark them as third cube spaces; Step S805: Obtain the number of all third-party volumes filled with layered models, and label it as K2; Step S806: Calculate the food volume of the layered model as: Tf = m³ × K1 + (m³ ÷ p) × K2; where Tf is the food volume of the layered model.
[0039] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0040] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
Claims
1. A machine vision-based method for identifying food waste in the catering industry, characterized in that, Includes the following steps: Construct an image acquisition scenario; based on the image acquisition scenario, obtain the three views of food residue in the plate and label them as food images; The food image is converted to grayscale to obtain a grayscale image of the food. Binarize the grayscale image of the food to obtain the initial binary image of the food; The initial food binarized image is denoised to obtain the final food binarized image; Perform edible and inedible part identification on each of the final food binarized images to obtain an edible part binarized image that retains only the edible part; A food model is constructed based on the binarized images of the three edible parts; The food model is layered to obtain a layered model; Obtain the food volume of the layered model; The total volume of edible food waste is obtained by summing the food volumes of each layered model.
2. The method for identifying food waste in catering based on machine vision according to claim 1, characterized in that, Constructing an image acquisition scenario; acquiring three views of food residue on a plate based on the image acquisition scenario and labeling them as food images includes the following sub-steps: The image acquisition scene includes a plate placement area, which is white. A camera is placed on the front, side, and top of the plate placement area, and a white background is installed on the three cameras. Three views of food residue on a plate are captured by three cameras and labeled as food images.
3. The method for identifying food waste in catering based on machine vision according to claim 2, characterized in that, The process of converting a food image to grayscale to obtain a grayscale image of the food includes the following sub-steps: Obtain the RGB value of each pixel in the food image and label it as the food RGB value; convert the food RGB value to grayscale value using a grayscale conversion formula and label it as the food grayscale value; replace the food RGB value of each pixel in the food image with the food grayscale value to obtain the food grayscale image.
4. The method for identifying food waste in catering based on machine vision according to claim 3, characterized in that, Binarizing the grayscale image of food to obtain the initial binary image of food includes the following sub-steps: Divide the gray values from 0 to 255 into a range of equal intervals, and mark them as interval ranges; Get the number of grayscale values of food within each division range and mark it as the number of food items; A histogram is plotted with grayscale values on the X-axis, the number of food items on the Y-axis, and the interval range as the histogram interval. This histogram is then labeled as the food grayscale histogram.
5. The method for identifying food waste in catering based on machine vision according to claim 4, characterized in that, Binarizing the grayscale image of food to obtain the initial binary image of food also includes the following sub-steps: Mark the median of the interval range as the representative value of the range; The interval range in the food grayscale histogram where the number of food items is greater than the number of adjacent divisions on the left and right sides is marked as the peak range; Get the smallest representative value in the peak range and mark it as the left representative value; get the largest representative value in the peak range and mark it as the right representative value. Obtain the minimum interval range of the number of food items between the left representative value and the right representative value, and mark it as the binarization threshold range; Obtain the median value of the binarization threshold range and mark it as the binarization threshold; Set the grayscale value of food that is greater than or equal to the binarization threshold to 0, and set the grayscale value of food that is less than the binarization threshold to 255 to obtain the initial binarized image of food.
6. The method for identifying food waste in catering based on machine vision according to claim 5, characterized in that, The process of denoising the initial food binarized image to obtain the final food binarized image includes the following sub-steps: The initial food binarized image is scanned from top to bottom and from left to right to obtain pixels whose grayscale value changes from 255 to 0 and are marked as target pixels. It is then determined whether there are any pixels with a grayscale value of 0 among the eight pixels surrounding the target pixel. If not, the grayscale value of the target pixel is set to 255. If so, the scanning continues until the entire food binarized image is scanned to obtain the intermediate food binarized image. Obtain the continuous region consisting of all pixels with a grayscale value of 0 in the binarized image of the intermediate food, and mark it as the filtering region; Obtain the number of pixels in each filtered region and mark it as the monitoring count; Obtain the first number of images containing only stain spots and label them as stain images; Obtain the number of pixels contained in a stain in the stain image and mark it as the number of stains; Get the maximum number of all stains and mark it as the stain threshold; Set the grayscale value of all screened areas with a number of monitored samples less than the stain threshold to 255 to obtain the final food binarized image.
7. The method for identifying food waste in catering based on machine vision according to claim 6, characterized in that, The process of creating a layered model by dividing the food model into layers includes the following sub-steps: Establish a three-dimensional coordinate system, labeled as the food coordinate system; place the three-dimensional food model within the food coordinate system; The plane containing both the X-axis and Y-axis is designated as the reference plane; the plane parallel to the reference plane is designated as the dividing plane. The dividing plane that has the smallest Z-axis value in the 3D food model is obtained and marked as the starting plane; Starting from the initial plane, with an interval of m and the direction being the positive direction of the Z-axis, n dividing planes are used to divide the space in the food coordinate system to obtain a space, which is marked as the layer division space; Obtain the 3D model of the food within the space divided by each layer, and label it as a layered model.
8. The method for identifying food waste in catering based on machine vision according to claim 7, characterized in that, Obtaining the food volume from the layered model involves the following sub-steps: The layer partitioning space is then divided into cubic spaces with length, width, and height all being m, and this space is marked as the first cubic space. Obtain the number of layered models that fill the first cubic space, and label it as K1; Obtain the layered model that is not filled in the first cubic space and mark it as the second cubic space.
9. The method for identifying food waste in catering based on machine vision according to claim 8, characterized in that, Obtaining the food volume from the layered model also includes the following steps: Divide each second cubic space into p equal cubic spaces, and label them as third cubic spaces; Obtain the number of all third-party volumes filled with hierarchical models, and label it K2; The food volume of the stratified model is calculated as: Tf = m³ × K1 + (m³ ÷ p) × K2; Where Tf represents the food volume in the layered model.
10. A machine vision-based food waste identification system for catering, used to implement the method described in any one of claims 1-9, characterized in that, It includes an image acquisition module, a grayscale processing module, a binarization module, a noise reduction module, an edible part recognition module, a model building module, a layering module, and a volume calculation module; The image acquisition module is used to construct an image acquisition scenario; Based on the image acquisition scenario, obtain the three views of food residue in the plate and label them as food images; The grayscale processing module is used to convert food images to grayscale to obtain a grayscale image of the food. The binarization module is used to binarize the grayscale image of the food to obtain an initial binarized image of the food; The denoising module is used to denoise the initial food binarized image to obtain the final food binarized image; The edible portion recognition module is used to perform edible and inedible portion recognition on each of the final food binarization images to obtain an edible portion binarization image that retains only the edible portion. The model building module is used to construct a food model based on the binarized images of three edible parts; The layering module is used to layer the food model to obtain a layered model; The volume calculation module is used to obtain the food volume of the layered model; Find the hierarchical model The total volume of food waste is calculated by summing the volumes of the edible portions.