A fruit sorting device and method based on improved YOLOv8

By combining the improved YOLOv8 algorithm with the mechanical structure, all-round recognition and classification of fruits are achieved, solving the problems of high cost and low efficiency in existing technologies, meeting the needs of small vendors, and improving sorting efficiency and accuracy.

CN120228053BActive Publication Date: 2025-09-12JILIN UNIVERSITY
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510702796.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-09-12
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

Existing fruit sorting technology is costly, inefficient, and unable to fully detect surface defects in fruits, which easily leads to sorting errors and makes it difficult to meet the needs of small vendors.

Method used

An improved YOLOv8 algorithm is combined with a mechanical structure to achieve all-round recognition and classification of fruits through sensors, cameras, and servo drive components. Frozen layer transfer learning, RCIoULoss function, and fireworks algorithm are used to optimize the model to improve detection accuracy and efficiency.

Benefits of technology

It achieves efficient and accurate fruit sorting, reduces costs, adapts to the needs of small vendors, and improves sorting efficiency and detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120228053B_ABST
    Figure CN120228053B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the field of fruit sorting technology and provides a fruit sorting device and method based on an improved YOLOv8 algorithm. The device comprises: a feed base plate, the feed base plate being provided with a size classification conveyor shaft; a conveyor belt 1 connected to the feed base plate, the conveyor belt 1 being connected to the conveyor belt 2, a conveyor belt baffle being provided between the conveyor belts 1 and 2, and a curved baffle being provided on the other side of the conveyor belt 2; a connecting plate connected to the conveyor belt 2, the other side of the connecting plate being provided with channel 1 and channel 2; a sensing component electrically connected to the conveyor belt baffle and conveyor belt 1; a visual recognition component electrically connected to the curved baffle, collecting information about the fruit on conveyor belt 2 and controlling the state of the curved baffle; and an intelligent sorting drive component for receiving and analyzing the data collected by the visual recognition component and driving the connecting plate to connect to channel 1 or channel 2. The present invention incorporates automated and intelligent technologies to achieve efficient and accurate fruit sorting and meet the needs of small vendors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of fruit sorting, and in particular relates to a fruit sorting device and method based on improved YOLOv8. Background Art

[0002] Sorting can remove defective, damaged or substandard fruits, ensure the quality of the fruits, reduce losses, and help achieve product standardization. It is an important step before the transportation and sale of fruits.

[0003] Traditional manual sorting is not only time-consuming and labor-intensive, but also prone to sorting errors due to human factors and low efficiency. Existing fruit sorting technologies mainly include machine vision, spectral detection, X-ray detection, etc., but they are expensive and suitable for large-scale fruit wholesale markets, but cannot meet the needs of small vendors. In addition, some existing visual recognition systems cannot fully detect the surface of the fruit, which can easily lead to the omission of bad and inferior fruits. At the same time, there is a problem of slow processing speed and prone to error processing. Summary of the Invention

[0004] The purpose of the embodiments of the present invention is to provide a fruit sorting device based on improved YOLOv8, aiming to solve the problems raised in the above background technology.

[0005] The embodiment of the present invention is implemented as follows: a fruit sorting device based on improved YOLOv8, comprising:

[0006] A feeding bottom plate, wherein a size classification conveying shaft is provided on the feeding bottom plate;

[0007] Conveyor belt 1 is connected to the feed bottom plate, the other side of the conveyor belt 1 is connected to conveyor belt 2, a conveyor belt baffle is provided between the conveyor belt 1 and the conveyor belt 2, and the other side of the conveyor belt 2 is provided with an arc baffle;

[0008] A connecting plate connected to the second conveyor belt, wherein the other side of the connecting plate is provided with a first channel and a second channel;

[0009] a sensing component electrically connected to the conveyor belt baffle and the conveyor belt 1, and used to control the status of the conveyor belt 1 and the conveyor belt baffle;

[0010] A visual recognition component is electrically connected to the arc baffle, and is used to collect information about the fruit rolling on the second conveyor belt and control the state of the arc baffle;

[0011] The intelligent sorting drive component is connected to the visual recognition component and the connecting plate, and is used to receive data collected by the visual recognition component for analysis, control the state of the connecting plate, and drive the connecting plate to connect with channel one or channel two.

[0012] Preferably, the sensing component comprises:

[0013] A sensor, mounted on the sensor base, is used to detect whether there is fruit at the starting end of the second conveyor belt;

[0014] The servo drive component 1 is connected to the conveyor belt baffle. The servo drive component 1 drives the conveyor belt baffle to rotate based on the information detected by the sensor, driving the conveyor belt baffle to block between conveyor belt 1 and conveyor belt 2. At the same time, conveyor belt 1 is controlled to open and close based on the information detected by the sensor.

[0015] Preferably, the visual identification component includes:

[0016] A camera, mounted on a camera base, is used to collect information about the fruit rolling on the second conveyor belt;

[0017] The servo drive assembly 2 is connected to the arc baffle. The servo drive assembly 2 drives the arc baffle to rotate based on the information detected by the camera, so as to limit the fruit from rolling on the conveyor belt 2 or remove the restriction.

[0018] Preferably, the intelligent sorting drive component includes:

[0019] An analysis and calculation module, connected to the visual recognition component, adopts an improved YOLOv8 model that introduces the RCIoULoss function and the fireworks algorithm to analyze and determine the state of the fruit;

[0020] The servo drive assembly three is connected to the connecting plate. The servo drive assembly three controls the rotation angle of the connecting plate based on the result determined by the analysis and calculation module, and drives the connecting plate to connect with channel one or channel two.

[0021] Preferably, the servo drive assembly 1, servo drive assembly 2 and servo drive assembly 3 have the same structure but different positions, and respectively include a servo installed on the servo groove. The servo is respectively connected to the conveyor belt baffle, arc baffle or connecting plate to drive the conveyor belt baffle, arc baffle or connecting plate to rotate.

[0022] Another object of an embodiment of the present invention is to provide a fruit sorting method based on an improved YOLOv8, using the above-mentioned fruit sorting device, comprising the following steps:

[0023] The fruits are placed on the size classification conveyor shaft. The fruits fall into different feeding bottom plates during the rolling process and roll onto the conveyor belt 1 on the feeding bottom plates.

[0024] The fruit is transferred from conveyor belt 1 to the starting end of conveyor belt 2. When the sensing component detects that there is no fruit on conveyor belt 2, the fruit is transferred to conveyor belt 2. When the sensing component detects that there is fruit on conveyor belt 2, the conveyor belt baffle is controlled to rotate to block between conveyor belt 1 and conveyor belt 2, and conveyor belt 1 is controlled to stop conveying.

[0025] The visual recognition component detects and collects data on the fruits on conveyor belt 2, and controls the arc baffle to rotate to block the conveyor path, causing the fruits to rotate in place on conveyor belt 2. When the visual recognition component completes recognition, it controls the arc baffle to rotate in the opposite direction.

[0026] The intelligent sorting drive component receives the data collected by the visual recognition component for analysis and calculation, determines the state of the fruit, controls the rotation angle of the connecting plate, drives the connecting plate to connect with channel one or channel two, and the fruit enters channel one or channel two to complete the sorting.

[0027] The fruit sorting device based on improved YOLOv8 provided by the embodiment of the present invention solves the problems of frequent errors in manual sorting operations for small fruit vendors and the large and expensive intelligent sorting equipment. It has a unique mechanical structure, combines traditional sorting with intelligent sorting, and uses a single-chip microcomputer to realize electronic control, thereby realizing all-round and multi-angle recognition and classification of fruits; adopts the improved YOLOv8 algorithm and utilizes the transfer learning strategy to fine-tune the pre-trained model yolov8n according to the self-prepared data set. During the fine-tuning process, the lower layers of the pre-trained model are frozen to retain the common features in target detection, which can greatly improve the accuracy of the fruit sorting. The RCIoULoss function significantly improves the robustness of circular object positioning and reduces false detections caused by angle sensitivity by dynamically weakening redundant angle penalties, using radial difference metrics, and performing dual-channel shape optimization. During image classification, the definition of the feature matrix and improvements to the Fireworks Algorithm (FAW) are used to obtain a selected feature matrix for image classification. This results in faster convergence and more accurate edge fitting in the fruit detection scenario, improving mAP@0.5 and mAP@0.5:0.95 by 4.23 and 2.40 percentage points, respectively, compared to the traditional YOLOv8 model.

[0028] The embodiments of the present invention, by introducing automated and intelligent technologies, combined with visual recognition, mechanical control, and electronic control systems, can achieve efficient and accurate sorting of fruits, meet the needs of small vendors, reduce costs, and improve sorting efficiency. It serves as a bridge connecting agricultural production with market demand, and promotes agricultural modernization. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of the structure of a fruit sorting device based on improved YOLOv8 provided by an embodiment of the present invention;

[0030] Figure 2 for Figure 1 Schematic diagram of a local enlarged structure;

[0031] Figure 3 A flowchart of frozen layer transfer learning for an analysis and calculation module in a fruit sorting device based on an improved YOLOv8 provided in an embodiment of the present invention;

[0032] Figure 4 An RCIoULoss function structure of an analysis and calculation module in a fruit sorting device based on an improved YOLOv8 provided in an embodiment of the present invention;

[0033] Figure 5 This is a flowchart of a fruit sorting method based on improved YOLOv8 provided by an embodiment of the present invention.

[0034] In the attached figure: 1-feed bottom plate, 2-size classification conveyor shaft, 3-conveyor belt 1, 4-conveyor belt baffle, 5-conveyor belt 2, 6-sensor base, 7-camera base, 8-servo groove, 9-servo, 10-arc baffle, 11-connecting plate; 12-channel 1; 13-channel 2. DETAILED DESCRIPTION

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

[0036] The specific implementation of the present invention is described in detail below with reference to specific embodiments.

[0037] like Figure 1 FIG. 1 is a structural diagram of a fruit sorting device based on an improved YOLOv8 provided by an embodiment of the present invention, including:

[0038] A feeding bottom plate 1, on which a size classification conveying shaft 2 is provided;

[0039] Conveyor belt 1 3 is connected to the feed bottom plate 1, and the other side of the conveyor belt 1 3 is connected to the conveyor belt 2 5. A conveyor belt baffle 4 is provided between the conveyor belt 1 3 and the conveyor belt 2 5, and an arc-shaped baffle 10 is provided on the other side of the conveyor belt 2 5;

[0040] A connecting plate 11 is connected to the conveyor belt 2 5, and a channel 12 and a channel 2 13 are provided on the other side of the connecting plate 11;

[0041] A sensing component electrically connected to the conveyor belt baffle 4 and the conveyor belt 1 3, and used to control the status of the conveyor belt 1 3 and the conveyor belt baffle 4;

[0042] A visual recognition component is electrically connected to the arc baffle 10 and is used to collect information about the fruit rolling on the conveyor belt 2 5 and control the state of the arc baffle 10;

[0043] The intelligent sorting drive component is connected to the visual recognition component and the connecting plate 11, and is used to receive data collected by the visual recognition component for analysis, control the state of the connecting plate 11, and drive the connecting plate 11 to connect with channel 1 12 or channel 2 13.

[0044] In one embodiment of the present invention, the fruit sorting device based on the improved YOLOv8 addresses the problems raised in the prior art and is equipped with a sensing component, a visual recognition component, and an intelligent sorting drive component. The entire sorting process includes traditional sorting, conveying, visual recognition, and intelligent sorting. Traditional sorting and intelligent sorting are combined to achieve rapid classification of fruit size using traditional sorting and classification based on the degree of fruit defects using intelligent sorting. This not only meets the requirements of fast, efficient, and accurate classification, but also has the characteristics of being small and low-cost. This allows small fruit vendors to use modern, automated, and intelligent equipment to achieve fruit sorting, greatly reducing labor costs.

[0045] Among them, the feeding bottom plate 1, the size classification conveying shaft 2 and the conveyor belt 3 are traditional sorting structures. The same kind of fruits of different sizes are placed on the size classification conveying shaft 2 at the front end of the device. They roll under the action of gravity. When the diameter is smaller than the spacing between the size classification conveying shafts 2, the fruits fall onto different feeding bottom plates 1, thereby realizing size classification; the feeding bottom plate 1 gathers the fruits to the middle position, which is conducive to the smooth subsequent visual recognition. At the same time, the feeding bottom plate 1 can be placed at a certain angle to the horizontal. The reasonable inclination angle can be determined according to the weight of the fruit, so that the fruit can roll under the action of gravity and be conveyed. Belt 1 3 prepares for visual recognition and conveys the fruit to the starting end of conveyor belt 2 5. The arc structure of the arc baffle 10 matches the shape of the fruit. When conveyor belt 2 5 is in motion, with the assistance of the arc baffle 10, the fruit is helped to roll on conveyor belt 2 5, making it convenient for the visual recognition component to detect the quality of the fruit in all directions. The intelligent sorting drive component calculates and analyzes the data collected by the visual recognition component, and divides the fruit into good fruit and inferior fruit. The control connecting plate 11 is connected to channel 1 12 or channel 2 13 to realize classification according to the degree of fruit defects.

[0046] like Figure 2 As shown, as a preferred embodiment of the present invention, the sensing component includes:

[0047] A sensor, mounted on the sensor base 6, is used to detect whether there is fruit at the starting end of the conveyor belt 2 5;

[0048] The servo drive assembly 1 is connected to the conveyor belt baffle 4. The servo drive assembly 1 drives the conveyor belt baffle 4 to rotate based on the information detected by the sensor, driving the conveyor belt baffle 4 to block between the conveyor belt 1 3 and the conveyor belt 2 5. At the same time, the conveyor belt 1 3 is controlled to open and close based on the information detected by the sensor.

[0049] The first driving assembly includes a steering gear 9 installed on the steering gear groove 8. The steering gear 9 is connected to the conveyor belt baffle 4 and is used to drive the conveyor belt baffle 4 to rotate.

[0050] The position and angle of the sensor are adjusted according to actual needs and are installed on the sensor base 6. When fruits are conveyed to the starting end of the conveyor belt 2 5 and there are fruits on the conveyor belt 2 5, the steering gear drive component 1 controls the conveyor belt baffle 4 to rotate, blocking the conveying path and controlling the conveyor belt 1 3 to stop conveying;

[0051] The conveyor belt baffle 4 is connected to the connecting piece on the steering gear 9. Starting the steering gear 9 can drive the conveyor belt baffle 4 to rotate upward to block. After one sorting is completed, the steering gear 9 can be started to drive the conveyor belt baffle 4 to rotate downward.

[0052] like Figure 2 As shown, as another preferred embodiment of the present invention, the visual recognition component includes:

[0053] A camera, mounted on a camera base 7, is used to collect information about the fruit rolling on the conveyor belt 2 5;

[0054] A second servo drive assembly is connected to the arc baffle 10. The second servo drive assembly drives the arc baffle 10 to rotate based on information detected by the camera, so as to restrict or release the rolling of the fruit on the second conveyor belt 5.

[0055] The second driving assembly includes a steering gear 9 installed on the steering gear groove 8. The steering gear 9 is connected to the arc baffle 10 and is used to drive the arc baffle 10 to rotate.

[0056] The position and angle of the camera are adjusted according to actual needs and are installed on the camera base 7. When there are fruits on the conveyor belt 2 5, the servo drive assembly 2 controls the arc baffle 10 to rotate. The arc structure of the arc baffle 10 fits the shape of the fruit, helping the fruit to continue rolling. The camera can collect fruit information from multiple angles in real time.

[0057] The arc baffle 10 is connected to the connecting piece on the steering gear 9. Starting the steering gear 9 can drive the arc baffle 10 to rotate to a vertical state to block the transmission path. After the visual recognition is completed, the steering gear 9 can be started to drive the arc baffle 10 to rotate to a horizontal state.

[0058] like Figure 2As shown in FIG. 1 , as a preferred embodiment of the present invention, the intelligent sorting drive component includes:

[0059] An analysis and calculation module, connected to the visual recognition component, adopts an improved YOLOv8 model that introduces the RCIoULoss function and the fireworks algorithm to analyze and determine the state of the fruit;

[0060] The servo drive assembly 3 is connected to the connecting plate 11. The servo drive assembly 3 controls the rotation angle of the connecting plate 11 based on the result determined by the analysis and calculation module, thereby driving the connecting plate 11 to connect with the channel 1 12 or the channel 2 13;

[0061] The driving assembly three includes a steering gear 9 installed on the steering gear groove 8. The steering gear 9 is connected to the connecting plate 11 to drive the connecting plate 11 to rotate.

[0062] The visual recognition component transmits the collected data to the intelligent sorting drive component, which uses the analysis and calculation module to perform calculations. According to the results calculated by the analysis and calculation module, the steering drive component 3 is driven. The steering gear 9 drives the connecting plate 11 to rotate to different angles, driving the connecting plate 11 to connect with channel 1 12 or channel 2 13, and driving the fruits into different channels.

[0063] The analysis and calculation module is based on the improved YOLOv8 (You Only Look Once version 8) algorithm. YOLOv8 is a target detection algorithm based on a convolutional neural network (CNN). It can simultaneously complete image classification, positioning, and bounding box regression in a single forward propagation. By combining global information and local features, it achieves efficient and accurate target detection. It is a deep learning algorithm widely used in target detection and computer vision tasks. Its main advantages lie in its extremely high inference speed and real-time processing capabilities. Based on traditional YOLOv8, the embodiment of the present invention uses frozen layer transfer learning to improve training efficiency and uses the RCIoULoss function to improve adaptability to circular targets and detection accuracy. By defining the feature matrix and improving the Fireworks Algorithm (FAW), the selected feature matrix is ​​obtained to achieve image classification.

[0064] Traditional YOLOv8 network architecture:

[0065] YOLOv8 is a single-stage object detector. Its core idea is to predict the location and category of the target directly on the image, without generating candidate regions first like a two-stage detector. The input image is divided into grids, and each grid is responsible for predicting the target containing its center point. For each grid, the network predicts a certain number of bounding boxes, each corresponding to a potential target. The predictions of these bounding boxes include the location (center coordinates), size (width and height), and confidence score. The confidence score reflects the probability that the bounding box contains the target.

[0066] The YOLOv8 training process involves designing a loss function and selecting an optimization algorithm. The loss function typically consists of three parts: category loss, confidence loss, and position loss. These are used to measure the accuracy of category predictions, the accuracy of bounding box confidence predictions, and the accuracy of bounding box position predictions, respectively. The optimization algorithm is used to minimize the loss function, thereby updating the network parameters. Common optimization algorithms include Adam and SGD. Ultimately, the trained model can detect objects in new images and output the object's location and category information.

[0067] YOLOv8 improvement method according to an embodiment of the present invention:

[0068] (1) Frozen layer transfer learning:

[0069] YOLOv8 uses deep learning to train its model, which requires a large amount of data and custom parameters, is time-consuming and costly. Therefore, an embodiment of the present invention integrates frozen layer transfer learning to optimize the YOLOv8 training process. Transfer learning is a machine learning method that applies knowledge learned from one task (source task) to another related task (target task). The pre-trained model has already learned common image features on a large dataset. Therefore, freezing the layers of the pre-trained model can prevent these features from being destroyed in the early stages of training, thereby avoiding learning from scratch. This can significantly reduce the time required for training on a self-prepared dataset, reduce computing resources, and thus reduce costs. Especially when the dataset is small, frozen layer transfer learning can improve the model's generalization ability, avoid overfitting, and thus achieve better performance.

[0070] The embodiment of the present invention uses a model pre-trained on a large dataset (COCO) as a starting point, and then fine-tunes it on a self-prepared dataset: selects a pre-trained model yolov8n.pt similar to the fruit detection target, which is suitable for low-precision but high-response speed target detection; then prepares a labeled fruit dataset, and fine-tunes the frozen layers based on the pre-trained model according to the self-prepared dataset. The lower layers (close to the input layer) learn more general features, and the higher layers (close to the output layer) learn more specific features. Therefore, the embodiment of the present invention freezes part of the Backbone layers and only trains the remaining Backbone layers and the Head part to improve learning efficiency. The frozen layer transfer learning flow chart of the embodiment of the present invention is shown in the figure. Figure 3 As shown;

[0071] (2) RCIoULoss loss function:

[0072] The original YOLOv8 model uses DFLLoss+CIoULoss as the regression loss. However, the CIoU angle penalty term is redundant for circular targets, resulting in unstable convergence. Furthermore, the aspect ratio constraint is not flexible enough, making it difficult to adapt to circular targets of different sizes. Therefore, this embodiment of the present invention introduces RCIoULoss to replace CIoULoss. By dynamically weakening the redundant angle penalty, implementing radial difference metrics (combining center offset and radius consistency constraints), and performing dual-channel shape optimization (approaching an aspect ratio of 1 with precise size matching), the model significantly improves the robustness of circular target positioning, reduces false detections caused by angle sensitivity, and achieves faster convergence and more accurate edge fitting in fruit detection scenarios.

[0073] The RCIoULoss function consists of two loss components: dynamically weighted geometric loss and adaptive angle loss. The structure of the RCIoULoss function is as follows: Figure 4 As shown, the red box represents the real box, the green box represents the predicted box (for easier description, the overlap between the predicted box and the real box is smaller than the actual situation), and the real box width is , Gao Wei , the prediction box width is , Gao Wei , the coordinates of the center point of the real frame are , the coordinates of the center point of the prediction box are The distance between the two center points is The angle between the line connecting the two center points and the horizontal line is ;

[0074] Dynamically weighted geometric loss combines center point offset, radius difference, aspect ratio constraint, and size error, and dynamically adjusts weights by IoU;

[0075] The IoU dynamic weight factor is , indicating that the weight factor decreases as the intersection over union (IoU) increases;

[0076] The center point offset penalty formula is: ;

[0077] in , represents the horizontal and vertical offset between the center point of the predicted box and the real box;

[0078] Radial difference penalty formula: ;

[0079] in , the average radius difference between the predicted box and the real box is expressed by the absolute value difference between the sum of the width and height of the predicted box and the sum of the width and height of the real box; is the radius of the largest target in the dataset;

[0080] The dual-channel shape constraint formula is: ;

[0081] This includes aspect ratio constraints and absolute size constraints ;

[0082] Summarize the dynamic weighted geometric loss formula: ;

[0083] Adaptive angle loss combines the dynamic weight of angle penalty and the original angle penalty term to dynamically weaken the angle redundancy problem of circular targets;

[0084] The dynamic weight formula of angle penalty is: ;

[0085] When the aspect ratio is close to 1, the weight is close to 0, and the angle penalty is almost ignored;

[0086] The original angle penalty term is:

[0087] Among them near The penalty is greatest when

[0088] The adaptive angle loss formula is summarized as follows: ;

[0089] In summary, the RCIoULoss formula is: ;

[0090] (3) Fireworks optimization algorithm:

[0091] In the conventional process of YOLOv8, the network automatically extracts image features through the convolution layer and directly uses the fully connected layer or detection head to complete classification and positioning. However, the texture and color changes on the surface of fruits are complex, and there are problems such as occlusion and ambient light flicker. Traditional feature extraction may cause redundant or inefficient features to interfere with detection accuracy. Therefore, the embodiment of the present invention introduces the Fireworks Algorithm (FAW) after the output layer of the Feature Pyramid Network (FPN) of YOLOv8 to dynamically screen the multi-dimensional feature matrix and retain the most discriminative feature combination for fruit defect detection, thereby improving classification accuracy: the input of FAW is the original feature matrix output from the FPN layer of YOLOv8 , where N is the number of samples, D is the feature dimension (such as 256 dimensions), and the output of FAW is the optimized binary feature selection vector , marking whether each feature is selected (1 for retention, 0 for removal);

[0092] The feature subset evaluation function is defined as F(S), and its formula is as follows:

[0093] ;

[0094] Among them, F(S) is used to measure the fitness of the feature vector S; α and β are parameters that weigh the discriminativeness and redundancy of features; Discriminative (S) reflects the discriminative ability of the selected features in image classification; Redundancy (S) reflects the degree of redundancy between the selected features;

[0095] The feature selection process of the Fireworks optimization algorithm is as follows:

[0096] Step 1. Initialize the fireworks population: Generate n Fireworks individuals, each individual represents a continuous feature selection probability vector , the initialization method is as follows:

[0097] ;

[0098] in, Indicates the i Fireworks individuals are j The selection probability of a feature; represents a uniform random sampling from 0 to 1;

[0099] Step 2: Convert the continuous vector of each firework individual X i Convert to a binary vector S i , and calculate the fitness value of each firework : ;

[0100] Step 3: Execute the explosion operation. Fireworks with high fitness will generate more sparks, while fireworks with low fitness will have a wider explosion range.

[0101] The formula for the number of explosion sparks is: ;

[0102] in, The number of explosion sparks generated for each firework, m is the total number of explosion sparks, is the maximum fitness of the current population, is the fitness value of the i-th firework, is a minimum value to prevent the denominator from being zero;

[0103] The explosion radius formula is: ;

[0104] in, For the i The explosion radius of the fireworks, is the initial explosion amplitude, which determines the initial value of the search range. is the minimum fitness of the current population;

[0105] That is, for each firework ,generate An explosion spark, during the explosion, each dimension j The disturbance range is determined by the explosion radius The formula for controlling and generating new sparks is:

[0106] ;

[0107] in, New solutions generated for the explosion;

[0108] Step 4: Randomly select some explosion sparks for Gaussian mutation:

[0109] ;

[0110] in, is the new solution generated by mutation, Gaussian (0,1) is the random sampling of standard normal distribution, σ is the mutation intensity (decays with iteration);

[0111] Step 5. Perform population merging on fireworks, explosion sparks, and mutation sparks, and select the next generation population according to the following probabilities: ;

[0112] in, is the probability that an individual is retained, For individuals The sum of the Euclidean distances to all other candidate individuals, where k is the total number of candidate individuals (including fireworks, explosion sparks, and mutation sparks);

[0113] Step 6: Determine whether the iteration has reached the maximum number of times. If not, return to step 3. If so, output the optimal result, that is, the optimal binary selection vector S :

[0114] Define a matrix X, where represents the jth feature of the i-th sample, and the feature selection vector S is obtained using the fireworks optimization algorithm, where Indicates the selection of the jth feature, Indicates that the jth feature is not selected. With the help of the feature selection vector S, the optimized feature matrix Xopt can be obtained, which is calculated as follows: ;

[0115] Support Vector Machine (SVM) is used as a classifier to classify images on the filtered feature matrix Xopt. The goal is to find a decision function f so that the given image sample The predicted output With actual label As close as possible, the formula is: .

[0116] like Figure 5 FIG. 1 is a flowchart of a fruit sorting method based on an improved YOLOv8 according to an embodiment of the present invention, which uses the above-mentioned fruit sorting device and includes the following steps:

[0117] The fruits are placed on the size classification conveyor shaft 2. The fruits fall into different feeding bottom plates 1 during the rolling process and roll onto the conveyor belt 3 in the feeding bottom plate 1.

[0118] The fruit is conveyed to the starting end of conveyor belt 2 5 via conveyor belt 1 3. When the sensing component detects that there is no fruit on conveyor belt 2 5, the fruit is conveyed to conveyor belt 2 5. When the sensing component detects that there is fruit on conveyor belt 2 5, the conveyor belt baffle 4 is controlled to rotate to block between conveyor belt 1 3 and conveyor belt 2 5, and conveyor belt 1 3 is controlled to stop conveying.

[0119] The visual recognition component detects and collects data on the fruits on the conveyor belt 2 5, and controls the arc baffle 10 to rotate to block the conveyor path, driving the fruits to rotate in place on the conveyor belt 2 5. When the visual recognition component finishes recognition, it controls the arc baffle 10 to rotate in the opposite direction;

[0120] The intelligent sorting drive component receives the data collected by the visual recognition component for analysis and calculation, determines the state of the fruit, controls the rotation angle of the connecting plate 11, drives the connecting plate 11 to connect with channel 1 12 or channel 2 13, and the fruit enters channel 1 12 or channel 2 13 to complete the sorting.

[0121] First, put the fruit onto the size classification conveyor shaft 2. Under the action of gravity, the fruit rolls along the shaft. When the diameter of the fruit is less than the axis distance, the fruit falls onto the feed base plate 1. The fruit is divided into two different feed base plates 1 according to the size of the diameter. Since the feed base plate 1 forms an angle with the horizontal, the fruit rolls under the action of gravity and reaches the conveyor belt 1 3. When the sensor detects that the fruit is conveyed to the starting end of the conveyor belt 2 5, the servo 9 controls the conveyor belt baffle 4 to rotate, blocks the conveying path and controls the conveyor belt 1 3 to stop conveying. The conveyor belt 2 5 is always in motion. When the fruit reaches the conveyor belt 2 5, the arc baffle 10 is at In the vertical state, it blocks the transmission path and can use the arc shape to rotate the fruit in place, so that the camera can capture the shape of the fruit in all directions and perform more accurate identification and classification. When the visual recognition is completed, the arc baffle 10 is rotated to the horizontal under the action of another servo 9. At the same time, the connecting plate 11 adjusts the corresponding angle under the action of another servo 9 according to the classification situation so that the fruit is transmitted to the corresponding channel. When the visual recognition of the fruit on conveyor belt 2 5 is completed, the conveyor belt baffle 4 rotates to the bottom, and conveyor belt 1 3 resumes the transmission mode to carry out the identification and classification of the next fruit. This working method is repeated until the classification work is completed.

[0122] The accuracy of the fruit sorting device was tested. The three existing target detection models, Faster R-CNN, YOLOv5, and YOLOv8, the improved YOLOv8 model that only introduced the RCIoULoss function (YOLOv8-R), the improved YOLOv8 model that only introduced the fireworks algorithm (YOLOv8-F), and the improved YOLOv8 model that introduced the RCIoULoss function and the fireworks algorithm (YOLOv8-RF) used in the embodiment of the present invention were selected for training using a standard fruit dataset. The results are shown in Table 1:

[0123] Table 1

[0124]

[0125] As can be seen from Table 1, the detection accuracy mAP@0.5 of the model adopted in the embodiment of the present invention is improved by 14.64, 7.64, and 4.23 percentage points respectively compared with FasterR-CNN, YOLOv5, and YOLOV8, and the detection accuracy mAP@0.5:0.95 is improved by 12.10, 9.00, and 2.40 percentage points respectively compared with FasterR-CNN, YOLOv5, and YOLOV8, and the number of model parameters is only 11.95, while taking into account both detection accuracy and real-time performance, which proves the advantage of the improved YOLOv8 model that introduces the RCIoULoss function and the fireworks algorithm in the embodiment of the present invention.

[0126] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A fruit sorting device based on improved YOLOv8, characterized in that: include: A feeding bottom plate (1), wherein a size classification transmission shaft (2) is provided on the feeding bottom plate (1); Conveyor belt one (3) is connected to the feed bottom plate (1), the other side of the conveyor belt one (3) is connected to conveyor belt two (5), a conveyor belt baffle (4) is provided between the conveyor belt one (3) and the conveyor belt two (5), and an arc-shaped baffle (10) is provided on the other side of the conveyor belt two (5); A connecting plate (11) is connected to the second conveyor belt (5), and the other side of the connecting plate (11) is provided with a channel 1 (12) and a channel 2 (13); A sensing component electrically connected to the conveyor belt baffle (4) and the conveyor belt one (3) for controlling the states of the conveyor belt one (3) and the conveyor belt baffle (4); A visual recognition component is electrically connected to the arc baffle (10) and is used to collect information about the fruit rolling on the second conveyor belt (5) and control the state of the arc baffle (10); An intelligent sorting drive component is connected to the visual recognition component and the connecting plate (11), and is used to receive data collected by the visual recognition component for analysis, control the state of the connecting plate (11), and drive the connecting plate (11) to connect with channel one (12) or channel two (13); The intelligent sorting drive component includes: An analysis and calculation module, connected to the visual recognition component, adopts an improved YOLOv8 model that introduces the RCIoULoss function and the fireworks algorithm to analyze and determine the state of the fruit; The RCIoULoss function consists of two loss components: dynamic weighted geometric loss and adaptive angle loss. The true frame width is , Gao Wei , the prediction box width is , Gao Wei , the coordinates of the center point of the real frame are , the coordinates of the center point of the prediction box are The distance between the two center points is The angle between the line connecting the two center points and the horizontal line is ; Dynamically weighted geometric loss combines center point offset, radius difference, aspect ratio constraint, and size error, and dynamically adjusts weights by IoU; The IoU dynamic weight factor is , indicating that the weight factor decreases as the intersection over union (IoU) increases; The center point offset penalty formula is: ; in , , represents the horizontal and vertical offset between the center point of the predicted box and the real box; Radial difference penalty formula: ; in , the average radius difference between the predicted box and the real box is expressed by the absolute value difference between the sum of the width and height of the predicted box and the sum of the width and height of the real box; is the radius of the largest target in the dataset; The dual-channel shape constraint formula is: ; This includes aspect ratio constraints and absolute size constraints ; Summarize the dynamic weighted geometric loss formula: ; Adaptive angle loss combines the dynamic weight of angle penalty and the original angle penalty term to dynamically weaken the angle redundancy problem of circular targets; The dynamic weight formula of angle penalty is: ; When the aspect ratio is close to 1, the weight is close to 0, and the angle penalty is almost ignored; The original angle penalty term is: ; Among them for The penalty is greatest when The adaptive angle loss formula is summarized as follows: ; In summary, the RCIoULoss formula is: .

2. The fruit sorting device based on improved YOLOv8 according to claim 1, characterized in that: The sensing component includes: A sensor, mounted on the sensor base (6), for detecting whether there is fruit at the starting end of the second conveyor belt (5); The servo drive assembly 1 is connected to the conveyor belt baffle (4). The servo drive assembly 1 drives the conveyor belt baffle (4) to rotate based on the information detected by the sensor, driving the conveyor belt baffle (4) to be blocked between the conveyor belt 1 (3) and the conveyor belt 2 (5). At the same time, the conveyor belt 1 (3) is controlled to open and close based on the information detected by the sensor.

3. The fruit sorting device based on improved YOLOv8 according to claim 2, characterized in that: The visual recognition component includes: A camera, mounted on a camera base (7), for collecting information about fruits rolling on the second conveyor belt (5); The servo drive assembly 2 is connected to the arc baffle (10). The servo drive assembly 2 drives the arc baffle (10) to rotate based on information detected by the camera, so as to restrict the fruit from rolling on the conveyor belt 2 (5) or to release the restriction.

4. The fruit sorting device based on improved YOLOv8 according to claim 3 is characterized in that: The intelligent sorting drive component also includes: The servo drive assembly three is connected to the connecting plate (11). The servo drive assembly three controls the rotation angle of the connecting plate (11) based on the result determined by the analysis and calculation module, and drives the connecting plate (11) to connect with the channel one (12) or the channel two (13).

5. The fruit sorting device based on improved YOLOv8 according to claim 4 is characterized in that: The servo drive assembly 1, servo drive assembly 2 and servo drive assembly 3 have the same structure but different positions, and each comprises a servo (9) installed on the servo groove (8). The servo (9) is respectively connected to the conveyor baffle (4), the arc baffle (10) or the connecting plate (11) and is used to drive the conveyor baffle (4), the arc baffle (10) or the connecting plate (11) to rotate.

6. A fruit sorting method based on improved YOLOv8, characterized in that: The fruit sorting device according to any one of claims 1 to 5 comprises the following steps: The fruits are placed on the size classification conveyor shaft (2), and the fruits fall into different feeding bottom plates (1) during the rolling process, and then roll on the feeding bottom plates (1) to the conveyor belt (3); The fruit is conveyed to the starting end of the second conveyor belt (5) via the first conveyor belt (3). When the sensing component detects that there is no fruit on the second conveyor belt (5), the fruit is conveyed to the second conveyor belt (5). When the sensing component detects that there is fruit on the second conveyor belt (5), the conveyor belt baffle (4) is controlled to rotate to block between the first conveyor belt (3) and the second conveyor belt (5), and the conveyor belt (3) is controlled to stop conveying. The visual recognition component detects and collects data on the fruits on the conveyor belt 2 (5), and controls the arc baffle (10) to rotate to block the conveying path, driving the fruits to rotate in place on the conveyor belt 2 (5). When the visual recognition component finishes the recognition, the arc baffle (10) is controlled to rotate in the reverse direction; The intelligent sorting drive component receives the data collected by the visual recognition component for analysis and calculation, determines the state of the fruit, controls the rotation angle of the connecting plate (11), drives the connecting plate (11) to connect with channel one (12) or channel two (13), and the fruit enters channel one (12) or channel two (13) to complete the sorting.

Citation Information

Patent Citations

  • Neural network model training method and multimedia information processing method and device

    CN113642727A

  • Sorting and stacking system for sphere-like fruits and vegetables

    CN119303843A

  • Fruit quality detects screening plant

    CN206356274U

  • Intelligent sorting device based on vision

    CN220496998U