Automatic food detection method and device, terminal equipment and storage medium
By introducing automated detection methods based on image technology in the food processing system, the use of imaging spectrometer and machine learning model for real -time detection and rating of food, solving the problem of unable to monitor food quality in existing technologies, realized efficient and accurate food Detection and rating.
Patent Information
- Application Number
- CN202411932082.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-01-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing food testing methods cannot achieve real-time inspection during food processing, especially the quality of different products cannot be effectively monitored.
The food automation detection method based on image technology is adopted to collect the image of food through the imaging spectrometer, and use the recognition model and evaluation model for food classification and quality rating. The system includes the transmission department, imaging spectrometer and server, which can detect the mildew situation and quality level of food in real time.
The real -time detection and rating classification of different foods is realized, the richness and accuracy of the test results are improved, and the quality changes in the food processing process can be effectively monitored.
Smart Images

Figure CN119360368A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated detection technology, and is a food detection method based on image technology, specifically a food automated detection method, device, terminal equipment and storage medium. Background Art
[0002] In the field of food processing, food testing includes food raw material testing, food ingredient testing, and food processing product testing. At present, food testing is mainly carried out through biochemical testing of food to obtain information on whether the microorganisms and main ingredients in the food are abnormal. However, the method for biochemical testing is mainly carried out through manual sampling, in which sampling is mainly carried out on the same batch of food, but for sampling, especially for meat food, even different individual products in the same batch have different quality conditions. However, the current detection method cannot achieve real-time detection during product processing. Summary of the invention
[0003] In order to solve the technical problems existing in the prior art, the embodiments of the present application provide a food automated detection method, apparatus, terminal device and storage medium, which can realize targeted detection and rating classification of different foods.
[0004] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows: In a first aspect, a method for automated food detection is provided, the method being applied to a food production system, the food production system comprising a conveying section for carrying and transmitting food to be detected, the conveying section comprising a conveying unit, the conveying unit being connected to at least four receiving channels, each receiving channel being used to receive food of corresponding quality; an imaging spectrometer being provided at an input end of the conveying unit, the imaging spectrometer being used to capture images of the food to be detected; the system further comprising a server, the server being connected to the imaging spectrometer, the method being configured in the server, the method comprising: determining a first target wavelength and an imaging focal length of the imaging spectrometer based on the type of the food to be detected, and capturing an image of the food to be detected based on the first target wavelength and the imaging focal length, to obtain a first spectrum graph and the first spectrum graph a first grayscale image corresponding to the food; the first grayscale image is input into the recognition model to obtain a recognition result, and the food is classified based on the recognition result; the recognition result includes a probability value of whether the food surface is moldy, when the probability value is greater than a preset moldy threshold, the recognition result is unqualified, and when the probability value is less than the preset moldy threshold, the recognition result is qualified; based on the type of the food to be detected and the first target wavelength, the second target wavelength of the second imaging spectrometer is determined, and based on the second target wavelength and the imaging focal length, a second image is captured for the qualified food to obtain a second image and a second grayscale image corresponding to the second image; the second grayscale image is input into the evaluation model to obtain a quality evaluation result of the food, and the food corresponding to the quality evaluation result is input into the corresponding receiving channel; the quality evaluation results include ordinary, high-quality and fine.
[0005] Furthermore, the process of determining the first target wavelength and the second target wavelength includes: obtaining the label of the food to be detected, and performing a corresponding query in the food-wavelength database based on the label to obtain the corresponding first target wavelength and second target wavelength, specifically including: querying a first subset corresponding to the first label code of the food to be detected, querying a second subset corresponding to the second label code of the food to be detected in the first subset, and querying a third subset corresponding to the third label code of the food to be detected in the third subset, and the first target wavelength and the second target wavelength of the food to be detected are configured in the third subset.
[0006] Furthermore, the food-wavelength database stores a first target wavelength and a second target wavelength corresponding to each food, and each of the first target wavelength and each of the second target wavelength are pre-screened based on each food, specifically including: obtaining a spectrum corresponding to each food, and obtaining multiple spectral wavelengths and corresponding spectral wavelength vectors in the spectrum, and projecting different spectral wavelength vectors onto other spectral wavelengths, and then performing vector comparison, taking the wavelength of the maximum projection vector as the candidate wavelength, and screening the candidate wavelengths based on multivariate linear regression analysis to obtain multiple cross-validation root mean square errors, and taking the spectral wavelength corresponding to the minimum value of the multiple cross-validation root mean square errors as the target wavelength.
[0007] Furthermore, determining the imaging focal length of the imaging spectrometer based on the type of the food to be detected includes: determining size information of the food to be detected based on the type of the food to be detected, and determining the imaging focal length of the imaging spectrometer based on a size-focal length correspondence.
[0008] Furthermore, before processing the first spectrum graph and the second spectrum graph, the first spectrum graph and the second spectrum graph are also preprocessed, specifically including: taking 5 consecutive data points of spectral data in the first spectrum graph and the second spectrum graph as a group, replacing the center point value with a polynomial fitting value based on the data of each group, and performing moving calculations on the spectral data in sequence based on a filtering window until the window slides through the first spectrum graph and the second spectrum graph, so as to obtain updated spectral data in the processed first spectrum graph and the second spectrum graph.
[0009] Furthermore, the recognition model includes five convolution blocks with successively decreasing scales, and five pooling layers cross-arranged in the five convolution blocks, and a fully connected layer and an activation layer are connected after the last pooling layer; two convolution layers of the same size are arranged in the first convolution block.
[0010] Furthermore, the evaluation model is constructed based on a support vector machine constructed based on a polynomial kernel function.
[0011] In a second aspect, a food automated detection device is provided, comprising: a preliminary image processing module, for determining a first target wavelength and an imaging focal length of an imaging spectrometer based on the type of food to be detected, and performing image acquisition of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum map and a first grayscale map corresponding to the first spectrum map; a recognition module, for inputting the first grayscale map into a recognition model to obtain a recognition result, and classifying the food based on the recognition result; the recognition result includes a probability value of whether the food surface is moldy, when the probability value is greater than a preset mold threshold, the recognition result is unqualified, and when the probability value is less than the preset mold threshold, the recognition result is qualified; a secondary image processing module, for determining a second target wavelength of a second imaging spectrometer based on the type of food to be detected and the first target wavelength, and performing secondary image acquisition of qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map; an evaluation module, for inputting the second grayscale map into an evaluation model to obtain a quality evaluation result on the food, and inputting the food corresponding to the quality evaluation result into a corresponding receiving channel; the quality evaluation result includes ordinary, high-quality and fine products.
[0012] In a third aspect, a terminal device is provided, comprising: a memory and a processor coupled to the memory, wherein the processor is configured to execute any of the above-mentioned automated food detection methods based on instructions stored in the memory.
[0013] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the automated food detection method as described in any one of the above are implemented.
[0014] In the technical solution provided in the embodiment of the present application, through spectral image processing technology, more abundant image information about food can be obtained compared with the existing image acquisition technology, and the recognition model and evaluation model established based on machine learning improve the richness and accuracy of food detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] The methods, systems and / or programs in the accompanying drawings will be further described according to exemplary embodiments. These exemplary embodiments will be described in detail with reference to the drawings. These exemplary embodiments are non-limiting exemplary embodiments, wherein example numbers represent similar mechanisms in the various views of the accompanying drawings.
[0017] Figure 1 It is a schematic diagram of the structure of the food production system provided in the embodiment of the present application.
[0018] Figure 2 It is a schematic diagram of the structure of an imaging spectrometer provided in an embodiment of the present application.
[0019] Figure 3 It is a flow chart of the automated food detection method provided in the embodiment of the present application.
[0020] Figure 4 It is a schematic diagram of the structure of the automatic food detection device provided in the embodiment of the present application.
[0021] Figure 5 It is a schematic diagram of the terminal device structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to better understand the above technical scheme, the technical scheme of the present application is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present application and the specific features in the embodiments are detailed descriptions of the technical scheme of the present application, rather than limitations on the technical scheme of the present application. In the absence of conflict, the embodiments of the present application and the technical features in the embodiments can be combined with each other.
[0023] In the following detailed description, numerous specific details are set forth by way of example in order to provide a comprehensive understanding of the relevant guidance. However, it will be apparent to those skilled in the art that the present application may be practiced without these details. In other cases, well-known methods, procedures, systems, compositions and / or circuits have been described at a relatively high level, without detail, in order to avoid unnecessarily obscuring aspects of the present application.
[0024] Flowcharts are used in the present application to illustrate the execution process performed by the system according to the embodiment of the present application. It should be clearly understood that the execution process of the flowchart may not be performed in order. On the contrary, these execution processes may be performed in reverse order or simultaneously. In addition, at least one other execution process may be added to the flowchart. One or more execution processes may be deleted from the flowchart.
[0025] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are subject to the following interpretations.
[0026] (1) In response to, it is used to indicate the conditions or states on which the executed operation depends. When the dependent conditions or states are met, one or more operations executed may be in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.
[0027] (2) Based on: used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.
[0028] According to this embodiment, a food automation detection method is provided, which is used to automatically detect the produced food based on the production line. Figure 1 The method is configured in a food production system 100, wherein the production system includes a conveying section 110 for carrying and transmitting the food to be tested, and the conveying section includes a conveying unit and at least four receiving channels connected to the conveying unit, wherein each receiving channel is used to receive food of corresponding quality.
[0029] Among them, the quality identification of food is achieved based on the automated food detection method provided in this embodiment.
[0030] Specifically, the food automated detection method is implemented based on an imaging spectrometer 120 disposed at the input end of the transmission unit and a server 130 connected to the imaging spectrometer. The imaging spectrometer is used to collect images of the food to be detected, and the server is used to process the collected images of the food to be detected to obtain the classification of the food to be detected, and control the transmission unit to transmit the food accordingly according to the classification result, so that the food enters the corresponding receiving channel.
[0031] Therefore, the food production system in this embodiment includes a transmission unit, an imaging spectrometer and a server.
[0032] Among them, this imaging spectrometer collects images of the food to be tested based on hyperspectral imaging.
[0033] For details, please refer to Figure 2 The imaging spectrometer 120 includes a CCD sensor 121 , a spectrometer 122 , a light source 123 and a lens 124 .
[0034] The CCD sensor and the spectrometer are placed directly on the food to be tested, and the light source is illuminated at an angle, so that the image of the food to be tested can be obtained through this imaging device. The wavelength range of the spectrometer in this embodiment is 400-1000nm, and the resolution is 1.27nm.
[0035] The imaging spectrometer acquires an image of the food to be tested and transmits the image to the server, which executes the automated food testing method to detect the food, determine the quality of the food, and transport the food to the corresponding channel based on different qualities.
[0036] The quality of food in this embodiment includes unqualified, ordinary, high-quality and fine.
[0037] See also Figure 3 The food automatic detection method executed by the server specifically includes the following steps: Step S310. Determine a first target wavelength and an imaging focal length of the imaging spectrometer based on the type of the food to be detected, and capture an image of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum map and a first grayscale map corresponding to the first spectrum map.
[0038] The amount of hyperspectral data collected by hyperspectral imagers over the entire food band is extremely large, but since the reflectivity of adjacent bands is highly correlated, the hyperspectral data contains a large amount of redundant information.
[0039] Therefore, in the embodiments of the present application, for different foods and different detection tasks, in order to reduce the data processing pressure and processing cost caused by full-band image acquisition, it is necessary to configure the optimal wavelength for different foods to be detected and different detection tasks, and collect spectra based on this wavelength.
[0040] In this embodiment, the first target wavelength is determined by determining the label of the food to be detected, and performing a corresponding query in the food-wavelength database based on the label to obtain the corresponding first target wavelength.
[0041] Specifically, the labels of the food to be detected are configured in the food production system, and each type of food is configured with a corresponding label. The process of determining the wavelength based on the label is to query the first subset corresponding to the first label code of the food to be detected, query the second subset corresponding to the second label code of the food to be detected in the first subset, and query the third subset corresponding to the third label code of the food to be detected in the second subset, wherein each third subset is configured with a target wavelength corresponding to the detection task, which is the first target wavelength in this embodiment.
[0042] The first subset, the second subset and the third subset are data storage methods set in a coding gradient manner. The determination is based on the classification of food, for example, the coding method for cakes is ready-to-eat food-pastry food-Western cake, wherein the corresponding target wavelength is configured in the Western cake.
[0043] In this embodiment, the wavelength determination for different foods to be tested is based on pre-screening, and the screening method is to obtain the spectrum corresponding to each food, and obtain multiple spectral wavelengths and corresponding spectral wavelength vectors in the spectrum, and project the different spectral wavelength vectors onto other spectral wavelengths, and then perform vector comparison, and take the wavelength of the maximum projection vector as the selected wavelength.
[0044] Specifically, in order to obtain the spectrum corresponding to each food, firstly, any column of the spectrum matrix is randomly selected to collect the spectrum image, and then the spectrum data of the i-th column is defined as xi, and this spectrum matrix is recorded as xk(0); the column vector positions that have not been selected in the spectrum are recorded as s set, which is expressed based on the following formula: , where I represents the total number of columns and n represents the number of selected variables; the projection of xi on the remaining column vectors is calculated respectively, based on the following expression: , x represents the spectral data, xi represents the spectral data of the i-th column; extract the spectral wavelength of the maximum projection vector, let , pxi is the projection of xi on the remaining column vectors, and the maximum projection is determined: , iterate the loop, when When , the target band sequence is determined as the candidate wavelength, and N represents the variable threshold.
[0045] Based on the determined candidate wavelengths, multiple cross-validation root mean square errors are screened based on multivariate linear regression analysis, and the spectral wavelength corresponding to the minimum value of the multiple cross-validation root mean square errors is used as the target wavelength.
[0046] The wavelength corresponding to the food can be determined through the above processing.
[0047] In the corresponding imaging process, not only the influence of wavelength on the imaging results must be considered, but also the influence of lens focal length on imaging must be determined. When the focal length is too small, the complete image information of the food cannot be obtained. When the focal length is too large, too many background images will be introduced, thereby increasing the process cost of image processing.
[0048] Therefore, in this embodiment, it is also necessary to determine the focal length for image acquisition. Specifically, in this embodiment, the size information of the food is determined according to the type of food to be detected, and the imaging focal length of the imaging spectrometer, i.e., the lens, is determined based on the size-focal length correspondence. Image acquisition is performed based on this imaging focal length to obtain a first spectrum map, and then the first spectrum map is preprocessed to eliminate the influence of noise on the imaging result.
[0049] Among them, for preprocessing, 5 consecutive data points of the spectral data in the first spectrogram are taken as a group, and the center point value is replaced by the polynomial fitting value of the data in each group. The spectral data are moved and calculated in sequence based on the filter window until the window slides through the first spectrogram to obtain updated spectral data of the processed first spectrogram, and the first spectrogram is updated based on the updated spectral data to obtain the processed first spectrogram.
[0050] Then the first spectrum image is gray-scaled to obtain a corresponding first gray-scale image.
[0051] Step S320: Input the first grayscale image into a recognition model to obtain a recognition result, and classify the food based on the recognition result.
[0052] In this embodiment, this process is used to classify food, and the classification result is specifically to evaluate whether the food is qualified food or unqualified food.
[0053] The recognition model in this embodiment includes five convolution blocks with successively decreasing scales, and five pooling layers cross-arranged in the five convolution blocks, and a fully connected layer and an activation layer are connected after the last pooling layer; two convolution layers of the same size are arranged in the first convolution block.
[0054] Among them, the number of planes with volume structure for the convolution layer. The number of smaller kernels (Ks) defines each plane. The weight of the filter size is 3×3, and the feature extraction of the convolution layer is expressed based on the following formula: ,in is the matrix value about the kth input plane, D represents the dimension of the convolutional layer, For the parameter weights, generate a two-dimensional matrix on the kth input plane , F is the activation function, b1 is the bias function, the activation function F and the bias function b1 transform the result. The feature mapping obtains the matrix Xl and the feature map M.
[0055] Pooling layers are used after a layer or each block of convolutional layers to reduce the size of feature maps.
[0056] After the pooling layer and the continuous convolution layer, the feature map set is obtained. The input and output operations of each neuron in the fully connected layer are as follows: ,in represents the weight of the neuron, represents the input feature, Z represents the output of the fully connected layer, n represents the dimension of the input feature, b represents the bias number, and j represents the starting calculation position.
[0057] In this embodiment, the softmax function is used as the activation function, and two output neurons are used to classify the evaluation. The output layer of each neuron node result obtains a probability distribution result, and the result with the largest probability distribution is selected as the initial evaluation result.
[0058] In order to further improve the accuracy of determining unqualified food, a secondary recognition mechanism is also configured in this embodiment. Specifically, when the initial evaluation result is qualified, the probability value of qualified recognition in another output layer is compared with the preset mold threshold. When this probability value is greater than the preset mold threshold, the final recognition result is determined to be unqualified, and when this probability value is less than the preset mold threshold, the final recognition result is qualified.
[0059] Step S330. Determine the second target wavelength of the second imaging spectrometer based on the type of the food to be tested and the first target wavelength, and perform secondary image acquisition on the qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map.
[0060] In this embodiment, the reason why secondary image acquisition is required is that the corresponding setting is based on the food production system. The food production system is an assembly line production process. The result detected in step S320 will be correspondingly allocated to separate qualified food and unqualified food. Unqualified food will directly enter the recycling channel for recycling, while qualified products will enter the next stage of the production line.
[0061] In this embodiment, the next stage of the production line is the grading and evaluation of the products, which is to judge the level of qualified food. For example, qualified fruit food is only the standard for being put on the market. Fruits of different maturity and appearance correspond to different levels.
[0062] Therefore, after the qualified classification, the fruit needs to be graded and evaluated, and the grading and evaluation is performed on the production line after the qualified identification, and this process is also realized by spectral imaging technology. The spectral imaging device in this process needs to determine the wavelength and focal length based on the process of step S310, so as to obtain the second spectrum.
[0063] The process of acquiring the second spectrum graph may be performed in the same manner as step S310, and will not be described in detail in step S330.
[0064] Step S340: Input the second grayscale image into the evaluation model to obtain a quality evaluation result of the food, and input the food corresponding to the quality evaluation result into the corresponding receiving channel.
[0065] The quality evaluation result is determined based on the second grayscale image obtained in step S330 through the evaluation model, wherein the evaluation model is implemented by a support vector machine based on a polynomial kernel function in this embodiment.
[0066] The support vector machine finds an optimal hyperplane in the data to separate samples of different categories. The core idea is to find a hyperplane that can maximize the interval to ensure the generalization performance of unseen data. The choice of kernel function is indeed an important variable in the support vector machine because it directly affects the performance and applicability of the model. The kernel function is used to map the original feature space to a higher-dimensional feature space, so that the originally linearly inseparable problem becomes linearly separable in the new space.
[0067] In this embodiment, a polynomial kernel function is used as a basis function, and the polynomial kernel function maps the original features to a higher-dimensional polynomial space. The polynomial kernel function has a parameter d, i.e., the order of the polynomial, and the complexity of the model can be adjusted by adjusting the parameter d.
[0068] Through steps S310 to S340, it is possible to determine whether the food to be tested is qualified food and the final grade evaluation of the food. Compared with the existing image acquisition technology, the spectral image processing technology can obtain more abundant image information about the food, and the recognition model and evaluation model established based on machine learning improve the richness and accuracy of the food detection results.
[0069] See also Figure 4 Based on step S310-step S340, a virtual device for execution is also provided, which is a food automated detection device 400. This device can be configured in any software product to execute the process of step S310-step S340. This device can be a separate plug-in module or a complete computer product. This device includes: A preliminary image processing module 410 is used to determine a first target wavelength and an imaging focal length of an imaging spectrometer based on the type of food to be detected, and to collect an image of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum image and a first grayscale image corresponding to the first spectrum image; The recognition module 420 is used to input the first grayscale image into the recognition model to obtain a recognition result, and classify the food based on the recognition result; the recognition result includes a probability value of whether the food surface is moldy, when the probability value is greater than a preset mold threshold, the recognition result is unqualified, and when the probability value is less than the preset mold threshold, the recognition result is qualified; A secondary image processing module 430 is used to determine a second target wavelength of a second imaging spectrometer based on the type of the food to be detected and the first target wavelength, and to perform secondary image acquisition on the qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map; The evaluation module 440 is used to input the second grayscale image into the evaluation model to obtain the quality evaluation result of the food, and input the food corresponding to the quality evaluation result into the corresponding receiving channel; the quality evaluation results include ordinary, high-quality and fine.
[0070] See also Figure 5 , the above method can also be integrated into the provided terminal device 500, and the device may have relatively large differences due to different configurations or performances, and may include one or more processors 501 and memory 502, and the memory 502 may store one or more storage applications or data. Among them, the memory 502 can be a temporary storage or a permanent storage. The application stored in the memory 502 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the terminal device. Furthermore, the processor 501 can be configured to communicate with the memory 502, and the terminal device executes a series of computer executable instructions in the memory 502. The terminal device may also include one or more power supplies 503, one or more wired / wireless network interfaces 504, one or more input / output interfaces 505, one or more keyboards 506, etc.
[0071] In a specific embodiment, the terminal device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the terminal device, and the one or more programs are configured to be executed by one or more processors, including computer executable instructions for performing the following: Determine a first target wavelength and an imaging focal length of the imaging spectrometer based on the type of the food to be detected, and capture an image of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum image and a first grayscale image corresponding to the first spectrum image; Inputting the first grayscale image into a recognition model to obtain a recognition result, and classifying the food based on the recognition result; Determine a second target wavelength of the second imaging spectrometer based on the type of the food to be tested and the first target wavelength, and perform secondary image acquisition on the qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map; The second grayscale image is input into the evaluation model to obtain a quality evaluation result of the food, and the food corresponding to the quality evaluation result is input into the corresponding receiving channel.
[0072] The following is a detailed introduction to the various components of the processor: In this embodiment, the processor is an application specific integrated circuit (ASIC), or is configured to implement one or more integrated circuits of the embodiments of the present application, such as one or more microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays (field programmable gate array, FPGA).
[0073] Optionally, the processor may execute various functions by running or executing a software program stored in the memory and calling data stored in the memory, such as executing the above-mentioned Figure 2 The method shown.
[0074] In a specific implementation, as an embodiment, the processor may include one or more microprocessors.
[0075] Among them, the memory is used to store the software program that executes the solution of the present application, and the execution is controlled by the processor. The specific implementation method can refer to the above method embodiment and will not be repeated here.
[0076] Optionally, the memory may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may be integrated with the processor, or may exist independently and be coupled to the processing unit through the interface circuit of the processor, which is not specifically limited in the embodiments of the present application.
[0077] It should be noted that the structure of the processor shown in this embodiment does not constitute a limitation on the device, and the actual device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0078] In addition, the technical effects of the processor can refer to the technical effects of the method described in the above method embodiment, which will not be repeated here.
[0079] It should be understood that the processor in the embodiments of the present application may be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0080] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0081] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0082] In this application, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0083] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0084] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0086] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0089] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0090] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A food automated detection method, characterized in that: The method is applied to a food production system, the food production system includes a conveying part for carrying and transmitting food to be detected, the conveying part includes a conveying unit, the conveying unit is connected to at least four receiving channels, each receiving channel is used to receive food of corresponding quality; an imaging spectrometer is arranged at the input end of the conveying unit, the imaging spectrometer is used to collect images of the food to be detected; the system also includes a server, the server is connected to the imaging spectrometer and the conveying unit, the method is configured in the server, the method includes: Determine a first target wavelength and an imaging focal length of the imaging spectrometer based on the type of the food to be detected, and capture an image of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum image and a first grayscale image corresponding to the first spectrum image; Inputting the first grayscale image into a recognition model to obtain a recognition result, and classifying the food based on the recognition result; the recognition result includes a probability value of whether the food surface is moldy, when the probability value is greater than a preset mold threshold, the recognition result is unqualified, and when the probability value is less than the preset mold threshold, the recognition result is qualified; Determine a second target wavelength of a second imaging spectrometer based on the type of the food to be tested and the first target wavelength, and perform secondary image acquisition on the qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map; The second grayscale image is input into the evaluation model to obtain the quality evaluation result of the food, and the food corresponding to the quality evaluation result is input into the corresponding receiving channel; the quality evaluation results include ordinary, high-quality and fine.
2. The automated food detection method according to claim 1, characterized in that: The process of determining the first target wavelength and the second target wavelength includes: obtaining the label of the food to be detected, and performing a corresponding query in the food-wavelength database based on the label to obtain the corresponding first target wavelength and second target wavelength, specifically including: querying a first subset corresponding to the first label code of the food to be detected, querying a second subset corresponding to the second label code of the food to be detected in the first subset, and querying a third subset corresponding to the third label code of the food to be detected in the second subset, and the first target wavelength and the second target wavelength of the food to be detected are configured in the third subset.
3. The automated food detection method according to claim 2, characterized in that: The food-wavelength database stores a first target wavelength and a second target wavelength corresponding to each food. Each of the first target wavelength and each of the second target wavelength are pre-screened based on each food, specifically including: obtaining a spectrum corresponding to each food, and obtaining multiple spectral wavelengths and corresponding spectral wavelength vectors in the spectrum, and projecting different spectral wavelength vectors onto other spectral wavelengths, and then performing vector comparison, taking the wavelength of the maximum projection vector as the candidate wavelength, and screening the candidate wavelengths based on multivariate linear regression analysis to obtain multiple cross-validation root mean square errors, and taking the spectral wavelength corresponding to the minimum value of the multiple cross-validation root mean square errors as the target wavelength.
4. The automated food detection method according to claim 1, characterized in that: Determining the imaging focal length of the imaging spectrometer based on the type of the food to be detected includes: determining size information of the food to be detected based on the type of the food to be detected, and determining the imaging focal length of the imaging spectrometer based on a size-focal length correspondence relationship.
5. The automated food detection method according to claim 1, characterized in that: Before processing the first spectrum graph and the second spectrum graph, the first spectrum graph and the second spectrum graph are also preprocessed, specifically including: taking 5 consecutive data points of spectral data in the first spectrum graph and the second spectrum graph as a group, replacing the center point value with a polynomial fitting value based on the data of each group, and performing moving calculations on the spectral data in sequence based on a filtering window until the window slides through the first spectrum graph and the second spectrum graph, so as to obtain updated spectral data in the processed first spectrum graph and the second spectrum graph.
6. The automated food detection method according to claim 1, characterized in that: The recognition model includes five convolution blocks with successively decreasing scales, and five pooling layers cross-arranged in the five convolution blocks, and a fully connected layer and an activation layer are connected after the last pooling layer; two convolution layers of the same size are arranged in the first convolution block.
7. The automated food detection method according to claim 1, characterized in that: The evaluation model is constructed based on a support vector machine constructed based on a polynomial kernel function.
8. A food automated testing device, characterized in that: include: A preliminary image processing module, used to determine a first target wavelength and an imaging focal length of an imaging spectrometer based on the type of food to be detected, and to collect an image of the food to be detected based on the first target wavelength and the imaging focal length to obtain a first spectrum image and a first grayscale image corresponding to the first spectrum image; a recognition module, configured to input the first grayscale image into a recognition model to obtain a recognition result, and classify the food based on the recognition result; the recognition result includes a probability value of whether the food surface is moldy, when the probability value is greater than a preset mold threshold, the recognition result is unqualified, and when the probability value is less than the preset mold threshold, the recognition result is qualified; A secondary image processing module, used to determine a second target wavelength of a second imaging spectrometer based on the type of the food to be detected and the first target wavelength, and to perform secondary image acquisition on the qualified food based on the second target wavelength and the imaging focal length to obtain a second spectrum map and a second grayscale map corresponding to the second spectrum map; An evaluation module, used for inputting the second grayscale image into an evaluation model to obtain a quality evaluation result of the food, and inputting the food corresponding to the quality evaluation result into a corresponding receiving channel; The quality evaluation results include ordinary, high-quality and fine.
9. A terminal device, comprising: A memory and a processor coupled to the memory, wherein the processor is configured to execute the food automated detection method according to any one of claims 1 to 7 based on instructions stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the automated food detection method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Food safety detection system and method thereof
CN116858789A
Digital food production detection system and method
CN117911912A