A method and system for cookie doneness detection based on image recognition
Patent Information
- Application Number
- CN202611440214.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-10-27
AI Technical Summary
[0016]综合而言,本发明提供的一种基于图像识别的曲奇烘烤熟度检测的方法及系统,其中,方法通过获取曲奇图像并提取表征个体厚薄差异的形态表征信息,结合边缘与中心区域的视觉特征差异判定熟化状态类别,进而动态调整两区域在熟度判定中的贡献权重,解决了现有技术中因个体规格波动导致边缘先褐变而中心滞后时产生的同色异熟系统性误判问题。该技术方案通过将二维视觉特征与三维物理受热条件关联,突破了传统统一规则解释整块图像的局限,有效阻断了边缘先熟表象掩盖中心真实滞后状态的传导路径,使熟度判定基于曲奇中心的真实成熟状态而非表面颜色,显著提高了连续生产条件下熟度检测的一致性和准确性,确保厚薄不一的曲奇均能按其真实品质被准确分拣。
Smart Images

Figure CN122990350A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food processing and automated testing technology, and in particular to a method and system for detecting the baking doneness of cookies based on image recognition. Background Technology
[0002] In the industrialized continuous production of cookies, to ensure product quality stability, a visual inspection system is typically introduced after the baking process to assess cookie doneness using image recognition. The current common practice is to extract the overall color and texture features of the cookie and judge them based on a pre-set, uniform doneness standard model. However, in actual continuous production scenarios, fluctuations in dough segmentation quality and irregular spreading during baking lead to differences in the physical specifications of individual cookies, such as thickness and edge shape. When a batch of cookies is thick and unevenly heated, the heat conduction rate in the center is significantly lower than at the edges, causing browning at the edges in the early stages of baking, while the center has not yet reached the required doneness. Because existing recognition schemes lack specific consideration for individual shape differences and still use uniform weights to fuse features of the cookie edges and center, the weight of edge color features on the overall evaluation score is unreasonably amplified. This logic causes thick cookies with dark edges but uncooked centers to be incorrectly classified into the same doneness level as truly well-done thin cookies, resulting in serious missed detections and misjudgments, affecting the overall consistency of product quality. Summary of the Invention
[0003] To address the shortcomings of existing technologies, this invention discloses a method and system for detecting the baking doneness of cookies based on image recognition. The aim is to solve the systematic misjudgment problem in existing technologies when the edges brown first due to differences in the thickness of individual cookies, while the center is baked later.
[0004] The technical solution of the present invention is as follows: In a first aspect, the present invention discloses a method for detecting the baking doneness of cookies based on image recognition, comprising: Acquire image information of cookies and extract individual morphological representation information to characterize the thickness differences of individual cookies; Based on the image information, the cookies are divided into edge regions and center regions; Extract visual features from the edge region and visual features from the center region respectively; Calculate the visual feature difference between the edge region and the center region based on the visual features of the edge region and the center region; Based on individual morphological representation information and visual feature difference values, determine the cookie's ripening status category; Based on the ripeness category, adjust the contribution weights of visual features in the edge region and visual features in the center region in ripeness determination, and output the ripeness level of the cookie based on the adjusted contribution weights.
[0005] This technical solution can solve the problem of systematic misjudgment of different ripeness levels in the same color system. By quantifying the differences in individual thickness and dynamically adjusting the judgment weights in combination with the visual feature differences between the edge and the center, the ripeness detection results can truly reflect the actual ripeness status of the central area of the cookie, avoid the interference of the appearance of premature ripening at the edge on the overall ripeness judgment, and significantly improve the accuracy and consistency of ripeness detection under continuous production conditions.
[0006] Furthermore, based on the image information, individual morphological representation information of the cookies is extracted, including: Based on the image information, obtain the spreadable area of the cookies; Calculate the relative thickness of the cookies based on the preset standard volume and spread area of the dough; Based on the deviation between the relative thickness and the standard target thickness, the individual morphological fluctuation index is calculated and used as information representing the individual morphology.
[0007] Furthermore, based on the image information, the steps of dividing the cookie into edge and center regions include: Based on image information, determine the outline region of the cookie; A distance transformation is performed on the binary mask image of the contour region to obtain a distance map, which represents the shortest distance from each pixel in the contour region to the contour boundary. Determine the maximum distance value in the distance map; The partition distance threshold is determined based on the product of the maximum distance value and the preset ratio coefficient. Pixels with distance values less than the partition distance threshold are classified as edge regions, and pixels with distance values greater than or equal to the partition distance threshold are classified as center regions.
[0008] Furthermore, after dividing the cookie into edge and center regions, the method also includes: Identify the set of pixels in an image whose grayscale values significantly deviate from the average grayscale value of the cookie subject; Perform connected component analysis on the pixel set, and mark abnormal focal spots or foreign objects based on the area and shape irregularity of the connected components; When extracting visual features from the edge region and the center region respectively, the influence of abnormal focal spots or foreign objects on the visual feature statistics is excluded.
[0009] Furthermore, the steps for determining the ripening state category of cookies based on individual morphological representation information and visual feature difference values include: The individual morphological characterization information is compared with the preset upper and lower thickness safety thresholds. Compare the visual feature difference values with a preset local difference threshold; If the individual morphological representation information is greater than the upper limit of the thickness safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be a state where the edges brown first and the center ripens later. If the individual morphological representation information is between the upper and lower thickness safety thresholds, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be a normal synchronous ripening state. If the individual morphological representation information is less than the thickness lower limit safety threshold, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be an overall fast ripening state. If the individual morphological representation information is less than the thickness lower limit safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be a surface abnormal state.
[0010] Furthermore, the steps of adjusting the contribution weights of visual feature information from the edge region and the center region in ripeness determination according to the ripeness status category, and outputting the ripeness level of the cookie based on the adjusted contribution weights, include: If the ripening state is characterized by browning at the edges followed by a delayed ripening at the center, then execute: Based on the visual feature difference value, the attenuation coefficient of the edge feature weight is calculated according to the preset weight allocation rule; The original contribution weights of the visual features of the edge region are multiplied by the attenuation coefficient to obtain the attenuated edge region weights. The attenuation weight share after the weight attenuation in the edge region is fully compensated to the center region, thereby increasing the dominant weight of the visual features in the center region. Output the cookie's ripeness level based on the adjusted contribution weights; If the ripening state category is normal synchronous ripening state, the preset fixed benchmark weight remains unchanged, and the ripeness level of the cookie is output according to the fixed benchmark weight. If the ripening status category is overall fast ripening, the preset fixed baseline weight remains unchanged, and the corresponding preset ripeness judgment parameter is called to calculate and output the ripeness level of the cookie. If the ripening state category is surface abnormality, the regular weighted fusion process will be interrupted, and the cookie ripeness level will be directly determined as unqualified.
[0011] Furthermore, after extracting the visual features of the edge region and the visual features of the center region respectively, the method also includes: Identify defective areas in image information; Calculate the proportion of the defect area to the total area of the image information; When the area ratio of the defective region exceeds the preset interference threshold, the contribution weight is adjusted a second time according to the distribution location of the defective region. The ripeness determination of cookies is corrected based on the area ratio of the defective region.
[0012] Furthermore, the method also includes: When the browning state category is that the edges brown first and the center browns later, extract the brightness feature value from the visual features of the central region. The brightness feature value is compared with the preset raw and cooked critical safety threshold. If the brightness characteristic value is higher than the preset safety threshold for raw and cooked cookies, the cookie's ripeness level will be forcibly determined as unqualified.
[0013] Furthermore, the method also includes: Determine whether the instruction to adjust the contribution weight of the visual features of the edge region and the visual features of the center region in the maturity determination is within the preset physical thermal inertia shielding window period; If the instruction to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination is within the physical thermal inertia shielding window, then the current contribution weight settings of the visual feature information of the edge region and the visual feature information of the center region in the maturity determination will remain unchanged. If the physical thermal inertia shielding window expires, the moving average anomaly ratio is calculated. The moving average anomaly ratio refers to the proportion of abnormal cookies that are judged to be in a state of browning at the edges and lag in the center within the preset continuous sampling window, out of the total number of detected cookies. Determine whether the proportion of anomalies in the moving average is within the preset dead zone. If the moving average anomaly ratio is within the dead zone, the current contribution weight setting remains unchanged. If the moving average anomaly ratio is not within the dead zone, then an additional instruction is output to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination.
[0014] Secondly, the present invention also discloses a system for detecting the baking doneness of cookies based on image recognition, for performing the aforementioned method, the system comprising: The information acquisition module is used to acquire image information of cookies and extract individual morphological characterization information to characterize the thickness differences of individual cookies based on the image information. The region segmentation module is used to divide the cookie into edge regions and center regions based on image information; The feature extraction module is used to extract visual features of the edge region and visual features of the center region, respectively. The feature difference module is used to calculate the visual feature difference value between the edge region and the center region based on the visual features of the edge region and the visual features of the center region. The condition judgment module is used to determine the ripening status category of cookies based on individual morphological representation information and visual feature difference values; The output adjustment module is used to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the ripeness determination according to the ripeness status category, and output the ripeness level of the cookie according to the adjusted contribution weights.
[0015] This technical solution enables the automation of image recognition and maturity detection at the system level. Through modular design, the functional units work together to ensure that the method operates efficiently and stably in actual industrial environments, thereby improving the online quality control level of large-scale production lines.
[0016] In summary, this invention provides a method and system for detecting cookie baking doneness based on image recognition. The method acquires cookie images and extracts morphological information representing individual thickness differences. It then combines the visual feature differences between the edge and center regions to determine the baking doneness category, dynamically adjusting the contribution weights of the two regions in the doneness determination. This solves the systemic misjudgment problem in existing technologies where variations in individual cookie sizes lead to browning at the edges before the center, resulting in inconsistent doneness across different colors. This technical solution, by associating two-dimensional visual features with three-dimensional physical heating conditions, overcomes the limitations of traditional unified rules interpreting the entire image. It effectively blocks the transmission path where the appearance of premature browning at the edges masks the true delayed state at the center, ensuring that doneness determination is based on the true doneness of the cookie center rather than surface color. This significantly improves the consistency and accuracy of doneness detection under continuous production conditions, ensuring that cookies of varying thicknesses can be accurately sorted according to their true quality. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating a method for detecting the baking doneness of cookies based on image recognition, provided in an embodiment of the present invention.
[0018] Figure 2 This is a schematic diagram of a system for detecting the baking doneness of cookies based on image recognition, provided in an embodiment of the present invention.
[0019] Labeling Explanation: 210, Information Acquisition Module; 220, Region Division Module; 230, Feature Extraction Module; 240, Feature Difference Module; 250, Situation Judgment Module; 260, Output Adjustment Module. Detailed Implementation
[0020] The technical solutions of this invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some, not all, of the embodiments of this invention. The components of this invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0021] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0022] In continuous industrial cookie production lines, after being extruded or cut into shape by a forming machine, the cookies are baked in a long tunnel oven and then enter a visual inspection area for quality control. Existing image recognition systems typically use uniform rules to interpret images of the entire cookie, failing to consider the asynchronous browning between the center and edges caused by individual size variations. This leads to an amplification of the contribution of dark edge areas to the overall color statistics, causing thick cookies with dark edges but uncooked interiors to be mapped to the same ripeness level as truly ripe thin cookies. This error of judging different ripeness levels by the same color makes it difficult for ripeness detection results to accurately reflect the actual ripening process of different individuals. Consequently, undercooked products with insufficiently ripe centers are misjudged as acceptable, severely impacting the consistency and taste of the final product.
[0023] Firstly, please see Figure 1 This invention provides a method for detecting the baking doneness of cookies based on image recognition, comprising: 1. Obtain image information of cookies and extract individual morphological representation information to characterize the thickness differences of individual cookies; 2. Based on the image information, divide the cookie into an edge region and a center region; 3. Extract the visual features of the edge region and the visual features of the central region respectively; 4. Calculate the visual feature difference between the edge region and the central region based on their visual features. 5. Determine the cookie's ripening status category based on individual morphological characteristics and visual feature differences; 6. Based on the ripeness category, adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the ripeness determination, and output the ripeness level of the cookie according to the adjusted contribution weights.
[0024] Specifically, individual morphological characterization information refers to quantitative data used to reflect the differences between the physical form of the currently tested cookie, especially its thickness or spread, and the standard form. This information is not limited to a single thickness value; it can also be a characterization result that can indirectly reflect the trend of thickness variation, such as the relative thickness derived from the spread area, the deviation level obtained by comparing the relative thickness with the standard target thickness, or the fluctuation index that combines multiple morphological indicators.
[0025] The visual feature difference value refers to the difference in visual appearance, such as color depth and texture roughness, between different areas on the same surface of a cookie, such as the edge and the center. It is used to measure the uniformity of browning on the cookie surface. This difference can originate from differences between color features, differences between texture features, or a combination of both.
[0026] The baking state category refers to the specific physical state of the cookie, inferred from its physical shape and the uniformity of browning. For example, is the cookie evenly baked throughout, or is it burnt at the edges while the center is undercooked? This category can be understood as an intermediate judgment connecting the appearance and the actual baking process. Its role is not to directly determine whether the cookie is acceptable or not, but rather to first identify which typical baking mode the cookie belongs to, and then adjust the subsequent baking determination strategy accordingly. For example, baking state categories may include normal synchronous baking, browning at the edges while the center bakes later, rapid baking overall, and abnormal surface conditions. Different categories correspond to different visual interpretation logics and different weighting methods.
[0027] For the above technical solution, acquiring image information of the cookies is fundamental to the entire inspection process. In one embodiment, an industrial color camera can be deployed above the production line to acquire RGB images of the cookies passing through the inspection area in real time under uniform diffuse light source illumination. The image information is preferably an area array image containing the complete cookie outline, surface color distribution, and local texture details. To ensure the repeatability of subsequent area calculations, region division, and color comparisons, the acquisition position is preferably set at the inspection station after the cookies have left the baking equipment and undergone a brief, stable conveying process. This ensures that the cookie posture is basically stable, adjacent cookies have separable spacing, and the surface is no longer directly affected by the strong heat radiation from the oven. The diffuse light source aims to minimize the reflection of grease on the cookie surface and local bright spots, preventing edge highlights from being misidentified as light-colored areas or central shadows from being misidentified as dark-colored areas.
[0028] After acquiring the image, it is necessary to extract individual morphological characterization information. For example, a high-precision 3D laser contour scanner can be installed above the production line. As cookies pass by, the scanner directly acquires 3D point cloud data of the cookie surface. By calculating the distance between the highest point of the point cloud and the reference conveyor belt plane, the absolute thickness of the cookie can be directly obtained, serving as the individual morphological characterization information. To ensure stable implementation, the height of the conveyor belt surface when no cookies are passing is prioritized for reference acquisition. This reference surface is used as the reference plane for thickness measurement. When a cookie enters the scanning area, the point cloud belonging to the cookie body is extracted, and the position of the highest point is identified. The vertical distance from this highest point to the reference plane is used as the absolute thickness value. If particles, cracks, or local protrusions exist on the cookie surface, to avoid inflated thickness due to a single abnormal point, a smoothing and statistical analysis of the top local area can be performed before determining the representative height. This ensures that the obtained individual morphological characterization information more closely approximates the overall thickness of the cookie, rather than reflecting accidental surface protrusions.
[0029] After acquiring the image, the cookie region needs to be divided. In some implementations, this can be done by extracting the smallest bounding rectangle or circumscribed circle of the cookie in the image, and then dividing the outer pixel ring into edge regions and the remaining pixels into center regions, using a fixed pixel width as the boundary. To ensure this division method is truly applicable to ripeness detection, the cookie body should be separated from the background first, and then region division should be performed on a single cookie target. Specifically, color thresholding or background subtraction can be performed on the RGB image to obtain the foreground mask of the cookie. If debris, small holes, or edge burrs exist, connected component filtering, hole filling, and smoothing can be further performed to obtain a complete contour region. Subsequently, for this contour region, the contour line is shrunk inward by a preset width. The outer ring after shrinkage is defined as the edge region, and the inner retained part is defined as the center region. The preset width is set according to the image resolution, the imaging size of the cookie in the image, and the calibration relationship of the detection station, so that the edge region can cover the outer band of the cookie where obvious browning first occurs, while the center region can retain the main body region sufficient to reflect the internal ripening state. If there are batch variations in cookie size, the width can be set to a relative width related to the cookie's shape scale to avoid small cookies being over-divided and having an overly small central area, or large cookies having an overly narrow edge area that fails to adequately characterize edge browning features.
[0030] After dividing the region, the visual features of the two regions are extracted separately. More specifically, the RGB image can be converted to the HSV color space, and the mean and dispersion of the H (hue), S (saturation), and V (brightness) channels of pixels in the edge and center regions can be statistically analyzed. Simultaneously, the contrast and energy texture features of the two regions are extracted using a gray-level co-occurrence matrix. The HSV color space is used because during the baking process of cookies, the color change from light yellow to golden yellow and then to dark brown is reflected not only in the brightness but also in the changes in overall hue and saturation. Using HSV representation makes it easier to distinguish between the phenomena of color deepening and color browning. In practice, pixel sets can be established for the edge and center regions respectively, and then the color distribution of each pixel in each region can be statistically analyzed to obtain the comprehensive color features of that region. At the same time, the region image is converted to a grayscale image, and a gray-level co-occurrence matrix is constructed according to a preset adjacency direction and distance. From this matrix, texture indicators reflecting surface roughness, graininess, and dryness can be extracted. Subsequently, visual feature difference values are derived by calculating the distance-based or similarity-based difference values between the feature vectors of these two regions. If a distance-based representation is used, a larger difference value indicates a stronger contrast in color or texture between the cookie's edge and center. If a similarity-based representation is used, the similarity level can be converted into a difference level before being uniformly included in the subsequent judgment process. To ensure comparability between different batches of images, white balance correction, brightness normalization, or color calibration based on a standard color chart are performed before feature extraction. This ensures that the visual feature difference values reflect more the baking differences within the cookies themselves, rather than spurious differences caused by ambient light fluctuations.
[0031] Next, the individual morphological representation information and visual feature difference values are combined for logical judgment. For example, a two-dimensional judgment matrix is pre-constructed, with the horizontal axis representing thickness level and the vertical axis representing visual difference level. When the input individual morphological representation information indicates that the cookie is too thick, and the visual feature difference value indicates a large contrast between the edge and the center, the matrix will determine the cookie's ripening state category by looking up a table: the edge browns first while the center ripens later. To more clearly and completely describe how this judgment matrix is obtained, it can be constructed as follows: First, images of multiple batches of cookie samples are continuously collected on the actual production line, and the individual morphological representation information and visual feature difference value of each sample are recorded simultaneously; then, quality inspectors, based on cross-sectional observation, experience assessment, or offline verification results, label each sample with its true ripening state category; then, these labeled samples are divided into several thickness level intervals according to the size of the individual morphological representation information, and into several visual difference level intervals according to the size of the visual feature difference value; finally, the most frequently occurring ripening state category in each intersection interval is counted, and this correspondence is recorded as a two-dimensional judgment matrix. The resulting judgment matrix is not arbitrary but derived from empirical induction of actual samples. For example, when most samples within a certain cross-section exhibit smaller area, higher relative thickness, significantly darker edge color than the center, and a still relatively soft and moist central cross-section, this cross-section can be labeled as a state where the edges brown first and the center ripens later. In subsequent online detection, simply mapping the thickness level and visual difference level of the current cookie to this matrix quickly yields the ripening state category.
[0032] Finally, the weights are dynamically adjusted based on the determined ripening state category. Under normal circumstances, the contribution weights of the edges and the center to the final ripening score can be set to a relatively balanced state; however, if the state category is determined to be the aforementioned state where the edges brown first and the center ripens later, the weight of the visual features of the edge region will be reduced, and the weight of the center region will be increased accordingly. The reduction and increase can be set to different weight combinations depending on the ripening state category. For example, for the normal synchronous ripening state, the edge region and the center region can adopt a near-balanced contribution weight; for the state where the edges brown first and the center ripens later, the center region is set as the dominant weight and the edge region as the auxiliary weight; for the overall fast ripening state, both the edges and the center can maintain high attention, but the overall mapping result is biased towards the low ripening level. Finally, the features of the edge and the center are weighted and integrated using the adjusted weights, and input into the preset ripening mapping model to output the final ripening level.
[0033] Through the aforementioned overall technical solution, this invention overcomes the limitations of traditional visual inspection methods that rely on fixed global features for ripeness assessment. Its core working principle lies in the fact that the system no longer blindly trusts the overall color of the cookie surface, but instead establishes a logical connection between physical shape, local visual differences, and internal ripeness status. When it detects that a cookie is thick and has abnormally dark edges, it can intelligently infer that this is a surface illusion caused by lag in heat conduction. It then actively weakens the interference of deceptive dark edge features, shifting the focus of judgment to the central area, which better reflects the true internal ripeness. This dynamic weight adjustment mechanism effectively avoids misjudgments of different ripeness levels due to individual shape differences, allowing the ripeness detection results to penetrate surface phenomena and truly reflect the internal ripening process of the cookie, thereby accurately intercepting substandard products that are undercooked in the center.
[0034] In some preferred embodiments, based on image information, individual morphological characterization information of the cookies is extracted, including: Based on the image information, obtain the spreadable area of the cookies; Calculate the relative thickness of the cookies based on the preset standard volume and spread area of the dough; Based on the deviation between the relative thickness and the standard target thickness, the individual morphological fluctuation index is calculated and used as information representing the individual morphology.
[0035] Specifically, the preset standard volume of dough can be obtained through production process calibration. Specifically, under stable production conditions, several unbaked dough blanks can be continuously sampled from the forming machine, and their average volume can be measured, or a representative volume value can be obtained by converting the stable weight and formula density, and this representative volume value can be used as the standard volume of dough under the current product specifications.
[0036] The preset standard target thickness can be determined by selecting a batch of standard cookie samples that have been manually confirmed to be qualified in terms of ripeness, appearance, and taste during the product finalization stage, measuring their representative thickness range using an offline thickness measurement tool, and then determining the standard target thickness applicable to the product specification.
[0037] In standardized cookie production, the weight and volume of dough cut by the front-end forming machine are highly consistent each time; that is, the standard volume of the dough is a known, fixed constant. When the dough enters the oven, it spreads out. The more it spreads, the larger the area, and naturally, the thinner the dough. Therefore, the first step is to perform threshold segmentation on the acquired 2D image, count the total number of pixels belonging to the cookie body, and calculate the actual spread area of the cookie by combining this with the camera's physical calibration parameters. To ensure stable implementation, a calibration plate of known size is placed at the detection station to obtain the pixel scale relationship per unit length in the image, and based on this, the total number of cookie body pixels is converted into the actual area. During threshold segmentation, the difference in color or brightness between the cookie and the conveyor belt can be used to separate the cookie body from the background. If the conveyor belt color is close to the cookie color, the contrast between the two can be enhanced in the lighting design, or a background reference image can be used for differential segmentation. After segmentation, the foreground area is denoised, edge-repaired, and connected component filtered to avoid interference from debris, shadows, or adjacent cookie adhesion on the area calculation. Next, by dividing the preset standard dough volume by the spreadable area, the relative thickness of the cookie can be estimated. Since water loss and slight deformation occur during baking, this relative thickness is more suitable as a relative indicator reflecting individual thickness differences than as a precise substitute for absolute geometric thickness. Subsequently, this relative thickness is compared with the standard target thickness required by the process to obtain an individual shape fluctuation index. This fluctuation index can be expressed in the form of a grade value, deviation label, or continuous rating, as long as it can stably distinguish between thicker, near-standard, and thinner states. For example, the individual shape fluctuation index can be calculated as follows: First, the standard dough volume and standard target thickness are obtained offline, and the camera pixel and physical size scales are calibrated; during online detection, threshold segmentation, noise reduction, and connected component filtering are performed on the acquired cookie images, and the effective pixels of the cookies are counted and converted to obtain the actual spreadable area. Based on the volume conservation relationship, the relative thickness of the cookie is obtained by dividing the standard dough volume by the spreadable area. The individual morphological fluctuation index is then calculated using the formula I = (H − H0) / H0, where H is the relative thickness of the cookie and H0 is the standard target thickness. This index is a dimensionless relative deviation value: a high positive deviation indicates that the relative thickness of the cookie is greater than the standard target thickness, meaning the cookie is generally too thick; a near-zero index indicates that the cookie thickness meets the process standard; and a high negative deviation indicates that the relative thickness of the cookie is less than the standard target thickness, meaning the cookie is generally too thin. This index can be output as a continuous value, a discrete level, or a textual deviation label to quantify the individual differences in cookie spread and thickness. This specific implementation scheme utilizes only conventional two-dimensional image data, combined with prior knowledge of volume conservation physics in the production process, to achieve high-speed and accurate estimation of cookie thickness, completely eliminating reliance on expensive 3D scanning equipment.
[0038] In practical applications, the steps for dividing a cookie into edge and center regions based on image information include: Based on image information, determine the outline region of the cookie; A distance transformation is performed on the binary mask image of the contour region to obtain a distance map, which represents the shortest distance from each pixel in the contour region to the contour boundary. Determine the maximum distance value in the distance map; The partition distance threshold is determined based on the product of the maximum distance value and the preset ratio coefficient. Pixels with distance values less than the partition distance threshold are classified as edge regions, and pixels with distance values greater than or equal to the partition distance threshold are classified as center regions.
[0039] Because the spreading of dough during baking has a certain degree of randomness, the final shape of cookies is often not a perfect circle or rectangle, but a natural shape with irregular edges. If a fixed pixel width is used to divide the region inward, when encountering irregularly shaped cookies or cookies with gaps, the divided central region will deviate significantly from the actual physical geometric center, thus extracting incorrect visual features. In order to accurately fit cookies with arbitrary irregular shapes, this specific implementation introduces a distance transformation algorithm.
[0040] In practice, the closed contour of the cookie is first extracted using an edge detection algorithm, generating a binary mask image with the target value filled inside and the background value outside. To avoid distortion of the distance transformation result due to contour breakage, contour closure, hole filling, and small region removal are added after edge detection to ensure that the obtained contour area completely covers the cookie body. Subsequently, a Euclidean distance transformation is performed on the binary mask image. In the generated distance map, the value of each pixel is no longer color, but represents the shortest distance from that point to the nearest contour boundary. The distance is the depth of the pixel inside the cookie; the closer to the edge, the smaller the distance value; the closer to the inner core area, the larger the distance value. The system traverses the distance map to find the pixel with the largest value or the region with the largest value. This position corresponds to the core position inside the cookie furthest from the boundary, and its corresponding value is the maximum distance value. Next, a preset scaling factor is introduced, and the maximum distance value is combined with this preset scaling factor to obtain the partition distance threshold. The role of this preset scaling factor is to control the relative range of the edge region and the center region.
[0041] If product specifications change, such as significant variations in cookie diameter, recipe, or spreading characteristics, the scaling factor can be recalibrated. Finally, similar to contour mapping, pixels with distance values less than the partition distance threshold are classified as edge regions, while pixels with values greater than or equal to the threshold are classified as center regions. Through this dynamic partitioning mechanism based on topological distance, regardless of the irregular twists or distortions of the cookies, the true physical edges and centers can be adaptively and accurately identified, ensuring the accuracy of subsequent feature extraction and providing a reliable spatial data foundation for high-precision ripeness comparison.
[0042] In continuous industrial production lines, during the baking process of cookies, in addition to normal browning, abnormal black spots or foreign objects sometimes appear on the cookie surface due to localized overheating of the baking pan, sugar granules or chocolate chips adhering to the dough surface, or tiny foreign objects falling from the production environment. If the overall visual features are extracted directly from the defined edge and center areas, these small but extremely dark abnormal spots will significantly reduce the average brightness of the area or change the statistical results of color distribution, causing the system to mistakenly identify the area as over-browned or even burnt. To avoid such local anomalies interfering with the extraction of overall ripeness features, it is necessary to identify and remove abnormal pixels in the image.
[0043] In some preferred embodiments, after dividing the cookie into edge and center regions, the method further includes: Identify the set of pixels in an image whose grayscale values significantly deviate from the average grayscale value of the cookie subject; Perform connected component analysis on the pixel set, and mark abnormal focal spots or foreign objects based on the area and shape irregularity of the connected components; When extracting visual features from the edge region and the center region respectively, the influence of abnormal focal spots or foreign objects on the visual feature statistics is excluded.
[0044] Specifically, the average gray value of the cookie body refers to the gray level obtained only for the main body area after the cookie outline has been segmented, excluding the pixels of the conveyor belt, baking tray edge, background shadow and adjacent cookies, so as to avoid the background area from being included in the statistics and causing the baseline value to be distorted.
[0045] Significant deviations in grayscale values are outliers that appear noticeably darker or brighter compared to the main distribution formed by the normal browning of cookies. For example, black spots formed by localized scorching usually appear as continuous small dark areas, while highly reflective particles, debris, or white foreign matter attached to the surface may appear as localized abnormal bright spots. Identifying sets of pixels with significantly deviated grayscale values primarily involves statistically analyzing the grayscale histogram of the cookie body to calculate the average grayscale value and standard deviation. When the grayscale value of some pixels is lower than the average grayscale value minus several times (e.g., 3 times) the standard deviation (i.e., abnormally dark), or higher than the average grayscale value plus several times the standard deviation (i.e., abnormally bright), these pixels are extracted to form a set of pixels.
[0046] Connected component analysis combines these adjacent anomalous pixels into independent regions, calculating their area and shape irregularity, such as the ratio of the square of the perimeter to the area. Anomalous focal spots are usually small in area and relatively regular in shape, while foreign objects may exhibit elongated or extremely irregular shapes.
[0047] Shape irregularity is used to distinguish between natural browning boundaries and aberrant contamination boundaries. Natural browning generally has a smooth transition and continuous edges, while foreign matter or broken residues usually have abrupt edges, sharp corners, long tails, or blocky broken outlines, making it suitable as one of the screening conditions for connected regions.
[0048] To describe the process more clearly and completely, the following image acquisition and preprocessing methods can be used: An industrial camera is installed above the discharge end of the baking equipment, continuously capturing images of the cookie surface along the conveying direction. To reduce the impact of ambient light variations, a ring-shaped diffused light source or a strip-shaped supplementary light source can be used to keep the shadows and specular reflections on the cookie surface within a stable range. The raw color images captured by the camera are first sent to an image processing unit. The image processing unit obtains a complete contour mask of a single cookie through threshold segmentation, edge detection, or contour extraction based on a trained segmentation model. Then, grayscale conversion and grayscale statistics are performed only within this complete contour mask. The purpose of this processing is to ensure that the subsequent statistical object is indeed the cookie surface and not the external background. For example, when a cookie is located on a metal conveyor belt, if the complete contour is not extracted first, the bright reflective points on the metal conveyor belt may be mistaken for abnormal bright spots, thus affecting the identification results of abnormal pixel sets.
[0049] In practice, after obtaining the complete outline of the cookie, it can be converted into a grayscale image, and the overall average grayscale value can be calculated. A deviation threshold is set, for example, if the grayscale difference is greater than a preset value, and all pixels meeting the condition are binarized. Next, a connected component labeling algorithm is called to filter out connected components with an area within a specific pixel range and a shape irregularity greater than a preset value, marking them as anomalous masks. When subsequently extracting the HSV color mean or grayscale co-occurrence matrix texture features of the edge and center regions, these pixels covered by anomalous masks are directly ignored in the statistical calculation. The preset value, the specific pixel range, and the preset value can be established using historical samples.
[0050] The working principle of this specific implementation scheme is to identify interference sources that do not belong to the normal baking browning process at the pixel level in advance through grayscale statistics and morphological analysis. When extracting visual features, only normal pixels that truly reflect the baking state of the dough are used for calculation.
[0051] After acquiring individual morphological representation information and visual feature difference values, it is necessary to combine these two dimensions of information to accurately infer the current true baking state of the cookies. In actual production, the baking process of cookies is not simply a matter of raw or cooked, but involves multiple complex physical states. Using only a single threshold for a one-size-fits-all judgment cannot cover these complex production realities. To accurately identify the specific baking mode of the cookies so that targeted judgment strategies can be adopted subsequently, a multi-dimensional classification and judgment logic needs to be established.
[0052] In a preferred embodiment of the present invention, the step of determining the ripening state category of cookies based on individual morphological characterization information and visual feature difference values includes: The individual morphological characterization information is compared with the preset upper and lower thickness safety thresholds. Compare the visual feature difference values with a preset local difference threshold; If the individual morphological representation information is greater than the upper limit of the thickness safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be a state where the edges brown first and the center ripens later. If the individual morphological representation information is between the upper and lower thickness safety thresholds, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be a normal synchronous ripening state. If the individual morphological representation information is less than the thickness lower limit safety threshold, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be an overall fast ripening state. If the individual morphological representation information is less than the thickness lower limit safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be a surface abnormal state.
[0053] In practice, thresholds can be set by statistically analyzing data from historical normal production batches. For example, a confidence interval for the relative thickness of historical normal cookies can be taken, with the upper limit serving as the upper limit safety threshold for thickness and the lower limit as the lower limit safety threshold for thickness; the maximum tolerable value for the color difference between the edge and center of a normally ripened cookie can be taken as the local difference threshold. During online detection, if the calculated relative thickness of a cookie exceeds the upper limit (i.e., it is too thick), and the color difference between its edge and center is extremely large (greater than the local difference threshold), the first logic will be triggered, accurately classifying it as a state where the edge browns first while the center ripens later. Conversely, if the thickness is between the upper and lower limits and the color difference is small, it is classified as a normal synchronous ripening state. If the cookie is extremely thin (less than the lower limit) and the color difference is small, it indicates that it is heated very quickly and evenly, and is classified as an overall fast-ripening state. However, if the cookie is extremely thin but the color difference is extremely large, this violates the physical common sense that thin cookies are usually heated evenly, which usually means that the local temperature of the baking pan is out of control or the surface is subjected to abnormal heat radiation, and is therefore classified as an abnormal surface state.
[0054] The working principle of this specific implementation scheme lies in cross-validating physical form with surface visual phenomena. Instead of viewing color or thickness in isolation, the system utilizes the principles of baking thermodynamics to map different combinations of conditions onto specific physical ripening states. Through this multi-condition branching decision logic, the system can accurately discern the true reasons behind the cookie's appearance.
[0055] After accurately determining the cookie's ripening state, the core task of the system is to provide the most realistic ripeness rating based on these different states. Traditional detection systems often use a fixed weighting formula to fuse edge and center features, which is effective when dealing with normal, synchronized ripening states. However, when faced with a state where the edges brown first while the center ripens later, the fixed weights cause the darker edges to excessively inflate the overall ripeness score; and when dealing with abnormal surface states, conventional weighted calculations are meaningless. To completely solve the problem of different ripening states for the same color and to implement the most reasonable evaluation for different ripening patterns, the system needs to break free from the constraints of fixed weights and introduce a dynamic weight adjustment and output mechanism based on state categories.
[0056] In practical applications, the steps of adjusting the contribution weights of visual feature information from the edge region and the center region in ripeness determination according to the ripeness status category, and then outputting the ripeness level of the cookie based on the adjusted contribution weights, include: If the ripening state is characterized by browning at the edges followed by a delayed ripening at the center, then execute: Based on the visual feature difference value, the attenuation coefficient of the edge feature weight is calculated according to the preset weight allocation rule; The original contribution weights of the visual features of the edge region are multiplied by the attenuation coefficient to obtain the attenuated edge region weights. The attenuation weight share after the weight attenuation in the edge region is fully compensated to the center region, thereby increasing the dominant weight of the visual features in the center region. Output the cookie's ripeness level based on the adjusted contribution weights; If the ripening state category is normal synchronous ripening state, the preset fixed benchmark weight remains unchanged, and the ripeness level of the cookie is output according to the fixed benchmark weight. If the ripening status category is overall fast ripening, the preset fixed baseline weight remains unchanged, and the corresponding preset ripeness judgment parameter is called to calculate and output the ripeness level of the cookie. If the ripening state category is surface abnormality, the regular weighted fusion process will be interrupted, and the cookie ripeness level will be directly determined as unqualified.
[0057] Specifically, the weight allocation rule can be a mathematical model that dynamically calculates the attenuation coefficient. Its input is the visual feature difference value, and its output is the attenuation coefficient within a specific range. The larger the difference value, the smaller the attenuation coefficient. The compensation mechanism for the attenuation weight share ensures that the sum of the total weights of the edges and centers remains constant, thereby guaranteeing the consistency of the input scale of the subsequent maturity mapping model.
[0058] For the overall quick-ripening state, the preset ripeness determination parameters are the mapping model parameters specifically built for thin cookies (i.e., the model parameters of the ripeness mapping model), because the overall color change curve of thin cookies is different from that of standard cookies.
[0059] In practice, it is assumed that the initial contribution weights for the edges and center are balanced. When a cookie is detected to be browning at the edges while the center lags behind in ripening, and the visual feature difference is large, the weight allocation rule calculates the corresponding attenuation coefficient. At this time, the new weight of the edge region becomes the original weight multiplied by the attenuation coefficient. The attenuated portion is fully compensated to the center region, causing the new weight of the center region to increase accordingly. Subsequently, the adjusted edge and center features are weighted and input into the ripeness mapping model to obtain the grade. If the state is a normal synchronous ripening state, the fixed baseline weights are used directly for calculation. If the state is an overall fast ripening state, the weights remain at the baseline, but the system switches to another set of ripeness judgment parameters specifically trained for thin cookies for scoring. If the state is a surface abnormal state, all calculations are skipped, an unqualified signal is output, and the rejection mechanism can be linked to remove it.
[0060] The preset weight allocation rule can be implemented as follows: First, select cookies from historical samples that are confirmed to be in a state of browning at the edges and lagging ripening in the center. Record the visual feature difference value, edge region features, center region features, and the final ripeness evaluation of each sample. Then, with the goal of making the final system judgment result as close as possible to the final ripeness evaluation, gradually test multiple sets of attenuation strategies, select a set of difference value-attenuation coefficient correspondences that can effectively reduce the misjudgment rate in most samples, and solidify this correspondence into a lookup table rule or program rule. For example, the visual feature difference value can be divided into several intervals: slight deviation, moderate deviation, and significant deviation, and different levels of edge weight attenuation can be set accordingly, without the need for complex formulas. During system operation, it is only necessary to look up the corresponding attenuation coefficient according to the difference interval into which the current cookie falls. The preset ripeness judgment parameters can also be established in the same way, that is, based on a large number of known ripeness level samples, form grade mapping parameter files for standard cookies and thin cookies respectively, and the control program automatically calls the corresponding files according to the ripeness status category during deployment.
[0061] The working principle of this specific implementation scheme is to achieve precise response to different baking phenomena through state-driven adaptive weight reconstruction.
[0062] During the extraction of visual features and weight adjustment, although small abnormal burnt spots or foreign objects have been eliminated through connected component analysis, in actual production, cookie surfaces sometimes exhibit large-area defects, such as large-area crust damage, severe cracking, or large pieces missing due to mold adhesion. The color and texture of these large-area defect areas are drastically different from those of normally baked surfaces. If these defect areas happen to be located in the central or edge areas assigned high weights, even after weight adjustment based on state categories, these large-area anomalous features will still severely distort the overall visual characteristics of the area, leading to significant deviations in the final ripeness grade calculation. To address the destructive impact of such large-area structural defects on ripeness determination, a feature correction mechanism based on the defect area ratio needs to be introduced after feature extraction.
[0063] In one specific embodiment, after extracting the visual features of the edge region and the visual features of the center region respectively, the method further includes: Identify defective areas in image information; Calculate the proportion of the defect area to the total area of the image information; When the area ratio of the defective region exceeds the preset interference threshold, the contribution weight is adjusted a second time according to the distribution location of the defective region. The ripeness determination of cookies is corrected based on the area ratio of the defective region.
[0064] Defect region identification typically relies on morphological analysis or deep learning semantic segmentation models to identify areas where surface textures are severely broken or where large areas exhibit unnatural color transitions. An interference threshold is a set upper limit on the area ratio used to distinguish between negligible minor imperfections and large-area defects sufficient to affect overall features. Based on the distribution location of the defect regions, contribution weights are adjusted a second time to shift the focus of feature extraction to intact surfaces. For example, when the area ratio of the defect region exceeds a preset interference threshold, a secondary weight adjustment is performed based on the pixel distribution location of the defect: If the defect is concentrated in the center region of the cookie (i.e., the sum of the areas of the defect regions in the center region accounts for more than a first preset ratio of the total area of all defect regions), the feature contribution weight of the center region is reduced by gradient, while the feature contribution weight of the edge regions is increased; if the defect is concentrated in the edge region of the cookie (i.e., the sum of the areas of the defect regions in the center region accounts for less than a second preset ratio of the total area of all defect regions, and the second preset ratio is less than the first preset ratio), the feature contribution weight of the edge regions is reduced by gradient, while the feature contribution weight of the center region is increased; if the defect covers both the edge and center regions (i.e., the sum of the areas of the defect regions in the center region accounts for between the first and second preset ratios of the total area of all defect regions), the feature contribution weights of the center and edge regions remain unchanged. The magnitude of the weight reduction is positively correlated with the area ratio of the defect in the corresponding region; the higher the defect ratio, the greater the weight reduction of the corresponding block. The weight reduction amount is added to the weight of another region as an increase. This adjustment is a localized secondary fine-tuning superimposed on the weight of the ripening state category. After the adjustment is completed, the ripeness determination result of the cookies will be corrected by combining the defect area ratio.
[0065] There is a difference in processing level between defective areas and abnormal focal spots or foreign objects: the former are usually larger in area and have more obvious structural damage, such as cracks running through the center, entire pieces of the surface peeling off, and large defects at the edges; the latter are usually localized small spots, small particles, or small contaminants, mainly affecting local pixel statistics. Here, the proportion of the area to the total area of the image information refers to the proportion of the defective area to the main area of the cookie, not the proportion to the entire camera frame, to avoid distortion caused by changes in the camera's field of view and the size of the background white space. Correcting the cookie's ripeness assessment result can be done not only by downgrading the ripeness level, but also by adding an appearance defect label, outputting a re-inspection mark, or simultaneously generating two parallel evaluation information sets: ripeness result and appearance result, so that downstream sorting stations can implement different processing strategies.
[0066] In practice, the system can run a surface defect detection model in parallel, outputting a defect mask of the cookie surface in real time. The proportion of this mask area to the total pixel area of the cookie is calculated. When a large crack appears in the center of a cookie, causing the defect area proportion to exceed a preset interference threshold, the system triggers a correction mechanism. When analyzing the visual features of the central region, the system significantly reduces the weight of the pixel set containing the crack, while increasing the weight of the remaining intact pixels within the central region, using these intact pixels to represent the features of the entire central region. Furthermore, since large-area defects already affect the cookie's appearance quality, the system will also downgrade the final ripeness assessment result based on this defect proportion, for example, by forcibly deducting one level from the original calculated ripeness level, or by adding an appearance downgrade label.
[0067] To make this defect detection mechanism easier to implement, two implementation paths can be adopted. The first is a rule-based path: first, perform texture analysis and edge continuity analysis on the main body area of the cookie. If features such as large low-texture voids, long-distance cracks, local boundary breaks, and color abrupt changes appear, the corresponding areas are marked as defect areas. The second is a model-based path: collect cookie images containing various states such as normal surfaces, minor cracks, severe cracks, defects, and adhesion damage. Manually annotate the defect range at the pixel level to train a semantic segmentation model, so that the model outputs a pixel-by-pixel defect mask. For the preset interference threshold, first statistically analyze the critical range at which the ripeness judgment deviation begins to increase significantly under different defect area ratios, and then select this critical range as the basis for setting the interference threshold. In actual deployment, it can also be set according to product specifications. For example, for small-sized cookies, smaller cracks may account for a higher proportion; while for large-sized cookies, a larger defect area is needed to significantly affect feature statistics. Therefore, the interference threshold can be saved according to specifications and automatically called by the system.
[0068] The working principle of this specific implementation plan is to establish a feature isolation and outcome compensation mechanism for large-area structural damage.
[0069] After determining that the edges are browning first while the center is lagging behind in ripening, although the system has shifted the focus of judgment to the central region through weight adjustment, if the ripening degree of the central region is too low—that is, completely in a raw dough state—even with weight adjustment, a conventional ripening mapping model may still give a low acceptable edge score. To completely prevent severely undercooked products from flowing into the next process, in a preferred embodiment of the present invention, the method further includes: When the browning state category is that the edges brown first and the center browns later, extract the brightness feature value from the visual features of the central region. The brightness feature value is compared with the preset raw and cooked critical safety threshold. If the brightness characteristic value is higher than the preset safety threshold for raw and cooked cookies, the cookie's ripeness level will be forcibly determined as unqualified.
[0070] Specifically, raw dough has a high moisture content in the early stages of baking, resulting in a highly reflective surface and a pale, whitish color. This manifests in images as abnormally high brightness characteristics, such as the average V channel value or average grayscale value in the HSV color space. The preset safety threshold for raw / undercooked dough is used to define the brightness boundary between barely cooked and completely undercooked. This threshold can be set by statistically analyzing the brightness of the central area of a large number of undercooked raw dough samples, combined with human sensory evaluation. When the system extracts a brightness characteristic value for the central area higher than this threshold, it indicates that the cookie's internal moisture has not fully evaporated and the starch has not completely gelatinized, classifying it as a severely undercooked defective product. In this case, the system no longer relies on weighted calculations but directly triggers a mandatory judgment mechanism, locking its ripeness level as unacceptable.
[0071] In continuous production processes, the temperature regulation of baking equipment often exhibits a significant lag. To avoid the system frequently triggering unnecessary control commands due to individual abnormal cookies, leading to oscillations in the production line control system, this invention further proposes the following control logic: Determine whether the instruction to adjust the contribution weight of the visual features of the edge region and the visual features of the center region in the maturity determination is within the preset physical thermal inertia shielding window period; If the instruction to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination is within the physical thermal inertia shielding window, then the current contribution weight settings of the visual feature information of the edge region and the visual feature information of the center region in the maturity determination will remain unchanged. If the physical thermal inertia shielding window expires, the moving average anomaly ratio is calculated. The moving average anomaly ratio refers to the proportion of abnormal cookies that are judged to be in a state of browning at the edges and lag in the center within the preset continuous sampling window, out of the total number of detected cookies. Determine whether the proportion of anomalies in the moving average is within the preset dead zone. If the moving average anomaly ratio is within the dead zone, the current contribution weight setting remains unchanged. If the moving average anomaly ratio is not within the dead zone, then an additional instruction is output to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination.
[0072] In actual tunnel oven baking, the oven chamber is large and has a high heat capacity. There is a physical time lag between adjusting the heating tube power and the actual heating state of the cookies changing, known as physical thermal inertia. If the system immediately re-evaluates the subsequent cookies and issues new instructions after issuing a weight adjustment or process intervention command, over-adjustment will occur because the effect of the previous adjustment has not yet manifested. Therefore, a physical thermal inertia shielding window is introduced. The length of this window is typically set to the time required for the cookies to travel from the heating zone to the detection zone, or the empirical time required for the oven temperature to stabilize. During this period, the system will shield new adjustment commands, maintain the existing weight settings, and keep the production line in a stable observation period.
[0073] After the shielding window ends, the system doesn't act rashly based solely on the state of a single cookie. Instead, it introduces the concepts of a moving average anomaly ratio and a deadband. Within a preset continuous sampling window, such as the most recently tested 100 cookies, the system calculates the proportion of cookies where the edges brown first while the center lags behind. The deadband is a commonly used concept in control engineering, used to tolerate normal, minor fluctuations in the process. If the calculated anomaly ratio falls within this deadband, for example, 3% to 5%, it indicates that the current anomaly is within acceptable random fluctuations, and the system maintains the status quo. Only when the anomaly ratio exceeds the deadband, for example, exceeding 5%, does it indicate a systemic process deviation in the production line, such as an overall dough thickness or an overall low oven temperature. Only then will the system output additional weight adjustment commands, and may even coordinate with the host computer to correct process parameters.
[0074] Secondly, see Figure 2 The present invention also proposes a system for detecting the baking doneness of cookies based on image recognition, for performing the aforementioned method, the system comprising: The information acquisition module 210 is used to acquire image information of cookies and extract individual morphological characterization information to characterize the thickness difference of individual cookies based on the image information. The region segmentation module 220 is used to divide the cookie into an edge region and a center region based on image information; Feature extraction module 230 is used to extract visual features of the edge region and visual features of the center region respectively; The feature difference module 240 is used to calculate the visual feature difference value between the edge region and the center region based on the visual features of the edge region and the visual features of the center region. The condition judgment module 250 is used to determine the ripening status category of cookies based on individual morphological representation information and visual feature difference values. The output module 260 is used to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the ripeness determination according to the ripeness status category, and output the ripeness level of the cookie according to the adjusted contribution weights.
[0075] Specifically, the information acquisition module 210 can communicate directly with the industrial camera and image acquisition card; the region division module 220 and the feature extraction module 230 can be implemented using an image processing algorithm library; and the situation judgment module 250 and the output adjustment module 260 can be constructed based on preset logical rules or trained machine learning models.
[0076] Through the aforementioned technical solution, the system can automatically and intelligently execute the aforementioned ripeness detection method. Instead of blindly relying on global color features, the system establishes a deep logical connection between physical shape, local visual differences, and internal ripeness state through the collaborative work of various modules, dynamically adjusting the judgment weights. This effectively overcomes the problem of misjudging different ripeness levels due to variations in the shape of individual cookies, achieving accurate insight into the true ripening process inside the cookie and providing an efficient and reliable quality control method for continuous industrial production.
[0077] The above description is merely an embodiment of the present invention and is not intended to limit the scope of protection of the present invention. For those skilled in the art, the present invention can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for detecting the baking doneness of cookies based on image recognition, characterized in that, include: Acquire image information of cookies and extract individual morphological representation information to characterize the thickness differences of individual cookies; Based on the image information, the cookie is divided into an edge region and a center region; Extract the visual features of the edge region and the visual features of the center region respectively; Calculate the visual feature difference value between the edge region and the center region based on the visual features of the edge region and the center region; Based on the individual morphological representation information and the visual feature difference value, the ripening state category of the cookie is determined; Based on the ripening state category, the contribution weights of the visual features of the edge region and the visual features of the center region in ripening determination are adjusted, and the ripeness level of the cookie is output based on the adjusted contribution weights.
2. The method for detecting cookie baking doneness based on image recognition according to claim 1, characterized in that, The step of extracting the individual morphological representation information of the cookie based on the image information includes: Based on the image information, obtain the spreadable area of the cookie; The relative thickness of the cookie is calculated based on the preset standard volume of the dough and the spread area. Based on the deviation between the relative thickness and the standard target thickness, the individual morphological fluctuation index is calculated and used as the individual morphological characterization information.
3. The method for detecting cookie baking doneness based on image recognition according to claim 1, characterized in that, The step of dividing the cookie into an edge region and a center region based on the image information includes: Based on the image information, the outline region of the cookie is determined; A distance transformation is performed on the binary mask image of the contour region to obtain a distance map, which represents the shortest distance from each pixel point in the contour region to the contour boundary. Determine the maximum distance value in the distance map; The partition distance threshold is determined based on the product of the maximum distance value and the preset ratio coefficient; The set of pixels with a distance value less than the partition distance threshold is divided into the edge region, and the set of pixels with a distance value greater than or equal to the partition distance threshold is divided into the center region.
4. The method for detecting cookie baking doneness based on image recognition according to claim 1, characterized in that, After dividing the cookie into an edge region and a center region, the method further includes: Identify the set of pixels in the image information whose grayscale values significantly deviate from the average grayscale value of the cookie body; Perform connected component analysis on the set of pixels, and mark abnormal focal spots or foreign objects according to the area and shape irregularity of the connected components; When extracting the visual features of the edge region and the visual features of the center region respectively, the influence of abnormal focal spots or foreign objects on the visual feature statistics is excluded.
5. The method for detecting cookie baking doneness based on image recognition according to claim 1, characterized in that, The step of determining the ripening state category of the cookie based on the individual morphological representation information and the visual feature difference value includes: The individual morphological characterization information is compared with the preset upper and lower thickness safety thresholds. The visual feature difference value is compared with a preset local difference threshold; If the individual morphological characterization information is greater than the upper limit of the thickness safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be a state where the edges brown first and the center ripens later. If the individual morphological characterization information is between the upper limit safety threshold and the lower limit safety threshold of thickness, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be a normal synchronous ripening state. If the individual morphological representation information is less than the thickness lower limit safety threshold, and the visual feature difference value is less than or equal to the local difference threshold, then the cookie's ripening state is determined to be an overall fast ripening state. If the individual morphological characterization information is less than the thickness lower limit safety threshold, and the visual feature difference value is greater than the local difference threshold, then the cookie's ripening state is determined to be an abnormal surface state.
6. The method for detecting cookie baking doneness based on image recognition according to claim 5, characterized in that, The step of adjusting the contribution weights of the visual feature information of the edge region and the visual feature information of the center region in ripeness determination according to the ripeness state category, and outputting the ripeness level of the cookie according to the adjusted contribution weights, includes: If the ripening state category is one where the edges brown first and the center ripens later, then execute: Based on the visual feature difference values, the attenuation coefficient of the edge feature weight is calculated according to the preset weight allocation rule; The original contribution weight of the visual features of the edge region is multiplied by the attenuation coefficient to obtain the attenuated edge region weight. The attenuation weight share after the weight attenuation of the edge region is fully compensated to the central region, thereby increasing the dominant weight of the visual features of the central region in the determination. Based on the adjusted contribution weights, output the ripeness level of the cookies; If the ripening state category is normal synchronous ripening state, the preset fixed benchmark weight remains unchanged, and the ripeness level of the cookie is output according to the fixed benchmark weight. If the ripening state category is overall fast ripening state, the preset fixed benchmark weight remains unchanged, and the corresponding preset ripeness determination parameter is called to calculate and output the ripeness level of the cookie; If the ripening state category is a surface abnormality state, the regular weighted fusion process is interrupted, and the ripeness level of the cookie is directly determined to be unqualified.
7. The method for detecting cookie baking doneness based on image recognition according to claim 6, characterized in that, After extracting the visual features of the edge region and the visual features of the center region respectively, the method further includes: Identify defective regions in the image information; Calculate the proportion of the area of the defective region to the total area of the image information; When the area ratio of the defective region exceeds the preset interference threshold, the contribution weight is adjusted a second time according to the distribution location of the defective region. The ripeness determination result of the cookie is corrected based on the area ratio of the defective region.
8. The method for detecting cookie baking doneness based on image recognition according to claim 6, characterized in that, The method also includes: When the ripening state category is a state in which the edges brown first and the center ripens later, the brightness feature value in the visual features of the central region is extracted. The brightness feature value is compared with a preset safety threshold for raw and cooked food. If the brightness characteristic value is higher than the preset safety threshold for raw and cooked cookie, the cookie's ripeness level will be forcibly determined as unqualified.
9. The method for detecting cookie baking doneness based on image recognition according to claim 6, characterized in that, The method also includes: Determine whether the instruction to adjust the contribution weight of the visual features of the edge region and the visual features of the center region in the maturity determination is within a preset physical thermal inertia shielding window period; If the instruction to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination is within the physical thermal inertia shielding window period, then the current contribution weight settings of the visual feature information of the edge region and the visual feature information of the center region in the maturity determination remain unchanged. If the physical thermal inertia shielding window expires, the moving average anomaly ratio is calculated. The moving average anomaly ratio refers to the proportion of abnormal cookies that are judged to be in a state of browning at the edges and lag in the center within a preset continuous sampling window, out of the total number of detected cookies. Determine whether the abnormal proportion of the moving average is within a preset dead zone. If the abnormal proportion of the moving average is within the dead zone, the current contribution weight setting remains unchanged. If the moving average anomaly ratio is not within the dead zone interval, then an additional instruction is output to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the maturity determination.
10. A system for detecting the baking doneness of cookies based on image recognition, used to perform the method described in any one of claims 1 to 9, characterized in that, The system includes: The information acquisition module is used to acquire image information of cookies and extract individual morphological characterization information to characterize the thickness difference of individual cookies based on the image information. The region segmentation module is used to divide the cookie into an edge region and a center region based on the image information; The feature extraction module is used to extract the visual features of the edge region and the visual features of the center region, respectively. The feature difference module is used to calculate the visual feature difference value between the edge region and the center region based on the visual features of the edge region and the visual features of the center region; The condition judgment module is used to determine the ripening state category of the cookie based on the individual morphological representation information and the visual feature difference value; The output adjustment module is used to adjust the contribution weights of the visual features of the edge region and the visual features of the center region in the ripeness determination according to the ripeness status category, and output the ripeness level of the cookie according to the adjusted contribution weights.
