Food detection method and system based on image recognition
By combining the surface and internal image information of food, the pre -trained food recognition model and origin recognition model are used to extract features to achieve more targeted origin recognition. The accuracy and reliability of quality detection.
Patent Information
- Application Number
- CN202411420472.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing food quality detection technology relies on a single image information and cannot fully capture food characteristics, resulting in low recognition accuracy, especially when the appearance of foods from different origins is similar.
Adopting food testing methods based on image recognition, through the collection of food surface and internal image information of food, combined with pre -trained food recognition models and origin recognition models to extract the surface and internal characteristics to achieve more targeted origin recognition.
It improves the accuracy and reliability of food recognition, can more refined the quality of food, and enhance the transparency and safety of the food supply chain.
Smart Images

Figure CN119380333A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a food detection method and system based on image recognition. Background Art
[0002] With the rapid development of the global food industry, food quality and safety issues have attracted more and more attention from consumers and regulatory agencies. In the food supply chain, the origin, quality, ingredients and safety standards of food have become important factors in measuring food quality. However, due to the globalization of food circulation, food origin information and related quality inspections have become complex and challenging.
[0003] The existing technology has the following problems in food quality testing:
[0004] A single information source leads to insufficient recognition accuracy: Traditional food origin recognition technology usually relies on single image information (such as appearance images). This method cannot capture the comprehensive characteristics of food, resulting in low recognition accuracy, especially when foods from different origins have similar appearances, making it difficult to distinguish them effectively.
[0005] Secondly, the existing technology uses a unified recognition model for different food types, ignoring the differences between food types. The use of a unified model may not fully reflect the characteristics of each food type, resulting in inaccurate recognition results; it does not extract targeted features based on food categories, resulting in poor performance of the model when processing complex and diverse food data; especially in high-demand food quality assessment scenarios, existing methods are difficult to provide refined quality judgments.
[0006] Therefore, it is an urgent problem for those skilled in the art to propose a food detection method and system based on image recognition to solve the difficulties existing in the prior art. Summary of the invention
[0007] The purpose of the present invention is to provide a food detection method and system based on image recognition to solve the shortcomings of the background technology.
[0008] In order to achieve the above object, the present invention provides the following technical solution: a food detection method based on image recognition, comprising:
[0009] Collecting image information of the food to be identified, the image information includes first image information and second image information; the first image information is surface image information of the food to be identified, and the second image information is internal image information of the food to be identified;
[0010] Inputting the first image information into a pre-trained food recognition model to obtain a food recognition result;
[0011] Extracting quality features corresponding to the first image information and the second image information according to the recognition result; the corresponding quality features include surface features and intrinsic features;
[0012] According to the recognition result, a corresponding origin recognition model is selected, the surface features and intrinsic features are input into the origin recognition model corresponding to the recognition result, the origin recognition result is obtained, and the origin recognition result is written into the food inspection report.
[0013] Furthermore, the training method of the food recognition model includes:
[0014] All the first image information collected in advance is used as the input of the food recognition model. The food recognition model takes the predicted recognition result of each group of first image information as the output, takes the actual recognition result corresponding to each group of first image information as the prediction target, and takes minimizing the sum of the first prediction accuracies of all predicted recognition results as the training target; the training is stopped when the sum of the first prediction accuracies reaches convergence; the food recognition model is a convolutional neural network model.
[0015] Furthermore, when the identification result is melons and fruits, the surface features include texture features, color features and size features; the intrinsic features include sugar content peak value, water content peak value, mineral content peak value, organic acid content peak value, cellulose content peak value and antioxidant content peak value. The climate, whether there is sufficient sunlight, whether it is moist, and the soil will affect the changes in intrinsic characteristics.
[0016] Furthermore, when the identification result is meat, the surface features include texture features, color features and part names; the intrinsic features include unsaturated fatty acid content peak, saturated fatty acid content peak, myoglobin content peak, myosin content peak, water content peak, mineral content peak and collagen content peak.
[0017] Furthermore, the method for acquiring the size feature includes:
[0018]
[0019] Where DX is the surface area, i.e., the size feature, D is the number of pixels in the recognition result area in the first image information, L is the real length of the scale, and L′ is the pixel length of the scale;
[0020] The method for acquiring the color feature includes:
[0021] Extracting red, green and blue components of each pixel in the recognition result area in the first image information;
[0022] Calculate the color average of the RGB colors in all pixels. The color average reflects the main color of the entire fruit surface, and the main color is the color feature.
[0023] Furthermore, the method for acquiring the texture feature includes:
[0024] Step 101, selecting any target pixel in the recognition result area, wherein the target pixel is a main color and has 8 adjacent pixels of the main color;
[0025] Step 102: Using the eight adjacent pixel points in step 101, diffuse them to the surrounding areas, and mark the target pixel point that does not have eight adjacent pixel points as a measurement point;
[0026] Step 103, repeating steps 101-102 until the number of measurement points no longer increases, marking the area enclosed by all the measurement points as the measurement area;
[0027] Step 104, divide the measurement area into Y sub-measurement sections in the length direction, where Y is an integer greater than 1, connect the midpoints of the two wide sides in the y-th sub-measurement section, y∈Y, the initial value of y is 1, select N points on the connection line, take the n-th point as the starting point, n∈N, the initial value of n is 1, draw a straight line perpendicular to the n-th point, extend the two ends of the straight line to the two long sides in the sub-measurement section and stop extending, calculate the length of the straight line on both sides of the n-th point, and record it; when n is greater than N, set y=y+1, and execute step 105;
[0028] Step 105, repeat step 104, and when y is greater than Y, stop the loop;
[0029] Step 106: Calculate the mean and standard deviation of the lengths of all the straight lines on both sides, that is, the texture feature.
[0030] Furthermore, the method for acquiring the texture feature includes:
[0031] Step 201, marking the number of fat regions in the recognition result region as T;
[0032] Step 202: select any target pixel in the t-th fat region, t∈T, the initial value of t is 1, any target pixel has 8 adjacent pixels, and all of the 8 adjacent pixels are pixels represented by fat;
[0033] Step 203, using the eight adjacent pixel points in step 202 to diffuse to the surroundings, marking the target pixel point without eight adjacent pixel points as a measurement point;
[0034] Step 204, repeat step 202 until the number of measurement points no longer increases, mark the area enclosed by all the measurement points as the measurement area, and set t=t+1;
[0035] Step 205, repeat steps 202-204, and when t is greater than T, stop the loop;
[0036] Step 206: Calculate the average value of pixels, the average value and standard deviation of the number of pixel blocks in all measurement areas, that is, texture features.
[0037] Furthermore, the training method of the origin recognition model includes:
[0038] All pre-collected surface features and intrinsic features are used as inputs of a food recognition model, the food recognition model takes the predicted origin recognition results for each group of surface features and intrinsic features as outputs, takes the actual origin recognition results corresponding to each group of surface features and intrinsic features as prediction targets, and takes minimizing the sum of the second prediction accuracies of all predicted origin recognition results as a training target; training is stopped when the sum of the second prediction accuracies converges; the food recognition model is a decision tree model or a support vector machine model.
[0039] Further, including;
[0040] The first image information also includes shooting distance and shooting brightness; the shooting brightness is the ambient brightness detected when the shooting device shoots the first image information;
[0041] The standard environment brightness and the standard shooting distance are preset, and the distance difference between the shooting distance and the standard shooting distance, and the brightness difference between the shooting brightness and the standard environment brightness are calculated respectively.
[0042] Furthermore, the shooting distance acquisition method includes:
[0043] When obtaining the first image information, the photographing device sends a short pulse of light to the food to be identified, and the photographing device records the light pulse emission time k1, and records the light signal reflection and reception time k2;
[0044] By formula JL is the shooting distance and c is the speed of light.
[0045] A food detection system based on image recognition, implementing the food detection method based on image recognition, comprising:
[0046] A data acquisition module is used to acquire image information of the food to be identified, the image information including first image information and second image information; the first image information is the surface image information of the food to be identified, the first image information also includes the shooting distance and the shooting brightness, and the second image information is the internal image information of the food to be identified;
[0047] A first recognition module, used to input the first image information into a pre-trained food recognition model to obtain a food recognition result;
[0048] A feature extraction module, used to extract quality features corresponding to the first image information and the second image information according to the recognition result; the corresponding quality features include surface features and intrinsic features;
[0049] The integrated recognition module is used to select a corresponding origin recognition model according to the recognition result, input the surface features and intrinsic features into the origin recognition model corresponding to the recognition result, obtain the origin recognition result, and write the origin recognition result into the food inspection report.
[0050] The present invention provides a food detection method and system based on image recognition with the following technical effects and advantages:
[0051] By combining two sets of image information, namely the first image information and the second image information, not only the surface features of the food are obtained, but also the intrinsic features are extracted through internal analysis. For different recognition results, specific quality features are extracted respectively, so that these features are more closely related to the characteristics and origin of the food itself. By introducing foods with different recognition results into an origin recognition model specifically corresponding to the recognition results, more targeted origin recognition is achieved, which effectively improves the accuracy and reliability of the model.
[0052] Traditional origin identification is often based on a single type of image information, resulting in insufficient recognition accuracy. By combining surface and intrinsic features, the multi-dimensional quality information of food under different conditions can be fully captured. In particular, the extraction of intrinsic features can reflect the deep chemical and physical properties of food. The quality feature extraction corresponding to different food identification results is more targeted, which not only improves the accuracy of origin identification, but also reflects the quality differences of food, allowing manufacturers to make adjustments and optimizations based on different market demands based on the detailed quality information in the report.
[0053] In food inspection reports, origin identification results can not only provide consumers with important information about the source of food, but also provide key data reflecting food quality to the production side. By comparing the quality characteristics of different origins, the production side can more accurately adjust planting or breeding strategies to optimize food quality; this makes the management of the food supply chain more transparent and efficient. Manufacturers can optimize production processes and improve product competitiveness based on detailed origin and quality assessment reports to meet the quality requirements of different markets.
[0054] Through accurate origin identification, consumers can clearly understand the source of food and have a higher degree of trust in the quality of food. The combination of origin information and quality characteristics greatly improves the transparency of the food supply chain and reduces the risk of unqualified food circulation in the market. In the context of frequent food safety issues, it helps to improve food safety standards and enhance consumer confidence in brands and products, thereby promoting the healthy development of the food industry.
[0055] This technology can be integrated into an automated food inspection system. Through efficient image processing and recognition models, it can reduce manual operations and improve inspection efficiency. Especially for large-scale food inspection scenarios, the present invention can provide fast and accurate origin and quality information, which is helpful for batch control of food quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0057] Figure 1 Schematic diagram of a food detection system based on image recognition in Example 1 of the present invention;
[0058] Figure 2 A flow chart of a texture feature acquisition method of the present invention;
[0059] Figure 3 is a flow chart of another texture feature acquisition method of the present invention;
[0060] Figure 4 Schematic diagram of a food detection system based on image recognition in Example 2 of the present invention;
[0061] Figure 5 This is a flow chart of a food detection method based on image recognition in Example 3 of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be an intermediate element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.
[0064] Example 1
[0065] like Figure 1As shown, this embodiment is a food detection system based on image recognition, including a data acquisition module, a first recognition module, a feature extraction module and an integrated recognition module, and the modules are connected by wire and / or wirelessly.
[0066] The data acquisition module is used to acquire image information of the food to be identified, the image information includes first image information and second image information; the first image information is the surface image information of the food to be identified, and the second image information is the internal image information of the food to be identified.
[0067] The first recognition module is used to input the first image information into the pre-trained food recognition model to obtain the recognition result of the food; the recognition result is such as fruits and meat, etc., fruits such as watermelon, Hami melon, etc., and meat such as beef, mutton, etc.
[0068] The training methods for the food recognition model include:
[0069] All pre-collected first image information is used as the input of the food recognition model. The food recognition model takes the predicted recognition result for each group of first image information as the output, takes the actual recognition result corresponding to each group of first image information as the prediction target, and takes minimizing the sum of the first prediction accuracies of all predicted recognition results as the training target.
[0070] Among them, the calculation formula for the first prediction accuracy is: Mc e =(Mq e -Md e ) 2 , where e is the number of each group of first image information, Mc e is the first prediction accuracy, Mq e is the predicted recognition result corresponding to the first image information of the e-th group, Md e is the actual recognition result corresponding to the first image information of the e-th group; the food recognition model is trained until the sum of the first prediction accuracies reaches convergence and the training is stopped; the food recognition model is a suitable model such as a convolutional neural network model (CNN) or a YOLO model.
[0071] Identifying the identification result of the food to be identified makes it convenient to determine the corresponding quality characteristics according to the specific identification result, that is, to extract what kind of characteristics from the first image information and the second image information for subsequent inspection of the food.
[0072] The feature extraction module is used to extract the corresponding quality features in the first image information and the second image information according to the recognition result; the corresponding quality features include surface features and intrinsic features.
[0073] Taking the recognition result of fruits as an example, specifically watermelon, the surface features include texture features, color features and size features; the intrinsic features include sugar content peak value, water content peak value, mineral content peak value, organic acid content peak value, cellulose content peak value and antioxidant content peak value. The climate, whether there is sufficient sunlight, whether it is moist, and the soil will affect the changes in the intrinsic features.
[0074] Methods for obtaining size features include:
[0075]
[0076] Where DX is the surface area, that is, the size feature, D is the number of pixels in the recognition result area in the first image information, L is the real length of the scale, and L′ is the pixel length of the scale. For example, the size of watermelon is usually closely related to the climate and soil conditions of the place of origin. In warm places with sufficient water resources, watermelon has excellent growth conditions and can grow larger. In areas with dry climate and little precipitation, watermelon may be smaller.
[0077] The color feature acquisition methods include:
[0078] Extracting the red (R), green (G), and blue (B) components of each pixel in the recognition result area in the first image information;
[0079] The color average of the RGB colors in all pixels is calculated. The color average reflects the main color of the entire watermelon surface. The main color is the color feature. This value is based on the average color distribution of all pixels. It is not a specific color on the watermelon surface, but the overall tendency of the color on the watermelon surface.
[0080] For example, the average RGB value is (120, 200, 150), which means that the surface of the watermelon is generally green (with a higher G value). The color of the watermelon peel usually ranges from dark green to light green, which has a lot to do with the climate, sunshine time and soil of the growing area. The climatic conditions of different production areas may affect the color depth of the peel, thereby affecting the RGB value.
[0081] For example, Xinjiang watermelons usually have darker green peels, which is related to the strong sunshine, large temperature difference between day and night, and rapid sugar accumulation in the region; the RGB value of the peel usually tends to lower green values (higher G value), which reflects the characteristics of the dark green peel; in Tottori Prefecture, Japan, the peel color of "black-skinned watermelons" is close to black-green, the red and blue components in the RGB values are lower, and the green component dominates; this dark peel is a unique feature formed under specific climatic conditions.
[0082] See also Figure 2 As shown, the method for obtaining texture features includes:
[0083] Step 101, select any target pixel point in the recognition result area, wherein any target pixel point is the main color, and any target pixel point has 8 adjacent pixels of the main color. Having 8 adjacent pixels of the main color indicates that any target pixel point is located in the middle position of the main color area and is not located at the edge position.
[0084] Step 102: diffuse the eight adjacent pixel points in step 101 to the surrounding areas, and mark the target pixel points that do not have eight adjacent pixel points as measurement points.
[0085] Step 103, repeat steps 101-102 until the number of measurement points no longer increases, and mark the area enclosed by all the measurement points as the measurement area.
[0086] Step 104, divide the measurement area into Y sub-measurement segments in the length direction, where Y is an integer greater than 1, connect the midpoints of the two wide sides in the y-th sub-measurement segment, y∈Y, where the initial value of y is 1, select N points on the line, take the n-th point as the starting point, n∈N, where the initial value of n is 1, draw a straight line perpendicular to the n-th point, extend the two ends of the straight line to the two long sides in the sub-measurement segment and stop extending, calculate the length of the straight line on both sides of the n-th point, and record it; when n is greater than N, set y=y+1 and execute step 105.
[0087] Step 105: Repeat step 104, and when y is greater than Y, stop the loop.
[0088] Step 106, calculate the mean and standard deviation of the lengths of all the straight lines on both sides, that is, the texture features. In this case, the mean reflects the width of the main color stripes of the watermelon, and the standard deviation reflects the clarity of the main color stripes. The larger the standard deviation, the more regular the main color stripes are, and the clearer they are, and vice versa. The intensity and duration of sunshine directly affect the appearance of the watermelon. In areas with strong sunshine, the western stripes are often clearer and more obvious. In areas with sufficient sunshine and a relatively stable climate, the stripes of the watermelon are more likely to show a regular shape and distribution. This is because the growth process of the watermelon is less affected by the external environment and the growth rate is more uniform.
[0089] Taking the identification result of meat as an example, specifically beef, the surface characteristics include texture characteristics, color characteristics and part names; the intrinsic characteristics include unsaturated fatty acid content peak, saturated fatty acid content peak, myoglobin content peak, myosin content peak, water content peak, mineral content peak, collagen content peak. Due to differences in climate, feed and breeding methods, different origins will show significant differences in these chemical components, which will be manifested in the Raman spectrum through different vibration peaks.
[0090] When the production end conducts batch testing on food, the part names are input into the system in advance; the color feature acquisition methods include:
[0091] Extracting the red (R), green (G), and blue (B) components of each pixel in the recognition result area in the first image information;
[0092] Calculate the color average of the RGB colors in all pixels. The color average reflects the main color of the entire watermelon surface, and the main color is the color feature.
[0093] The average value of RGB color reflects the overall color tone of beef, which is mainly affected by factors such as the myoglobin content, oxidation degree, and fat content in beef. Beef from different origins has different colors due to different feeding and environment; Red channel (R): represents the myoglobin content in beef. Grazing cattle usually have a lot of exercise, a higher myoglobin content, a darker meat color, and a higher R value. Relatively speaking, captive beef has a lighter meat color and a lower R value because it has less exercise; Green channel (G) and blue channel (B): The fat distribution and oxidation degree in beef affect these values. Beef with a high fat content may be brighter and whiter in color, and the values of the G and B channels are relatively high.
[0094] In mountainous areas with cold climates, beef may be lighter in color, with more evenly distributed fat, and the G and B components in the RGB average will be slightly higher. Grazing beef in plain areas has a darker color and a higher R component due to its high activity level.
[0095] See also Figure 3 As shown, the method for obtaining texture features includes:
[0096] Step 201: Mark the number of fat regions in the recognition result region as T.
[0097] Step 202: Select any target pixel in the t-th fat region, t∈T, the initial value of t is 1, and any target pixel has 8 adjacent pixels, and all of the 8 adjacent pixels are pixels represented by fat.
[0098] Step 203: diffuse the eight adjacent pixel points in step 202 to the surrounding areas, and mark the target pixel points that do not have eight adjacent pixel points as measurement points.
[0099] Step 204, repeat step 202 until the number of measurement points no longer increases, mark the area enclosed by all the measurement points as the measurement area, and set t=t+1.
[0100] Step 205: Repeat steps 202-204, and when t is greater than T, stop the loop.
[0101] Step 206: Calculate the average value of pixels, the average value and standard deviation of the number of pixel blocks in all measurement areas, that is, texture features.
[0102] The distribution, quantity and pixel average of fat areas on the beef surface are important characteristics of beef quality and origin. The distribution of fat areas in beef from different origins will vary significantly due to differences in feeding methods, environment and climate. By calculating the pixel average of the fat area, the average and standard deviation of the number of pixel blocks, the fat distribution pattern on the beef surface can be reflected, thus correlating it with its origin and sampling method.
[0103] Fat areas are usually lighter in color and are mainly concentrated in the marbling (i.e., white fat texture in meat), and these fat areas can be extracted through image processing techniques such as color threshold segmentation.
[0104] For example, for pastured beef (such as Australia and New Zealand), the average number of pixel blocks in the fat area is small. Due to the large amount of exercise, pastured cattle have less fat reserves and smaller fat blocks. The calculated average number of pixel blocks in the fat area is usually low, indicating that the beef has more lean meat and less fat; the standard deviation is large. Due to the uneven distribution of fat in pastured cattle, the standard deviation is usually large, and the size of fat blocks varies significantly; the pixel average is dark red: the lean meat accounts for a large proportion of pastured beef, so the overall color is dark red, and the R (red) component in RGB is high; the sample data is as follows:
[0105] The average number of pixel blocks in the fat area is 60 pixels; the standard deviation of the number of pixel blocks is 40 pixels; the average value of pixel RGB is R=150, G=50, B=40 (overall reddish).
[0106] For example, grain-fed beef (such as the United States and Canada) has a larger average fat area. Grain-fed beef has a higher fat content and a larger fat area, so the average is higher, indicating that the fat distribution in the beef is rich and there is less lean meat; the standard deviation is medium: the fat distribution of grain-fed beef is relatively uniform, the standard deviation is small, and the size of the fat pieces does not vary much; the RGB average is light red: due to the high fat content, the overall color of the beef is lighter, and the fat part is white or light, which makes the red component of the overall RGB decrease and the green and blue components increase; the sample data is as follows:
[0107] The average number of pixel blocks in the fat area is 150 pixels; the standard deviation of the number of pixel blocks is 30 pixels; the average value of pixel RGB is R=120, G=80, B=70 (lighter color).
[0108] The integrated recognition module is used to select the corresponding origin recognition model according to the recognition result, input the surface characteristics and intrinsic characteristics into the origin recognition model corresponding to the recognition result (the origin is told to the buyer in advance by the seller, the buyer knows it through food guarantee, or other channels), obtain the origin recognition result, write the origin recognition result into the food inspection report, and also can identify the breeding and planting methods of the food.
[0109] The training methods for the origin recognition model include:
[0110] All pre-collected surface features and intrinsic features are used as input to a food recognition model, which takes the predicted origin recognition results for each group of surface features and intrinsic features as output, the actual origin recognition results corresponding to each group of surface features and intrinsic features as prediction targets, and minimizing the sum of the second prediction accuracies of all predicted origin recognition results as a training target.
[0111] Among them, the calculation formula for the second prediction accuracy is: Mc i =(Mq i -Md i ) 2 , where i is the number of each set of surface features and intrinsic features, Mc i is the second prediction accuracy, Mq i is the predicted origin identification result corresponding to the i-th group of surface features and intrinsic features, Md i is the actual origin identification result corresponding to the i-th group of surface features and intrinsic features; the food identification model is trained until the sum of the second prediction accuracies reaches convergence and the training is stopped; the food identification model is a suitable model such as a decision tree model or a support vector machine model (SVM).
[0112] This embodiment combines two sets of image information, namely the first image information and the second image information, not only to obtain surface features from the appearance of the food, but also to extract intrinsic features through internal analysis, and extracts specific quality features for different recognition results, so that these features are more strongly correlated with the characteristics and origin of the food itself; by introducing foods with different recognition results into an origin recognition model specifically corresponding to the recognition results, more targeted origin recognition is achieved, which effectively improves the accuracy and reliability of the model.
[0113] Traditional origin identification is often based on a single type of image information, resulting in insufficient recognition accuracy. By combining surface and intrinsic features, the multi-dimensional quality information of food under different conditions can be fully captured. In particular, the extraction of intrinsic features can reflect the deep chemical and physical properties of food. The quality feature extraction corresponding to different food identification results is more targeted, which not only improves the accuracy of origin identification, but also reflects the quality differences of food, allowing manufacturers to make adjustments and optimizations based on different market demands based on the detailed quality information in the report.
[0114] In food inspection reports, origin identification results can not only provide consumers with important information about the source of food, but also provide key data reflecting food quality to the production side. By comparing the quality characteristics of different origins, the production side can more accurately adjust planting or breeding strategies to optimize food quality; this makes the management of the food supply chain more transparent and efficient. Manufacturers can optimize production processes and improve product competitiveness based on detailed origin and quality assessment reports to meet the quality requirements of different markets.
[0115] Through accurate origin identification, consumers can clearly understand the source of food and have a higher degree of trust in the quality of food. The combination of origin information and quality characteristics greatly improves the transparency of the food supply chain and reduces the risk of unqualified food circulation in the market. In the context of frequent food safety issues, it helps to improve food safety standards and enhance consumer confidence in brands and products, thereby promoting the healthy development of the food industry.
[0116] This technology can be integrated into an automated food inspection system. Through efficient image processing and recognition models, it can reduce manual operations and improve inspection efficiency. Especially for large-scale food inspection scenarios, the present invention can provide fast and accurate origin and quality information, which is helpful for batch control of food quality.
[0117] Example 2
[0118] See also Figure 4 As shown, the food detection system based on image recognition provided by this embodiment also includes a difference detection module.
[0119] The first image information also includes shooting distance and shooting brightness; the shooting brightness is the ambient brightness detected when the shooting device shoots the first image information.
[0120] The shooting distance acquisition method comprises:
[0121] When obtaining the first image information, the photographing device sends a short pulse of light to the food to be identified. The photographing device records the time k1 when the light pulse is emitted, and records the time k2 when the light signal reflection is received.
[0122] By formula JL is the shooting distance and c is the speed of light.
[0123] The difference detection module is used to preset the standard environment brightness and the standard shooting distance, and respectively calculate the distance difference between the shooting distance and the standard shooting distance, and the brightness difference between the shooting brightness and the standard environment brightness.
[0124] The quality features also include distance difference and brightness difference. Shooting at too close or too far distances will cause image distortion and affect the accuracy of feature extraction. Shooting at too close distances may cause excessive magnification of food surface details, while shooting at too far distances may cause loss of some subtle color and texture information. By taking the shooting distance as input, the model can automatically adjust its tolerance for these distortions to avoid the influence of differences caused by different distances in the image on the judgment results. If the ambient brightness during shooting is too high or too low, the color of the image may shift or be overexposed, making it difficult to identify key features. The model can dynamically adjust the interpretation of image color and texture by introducing brightness differences, reduce interference caused by environmental changes, and thus improve the recognition accuracy of the origin recognition model.
[0125] The food test report also includes the peak value of drug residues, which is obtained by Raman spectroscopy. Drug residue testing allows consumers to enjoy safer and healthier food and avoid potential health hazards caused by long-term intake of drug residues; through early detection and preventive measures at the production end, food safety accidents (such as drug residue poisoning and health problems caused by hormone residues) can be greatly reduced, improving the safety of the overall food supply chain.
[0126] Example 3
[0127] See also Figure 5 As shown, this embodiment provides a food detection method based on image recognition, including:
[0128] Collecting image information of the food to be identified, the image information includes first image information and second image information; the first image information is surface image information of the food to be identified, and the second image information is internal image information of the food to be identified;
[0129] Inputting the first image information into a pre-trained food recognition model to obtain a food recognition result;
[0130] Extracting quality features corresponding to the first image information and the second image information according to the recognition result; the corresponding quality features include surface features and intrinsic features;
[0131] According to the recognition result, a corresponding origin recognition model is selected, the surface features and intrinsic features are input into the origin recognition model corresponding to the recognition result, the origin recognition result is obtained, and the origin recognition result is written into the food inspection report.
[0132] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A food detection method based on image recognition, characterized in that: include: Collecting image information of the food to be identified, the image information includes first image information and second image information; the first image information is surface image information of the food to be identified, and the second image information is internal image information of the food to be identified; Inputting the first image information into a pre-trained food recognition model to obtain a food recognition result; Extracting, according to the recognition result, quality features in the first image information corresponding to the quality features in the second image information; The corresponding quality characteristics include surface characteristics and intrinsic characteristics; According to the recognition result, a corresponding origin recognition model is selected, the surface features and intrinsic features are input into the origin recognition model corresponding to the recognition result, the origin recognition result is obtained, and the origin recognition result is written into the food inspection report.
2. A food detection method based on image recognition according to claim 1, characterized in that: The training method of the food recognition model includes: All the first image information collected in advance is used as the input of the food recognition model. The food recognition model takes the predicted recognition result of each group of first image information as the output, takes the actual recognition result corresponding to each group of first image information as the prediction target, and takes minimizing the sum of the first prediction accuracies of all predicted recognition results as the training target; the training is stopped when the sum of the first prediction accuracies reaches convergence; the food recognition model is a convolutional neural network model.
3. A food detection method based on image recognition according to claim 1, characterized in that: When the identification result is melon or fruit, the surface features include texture features, color features and size features; the intrinsic features include sugar content peak value, water content peak value, mineral content peak value, organic acid content peak value, cellulose content peak value and antioxidant content peak value.
4. A food detection method based on image recognition according to claim 1, characterized in that: When the identification result is meat, the surface features include texture features, color features and part names; the intrinsic features include unsaturated fatty acid content peak, saturated fatty acid content peak, myoglobin content peak, myosin content peak, water content peak, mineral content peak and collagen content peak.
5. The food detection method based on image recognition according to claim 3, characterized in that: The method for obtaining the size feature includes: Where DX is the surface area, i.e., the size feature, D is the number of pixels in the recognition result area in the first image information, L is the real length of the scale, and L′ is the pixel length of the scale; The method for acquiring the color feature includes: Extracting red, green and blue components of each pixel in the recognition result area in the first image information; Calculate the color average of the RGB colors in all pixels. The color average reflects the main color of the entire fruit surface, and the main color is the color feature.
6. A food detection method based on image recognition according to claim 3, characterized in that: The method for acquiring the texture feature includes: Step 101, selecting any target pixel in the recognition result area, wherein the target pixel is a main color and has 8 adjacent pixels of the main color; Step 102: Using the eight adjacent pixel points in step 101, diffuse them to the surrounding areas, and mark the target pixel points that do not have eight adjacent pixel points as measurement points; Step 103, repeating steps 101-102 until the number of measurement points no longer increases, marking the area enclosed by all the measurement points as the measurement area; Step 104, divide the measurement area into Y sub-measurement sections in the length direction, where Y is an integer greater than 1, connect the midpoints of the two wide sides in the y-th sub-measurement section, y∈Y, the initial value of y is 1, select N points on the connection line, take the n-th point as the starting point, n∈N, the initial value of n is 1, draw a straight line perpendicular to the n-th point, extend the two ends of the straight line to the two long sides in the sub-measurement section and stop extending, calculate the length of the straight line on both sides of the n-th point, and record it; when n is greater than N, set y=y+1, and execute step 105; Step 105, repeat step 104, and when y is greater than Y, stop the loop; Step 106: Calculate the mean and standard deviation of the lengths of all the straight lines on both sides, that is, the texture feature.
7. A food detection method based on image recognition according to claim 4, characterized in that: The method for acquiring the texture feature includes: Step 201, marking the number of fat regions in the recognition result region as T; Step 202: select any target pixel in the t-th fat region, t∈T, the initial value of t is 1, any target pixel has 8 adjacent pixels, and all of the 8 adjacent pixels are pixels represented by fat; Step 203, using the eight adjacent pixel points in step 202 to diffuse to the surroundings, marking the target pixel point without eight adjacent pixel points as a measurement point; Step 204, repeat step 202 until the number of measurement points no longer increases, mark the area enclosed by all the measurement points as the measurement area, and set t=t+1; Step 205, repeat steps 202-204, and when t is greater than T, stop the loop; Step 206: Calculate the average value of pixels, the average value and standard deviation of the number of pixel blocks in all measurement areas, that is, texture features.
8. The food detection method based on image recognition according to claim 1, characterized in that: include; The first image information also includes shooting distance and shooting brightness; The standard environment brightness and the standard shooting distance are preset, and the distance difference between the shooting distance and the standard shooting distance, and the brightness difference between the shooting brightness and the standard environment brightness are calculated respectively.
9. A food detection method based on image recognition according to claim 8, characterized in that: The shooting distance acquisition method comprises: When obtaining the first image information, the photographing device sends a short pulse of light to the food to be identified, and the photographing device records the light pulse emission time k1, and records the light signal reflection and reception time k2; By formula JL is the shooting distance and c is the speed of light.
10. A food detection system based on image recognition, characterized in that: Implementing a food detection method based on image recognition as described in any one of claims 1 to 9, comprising: A data acquisition module is used to acquire image information of the food to be identified, the image information including first image information and second image information; the first image information is the surface image information of the food to be identified, the first image information also includes the shooting distance and the shooting brightness, and the second image information is the internal image information of the food to be identified; A first recognition module, used to input the first image information into a pre-trained food recognition model to obtain a food recognition result; A feature extraction module, used to extract quality features corresponding to the first image information and the second image information according to the recognition result; the corresponding quality features include surface features and intrinsic features; The integrated recognition module is used to select a corresponding origin recognition model according to the recognition result, input the surface features and intrinsic features into the origin recognition model corresponding to the recognition result, obtain the origin recognition result, and write the origin recognition result into the food inspection report.
Citation Information
Patent Citations
Method of automatically segmenting longissimus dorsi in beef image based on distance maintenance level set
CN106780504A
Food safety intelligent management method and system based on big data
CN111879772A
Fruit detection method, refrigerator and storage medium
CN113218889A
Evaluation of food quality based on machine learning
CN118742928A