A method for detecting foreign matter in packaged food

By adjusting the parameters and image correction of image capture equipment, combined with X-ray detection, the problem of incomplete coverage of traditional detection methods in a diverse environment is solved, and efficient and accurate detection of foreign objects in packaged food is achieved to ensure food safety and production quality control.

CN118896962BActive Publication Date: 2024-12-03TANGSHAN ANIMAL HUSBANDRY AQUATIC PROD QUALITY MONITORING CENT

Patent Information

Application Number
CN202411397758.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2024-12-03
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

Traditional packaging food foreign object detection methods are not comprehensive in the diverse production environment, especially in low light or strong reflection environments, it is difficult to accurately capture all types of foreign objects, resulting in misjudgment or misjudgment, which cannot meet high-standard food safety needs. .

Method used

By adjusting the shooting parameters and image correction of the image capture device, combining X-ray detection, foreign objects are identified and marked, the matching degree of foreign objects characteristics and preset databases is evaluated, and the repeated labeled foreign objects are identified through the integrated analysis of images and X-ray results, and the evaluation is carried out. The abnormality level of the production process.

Benefits of technology

It improves the accuracy and integrity of foreign object detection, enhances the recognition rate of foreign object categories, ensures that no matter what kind of foreign object species, reduces the risk of food safety accidents, and helps food manufacturers to control production quality more effectively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118896962B_ABST
    Figure CN118896962B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of foreign body detection technology, specifically to a packaged food foreign body detection method, comprising the following steps: based on the packaged food to be detected, adjusting the shooting parameters of the image capture device according to the intensity of the ambient light, shooting the packaged food image, and correcting the captured image according to the color temperature of the ambient light to obtain the corrected packaged food image. The present invention makes the image analysis more accurate by correcting the image color deviation, enhances the recognition rate of the foreign body category by comparing with the preset foreign body library, and combines with X-ray imaging technology to perform more comprehensive detection of foreign bodies of different properties. Through the integrated analysis of the image and X-ray results, the integrity of the detection process is enhanced, avoiding the risk of possible omissions by a single technology, and evaluating the abnormality of the production process by analyzing the frequency and quantity of foreign bodies, which helps food manufacturers to control production quality more effectively.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of foreign matter detection, and in particular to a method for detecting foreign matter in packaged food. Background Art

[0002] Foreign body detection technology involves the use of various sensors, imaging techniques and data processing algorithms to identify and locate foreign objects in items. This technology is widely used in industries such as food safety, pharmaceuticals, textiles and packaging to ensure product quality and consumer safety. In the food industry, foreign body detection technology is particularly important to effectively prevent foreign objects such as metal, plastic, glass, stone, etc. from being mixed into products. The main detection technologies include X-ray imaging, metal detection, optical vision systems and infrared scanning, which can achieve high efficiency and high accuracy detection without damaging the product packaging.

[0003] Among them, the packaged food foreign body detection method is a technology applied to the food processing and packaging industry to identify and exclude substances that should not be present in packaged food, such as metal fragments, plastic pieces, glass pieces, etc. The method usually uses detection equipment such as X-ray detectors, optical scanners and metal detectors to ensure the safety and compliance of food. The method is designed to help food manufacturers comply with strict food safety regulations and protect consumers from potential health risks.

[0004] Traditional detection methods rely on a single imaging or detection method, which has incomplete detection coverage in diverse production environments, especially in complex lighting or variable foreign body characteristics, which can easily affect the detection effect. For example, in low-light or highly reflective environments, a single optical vision system or X-ray imaging is difficult to accurately capture all types of foreign bodies, especially those with a similar color to the background. Traditional methods rely on preset parameters and are not adaptable to environmental changes, resulting in misjudgments or missed judgments during the detection process, affecting overall product quality control, failing to fully meet high standards for food safety, and increasing the risk of food safety accidents. Summary of the invention

[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a method for detecting foreign matter in packaged food.

[0006] In order to achieve the above object, the present invention adopts the following technical solution: a method for detecting foreign matter in packaged food, comprising the following steps:

[0007] S1: Based on the packaged food to be inspected, adjusting the shooting parameters of the image capture device according to the intensity of the ambient light, capturing the packaged food image, and correcting the captured image according to the color temperature of the ambient light to obtain a corrected packaged food image;

[0008] S2: Based on the corrected packaged food image, by analyzing the pixel differences in the image, identifying and marking the foreign matter in the packaged food, evaluating the matching degree between the foreign matter features and the foreign matter in the preset foreign matter library, identifying the foreign matter category, and obtaining the image foreign matter detection result;

[0009] S3: Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and foreign matter in the packaged food is identified by analyzing the X-ray image to obtain an X-ray foreign matter detection result;

[0010] S4: Based on the image foreign body detection results and the X-ray foreign body detection results, the X-ray image is overlapped with the normal image by adjusting the X-ray image scaling and angle, and the repeatedly marked foreign bodies are identified. According to the frequency of occurrence of foreign bodies and the number of foreign bodies per unit time, the abnormality level is evaluated to determine whether the production process of packaged food is normal, and the production process abnormality evaluation result is obtained.

[0011] The present invention is improved in that the method for adjusting the shooting parameters of the image capture device is:

[0012] S111: Based on the packaged food to be tested, collect ambient light intensity data through a light sensor, compare it with the reference light intensity, and calculate the light intensity ratio;

[0013] S112: Based on the light intensity ratio, combined with the standard exposure time and the standard sensitivity, the formula is:

[0014]

[0015] and

[0016]

[0017] Calculate the adjusted exposure time and adjusted sensitivity ,in, is the standard exposure time, and is the adjustment factor, is the base of natural logarithms, is the standard sensitivity. is the adjusted exposure time, is the adjusted sensitivity;

[0018] S113: Based on the adjusted exposure time and adjusted sensitivity , adjust the image capture device and obtain the image capture device adjustment result.

[0019] The present invention is improved in that the steps of acquiring the corrected packaged food image are as follows:

[0020] S121: Based on the adjustment result of the image capture device, take pictures of the packaged food, and record the color temperature information of the ambient light during the shooting process to obtain basic image data;

[0021] S122: Calculate the deviation between the color temperature of the standard light source and the color temperature of the ambient light source based on the basic image data to obtain a color temperature offset;

[0022] S123: Based on the color temperature offset, the formula:

[0023]

[0024] Calculate the corrected image color temperature , the captured image is corrected to obtain a corrected packaged food image, where is the adjustment coefficient, is the corrected image color temperature, is the color temperature offset, The color temperature of the base image.

[0025] The present invention is improved in that the method for identifying and marking foreign matter in packaged food is:

[0026] S211: Based on the corrected packaged food image, extract the color and brightness data of each pixel, and obtain the average color and average brightness of the image to obtain color and brightness data;

[0027] S212: Based on the color and brightness data, the formula:

[0028]

[0029] Calculating difference measures ,in, is the difference between the color of the target pixel and the average color of the image, is the difference between the target pixel brightness and the average brightness of the image, and is the weight coefficient, is the adjustment parameter of brightness difference, and is the sensitivity adjustment parameter, is the difference measure;

[0030] S213: Based on the difference measurement value , and compared with the preset difference threshold, the pixels exceeding the preset difference threshold are marked as abnormal to obtain the foreign body marking result.

[0031] The present invention is improved in that the steps of obtaining the image foreign body detection result are:

[0032] S221: Based on the foreign body marking result, extract the color and brightness data of the marked foreign body to obtain foreign body feature data;

[0033] S222: Based on the foreign body feature data, compare with the preset foreign body library, through the formula:

[0034]

[0035] Calculate the matching degree ,in, and is the weight coefficient, and are the color and brightness data of the foreign matter, and The standard color and brightness data of foreign objects in the preset foreign object library. and are the maximum difference ranges of color and brightness, is the matching degree;

[0036] S223: Based on the matching degree , by comparing the matching The size of the value, select the matching degree The foreign body type with the largest value is taken as the matching foreign body type to obtain the image foreign body detection result.

[0037] The present invention is improved in that the steps of obtaining the X-ray foreign body detection result are:

[0038] S311: Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and darkness values ​​of pixels of the image are obtained;

[0039] S312: Based on the darkness value of the image pixel, by formula:

[0040]

[0041] Calculate the probability of foreign matter for each pixel ,in, represents the maximum dark value in the X-ray image, is the darkness value of the pixel, is the foreign body feature threshold, is the probability of foreign matter;

[0042] S313: Based on the foreign matter probability , compared with the preset recognition threshold, and the probability of foreign matter Pixels exceeding the recognition threshold are marked as foreign matter, and the X-ray foreign matter detection result is obtained.

[0043] The present invention is improved in that the method for identifying repeatedly marked foreign matter is:

[0044] S411: Based on the image foreign body detection result and the X-ray foreign body detection result, length data between preset corner points in the X-ray image and the normal image are obtained, and angle data of a line connecting the preset corner points is obtained to obtain adjustment association data;

[0045] S412: Based on the adjustment associated data, by formula:

[0046]

[0047] and

[0048]

[0049] Calculate the scaling factor and angle adjustment value ,in, and are the angles formed by the lines connecting the preset corner points of the packaged food in the image, is the scaling factor, is the angle adjustment value, and are the lengths of the lines connecting the preset corner points in the X-ray image and the normal image respectively.

[0050] S413: Based on the scaling ratio and angle adjustment value , scale and adjust the angle of the X-ray image, overlap the X-ray image with the normal image, identify the foreign body marks that appear repeatedly in the two, and obtain the repeated foreign body recognition results.

[0051] The present invention is improved in that the steps of obtaining the abnormal evaluation results of the production process are:

[0052] S421: Based on the repeated mark foreign body identification result, the image foreign body detection result and the X-ray foreign body detection result, the number of products with foreign bodies in the packaged food per unit time is recorded and the total number of foreign bodies , get the foreign matter quantity related data;

[0053] S422: Calculating the frequency of occurrence of foreign matter based on the foreign matter quantity association data;

[0054] S423: Based on the frequency of occurrence of the foreign matter, the formula:

[0055]

[0056] Calculate the abnormal level of the production process ,in, is the total number of foreign objects detected per unit time, is the unit detection time, is the frequency of foreign matter occurrence, is the sensitivity adjustment factor, is the abnormal level of the production process, is the base of natural logarithms;

[0057] S424: Based on the abnormal level of the production process , compared with the preset production abnormality threshold, if If the value exceeds the production abnormality threshold, it is marked that there is an abnormality in the production process of the packaged food, and the production process abnormality assessment result is obtained.

[0058] Compared with the prior art, the advantages and positive effects of the present invention are:

[0059] In the present invention, by correcting the color deviation of the image, the image analysis is made more accurate, especially under different lighting conditions, the characteristics of foreign matter such as color and brightness can be more effectively identified, and by comparing with the preset foreign matter library, the recognition rate of the foreign matter category is enhanced. Combined with X-ray imaging technology, a more comprehensive detection of foreign matter of different properties, such as plastic and metal, can be performed to ensure that no matter what the type of foreign matter is, it can be effectively identified. Through the integrated analysis of the image and X-ray results, the integrity of the detection process is enhanced, avoiding the risk of omissions that may be caused by a single technology, and by analyzing the frequency and quantity of foreign matter to evaluate the abnormalities of the production process, it is helpful for food manufacturers to control production quality more effectively. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 is a flow chart of the method of the present invention;

[0061] Figure 2 A flow chart for adjusting the shooting parameters of an image capture device for the present invention;

[0062] Figure 3 A flow chart for obtaining a corrected packaged food image for the present invention;

[0063] Figure 4 A flow chart for identifying and marking foreign matter present in packaged food for the present invention;

[0064] Figure 5 A flow chart of obtaining image foreign body detection results according to the present invention;

[0065] Figure 6 A flow chart of obtaining X-ray foreign body detection results in the present invention;

[0066] Figure 7 A flow chart for identifying repeatedly marked foreign objects for the present invention;

[0067] Figure 8 The present invention is a flow chart for obtaining abnormal evaluation results of the production process. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0069] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating positions or positional relationships, are based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0070] See also Figure 1 The present invention provides a technical solution: a method for detecting foreign matter in packaged food, comprising the following steps:

[0071] S1: Based on the packaged food to be inspected, according to the intensity of the ambient light, adjusting the shooting parameters of the image capture device, including exposure time and sensitivity, to capture the packaged food image, and correcting the captured image according to the color temperature of the ambient light to obtain a corrected packaged food image;

[0072] S2: Based on the corrected packaged food image, foreign objects in the packaged food are identified and marked by analyzing pixel differences in the image, and the matching degree between the foreign object features and the foreign objects in the preset foreign object library is evaluated according to the foreign object features, including the color and brightness of the foreign object, and the foreign object categories, including glass, plastic, hair and fiber, are identified to obtain the image foreign object detection results;

[0073] S3: Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and foreign matter in the packaged food, including plastic, glass and metal, is identified by analyzing the X-ray image to obtain an X-ray foreign matter detection result;

[0074] S4: Based on the image foreign body detection results and the X-ray foreign body detection results, by adjusting the X-ray image scaling and angle, overlapping the X-ray image with the normal image, identifying the repeatedly marked foreign bodies, and evaluating the abnormality level according to the frequency of foreign body occurrence and the number of foreign bodies per unit time, it is determined whether the packaged food production process is normal, and the production process abnormality evaluation results are obtained.

[0075] The corrected packaged food image is specifically an image that has been color balanced and brightness optimized. The image foreign body detection results include the location, type and size of the foreign body. The X-ray foreign body detection results include the shape of the foreign body and the location on the X-ray image. The production process abnormality assessment results include the repeated detection rate of foreign bodies, the distribution of foreign body types and the abnormal status of the production line.

[0076] See also Figure 2 , the method to adjust the shooting parameters of the image capture device is:

[0077] S111: Based on the packaged food to be tested, the light sensor collects the ambient light intensity data and compares it with the reference light intensity, using the formula:

[0078]

[0079] Calculate light intensity ratio ,in, is the ambient light intensity, is the reference light intensity, is the light intensity ratio;

[0080] S112: Based on light intensity ratio , combined with the standard exposure time and standard sensitivity, through the formula:

[0081]

[0082] and

[0083]

[0084] Calculate the adjusted exposure time and adjusted sensitivity ,in, is the standard exposure time, and is the adjustment factor, is the base of natural logarithms, is the standard sensitivity. is the adjusted exposure time, is the adjusted sensitivity;

[0085] S113: Based on the adjusted exposure time and adjusted sensitivity , adjust the image capture device and obtain the image capture device adjustment result.

[0086] formula:

[0087]

[0088] and

[0089]

[0090] and

[0091]

[0092] Parameter meaning and acquisition method:

[0093] : Ambient light intensity, measured directly by the image capture device's sensor.

[0094] :The reference light intensity is a preset value, usually set to the light intensity under a standard test environment, for example, 500 lux.

[0095] : Light intensity ratio, measured by ambient light intensity With reference light intensity The ratio is worth getting.

[0096] : Standard exposure time, which is the default exposure time of the device under standard light intensity. For example, it is set to 1 / 60 second.

[0097] : The exposure adjustment factor is an empirical value, which is set according to the performance of the device and the sensitivity of light changes. For example, it is set to 0.05.

[0098] : Standard sensitivity, which is the default sensitivity of the device under standard lighting conditions, for example, set to ISO100.

[0099] : The sensitivity adjustment coefficient is determined based on the device's responsiveness to changes in light. For example, it is set to 0.1.

[0100] Calculation example:

[0101] Set the actual measured ambient light intensity It is 250lux.

[0102] Calculate the light intensity ratio:

[0103]

[0104] calculate :

[0105]

[0106]

[0107]

[0108]

[0109]

[0110]

[0111] Calculation results show that when the ambient light intensity is 250 lux, the adjusted exposure time is approximately 0.01625 seconds, ensuring that the image capture device can work effectively under this lighting condition.

[0112] calculate :

[0113]

[0114]

[0115]

[0116]

[0117] The calculation results show that under a given ambient light intensity, the adjusted sensitivity is ISO105, ensuring that the device can adapt to and maintain image quality under such lighting conditions.

[0118] See also Figure 3 , the steps to obtain the corrected packaged food image are:

[0119] S121: based on the adjustment result of the image capture device, take pictures of the packaged food, and record the color temperature information of the ambient light during the shooting process to obtain basic image data;

[0120] S122: Based on the basic image data, according to the formula:

[0121]

[0122] Calculate the deviation between the color temperature of the standard light source and the color temperature of the ambient light source to obtain the color temperature offset ,in, It is the preset standard white light color temperature. is the color temperature of the ambient light source, is the color temperature offset;

[0123] S123: Based on color temperature offset , through the formula:

[0124]

[0125] Calculate the corrected image color temperature , the captured image is corrected to obtain a corrected packaged food image, where is the adjustment coefficient, is the corrected image color temperature, is the color temperature offset, The color temperature of the base image.

[0126] formula:

[0127]

[0128] and

[0129] Parameter meaning and acquisition process:

[0130] : The color temperature of the underlying image, measured directly by the image capture device. The parameter reflects the raw image data captured under a specific ambient light.

[0131] : The actual color temperature of the ambient light source, measured by an ambient light color temperature meter or a sensor built into an image capture device.

[0132] : Standard white light color temperature, preset value, generally set to 6500K, used as a reference standard for daylight color temperature and as a comparison benchmark for image color correction.

[0133] : Adjustment coefficient, the adjustment parameter of color temperature correction, is an empirical value used to balance the influence of color temperature correction.

[0134] Calculation Example

[0135] Assume the following parameters:

[0136] Standard white light color temperature :6500K.

[0137] Ambient light color temperature :5500K.

[0138] Color temperature of the original image :6500K.

[0139] Adjustment parameters :5000.

[0140] Calculation steps:

[0141] Calculate color temperature difference :

[0142]

[0143] It means that the color temperature difference between the standard light source and the ambient light source is 1000K.

[0144]

[0145]

[0146]

[0147] Calculate the corrected color temperature :

[0148]

[0149]

[0150]

[0151]

[0152] According to calculations, the color temperature of the corrected image is 7583.35K. The correction results show that the color temperature of the original image is adjusted to be closer to the natural color under daylight conditions, compensating for the cold color deviation caused by the lower color temperature of the ambient light source.

[0153] See also Figure 4 , the method to identify and mark foreign matter in packaged food is:

[0154] S211: based on the corrected packaged food image, extract the color and brightness data of each pixel, and obtain the average color and average brightness of the image to obtain the color and brightness data;

[0155] S212: Based on color and brightness data, through the formula:

[0156]

[0157] Calculating difference measures ,in, is the difference between the color of the target pixel and the average color of the image, is the difference between the target pixel brightness and the average brightness of the image, and is the weight coefficient, is the adjustment parameter of brightness difference, and is the sensitivity adjustment parameter, is the difference measure;

[0158] S213: Based on difference measurement , and compared with the preset difference threshold, the pixels exceeding the preset difference threshold are marked as abnormal to obtain the foreign body marking result.

[0159] formula:

[0160]

[0161] Parameter meaning and acquisition method:

[0162] and : The parameters are used to calculate the difference between the color and brightness of a certain pixel and the average color and brightness of the entire image. The calculation formula is: and ,in, It is the color data of the pixel point, usually directly obtained through the image capture device. It can be the color value of a preset single color channel. For example, for red food, you can choose the color value of the red channel for calculation, or you can choose the grayscale value of the pixel for calculation. Represents the brightness data of a pixel, directly obtained through an image capture device. and They are the average color and average brightness of the image, respectively, and are calculated by averaging the color and brightness values ​​of all pixels.

[0163] and : Weight coefficients of color and brightness, used to adjust the influence of color difference and brightness difference in the foreign body detection formula. The value is set based on image processing experience, for example, and .

[0164] , and : Parameters are used to adjust the sensitivity and balance in the difference measurement formula and are preset by experts, for example, , adjust the weight of brightness difference, and , helps smooth out smaller differences and avoid false detections due to minor changes.

[0165] Calculation example:

[0166] Set the color value of the pixel: (using red value), brightness value , the average color of the image and average brightness .

[0167] Calculation steps:

[0168] Compute color and brightness differences:

[0169]

[0170]

[0171] Calculating difference measures :

[0172]

[0173]

[0174]

[0175]

[0176] The calculated difference , if the preset threshold is 3 , the difference value does not exceed the threshold, so the pixel is not identified as a foreign object.

[0177] See also Figure 5 , the steps to obtain the image foreign body detection results are:

[0178] S221: based on the foreign body marking result, extracting the color and brightness data of the marked foreign body to obtain foreign body feature data;

[0179] S222: Based on the foreign body feature data, compare with the preset foreign body library, through the formula:

[0180]

[0181] Calculate the matching degree ,in, and is the weight coefficient, and are the color and brightness data of the foreign matter, and The standard color and brightness data of foreign objects in the preset foreign object library. and are the maximum difference ranges of color and brightness, is the matching degree;

[0182] S223: Based on matching degree , by comparing the matching The size of the value, select the matching degree The foreign body type with the largest value is taken as the matching foreign body type to obtain the image foreign body detection result.

[0183] formula:

[0184]

[0185] Parameter meaning and acquisition method:

[0186] and : is the color and brightness data of the foreign object detected in the image. Usually, the data is directly extracted from the identified foreign object area through image processing software.

[0187] and :It is the standard color and brightness data of various foreign objects (such as glass, plastic, hair and fiber) preset in the foreign object library. The data is collected based on previous experiments and literature data to provide a benchmark for comparison and identification of unknown samples.

[0188] and : The parameter defines the maximum possible difference range of color and brightness in foreign object recognition. The range is usually set based on historical data. For example, if the color values ​​in the foreign object library are between 0 and 255, Can be set to 255.

[0189] and : is the weight coefficient of color and brightness in foreign object recognition. The weight coefficient is adjusted according to different actual application environments to ensure that the relative importance of color and brightness in foreign object recognition is appropriately reflected. In actual applications, the value can be adjusted by an optimization algorithm (such as a regression algorithm) to achieve the best recognition effect.

[0190] Calculation example:

[0191] Set the color value of the detected foreign object pixel and brightness value . Color values ​​in the foreign object library and brightness value . Setting range , , and the weight coefficient and .

[0192] Calculation steps:

[0193] Calculate the color and brightness difference ratio:

[0194]

[0195]

[0196]

[0197]

[0198]

[0199]

[0200] Calculate the matching degree :

[0201]

[0202]

[0203]

[0204] The calculated matching degree 6, showing that the foreign object has similar characteristics to those in the preset library, and the high matching degree indicates that the foreign object is likely to be of the corresponding material category.

[0205] See also Figure 6 , the steps to obtain the X-ray foreign body detection results are:

[0206] S311: Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and darkness values ​​of pixels of the image are obtained;

[0207] S312: Based on the darkness value of the image pixel, by the formula:

[0208]

[0209] Calculate the probability of foreign matter for each pixel ,in, represents the maximum dark value in the X-ray image, is the darkness value of the pixel, is the foreign body feature threshold, is the probability of foreign matter;

[0210] S313: Based on foreign matter probability , compared with the preset recognition threshold, and the probability of foreign matter Pixels exceeding the recognition threshold are marked as foreign matter, and the X-ray foreign matter detection result is obtained.

[0211] formula:

[0212]

[0213] Parameter meaning and acquisition method:

[0214] : It is the darkness value of the pixel obtained from the X-ray image. The darkness is usually related to the density or composition of the material and is calculated by subtracting the gray value of the pixel from 255. The larger the value, the darker the pixel color and the greater its density.

[0215] : Foreign body characteristic threshold, which is a preset value based on the X-ray absorption characteristics of different substances. For example, different materials such as plastic, glass and metal will have different X-ray absorption rates, and the threshold is derived from previous experimental data.

[0216] : The maximum darkness value in the X-ray image, used for normalization to maintain consistency in the foreign body probability calculation. This value is determined by analyzing the darkness values ​​of all pixels in the entire X-ray image.

[0217] Calculation example:

[0218] Suppose that in an X-ray image, the target pixel The value is 150. Foreign body feature threshold The maximum dark value in the entire image is 100 (the threshold is based on the absorbance of pre-tested plastics). is 255. Calculation steps:

[0219] Calculate the difference between a pixel and a threshold:

[0220]

[0221] Calculating the probability of foreign matter :

[0222]

[0223]

[0224]

[0225]

[0226] Calculated foreign body probability The higher the value, the greater the difference between the pixel and the threshold, and the more likely it is a foreign object. If the recognition threshold is set to 2.0, the calculated If this threshold is exceeded, the pixel will be identified as a foreign object.

[0227] See also Figure 7 , the method to identify duplicate marked foreign objects is:

[0228] S411: Based on the image foreign body detection result and the X-ray foreign body detection result, length data between preset corner points in the X-ray image and the normal image are obtained, and angle data of the line connecting the preset corner points are obtained to obtain adjustment association data;

[0229] S412: Based on the adjustment of the associated data, by formula:

[0230]

[0231] and

[0232]

[0233] Calculate the scaling factor and angle adjustment value ,in, and are the angles formed by the lines connecting the preset corner points of the packaged food in the image, is the scaling factor, is the angle adjustment value, and are the lengths of the lines connecting the preset corner points in the X-ray image and the normal image respectively.

[0234] S413: Based on scaling and angle adjustment value , scale and adjust the angle of the X-ray image, overlap the X-ray image with the normal image, identify the foreign body marks that appear repeatedly in the two, and obtain the repeated foreign body recognition results.

[0235] formula:

[0236]

[0237] and

[0238]

[0239] Parameter meaning and acquisition method:

[0240] and : The parameter represents the length of the line connecting the preset corner points of the packaged food in the X-ray image and the normal image. The length is obtained by measuring the distance from a specific marked point to another point in each image through image processing software. This measurement usually requires the calibration of the corner points in the image preprocessing stage.

[0241] and : Angle is the angle formed by the line connecting the preset corner points of the packaged food in the image. The angle measurement relies on image analysis software to calculate the angle difference between the line segment formed by two specified points in the image and the horizontal line.

[0242] Calculation example:

[0243] Set the following parameters:

[0244] Preset edge point connection length of X-ray image Unit, the default corner point connection length of a normal image Unit, angle in X-ray image , the angle in the normal image .

[0245] Calculate the scaling factor :

[0246]

[0247] The scale shows that in order to match the size of the normal image, the X-ray image needs to be enlarged to 125% of its original size.

[0248] Calculate angle adjustment :

[0249]

[0250] The angle adjustment ensures that the direction of the connecting lines of the corner points of the X-ray image is consistent with that of the normal image after the size adjustment.

[0251] By applying scaling and angle adjustment , the X-ray image can be correctly resized and oriented to align with the normal image. This ensures that during the image overlay process, foreign body markings can be accurately overlapped, allowing for more accurate identification of duplicated foreign bodies.

[0252] See also Figure 8 , the steps to obtain the abnormal evaluation results of the production process are:

[0253] S421: Based on the repeated marking foreign body identification results, image foreign body detection results and X-ray foreign body detection results, record the number of products with foreign bodies in the packaged food per unit time and the total number of foreign bodies , get the foreign matter quantity related data;

[0254] S422: Based on the data related to the number of foreign objects, the formula:

[0255]

[0256] Calculate the frequency of foreign matter ,in, is the unit detection time, is the number of packaged products containing foreign matter detected per unit time, is the frequency of foreign matter appearance;

[0257] S423: Based on the frequency of foreign matter , through the formula:

[0258]

[0259] Calculate the abnormal level of the production process ,in, is the total number of foreign objects detected per unit time, is the unit detection time, is the frequency of foreign matter occurrence, is the sensitivity adjustment factor, is the abnormal level of the production process, is the base of natural logarithms;

[0260] S424: Abnormal level based on production process , compared with the preset production abnormality threshold, if If the value exceeds the production abnormality threshold, it is marked that there is an abnormality in the production process of the packaged food, and the production process abnormality assessment result is obtained.

[0261] formula:

[0262]

[0263] and

[0264]

[0265] Parameter details and how to obtain them:

[0266] : The number of packaged products detected to contain foreign matter per unit time, obtained by counting the total number of products marked as containing foreign matter within a set time window.

[0267] : The total number of foreign objects detected per unit time, obtained by accumulating the number of foreign objects detected in each packaged product.

[0268] :Unit detection time, preset according to needs.

[0269] : Sensitivity adjustment factor, used to adjust the effect of frequency on the abnormality level, preset by experts.

[0270] Calculation Example

[0271] Assume that in one hour of production, 10 packaged products are detected to contain foreign matter, and a total of 15 foreign matter are detected. Unit detection time of the production process The sensitivity coefficient is set to 1 hour. is 0.05.

[0272] Calculate the frequency of foreign matter :

[0273]

[0274] Calculating the anomaly level :

[0275]

[0276]

[0277]

[0278]

[0279]

[0280] The abnormal level obtained ,If the set abnormal threshold is 0.7, the current production process will be judged as abnormal, indicating that the frequency and quantity of foreign matter in the production process exceed the normal range, and further investigation or intervention measures are needed to determine the root cause of the problem and take corresponding corrective measures.

[0281] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A method for detecting foreign matter in packaged food, characterized in that: The following steps are involved: Based on the packaged food to be inspected, adjusting the shooting parameters of the image capture device according to the intensity of the ambient light, capturing the packaged food image, and correcting the captured image according to the color temperature of the ambient light to obtain a corrected packaged food image; Based on the corrected packaged food image, by analyzing the pixel differences in the image, identifying and marking the foreign matter present in the packaged food, evaluating the matching degree between the foreign matter features and the foreign matter in the preset foreign matter library, identifying the foreign matter category, and obtaining the image foreign matter detection result; Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and foreign matter in the packaged food is identified by analyzing the X-ray image to obtain an X-ray foreign matter detection result; Based on the image foreign body detection results and the X-ray foreign body detection results, the X-ray image is overlapped with the normal image by adjusting the X-ray image scaling and angle, repeatedly marked foreign bodies are identified, and the abnormality level is evaluated according to the frequency of occurrence of foreign bodies and the number of foreign bodies per unit time, so as to determine whether the packaged food production process is normal and obtain the production process abnormality evaluation result.

2. The method for detecting foreign matter in packaged food according to claim 1, characterized in that: The method for adjusting the shooting parameters of the image capture device is: Based on the packaged food to be tested, the light sensor collects the ambient light intensity data, compares it with the reference light intensity, and calculates the light intensity ratio; Based on the light intensity ratio, combined with the standard exposure time and standard sensitivity, the formula is: ; and ; Calculate the adjusted exposure time and adjusted sensitivity ,in, is the standard exposure time, and is the adjustment factor, is the base of natural logarithms, is the standard sensitivity. is the adjusted exposure time, is the adjusted sensitivity; Based on the adjusted exposure duration and adjusted sensitivity , adjust the image capture device and obtain the image capture device adjustment result.

3. The method for detecting foreign matter in packaged food according to claim 2, characterized in that: The steps of acquiring the corrected packaged food image are as follows: Based on the adjustment result of the image capture device, the packaged food image is captured, and the color temperature information of the ambient light during the shooting process is recorded to obtain basic image data; Based on the basic image data, calculating the deviation between the color temperature of the standard light source and the color temperature of the ambient light source to obtain a color temperature offset; Based on the color temperature offset, by the formula: ; Calculate the corrected image color temperature , the captured image is corrected to obtain a corrected packaged food image, where is the adjustment coefficient, is the corrected image color temperature, is the color temperature offset, The color temperature of the base image.

4. The method for detecting foreign matter in packaged food according to claim 1, characterized in that: The method for identifying and marking foreign matter in packaged food is as follows: Based on the corrected packaged food image, extract the color and brightness data of each pixel, and obtain the average color and average brightness of the image to obtain color and brightness data; Based on the color and brightness data, through the formula: ; Calculating difference measures ,in, is the difference between the color of the target pixel and the average color of the image, is the difference between the target pixel brightness and the average brightness of the image, and is the weight coefficient, is the adjustment parameter of brightness difference, and is the sensitivity adjustment parameter, is the difference measure; Based on the difference metric , and compared with the preset difference threshold, the pixels exceeding the preset difference threshold are marked as abnormal to obtain the foreign body marking result.

5. The method for detecting foreign matter in packaged food according to claim 4, characterized in that: The steps for obtaining the image foreign body detection result are: Based on the foreign body marking result, extracting the color and brightness data of the marked foreign body to obtain foreign body feature data; Based on the foreign body feature data, compared with the preset foreign body library, the formula is: ; Calculate the matching degree ,in, and is the weight coefficient, and are the color and brightness data of the foreign matter, and The standard color and brightness data of foreign objects in the preset foreign object library. and are the maximum difference ranges of color and brightness, is the matching degree; Based on the matching , by comparing the matching The size of the value, select the matching degree The foreign body type with the largest value is taken as the matching foreign body type to obtain the image foreign body detection result.

6. The method for detecting foreign matter in packaged food according to claim 1, characterized in that: The steps for obtaining the X-ray foreign body detection result are: Based on the packaged food to be inspected, an X-ray image of the packaged food is captured by an X-ray detector, and a darkness value of the image pixel is obtained; Based on the darkness value of the image pixel, by the formula: ; Calculate the probability of foreign matter for each pixel ,in, represents the maximum dark value in the X-ray image, is the darkness value of the pixel, is the foreign body feature threshold, is the probability of foreign matter; Based on the foreign matter probability , compared with the preset recognition threshold, and the probability of foreign matter Pixels exceeding the recognition threshold are marked as foreign matter, and the X-ray foreign matter detection result is obtained.

7. The method for detecting foreign matter in packaged food according to claim 1, characterized in that: The method for identifying repeatedly marked foreign bodies is: Based on the image foreign body detection result and the X-ray foreign body detection result, length data between preset corner points in the X-ray image and the normal image are obtained, and angle data of the line connecting the preset corner points are obtained to obtain adjustment association data; Based on the adjusted associated data, by the formula: ; and ; Calculate the scaling factor and angle adjustment value ,in, and are the angles formed by the lines connecting the preset corner points of the packaged food in the image, is the scaling factor, is the angle adjustment value, and are the lengths of the lines connecting the preset corner points in the X-ray image and the normal image respectively; Based on the scaling and angle adjustment value , scale and adjust the angle of the X-ray image, overlap the X-ray image with the normal image, identify the foreign body marks that appear repeatedly in the two, and obtain the repeated foreign body recognition results.

8. The method for detecting foreign matter in packaged food according to claim 7, characterized in that: The steps for obtaining the abnormal evaluation results of the production process are as follows: Based on the repeated marking foreign body recognition results, image foreign body detection results and X-ray foreign body detection results, the number of products with foreign bodies in the packaged food per unit time is recorded. and the total number of foreign bodies , get the foreign matter quantity related data; Calculating the frequency of occurrence of foreign matter based on the foreign matter quantity association data; Based on the frequency of occurrence of the foreign matter, the formula: ; Calculate the abnormal level of the production process ,in, is the total number of foreign objects detected per unit time, is the unit detection time, is the frequency of foreign matter occurrence, is the sensitivity adjustment factor, is the abnormal level of the production process, is the base of natural logarithms; Based on the level of abnormality of the production process , compared with the preset production abnormality threshold, if If the value exceeds the production abnormality threshold, it is marked that there is an abnormality in the production process of the packaged food, and the production process abnormality assessment result is obtained.

Citation Information

Patent Citations

  • Ray detection method and device for noodle food

    CN101936928A

  • Irregularly shaped meat foreign matter detection system

    CN102331430A

Cited By

  • Packaging production date identification method and system based on AI dynamic illumination adjustment

    CN120656155A