Pepper plug seeding quality detection method and storage medium
By combining single-cell training with whole-tray detection using deep learning methods, the problems of low efficiency and large errors in the quality detection of pepper tray sowing have been solved, achieving efficient and accurate automatic detection of sowing quality, which is suitable for seedling sowing production lines.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINESE ACAD OF AGRI MECHANIZATION SCI GRP CO LTD
- Filing Date
- 2024-12-09
- Publication Date
- 2026-05-29
AI Technical Summary
The existing methods for detecting the quality of chili seedlings in trays mainly rely on manual observation, which is inefficient, prone to errors, and unable to provide real-time feedback. In particular, during automated seeding processes, missed sowing and double sowing are likely to occur, affecting the quality of seedlings.
Combining single-cell training and whole-plate detection methods, a deep learning object detection network is used to detect the quality of chili seed tray planting. A relative pixel loss function is used to improve the accuracy of small object recognition, and efficient inference is achieved through ONNX and TensorRT acceleration libraries. Automatic detection is performed in conjunction with PC-based host software.
It has achieved automated detection of the quality of chili seed tray sowing, improving detection efficiency and accuracy. It can provide real-time feedback on sowing quality, adapt to the detection of irregular small targets, and has portability and efficient reasoning capabilities.
Smart Images

Figure CN119722626B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to sowing quality detection technology, and in particular to a method and storage medium for detecting the sowing quality of chili pepper seed trays based on deep learning. Background Technology
[0002] Chili seeds are small and flat, making them prone to missed sowing and double sowing during automated seeding processes, which affects seedling quality and subsequent growth. Current seeding quality monitoring mainly relies on manual observation and sampling calculations, requiring constant visual monitoring of the sowing process. This approach suffers from high workload, low efficiency, large errors, and a lack of real-time feedback.
[0003] In recent years, with the development of computer vision and deep learning technologies, image recognition-based target detection methods have gradually become a research hotspot. Deep learning algorithms utilize convolutional neural networks to predict seeding quality results, calculating the quantity and location information of detected targets, and are characterized by high accuracy and efficiency. For seeding quality detection in seed trays, deep learning target detection algorithms mainly employ two methods: "whole tray training + whole tray detection" and "single-cell training + single-cell detection + result stitching." Whole tray training requires more labeled data, increasing training costs, while single-cell training can utilize less labeled data, improving training efficiency; however, whole tray detection is more efficient than single-cell detection, and its post-processing is also more convenient. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a method and storage medium for detecting the quality of chili seed tray sowing, which addresses the above-mentioned deficiencies of the prior art.
[0005] To achieve the above objectives, the present invention provides a method for detecting the quality of chili pepper tray sowing, wherein the method combines single-cell training with whole-tray detection to detect the quality of chili pepper tray sowing, and includes the following steps:
[0006] S100. Collect images of chili seeds after seed tray sowing and extract individual cell images. Perform data augmentation on the individual cell images, label the chili seed outlines of the individual cells, and create training and testing sets.
[0007] S200. Construct a deep learning object detection network, introduce the relative pixel loss function into the deep learning object detection network, train the deep learning object detection network using training set data, and judge the training iteration results.
[0008] S300. Load the optimal weight file from the training iteration into the target detection algorithm of the deep learning target detection network, input the whole image of the chili seed tray after sowing, perform whole-tray detection, and set the image size adjustment step size to obtain the size adjustment parameters when the detection time and accuracy are optimal.
[0009] S400: Based on the size adjustment parameters obtained in step S300, set the target detection algorithm weights and size adjustment parameters, input the online acquired images into the constructed target detection algorithm for sowing quality detection, output the total number of seeds in the tray and the coordinate center point, and calculate the single seed rate, replanting rate, and missed seed rate of each tray of chili seeds based on the specifications of the chili seed trays to be detected; and
[0010] S500: Based on the calculation results of step S400, calculate the average single seed rate, average replanting rate, and average missed seed rate of all pepper seeds under the current sowing task to detect the current overall sowing quality.
[0011] The above-mentioned method for testing the quality of chili seed tray sowing also includes the following steps:
[0012] S600. Calculate the consistency variation coefficient of each row under the current sowing task, as the basis for subsequent quality control judgment.
[0013] The above-mentioned method for detecting the quality of chili pepper tray sowing, wherein step S400 further includes:
[0014] S401. Convert the pepper seed tray sowing quality detection model into the ONNX open neural network exchange format, and combine it with the TensorRT acceleration library to achieve efficient inference.
[0015] S402. Divide and calculate the coordinates of the detected chili seed center points, and construct a seed distribution matrix corresponding to the seed tray positions; and
[0016] S403. If the number of seeds detected in the same area is 0, it is determined to be a missed sowing; if the number of seeds detected in the same area is 1, it is determined to be a single seed; if the number of seeds detected in the same area is greater than 1, it is determined to be a re-sowing.
[0017] The above-mentioned method for detecting the quality of chili seed tray sowing, wherein step S100 further includes:
[0018] S101. After selecting the acupuncture point image, remove invalid areas based on the main distribution area of the acupuncture point to obtain the processed image; and
[0019] S102. Using the OpenCV library, set up a template matching script to extract individual images from the processed image and merge randomly cropped rich data to obtain multiple individual images.
[0020] The above-mentioned method for detecting the quality of chili seed tray sowing, wherein step S100 further includes:
[0021] S103. Data enhancement is performed on the extracted single-cell images using brightness transformation, random flipping, contrast enhancement, and random scaling, with an amplification ratio of 25% to 35%.
[0022] S104. Divide the enhanced overall single-cell image data into training and test sets according to an 8:2 ratio; and
[0023] S105. Labelme software is used to label the chili seeds in each individual image in the training set, generating a .txt file.
[0024] The above-mentioned method for detecting the quality of chili seed tray sowing includes, in the .txt file, information such as category, center coordinates of the horizontal axis of the labeled object, center coordinates of the vertical axis of the labeled object, width, and height.
[0025] The above-mentioned method for detecting the quality of chili seed tray sowing, wherein step S200 further includes:
[0026] S201. The average pixel size of chili seeds in the dataset is 30 pixels × 30 pixels. A targeted relative pixel loss function is introduced to improve the recognition accuracy and improve the IoU measure of the offset tolerance of small target positions.
[0027] S202. Perform training, observe the result curve, and determine whether the target detection algorithm has converged during training and whether the accuracy meets the requirements.
[0028] S203. Load the trained weight file into the object detection algorithm and test it on the test set to observe the actual detection effect; and
[0029] S204. If the detection results do not meet the actual requirements, increase the number of training iterations, or recreate and expand the dataset, and retrain and test according to steps S201 to S203 until a weight file that meets the required accuracy is trained.
[0030] The above-mentioned method for detecting the quality of chili seed tray sowing, wherein step S201 further includes:
[0031] S011, Set the center point of the target ground truth bounding box in the dataset annotation to X. o Y o The relative width and height are w o h o The center point of the network prediction box is X. z Y z The relative width and height are w z h z ;
[0032] S2012, The Euclidean distance between the center point of the network predicted bounding box and the center point of the target ground truth bounding box is: Dc 2 =(X z -X o ) 2 +(Y z -Y o ) 2 ;
[0033] S2013, Set the width and height dimensions to D. l 2 =(w z -w o ) 2 +(h z -h o ) 2 To avoid the prediction boxes having no overlap and an IoU of 0;
[0034] S2014, Set the largest boundary dimension unified divisor term to D. f 2 =max(w z , w o ) 2 +max(h z , h o ) 2 To eliminate the influence of dimensions;
[0035] S2015, then the relative pixel loss Pxi.Loss is:
[0036] ;
[0037] S2016. Normalize the relative pixel loss using the exponential function of e, and the result is a similarity measure with a value range of (0, 1].
[0038] ;
[0039] Where λ is the constant normalization coefficient.
[0040] The above-mentioned method for detecting the quality of chili pepper tray sowing, wherein step S300 further includes:
[0041] S301. Load the optimal weight file into the target detection algorithm;
[0042] S302. Based on the downsampling times k of the target detection algorithm, determine the overall disk size change step size as 2. k Pixels, the original dimensions width w and height h are adjusted proportionally, with an adjustment ratio R. a =2 k f ceil (max(w, h) / 2 kf(w, h) + n) / max(w, h), where f ceil (*) is the floor function, n is the size adjustment variable coefficient, and its value is an integer; and
[0043] S303. Change the variable coefficient n for size adjustment, observe the algorithm inference time and accuracy, and select the variable coefficient value for size adjustment that provides the highest detection accuracy at the required detection speed.
[0044] To better achieve the above objectives, the present invention also provides a storage medium storing a computer program configured to execute the above-described method for detecting the quality of chili seed tray sowing.
[0045] The technical advantages of this invention are as follows:
[0046] This invention enables automatic detection and data calculation of the sowing quality of pepper seeds in seed trays after sowing. To facilitate integrated application and improve detection efficiency and accuracy, a deep learning framework is used to perform pepper seed target detection. The deep learning algorithm is improved to adapt to the detection of irregularly shaped small pepper seeds, facilitating expansion and application. Furthermore, single-cell images are used for algorithm training, effectively reducing the number of samples and significantly improving the efficiency of the preliminary work; whole-tray images are used for result prediction to ensure the algorithm's inference speed. This invention provides a fast and feasible technical solution for detecting various features of pepper seed tray sowing quality, improving task performance while simultaneously ensuring accuracy and real-time performance; the introduction of a relative pixel loss function Pxi.Loss for small-target pepper seed identification effectively reduces the sensitivity to prediction box positioning offset. Compared to single Euclidean distance metrics or existing bounding box loss methods, the introduction of a unified divisor term with the maximum boundary dimension for balancing maintains the advantage of higher weights for small target boxes under the same distance offset. Its deep learning network is portable, and can be converted to the ONNX universal format to run on a host computer, achieving efficient inference in combination with the TensorRT acceleration library. The host computer software is written in Python, which facilitates cross-platform portability and provides an end-to-end computer application.
[0047] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the present invention. Attached Figure Description
[0048] Figure 1 This is a schematic diagram illustrating the working principle of an embodiment of the present invention;
[0049] Figure 2A-2C This is a schematic diagram of the process of acquiring a single cell image of the acupoint plate according to an embodiment of the present invention;
[0050] Figures 3A-3BThis is a schematic diagram of a single cell image of the acupuncture point plate extracted according to an embodiment of the present invention and the annotation file;
[0051] Figure 4 This is a schematic diagram of the relative pixel loss function according to an embodiment of the present invention;
[0052] Figure 5 This is a schematic diagram illustrating the training results of a deep learning target detection algorithm based on single-cell image data of chili seeding trays according to an embodiment of the present invention.
[0053] Figure 6 This is a schematic diagram illustrating the whole-disk image size adjustment operation during whole-disk testing according to an embodiment of the present invention;
[0054] Figure 7 This is a schematic diagram illustrating the porting of a target detection model to host computer software according to an embodiment of the present invention;
[0055] Figure 8 This is a schematic diagram of the detection and counting results according to an embodiment of the present invention;
[0056] Figure 9 A schematic diagram illustrating the calculation of the coefficient of variation for each row;
[0057] Figures 10A-10B This is an image illustrating the effect of detecting the seeding quality of chili pepper seeds in a tray according to an embodiment of the present invention. Detailed Implementation
[0058] The structural and working principles of the present invention will be described in detail below with reference to the accompanying drawings:
[0059] See Figure 1 , Figure 1 This is a schematic diagram illustrating the working principle of an embodiment of the present invention. The method for detecting the quality of chili pepper tray sowing in the present invention combines single-cell training with whole-tray testing to detect the quality of chili pepper tray sowing, and includes the following steps:
[0060] Step S100: Collect images of chili seeds after seed tray sowing and extract individual cell images. Perform data augmentation on the individual cell images by random flipping, color changing, random scaling and translation. Mark the outline of the chili seeds in the individual cells and create training and test sets.
[0061] Step S200: Construct a deep learning object detection network, introduce the relative pixel loss function into the deep learning object detection network, train the deep learning object detection network using training set data, and judge the training iteration results;
[0062] Step S300: Load the optimal weight file from the training iterations into the target detection algorithm of the deep learning target detection network, input the whole image of the chili seed tray after sowing, perform whole-tray detection, and simultaneously set the image size adjustment step size to obtain the size adjustment parameters when the detection time and accuracy are optimal.
[0063] Step S400: The quality of chili pepper tray sowing is detected by taking pictures. A chili pepper tray sowing quality detection model is used to identify the overall sowing quality of the chili peppers in the tray. Based on the size adjustment parameters obtained in step S300, the weights and size adjustment parameters of the target detection algorithm are set. The online acquired images are input into the constructed target detection algorithm for sowing quality detection, outputting the total number of seeds in the tray and the coordinate center point. Combined with the specifications of the chili pepper trays to be detected, the single seed rate, replanting rate, and missed seed rate of each tray are calculated. That is, the weights and size adjustment parameters of the target detection algorithm (algorithm hyperparameters, i.e., in machine learning) are set according to the above results. In learning and deep learning algorithms, parameters need to be pre-set before training the model. These parameters are not learned through the model training process itself, but are set based on experience, domain knowledge, experiments, or heuristics. They control the overall behavior and performance of the algorithm, such as the learning speed and model complexity. This data is then loaded into host computer software, and a computer application is designed to identify the overall seeding quality of chili peppers in a tray, outputting the total number of seeds in the tray and the coordinate center point. Combined with the tray specifications used (e.g., a 72-cell standard seedling tray: 12 rows × 6 columns), the single-seed rate, replanting rate, and missed seeding rate of chili pepper seeds sown in each tray are calculated.
[0064] Step S500: Based on the calculation results of step S400, calculate the average single seed rate, average replanting rate, and average missed seed rate of all pepper seeds under the current sowing task to detect the current overall sowing quality.
[0065] This embodiment also includes the following steps:
[0066] Step S600: Calculate the consistency variation coefficient of each row under the current sowing task, as the basis for subsequent quality control judgment.
[0067] Step S100 further includes:
[0068] Step S101: Remove invalid areas from the selected acupuncture plate images based on the main distribution area of the acupuncture plate to obtain the processed images;
[0069] Step S102: Using the OpenCV library, set up a template matching script to extract individual images from the processed image and fuse randomly cropped rich data to obtain multiple individual images;
[0070] Step S103: Data augmentation is performed on the extracted single-cell image using brightness transformation, random flipping, contrast enhancement, and random scaling, with an augmentation ratio of 25%~35%;
[0071] Step S104: Divide the enhanced overall single-cell image data into training and test sets according to an 8:2 ratio; and
[0072] Step S105: Use Labelme software to label the chili seeds in each individual image in the training set, generating a .txt file. The .txt file includes the category, the center coordinates of the labeled object's horizontal axis, the center coordinates of the labeled object's vertical axis, width, and height information.
[0073] Step S200 further includes:
[0074] Step S201: The average pixel size of chili seeds in the dataset is 30 pixels × 30 pixels. A targeted relative pixel loss function is introduced to improve the recognition accuracy and improve the IoU measure of the offset tolerance of small target positions.
[0075] Step S202: Perform training, observe the result curve, and determine whether the target detection algorithm has converged and whether the accuracy meets the requirements.
[0076] Step S203: Load the trained weight file into the object detection algorithm and test it on the test set to observe the actual detection effect; and
[0077] Step S204: If the detection results do not meet the actual requirements, increase the number of training iterations, or recreate and expand the dataset, and retrain and test according to steps S201 to S203 until a weight file that meets the required accuracy is trained.
[0078] Step S201 further includes:
[0079] Step S2011: Set the center point of the target ground truth bounding box in the dataset annotation to X. o Y o The relative width and height are w o h o The center point of the network prediction box is X. z Y z The relative width and height are w z h z ;
[0080] Step S2012: The Euclidean distance between the center point of the network predicted bounding box and the center point of the target ground truth bounding box is: D c 2 =(X z -X o ) 2+(Y z -Y o ) 2 ;
[0081] Step S2013: Set the width and height dimensions to D. l 2 =(w z -w o ) 2 +(h z -h o ) 2 To avoid the prediction boxes having no overlap and an IoU of 0;
[0082] Step S2014: Set the largest boundary dimension unified divisor term to D. f 2 =max(w z , w o ) 2 +max(h z , h o ) 2 To eliminate the influence of dimensions;
[0083] Step S2015, then the relative pixel loss Pxi.Loss is:
[0084] ;
[0085] Step S2016: Normalize the relative pixel loss using the exponential function of e, resulting in a similarity measure with a value range of (0, 1].
[0086] ;
[0087] Where λ is the constant normalization coefficient.
[0088] Step S300 further includes:
[0089] Step S301: Load the optimal weight file into the target detection algorithm;
[0090] Step S302: Based on the downsampling times k of the target detection algorithm, determine the overall disk size change step size as 2. k Pixels, the original dimensions width w and height h are adjusted proportionally, with an adjustment ratio R. a =2 k f ceil (max(w, h) / 2 k f(w,h) + n) / max(w,h), where f ceil (*) is the floor function, n is the size adjustment variable coefficient, and its value is an integer; and
[0091] Step S303: Change the variable coefficient n for size adjustment, observe the algorithm inference time and accuracy, and select the variable coefficient value for size adjustment that achieves the highest detection accuracy at the required detection speed.
[0092] Step S400 further includes:
[0093] Step S401: Convert the pepper seed tray sowing quality detection model into the ONNX open neural network exchange format, and combine it with the TensorRT acceleration library to achieve efficient inference;
[0094] Step S402: Divide and calculate the coordinates of the detected chili seed center points, and construct a Matrix seed distribution matrix corresponding to the seed tray positions; and
[0095] Step S403: If the number of seeds detected in the same area is 0, it is determined to be a missed sowing; if the number of seeds detected in the same area is 1, it is determined to be a single seed; if the number of seeds detected in the same area is greater than 1, it is determined to be a re-sowing.
[0096] The method for detecting the quality of chili seed tray sowing according to the present invention will be described in detail below with specific embodiments:
[0097] Example 1
[0098] See Figure 1 This invention employs a "single-cell training + whole-disk detection" approach, introducing a novel relative pixel distance, Pix.Loss, into the training loss function, specifically including:
[0099] Image acquisition was carried out after the chili seed trays were planted. Specifically, images of chili seeds after the seed trays were collected. The images were taken from actual field photos of chili seeds after the seed trays were planted. According to the technical conditions of greenhouse vegetable tray precision seeders NY / T 1823-2009, a total of 456 images were collected. Among them, the number of images of seeds planted in 72-cell and 128-cell standard seedling trays each accounted for 50%. All images were taken in actual seedling operation scenarios.
[0100] The process of extracting individual images from the acquired full-disc post-play images includes:
[0101] After selecting the acupuncture point images, invalid areas are removed based on the main distribution area of the acupuncture point.
[0102] Using the OpenCV library, a template matching script was written to extract individual images from the processed image and incorporate random cropping operations to improve data richness, resulting in 8064 individual images.
[0103] The acquired individual images underwent data augmentation, and the outlines of the chili seeds in each cell were labeled. Training and test sets were created. Specifically, the extracted individual images were augmented using brightness transformation, random flipping, contrast enhancement, and random scaling, with an augmentation ratio of 25% to 35%, resulting in a total of 10,682 augmented individual images. The augmented overall individual image data was then divided into training and test sets at an 8:2 ratio. Labelme software was used to label the chili seeds in each individual image in the training set, generating a .txt file containing information such as: category, the center coordinate of the labeled object's horizontal axis, the center coordinate of the labeled object's vertical axis, width, and height.
[0104] A relative pixel loss function is introduced into the deep learning object detection network. The network is trained using the training set data, and the training iteration results are evaluated. The average pixel size of chili seeds in the dataset is 30 pixels × 30 pixels. Compared to larger and medium-sized targets (such as corn and rice seeds), even a slight deviation in the predicted bounding box position of the small chili seed significantly reduces the Intersection over Union (IoU). A targeted relative pixel loss function is introduced to improve recognition accuracy and address the issue of low tolerance for IoU in measuring the positional offset of small targets. Specifically:
[0105] Let X be the center point of the ground truth bounding box labeled in the dataset. o Y o The relative width and height are w o h o The center point of the network prediction box is X. z Y z The relative width and height are w z h z The Euclidean distance between the two center points is: D c 2 =(X z -X o ) 2 +(Y z -Y o ) 2 The width and height dimensions are measured in D. l 2 =(w z -w o ) 2 +(h z -h o ) 2 To avoid the problem of non-overlapping prediction boxes and IoU of 0; the maximum boundary dimension unified divisor term is: D f 2 =max(w z , w o ) 2+max(h z , h o ) 2 To eliminate the influence of dimensions; the relative pixel loss Pxi.Loss is:
[0106] ;
[0107] Normalizing the relative pixel loss using the exponential function of e yields a similarity measure with a value range of (0, 1). Where λ is the constant normalization coefficient.
[0108] Then, training is performed, and the result curve is observed to determine whether the object detection algorithm has converged and whether the accuracy meets the requirements. The trained weight file is loaded into the object detection algorithm and tested on the test set to observe the actual detection effect. If the detection result does not meet the actual requirements, consider increasing the number of training iterations or recreating and expanding the dataset, and retraining and predicting according to the above steps until a weight file that meets the required accuracy is trained. The optimal weight file from the training iterations is loaded into the object detection algorithm, the entire image is input, and the entire image is detected. At the same time, the image size adjustment step size is set, and the size adjustment parameters when the detection time and accuracy are optimal are observed. Specifically, this includes:
[0109] Load the optimal weight file into the object detection algorithm; given the significant size difference between individual images and the entire image, determine the overall image size change step size to be 2, based on the algorithm's downsampling count k. k Pixels, then proportionally adjust the original dimensions width w and height h, where the adjustment ratio R a =2 k f ceil (max(w, h) / 2 k f(w, h) + n) / max(w, h), where f ceil (*) is the floor function, and n is the size adjustment variable coefficient, which is determined through experiments and takes an integer value. By changing the size adjustment variable coefficient n (e.g., taking a value of [-10, 20]), the algorithm inference time and accuracy are observed, and the size adjustment variable coefficient value with the highest detection accuracy at the required detection speed is selected.
[0110] Based on the above results, the weights and size adjustment parameters (algorithm hyperparameters) of the target detection algorithm are set. Combined with the acquisition device, the online acquired images are input into the constructed target detection algorithm for sowing quality detection. The algorithm outputs the total number of seeds in the tray and the coordinate center point. Based on the tray specifications used (e.g., a 72-cell standard seedling tray: 12 rows × 6 columns), the single-seed rate, replanting rate, and missed-sowing rate of chili seeds sown in each tray are calculated. Specifically, this includes: setting up the computer-based host computer software to perform chili tray sowing quality detection by capturing images; and converting the implemented chili tray sowing quality detection model into ONNX (OpenNeural Network) software. The software utilizes an open neural network exchange format (Exchange) combined with the TensorRT acceleration library to achieve efficient inference. The computer-side host software is written in Python, facilitating cross-platform portability. After successful compilation, the code is exported as an .exe executable file. After installation, the software can capture images using a portable camera or upload pre-collected images to complete the detection. Clicking "Start Task" initiates model preloading, with the middle image showing the detection screen. Clicking the "Detect" button displays the detection results for each image on the right and the average of all current detection results on the left. The software divides and calculates the coordinates of the detected chili seeds' center points. If the seed tray used is a 72-cell standard seedling tray (12 rows × 6 columns), a Matrix[12, 6] seed distribution matrix (corresponding to the 72 tray cell positions) is constructed: if the number of seeds detected in the same area is 0, it is considered a missed sowing; if the number of seeds detected in the same area is 1, it is considered a single seed (qualified); if the number of seeds detected in the same area is greater than 1, it is considered a re-sowing. Clicking the "Export Data" button exports the detection results to the local device as an Excel spreadsheet.
[0111] Based on the above results, the sowing quality (average single seed rate, average replanting rate, and average missed seed rate) of all chili seeds sown under the current sowing task is calculated to reflect the overall sowing effect. The coefficient of variation for consistency of each row is calculated as a basis for subsequent quality control.
[0112] This invention enables automatic detection and data calculation of the sowing quality of pepper seeds in seed trays after sowing. To facilitate integrated application and improve detection efficiency and accuracy, a deep learning framework is used to implement the pepper seed target detection task, and a relative pixel loss function is introduced to enhance the detection accuracy of small targets. Furthermore, single-cell images are used for algorithm training, effectively reducing the number of samples and the amount of annotation work, while significantly improving the efficiency of the preliminary work. Whole-tray images are used for result prediction to ensure the algorithm's inference speed. This invention provides a fast and feasible method for detecting various features of pepper seed tray sowing quality, improving task performance. The algorithm is also portable to host computer software, enabling cross-platform compatibility and providing technical support for the integrated automated detection of sowing quality.
[0113] Example 2
[0114] See Figure 2A-2C , Figure 2A-2C This is a schematic diagram illustrating the process of acquiring a single-cell image of the acupoint plate according to an embodiment of the present invention. Figure 2A-2C The diagram illustrates the cropping and individual image extraction of the acquired whole-disc image. Since the whole-disc image captured by the camera has high consistency and generally contains background areas other than the disc itself, a fixed region is cropped using the average relative coordinates of the "top left" and "bottom right" corners based on the OpenCV library to remove invalid background areas. Then, based on template matching, as shown in Equation 2-1, pixel-level sliding templates are used to match the whole-disc image. The normalized correlation coefficient R between the matching region S of the whole-disc image and the template image M is obtained according to Equation (2-1). In the experiment, the matching confidence level T = 0.14 was set. If R ≥ T, a match is considered to exist at that position, with a matching success rate of approximately 84%.
[0115] (2-1)
[0116] In the formula, x p y p — Matches the starting coordinates, in pixels (px);
[0117] U M V M — Template size, in pixels (px);
[0118] E(M) – Mean of the template image;
[0119] —with (x p , y p The size of the starting point is U. M ×V M The mean of the region.
[0120] See Figures 3A-3B , Figures 3A-3B This is a schematic diagram of a single-cell image of the acupuncture point plate extracted according to an embodiment of the present invention, along with its annotation file. Figure 3A This section presents individual images and annotation files of the acupuncture point clusters. The figure shows the extracted individual images of the acupuncture point clusters and their corresponding annotation files. The annotation information for each image is (Class, x0, y0, L). w L h The following are represented in sequence: target category number, relative x-coordinate of center point, relative y-coordinate of center point, relative width, and relative height, such as... Figure 3B As shown.
[0121] See Figure 4 , Figure 4 This is a schematic diagram of the relative pixel loss function according to an embodiment of the present invention. Since the error caused by pixel loss when a small target experiences prediction offset is sensitive to the Intersection over Union (IoU), which is the ratio of the pixel intersection of the predicted bounding box and the ground truth bounding box to their union, a targeted relative pixel loss function is introduced to improve recognition accuracy and address the problem of low tolerance for IoU in measuring the positional offset of small targets. Specifically:
[0122] Let X be the center point of the ground truth bounding box labeled in the dataset. o Y o Relative width and height w o h o ;Network prediction box center point X z Y z Relative width and height w z h z Set the Euclidean distance between the two center points as follows:
[0123] D c 2 =(X z -X o ) 2 +(Y z -Y o ) 2 (2-2)
[0124] To set width and height dimensions to avoid the problem of non-overlapping bounding boxes and an IoU of 0:
[0125] D l 2 =(w z -w o ) 2 +(h z -h o ) 2 (2-3)
[0126] To eliminate the influence of dimensions, a maximum boundary dimension-unified divisor term is set.
[0127] D f 2 =max(w z , w o ) 2 +max(h z , h o ) 2 (2-4)
[0128] The relative pixel loss Pxi.Loss is:
[0129] ; (2-5)
[0130] Normalizing the relative pixel loss using the exponential function of e yields a similarity measure with a value range of (0, 1).
[0131] (2-6)
[0132] In the formula, λ is the constant normalization coefficient;
[0133] The loss function for the target detection network after relative pixel loss is set as follows (taking the YOLOv8 nano network as an example):
[0134] ; (2-7)
[0135] In the formula, l box For location loss; l cls For confidence loss; pxi This represents the relative pixel loss.
[0136] See Figure 5 , Figure 5 This diagram illustrates the training results of a deep learning object detection algorithm based on single-cell image data of chili pepper planting trays according to an embodiment of the present invention. The diagram shows the training results of the improved YOLO v8 nano algorithm, implemented using the PyTorch framework. YOLO v8 nano has advantages such as lightweight design and fast detection speed, and its accuracy meets the requirements of practical application scenarios. The horizontal axis represents the number of training epochs for all images, with 100 iterations. The vertical axis represents the values of various metrics. Visible localization loss, confidence loss, and relative pixel loss converge with increasing training epochs; smaller values indicate better performance. Precision is the proportion of correctly predicted positive samples out of all positive samples found. Recall is the proportion of correctly predicted positive samples out of all positive samples. Average precision (mAP50) and mAP50-95 represent the prediction accuracy for IoU values greater than 50% and between 50% and 95%, respectively. The training yields two weight files: best.pt and last.pt.
[0137] See Figure 6 , Figure 6 This is a schematic diagram illustrating the whole-disk image size adjustment operation during whole-disk testing according to an embodiment of the present invention. The whole-disk image shown in the diagram is first adjusted using equation (2-8), and the adjustment step size Step is determined to be 2. k (k is the downsampling number of the algorithm, 5 for YOLOv8 nano), meaning the adjustment step size is 32 pixels. To ensure each pixel in the entire image is effective, it needs to be divisible by 32. Within a suitable range, appropriate sizing methods can help improve detection accuracy, such as making the variable coefficient n ∈ [-10, 20]. Then, experiments are conducted to comprehensively consider detection time and accuracy, determining the final feasible variable coefficient n.
[0138] (2-8)
[0139] See Figure 7 , Figure 7 This diagram illustrates the porting of a target detection model to a host computer software according to an embodiment of the present invention. The implemented chili pepper tray sowing quality detection model is converted into the ONNX (Open Neural Network Exchange) format and combined with the TensorRT acceleration library to achieve efficient inference. The host computer software is written in Python, which facilitates cross-platform portability. After successful compilation, the code is exported as an .exe executable file. After installing the software, detection can be completed by acquiring images with a portable camera or by uploading previously acquired images. After clicking "Start Task", the software completes model preloading. The middle image is the detection screen. Clicking the "Detect" button displays the detection results of each image on the right and the average value of all current detection results on the left.
[0140] See Figure 8 This is a schematic diagram of the detection and counting results according to an embodiment of the present invention. The left side is the image to be detected, and the right side is the solution result for obtaining features such as single seed rate, replanting rate, and missed seeding rate after pepper sowing. The solution process is as follows:
[0141] Prediction result Location(x) i ,y i )
[0142] The seed quantity matrix Matrix[X, Y]
[0143] Position coordinates X cal Y cal
[0144] Overall plate dimensions:
[0145] S x = ImageSize[0]
[0146] S y = ImageSize[1]
[0147] *Normalized coordinate position:
[0148] X cal =(x i / S x )*6 # Column position
[0149] Y cal =(y i / S y *12 # Line position
[0150] *Calculation result matrix:
[0151] Matrix[X, Y]←[X cal Y cal # Relative coordinate position
[0152] CountX, Y[N] +=1 # Quantity in the corresponding cell
[0153] That is, the normalized coordinate method is used to normalize the center coordinates of the seeds in the seed tray after sowing. Taking a standard 72-cell seedling tray (12 rows × 6 columns) as an example, the width of the entire tray is calculated using the OpenCV library. x =ImageSize[0], height is S y =ImageSize[1], perform normalized matching, then the normalized position coordinates of each seed detection: column position is X cal =(x i / S x )*6, Row position is Y cal= (y i / S y )*12, to record the relative coordinate positions, forming the sowing quantity result matrix Matrix[X cal Y cal ] Count of seeds in the corresponding cell X, Y [N], such as Figure 8 As shown, the single-grain rate (number of single-grain holes / total number of holes), reseeding rate (number of reseeding holes / total number of holes), and missed seeding rate (number of missed seeding holes / total number of holes) are further obtained, and then the average single-grain rate, average reseeding rate, and average missed seeding rate of the total seeding tray are calculated.
[0154] See Figure 9 , Figure 9 This is a diagram illustrating the calculation of the consistency coefficient of variation for each row. The calculation of the consistency coefficient of variation for each row is as follows:
[0155] First, the number of seeds planted in each cell was obtained through algorithm detection. Then, the number of seeds N corresponding to each row was summed based on the row. y Where y represents the row number and x represents the column number. Taking a standard seedling tray with 72 cells (12×6) as an example, the maximum row number for each tray is 12, and the number of columns is 6, i.e., Y=12, X=6. The number of seeds N1 in the first row can be calculated using the following formula: N1=N (1 , 1) + N (2 , 1) + N (3 , 1) + N (4 , 1) + N (5 ,1) + N (6 , 1) ;
[0156] ;
[0157] Calculate the average number of seeds per row : ;
[0158] Calculate the standard deviation S: ;
[0159] Calculate the coefficient of variation (CV): .
[0160] The uniformity of sowing can be assessed by calculating the coefficient of variation (COP) of the consistency between rows in the seed trays after sowing. A smaller COP indicates less variation between rows, higher sowing quality, and helps ensure relatively consistent growth conditions for the crop, thus improving overall seedling quality. For roller-type seeding production lines, this coefficient can be used to evaluate the equipment's sowing performance. A large COP may indicate problems with the equipment's sowing mechanism, such as unstable seed metering or errors in transmission components, providing a basis for equipment debugging and improvement. Understanding the consistency of rows in the seed trays after sowing helps optimize the production process. For example, parameters such as sowing speed and seed type can be adjusted based on the COP to improve production efficiency and quality.
[0161] See Figures 10A-10B , Figures 10A-10B This is an image illustrating the effect of detecting the seeding quality of chili pepper seeds in a tray according to an embodiment of the present invention. Figure 10A The effect of sowing peppers in a standard 72-cell seedling tray was tested after planting. Figure 10B The results show the post-sowing detection effect of peppers in a standard 128-cell seedling tray. It is evident that the method combining deep learning single-cell training and whole-tray detection improves efficiency during the training phase while maintaining very high detection accuracy during the detection phase. Combined with pixel loss judgment, it achieves high-quality detection results.
[0162] This invention is applicable to online detection of chili seeding quality in seedling production lines, completing image acquisition after chili seed tray sowing. Given the structural characteristics of the seed tray (the entire tray image can be considered as a composite of individual images), individual images are extracted from the acquired source image. Then, data augmentation is performed on the individual tray images, and the chili seeds in each individual image are labeled to form a dataset of individual tray images. A weight file is then trained on this dataset. The weight file is loaded into a deep learning object detection algorithm to obtain a seed tray sowing quality detection network. During detection, the entire tray image is directly detected. By adjusting the overall tray image size change coefficient, the optimal adjustment size parameter for the overall tray image is selected to achieve the best detection effect of the object detection algorithm. After setting the adjustment size parameter in the object detection algorithm, online detection of the entire tray image is completed, thereby obtaining data such as the single-seed rate, reseeding rate, missed sowing rate, and seed center point of the chili seeds sown in the tray. This invention addresses the problems of low efficiency in existing seedling production lines when sowing irregular seeds such as chili peppers, which rely on manual calculation for sowing quality; low training and detection efficiency or accuracy in existing tray detection methods; and the failure to achieve a balance between the two. By combining "single-cell training + whole-tray detection," the training efficiency of deep learning target detection algorithms is improved, thereby enhancing both the algorithm's detection speed and accuracy.
[0163] Accordingly, based on the same inventive concept, the present invention also provides a storage medium storing a computer program configured to execute the above-described method for detecting the quality of chili seed tray sowing during runtime. Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (e.g., a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (which can be a personal computer, server, mobile terminal, or network device, etc.) to execute the method according to the embodiments of the present invention.
[0164] In some possible implementations, various aspects of the present invention can also be implemented as a program product comprising program code that, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0165] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a host computer or personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0166] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0167] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0168] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0169] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0170] Of course, the present invention may have other various embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art can make various corresponding changes and modifications according to the present invention, but these corresponding changes and modifications should all fall within the protection scope of the appended claims.
Claims
1. A method for detecting the quality of chili pepper seed tray sowing, characterized in that, The quality assessment of chili pepper tray sowing was conducted by combining single-cell training with whole-tray testing, including the following steps: S100. Collect images of chili seeds after seed tray sowing and extract individual cell images. Perform data augmentation on the individual cell images, label the chili seed outlines of the individual cells, and create training and testing sets. S200. Construct a deep learning object detection network, introduce the relative pixel loss function into the deep learning object detection network, train the deep learning object detection network using training set data, and judge the training iteration results. S300. Load the optimal weight file from the training iteration into the target detection algorithm of the deep learning target detection network, input the whole plate image after the chili seed tray is sown, perform whole plate detection, and at the same time set the image size adjustment step size to obtain the size adjustment parameters that meet the detection time and accuracy requirements. S400. Based on the size adjustment parameters obtained in step S300, set the target detection algorithm weights and size adjustment parameters, input the online acquired image into the constructed target detection algorithm for sowing quality detection, output the total number of seeds in the tray and the coordinate center point, and calculate the single seed rate, replanting rate and missed seed rate of each tray of chili seeds in combination with the specifications of the chili seed tray to be detected. as well as S500: Based on the calculation results of step S400, calculate the average single seed rate, average replanting rate and average missed seed rate of all pepper seeds under the current sowing task to detect the current overall sowing quality. Step S300 further includes: S301. Load the optimal weight file into the target detection algorithm; S302. Based on the downsampling times k of the target detection algorithm, determine the step size of the overall disk size change as 2. k Pixels, the original dimensions width w and height h are adjusted proportionally, with an adjustment ratio R. a =2 k f ceil (max(w, h) / 2 k f(w, h) + n) / max(w, h), where f ceil (*) is the floor function, n is the size adjustment variable coefficient, and its value is an integer; and S303. Change the variable coefficient n for size adjustment, observe the algorithm inference time and accuracy, and select the variable coefficient value for size adjustment that provides the highest detection accuracy at the required detection speed.
2. The method for detecting the quality of chili pepper tray sowing as described in claim 1, characterized in that, It also includes the following steps: S600. Calculate the consistency variation coefficient of each row under the current sowing task, as the basis for subsequent quality control judgment.
3. The method for detecting the quality of chili pepper tray sowing as described in claim 1, characterized in that, Step S400 further includes: S401. Convert the chili seed tray sowing quality detection model into the ONNX open neural network exchange format, and combine it with the TensorRT acceleration library to achieve efficient inference. S402. Divide and calculate the coordinates of the detected chili seed center points, and construct a seed distribution matrix corresponding to the seed tray positions; and S403. If the number of seeds detected in the same area is 0, it is determined to be a missed sowing; if the number of seeds detected in the same area is 1, it is determined to be a single seed; if the number of seeds detected in the same area is greater than 1, it is determined to be a re-sowing.
4. The method for detecting the quality of chili pepper tray sowing as described in claim 1, characterized in that, Step S100 further includes: S101. After selecting the acupuncture point image, remove invalid areas based on the main distribution area of the acupuncture point to obtain the processed image; and S102. Using the OpenCV library, set up a template matching script to extract individual images from the processed image and merge randomly cropped rich data to obtain multiple individual images.
5. The method for detecting the quality of chili pepper tray sowing as described in claim 4, characterized in that, Step S100 further includes: S103. Data enhancement is performed on the extracted single-cell images using brightness transformation, random flipping, contrast enhancement, and random scaling, with an amplification ratio of 25% to 35%. S104. Divide the enhanced overall single-cell image data into training and test sets according to an 8:2 ratio; and S105. Labelme software is used to label the chili seeds in each individual image in the training set, generating a .txt file.
6. The method for detecting the quality of chili pepper tray sowing as described in claim 5, characterized in that, The .txt file includes the category, the center coordinates of the horizontal axis of the labeled object, the center coordinates of the vertical axis of the labeled object, and information on width and height.
7. The method for detecting the quality of chili pepper tray sowing as described in claim 1, characterized in that, Step S200 further includes: S201. The average pixel size of chili seeds in the dataset is 30 pixels × 30 pixels. A targeted relative pixel loss function is introduced to improve the recognition accuracy and improve the IoU measure of the offset tolerance of small target positions. S202. Perform training, observe the result curve, and determine whether the target detection algorithm has converged during training and whether the accuracy meets the requirements. S203. Load the trained weight file into the object detection algorithm and test it on the test set to observe the actual detection effect; and S204. If the detection results do not meet the actual requirements, increase the number of training iterations, or recreate and expand the dataset, and retrain and test according to steps S201 to S203 until a weight file that meets the required accuracy is trained.
8. The method for detecting the quality of chili pepper tray sowing as described in claim 7, characterized in that, Step S201 further includes: S011, Set the center point of the target ground truth bounding box in the dataset annotation to X. o Y o The relative width and height are w o h o The center point of the network prediction box is X. z Y z The relative width and height are w z h z ; S2012, The Euclidean distance between the center point of the network predicted bounding box and the center point of the target ground truth bounding box is: D c 2 =(X z -X o ) 2 +(Y z -Y o ) 2 ; S2013, Set the width and height dimensions to D. l 2 =(w z -w o ) 2 +(h z -h o ) 2 This is to avoid the prediction boxes having no overlap and an IoU of 0; S2014, Set the largest boundary dimension unified divisor term to D. f 2 =max(w z , w o ) 2 +max(h z , h o ) 2 To eliminate the influence of dimensions; S2015, then the relative pixel loss Pxi.Loss is: ; S2016. Normalize the relative pixel loss using the exponential function of e, and the result is a similarity measure with a value range of (0, 1]. ; Where λ is the constant normalization coefficient.
9. A storage medium, characterized in that, The storage medium stores a computer program, which is configured to execute the chili pepper tray sowing quality detection method according to any one of claims 1-8 when running.