Automatic cereal quality defect detection method and system based on machine vision
By generating vibration spectrum diagrams and dual-spectrum fusion technology, the problem of high-precision identification of grain defects under high-speed movement was solved, the refined classification and positioning of mold and insect damage defects were achieved, and the stability and accuracy of detection were improved.
Patent Information
- Application Number
- CN202511121916.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-08-12
AI Technical Summary
Existing technologies make it difficult to perform high-precision, non-destructive online identification of grain surface defects under high-speed motion, especially the distinction and analysis of defects such as mildew and insect damage. Traditional methods are also severely affected by mechanical vibrations, resulting in insufficient detection refinement.
By acquiring the three-axis vibration data of the conveyor belt to generate a vibration spectrum diagram, the compensation angle is calculated to control the deflection of the LED module of the ring light source. Visible light and near-infrared cameras are combined to simultaneously shoot and generate a dual-spectrum fusion image. The color saturation and transmittance channel features are extracted to generate a defect distribution map.
It achieves refined classification and accurate positioning of mildew and insect damage defects, improves the stability and accuracy of detection, can identify single and complex defects, and supports subsequent sorting, rejection and quality grading.
Smart Images

Figure CN120609837A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine vision detection and relates to a method and system for automatically detecting cereal quality defects based on machine vision. Background Art
[0002] In modern grain processing and storage, rapid and accurate grain quality testing is crucial for ensuring food safety and enhancing product value. When grain is transported at high speeds on conveyor belts, it often develops surface defects such as mold and insect damage. Non-destructively identifying these subtle defects online is a major challenge facing automated production lines. Especially at high speeds, defects are diverse and complex, making a single detection method incapable of meeting the high-precision and high-efficiency requirements of industrial production.
[0003] Traditional grain defect detection relies on manual sorting or conventional machine vision systems. Manual sorting is not only inefficient and labor-intensive, but also susceptible to subjective factors, making it difficult to ensure uniform and stable standards. Conventional machine vision systems, while offering improved automation, typically utilize a single visible light camera, limiting their ability to detect defects such as internal insect damage or early mildew, where color features are less distinct. Furthermore, the mechanical vibrations generated by conveyor belts during operation can blur images, severely reducing the accuracy of defect detection and becoming a technical bottleneck hindering improved detection performance.
[0004] Based on the above problems, traditional methods confuse defects such as mildew and insect damage, which have completely different physical causes and visual characteristics, and are unable to effectively distinguish and conduct targeted analysis, resulting in insufficient precision in detection. Summary of the Invention
[0005] In a first aspect, the present invention provides a method for automatically detecting cereal quality defects based on machine vision, which adopts the following technical solutions: A method for automatically detecting grain quality defects based on machine vision comprises the following steps: S1. Acquire the three-axis vibration data of the conveyor belt and generate a vibration spectrum based on the three-axis vibration data; S2. Analyze the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and control the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; S3, the LED module deflects the compensating light in the illumination direction, driving the coaxially arranged visible light camera and near-infrared camera to shoot synchronously and generate a dual-spectrum fusion image; S4. Extracting the color saturation channel and the surface transmittance channel of the dual-spectral fusion image, identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, and generating mapping data containing spatial coordinates correlating potential moldy areas with potential insect-infested cavity locations; S5. Receive an externally input grain variety identifier, call a pre-stored variety feature library to combine and generate a dynamic judgment template including a mold threshold condition and an insect-damaged threshold condition; S6. Based on the mildew threshold condition and the insect-eaten threshold condition of the dynamic judgment template, compare the potential mildew area and the potential insect-eaten cavity in the spatial coordinate mapping data to generate a defect distribution map including the defect position coordinates.
[0006] A further solution of the present invention generates a vibration spectrum diagram, comprising the following steps: The original vibration waveform in the X / Y / Z directions is captured in real time by a three-axis acceleration sensor installed on the conveyor belt support frame; Bandpass filtering is performed on the original vibration waveform to generate a filtered time domain waveform; The filtered time domain waveform is fast Fourier transformed to generate a frequency domain energy distribution map; The frequency domain energy distribution diagram identifies the main resonance peak position and the corresponding amplitude value, and generates a vibration spectrum diagram.
[0007] A further solution of the present invention is to calculate the compensation angle, comprising the following steps: Extract the frequency value and acceleration amplitude value of the main resonance peak from the vibration spectrum; Calculate the displacement amplitude based on the acceleration amplitude and frequency values; The compensation angle is calculated according to the displacement amplitude and the preset vertical distance from the conveyor belt surface to the annular light source.
[0008] A further solution of the present invention controls the deflection illumination directions of multiple LED modules of the annular light source according to the compensation angle, comprising the following steps: After calculating the compensation angle, the multiple LED modules of the ring light source are controlled to synchronously deflect the illumination direction in the opposite direction of the vibration displacement according to the compensation angle; Synchronously match the camera exposure time window so that the deflection action of the ring light source based on the compensation angle completely covers the camera exposure cycle.
[0009] A further solution of the present invention generates a dual-spectrum fusion image, comprising the following steps: Drive the coaxially arranged visible light camera and near-infrared camera to shoot synchronously, extract the color saturation channel from the visible light image, and extract the surface transmittance channel from the near-infrared image; The saturation value of the color saturation channel is calculated based on the red channel intensity, green channel intensity, and blue channel intensity read from the pixels of the visible light image; The transmittance value of the surface transmittance channel is calculated based on the ratio of the pixel intensity value of the near-infrared image to the intensity value of the preset reference white plate; The color saturation channel and the surface transmittance channel are fused by weighted average at the same pixel position to generate a dual-spectrum fusion image.
[0010] A further embodiment of the present invention generates mapping data containing spatial coordinates of potential moldy areas and potential insect-damaged cavities, comprising the following steps: The adjacent pixel set with a saturation value lower than a preset mildew threshold in the color saturation channel is marked as a potential mildew area; The position points where the rate of change of the transmittance gradient in the surface transmittance channel exceeds the preset mutation threshold are marked as potential worm-eaten cavities; The pixel coordinates of all potential moldy areas and potential insect-eaten cavities are traversed, their overlapping positions on the image plane are identified and associated, and mapping data containing the spatial coordinates associated with the potential moldy areas and the potential insect-eaten cavities are generated.
[0011] A further solution of the present invention combines and generates a dynamic judgment template including a mildew threshold condition and an insect-eaten threshold condition, comprising the following steps: According to the received grain variety identification, the corresponding mildew threshold and the corresponding insect-eaten threshold are retrieved and extracted from the pre-stored variety feature library, where the insect-eaten threshold is the mutation threshold; The mold threshold and insect-eaten threshold of the current variety are extracted and combined to generate a dynamic judgment template containing the mold threshold conditions and the insect-eaten threshold conditions.
[0012] A further solution of the present invention is to compare the potential moldy areas and potential insect-eaten cavities in the spatial coordinate mapping data, including the following steps: The color saturation value of the potential moldy area marked in the spatial coordinate mapping data is compared with the mold threshold in the dynamic judgment template. The location of the moldy defect is marked if the saturation value is less than the threshold. The density of light transmission mutation points of potential worm-eaten cavities marked in the spatial coordinate mapping data is compared with the worm-eaten threshold in the dynamic judgment template, and the area exceeding the threshold is marked as the worm-eaten defect location.
[0013] A further embodiment of the present invention generates a defect distribution map including defect location coordinates, comprising the following steps: Detect the coordinate intersection of mold defects and insect-eaten defects on the image plane, and merge the spatially overlapping mold-eaten and insect-eaten areas as the composite defect location; Finally, all defect marking results are integrated to generate coordinate information including the locations of mildew defects, insect damage defects, and composite defects, forming a complete defect distribution map.
[0014] In a second aspect, the present invention provides a system for automatically detecting grain quality defects based on machine vision, which adopts the following technical solutions: A machine vision-based automatic detection system for grain quality defects, including the following modules: The vibration spectrum feature acquisition module acquires the three-axis vibration data of the conveyor belt and generates a vibration spectrum diagram based on the three-axis vibration data; The dynamic illumination compensation control module analyzes the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and controls the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; The dual-spectral image fusion imaging module uses the LED module to deflect the illumination direction to compensate for the light, driving the coaxially arranged visible light camera and near-infrared camera to shoot synchronously and generate a dual-spectral fusion image. A multi-dimensional defect feature separation and extraction module is used to extract the color saturation channel and surface transmittance channel of the dual-spectral fusion image. By identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, mapping data containing the spatial coordinates linking potential moldy areas and potential insect-damaged cavities is generated; A dynamic judgment template generation module is used to receive an external input grain variety identifier and call a pre-stored variety feature library to generate a dynamic judgment template containing a mold threshold condition and an insect-damaged threshold condition; The defect precision classification and positioning module compares potential moldy areas and potential insect-eaten cavities in the spatial coordinate mapping data based on the mold and insect-eaten threshold conditions of the dynamic judgment template, and generates a defect distribution map containing the defect location coordinates.
[0015] In summary, the present invention has the following beneficial technical effects: 1. By actively compensating for vibration interference during conveying, the system significantly improves image acquisition stability and clarity. The system monitors the conveyor belt's vibration spectrum in real time and, based on the analysis, reversely controls the light source's illumination angle, thereby physically offsetting the relative displacement caused by vibration. This dynamic illumination compensation mechanism ensures that the camera captures high-quality, motion-blur-free images at the moment of exposure, laying a solid foundation for subsequent, accurate defect analysis and effectively addressing the interference of industrial site vibration on high-precision visual inspection.
[0016] 2. Utilizing dual-spectral imaging technology, visible light and near-infrared (NIR) enables in-depth exploration and complementary analysis of grain defects. Visible light images are sensitive to color variations and can effectively extract color saturation characteristics that reflect the degree of mold and mildew. Meanwhile, NIR light has greater penetration into the internal structure of materials, revealing transmittance variations caused by microscopic subsurface cavities caused by insect damage. By integrating information from these two distinct spectral bands, the system can obtain richer and more comprehensive defect features than a single imaging mode. This allows for effective differentiation between color and texture anomalies, improving the ability to identify complex and compound defects.
[0017] 3. It can precisely classify and spatially locate defects, not only identifying single mildew or insect damage defects but also accurately identifying and marking areas with combined defects. By establishing spatial coordinate mapping relationships between different defect characteristics and merging and analyzing overlapping areas, the system can generate detailed defect distribution maps. This refined classification and accurate location of defect types provides more accurate data support for subsequent sorting, rejection, quality grading, and other process steps, enhancing the intelligence level of the entire production line and product quality control capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. The drawings are used to provide a further understanding of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 A schematic diagram of the flow chart in the embodiment of the present application is disclosed.
[0020] Figure 2 The present invention discloses a schematic structural diagram in an embodiment of the present application. DETAILED DESCRIPTION
[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0022] The following is combined with Figure 1-Figure 2 The preferred embodiments of the present invention are described in detail.
[0023] Refer to the attached Figure 1 The present invention proposes a method for automatically detecting grain quality defects based on machine vision, comprising the following steps: S1. Acquire the three-axis vibration data of the conveyor belt and generate a vibration spectrum based on the three-axis vibration data; S2. Analyze the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and control the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; S3, the LED module deflects the compensating light in the illumination direction, driving the coaxially arranged visible light camera and near-infrared camera to shoot synchronously and generate a dual-spectrum fusion image; S4. Extracting the color saturation channel and the surface transmittance channel of the dual-spectral fusion image, identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, and generating mapping data containing spatial coordinates correlating potential moldy areas with potential insect-infested cavity locations; S5. Receive an externally input grain variety identifier, call a pre-stored variety feature library to combine and generate a dynamic judgment template including a mold threshold condition and an insect-damaged threshold condition; S6. Based on the mildew threshold condition and the insect-eaten threshold condition of the dynamic judgment template, compare the potential mildew area and the potential insect-eaten cavity in the spatial coordinate mapping data to generate a defect distribution map including the defect position coordinates.
[0024] In one embodiment of the present invention, step S1 includes the following steps: The vibration spectrum characteristics of the conveyor belt are obtained. The three-axis vibration data of the grain conveying process is collected through an acceleration sensor and a vibration spectrum diagram is generated. Specifically, a three-axis acceleration sensor is installed on the conveyor belt support frame to capture the original vibration waveform in the X / Y / Z directions in real time; the original vibration waveform is subjected to 0.1-5Hz bandpass filtering, the time domain waveform is converted into a frequency domain energy distribution diagram, the main resonance peak position and amplitude value are marked, and a vibration spectrum diagram is generated.
[0025] Specifically, a triaxial accelerometer is installed on the conveyor belt support frame. It measures acceleration changes in three orthogonal directions (X, Y, and Z). The sensor is configured according to industrial-grade sensor standards and selected based on the installation requirements of the actual grain conveying system. The triaxial accelerometer captures the vibration waveforms generated in real time in the X, Y, and Z directions during grain conveying. These waveforms represent the time-varying vibration signal curves in these directions. The captured raw vibration waveforms are then bandpass filtered. The raw waveform refers to the unprocessed initial vibration signal data. The filter is set to a frequency range of 0.1 Hz to 5 Hz. This range allows signals within this range to pass, while removing high-frequency mechanical noise interference. Analysis of 200 sets of field-measured data from grain conveyor belts indicates that the 0.1 Hz to 5 Hz frequency band contains valid vibration signals. High-frequency mechanical noise interference refers to irrelevant high-frequency vibration signals (e.g., high-frequency mechanical noise > 5 Hz) originating from the conveyor belt system.
[0026] The filtered time domain waveform is converted into a frequency domain energy distribution diagram through fast Fourier transform. The time domain waveform represents the expression of the vibration signal on the time axis. The frequency domain energy distribution diagram shows the energy intensity distribution of the signal at different frequency points. The frequency domain energy distribution diagram identifies and marks the position of the main resonance peak and its corresponding amplitude value. The main resonance peak position refers to the frequency point with the highest energy value in the frequency domain energy distribution diagram, and the amplitude value refers to the signal amplitude corresponding to the main resonance peak position. Finally, a vibration spectrum diagram containing the main resonance peak position and amplitude value is generated based on the marking information.
[0027] For example, assume a grain conveyor belt is in operation, with a triaxial accelerometer fixed to the support frame, capturing vibration waveforms in real time along the X, Y, and Z axes. A 0.1-5 Hz bandpass filter is applied to the original waveform to remove high-frequency mechanical noise interference while retaining the valid signal. After conversion to a frequency domain energy distribution diagram, the main resonance peak position is identified at a frequency of 2 Hz, with an amplitude of 0.5g. A vibration spectrum is generated containing the main resonance peak position and amplitude information, verifying that the 0.1-5 Hz bandpass filter effectively removes noise and that the main resonance peak marking function is functioning properly.
[0028] In one embodiment of the present invention, step S2 includes the following steps: Analyze the amplitude of the main resonance peak of the vibration spectrum and calculate the compensation angle , control the 48 sets of LED modules of the ring light source, according to the compensation angle Reverse the deflection direction of illumination and synchronize with the camera exposure time window so that the light source compensation action covers the entire exposure period.
[0029] Specifically, the vibration spectrum generated in step S1 is analyzed to extract the frequency value corresponding to the main resonance peak position.f and amplitude values a , according to the physical relationship between acceleration and displacement, calculate the displacement amplitude , a is the main resonance peak acceleration amplitude, f is the main resonance peak frequency value. According to the displacement amplitude d The vertical distance from the preset conveyor belt surface to the ring light source L , calculate the compensation angle , Indicates the vertical distance from the conveyor belt surface to the annular light source. The preset fixed value is 0.5m, which is set based on the actual measurement of industrial installation standards. Then the 48 sets of LED modules of the annular shadowless light source are controlled, and all modules are adjusted according to the compensation angle. Synchronously deflect the irradiation direction in the opposite direction of the vibration displacement to compensate the angle Indicates the arc value of the LED module deflection. The ring shadowless light source is a lighting device composed of 48 independently controlled light-emitting units arranged in a ring.
[0030] The LED module is the smallest control unit of the light source and has mechanical deflection capabilities. The illumination direction refers to the angle of the LED module's light center. It also matches the camera's exposure window (the time interval between the start and end of camera exposure), ensuring that the start and end times of light compensation fully cover the entire exposure cycle.
[0031] For example, the vibration spectrum of step S1 is used to obtain the main resonance peak frequency. , acceleration amplitude That is 4.9m / s², the calculated displacement amplitude is: ; According to the preset distance L =0.5m, calculated The 48 LED modules are deflected in the opposite direction of vibration by 0.062 radians, and the camera exposure time window is synchronized to 10ms to ensure that the deflection action covers the entire 10ms exposure time.
[0032] In one embodiment of the present invention, step S3 includes the following steps: The coaxially arranged visible light camera and near-infrared camera are driven to shoot synchronously, the color saturation channel is extracted from the visible light image, and the surface transmittance channel is extracted from the near-infrared image; the saturation channel and the transmittance channel are weightedly fused according to the pixel position to generate a dual-spectrum fusion image.
[0033] Specifically, under the compensated illumination adjusted in step S2, the coaxially arranged visible light camera and near-infrared camera are driven to perform synchronous shooting. The visible light camera captures images within the wavelength range of 400-700nm, and the near-infrared camera captures images within the nanometer wavelength range of 900-1700nm. Visible light camera refers to an optical imaging device with an operating wavelength range of 400-700nm; near-infrared camera refers to an optical imaging device with an operating wavelength range of 900-1700nm. Coaxial arrangement means that the optical center axes of the two cameras coincide to ensure that the spatial positions of the images are aligned. Color space conversion processing is applied to the visible light image to extract the color saturation channel. The color saturation channel is a data layer extracted from the visible light image, which represents the color purity. The saturation value is obtained by calculating the difference in the RGB channel values of each pixel, and satisfies the following formula: ;
[0034] in, Indicates the saturation value, ranging from 0 to 1. represents the red channel intensity, represents the green channel intensity, Represents the blue channel intensity. The red channel intensity, green channel intensity, and blue channel intensity are all directly read from the pixel values obtained from the visible light camera.
[0035] Apply transmittance analysis to the near-infrared image to extract the surface transmittance channel. The surface transmittance channel is a data layer extracted from the near-infrared image that represents the material's ability to transmit light. The transmittance value is calculated by calculating the ratio of pixel intensity to a reference benchmark, satisfying the following formula: , Indicates the transmittance value; represents the pixel intensity value of the near-infrared image, The pixel intensity value represents the pixel intensity of a reference whiteboard under the same lighting conditions. It is set to a grayscale value of 100 through pre-calibration experiments based on laboratory calibration data. Finally, the color saturation channel and the surface transmittance channel are fused by weighted averaging at the same pixel position to generate a dual-spectral fused image.
[0036] Exemplarily, under the coverage of the compensation illumination and exposure time window of step S2, the visible light camera and the near-infrared camera are driven to shoot synchronously, and the color saturation channel of the visible light image is extracted, such as the saturation S value at the center pixel position is calculated to be 0.65; the surface transmittance channel of the near-infrared image is extracted, such as the transmittance T value at the same pixel position is calculated to be 0.75; and the S and T channels are weightedly averaged and fused with equal weights according to the pixel position to generate a pixel value of 0.70 for the dual-spectrum fusion image.
[0037] In one embodiment of the present invention, step S4 includes the following steps: Continuous dark areas are identified in the color saturation channel and marked as potential moldy areas. Local transmittance mutation points are detected in the surface transmittance channel and marked as potential insect-eaten cavities. A spatial coordinate mapping relationship is established to associate the overlapping positions of moldy areas and cavity areas.
[0038] Specifically, the dual-spectrum fusion image generated in step S3 is received, the saturation value of the color saturation channel and the transmittance value of the surface transmittance channel are separated and extracted from the dual-spectrum fusion image, and each saturation value is compared with the preset mildew threshold value. , the saturation value is lower than the preset mildew threshold The adjacent pixel set of is marked as the potential moldy area. The continuous dark area is the image area attribute identified from the color saturation channel, which is defined as the saturation value below A potential mold area is a set of annotated image coordinates that indicates the location of possible mold defects.
[0039] Calculate the gradient change rate of each pixel transmittance value and compare each gradient change rate with the preset mutation threshold , the gradient change rate exceeds the preset mutation threshold The position point is marked as a potential wormhole. The local transmittance mutation point is the image position attribute detected from the surface transmittance channel, which is defined as the transmittance gradient change rate exceeding the preset mutation threshold. The points are calibrated based on the measured data of 150 sets of worm-eaten grain samples. Potential worm-eaten voids are a set of annotated image points that indicate the locations of possible worm-eaten defects.
[0040] Establish a spatial coordinate mapping relationship, traverse the pixel coordinates of all potential moldy areas and potential insect-eaten cavities, identify and associate their overlapping locations on the image plane, and output spatial coordinate mapping data containing separated color anomaly features, potential moldy areas, and texture anomaly features, potential insect-eaten cavities. The separated defect feature space includes decoupled color anomaly features and texture anomaly features. Decoupling color anomaly and texture anomaly features is the process of separating and identifying color-related and texture-related defect features from the fused image.
[0041] For example, following the pixel value of 0.70 in the bispectral fusion image of step S3, a color saturation channel value of 0.65 and a surface transmittance channel value of 0.75 are extracted from the bispectral fusion image, a preset mildew threshold of 0.4 is set, and a preset mutation threshold of 0.1 is set. In the color saturation channel, continuous dark areas with a saturation below the preset mildew threshold of 0.4 are identified, for example, an area containing 50 pixels and marked as a potential mildew area. In the surface transmittance channel, areas with a gradient change rate of transmittance above the preset mutation threshold of 0.1 are marked as potential insect-infested cavities. The overlapping positions of the mildew area and the cavity area are associated through spatial coordinate mapping.
[0042] In one embodiment of the present invention, step S5 includes the following steps: Receive the external input grain variety identification, call the pre-stored variety feature library to combine the current variety's mildew-insect damage dual threshold conditions, and generate a dynamic judgment template.
[0043] Specifically, an externally input grain variety identifier is received, and the grain variety identifier represents the type of grain currently being detected, such as one of soybeans, red beans, or purse beans. Then, a pre-stored variety feature library is called, which pre-stores the mold threshold and insect-eaten threshold rules corresponding to different grain varieties. Based on the received variety identifier, the corresponding mold threshold and insect-eaten threshold are extracted from the pre-stored variety feature library. The insect-eaten threshold is the mutation threshold. For example, when the grain variety identifier is soybean, the mold threshold condition saturation value is extracted as <0.7, and the insect-eaten threshold condition transmittance mutation point density is extracted as >12 / mm². The mold threshold condition and the insect-eaten threshold condition of the current variety are combined to generate a dynamic judgment template containing a dual-threshold rule set. The grain variety identifier of the dynamic judgment template is an input data item, and the attribute is a string enumeration value. The mold threshold and insect-eaten threshold rules corresponding to different grain varieties are set to be manually selected by the user or automatically input.
[0044] Among them, the pre-stored variety characteristic library is set as laboratory test data, which is calibrated based on actual measurements of 100 groups of different grain variety samples.
[0045] The soybean mold threshold is a rule for determining soybean tofu defects. It is defined as a saturation value < 0.7, and is determined based on experimental data from 50 soybean mold samples. The soybean insect damage threshold is a rule for determining soybean insect damage defects. It is defined as a transmittance mutation point density > 12 / mm², and is determined based on measured data from 60 soybean insect damage samples. The mold-insect damage dual threshold condition is a combined logical rule set consisting of two conditional items: the mold threshold and the insect damage threshold.
[0046] Exemplarily, the spatial coordinate mapping data output in step S4 includes a potential moldy area saturation value of 0.35 and a potential insect-eaten cavity light transmittance mutation point density value of 10 / mm²; an external input soybean variety identifier is received, a pre-stored variety feature library is called, and a soybean moldy threshold saturation of <0.7 and a soybean insect-eaten threshold light transmittance mutation point density of >12 / mm² are extracted; and a dynamic judgment template is generated by combining the moldy condition saturation of <0.7 and the insect-eaten condition light transmittance mutation point density of >12 / mm².
[0047] In one embodiment of the present invention, step S6 includes the following steps: The areas exceeding the mildew threshold mark by comparing the color saturation of the tested area are identified as mildew defects. The areas exceeding the mildew threshold mark by comparing the light transmittance mutation point density of the tested area are identified as worm-eaten defects. The spatially overlapping mildew-worm-eaten areas are merged as composite defects to generate a defect distribution map with position coordinates.
[0048] Specifically, the feature space data output in step S4 is received. The feature space data includes a set of color saturation values for potential moldy areas and a set of light transmittance mutation point density values for potential worm-eaten cavities. The dynamic judgment template generated in step S5 is also received. The color saturation value of each area to be tested is compared with the mold threshold of the dynamic judgment template. If the saturation value exceeds the mold threshold, the area is marked as a mold defect. The light transmittance mutation point density of each area to be tested is compared with the worm-eaten threshold of the dynamic judgment template. If the mutation point density exceeds the worm-eaten threshold, the area is marked as a worm-eaten defect. The light transmittance mutation point density is defined as the number of light transmittance mutation points per square millimeter.
[0049] Based on the spatial coordinate mapping relationship established in step S4, the spatial overlapping positions of the moldy defect area and the worm-eaten defect area are detected, and the overlapping areas are merged and marked as composite defects. The spatial overlapping position refers to the coordinate intersection of the moldy defect area and the worm-eaten defect area on the image plane. The composite defect indicates an area where moldy and worm-eaten areas exist at the same time. Finally, all defect marking results are integrated to generate coordinate information including the moldy defect position, the worm-eaten defect position, and the composite defect position to form a complete defect distribution map.
[0050] For example, if the potential mold area saturation value of step S4 is 0.35 and the dynamic judgment template mold threshold saturation of step S5 is less than 0.7, after comparison, the saturation of this area is 0.75 and does not exceed the standard, so the mold defect is not marked. The insect-eaten cavity light-transmitting mutation point density of step S4 is 10 / mm², compared with the insect-eaten threshold of 12 / mm² in step S5, this area does not meet the standard and is not marked as an insect-eaten defect. Another area with a saturation of 0.65 less than the 0.7 threshold is marked as a mold defect, and another area with a mutation point density of 18 / mm² exceeding the 12 / mm² threshold is marked as an insect-eaten defect. The two areas are spatially overlapped and merged into a composite defect, and the final defect distribution map is generated, including the above-mentioned marked locations.
[0051] See attached Figure 2 The present invention also proposes a machine vision-based automatic detection system for cereal quality defects, which includes the following modules: The vibration spectrum feature acquisition module acquires the three-axis vibration data of the conveyor belt and generates a vibration spectrum diagram based on the three-axis vibration data; The dynamic illumination compensation control module analyzes the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and controls the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; The dual-spectral image fusion imaging module uses the LED module to deflect the illumination direction to compensate for the light, driving the coaxially arranged visible light camera and near-infrared camera to shoot synchronously and generate a dual-spectral fusion image. A multi-dimensional defect feature separation and extraction module is used to extract the color saturation channel and surface transmittance channel of the dual-spectral fusion image. By identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, mapping data containing the spatial coordinates linking potential moldy areas and potential insect-damaged cavities is generated; A dynamic judgment template generation module is used to receive an external input grain variety identifier and call a pre-stored variety feature library to generate a dynamic judgment template containing a mold threshold condition and an insect-damaged threshold condition; The defect precision classification and positioning module compares potential moldy areas and potential insect-eaten cavities in the spatial coordinate mapping data based on the mold and insect-eaten threshold conditions of the dynamic judgment template, and generates a defect distribution map containing the defect location coordinates.
[0052] It should be noted that the formulas described above, through the principle of dimensional consistency and mathematical standardization (e.g., normalization, dimensionless parameter conversion, or unified unit system), can translate physical quantities of different attributes into unitless standard values or homogeneous, superimposable parameters. This eliminates the interference of different dimensions on operational logic, ensuring that the formulas retain the distribution characteristics of the original data while maintaining mathematical rationality and adaptability to objective laws. These are merely exemplary embodiments of the present invention and are not intended to limit the scope of the invention.
[0053] The modules can be implemented in whole or in part through software, hardware, or a combination thereof, supporting hardware embedded in or independent of a processor in a computer device, and also supporting software stored in a memory in a computer device, so that the processor can call and execute operations corresponding to the modules.
[0054] It should be noted that the human body information (including but not limited to human device information and personal information, etc.) and data (including but not limited to data used for analysis, stored data and displayed data, etc.) involved in the present invention are all information and data authorized by the human body or fully authorized by all parties. The collection, use and processing of relevant data require relevant legal standards.
[0055] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for automatically detecting cereal quality defects based on machine vision, characterized in that: The following steps are involved: S1. Acquire the three-axis vibration data of the conveyor belt and generate a vibration spectrum based on the three-axis vibration data; S2. Analyze the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and control the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; S3, the LED module deflects the compensating light in the illumination direction, driving the coaxially arranged visible light camera and near-infrared camera to shoot synchronously and generate a dual-spectrum fusion image; S4. Extracting the color saturation channel and the surface transmittance channel of the dual-spectral fusion image, identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, and generating mapping data containing spatial coordinates correlating potential moldy areas with potential insect-infested cavity locations; S5. Receive an externally input grain variety identifier, call a pre-stored variety feature library to combine and generate a dynamic judgment template including a mold threshold condition and an insect-damaged threshold condition; S6. Based on the mildew threshold condition and the insect-eaten threshold condition of the dynamic judgment template, compare the potential mildew area and the potential insect-eaten cavity in the spatial coordinate mapping data to generate a defect distribution map including the defect position coordinates.
2. The method for automatically detecting cereal quality defects based on machine vision according to claim 1, characterized in that: Generating a vibration spectrum diagram includes the following steps: The original vibration waveform in the X / Y / Z directions is captured in real time by a three-axis acceleration sensor installed on the conveyor belt support frame; Bandpass filtering is performed on the original vibration waveform to generate a filtered time domain waveform; The filtered time domain waveform is fast Fourier transformed to generate a frequency domain energy distribution map; The frequency domain energy distribution diagram identifies the main resonance peak position and the corresponding amplitude value, and generates a vibration spectrum diagram.
3. The method for automatic detection of cereal quality defects based on machine vision according to claim 1, characterized in that: Calculating the compensation angle includes the following steps: Extract the frequency value and acceleration amplitude value of the main resonance peak from the vibration spectrum; Calculate the displacement amplitude based on the acceleration amplitude and frequency values; The compensation angle is calculated according to the displacement amplitude and the preset vertical distance from the conveyor belt surface to the annular light source.
4. The method for automatically detecting cereal quality defects based on machine vision according to claim 3, characterized in that: Controlling the deflection illumination directions of multiple LED modules of a ring light source according to a compensation angle includes the following steps: After calculating the compensation angle, the multiple LED modules of the ring light source are controlled to synchronously deflect the illumination direction in the opposite direction of the vibration displacement according to the compensation angle; Synchronously match the camera exposure time window so that the deflection action of the ring light source based on the compensation angle completely covers the camera exposure cycle.
5. The method for automatically detecting cereal quality defects based on machine vision according to claim 1, characterized in that: Generating a dual-spectrum fusion image includes the following steps: Drive the coaxially arranged visible light camera and near-infrared camera to shoot synchronously, extract the color saturation channel from the visible light image, and extract the surface transmittance channel from the near-infrared image; The saturation value of the color saturation channel is calculated based on the red channel intensity, green channel intensity, and blue channel intensity read from the pixels of the visible light image; The transmittance value of the surface transmittance channel is calculated based on the ratio of the pixel intensity value of the near-infrared image to the intensity value of the preset reference white plate; The color saturation channel and the surface transmittance channel are fused by weighted average at the same pixel position to generate a dual-spectrum fusion image.
6. The method for automatically detecting cereal quality defects based on machine vision according to claim 5, characterized in that: Generating mapping data containing spatial coordinates correlating potential mold infestation areas with potential insect-infested cavity locations includes the following steps: The adjacent pixel set with a saturation value lower than a preset mildew threshold in the color saturation channel is marked as a potential mildew area; The position points where the rate of change of the transmittance gradient in the surface transmittance channel exceeds the preset mutation threshold are marked as potential worm-eaten cavities; The pixel coordinates of all potential moldy areas and potential insect-eaten cavities are traversed, their overlapping positions on the image plane are identified and associated, and mapping data containing the spatial coordinates associated with the potential moldy areas and the potential insect-eaten cavities are generated.
7. The method for automatically detecting cereal quality defects based on machine vision according to claim 1, characterized in that: Combining and generating a dynamic judgment template including a mildew threshold condition and an insect-eaten threshold condition includes the following steps: According to the received grain variety identification, the corresponding mildew threshold and the corresponding insect-eaten threshold are retrieved and extracted from the pre-stored variety feature library, where the insect-eaten threshold is the mutation threshold; The mold threshold and insect-eaten threshold of the current variety are extracted and combined to generate a dynamic judgment template containing the mold threshold conditions and the insect-eaten threshold conditions.
8. The method for automatically detecting cereal quality defects based on machine vision according to claim 1, characterized in that: Comparing the potential moldy areas and potential insect-infested cavities in the spatial coordinate mapping data includes the following steps: The color saturation value of the potential moldy area marked in the spatial coordinate mapping data is compared with the mold threshold in the dynamic judgment template. The location of the moldy defect is marked if the saturation value is less than the threshold. The density of light transmission mutation points of potential worm-eaten cavities marked in the spatial coordinate mapping data is compared with the worm-eaten threshold in the dynamic judgment template, and the area exceeding the threshold is marked as the worm-eaten defect location.
9. The method for automatically detecting cereal quality defects based on machine vision according to claim 8, characterized in that: Generating a defect distribution map containing defect location coordinates includes the following steps: Detect the coordinate intersection of mold defects and insect-eaten defects on the image plane, and merge the spatially overlapping mold-eaten and insect-eaten areas as the composite defect location; Finally, all defect marking results are integrated to generate coordinate information including the locations of mildew defects, insect damage defects, and composite defects, forming a complete defect distribution map.
10. A machine vision-based automatic detection system for cereal quality defects, characterized in that: Includes the following modules: The vibration spectrum feature acquisition module acquires the three-axis vibration data of the conveyor belt and generates a vibration spectrum diagram based on the three-axis vibration data; The dynamic illumination compensation control module analyzes the amplitude of the main resonance peak of the vibration spectrum to calculate the compensation angle, and controls the deflection illumination direction of the multiple LED modules of the ring light source according to the compensation angle; The dual-spectral image fusion imaging module uses the LED module to deflect the illumination direction to compensate for the light, driving the coaxially arranged visible light camera and near-infrared camera to synchronously shoot and generate a dual-spectral fusion image; A multi-dimensional defect feature separation and extraction module is used to extract the color saturation channel and surface transmittance channel of the dual-spectral fusion image. By identifying continuous dark areas in the color saturation channel and detecting local transmittance mutation points in the surface transmittance channel, mapping data containing the spatial coordinates linking potential moldy areas and potential insect-damaged cavities is generated; A dynamic judgment template generation module is used to receive an external input grain variety identifier and call a pre-stored variety feature library to generate a dynamic judgment template containing a mold threshold condition and an insect-damaged threshold condition; The defect precision classification and positioning module compares potential moldy areas and potential insect-eaten cavities in the spatial coordinate mapping data based on the mold and insect-eaten threshold conditions of the dynamic judgment template, and generates a defect distribution map containing the defect location coordinates.
Citation Information
Patent Citations
Rice disease and pest identification method and system based on machine vision technology
CN120219861A
Multi-scene self-adaptive visual acquisition system and method
CN120434509A
Method and apparatus for residue detection on a polished wafer
WO2006046236A1