1. Introduction
Spices are highly valued for their aroma and culinary significance, having been integral to human culture and cuisine for centuries. Additionally, they are among the most valuable medicinal plants utilized in the food industry and medical science. Due to variations in their composition and price, classification and grading based on quality levels are crucial [
1]. Star anise, as a spice and traditional Chinese medicine with both culinary and medicinal uses, is not only an economically valuable agricultural byproduct but also has extensive medicinal value and cultural significance. In China, star anise is classified as a food and medicinal plant and has been continuously included in the
Chinese Pharmacopoeia [
2], highlighting its significant potential for development and application. According to the
European Pharmacopoeia [
3], both star anise fruit and star anise essential oil have expectorant and antispasmodic properties, making them highly valuable medicinally.
In the traditional Chinese medicine market, the prices of different varieties of star anise vary significantly due to their different chemical compositions. Among them, the Dahong star anise, commonly referred to as autumn produce, has plump fruit segments, a brownish red color, a strong aroma, the best quality, and the highest market value [
4]. The Jiaohua star anise, commonly known as spring produce, has a lighter scent, a weaker aroma, a reddish brown color, slightly lower quality, and a slightly lower price. The Ganzhi branch star anise, which is harvested late, air-dried, and often collected after falling, is black red, of poor quality, and the least expensive.
In recent years, as the demand for star anise trade continues to grow, the overall yield rate of high-quality star anise has become increasingly important. This rate is also a crucial standard for evaluating the overall quality of single batches in import and export. Therefore, the ability to quickly and accurately sort different types of star anise is crucial not only for improving overall quality but also for enhancing the added value of agricultural products, making it of great practical significance. Machine vision, as a rapid and non-destructive detection method [
5], has a wide range of applications in agriculture, including crop seed screening, crop pest and disease monitoring, grain detection, and plant phenotyping. In recent years, its rapid development in agriculture has recently made the non-destructive detection of agricultural products feasible [
6]. Machine vision algorithms are mainly categorized into traditional machine learning algorithms and more advanced deep learning algorithms. Star anise, a small-scale agricultural product, is typically studied using traditional image detection methods that integrate machine learning with features such as color and texture to achieve classification and recognition. Minhui An et al. [
7] classified walnut shells and kernels using SVM and ELM methods in the near-infrared spectrum, achieving 97% accuracy. Yanqiu Zhu et al. [
8] used the PLS-DA algorithm in near-infrared spectroscopy to differentiate and classify corn seeds from different years, achieving 88.75% classification accuracy. Junyan Xu et al. [
9] collected spectral data characteristics of walnut mold at different stages, preprocessed the spectra using SNV, extracted feature bands with PCA, and modeled the feature bands using SVM, achieving 93% overall classification accuracy. Santos et al. [
10] classified papayas of different maturity levels using a random forest method, achieving 94.3% classification accuracy on the cross-validation set. Although machine learning methods are simple and efficient, they have limited sample processing capabilities and poor generalization and robustness, making them less suitable for practical implementation or deployment. In contrast, deep learning offers robust sample processing capabilities, faster speeds, and higher recognition accuracy, overcoming the limitations of traditional machine learning methods. As a result, it has gradually become a key branch in agricultural material detection [
11].
Deep learning algorithms based on machine vision are developing rapidly and are widely used in scientific research in agriculture [
12], animal husbandry [
13], and other fields, including sensor monitoring, automation, and robotic operations. Recent explorations by domestic and international scholars into the detection and grading of fields such as food [
14] and traditional Chinese medicinal materials [
15] have provided valuable references for the classification of star anise varieties. Depending on the dataset, feature selection, and problem complexity, each method has its own advantages and limitations, highlighting the importance in selecting the appropriate approach for different scenarios. Wang et al. [
16] proposed the WT-YOLOM model to detect endogenous impurities in walnut kernels, combining SPPF and MobileNet modules for improvements, achieving a recognition accuracy of 94.4%. Xue et al. [
17] used the Faster R-CNN model to detect defects in ginseng, a traditional Chinese medicinal material, with an accuracy of up to 95%. Feiyun Wang et al. [
18] improved YOLOv5 by integrating the DSConv module and using EIOU as the loss function to achieve real-time, efficient, non-destructive detection of various kiwi fruit defects. The improved model reduced the training loss by 0.013, decreased the number of parameters, and achieved an overall accuracy of 97.7%. Yang et al. [
19] added DSConv to YOLOv8s to reduce the model size and incorporated feature enhancement modules to improve recognition accuracy for efficient detection of different tomato varieties, achieving an mAP of 93.4%. Liu et al. [
20] improved the YOLOv5 algorithm by adding the lightweight upsampling operator CARAFE to reduce the workload of manual cottonseed sorting. Results showed that the detection mAP for uncoated cottonseeds reached 99.5%, and for coated cottonseeds, it reached 99.2%, achieving efficient detection. Xie et al. [
21] combined deformable convolutions and spatial pyramids to construct the Tea-YOLOv8s model, achieving multi-feature fusion. The study results showed that the average recognition accuracy for tea buds was 88.27%, with an inference time of 37.1 ms. Zhao et al. [
22] proposed an enhanced model based on YOLOv7 to improve plant disease detection, using the DW-ELAN structure to reduce model parameters and computational load. The improved model achieved mAP, F1 score, and Recall of 96.75%, 94%, and 89.69%, respectively. These studies demonstrate that YOLO models have high accuracy and strong generalization, allowing for tailored improvement plans based on the characteristics and scenarios of the detection targets, making them suitable for application and deployment in agriculture.
At the same time, image blurring is a significant issue that needs to be addressed in the agricultural field. In practical applications, image acquisition is often affected by factors such as machine vibration, operating speed, and occlusion, leading to low-resolution, blurred, and defocused images [
23], which is the challenge and research difficulty.
In summary, several main issues exist. First, research on star anise in the field of computer vision is limited, with a lack of reference frameworks. Second, the current related research mainly uses machine learning methods, with small sample sizes and poor model generalization, making future deployment in practical applications difficult. Third, in real detection environments, due to fast detection speeds and high model frame rates, low-resolution or blurred images often occur. To address these issues, this paper explores star anise variety detection technology using machine vision, focusing on star anise from Funing, Yunnan Province. Leveraging the YOLOv8 model, the study develops a high efficiency detection network, SA-SRYOLOv8, specifically designed for star anise through lightweight improvements, integration of a front-end SRGAN network, non-similar data augmentation, and optimized training strategies. The research results of this study provide theoretical support and an important reference for the classification of star anise varieties.