Rating system and method for peanuts with shells
Through deep learning network and image processing technology, combined with OCR technology of electronic scale display screen, multi-parameter rating of shell peanuts is achieved, solving the problems of low efficiency and strong subjectivity of existing rating methods, and improving the intelligence of ratings and precision.
Patent Information
- Application Number
- CN202411747717.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-02-07
AI Technical Summary
The existing rating methods for shelled peanuts mainly rely on manual testing, which has problems such as high labor intensity, low efficiency and strong subjectivity. Mechanical testing is only rated based on the size characteristics of peanuts. The rating basis is not comprehensive enough and it is easy to damage peanuts. Poor results.
Deep learning network model and image processing technology are used to automatically obtain the number, color defects, shape similarity and length of peanuts by collecting peanut images, and use OCR technology of electronic scale display screen images to obtain thousands of peanuts, and comprehensively utilize a variety of The parameters are accurately rated.
It has realized the automated rating of peanuts with shells, which is more comprehensive and intelligent, with simple operation and strong practicality, which improves rating efficiency and accuracy.
Smart Images

Figure CN119395017A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of agricultural product rating, and in particular to a system and method for rating shelled peanuts. Background Art
[0002] Peanuts are an important cash crop and daily food, widely grown in tropical and subtropical regions. They play an important role in China's agricultural production and food culture. They are rich in protein, healthy fats and multiple vitamins and are widely used in the food processing industry. With the improvement of people's healthy eating concept, the market demand for peanuts continues to expand, driving the development of peanut-related industries. Among them, small-packaged gift boxes of shelled peanuts as souvenirs are becoming more and more popular. The high-end products of small-packaged gift boxes of shelled peanuts require that the peanuts have no defects in color, close to the standard shape, long size, full grains, and consistent color, shape, size, etc. Therefore, peanuts need to be graded and screened during product processing.
[0003] Currently, the quality rating of shelled peanuts is mostly done manually, with some using mechanical equipment for auxiliary testing. Manual testing has problems such as high labor intensity, low efficiency, strong subjectivity, and being greatly influenced by personal bias, which leads to inconsistent rating results; mechanical testing equipment only rates peanuts based on their size characteristics, and the rating parameters are not comprehensive enough. In addition, the peanuts are easily damaged during the rating process, resulting in poor rating results. Summary of the invention
[0004] In view of the shortcomings of the background technology, the purpose of the present invention is to provide a system and method for grading peanuts in shells, which uses the collected peanut images to apply a deep learning network model and image processing technology to automatically obtain the number, color defects, shape similarity and length of peanuts, and uses the collected electronic scale display screen images to apply image processing technology and OCR technology to obtain the thousand-pearl weight of peanuts, and comprehensively utilizes parameters such as color, shape, size and weight to achieve accurate grading of peanuts in shells.
[0005] As for the system, the technical solution adopted by the present invention is: a peanut grading system in shell, which is mainly composed of a hardware module, a parameter setting module, a signal control module, a peanut image acquisition module, a camera calibration module, a color correction module, an image correction module, a peanut image segmentation and defect detection module, a peanut shape detection module, a peanut size measurement module, a peanut weighing module, and a peanut grading module;
[0006] The hardware module includes a first camera, a second camera, a first light source, a second light source, a light source controller, a relay, an electronic scale, a signal generator, a host, a gantry, a tray, a platform, a power supply voltage reduction module and a power supply; the first camera and the second camera are both fixed on the gantry and can be adjusted up, down, left and right, and the gantry is fixed on the platform; an electronic scale is placed directly below the first camera and aligned with the tray above the electronic scale, a first light source is placed between the first camera and the electronic scale, and the position is fixed for collecting peanut images; the second camera is aligned with the display screen of the electronic scale, a second light source is placed between the second camera and the display screen of the electronic scale, and the position is fixed for collecting images of the electronic scale display screen; the first light source and the second light source are connected to the light source controller through a signal line, the light source controller is connected to the relay through a signal line, the first camera and the second camera are connected to the host through a network cable, the first camera, the second camera and the relay are connected to the signal generator through a signal line, the relay is connected to the power supply voltage reduction module through a signal line, the signal generator is connected to the host through a signal line, and the first camera, the second camera, the power supply voltage reduction module, the light source controller, the host and the electronic scale are all connected to the power supply through a power line;
[0007] The host and the signal generator communicate with each other via a data line. The host sends data. After receiving the data, the signal generator sends a high level to the relay, and the relay changes from a normally open state to a closed state. The power supply step-down module provides voltage to the relay, and the light source controller triggers the first light source and the second light source, so that the first light source and the second light source change from an off state to a bright state. After a certain delay, the signal generator sends a high level to the first camera and the second camera, and the first camera and the second camera are both triggered to collect images. After a certain delay, the signal generator sends a low level to the relay, the first camera, and the second camera, and the relay changes from a closed state to a normally open state, so that the first light source and the second light source change from a bright state to an off state.
[0008] The parameter setting module is used to set parameters such as the variety, shape, grading size and grading thousand-pear weight of the peanuts to be graded; the signal control module is used to control the host in the hardware module to communicate with the signal generator via the serial port; the peanut image acquisition module is used to acquire the image of the shelled peanuts spread on the electronic scale tray through the first camera in the hardware module; the camera calibration module is used to calibrate the first camera in the hardware module to obtain the distortion coefficient, so as to facilitate the subsequent processing to eliminate the image distortion; the color correction module is used to obtain the color correction matrix, so as to facilitate the subsequent correction of the color of the shelled peanut image to make the color more real and natural; the image correction module is used to calibrate the shelled peanuts acquired by the first camera. The raw image is subjected to distortion correction and color correction to obtain a corrected image of peanuts in shells; the peanut image segmentation and defect detection module is used to detect whether there are defects such as black spots and blackheads from the entire corrected image of peanuts in shells and obtain a single image of peanuts in shells; the peanut shape detection module is used to calculate the shape similarity between peanuts in shells and standard peanuts, as well as the shape similarity mean and shape similarity uniformity; the peanut size measurement module is used to measure the length of peanuts in shells and calculate the length mean and length uniformity; the peanut weighing module is used to obtain the thousand-pearl weight of peanuts in shells; the peanut grading module is used to grade and evaluate the peanuts in shells according to their defects, shape similarity, size and thousand-pearl weight;
[0009] The parameter setting module, signal control module, peanut image acquisition module, camera calibration module, color correction module, image correction module, peanut image segmentation and defect detection module, peanut shape detection module, peanut size measurement module, peanut weighing module and peanut grading module are all installed in the host of the hardware module.
[0010] Compared with the prior art, the shelled peanut grading system of the present invention realizes the automatic grading of peanuts. On the one hand, the present invention triggers the camera and light source through a signal generator, collects the image of the shelled peanuts flat on the electronic scale tray, and uses a deep learning model and image processing technology to automatically obtain the color, shape, size and other information of the shelled peanuts. At the same time, the electronic scale display screen image is collected, and the OCR text recognition model based on deep learning is used to automatically identify the weight of peanuts; on the other hand, the present invention combines multiple characteristic parameters of peanuts (especially shape similarity and thousand-pearl weight) to grade the shelled peanuts. Compared with the existing automatic detection device and manual detection, the system of the present invention is more comprehensive and intelligent in grading the shelled peanuts. In addition, the system of the present invention is simple to operate and has strong practicality.
[0011] As an optimization, the peanut image segmentation and defect detection module detects whether there are defects such as black spots and blackheads in the entire image of shelled peanuts after distortion correction and color correction through a trained deep learning-based instance segmentation model, and separates each shelled peanut to generate multiple single peanut images containing only one shelled peanut.
[0012] As an optimization, the peanut shape detection module extracts the outer contours of the shelled peanuts in each single peanut image, calculates the similarity of each contour with the standard peanut contour, obtains the shape similarity of each shelled peanut with the standard peanut, and then calculates the mean and standard deviation of the shape similarity of all shelled peanuts to obtain the shape similarity mean and shape similarity uniformity of all shelled peanuts.
[0013] As an optimization, the peanut size measurement module extracts the minimum circumscribed rectangle of the in-shell peanuts in each single peanut image, multiplies the length of the longer side of the minimum circumscribed rectangle by the pixel equivalent, and obtains the length size of each in-shell peanut in mm; then the mean and standard deviation of the length sizes of all in-shell peanuts are calculated to obtain the length mean and length uniformity of all in-shell peanuts.
[0014] As an optimization, the peanut weighing module uses a second camera to capture the image of the electronic scale display screen and adopts an OCR text recognition model based on deep learning to obtain the weight of the shelled peanuts to be graded on the electronic scale tray, and then converts it into the weight of 1,000 peanuts based on the number of peanuts to obtain the thousand-pearl weight.
[0015] As an optimization, the peanut grading module assesses the peanuts to be graded into corresponding grades based on the established grading standards for shelled peanuts, the defect detection status obtained by the peanut image segmentation and defect detection module, the similarity mean and similarity uniformity of the shape similarity obtained by the peanut shape detection module, the length mean and length uniformity obtained by the peanut size measurement module, and the thousand-pearl weight obtained by the peanut weighing module.
[0016] As for the grading method, the technical solution of the present invention is: a method for grading peanuts in shells using the aforementioned peanut grading system of the present invention, comprising the following steps:
[0017] Step 1: Set the variety, standard shape, grading size, and grading thousand-pear weight of the peanuts to be graded through the parameter setting module, and load the corresponding instance segmentation model; obtain the distortion coefficient of the first camera through the camera calibration module using the calibration plate placed on the electronic scale tray; obtain the color correction matrix through the color correction module using the standard color card placed on the electronic scale tray;
[0018] Step 2: Randomly select a certain number of in-shell peanuts from the in-shell peanuts to be graded and evaluated, and lay them flat on the electronic scale tray;
[0019] Step 3: using the peanut image acquisition module to acquire images of the peanuts in shells laid out on the electronic scale tray through the first camera;
[0020] Step 4: Use the image correction module to perform distortion correction and color correction on the collected peanuts in shell image to obtain a corrected peanuts in shell image;
[0021] Step 5: Use the peanut image segmentation and defect detection module to perform defect detection on the corrected peanut image in shell and segment each peanut from the entire image to obtain each single peanut image in shell. If there are defective peanuts in shell, the peanut grading module is directly used to grade the peanuts in shell to be graded, and the grading is completed; otherwise, proceed to the next step 6;
[0022] Step 6: Calculate the shape similarity between each in-shell peanut and the standard peanut through the peanut shape detection module, then calculate the mean and standard deviation of the shape similarity of all in-shell peanuts, and obtain the shape similarity mean and shape similarity uniformity of all in-shell peanuts;
[0023] Step 7: Calculate the length of each shelled peanut through the peanut size measurement module, then calculate the mean and standard deviation of the length of all shelled peanuts, and obtain the mean length and length uniformity of all shelled peanuts;
[0024] Step 8: Obtain the weight of the unshelled peanuts to be rated placed on the electronic scale tray through the peanut weighing module, and convert it into the weight of 1,000 peanuts according to the number of peanuts to obtain the thousand-pearl weight;
[0025] Step 9: Steps 2 to 8 are performed three times in total. The mean of the three shape similarity means and the mean of the shape similarity uniformity, the mean of the three length means and the mean of the length uniformity, and the mean of the three thousand-pearl weights are calculated. The peanut grading module is used to grade the shelled peanuts to be graded, and the grading is completed.
[0026] The grading method of the present invention greatly improves the efficiency of identifying defects and the measurement accuracy of peanut sizes, while simplifying the peanut grading process, shortening the grading time, and effectively improving the grading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a block diagram of the components of the in-shell peanut rating system;
[0028] Figure 2 It is a schematic diagram of the hardware module composition;
[0029] Figure 3 It is a flow chart of the method for grading in-shell peanuts.
[0030] Marked in the attached figure: M1-hardware module; M2-parameter setting module; M3-signal control module; M4-peanut image acquisition module; M5-camera calibration module; M6-color correction module; M7-image correction module; M8-peanut image segmentation and defect detection module; M9-peanut shape detection module; M10-peanut size detection module; M11-peanut weighing module; M12-peanut grading module; 1-first camera; 2-second camera; 3-gantry; 4-second light source; 5-first light source; 6-light source controller; 7-platform; 8-electronic scale; 9-tray; 10-relay; 11-power step-down module; 12-signal generator; 13-host; 14-power supply. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0032] like Figure 1 As shown, the shelled peanut grading system of the present invention includes twelve modules, namely: a hardware module M1, a parameter setting module M2, a signal control module M3, a peanut image acquisition module M4, a camera calibration module M5, a color correction module M6, an image correction module M7, a peanut image segmentation and defect detection module M8, a peanut shape detection module M9, a peanut size measurement module M10, a peanut weighing module M11, and a peanut grading module M12.
[0033] The hardware module M1 is mainly composed of Figure 2As shown, it includes a first camera 1, a second camera 2, a first light source 5, a second light source 4, a light source controller 6, a relay 10, an electronic scale 8, a signal generator 12, a host 13, a gantry 3, a tray 9, a platform 7, a power supply step-down module 11 and a power supply 14; the first camera 1 and the second camera 2 are both fixed on the gantry 3 and can be adjusted up and down and left and right, and the gantry 3 is fixed on the platform 7; the electronic scale 8 is placed directly below the first camera 1 and is aligned with the tray 9 above the electronic scale 8, and the first light source 5 is placed between the first camera 1 and the electronic scale 8 and fixed in position for collecting peanut images; the second camera 2 is aligned with the display screen of the electronic scale 8, and a first light source 5 is placed between the second camera 2 and the display screen of the electronic scale 8. A second light source 4 is placed in the middle and fixed in position for collecting images on the electronic scale display screen; the first light source 5 and the second light source 4 are connected to the light source controller 6 through a signal line, the light source controller 6 is connected to the relay 10 through a signal line, the first camera 1 and the second camera 2 are connected to the host 13 through a network cable, the first camera 1, the second camera 2 and the relay 10 are all connected to the signal generator 12 through a signal line, the relay 10 is connected to the power supply step-down module 11 through a signal line, the signal generator 12 is connected to the host 13 through a signal line, and the first camera 1, the second camera 2, the power supply step-down module 11, the light source controller 6, the host 13 and the electronic scale 8 are all connected to the power supply 14 through a power line.
[0034] The host 13 and the signal generator 12 perform serial communication through a data line. The host 13 sends data. After receiving the data, the signal generator 12 sends a high level to the relay 10, and the relay 10 changes from a normally open state to a closed state. The power step-down module 11 provides voltage to the relay 10, and the light source controller 6 triggers the first light source 5 and the second light source 4, so that the first light source 5 and the second light source 4 change from an off state to a bright state; after a certain delay, the signal generator 12 sends a high level to the first camera 1 and the second camera 2, and the first camera 1 and the second camera 2 are both triggered to collect images; after a certain delay, the signal generator 12 sends a low level to the relay 10, the first camera 1 and the second camera 2, and the relay 10 changes from a closed state to a normally open state, so that the first light source 5 and the second light source 4 change from a bright state to an off state.
[0035] The parameter setting module M2 is used to set the parameters such as the variety, shape, grading size and grading thousand-pear weight of the peanuts to be graded; the signal control module M3 is used to control the host 13 in the hardware module M1 to communicate with the signal generator 12 via the serial port; the peanut image acquisition module M4 is used to acquire the image of the shelled peanuts spread on the electronic scale tray 9 through the first camera 1 in the hardware module M1; the camera calibration module M5 is used to calibrate the first camera 1 in the hardware module M1 to obtain the distortion coefficient, so as to facilitate the subsequent processing to eliminate the image distortion; the color correction module M6 is used to obtain the color correction matrix, so as to facilitate the subsequent correction of the color of the shelled peanut image to make the color more realistic and natural; the image correction module M7 is used to calibrate the first camera 1 The collected image of shelled peanuts is subjected to distortion correction and color correction to obtain a corrected image of shelled peanuts; the peanut image segmentation and defect detection module M8 is used to detect whether there are defects such as black spots and blackheads in the entire corrected image of shelled peanuts and obtain a single image of shelled peanuts; the peanut shape detection module M9 is used to calculate the shape similarity between shelled peanuts and standard peanuts, as well as the shape similarity mean and shape similarity uniformity; the peanut size measurement module M10 is used to measure the length of shelled peanuts and calculate the length mean and length uniformity; the peanut weighing module M11 is used to obtain the thousand-pearl weight of shelled peanuts; the peanut grading module M12 is used to grade and evaluate the shelled peanuts according to their defects, shape similarity, size and thousand-pearl weight.
[0036] The parameter setting module M2, signal control module M3, peanut image acquisition module M4, camera calibration module M5, color correction module M6, image correction module M7, peanut image segmentation and defect detection module M8, peanut shape detection module M9, peanut size measurement module M10, peanut weighing module M11 and peanut grading module M12 are all installed in the host 13 of the hardware module M1.
[0037] The peanut image segmentation and defect detection module M8 detects whether there are defects such as black spots and blackheads from the whole image of shelled peanuts after distortion correction and color correction through the trained instance segmentation model based on deep learning, and separates each shelled peanut to generate multiple single peanut images containing only one shelled peanut. The steps of generating a single peanut image containing only one shelled peanut are as follows: first, the bounding rectangle of each peanut and the corresponding mask image are obtained through the instance segmentation model; then, according to the bounding rectangle, a single peanut image is cut out from the whole image of shelled peanuts after distortion correction and color correction, but the single peanut image at this time may contain other peanut partial images; finally, in order to obtain an image containing only one shelled peanut, the single peanut image and the mask image are logically ANDed to generate a single peanut image containing only one shelled peanut.
[0038] The specific process of the peanut shape detection module M9 obtaining the shape similarity mean and shape similarity uniformity of the shelled peanuts is as follows: extracting the outer contour of the shelled peanuts in each single peanut image, calculating the similarity of each contour with the standard peanut contour, obtaining the shape similarity of each shelled peanut with the standard peanut, and then calculating the mean and standard deviation of the shape similarity of all shelled peanuts to obtain the shape similarity mean and shape similarity uniformity of all shelled peanuts.
[0039] The peanut shape similarity X is calculated by equation (1) and equation (2):
[0040]
[0041] Where: K is the number of contour points, s(k) is the complex sequence of contour points, a 1 (u) is the Fourier descriptor after standard peanut normalization, a 2 (u) is the Fourier descriptor after peanut normalization with rating, n 1 is the number of standard peanut outline points, n 2 It is a rating peanut outline point.
[0042] Shape similarity mean S and shape similarity uniformity S D Calculated by formula (3) and formula (4):
[0043]
[0044] Where: N is the number of peanuts, X is i is the shape similarity of the i-th peanut.
[0045] The specific process of the peanut size measurement module M10 obtaining the length mean and length uniformity of all shelled peanuts is as follows: extracting the minimum circumscribed rectangle of the shelled peanuts in each single peanut image, multiplying the length of the longer side of the minimum circumscribed rectangle by the pixel equivalent, and obtaining the length size of each shelled peanut in mm; then calculating the mean and standard deviation of the length sizes of all shelled peanuts to obtain the length mean and length uniformity of all shelled peanuts.
[0046] Mean length L and length uniformity L D Calculated by formula (5) and formula (6):
[0047]
[0048] Where: N is the number of peanuts, Y is i is the length of the i-th peanut, in mm.
[0049] The specific process of the peanut weighing module M11 obtaining the thousand-pearl weight of peanuts is as follows: using the second camera 2 to capture the image of the display screen on the electronic scale 8, detecting the text area, using the deep learning-based OCR text recognition model to perform text detection and recognition in the text area, obtaining the weight of the unshelled peanuts to be rated on the tray 9 above the electronic scale 8, and then converting it into the weight of 1000 peanuts according to the number of peanuts to obtain the thousand-pearl weight. The thousand-pearl weight T of peanuts is calculated by formula (7):
[0050]
[0051] Where: M is the weight of the in-shell peanuts to be rated, in grams; N is the number of peanuts.
[0052] The peanut grading module M12 assesses the peanuts to be graded into corresponding grades according to the established grading standards for shelled peanuts, the defect detection status obtained by the peanut image segmentation and defect detection module M8, the similarity mean and similarity uniformity of the shape similarity obtained by the peanut shape detection module M9, the length mean and length uniformity obtained by the peanut size measurement module M10, and the thousand-pearl weight obtained by the peanut weighing module M11.
[0053] The peanut grading standards are shown in Table 1:
[0054] Table 1 Peanut rating standards
[0055] grade defect <![CDATA[S mean ]]> <![CDATA[S Dmean ]]> <![CDATA[L mean ]]> <![CDATA[L Dmean ]]> <![CDATA[T mean ]]> First-class products none <![CDATA[≥S 1 ]]> <![CDATA[≤S D1 ]]> <![CDATA[≥L 1 ]]> <![CDATA[≤L D1 ]]> <![CDATA[≥T 1 ]]> Second-class products none <![CDATA[≥S 2 ]]> <![CDATA[≤S D2 ]]> <![CDATA[≥L 2 ]]> <![CDATA[≤L D2 ]]> <![CDATA[≥T 2 ]]> Third grade none <![CDATA[≥S 3 ]]> <![CDATA[≤S D3 ]]> <![CDATA[≥L 3 ]]> <![CDATA[≤L D3 ]]> <![CDATA[≥T 3 ]]> Substandard products have <![CDATA[<S 3 ]]> <![CDATA[>S D3 ]]> <![CDATA[<L 3 ]]> <![CDATA[>L D2 ]]> <![CDATA[<T 1 ]]>
[0056] S mean is the mean of the shape similarity means; S Dmean is the mean value of shape similarity uniformity; L mean is the mean of the length means; L Dmean is the mean value of length uniformity; T mean is the mean of the weight of 1,000 peanuts. The mean of the shape similarity is S mean ≥S 1 , the mean value S of shape similarity uniformity Dmean ≤S D1 , the mean of the length means L mean ≥L 1 , the mean value of length uniformity L Dmean ≤L D1 , the mean value of the weight of 1,000 particles is T mean ≥T 1 , then it is a first-class product; the peanuts are flawless, and the mean of the similarity means is S mean ≥S 2 , the mean value S of similarity uniformity Dmean ≤S D2 , the mean of the length means L mean ≥L2 , the mean value of length uniformity L Dmean ≤L D2 , the mean value of the weight of 1,000 particles is T mean ≥T 2 , then it is a second-class product; the peanuts are flawless, and the mean of the similarity means is S mean ≥S 3 , the mean value S of similarity uniformity Dmean ≤S D3 , the mean of the length means L mean ≥L 3 , the mean value of length uniformity L Dmean ≤L D3 , the mean value of the weight of 1,000 particles is T mean ≥T 3 , then it is a third-class product; if the peanuts have defects, they are substandard products; if one of the mean of the mean of the similarity mean, the mean of the similarity uniformity, the mean of the length mean, the mean of the length uniformity, and the mean of the thousand-pearl weight of the peanuts does not meet the minimum standard, the peanuts will be rated as substandard products; if one of the mean of the similarity mean, the mean of the similarity uniformity, the mean of the length mean, the mean of the length uniformity, and the mean of the thousand-pearl weight of the peanuts does not meet the same grade standard, the peanuts will be rated as a grade that meets the lower standard among the five, among which S 1 , S 2 and S 3 is the mean classification threshold of the mean peanut shape similarity, S D1 , S D2 and S D3 is the mean classification threshold of peanut shape similarity uniformity, L 1 , L 2 and L 3 is the mean classification threshold of the mean peanut length, L D1 , L D2 and L D3 is the mean classification threshold of the mean peanut length, T 1 , T 2 and T 3 is the mean classification threshold of the thousand-peanut weight.
[0057] A method for grading peanuts in shells using the peanut grading system of the present invention, such as Figure 3 As shown, the following steps are included:
[0058] Step 1: Set the variety, standard shape, grading size, grading thousand-pearl weight and other parameters of the peanuts to be graded through the parameter setting module M2, and load the corresponding instance segmentation model; obtain the distortion coefficient of the first camera 1 through the camera calibration module M5 using the calibration plate placed on the electronic scale tray 9; obtain the color correction matrix through the color correction module M6 using the standard color card placed on the tray 9 of the electronic scale 8.
[0059] Step 2: Randomly select a certain number of shelled peanuts from the shelled peanuts to be graded and evaluated, and spread them flat on the tray 9 of the electronic scale 8.
[0060] Step 3: Use the peanut image acquisition module M4 to acquire the image of the peanuts in shells spread on the tray 9 of the electronic scale 8 through the first camera 1 .
[0061] Step 4: Use the image correction module M7 to perform distortion correction and color correction on the collected image of the peanuts in shells to obtain a corrected image of the peanuts in shells.
[0062] Step 5: Use the peanut image segmentation and defect detection module M8 to perform defect detection on the corrected shelled peanut image and segment each peanut from the entire image to obtain individual shelled peanut images. If there are defective shelled peanuts, the peanut grading module M12 is directly used to grade the shelled peanuts to be graded, and the grading is completed; otherwise, proceed to the next step 6.
[0063] Step 6: The shape similarity between each shelled peanut and the standard peanut is calculated by the peanut shape detection module M9, and then the mean and standard deviation of the shape similarity of all shelled peanuts are obtained to obtain the shape similarity mean S and shape similarity uniformity S of all shelled peanuts. D .
[0064] Step 7: Calculate the length of each shelled peanut through the peanut size measurement module M10, and then calculate the mean and standard deviation of the length of all shelled peanuts to obtain the length mean L and length uniformity L of all shelled peanuts. D .
[0065] Step 8: The weight of the unshelled peanuts to be rated placed on the tray 9 of the electronic scale 8 is obtained through the peanut weighing module M11, and converted into the weight of 1000 peanuts according to the number of peanuts to obtain the thousand-pearl weight T.
[0066] Step 9: Perform steps 2 to 8 three times, and calculate the mean S of the three shape similarity means. mean And the mean S of shape similarity uniformity Dmean , the mean of the 3rd length means L mean And the mean value L of length uniformity Dmean And the average value T of 3 thousand weights mean , the peanut grading module M12 is used to grade the shelled peanuts to be graded, and the grading is completed.
[0067] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A peanut grading system in shell, mainly composed of a hardware module, a parameter setting module, a signal control module, a peanut image acquisition module, a camera calibration module, a color correction module, an image correction module, a peanut image segmentation and defect detection module, a peanut shape detection module, a peanut size measurement module, a peanut weighing module, and a peanut grading module, characterized in that: The hardware module includes a first camera, a second camera, a first light source, a second light source, a light source controller, a relay, an electronic scale, a signal generator, a host, a gantry, a tray, a platform, a power supply voltage reduction module and a power supply; the first camera and the second camera are both fixed on the gantry and can be adjusted up, down, left and right, and the gantry is fixed on the platform; an electronic scale is placed directly below the first camera and aligned with the tray above the electronic scale, a first light source is placed between the first camera and the electronic scale, and the position is fixed for collecting peanut images; the second camera is aligned with the display screen of the electronic scale, a second light source is placed between the second camera and the display screen of the electronic scale, and the position is fixed for collecting images of the electronic scale display screen; the first light source and the second light source are connected to the light source controller through a signal line, the light source controller is connected to the relay through a signal line, the first camera and the second camera are connected to the host through a network cable, the first camera, the second camera and the relay are connected to the signal generator through a signal line, the relay is connected to the power supply voltage reduction module through a signal line, the signal generator is connected to the host through a signal line, and the first camera, the second camera, the power supply voltage reduction module, the light source controller, the host and the electronic scale are all connected to the power supply through a power line; The host and the signal generator communicate with each other via a data line. The host sends data. After receiving the data, the signal generator sends a high level to the relay, and the relay changes from a normally open state to a closed state. The power supply step-down module provides voltage to the relay, and the light source controller triggers the first light source and the second light source, so that the first light source and the second light source change from an off state to a bright state. After a certain delay, the signal generator sends a high level to the first camera and the second camera, and the first camera and the second camera are both triggered to collect images. After a certain delay, the signal generator sends a low level to the relay, the first camera, and the second camera, and the relay changes from a closed state to a normally open state, so that the first light source and the second light source change from a bright state to an off state. The parameter setting module is used to set parameters such as the variety, shape, grading size and grading thousand-pear weight of the peanuts to be graded; the signal control module is used to control the host in the hardware module to communicate with the signal generator via the serial port; the peanut image acquisition module is used to acquire the image of the shelled peanuts spread on the electronic scale tray through the first camera in the hardware module; the camera calibration module is used to calibrate the first camera in the hardware module to obtain the distortion coefficient, so as to facilitate the subsequent processing to eliminate the image distortion; the color correction module is used to obtain the color correction matrix, so as to facilitate the subsequent correction of the color of the shelled peanut image to make the color more real and natural; the image correction module is used to calibrate the shelled peanuts acquired by the first camera. The raw image is subjected to distortion correction and color correction to obtain a corrected image of peanuts in shells; the peanut image segmentation and defect detection module is used to detect whether there are defects such as black spots and blackheads from the entire corrected image of peanuts in shells and obtain a single image of peanuts in shells; the peanut shape detection module is used to calculate the shape similarity between peanuts in shells and standard peanuts, as well as the shape similarity mean and shape similarity uniformity; the peanut size measurement module is used to measure the length of peanuts in shells and calculate the length mean and length uniformity; the peanut weighing module is used to obtain the thousand-pearl weight of peanuts in shells; the peanut grading module is used to grade and evaluate the peanuts in shells according to their defects, shape similarity, size and thousand-pearl weight; The parameter setting module, signal control module, peanut image acquisition module, camera calibration module, color correction module, image correction module, peanut image segmentation and defect detection module, peanut shape detection module, peanut size measurement module, peanut weighing module and peanut grading module are all installed in the host of the hardware module.
2. A peanut grading system in shell according to claim 1, characterized in that: The peanut image segmentation and defect detection module uses a trained deep learning-based instance segmentation model to detect whether there are defects such as black spots and blackheads in the entire image of shelled peanuts after distortion correction and color correction, and separates each shelled peanut to generate multiple single peanut images containing only one shelled peanut.
3. The peanut grading system according to claim 1, characterized in that: The peanut shape detection module extracts the outer contour of the shelled peanuts in each single peanut image, calculates the similarity between each contour and the standard peanut contour, obtains the shape similarity between each shelled peanut and the standard peanut, and then obtains the mean and standard deviation of the shape similarity of all shelled peanuts to obtain the shape similarity mean and shape similarity uniformity of all shelled peanuts.
4. The peanut grading system according to claim 1, characterized in that: The peanut size measurement module extracts the minimum circumscribed rectangle of the in-shell peanuts in each single peanut image, multiplies the length of the longer side of the minimum circumscribed rectangle by the pixel equivalent, and obtains the length size of each in-shell peanut in mm; then calculates the mean and standard deviation of the length sizes of all in-shell peanuts to obtain the length mean and length uniformity of all in-shell peanuts.
5. The peanut grading system according to claim 1, characterized in that: The peanut weighing module uses the second camera to capture the image of the electronic scale display screen and adopts the OCR text recognition model based on deep learning to obtain the weight of the shelled peanuts to be rated on the electronic scale tray, and then converts it into the weight of 1,000 peanuts according to the number of peanuts to obtain the thousand-pearl weight.
6. The peanut grading system according to claim 1, characterized in that: The peanut grading module is based on the established grading standards for shelled peanuts, and according to the defect detection status obtained by the peanut image segmentation and defect detection module, the similarity mean and similarity uniformity of the shape similarity obtained by the peanut shape detection module, the length mean and length uniformity obtained by the peanut size measurement module, and the thousand-pearl weight obtained by the peanut weighing module, the peanuts to be graded are rated into corresponding grades.
7. A method for grading peanuts in shells, characterized by: Use the in-shell peanut grading system according to any one of claims 1 to 7, and perform the following steps: Step 1: Set the variety, standard shape, grading size, and grading thousand-pear weight of the peanuts to be graded through the parameter setting module, and load the corresponding instance segmentation model; obtain the distortion coefficient of the first camera through the camera calibration module using the calibration plate placed on the electronic scale tray; obtain the color correction matrix through the color correction module using the standard color card placed on the electronic scale tray; Step 2: Randomly select a certain number of in-shell peanuts from the in-shell peanuts to be graded and evaluated, and lay them flat on the electronic scale tray; Step 3: using the peanut image acquisition module to acquire images of the peanuts in shells laid out on the electronic scale tray through the first camera; Step 4: Use the image correction module to perform distortion correction and color correction on the collected peanuts in shell image to obtain a corrected peanuts in shell image; Step 5: Use the peanut image segmentation and defect detection module to perform defect detection on the corrected peanut image in shell and segment each peanut from the entire image to obtain each single peanut image in shell. If there are defective peanuts in shell, the peanut grading module is directly used to grade the peanuts in shell to be graded, and the grading is completed; otherwise, proceed to the next step 6; Step 6: Calculate the shape similarity between each in-shell peanut and the standard peanut through the peanut shape detection module, then calculate the mean and standard deviation of the shape similarity of all in-shell peanuts, and obtain the shape similarity mean and shape similarity uniformity of all in-shell peanuts; Step 7: Calculate the length of each shelled peanut through the peanut size measurement module, then calculate the mean and standard deviation of the length of all shelled peanuts, and obtain the mean length and length uniformity of all shelled peanuts; Step 8: Obtain the weight of the unshelled peanuts to be rated placed on the electronic scale tray through the peanut weighing module, and convert it into the weight of 1,000 peanuts according to the number of peanuts to obtain the thousand-pearl weight; Step 9: Steps 2 to 8 are performed three times in total. The mean of the three shape similarity means and the mean of the shape similarity uniformity, the mean of the three length means and the mean of the length uniformity, and the mean of the three thousand-pearl weights are calculated. The peanut grading module is used to grade the shelled peanuts to be graded, and the grading is completed.
Citation Information
Cited By
Nut quality detection and analysis method based on visual technology
CN120668658A
A nut quality detection and analysis method based on visual technology
CN120668658B