CN114740091A - Watermelon maturity detection method and system based on acoustic analysis and machine learning - Google Patents

Watermelon maturity detection method and system based on acoustic analysis and machine learning Download PDF

Info

Publication number
CN114740091A
CN114740091A CN202210663997.3A CN202210663997A CN114740091A CN 114740091 A CN114740091 A CN 114740091A CN 202210663997 A CN202210663997 A CN 202210663997A CN 114740091 A CN114740091 A CN 114740091A
Authority
CN
China
Prior art keywords
watermelon
sample
time
maturity
samples
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210663997.3A
Other languages
Chinese (zh)
Other versions
CN114740091B (en
Inventor
滕召胜
黄潇
唐求
余舟
花金辉
王翔宇
马聪
刘涛
李琛恭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan University
Original Assignee
Hunan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan University filed Critical Hunan University
Priority to CN202210663997.3A priority Critical patent/CN114740091B/en
Publication of CN114740091A publication Critical patent/CN114740091A/en
Application granted granted Critical
Publication of CN114740091B publication Critical patent/CN114740091B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N29/00Investigating or analysing materials by the use of ultrasonic, sonic or infrasonic waves; Visualisation of the interior of objects by transmitting ultrasonic or sonic waves through the object
    • G01N29/04Analysing solids
    • G01N29/045Analysing solids by imparting shocks to the workpiece and detecting the vibrations or the acoustic waves caused by the shocks
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N29/00Investigating or analysing materials by the use of ultrasonic, sonic or infrasonic waves; Visualisation of the interior of objects by transmitting ultrasonic or sonic waves through the object
    • G01N29/44Processing the detected response signal, e.g. electronic circuits specially adapted therefor
    • G01N29/4409Processing the detected response signal, e.g. electronic circuits specially adapted therefor by comparison
    • G01N29/4418Processing the detected response signal, e.g. electronic circuits specially adapted therefor by comparison with a model, e.g. best-fit, regression analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2218/00Aspects of pattern recognition specially adapted for signal processing
    • G06F2218/02Preprocessing
    • G06F2218/04Denoising
    • G06F2218/06Denoising by applying a scale-space analysis, e.g. using wavelet analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2218/00Aspects of pattern recognition specially adapted for signal processing
    • G06F2218/08Feature extraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2218/00Aspects of pattern recognition specially adapted for signal processing
    • G06F2218/12Classification; Matching
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Biochemistry (AREA)
  • Evolutionary Computation (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Immunology (AREA)
  • Health & Medical Sciences (AREA)
  • Chemical & Material Sciences (AREA)
  • Analytical Chemistry (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Signal Processing (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Acoustics & Sound (AREA)
  • Medical Informatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Investigating Or Analyzing Materials By The Use Of Ultrasonic Waves (AREA)

Abstract

本发明公开了一种基于声学分析和机器学习的西瓜成熟度检测方法及系统,方法包括:获取西瓜样本的敲击声音信号和重量组成数据集,将西瓜样本按照成熟度分类,并将数据集划分为训练集和测试集;构建成熟度检测模型以计算目标西瓜样本的成熟度;用训练集训练成熟度检测模型,然后用测试集测试成熟度检测模型,最后计算准确度并记录,继续执行用训练集训练成熟度检测模型的步骤,直到准确度最高,得到训练好的成熟度检测模型;获取西瓜测试样本的敲击声音信号和重量,并输入训练好的成熟度检测模型,得到西瓜测试样本的成熟度。本发明实现了西瓜成熟度检测的需求,提高了检测准确度,在小样本数据集中可以完成模型的训练和测试,提升了适用性。

Figure 202210663997

The invention discloses a watermelon maturity detection method and system based on acoustic analysis and machine learning. The method comprises: acquiring a data set composed of a tap sound signal and weight of a watermelon sample, classifying the watermelon samples according to maturity, and classifying the data set Divide into training set and test set; build a maturity detection model to calculate the maturity of the target watermelon sample; train the maturity detection model with the training set, then test the maturity detection model with the test set, and finally calculate the accuracy and record it, and continue to execute The steps of training the maturity detection model with the training set until the accuracy is the highest, and the trained maturity detection model is obtained; the tap sound signal and weight of the watermelon test sample are obtained, and the trained maturity detection model is input to obtain the watermelon test The maturity of the sample. The invention fulfills the requirement of watermelon maturity detection, improves the detection accuracy, can complete the training and testing of the model in the small sample data set, and improves the applicability.

Figure 202210663997

Description

基于声学分析和机器学习的西瓜成熟度检测方法及系统Watermelon maturity detection method and system based on acoustic analysis and machine learning

技术领域technical field

本发明涉及音频分析领域,尤其涉及一种基于声学分析和机器学习的西瓜成熟度检测方法及系统。The invention relates to the field of audio analysis, in particular to a watermelon maturity detection method and system based on acoustic analysis and machine learning.

背景技术Background technique

我国西瓜产量大,但是在世界市场上存在竞争力不足、口量小和出口单价低等问题。原因是我国西瓜成熟度检测体系落后,导致各种成熟度的西瓜混杂在一起,降低了整体质量。my country's watermelon production is large, but there are problems such as insufficient competitiveness, small export volume and low export unit price in the world market. The reason is that my country's watermelon maturity detection system is backward, resulting in mixed watermelons of various maturity levels, reducing the overall quality.

目前对于西瓜成熟度检测主要采用基于声学特性的检测方法,因为敲击西瓜所产生的声音信号更容易获取,可以反映西瓜的果肉硬度、吸收和反射特性、大小、含水量等信息,从而可以判断西瓜的成熟度。At present, the detection method based on acoustic characteristics is mainly used for the detection of watermelon maturity, because the sound signal generated by tapping the watermelon is easier to obtain, which can reflect the watermelon pulp hardness, absorption and reflection characteristics, size, water content and other information, so that it can be judged Ripeness of watermelon.

目前基于声学特性的检测方法大都是采用单一频率点的声学分析方法,先采用傅里叶变换或快速傅里叶变换,对声音信号进行频域分析后提取单一频率点,然后将单一频率点与质量特征进行数学运算,得到评价指标,通过对比评价指标和设定范围的大小,确定成熟度,需要大量的数据样本来确定评价指标范围。由于单一频率点难以表达出样本的声学特征分布情况,因为它仅是频域上的一个最大频率成分,忽略了其他频域特征,且完全缺失了声音信号在时域上的变化情况。同时,评价指标的大小很容易受到单一频率点的计算结果误差影响,因为它只是通过简单的数学运算关系所得到。因此目前基于声学特性的检测方法适用性差,容易受到样本单一频率点误差的影响,准确度低。At present, most of the detection methods based on acoustic characteristics use the acoustic analysis method of a single frequency point. First, the Fourier transform or fast Fourier transform is used to analyze the sound signal in the frequency domain to extract a single frequency point, and then the single frequency point is compared with the single frequency point. Mathematical operations are performed on the quality characteristics to obtain evaluation indicators. By comparing the evaluation indicators and the size of the set range, the maturity level is determined. A large number of data samples are needed to determine the evaluation indicator range. Because it is difficult to express the acoustic feature distribution of the sample with a single frequency point, it is only a maximum frequency component in the frequency domain, ignoring other frequency domain features, and completely missing the variation of the sound signal in the time domain. At the same time, the size of the evaluation index is easily affected by the error of the calculation result of a single frequency point, because it is only obtained through a simple mathematical operation relationship. Therefore, the current detection methods based on acoustic characteristics have poor applicability, are easily affected by the error of a single frequency point of the sample, and have low accuracy.

而其他西瓜成熟检测方法,例如基于红外光谱检测、机器视觉检测等方法,都存在检测设备复杂,成本高,获取评价指标困难等缺点。However, other watermelon ripening detection methods, such as those based on infrared spectrum detection and machine vision detection, have shortcomings such as complex detection equipment, high cost, and difficulty in obtaining evaluation indicators.

机器学习是人工智能中最具智能特征,最前沿的研究领域之一,其能够解决使用传统方法太过复杂或者不存在已知算法的问题。其应用领域广泛且具有良好的应用前景。如何将机器学习的方法应用到西瓜成熟度检测中,也是值得研究的问题。Machine learning is one of the most intelligent features of artificial intelligence and one of the most cutting-edge research areas, which can solve problems that are too complicated or no known algorithms exist using traditional methods. Its application fields are wide and have good application prospects. How to apply machine learning methods to watermelon maturity detection is also a problem worth studying.

发明内容SUMMARY OF THE INVENTION

本发明要解决的技术问题就在于:针对现有技术存在的技术问题,本发明提供一种基于声学分析和机器学习的西瓜成熟度检测方法及系统,实现了西瓜成熟度检测的需求,提高了检测准确度,在小样本数据集中可以完成模型的训练和测试,提升了适用性。The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides a watermelon maturity detection method and system based on acoustic analysis and machine learning, which realizes the demand for watermelon maturity detection and improves the Detection accuracy, the training and testing of the model can be completed in a small sample data set, which improves the applicability.

为解决上述技术问题,本发明提出的技术方案为:In order to solve the above-mentioned technical problems, the technical scheme proposed by the present invention is:

一种基于声学分析和机器学习的西瓜成熟度检测方法,包括以下步骤:A watermelon maturity detection method based on acoustic analysis and machine learning, comprising the following steps:

获取西瓜样本的敲击声音信号和重量,并组成数据集,将所述数据集中的西瓜样本按照成熟度分类,并将所述数据集划分为训练集和测试集;Obtain the tap sound signal and weight of the watermelon samples, and form a data set, classify the watermelon samples in the data set according to maturity, and divide the data set into a training set and a test set;

构建成熟度检测模型,所述成熟度检测模型用于提取西瓜样本敲击声音信号的时频特征,然后根据时频特征和对应的重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离,最后在与目标西瓜样本距离最近的K个西瓜样本对应的类别中,将出现频率最高的类别作为目标西瓜样本的成熟度;Build a maturity detection model, the maturity detection model is used to extract the time-frequency features of the watermelon sample percussion sound signal, and then calculate the distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency characteristics and the corresponding weight, Finally, among the categories corresponding to the K watermelon samples that are closest to the target watermelon sample, the category with the highest frequency is used as the maturity of the target watermelon sample;

用所述训练集训练成熟度检测模型,然后用所述测试集测试成熟度检测模型,最后计算准确度并记录,重复本步骤直到准确度最高,得到训练好的成熟度检测模型;Use the training set to train the maturity detection model, then use the test set to test the maturity detection model, finally calculate the accuracy and record, repeat this step until the accuracy is the highest, and obtain the trained maturity detection model;

获取西瓜测试样本的敲击声音信号和重量,并输入训练好的成熟度检测模型,得到西瓜测试样本的成熟度。Obtain the tap sound signal and weight of the watermelon test sample, and input the trained maturity detection model to obtain the maturity of the watermelon test sample.

进一步的,提取西瓜样本敲击声音信号的时频特征具体步骤包括:Further, the specific steps of extracting the time-frequency characteristics of the watermelon sample percussion sound signal include:

根据所有西瓜样本的敲击声音信号,计算FFT频谱并提取频谱特征;Calculate the FFT spectrum and extract the spectral features according to the tapping sound signals of all the watermelon samples;

根据所提取的频谱特征,确定STFT窗函数频谱分辨率参数f的取值范围,根据时间 分辨率参数τ和频谱分辨率参数f的值构建STFT窗函数

Figure 592312DEST_PATH_IMAGE001
; According to the extracted spectral features, the value range of the spectral resolution parameter f of the STFT window function is determined, and the STFT window function is constructed according to the values of the time resolution parameter τ and the spectral resolution parameter f
Figure 592312DEST_PATH_IMAGE001
;

根据所述STFT窗函数

Figure 203422DEST_PATH_IMAGE001
和每个西瓜样本的敲击声音信号,计 算每个西瓜样本的时频矩阵。 According to the STFT window function
Figure 203422DEST_PATH_IMAGE001
and the percussion sound signal of each watermelon sample, calculate the time-frequency matrix of each watermelon sample.

进一步的,所述时频矩阵的函数表达式为:Further, the functional expression of the time-frequency matrix is:

Figure 100002_DEST_PATH_IMAGE002
Figure 100002_DEST_PATH_IMAGE002

上式中,x(t)为西瓜样本的敲击声音信号,

Figure 353781DEST_PATH_IMAGE001
为所构建的STFT 窗函数,其中τ为时间分辨参数,f为频谱分辨率参数,[f i , f i+1]之间的频谱间隔代表频谱 分辨率的带宽。 In the above formula, x ( t ) is the percussion sound signal of the watermelon sample,
Figure 353781DEST_PATH_IMAGE001
is the constructed STFT window function, where τ is the time resolution parameter, f is the spectral resolution parameter, and the spectral interval between [ f i , f i +1 ] represents the bandwidth of the spectral resolution.

进一步的,根据时频特征和重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离具体步骤包括:Further, the specific steps for calculating the distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency feature and weight include:

根据目标西瓜样本与训练集中其他西瓜样本的时频矩阵,计算目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离,根据目标西瓜样本与训练集中其他西瓜样本的重量,计算目标西瓜样本与训练集中其他西瓜样本之间的重量特征距离;Calculate the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, and calculate the target watermelon sample according to the weight of the target watermelon sample and other watermelon samples in the training set. The weight feature distance from other watermelon samples in the training set;

对目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离和重量特征距离归一化;Normalize the time-frequency matrix distance and weight feature distance between the target watermelon sample and other watermelon samples in the training set;

根据信息融合权重参数λ,以及归一化后的时频矩阵距离和重量特征距离,计算目标西瓜样本与训练集中其他西瓜样本之间的距离。According to the information fusion weight parameter λ , as well as the normalized time-frequency matrix distance and weight feature distance, the distance between the target watermelon sample and other watermelon samples in the training set is calculated.

进一步的,训练集中其他西瓜样本包括目标西瓜样本的第k个最邻近西瓜样本,目标西瓜样本与第k个最邻近西瓜样本之间的距离的函数表达式为:Further, other watermelon samples in the training set include the kth nearest watermelon sample of the target watermelon sample, and the function expression of the distance between the target watermelon sample and the kth nearest watermelon sample is:

Figure 100002_DEST_PATH_IMAGE003
Figure 100002_DEST_PATH_IMAGE003

上式中,λ为信息融合权重参数,m k 为目标西瓜样本与第k个最邻近西瓜样本之间的时频矩阵距离,n k 为目标西瓜样本与第k个最邻近西瓜样本之间的重量特征距离。In the above formula, λ is the information fusion weight parameter, m k is the time-frequency matrix distance between the target watermelon sample and the kth nearest watermelon sample, n k is the distance between the target watermelon sample and the kth nearest watermelon sample. Weight feature distance.

进一步的,用训练集训练成熟度检测模型之前还包括优化时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的步骤,具体包括:Further, before using the training set to train the maturity detection model, it also includes the steps of optimizing the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ , specifically including:

若时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值未达到预设的最大值,以预设步长增加时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值,执行用所述训练集训练成熟度检测模型的步骤;If the values of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ do not reach the preset maximum value, increase the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter with a preset step size The value of λ , executes the step of training maturity detection model with described training set;

若时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值达到预设的最大值,从记录的所有准确度中查找最高准确度,将时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值调整为最高准确度对应的值,执行用所述训练集训练成熟度检测模型的步骤。If the value of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ reaches the preset maximum value, find the highest accuracy from all the recorded accuracies, and use the time resolution parameter τ , the spectral resolution parameter The values of f and the information fusion weight parameter λ are adjusted to the value corresponding to the highest accuracy, and the step of training the maturity detection model with the training set is performed.

进一步的,获取西瓜样本的敲击声音信号之后,还包括提取有效信号的步骤,具体包括:Further, after acquiring the tapping sound signal of the watermelon sample, it also includes the step of extracting an effective signal, which specifically includes:

计算敲击声音信号每一帧的能量,保留能量大于预设阈值的帧,得到一次过滤后的敲击声音信号;Calculate the energy of each frame of the percussion sound signal, retain the frames whose energy is greater than the preset threshold, and obtain a filtered percussion sound signal;

对一次过滤后的敲击声音信号进行滤波,得到二次过滤后的敲击声音信号并作为敲击声音信号的有效信号。The percussion sound signal filtered once is filtered to obtain the percussion sound signal filtered for the second time, which is used as an effective signal of the percussion sound signal.

本发明还提出一种基于声学分析和机器学习的西瓜成熟度检测系统,包括:The present invention also proposes a watermelon maturity detection system based on acoustic analysis and machine learning, including:

数据获取单元,用于获取西瓜样本的敲击声音信号和重量,并组成数据集,将所述数据集中的西瓜样本按照成熟度分类,并将所述数据集划分为训练集和测试集;还用于获取西瓜测试样本的敲击声音信号和重量,并输入训练好的成熟度检测模型,得到西瓜测试样本的成熟度;a data acquisition unit for acquiring the tap sound signal and weight of the watermelon samples, and forming a data set, classifying the watermelon samples in the data set according to maturity, and dividing the data set into a training set and a test set; and It is used to obtain the tap sound signal and weight of the watermelon test sample, and input the trained maturity detection model to obtain the maturity of the watermelon test sample;

模型构建单元,用于构建成熟度检测模型,所述成熟度检测模型用于提取西瓜样本敲击声音信号的时频特征,然后根据时频特征和对应的重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离,最后在与目标西瓜样本距离最近的K个西瓜样本对应的类别中,将出现频率最高的类别作为目标西瓜样本的成熟度;The model building unit is used to build a maturity detection model, and the maturity detection model is used to extract the time-frequency characteristics of the tap sound signal of the watermelon sample, and then calculate the target watermelon sample and other watermelons in the training set according to the time-frequency characteristics and the corresponding weight. The distance between samples, and finally, in the categories corresponding to the K watermelon samples that are closest to the target watermelon sample, the category with the highest frequency is used as the maturity of the target watermelon sample;

模型训练及测试单元,用于用所述训练集训练成熟度检测模型,然后用所述测试集测试成熟度检测模型,最后计算准确度并记录,继续用所述训练集训练成熟度检测模型,直到准确度最高,得到训练好的成熟度检测模型。The model training and testing unit is used to train the maturity detection model with the training set, then use the test set to test the maturity detection model, finally calculate the accuracy and record, and continue to use the training set to train the maturity detection model, Until the accuracy is the highest, the trained maturity detection model is obtained.

进一步的,所述成熟度检测模型提取西瓜样本敲击声音信号的时频特征时,所述模型构建单元被配置以执行以下步骤:Further, when the maturity detection model extracts the time-frequency features of the watermelon sample tapping sound signal, the model building unit is configured to perform the following steps:

根据所有西瓜样本的敲击声音信号,计算FFT频谱并提取频谱特征;Calculate the FFT spectrum and extract the spectral features according to the tapping sound signals of all the watermelon samples;

根据所提取的频谱特征,确定STFT窗函数频谱分辨率参数f的取值范围,根据时间分辨率参数τ和频谱分辨率参数f的值构建STFT窗函数;According to the extracted spectral characteristics, determine the value range of the spectral resolution parameter f of the STFT window function, and construct the STFT window function according to the values of the time resolution parameter τ and the spectral resolution parameter f ;

根据所述STFT窗函数和每个西瓜样本的敲击声音信号,计算每个西瓜样本的时频矩阵。According to the STFT window function and the percussion sound signal of each watermelon sample, the time-frequency matrix of each watermelon sample is calculated.

进一步的,所述成熟度检测模型根据时频特征和重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离时,所述模型构建单元被配置以执行以下步骤:Further, when the maturity detection model calculates the distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency feature and weight, the model building unit is configured to perform the following steps:

根据目标西瓜样本与训练集中其他西瓜样本的时频矩阵,计算目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离,根据目标西瓜样本与训练集中其他西瓜样本的重量,计算目标西瓜样本与训练集中其他西瓜样本之间的重量特征距离;Calculate the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, and calculate the target watermelon sample according to the weight of the target watermelon sample and other watermelon samples in the training set. The weight feature distance from other watermelon samples in the training set;

对目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离和重量特征距离归一化;Normalize the time-frequency matrix distance and weight feature distance between the target watermelon sample and other watermelon samples in the training set;

根据信息融合权重参数λ,以及归一化后的时频矩阵距离和重量特征距离,计算目标西瓜样本与训练集中其他西瓜样本之间的距离。According to the information fusion weight parameter λ , as well as the normalized time-frequency matrix distance and weight feature distance, the distance between the target watermelon sample and other watermelon samples in the training set is calculated.

与现有技术相比,本发明的优点在于:Compared with the prior art, the advantages of the present invention are:

本发明实现了基于声学分析的西瓜成熟度检测需求,提取包含时间信息和频率信息的时频特征矩阵作为样本的声学特征,解决了单一频率点作为声学特征容易受到干扰的问题。而且通过改进STFT窗函数来优化时频矩阵的计算公式,降低了时频特征矩阵的维度,减少了后续计算量,同时为后续分类算法提供了更能代表样本的特征。The invention realizes the requirement of watermelon maturity detection based on acoustic analysis, extracts the time-frequency characteristic matrix including time information and frequency information as the acoustic characteristic of the sample, and solves the problem that a single frequency point is easily interfered as an acoustic characteristic. Moreover, the calculation formula of the time-frequency matrix is optimized by improving the STFT window function, which reduces the dimension of the time-frequency feature matrix, reduces the subsequent calculation amount, and provides features that are more representative of the sample for the subsequent classification algorithm.

本发明融合了时频特征矩阵和质量特征进行机器学习分类,建立了多种信息特征与西瓜成熟度之间的关系,解决了多种信息特征之间维度不统一,数量级差异较大的问题。融合了时频特征矩阵和质量特征的机器学习分类不再需要大量的样本来设定评价指标范围,可以在小样本数据集上进行训练和测试,就能够达到更高的准确度,提升适用性。The invention integrates the time-frequency feature matrix and the quality feature for machine learning classification, establishes the relationship between various information features and watermelon maturity, and solves the problems that the dimensions of the various information features are not uniform and the order of magnitude difference is large. Machine learning classification that combines time-frequency feature matrix and quality feature no longer requires a large number of samples to set the evaluation index range, and can be trained and tested on a small sample data set, which can achieve higher accuracy and improve applicability .

附图说明Description of drawings

图1为本发明实施例一的技术架构图。FIG. 1 is a technical architecture diagram of Embodiment 1 of the present invention.

图2为本发明实施例一的流程图。FIG. 2 is a flowchart of Embodiment 1 of the present invention.

图3为本发明实施例一的成熟度检测模型工作流程图。FIG. 3 is a working flowchart of a maturity detection model according to Embodiment 1 of the present invention.

图4为本发明实施例一中提取的时频特征与常规方法提取的时频特征对比图。FIG. 4 is a comparison diagram of the time-frequency feature extracted in the first embodiment of the present invention and the time-frequency feature extracted by the conventional method.

图5为本发明实施例一中敲击声音信号的原始信号和有效信号对比图。FIG. 5 is a comparison diagram of the original signal and the effective signal of the percussion sound signal in the first embodiment of the present invention.

具体实施方式Detailed ways

以下结合说明书附图和具体优选的实施例对本发明作进一步描述,但并不因此而限制本发明的保护范围。The present invention will be further described below with reference to the accompanying drawings and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.

实施例一Example 1

基于声学分析的时频分析方法有很多,例如短时傅里叶变换(Short-TimeFourier Transform,STFT),小波变换,S变换等,其中STFT因计算速度快,提取声音特征效果较好而得到普遍应用。STFT是可以通过窗函数将声音信号切割为指定时间长短的帧信号,并对每一帧信号快速傅里叶变换(Fast Fourier Transform,FFT),得到频域特征,并将这些帧的频域特征组合,得到表示时频特征的二维矩阵。但由于STFT的窗函数是固定的,时间分辨率不变,而且FFT的频谱分辨率也是确定的,若信号特征主要集中的低频区域,那么就会造成高频区域数据冗余,使得后续计算速度减慢。同时,窗函数的时间分辨率也是影响评价指标优劣的重要因素,它的确定需要根据样本做出自适应的改变。There are many time-frequency analysis methods based on acoustic analysis, such as Short-Time Fourier Transform (STFT), wavelet transform, S-transform, etc. Among them, STFT is widely used because of its fast calculation speed and good effect of extracting sound features. application. STFT can cut the sound signal into frame signals of a specified time length through a window function, and perform Fast Fourier Transform (FFT) on each frame signal to obtain frequency domain features, and convert the frequency domain features of these frames. Combined, a two-dimensional matrix representing time-frequency features is obtained. However, since the window function of STFT is fixed, the time resolution is unchanged, and the spectral resolution of FFT is also determined, if the signal features are mainly concentrated in the low-frequency region, it will cause data redundancy in the high-frequency region, making the subsequent calculation speed. slow down. At the same time, the time resolution of the window function is also an important factor affecting the quality of the evaluation index, and its determination needs to be adaptively changed according to the sample.

机器学习分类算法有很多,例如K近邻(K-Nearest Neighbor,KNN),支持向量机,逻辑回归,随机森林等,其中KNN具有原理简单,计算容易等优点适用于西瓜成熟度检测。KNN是通过计算测试样本特征与训练样本特征之间的距离,来进行判断。距离计算过程中,对样本的每一个特征赋予相同的权重,这将导致其中一些重要的特征点被忽略,进而降低分类准确度。在西瓜成熟度检测中,声学分析得到的时频特征二维矩阵和重量特征在数据维度和数量级都相差太多,但对最终分类结果都有重要的影响,需要均衡二维矩阵和重量特征的影响权重,这是传统KNN分类算法无法实现的。There are many machine learning classification algorithms, such as K-Nearest Neighbor (KNN), support vector machine, logistic regression, random forest, etc. Among them, KNN has the advantages of simple principle and easy calculation, which is suitable for watermelon maturity detection. KNN makes judgments by calculating the distance between the test sample features and the training sample features. In the process of distance calculation, the same weight is assigned to each feature of the sample, which will cause some important feature points to be ignored, thereby reducing the classification accuracy. In the watermelon maturity detection, the two-dimensional matrix of time-frequency features and the weight feature obtained by acoustic analysis are too different in data dimension and order of magnitude, but they have an important impact on the final classification result. It is necessary to balance the two-dimensional matrix and the weight feature. Influence weight, which cannot be achieved by traditional KNN classification algorithm.

为了解决上述问题,如图1所示,本实施例提出一种基于声学分析和机器学习的西瓜成熟度检测方法,建立优化STFT时频特征提取算法和信息融合KNN分类算法,并进行组合,实现西瓜成熟度检测的需求,提高检测准确度,在小样本数据集中可以完成系统的训练测试,提升适用性。In order to solve the above problems, as shown in Figure 1, this embodiment proposes a watermelon maturity detection method based on acoustic analysis and machine learning, establishes an optimized STFT time-frequency feature extraction algorithm and an information fusion KNN classification algorithm, and combines them to achieve To meet the needs of watermelon maturity detection, improve the detection accuracy, and complete the training and testing of the system in a small sample data set to improve the applicability.

如图2所示,本实施例的基于声学分析和机器学习的西瓜成熟度检测方法,包括以下步骤:As shown in Figure 2, the method for detecting the maturity of watermelon based on acoustic analysis and machine learning in this embodiment includes the following steps:

S1)获取西瓜样本的敲击声音信号和重量,并组成数据集,将数据集中的西瓜样本按照成熟度分类,一般分为[不成熟,成熟]或[不成熟,适成熟,过成熟]等类别;S1) Obtain the percussion sound signal and weight of the watermelon samples, and form a data set. The watermelon samples in the data set are classified according to their maturity, which are generally divided into [Immature, Ripe] or [Immature, Suitable Ripe, Overripe], etc. category;

S2)将数据集划分为训练集和测试集;S2) Divide the dataset into training set and test set;

S3)构建成熟度检测模型,如图3所示,该成熟度检测模型利用优化STFT时频特征提取算法来提取西瓜样本敲击声音信号的时频特征,还利用信息融合KNN分类算法,将目标西瓜样本作为测试样本,由时频特征和对应的重量计算测试样本与训练集中其他西瓜样本之间的距离,最后在与测试样本距离最近的K个西瓜样本对应的类别中,将出现频率最高的类别作为测试样本的成熟度;S3) Build a maturity detection model, as shown in Figure 3, the maturity detection model uses the optimized STFT time-frequency feature extraction algorithm to extract the time-frequency characteristics of the watermelon sample tapping sound signal, and also uses the information fusion KNN classification algorithm to classify the target. The watermelon sample is used as the test sample, and the distance between the test sample and other watermelon samples in the training set is calculated from the time-frequency features and the corresponding weight. the maturity of the category as a test sample;

S4)用训练集训练成熟度检测模型,然后用测试集测试成熟度检测模型,最后计算准确度并记录,重复本步骤直到准确度最高,得到训练好的成熟度检测模型;S4) Use the training set to train the maturity detection model, then use the test set to test the maturity detection model, finally calculate the accuracy and record, repeat this step until the accuracy is the highest, and obtain the trained maturity detection model;

S5)获取西瓜测试样本的敲击声音信号和重量,并输入由上述步骤训练好的成熟度检测模型,得到西瓜测试样本的成熟度。S5) Obtain the tap sound signal and weight of the watermelon test sample, and input the maturity detection model trained by the above steps to obtain the maturity of the watermelon test sample.

如图1所示,优化STFT时频特征提取算法具体包括以下步骤:As shown in Figure 1, optimizing the STFT time-frequency feature extraction algorithm specifically includes the following steps:

步骤一:计算数据集的FFT频谱,该数据集包含所有西瓜样本的敲击声音信号,信号的频谱会直接反映信号的频率成分,可以通过频谱观察声音信号的频率特征分布情况,FFT频谱的表达式如下:Step 1: Calculate the FFT spectrum of the data set. The data set contains the tap sound signals of all watermelon samples. The spectrum of the signal will directly reflect the frequency components of the signal. The frequency characteristic distribution of the sound signal can be observed through the spectrum. The expression of the FFT spectrum The formula is as follows:

Figure 574809DEST_PATH_IMAGE004
(1)
Figure 574809DEST_PATH_IMAGE004
(1)

上式中x(t)为西瓜样本的敲击声音信号,m为西瓜样本的序号,f为频率;In the above formula, x ( t ) is the percussion sound signal of the watermelon sample, m is the serial number of the watermelon sample, and f is the frequency;

步骤二:计算所有西瓜样本在每个频点f的方差,表示该频点样本之间的差异,根据方差值划分频率分辨率是因为方差能展示西瓜敲击声音信号在每个频率点上的差异性,频率点的方差越大代表差异性越大,对西瓜成熟度区分度越大,方差的表达式如下:Step 2: Calculate the variance of all watermelon samples at each frequency point f , indicating the difference between the samples at the frequency point. The frequency resolution is divided according to the variance value because the variance can show the watermelon tapping sound signal at each frequency point. The difference of the frequency points, the greater the variance of the frequency points, the greater the difference, and the greater the degree of discrimination of watermelon maturity. The expression of the variance is as follows:

Figure DEST_PATH_IMAGE005
(2)
Figure DEST_PATH_IMAGE005
(2)

上式中M是样本总数,m为西瓜样本的序号,X m (f)是频率点的实际值,X’ m (f)是频率点的平均值;In the above formula, M is the total number of samples, m is the serial number of the watermelon sample, X m ( f ) is the actual value of the frequency point, and X' m ( f ) is the average value of the frequency point;

步骤三:构建STFT窗函数

Figure 976971DEST_PATH_IMAGE001
,STFT窗函数中,时间分辨参数τ决 定了窗口长度;频谱分辨率参数f取值范围为f=[f 1 ,f 2 …f N ],确定取值范围f=[f 1 ,f 2 …f N ]表 达式如下 Step 3: Build the STFT window function
Figure 976971DEST_PATH_IMAGE001
, in the STFT window function, the time resolution parameter τ determines the window length; the spectral resolution parameter f has a value range of f = [ f 1 , f 2 ... f N ], and determines the value range f = [ f 1 , f 2 ... f N ] expression is as follows

Figure 645850DEST_PATH_IMAGE006
(3)
Figure 645850DEST_PATH_IMAGE006
(3)

上式中,DX(f)为所有西瓜样本在每个频点f的方差,N为STFT频谱带宽的个数, [f i , f i+1]之间的频谱间隔代表频谱分辨率的带宽,由步骤一和步骤二可以得到,窗函数

Figure 560585DEST_PATH_IMAGE001
的频谱分辨率参数f是自适应数据集频谱特征分布情况改变的;In the above formula, DX ( f ) is the variance of all watermelon samples at each frequency f , N is the number of STFT spectral bandwidths, and the spectral interval between [ f i , f i +1 ] represents the bandwidth of the spectral resolution , can be obtained from steps 1 and 2, the window function
Figure 560585DEST_PATH_IMAGE001
The spectral resolution parameter f is changed by the spectral feature distribution of the adaptive dataset;

步骤四:根据STFT窗函数

Figure 846073DEST_PATH_IMAGE001
,优化STFT变换的推导公式如下 Step 4: According to the STFT window function
Figure 846073DEST_PATH_IMAGE001
, the derivation formula for optimizing the STFT transformation is as follows

Figure DEST_PATH_IMAGE007
(4)
Figure DEST_PATH_IMAGE007
(4)

上式中,S(f i )是对西瓜样本的敲击声音信号进行时频特征提取后的时频二维 矩阵,

Figure 409516DEST_PATH_IMAGE008
为上一步骤中构建的窗函数,x(t)为西瓜样本的敲击声音信 号。 In the above formula, S ( f i ) is the time-frequency two-dimensional matrix after the time-frequency feature extraction of the tap sound signal of the watermelon sample,
Figure 409516DEST_PATH_IMAGE008
is the window function constructed in the previous step, x ( t ) is the tap sound signal of the watermelon sample.

优化STFT时频特征提取算法解决了传统STFT仅能改变时间分辨率而无法改变频谱分辨率的问题,并且频谱分辨率是自适应于样本频谱特征分布而改变的。因此本实施例步骤S2)中,根据优化STFT时频特征提取算法,提取西瓜样本敲击声音信号的时频特征具体步骤包括:The optimized STFT time-frequency feature extraction algorithm solves the problem that the traditional STFT can only change the time resolution but cannot change the spectral resolution, and the spectral resolution is adaptive to the sample spectral feature distribution. Therefore, in step S2) of this embodiment, according to the optimized STFT time-frequency feature extraction algorithm, the specific steps of extracting the time-frequency feature of the watermelon sample tapping sound signal include:

根据所有西瓜样本的敲击声音信号,由式(1)和式(2)计算FFT频谱并提取频谱特征;According to the tapping sound signals of all watermelon samples, the FFT spectrum is calculated by formula (1) and formula (2) and the spectrum features are extracted;

根据所提取的频谱特征,由式(3)确定STFT窗函数频谱分辨率参数f的取值范围, 根据时间分辨率参数τ和频谱分辨率参数f的值构建STFT窗函数

Figure 729639DEST_PATH_IMAGE008
; According to the extracted spectral features, the value range of the spectral resolution parameter f of the STFT window function is determined by formula (3), and the STFT window function is constructed according to the values of the time resolution parameter τ and the spectral resolution parameter f
Figure 729639DEST_PATH_IMAGE008
;

根据所述STFT窗函数

Figure 566008DEST_PATH_IMAGE008
和每个西瓜样本的敲击声音信号,由 式(4)计算每个西瓜样本的时频矩阵。 According to the STFT window function
Figure 566008DEST_PATH_IMAGE008
and the percussion sound signal of each watermelon sample, the time-frequency matrix of each watermelon sample is calculated by formula (4).

如图4所示,图4(a)为公式(1)计算的所有西瓜样本的FFT频谱,其横轴为频率,纵轴为西瓜样本序号。图4(b)为公式(2)计算得到方差值,结合图4(a)可以看出频谱中特征差异较大的部分主要集中在低频,各个频率点之间的差异性并不相同。所以本实施例的优化STFT时频特征提取算法根据方差值划分频率分辨率。图4(c)为西瓜样本的敲击声音信号按照常规的STFT变换后的时频矩阵,图4(d)为以本实施例的优化STFT时频特征提取算法对西瓜样本的敲击声音信号进行STFT变换后的时频矩阵,其横轴为时间,纵轴为频率,可以看出优化STFT时频特征提取算法所提取的时频矩阵特征分布更加明显,而且数据维度从[10,256]降低至[10,32],其中10是由时间参数决定的,为信号时间总长度/时间分辨率τ,32为公式(3)中STFT频谱带宽的个数NAs shown in Figure 4, Figure 4(a) is the FFT spectrum of all watermelon samples calculated by formula (1), the horizontal axis is the frequency, and the vertical axis is the watermelon sample serial number. Figure 4(b) shows the variance value calculated by formula (2). Combining with Figure 4(a), it can be seen that the parts with large characteristic differences in the spectrum are mainly concentrated in low frequencies, and the differences between each frequency point are not the same. Therefore, the optimized STFT time-frequency feature extraction algorithm of this embodiment divides the frequency resolution according to the variance value. Fig. 4(c) is the time-frequency matrix of the tap sound signal of the watermelon sample transformed according to the conventional STFT, and Fig. 4(d) is the tap sound signal of the watermelon sample based on the optimized STFT time-frequency feature extraction algorithm of the present embodiment The time-frequency matrix after STFT transformation, the horizontal axis is time, the vertical axis is frequency, it can be seen that the time-frequency matrix feature distribution extracted by the optimized STFT time-frequency feature extraction algorithm is more obvious, and the data dimension is reduced from [10,256] to [10, 32], where 10 is determined by the time parameter, which is the total signal time length/time resolution τ , and 32 is the number N of STFT spectral bandwidths in formula (3).

KNN在计算西瓜样本时频矩阵和重量之间的距离时,对于一个西瓜样本w d (S d ,y d )和它的第k个最邻近样本w k (S k ,y k )之间距离采用计算欧式距离的方式,计算公式如下:When KNN calculates the distance between the time-frequency matrix and the weight of the watermelon sample, the distance between a watermelon sample w d ( S d , y d ) and its kth nearest neighbor sample w k ( S k , y k ) The Euclidean distance is calculated using the following formula:

Figure DEST_PATH_IMAGE009
(5)
Figure DEST_PATH_IMAGE009
(5)

上式中,S d (f i )和S k (f i )分别代表西瓜样本w d (S d ,y d )与w k (S k ,y k )采用优化STFT时频特征提取算法后得到的时频矩阵,y d y k 分别为西瓜样本w d (S d ,y d )与w k (S k ,y k )的重量。In the above formula, S d ( f i , τ ) and S k ( f i , τ ) represent the watermelon samples w d ( S d , y d ) and w k ( S k , y k ), respectively, using the optimized STFT time-frequency characteristics After extracting the time-frequency matrix obtained by the algorithm, y d and y k are the weights of the watermelon samples w d ( S d , y d ) and w k ( S k , y k ), respectively.

传统的KNN欧式距离计算过程中不考虑特征维度之间的差距,但时频特征矩阵S(f i )是二维矩阵,而重量数据是一个数据点,而且数量级不统一。为了解决这些问题,本实施例提出了基于信息融合KNN分类算法,如图1所示,包括以下步骤:The traditional KNN Euclidean distance calculation process does not consider the gap between feature dimensions, but the time-frequency feature matrix S ( f i ) is a two-dimensional matrix, while the weight data is a data point, and the order of magnitude is not uniform. In order to solve these problems, this embodiment proposes a KNN classification algorithm based on information fusion, as shown in Figure 1, including the following steps:

步骤一:计算西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的时频矩阵距离和重量特征距离,以西瓜样本w d (S d ,y d )与它的第k个最邻近西瓜样本w k (S k ,y k )为例,计算西瓜样本w d (S d ,y d )与w k (S k ,y k )的时频矩阵距离m k 和重量特征距离n k 表达式如下:Step 1: Calculate the time-frequency matrix distance and weight feature distance between the watermelon sample w d ( S d , y d ) and other watermelon samples in the training set, take the watermelon sample w d ( S d , y d ) and its kth most Taking the adjacent watermelon sample w k ( S k , y k ) as an example, calculate the time-frequency matrix distance m k and the weight characteristic distance n k of the watermelon sample w d ( S d , y d ) and w k ( S k , y k ) The expression is as follows:

Figure 260163DEST_PATH_IMAGE010
(6)
Figure 260163DEST_PATH_IMAGE010
(6)

Figure DEST_PATH_IMAGE011
(7)
Figure DEST_PATH_IMAGE011
(7)

式(6)和式(7)中,S d (f i )和S k (f i )分别代表西瓜样本w d (S d ,y d )与w k (S k ,y k )采用优化STFT时频特征提取算法后得到的时频矩阵,y d y k 分别为西瓜样本w d (S d ,y d )与w k (S k ,y k )的重量;In formula (6) and formula (7), S d ( f i , τ ) and S k ( f i , τ ) represent the watermelon samples w d ( S d , y d ) and w k ( S k , y k ), respectively ) using the time-frequency matrix obtained after optimizing the STFT time-frequency feature extraction algorithm, y d and y k are the weights of the watermelon samples w d ( S d , y d ) and w k ( S k , y k ) respectively;

步骤二:将西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的时频矩阵距离和重量特征距离归一化,解决特征数量级不统一的问题,以西瓜样本w d (S d ,y d )与它的第k个最邻近西瓜样本w k (S k ,y k )为例,西瓜样本w d (S d ,y d )与w k (S k ,y k )的时频矩阵距离m k 和重量特征距离n k 归一化表达式如下:Step 2: Normalize the watermelon sample w d ( S d , y d ) with the time-frequency matrix distance and weight feature distance of other watermelon samples in the training set to solve the problem of non-uniform feature magnitudes. The watermelon sample w d ( S d , y d ) and its k -th nearest watermelon sample w k ( S k , y k ) as an example, the time-frequency of watermelon samples w d ( S d , y d ) and w k ( S k , y k ) The normalized expressions of matrix distance m k and weight feature distance n k are as follows:

Figure 207391DEST_PATH_IMAGE012
(8)
Figure 207391DEST_PATH_IMAGE012
(8)

Figure DEST_PATH_IMAGE013
(9)
Figure DEST_PATH_IMAGE013
(9)

式(8)和式(9)中,m max m min 分别表示西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的时频矩阵距离中的最大值和最小值,n max n min 分别表示西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的重量特征距离的最大值和最小值;In formula (8) and formula (9), m max , m min respectively represent the maximum and minimum values of the time-frequency matrix distance between the watermelon sample w d ( S d , y d ) and other watermelon samples in the training set, n max , n min respectively represent the maximum and minimum distances of the weight feature distance between the watermelon sample w d ( S d , y d ) and other watermelon samples in the training set;

步骤三:引入信息融合权重参数λ,根据归一化后的时频矩阵距离和重量特征距离计算西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的欧式距离,以西瓜样本w d (S d ,y d )与它的第k个最邻近西瓜样本w k (S k ,y k )为例,西瓜样本w d (S d ,y d )与w k (S k ,y k )的欧式距离表达式如下:Step 3: Introduce the information fusion weight parameter λ , calculate the Euclidean distance between the watermelon sample w d ( S d , y d ) and other watermelon samples in the training set according to the normalized time-frequency matrix distance and weight feature distance, and use the watermelon sample w d ( S d , y d ) and its k -th nearest watermelon sample w k ( S k , y k ) as an example, the watermelon sample w d ( S d , y d ) and w k ( S k , y k ) ), the Euclidean distance expression is as follows:

Figure DEST_PATH_IMAGE014
(10)
Figure DEST_PATH_IMAGE014
(10)

上式中,λ为信息融合权重参数,m k 为西瓜样本w d (S d ,y d )与w k (S k ,y k )之间的时频矩阵距离,n k 为西瓜样本w d (S d ,y d )与w k (S k ,y k )之间的重量特征距离。In the above formula, λ is the information fusion weight parameter, m k is the time-frequency matrix distance between the watermelon samples w d ( S d , y d ) and w k ( S k , y k ), and n k is the watermelon sample w d The weight characteristic distance between ( S d , y d ) and w k ( S k , y k ).

通过步骤三计算得到西瓜样本w d (S d ,y d )与训练集中其他西瓜样本的欧式距离之后,按照从小到大顺序进行排序,即可找到与西瓜样本w d (S d ,y d )最邻近的前K个西瓜样本,统计这K个西瓜样本的类别中出现频率最高的类别,即为西瓜样本w d (S d ,y d )的类别,即得到西瓜样本w d (S d ,y d )的成熟度。After calculating the Euclidean distance between the watermelon sample w d ( S d , y d ) and other watermelon samples in the training set through step 3, sort them in ascending order to find the watermelon sample w d ( S d , y d ) The nearest K watermelon samples are counted, and the category with the highest frequency among the categories of these K watermelon samples is counted, which is the category of the watermelon sample w d ( S d , y d ), that is, the watermelon sample w d ( S d , y d ) is obtained . y d ) maturity.

基于信息融合KNN分类算法通过融合音频特征和质量特征进一步提升了检测系统准确度,解决了多种信息特征之间维度不统一,数量级差异较大的问题。因此本实施例步骤S2)中,根据信息融合KNN,由时频特征和对应的重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离的具体步骤包括:The KNN classification algorithm based on information fusion further improves the accuracy of the detection system by fusing audio features and quality features, and solves the problem of non-uniform dimensions and large order of magnitude differences between various information features. Therefore, in step S2) of this embodiment, according to the information fusion KNN, the specific steps of calculating the distance between the target watermelon sample and other watermelon samples in the training set from the time-frequency feature and the corresponding weight include:

根据目标西瓜样本与训练集中其他西瓜样本的时频矩阵,由式(6)计算目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离,根据目标西瓜样本与训练集中其他西瓜样本的重量,由式(7)计算目标西瓜样本与训练集中其他西瓜样本之间的重量特征距离;According to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (6). According to the weight of the target watermelon sample and other watermelon samples in the training set , the weight feature distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (7);

由式(8)和式(9)对目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离和重量特征距离归一化;The time-frequency matrix distance and weight feature distance between the target watermelon sample and other watermelon samples in the training set are normalized by equations (8) and (9);

根据信息融合权重参数λ,以及归一化后的时频矩阵距离和重量特征距离,由式(10)计算目标西瓜样本与训练集中其他西瓜样本之间的距离。According to the information fusion weight parameter λ , as well as the normalized time-frequency matrix distance and weight feature distance, the distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (10).

本实施例的步骤S4)是在模型建立完成后,对其准确度和适用性进行测试,以优化模型性能,其中通过用训练集训练成熟度检测模型,能够优化并保存模型的相关参数,用测试集测试训练后的成熟度检测模型,即是按照所保存的模型相关参数,由成熟度检测模型对测试集中的西瓜样本进行步骤S2)中所述的特征提取和分类,以得到其成熟度,具体过程如图3的虚线框中所示,按照前文的优化STFT时频特征提取算法计算每个西瓜样本的时频特征并记录重量特征;测试集的西瓜样本作为测试样本,按照前文的信息融合KNN分类算法,计算测试样本与训练集中其他西瓜样本的欧式距离;按照递增排序,选取前K个距离最近的西瓜样本;最后统计这K个西瓜样本中出现频率最高的类别,就是该测试样本的成熟度。Step S4) of this embodiment is to test the accuracy and applicability of the model after the model is established to optimize the performance of the model. The maturity detection model after the test set is tested and trained, that is, according to the saved model-related parameters, the maturity detection model performs the feature extraction and classification described in step S2) on the watermelon samples in the test set to obtain its maturity. , the specific process is shown in the dashed box in Figure 3, according to the optimized STFT time-frequency feature extraction algorithm above to calculate the time-frequency feature of each watermelon sample and record the weight feature; Integrate the KNN classification algorithm to calculate the Euclidean distance between the test sample and other watermelon samples in the training set; select the top K watermelon samples with the closest distance in ascending order; finally count the category with the highest frequency among the K watermelon samples, which is the test sample maturity.

由于测试集中的西瓜样本在步骤S1)中也进行了分类,因此对于测试集中的西瓜样本,统计成熟度检测模型检测的成熟度与实际成熟度一致的西瓜样本数量,再除以测试集中的西瓜样本数量的总数,就能够得到成熟度检测模型的准确度。Since the watermelon samples in the test set are also classified in step S1), for the watermelon samples in the test set, the number of watermelon samples whose maturity detected by the statistical maturity detection model is consistent with the actual maturity is divided by the watermelon samples in the test set. The total number of samples, the accuracy of the maturity detection model can be obtained.

对于成熟度检测模型进行训练和测试的同时,还需考虑参数优化的问题,需要优化的参数包括时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ,因此在用训练集训练成熟度检测模型之前还包括优化时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的步骤,可以采用网格搜索算法、粒子群搜索算法、鸟群搜索算法等,以网格搜索算法为例,优化时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的步骤包括:While training and testing the maturity detection model, it is also necessary to consider the problem of parameter optimization. The parameters that need to be optimized include the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ , so when using the training set to train mature Before the degree detection model, it also includes the steps of optimizing the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ . The grid search algorithm, particle swarm search algorithm, bird flock search algorithm, etc. can be used. For example, the steps of optimizing the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ include:

若时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值未达到预设的最大值,以预设步长增加时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值,执行用所述训练集训练成熟度检测模型的步骤;If the values of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ do not reach the preset maximum value, increase the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter with a preset step size The value of λ , executes the step of training maturity detection model with described training set;

若时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值达到预设的最大值,从记录的所有准确度中查找最高准确度,将时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值调整为最高准确度对应的值,执行用所述训练集训练成熟度检测模型的步骤。If the value of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ reaches the preset maximum value, find the highest accuracy from all the recorded accuracies, and use the time resolution parameter τ , the spectral resolution parameter The values of f and the information fusion weight parameter λ are adjusted to the value corresponding to the highest accuracy, and the step of training the maturity detection model with the training set is performed.

本实施例中,时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ均预设有对应的区间以及步长,步骤S2)中,时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的初始值为对应预设区间的最小值,步骤S4)中每次以对应的步长增加时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值,直至到达对应预设区间的最大值,此时,最高准确度所对应的时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的值即为最优值,因此在时间分辨率参数τ、频谱分辨率参数f和信息融合权重参数λ的最优值之下训练好的成熟度检测模型具有最优的性能。In this embodiment, the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ are all preset with corresponding intervals and step sizes. In step S2), the time resolution parameter τ , the spectral resolution parameter f and The initial value of the information fusion weight parameter λ is the minimum value corresponding to the preset interval. In step S4), the values of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ are increased by the corresponding step size each time, until The maximum value of the corresponding preset interval is reached. At this time, the value of the time resolution parameter τ , the spectral resolution parameter f and the information fusion weight parameter λ corresponding to the highest accuracy is the optimal value, so the time resolution parameter τ is the optimal value. The maturity detection model trained under the optimal values of , spectral resolution parameter f and information fusion weight parameter λ has the best performance.

最后,本实施例的基于声学分析和机器学习的西瓜成熟度检测方法考虑滤波算法和预处理步骤对抗噪性的影响,获取西瓜样本的敲击声音信号之后,还包括提取有效信号的步骤,具体包括:Finally, the method for detecting the maturity of watermelon based on acoustic analysis and machine learning in this embodiment considers the influence of the filtering algorithm and the preprocessing steps on noise resistance, and after acquiring the tap sound signal of the watermelon sample, it also includes the step of extracting effective signals. include:

计算敲击声音信号每一帧的能量,保留能量大于预设阈值的帧,得到一次过滤后的敲击声音信号;Calculate the energy of each frame of the percussion sound signal, retain the frames whose energy is greater than the preset threshold, and obtain a filtered percussion sound signal;

对一次过滤后的敲击声音信号进行滤波,得到二次过滤后的敲击声音信号并作为敲击声音信号的有效信号。The percussion sound signal filtered once is filtered to obtain the percussion sound signal filtered for the second time, which is used as an effective signal of the percussion sound signal.

对于获取一次过滤后的敲击声音信号,是因为一般西瓜敲击声音信号的录音时间会比较长,需要采用端点检测方法将有效信号从整段声音信号中提取出来。可以采用短时能量、短时过零率和频域特征等方法,本实施例中采用的是基于短时能量的声音信号端点检测方法,它可以通过计算声音信号每一帧的能量,判断有效信号的开始和结束时间点。声音信号第n帧的短时能量计算公式如下:The reason for obtaining a filtered percussion sound signal is that the recording time of the watermelon percussion sound signal is generally relatively long, and the endpoint detection method needs to be used to extract the valid signal from the entire sound signal. Methods such as short-term energy, short-term zero-crossing rate, and frequency domain characteristics can be used. In this embodiment, the method for detecting the endpoint of a sound signal based on short-term energy is adopted. It can calculate the energy of each frame of the sound signal to determine the effective The start and end time points of the signal. The short-term energy calculation formula of the nth frame of the sound signal is as follows:

Figure 804856DEST_PATH_IMAGE015
(11)
Figure 804856DEST_PATH_IMAGE015
(11)

上式中,L表示帧的长度,x(m)表示西瓜样本第m帧的敲击声音信号。In the above formula, L represents the length of the frame, and x ( m ) represents the tap sound signal of the mth frame of the watermelon sample.

图5(a)为某一个西瓜样本的敲击声音信号,当E n 大于预设的阈值,则保留对应帧的敲击声音信号,当E n 小于预设的阈值,则丢弃对应帧的敲击声音信号,以此来截断声音信号,最终的一次过滤后的敲击声音信号如图5(b)所示,从而有利于提高后续步骤中提取的时频特征的准确度。Figure 5(a) is the tap sound signal of a certain watermelon sample. When En is greater than the preset threshold, the tap sound signal of the corresponding frame is retained. When En is less than the preset threshold, the tap of the corresponding frame is discarded. The tap sound signal is cut to cut off the sound signal. The final filtered tap sound signal is shown in Figure 5(b), which is beneficial to improve the accuracy of the time-frequency features extracted in the subsequent steps.

对于获取二次过滤后的敲击声音信号,是因为西瓜样本的敲击声音信号可能存在环境噪声的干扰,减低检测准确度,所有需要滤波算法来对西瓜样本的敲击声音信号进行滤波。可以采用低通滤波器、巴特沃斯滤波器、自适应滤波器等,本实施例中采用的是最小均方自适应滤波器,它能够依靠有效的自适应算法自动修正权系数,从而适应外部环境的变化,使得滤波器一直保持在最佳状态,具有良好适应性和滤波性能,可以有效滤除环境噪声,提升有效信号的信噪比。For obtaining the tap sound signal after secondary filtering, it is because the tap sound signal of the watermelon sample may be interfered with by environmental noise, which reduces the detection accuracy. Therefore, a filtering algorithm is required to filter the tap sound signal of the watermelon sample. A low-pass filter, a Butterworth filter, an adaptive filter, etc. can be used, and the least mean square adaptive filter is used in this embodiment, which can automatically correct the weight coefficients by means of an effective adaptive algorithm, so as to adapt to the external Changes in the environment keep the filter in the best state, with good adaptability and filtering performance, which can effectively filter out environmental noise and improve the signal-to-noise ratio of effective signals.

实施例二Embodiment 2

本实施例根据实施例一提出一种基于声学分析和机器学习的西瓜成熟度检测系统,包括:This embodiment proposes a watermelon maturity detection system based on acoustic analysis and machine learning according to the first embodiment, including:

数据获取单元,用于获取西瓜样本的敲击声音信号和重量,并组成数据集,将所述数据集中的西瓜样本按照成熟度分类,并将所述数据集划分为训练集和测试集;还用于获取西瓜测试样本的敲击声音信号和重量,并输入训练好的成熟度检测模型,得到西瓜测试样本的成熟度;a data acquisition unit for acquiring the tap sound signal and weight of the watermelon samples, and forming a data set, classifying the watermelon samples in the data set according to maturity, and dividing the data set into a training set and a test set; and It is used to obtain the tap sound signal and weight of the watermelon test sample, and input the trained maturity detection model to obtain the maturity of the watermelon test sample;

模型构建单元,用于构建成熟度检测模型,该成熟度检测模型利用优化STFT时频特征提取算法来提取西瓜样本敲击声音信号的时频特征,还利用信息融合KNN分类算法,将目标西瓜样本作为测试样本,由时频特征和对应的重量计算测试样本与训练集中其他西瓜样本之间的距离,最后在与测试样本距离最近的K个西瓜样本对应的类别中,将出现频率最高的类别作为测试样本的成熟度;The model building unit is used to build a maturity detection model. The maturity detection model uses the optimized STFT time-frequency feature extraction algorithm to extract the time-frequency characteristics of the tap sound signal of the watermelon sample, and also uses the information fusion KNN classification algorithm to extract the target watermelon sample. As a test sample, the distance between the test sample and other watermelon samples in the training set is calculated from the time-frequency features and the corresponding weight. Finally, among the categories corresponding to the K watermelon samples that are closest to the test sample, the category with the highest frequency is used as the maturity of the test sample;

模型训练及测试单元,用于用所述训练集训练成熟度检测模型,然后用所述测试集测试成熟度检测模型,最后计算准确度并记录,继续用所述训练集训练成熟度检测模型,直到准确度最高,得到训练好的成熟度检测模型。The model training and testing unit is used to train the maturity detection model with the training set, then use the test set to test the maturity detection model, finally calculate the accuracy and record, and continue to use the training set to train the maturity detection model, Until the accuracy is the highest, the trained maturity detection model is obtained.

本实施例中,所述成熟度检测模型提取西瓜样本敲击声音信号的时频特征时,所述模型构建单元被配置以执行以下步骤:In this embodiment, when the maturity detection model extracts the time-frequency features of the watermelon sample tapping sound signal, the model building unit is configured to perform the following steps:

根据所有西瓜样本的敲击声音信号,由式(1)和式(2)计算FFT频谱并提取频谱特征;According to the tapping sound signals of all watermelon samples, the FFT spectrum is calculated by formula (1) and formula (2) and the spectrum features are extracted;

根据所提取的频谱特征,由式(3)确定STFT窗函数频谱分辨率参数f的取值范围, 根据时间分辨率参数τ和频谱分辨率参数f的值构建STFT窗函数

Figure 812127DEST_PATH_IMAGE008
根据 所述STFT窗函数
Figure 72207DEST_PATH_IMAGE008
和每个西瓜样本的敲击声音信号,由式(4)计算每个 西瓜样本的时频矩阵。 According to the extracted spectral features, the value range of the spectral resolution parameter f of the STFT window function is determined by formula (3), and the STFT window function is constructed according to the values of the time resolution parameter τ and the spectral resolution parameter f
Figure 812127DEST_PATH_IMAGE008
According to the STFT window function
Figure 72207DEST_PATH_IMAGE008
and the percussion sound signal of each watermelon sample, the time-frequency matrix of each watermelon sample is calculated by formula (4).

本实施例中,所述成熟度检测模型根据时频特征和重量计算目标西瓜样本与训练集中其他西瓜样本之间的距离时,所述模型构建单元被配置以执行以下步骤:In this embodiment, when the maturity detection model calculates the distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency feature and weight, the model building unit is configured to perform the following steps:

根据目标西瓜样本与训练集中其他西瓜样本的时频矩阵,由式(6)计算目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离,根据目标西瓜样本与训练集中其他西瓜样本的重量,由式(7)计算目标西瓜样本与训练集中其他西瓜样本之间的重量特征距离;According to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (6). According to the weight of the target watermelon sample and other watermelon samples in the training set , the weight feature distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (7);

由式(8)和式(9)对目标西瓜样本与训练集中其他西瓜样本之间的时频矩阵距离和重量特征距离归一化;The time-frequency matrix distance and weight feature distance between the target watermelon sample and other watermelon samples in the training set are normalized by equations (8) and (9);

根据信息融合权重参数λ,以及归一化后的时频矩阵距离和重量特征距离,由式(10)计算目标西瓜样本与训练集中其他西瓜样本之间的距离。According to the information fusion weight parameter λ , as well as the normalized time-frequency matrix distance and weight feature distance, the distance between the target watermelon sample and other watermelon samples in the training set is calculated by formula (10).

上述只是本发明的较佳实施例,并非对本发明作任何形式上的限制。本发明的核心思想是采用时频分析的特征提取算法+机器学习分类算法的组合模型,来解决西瓜成熟度检测问题,利用的是敲击西瓜产生的声音信号和西瓜的质量作为基础。其他基于机器视觉或红外光谱检测等方案与本发明在信息来源和技术方案上存在较大差异,但基于声学分析的西瓜成熟度检测方案,会存在可替代技术方案。The above are only preferred embodiments of the present invention, and do not limit the present invention in any form. The core idea of the present invention is to use the combined model of the feature extraction algorithm of time-frequency analysis + machine learning classification algorithm to solve the problem of watermelon maturity detection, using the sound signal generated by tapping the watermelon and the quality of the watermelon as the basis. Other schemes based on machine vision or infrared spectrum detection are quite different from the present invention in terms of information sources and technical schemes, but there are alternative technical schemes for the watermelon maturity detection scheme based on acoustic analysis.

具体来说,以声音信号的时频分析方法为例,本发明采用的是基于STFT的改进方法,还存在小波变换,S变换,梅尔倒谱分析等其他基础时频分析方法和改进方法来替代本发明的方法,但这些方法的本质还是时频分析方法,即可以同时提取声音信号在时间域的特征和频域上的特征的方法;以机器学分类算法为例,本发明采用的是基于KNN改进的信息融合算法,可以代替KNN的有支持向量机,逻辑回归,随机森林,决策树,神经网络等分类算法,但本质是需要结合上面的时频特征和质量特征,通过模型的训练和测试完成西瓜成熟度分类。时频分析的特征提取算法+机器学习分类算法可以任意更换和组合以上这些方法,本发明所采用的组合方案是在实际数据集上进行模型训练和测试后,性能较优的组合方案,但其他组合方案也能实现西瓜成熟度检测的目的。Specifically, taking the time-frequency analysis method of a sound signal as an example, the present invention adopts an improved method based on STFT, and there are other basic time-frequency analysis methods and improved methods such as wavelet transform, S transform, and Mel cepstral analysis. Substitute the method of the present invention, but the essence of these methods is still a time-frequency analysis method, that is, a method that can extract the characteristics of the sound signal in the time domain and the frequency domain at the same time; The improved information fusion algorithm based on KNN can replace KNN with support vector machine, logistic regression, random forest, decision tree, neural network and other classification algorithms, but the essence is to combine the above time-frequency characteristics and quality characteristics, through the training of the model And the test completes the watermelon ripeness classification. The feature extraction algorithm of time-frequency analysis + machine learning classification algorithm can arbitrarily replace and combine the above methods. The combination scheme adopted in the present invention is a combination scheme with better performance after model training and testing on the actual data set, but other The combination scheme can also achieve the purpose of watermelon maturity detection.

虽然本发明已以较佳实施例揭露如上,然而并非用以限定本发明。因此,凡是未脱离本发明技术方案的内容,依据本发明技术实质对以上实施例所做的任何简单修改、等同变化及修饰,均应落在本发明技术方案保护的范围内。Although the present invention has been disclosed above with preferred embodiments, it is not intended to limit the present invention. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solutions of the present invention should fall within the protection scope of the technical solutions of the present invention.

Claims (10)

1. A watermelon maturity detection method based on acoustic analysis and machine learning is characterized by comprising the following steps:
acquiring a knocking sound signal and weight of a watermelon sample, forming a data set, classifying the watermelon sample in the data set according to maturity, and dividing the data set into a training set and a testing set;
constructing a maturity detection model, wherein the maturity detection model is used for extracting time-frequency characteristics of a knocking sound signal of a watermelon sample, calculating the distance between the target watermelon sample and other watermelon samples in a training set according to the time-frequency characteristics and corresponding weight, and finally taking the class with the highest occurrence frequency as the maturity of the target watermelon sample in the classes corresponding to K watermelon samples closest to the target watermelon sample;
training a maturity detection model by using the training set, testing the maturity detection model by using the testing set, finally calculating and recording the accuracy, and repeating the steps until the accuracy is highest to obtain the trained maturity detection model;
and acquiring the knocking sound signal and the weight of the watermelon test sample, and inputting the knocking sound signal and the weight into the trained maturity detection model to obtain the maturity of the watermelon test sample.
2. The method for detecting the maturity of the watermelon according to claim 1, wherein the step of extracting the time-frequency characteristics of the knocking sound signal of the watermelon sample comprises the following steps:
calculating an FFT frequency spectrum and extracting frequency spectrum characteristics according to the knocking sound signals of all watermelon samples;
determining a spectral resolution parameter of the STFT window function from the extracted spectral featuresfAccording to the time resolution parameterτAnd spectral resolution parameterfValue of (a) construct an STFT window function
Figure 738445DEST_PATH_IMAGE001
According to the STFT window function
Figure 655586DEST_PATH_IMAGE001
And the knocking sound signal of each watermelon sample, and calculating the time-frequency matrix of each watermelon sample.
3. The method for detecting the maturity of watermelon according to claim 2, wherein the function expression of the time-frequency matrix is as follows:
Figure DEST_PATH_IMAGE002
in the above-mentioned formula, the compound has the following structure,x(t) Is the knock sound signal of the watermelon sample,
Figure 232061DEST_PATH_IMAGE001
is a constructed STFT window function, whereinτIs time of dayThe resolution parameters are used to determine the resolution parameters,fis a spectral resolution parameter [ alpha ], [ alpha ]f i , f i+1]The spectral interval in between represents the bandwidth of the spectral resolution.
4. The method for detecting watermelon ripeness based on acoustic analysis and machine learning of claim 2, wherein the specific step of calculating the distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency characteristics and the weight comprises:
calculating the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, and calculating the weight characteristic distance between the target watermelon sample and other watermelon samples in the training set according to the weight of the target watermelon sample and other watermelon samples in the training set;
normalizing the time-frequency matrix distance and the weight characteristic distance between the target watermelon sample and other watermelon samples in the training set;
fusing weight parameters according to informationλAnd calculating the distance between the target watermelon sample and other watermelon samples in the training set according to the normalized time-frequency matrix distance and the normalized weight characteristic distance.
5. The method of claim 4, wherein the other watermelon samples in the training set comprise the first watermelon sample of the target watermelonkThe nearest watermelon sample, the target watermelon sample andkthe functional expression for the distance between the nearest watermelon samples is:
Figure DEST_PATH_IMAGE003
in the above formula, the first and second carbon atoms are,λin order to obtain the information fusion weight parameter,m k is the target watermelon sample andkthe time-frequency matrix distance between the nearest watermelon samples,n k is the target watermelon sample andkat the mostThe weight characteristic distance between adjacent watermelon samples.
6. The method of claim 4, wherein training the maturity detection model with a training set further comprises optimizing a temporal resolution parameterτSpectral resolution parameterfAnd information fusion weight parameterλThe method specifically comprises the following steps:
if the time resolution parameterτSpectral resolution parameterfAnd information fusion weight parameterλThe value of (a) does not reach the preset maximum value, and the time resolution parameter is increased by the preset step lengthτSpectral resolution parameterfAnd information fusion weight parameterλPerforming a step of training a maturity detection model with the training set;
if the time resolution parameterτSpectral resolution parameterfAnd information fusion weight parameterλThe value of (d) reaches a preset maximum value, the highest accuracy is found from all recorded accuracies, and the time resolution parameter is usedτSpectral resolution parameterfAnd information fusion weight parameterλIs adjusted to the value corresponding to the highest accuracy, the step of training the maturity detection model with the training set is performed.
7. The method for detecting the maturity of watermelon based on acoustic analysis and machine learning of claim 1, wherein after acquiring the tapping sound signal of the watermelon sample, the method further comprises a step of extracting effective signals, and the method specifically comprises the following steps:
calculating the energy of each frame of the knocking sound signal, and reserving the frames with the energy larger than a preset threshold value to obtain the knocking sound signal after primary filtering;
and filtering the primarily filtered tapping sound signal to obtain a secondarily filtered tapping sound signal which is used as an effective signal of the tapping sound signal.
8. A watermelon maturity detection system based on acoustic analysis and machine learning, comprising:
the system comprises a data acquisition unit, a training unit and a testing unit, wherein the data acquisition unit is used for acquiring knocking sound signals and weight of watermelon samples, forming a data set, classifying the watermelon samples in the data set according to maturity and dividing the data set into a training set and a testing set; the device is also used for acquiring a knocking sound signal and weight of the watermelon test sample, and inputting the knocking sound signal and weight into the trained maturity detection model to obtain the maturity of the watermelon test sample;
the model construction unit is used for constructing a maturity detection model, the maturity detection model is used for extracting time-frequency characteristics of a watermelon sample knocking sound signal, then calculating the distance between a target watermelon sample and other watermelon samples in a training set according to the time-frequency characteristics and corresponding weight, and finally taking the class with the highest occurrence frequency as the maturity of the target watermelon sample in the classes corresponding to K watermelon samples closest to the target watermelon sample;
and the model training and testing unit is used for training the maturity detection model by using the training set, testing the maturity detection model by using the testing set, calculating and recording the accuracy, and continuing training the maturity detection model by using the training set until the accuracy is highest to obtain the trained maturity detection model.
9. The system of claim 8, wherein when the maturity detection model extracts time-frequency features of a watermelon sample tapping sound signal, the model construction unit is configured to perform the following steps:
calculating an FFT frequency spectrum and extracting frequency spectrum characteristics according to the knocking sound signals of all watermelon samples;
determining a spectral resolution parameter of the STFT window function from the extracted spectral featuresfAccording to the time resolution parameterτAnd spectral resolution parameterfConstructing an STFT window function;
and calculating a time-frequency matrix of each watermelon sample according to the STFT window function and the knocking sound signal of each watermelon sample.
10. The acoustic analysis and machine learning based watermelon maturity detection system of claim 9 wherein said maturity detection model, when calculating the distance between the target watermelon sample and other watermelon samples in the training set from time-frequency features and weight, said model building unit is configured to perform the steps of:
calculating the time-frequency matrix distance between the target watermelon sample and other watermelon samples in the training set according to the time-frequency matrix of the target watermelon sample and other watermelon samples in the training set, and calculating the weight characteristic distance between the target watermelon sample and other watermelon samples in the training set according to the weight of the target watermelon sample and other watermelon samples in the training set;
normalizing the time-frequency matrix distance and the weight characteristic distance between the target watermelon sample and other watermelon samples in the training set;
fusing weight parameters according to informationλAnd calculating the distance between the target watermelon sample and other watermelon samples in the training set according to the normalized time-frequency matrix distance and the normalized weight characteristic distance.
CN202210663997.3A 2022-06-14 2022-06-14 Watermelon maturity detection method and system based on acoustic analysis and machine learning Active CN114740091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210663997.3A CN114740091B (en) 2022-06-14 2022-06-14 Watermelon maturity detection method and system based on acoustic analysis and machine learning

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210663997.3A CN114740091B (en) 2022-06-14 2022-06-14 Watermelon maturity detection method and system based on acoustic analysis and machine learning

Publications (2)

Publication Number Publication Date
CN114740091A true CN114740091A (en) 2022-07-12
CN114740091B CN114740091B (en) 2022-09-06

Family

ID=82287013

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210663997.3A Active CN114740091B (en) 2022-06-14 2022-06-14 Watermelon maturity detection method and system based on acoustic analysis and machine learning

Country Status (1)

Country Link
CN (1) CN114740091B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115272617A (en) * 2022-08-29 2022-11-01 北京京航计算通讯研究所 Virtual simulation display method and system for object acoustics
CN117007552A (en) * 2023-10-07 2023-11-07 北京市农林科学院智能装备技术研究中心 Watermelon maturity detection method, device, system, electronic equipment and storage medium
CN117969670A (en) * 2024-04-02 2024-05-03 湖南大学 Watermelon maturity rapid nondestructive detection method and system based on acoustic characteristics

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0450716A2 (en) * 1990-04-03 1991-10-09 Kalman Peleg Method and equipment for measuring firmness of fruits and vegetables
JPH10318992A (en) * 1997-05-20 1998-12-04 Toshiba Eng Co Ltd Fruits and vegetables judging system
JP2982802B1 (en) * 1998-09-29 1999-11-29 松下電器産業株式会社 Fruit texture measuring device
US20110040504A1 (en) * 2009-08-11 2011-02-17 Rong Zhi Xin Science and Technology Development (Beijing) Co., Ltd. Fruit maturity determination method and system
CN104359978A (en) * 2014-11-09 2015-02-18 兰州交通大学 Ripeness-degree measuring device for watermelons
CN105403625A (en) * 2015-12-05 2016-03-16 浙江大学 Portable fruit maturity detection device
CN106525981A (en) * 2016-12-19 2017-03-22 浙江大学 Acoustic nondestructive detection experimental device for ripeness of thick-peel melons and fruits
CN206378427U (en) * 2016-11-25 2017-08-04 江西老庄主绿色农业发展有限公司 A kind of Watermelon Maturity detection means
CN111640451A (en) * 2020-05-07 2020-09-08 Oppo广东移动通信有限公司 Maturity evaluation method and device, and storage medium
CN111652326A (en) * 2020-06-30 2020-09-11 华南农业大学 Improved fruit maturity recognition method and recognition system based on MobileNet v2 network
CN112529152A (en) * 2020-12-03 2021-03-19 开放智能机器(上海)有限公司 System and method for detecting watermelon maturity based on artificial intelligence
CN113295690A (en) * 2021-05-17 2021-08-24 福州大学 Rapid discrimination method of strawberry ripeness based on machine learning
CN113588787A (en) * 2021-07-28 2021-11-02 广东工业大学 Watermelon maturity detector and detection method
CN113984901A (en) * 2021-09-29 2022-01-28 钱思行 Method for detecting watermelon maturity by using sound signal of smart phone

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0450716A2 (en) * 1990-04-03 1991-10-09 Kalman Peleg Method and equipment for measuring firmness of fruits and vegetables
JPH10318992A (en) * 1997-05-20 1998-12-04 Toshiba Eng Co Ltd Fruits and vegetables judging system
JP2982802B1 (en) * 1998-09-29 1999-11-29 松下電器産業株式会社 Fruit texture measuring device
US20110040504A1 (en) * 2009-08-11 2011-02-17 Rong Zhi Xin Science and Technology Development (Beijing) Co., Ltd. Fruit maturity determination method and system
CN104359978A (en) * 2014-11-09 2015-02-18 兰州交通大学 Ripeness-degree measuring device for watermelons
CN105403625A (en) * 2015-12-05 2016-03-16 浙江大学 Portable fruit maturity detection device
CN206378427U (en) * 2016-11-25 2017-08-04 江西老庄主绿色农业发展有限公司 A kind of Watermelon Maturity detection means
CN106525981A (en) * 2016-12-19 2017-03-22 浙江大学 Acoustic nondestructive detection experimental device for ripeness of thick-peel melons and fruits
CN111640451A (en) * 2020-05-07 2020-09-08 Oppo广东移动通信有限公司 Maturity evaluation method and device, and storage medium
CN111652326A (en) * 2020-06-30 2020-09-11 华南农业大学 Improved fruit maturity recognition method and recognition system based on MobileNet v2 network
CN112529152A (en) * 2020-12-03 2021-03-19 开放智能机器(上海)有限公司 System and method for detecting watermelon maturity based on artificial intelligence
CN113295690A (en) * 2021-05-17 2021-08-24 福州大学 Rapid discrimination method of strawberry ripeness based on machine learning
CN113588787A (en) * 2021-07-28 2021-11-02 广东工业大学 Watermelon maturity detector and detection method
CN113984901A (en) * 2021-09-29 2022-01-28 钱思行 Method for detecting watermelon maturity by using sound signal of smart phone

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
GAL RIBAK ET AL.: "Free flight maneuvers of stalk-eyed flies:do eye-stalks affect aerial turing behavior?", 《J COMP PHYSIOL A》 *
PUNJAB: "Fruit quality identification using image processing, machine learning, and deep learning: a review", 《ADVANCES AND APPLICATION IN MATHEMATICAL SCIENCES》 *
ROBERT G. DE LUNA ET AL.: "Tomato growth stage monitoring for smart farm using deep transfer learning with machine learning-based maturity grading", 《JOURNAL OF AGRICULTURAL SCIENCE》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115272617A (en) * 2022-08-29 2022-11-01 北京京航计算通讯研究所 Virtual simulation display method and system for object acoustics
CN115272617B (en) * 2022-08-29 2023-05-02 北京京航计算通讯研究所 Virtual simulation display method and system for object acoustics
CN117007552A (en) * 2023-10-07 2023-11-07 北京市农林科学院智能装备技术研究中心 Watermelon maturity detection method, device, system, electronic equipment and storage medium
CN117007552B (en) * 2023-10-07 2024-02-06 北京市农林科学院智能装备技术研究中心 Watermelon maturity detection method, device, system, electronic equipment and storage medium
CN117969670A (en) * 2024-04-02 2024-05-03 湖南大学 Watermelon maturity rapid nondestructive detection method and system based on acoustic characteristics
CN117969670B (en) * 2024-04-02 2024-06-25 湖南大学 Watermelon maturity rapid nondestructive detection method and system based on acoustic characteristics

Also Published As

Publication number Publication date
CN114740091B (en) 2022-09-06

Similar Documents

Publication Publication Date Title
CN114740091B (en) Watermelon maturity detection method and system based on acoustic analysis and machine learning
CN109034046B (en) An automatic identification method of foreign objects in electric energy meters based on acoustic detection
CN111540368B (en) Stable bird sound extraction method and device and computer readable storage medium
CN112732748A (en) Non-invasive household appliance load identification method based on adaptive feature selection
CN117727307B (en) Bird voice intelligent recognition method based on feature fusion
CN108648764A (en) Rainfall measurement system and its measurement method based on the identification of rainwater knock
CN110808067A (en) Low signal-to-noise ratio sound event detection method based on binary multiband energy distribution
CN111600878A (en) A low-rate denial-of-service attack detection method based on MAF-ADM
CN115662464A (en) Method and system for intelligently identifying environmental noise
CN114966836A (en) Earthquake P wave pickup method based on SAIP-Unet network
CN113571050A (en) A Speech Depressed State Recognition Method Based on Attention and Bi-LSTM
CN118091341A (en) Cable partial discharge detection method and system based on multi-voiceprint feature spectrogram recognition
CN115457966B (en) Pig cough sound identification method based on improved DS evidence theory multi-classifier fusion
CN106251861A (en) A kind of abnormal sound in public places detection method based on scene modeling
CN105916090A (en) Hearing aid system based on intelligent speech recognition technology
CN115510909A (en) Unsupervised algorithm for DBSCAN to perform abnormal sound features
CN108564967B (en) Mel energy voiceprint feature extraction method for cry detection system
CN118173107B (en) Bird sound quality analysis method based on multi-mode depth feature level fusion
CN113523904A (en) Cutter wear detection method
CN117219088A (en) Continuous cough voice recognition method for live pigs in complex environment
CN115862639A (en) Artificial intelligence voice analysis method based on K-means clustering analysis
CN116548979A (en) Physiological signal segment analysis method based on time-frequency information fusion attention
Feng et al. Noise classification speech enhancement generative adversarial network
CN111027453B (en) Automatic non-cooperative underwater target identification method based on Gaussian mixture model
CN117969670B (en) Watermelon maturity rapid nondestructive detection method and system based on acoustic characteristics

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant