Coffee bean grading screening system and method and storage medium

By combining an airflow sorter and a multi-branch network model with a stereo matching algorithm, the problems of low coffee bean grading efficiency and inconsistent results in the existing technology are solved, and efficient and accurate grading of coffee beans is achieved.

CN120656163AInactive Publication Date: 2025-09-16HEFEI RUIYUN SUPER MICRO IDENTIFICATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510746512.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-09-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing coffee bean grading and screening methods are inefficient and have difficulty accurately assessing the internal quality and three-dimensional morphology of coffee beans, resulting in inconsistent grading results and failing to meet the demand for high-quality coffee.

Method used

An airflow sorter is used for density screening, and a multi-branch network model is combined with dual-view detection and stereo matching algorithm to obtain the equivalent area and height of coffee beans and establish an objective grading standard.

Benefits of technology

It achieves dual screening of internal and external defects of coffee beans, improves the accuracy and consistency of grading results, improves grading efficiency, and meets the production needs of high-quality coffee.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120656163A_ABST
    Figure CN120656163A_ABST
Patent Text Reader

Abstract

The invention discloses a coffee bean grading screening system and method and a storage medium, and the method comprises the steps: carrying out the preliminary screening of coffee beans through an airflow sorting machine, and reserving the coffee beans with the density reaching a preset density threshold value, so as to obtain primary coffee beans; obtaining a top view and a bottom view of the primary coffee beans, inputting the top view and the bottom view into the multi-branch network model for defect detection and semantic segmentation, and outputting a classification result and a segmentation mask of the primary coffee beans; extracting and calculating the equivalent area of the segmentation mask of the normal coffee beans, and calculating the height of the normal coffee beans based on a stereo matching algorithm; and according to the equivalent area and the height, grading and screening normal coffee beans to obtain a coffee bean grading result. The invention relates to the technical field of coffee bean screening, and solves the technical problems of missing detection of internal defects of coffee beans, subjective grading standard and low efficiency in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of coffee bean screening and relates to computer vision technology, in particular to a coffee bean grading and screening system, method and storage medium. Background Art

[0002] Coffee, a widely consumed beverage worldwide, relies heavily on the quality of its beans. Grading and screening of coffee beans is a critical step in the coffee production process, directly impacting its taste, aroma, and market value. However, existing coffee bean grading and screening methods and systems have numerous shortcomings, making them inadequate for high-quality coffee production.

[0003] In the early days, coffee bean grading and screening relied primarily on manual labor. This method was inefficient, with workers prone to fatigue from long hours, resulting in slow screening and limited hourly processing capacity, making it difficult to meet the demands of large-scale production. Furthermore, manual screening was highly subjective, with varying experience and judgment among workers. This led to inconsistent and inaccurate screening results, resulting in varying quality within the same batch of coffee beans and making it difficult to guarantee stable product quality.

[0004] With technological advancements, machine vision technology is increasingly being applied to coffee bean grading and screening. However, most current visual inspection systems utilize only single-view or two-dimensional visual inspection methods, capturing only two-dimensional information about the beans. This method cannot accurately assess the internal quality and three-dimensional morphology of coffee beans, and can easily miss beans with internal defects such as hollowness, insect damage, and mold. Because internal defects may not be apparent externally, they can be difficult to detect using only two-dimensional images. Furthermore, two-dimensional visual inspection cannot accurately measure three-dimensional features such as the plumpness of coffee beans, resulting in grading results that do not fully reflect the beans' true quality. Therefore, existing grading and screening methods fail to meet consumer demand for high-quality coffee and hinder the further development of the coffee industry. Summary of the Invention

[0005] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a coffee bean grading and screening system, method and storage medium for solving the technical problems of missed detection of internal defects of coffee beans, subjective grading standards and low efficiency in the prior art.

[0006] To achieve the above objectives, a first aspect of the present invention provides a coffee bean grading and screening method, comprising:

[0007] The coffee beans are preliminarily screened using an airflow sorter, and coffee beans with a density reaching a preset density threshold are retained to obtain primary coffee beans;

[0008] Obtaining top and bottom views of primary coffee beans, and inputting these views into a multi-branch network model for defect detection and semantic segmentation, and outputting classification results and segmentation masks for the primary coffee beans; wherein the classification results include defective coffee beans and normal coffee beans, and the segmentation masks include top view masks and bottom view masks;

[0009] Extract and calculate the equivalent area of ​​the segmentation mask of normal coffee beans, and calculate the height of normal coffee beans based on the stereo matching algorithm;

[0010] Normal coffee beans are graded and screened according to equivalent area and height to obtain coffee bean grading results.

[0011] Furthermore, the preliminary screening of coffee beans using the airflow sorter includes: using a preset critical airflow velocity formula: Calculate the target wind speed and retain coffee beans whose density reaches the preset density threshold; where v c represents the target wind speed, k represents the correction coefficient, ρ represents the preset density threshold, g represents the acceleration of gravity, ρ a Indicates the air density, C d Indicates the resistance coefficient of coffee beans.

[0012] Furthermore, the method for obtaining the top view and the bottom view of the primary coffee beans comprises:

[0013] The primary coffee beans are spread flat on a transparent placement plate and dispersed into a single layer by a vibration motor at a preset frequency;

[0014] A top-view camera and a bottom-view camera deployed directly above and below a transparent placement plate are used to capture dual-perspective images to obtain a top view and a bottom view; wherein a ring-shaped LED light source is arranged below the transparent placement plate.

[0015] Furthermore, the multi-branch network model includes a backbone network, a defect detection branch and a semantic segmentation branch, wherein:

[0016] The backbone network adopts a dual-stream branch architecture, takes the top view and bottom view of coffee beans as input images, uses a convolutional neural network to extract the general features of the top view and bottom view of coffee beans, and then obtains fused features through channel splicing;

[0017] The defect detection branch uses the fused features as input features and outputs a bounding box and a category label of the coffee beans, wherein the category label includes defective coffee beans and normal coffee beans;

[0018] The semantic segmentation branch uses the fused features as input features and outputs a pixel-level segmentation mask of the coffee beans, where the pixel-level segmentation mask includes a coffee bean area and a background area.

[0019] It should be noted that when labeling the categories of coffee beans, coffee beans with cracks, spots, abnormal color areas, moldy areas, etc. on the surface are marked as defective coffee beans, and coffee beans with no quality problems on the surface are marked as normal coffee beans.

[0020] Density screening, using an airflow sorter, calculates the target air speed based on the critical airflow velocity formula. This effectively removes coffee beans whose density falls below a preset threshold. These beans may have internal defects such as hollowness, insect damage, and mold, which are difficult to detect through visual inspection. Density screening can be performed first to preemptively exclude beans with internal defects, reducing the processing load for subsequent model testing and improving overall screening efficiency. Appearance screening allows for more targeted detection of surface defects such as cracks, spots, and color anomalies, making the screening process more targeted and ensuring that the final beans meet both density and appearance requirements.

[0021] Furthermore, the calculation method of the equivalent area is:

[0022] Count the total number of pixels in the top view mask and bottom view mask of normal coffee beans respectively to obtain the total number of top view pixels N1 and the total number of bottom view pixels N2;

[0023] The coffee bean area A in a single view is calculated using the pre-calibrated camera pixel physical size conversion coefficient S: S = actual area of ​​the transparent placement plate / pixel area of ​​the transparent placement plate image i =N i ×S; where i=1,2, represents the view index;

[0024] Calculate the average of the area of ​​the coffee bean in the top view and the area of ​​the coffee bean in the bottom view to get the equivalent area A.

[0025] Furthermore, the calculation of the height of normal coffee beans based on the stereo matching algorithm includes:

[0026] Obtaining the focal length f and baseline distance B of the top-view camera and the bottom-view camera; wherein the baseline distance is the horizontal distance between the optical centers of the top-view camera and the bottom-view camera, and the focal lengths of the top-view camera and the bottom-view camera are preset to be the same value;

[0027] Grayscale processing and Gaussian filtering denoising are performed on the top and bottom views of normal coffee beans to obtain preprocessed top and bottom views;

[0028] The ORB feature points of the top view and bottom view are extracted respectively after preprocessing, and the fast approximate nearest neighbor matcher FLANN is used to match the top view ORB feature point set P t And the bottom view ORB feature point set P b Perform matching to obtain the initial matching point pair set M raw ;

[0029] For the initial matching point pair set M raw Apply the random sampling consensus algorithm RANSAC to obtain the effective matching point set M valid ; Among them, the matching point pair (p t ,p b )∈M valid The pixel coordinates p corresponding to the same coffee bean feature point in the top view and bottom view t =(u t ,v t ) and p b =(u b ,v b ), and p t ∈P t , p b ∈P b ;

[0030] Calculate matching point pairs (p t ,p b ) horizontal disparity d=|v t -v b |, get the disparity of the matching points of a single coffee bean, and calculate the average disparity of all matching points to get the average disparity d avg ;

[0031] According to the formula h=B·f / d avg Calculate the height H of normal coffee beans.

[0032] Furthermore, the ORB feature point extraction process includes:

[0033] Performing corner detection on the preprocessed top view image using the FAST corner detection algorithm, and retaining corner points with response values ​​greater than a preset threshold as top view key points through non-maximum suppression to obtain a top view key point set; wherein the preset threshold is used to filter corner points with a predetermined proportion before the response value, and the predetermined proportion is adaptively adjusted according to the resolution of the coffee bean image;

[0034] The main direction is determined by calculating the gradient histogram in a neighborhood with a preset radius centered on the top view key point, and a BRIEF descriptor is generated based on the main direction to obtain the top view ORB feature point set;

[0035] Repeat the above process for the preprocessed bottom view to obtain a bottom view ORB feature point set.

[0036] Furthermore, the screening conditions of the random sampling consensus algorithm RANSAC are to satisfy the epipolar geometry constraints, including:

[0037] Calculate the initial matching point set M using the eight-point method rawThe basic matrix F of

[0038] For each pair of initial matching points (p1, p2) ∈ M raw ,judge Is the absolute value of greater than the preset threshold? If yes, the initial matching point pair (p1, P2) is marked as a wrong matching point pair and removed; if no, (p1, p2) is marked as satisfying the epipolar geometry constraint and retained as a valid matching point pair.

[0039] Furthermore, the hierarchical screening rules include:

[0040] Set the equivalent area thresholds of different levels: A1<A2<A3;

[0041] Set different levels of height thresholds: H1<H2<H3;

[0042] Normal coffee beans that meet A≥A3 and H≥H3 are marked as first-grade beans; where A represents the equivalent area and H represents the height of the coffee beans;

[0043] Normal coffee beans that satisfy A2≤A<A3 and H2≤H<H3 are marked as secondary beans;

[0044] Normal coffee beans that meet A1≤A<A2 and H2≤H<H3 or A2≤A<A3 and H1≤H<H2 are marked as third-grade beans;

[0045] Normal coffee beans that meet A<A1 or H

[0046] Traditional manual grading relies on manual experience, is inefficient and highly subjective, and the judgment criteria of different operators may differ, resulting in unstable grading results; and relying solely on visual inspection can usually only obtain two-dimensional plane information of coffee beans, which is difficult to accurately reflect their three-dimensional fullness. In the present invention, the equivalent area is calculated by the top view and bottom view mask pixels, which can reflect the size and shape of the coffee beans on the two-dimensional plane, and the height is calculated based on the dual views through a stereo matching algorithm, which reflects the three-dimensional information of the coffee beans. The combination of the two can more comprehensively and accurately reflect the fullness of the coffee beans. This grading method uses quantified equivalent area and height as grading indicators, establishes an objective and unified grading standard, reduces the interference of human factors, and improves the reliability and consistency of the grading results.

[0047] A second aspect of the present invention provides a coffee bean grading and screening system, comprising:

[0048] Airflow sorter: used to calculate the target air speed according to the preset critical airflow speed formula, screen the coffee beans by density, and retain the coffee beans with a density reaching the preset density threshold to obtain primary coffee beans;​

[0049] Image acquisition device: used for acquiring top view and bottom view of primary coffee beans through a top view camera and a bottom view camera;

[0050] Computer processing equipment: used for running a multi-branch network model to process the top view and the bottom view of the primary coffee beans, screening out normal coffee beans, and calculating the equivalent area and height parameters of the normal coffee beans;

[0051] The output of the multi-branch network model is a classification result and a segmentation mask of the coffee beans. The classification result includes defective and normal. The segmentation mask includes a top view mask and a bottom view mask. The equivalent area is calculated based on the segmentation mask. The height parameter is calculated based on the top view and the bottom view.

[0052] Grading and screening device: used to execute grading and screening rules according to the equivalent area and height parameters of normal coffee beans and perform grading and screening.

[0053] The equivalent area of ​​the segmentation mask of normal coffee beans is extracted and calculated, and the height of the normal coffee beans is calculated based on the stereo matching algorithm. The normal coffee beans are graded and screened according to the equivalent area and height to obtain the coffee bean grading results.

[0054] A third aspect of the present invention provides a computer-readable storage medium comprising:

[0055] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the coffee bean grading and screening method described above are specifically as follows:

[0056] The airflow sorting machine is controlled to calculate the target air speed according to the preset critical airflow speed formula, and the coffee beans are density screened. The coffee beans with a density reaching the preset density threshold are retained to obtain primary coffee beans.

[0057] Controlling the image acquisition device to obtain a top view and a bottom view of the primary coffee beans through a top view camera and a bottom view camera;

[0058] Running a multi-branch network model to process the top view and the bottom view of the primary coffee beans, obtaining classification results and segmentation masks of the coffee beans, wherein the classification results include defects and normal, and the segmentation masks include a top view mask and a bottom view mask;

[0059] Calculating the equivalent area of ​​normal coffee beans based on the segmentation mask, and calculating the height parameters of the normal coffee beans based on the top view and the bottom view using a stereo matching algorithm;

[0060] According to the equivalent area and height parameters of normal coffee beans, the grading and screening rules are implemented to perform grading and screening to obtain the coffee bean grading results;

[0061] The computer-readable storage medium includes, but is not limited to, a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, an optical disk, and other media that can store program codes.

[0062] Compared with the prior art, the present invention has the following beneficial effects:

[0063] First, an airflow sorter is used to screen the coffee beans for density, effectively eliminating those with internal defects such as hollowness, insect damage, and mildew. A multi-branch network model is then used to process the top and bottom views to detect surface defects such as cracks, spots, and color anomalies. This achieves dual screening of the coffee beans' internal density and external appearance, ensuring that the selected coffee beans are of higher quality, reducing the contamination of defective beans, and improving the overall quality of the coffee beans.

[0064] Furthermore, the multi-branch network model adopts a dual-stream branch architecture, taking top and bottom views as input. The backbone network extracts common visual features, while the defect detection branch and semantic segmentation branch output classification results and segmentation masks, respectively. This allows the model to simultaneously complete defect detection and semantic segmentation tasks, avoiding the tedious process of performing different tests separately in traditional methods. This improves detection efficiency and parallel processing capabilities, enabling the processing of more coffee bean images per unit time and increasing the overall processing speed of the system.

[0065] By capturing multi-view images from top- and bottom-view cameras, and combining them with a stereo matching algorithm to calculate the height of the coffee beans, the system then uses the equivalent area to comprehensively assess the fullness of the beans in both two-dimensional and three-dimensional dimensions, establishing a more comprehensive and accurate grading index system. Compared to traditional methods that rely solely on visual inspection or manual grading, this grading method based on multi-dimensional quantitative indicators can more accurately grade coffee beans, ensuring that the grading results are more consistent with the actual quality of the coffee beans, providing a scientific and reliable basis for quality assessment and market grading of coffee beans. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] 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. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0067] Figure 1 A schematic diagram of a process for grading and screening coffee beans provided by the present invention;

[0068] Figure 2 A schematic diagram of the process for calculating the height of coffee beans provided by the present invention;

[0069] Figure 3 A schematic diagram of the process of obtaining a top-view ORB feature point set provided by the present invention. DETAILED DESCRIPTION

[0070] The technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0071] The coffee bean grading and screening method provided in the embodiment of the present application can be applied to a coffee bean grading and screening system including an airflow sorter, an image acquisition device, and a computer processing device.

[0072] Among them, the airflow sorter is used to calculate the target wind speed according to the preset critical airflow velocity formula, screen the coffee beans for density, and eliminate coffee beans whose density does not reach the preset threshold; the image acquisition device is used to obtain the top view and bottom view of the coffee beans through the top view camera and the bottom view camera; the computer processing equipment is used to run the multi-branch network model to process images, calculate coffee bean parameters and complete grading.

[0073] In order to solve the technical problems of missed detection of internal defects of coffee beans, subjective grading standards and low efficiency in the prior art, the present application provides a coffee bean grading and screening method, such as Figure 1 As shown in the figure, this method achieves automatic and accurate grading of coffee beans through the process of "density screening → multi-view detection → quantitative grading". It specifically includes the following steps:

[0074] S1, using an airflow sorter to perform preliminary screening of coffee beans, retaining coffee beans with a density reaching a preset density threshold to obtain primary coffee beans.

[0075] The airflow sorter calculates the target air speed using a preset critical airflow velocity formula and removes coffee beans whose density does not reach the preset threshold. The calculation formula is: in:

[0076] υ c Indicates the target air speed (m / s), used to separate low-density coffee beans;

[0077] k represents the correction coefficient (m), which is used to correct the geometric scale difference of the air duct structure of the air separator and is obtained through experimental fitting;

[0078] ρ represents the preset density threshold (kg / m 3 ), set according to coffee bean variety;

[0079] g represents the acceleration due to gravity, ρ aIndicates the air density;

[0080] C d The drag coefficient of coffee beans is measured through wind tunnel experiments and is related to the shape of the coffee beans.

[0081] In some implementations, the preset threshold and target wind speed can be adjusted according to the characteristics of different types of coffee beans.

[0082] It should be pointed out that density screening can eliminate coffee beans with internal defects in advance, such as those that are hollow, worm-eaten, or moldy, so as to reduce the burden of subsequent appearance screening.

[0083] S2, obtain top and bottom views of primary coffee beans.

[0084] After screening, the primary coffee beans are transported to the image acquisition device. The primary coffee beans are spread flat on a transparent placement plate and the vibration motor is activated to vibrate at a preset frequency, so that the beans are dispersed into a single layer without overlapping.

[0085] A top-view camera mounted vertically above the placement board and a bottom-view camera of the same model, mounted symmetrically below, were then used to capture both top and bottom views simultaneously, using a uniform focal length, f, and baseline distance, B. Before capturing, a ring-shaped LED light source was activated beneath the transparent placement board to avoid shadows.

[0086] It should be noted that the ring-shaped LED light strip is arranged around the geometric center of the transparent placement plate, and the inner diameter of the ring area is not less than the boundary of the effective load-bearing area of ​​the transparent placement plate, ensuring that the light-emitting area of ​​the light strip completely covers the entire area of ​​the transparent placement plate used to carry coffee beans. The light strip adopts a side-emitting or back-transmitting design, and the light is evenly transmitted to the surface of the coffee beans through the transparent placement plate. Because the light strip is located directly below the placement plate and has a ring-shaped hollow structure, the light strip itself will not appear in the effective field of view in the images captured by the top-view camera and the bottom-view camera. Only the background of the placement plate with uniform light transmission and the outline of the coffee beans are displayed, thereby avoiding obstruction or interference with the top view and bottom view obtained by the image acquisition device, ensuring that the captured image completely covers the coffee bean area on the placement plate and there are no blind spots in the lighting.

[0087] S3, input the top view and bottom view into the multi-branch network model for defect detection and semantic segmentation, and output the classification results and segmentation masks of the primary coffee beans; the classification results include defective coffee beans and normal coffee beans, and the segmentation masks include the top view mask M top and bottom view mask M bot .

[0088] Among them, the multi-branch network model consists of three parts:

[0089] Backbone network: A two-stream convolutional neural network is used to input the top view and bottom view respectively, and extract the common features F of the two views top and F bot , and then after splicing, the fusion feature F is obtained fusion ;

[0090] Defect detection branch: This branch uses the fused features as input and outputs coffee bean bounding boxes and category labels through the YOLO-based object detection network head. Category labels are 0 and 1, with 0 indicating a defective bean and 1 indicating a normal bean.

[0091] Semantic segmentation branch: takes fusion features as input, adopts U-Net network structure, and outputs pixel-level segmentation mask M top and M bot ; The white area in the segmentation mask is the coffee beans, and the black area is the background.

[0092] It should be noted that the multi-branch network model needs to be trained and verified before being applied in this method.

[0093] In some implementations, manual sampling or other auxiliary detection methods can be used to set a certain sampling ratio to verify the classification results output by the multi-branch network model.

[0094] S4, calculate the equivalent area and height of normal coffee beans, and perform graded screening.

[0095] The calculation method of the equivalent area of ​​coffee beans may include:

[0096] Before calculating the equivalent area, the conversion relationship between the physical size of the camera pixels in the spot area is:

[0097] Use the fixed top view camera to capture the image of the transparent placement board and calculate the actual area A of the transparent placement board img and pixel area P img , calculate the ratio of the two to get the physical size conversion coefficient S of the camera pixel: S = A img / P img .

[0098] Then, the total number of pixels in the coffee bean area within the top view mask and the bottom view mask of the normal coffee bean is counted, that is, the number of pixels with a statistical value of 1, to obtain the total number of pixels N1 for the top view and N2 for the bottom view;

[0099] Multiplying the total number of pixels by the physical size conversion factor S gives the area A of the coffee bean in each view. i ; i = 1, 2, represents the image index;

[0100] Calculate the average of the top view coffee bean area and the bottom view coffee bean area to get the equivalent area A.

[0101] like Figure 2 As shown, calculating the height of coffee beans based on a stereo matching algorithm may include:

[0102] Obtain the focal length f and baseline distance B of the top-view camera and the bottom-view camera; wherein the baseline distance represents the horizontal distance between the optical centers of the top-view camera and the bottom-view camera;

[0103] The top view and bottom view are grayed and denoised by Gaussian filtering to obtain the preprocessed top view G top and bottom view G bot ;

[0104] Extract G top and G bot ORB feature points: such as Figure 3 As shown, the top view G after preprocessing top For example, the FAST corner detection algorithm is used to detect G top Perform corner detection and retain corners with response values ​​greater than a preset threshold as top-view key points through non-maximum suppression to obtain a top-view key point set;

[0105] The preset threshold is used to filter out a predetermined proportion of corner points before the response value, and the predetermined proportion is adaptively adjusted according to the resolution of the coffee bean image. For example, the corner points with the top 20% response values ​​can be retained as key points, and then the response value of the last point in the top 20% can be set as the preset threshold.

[0106] Then, the main direction is determined by calculating the gradient histogram in the neighborhood of the preset radius with each top view key point in the top view key point set as the center, and the BRIEF descriptor is generated based on the main direction to obtain the top view ORB feature point set P t ;

[0107] To G bot Repeat the above process to obtain the bottom view ORB feature point set P b .

[0108] Then use the fast approximate nearest neighbor matcher FLANN to match the set P t and set P b Perform matching to obtain the initial matching point pair set M raw ;

[0109] For the initial matching point pair set M raw The random sampling consensus algorithm RANSAC is applied, and the RANSAC algorithm must meet the screening conditions of the epipolar geometry constraint, specifically:

[0110] Use the eight-point method to calculate the initial matching point pair set M raw The basic matrix F of ; where F is solved by the least squares method to find the function Get, and Q t =(u t , v t , 1) T , Q b =(u b , v b , 1) T ;

[0111] For each pair of initial matching points (p1, p2) ∈ M raw ,judge Is the absolute value of greater than the preset threshold? If yes, the initial matching point pair (p1, p2) is marked as a wrong matching point pair and removed; if no, (p1, p2) is marked as satisfying the epipolar geometry constraint and retained as a valid matching point pair, and the valid matching point set M is obtained. valid ; Among them, the matching point pair (p t ,p b ) corresponds to the pixel coordinates p of the same coffee bean feature point in the top view and bottom view t =(u t ,v t )∈P t and p b =(u b ,v b )∈P b ;

[0112] Calculate matching point pairs (p t ,p b ) horizontal disparity d=|v t -v b |, get the disparity of the matching points of a single coffee bean, and calculate the average disparity of all matching points to get the average disparity d avg ;

[0113] According to the formula h=B·f / d avg Calculate the height H of normal coffee beans.

[0114] Finally, the coffee beans are screened according to the equivalent area and height of the coffee beans and the preset grading and screening rules, including:

[0115] Set the equivalent area thresholds of different levels: A1<A2<A3;

[0116] Set different levels of height thresholds: H1<H2<H3;

[0117] Normal coffee beans that meet A≥A3 and H≥H3 are marked as first-grade beans; where A represents the equivalent area and H represents the height of the coffee beans;

[0118] Normal coffee beans that satisfy A2≤A<A3 and H2≤H<H3 are marked as secondary beans;

[0119] Normal coffee beans that meet A1≤A<A2 and H2≤H<H3 or A2≤A<A3 and H1≤H<H2 are marked as third-grade beans;

[0120] Normal coffee beans that meet A<A1 or H

[0121] Based on the above technical solution, the present invention can effectively solve the core problems of missed detection of internal defects, one-sidedness of two-dimensional visual inspection, and inefficient and subjective manual grading in traditional coffee bean grading, and realize full-process automated and precise grading. Through the airflow sorting machine combined with the critical airflow velocity formula, low-density defective beans such as internal hollowness, insect infestation, and mildew can be efficiently eliminated based on the density threshold, filling the blind spot of hidden defect detection; using dual-view acquisition and multi-branch network models, surface cracks, spots and other defects can be accurately detected, and background interference can be eliminated through semantic segmentation masks to achieve dual filtering of internal and external defects; using stereo matching algorithms to obtain the equivalent area and height of coffee beans, a multi-dimensional evaluation system of plane size + three-dimensional fullness is constructed to solve the problem of single traditional grading indicators, improve the grading efficiency of coffee beans, and reduce manual labor and screening costs.

[0122] During implementation, each step of the method provided in this embodiment can be completed by hardware integrated logic circuits in a processor or by software instructions. The steps of the method disclosed in the embodiments of this application can be directly implemented as execution by a hardware processor, or as a combination of hardware and software modules in a processor.

[0123] ​The processor in this application may include but is not limited to at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU) or an artificial intelligence processor, and other types of computing devices that run software. Each computing device may include one or more cores for executing software instructions to perform operations or processing. The processor may be a separate semiconductor chip, or it may be integrated into a semiconductor chip together with other circuits. For example, it may form an SoC (system on chip) with other circuits (such as a codec circuit, a hardware acceleration circuit or various bus and interface circuits), or it may be integrated into an ASIC as a built-in processor of an ASIC. The ASIC with the integrated processor may be packaged separately or together with other circuits. In addition to the core for executing software instructions to perform operations or processing, the processor may further include necessary hardware accelerators, such as a field programmable gate array (FPGA), a PLD (programmable logic device) or a logic circuit that implements dedicated logic operations.

[0124] The memory in the embodiments of the present application may include at least one of the following types: read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or electrically erasable programmable read-only memory (EEPROM). In some scenarios, the memory may also be a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage medium or other magnetic storage device or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0125] An embodiment of the present application also provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute any of the above methods.

[0126] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above methods.

[0127] Some of the data in the above formula are calculated by removing the dimensions and taking their numerical values. The formula is a formula that is closest to the actual situation obtained by software simulation of a large amount of collected data; the preset parameters and preset thresholds in the formula are set by technical personnel in this field according to actual conditions or obtained through simulation of a large amount of data.

[0128] Working principle of the present invention:

[0129] The present invention first uses an airflow sorter to calculate the target air speed according to the critical airflow velocity formula, and then screens the coffee beans for density. Low-density beans with internal defects such as hollowness, insect damage, and mildew are eliminated based on the density threshold to obtain primary coffee beans, completing the preliminary screening to eliminate hidden internal defects.

[0130] The primary coffee beans are then spread flat on a transparent plate and dispersed into a single layer using a vibrating motor. Top- and bottom-view cameras, assisted by a ring-shaped LED light source, capture dual-view images. These images are fed into a multi-branch network model. The backbone network extracts common visual features from both views. The defect detection branch outputs bounding boxes and category labels to identify surface defects such as cracks and spots. The semantic segmentation branch generates pixel-level masks to separate the coffee beans from the background.

[0131] Then, for the retained normal coffee beans, the equivalent area is calculated by counting the mask pixels of the top and bottom views and combining them with the physical size conversion relationship calibrated by the camera. At the same time, based on the stereo matching algorithm, effective matching point pairs are selected through grayscale conversion, Gaussian filtering, ORB feature point extraction and matching, and the RANSAC algorithm. The average disparity is calculated and the height is obtained according to the formula;

[0132] Finally, grading and screening are carried out according to the preset equivalent area and height thresholds, and normal coffee beans are divided into different grades according to their fullness, achieving a comprehensive evaluation from internal density to external appearance, two-dimensional shape to three-dimensional size, and completing automated and precise grading.

[0133] The above embodiments are only used to illustrate the technical method of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.

Claims

1. A coffee bean grading and screening method, characterized in that: include: The coffee beans are preliminarily screened using an airflow sorter, and coffee beans with a density reaching a preset density threshold are retained to obtain primary coffee beans; Obtaining top and bottom views of primary coffee beans, and inputting these views into a multi-branch network model for defect detection and semantic segmentation, and outputting classification results and segmentation masks for the primary coffee beans; wherein the classification results include defective coffee beans and normal coffee beans, and the segmentation masks include top view masks and bottom view masks; Extract and calculate the equivalent area of ​​the segmentation mask of normal coffee beans, and calculate the height of normal coffee beans based on the stereo matching algorithm; Normal coffee beans are graded and screened according to equivalent area and height to obtain coffee bean grading results.

2. A coffee bean grading and screening method according to claim 1, characterized in that: The method for obtaining the top view and the bottom view of the primary coffee beans comprises: The primary coffee beans are spread flat on a transparent placement plate and dispersed into a single layer by a vibration motor at a preset frequency; A top-view camera and a bottom-view camera deployed directly above and below a transparent placement plate are used to capture dual-perspective images to obtain a top view and a bottom view; wherein a ring-shaped LED light source is arranged below the transparent placement plate.

3. The coffee bean grading and screening method according to claim 1, wherein: The multi-branch network model includes a backbone network, a defect detection branch, and a semantic segmentation branch, wherein: The backbone network adopts a dual-stream branch architecture, takes the top view and bottom view of coffee beans as input images, uses a convolutional neural network to extract the general features of the top view and bottom view of coffee beans, and then obtains fused features through channel splicing; The defect detection branch uses the fused features as input features and outputs a bounding box and a category label of the coffee beans, wherein the category label includes defective coffee beans and normal coffee beans; The semantic segmentation branch uses the fused features as input features and outputs a pixel-level segmentation mask of the coffee beans, where the pixel-level segmentation mask includes a coffee bean area and a background area.

4. The coffee bean grading and screening method according to claim 1, wherein: The calculation method of the equivalent area is: Count the total number of pixels in the top view mask and bottom view mask of normal coffee beans respectively to obtain the total number of top view pixels N1 and the total number of bottom view pixels N2; The coffee bean area A in a single view is calculated using the pre-calibrated camera pixel physical size conversion coefficient S: S = actual area of ​​the transparent placement plate / pixel area of ​​the transparent placement plate image i =N i ×S; where i=1,2, represents the view index; Calculate the average of the area of ​​the coffee bean in the top view and the area of ​​the coffee bean in the bottom view to get the equivalent area A.

5. The coffee bean grading and screening method according to claim 1, wherein: The method of calculating the height of normal coffee beans based on a stereo matching algorithm includes: Obtaining the focal length f and baseline distance B of the top-view camera and the bottom-view camera; wherein the baseline distance is the horizontal distance between the optical centers of the top-view camera and the bottom-view camera, and the focal lengths of the top-view camera and the bottom-view camera are preset to be the same value; Grayscale processing and Gaussian filtering denoising are performed on the top and bottom views of normal coffee beans to obtain preprocessed top and bottom views; The ORB feature points of the top view and bottom view are extracted respectively after preprocessing, and the fast approximate nearest neighbor matcher FLANN is used to match the top view ORB feature point set P t And the bottom view ORB feature point set P b Perform matching to obtain the initial matching point pair set M raw ; For the initial matching point pair set M raw Apply the random sampling consensus algorithm RANSAC to obtain the effective matching point set M valid ; Among them, the matching point pair (p t ,p b )∈M valid The pixel coordinates p corresponding to the same coffee bean feature point in the top view and bottom view t =(u t ,v t ) and p b =(u b ,v b ), and p t ∈P t , p b ∈P b ; Calculate matching point pairs (p t ,p b ) horizontal disparity d=|v t -v b |, get the disparity of the matching points of a single coffee bean, and calculate the average disparity of all matching points to get the average disparity d avg ; According to the formula h=B·f / d avg Calculate the height H of normal coffee beans.

6. A coffee bean grading and screening method according to claim 5, characterized in that: The extraction process of the ORB feature points includes: Performing corner detection on the preprocessed top view image using the FAST corner detection algorithm, and retaining corner points with response values ​​greater than a preset threshold as top view key points through non-maximum suppression to obtain a top view key point set; wherein the preset threshold is used to filter corner points with a predetermined proportion before the response value, and the predetermined proportion is adaptively adjusted according to the resolution of the coffee bean image; The main direction is determined by calculating the gradient histogram in a neighborhood with a preset radius centered on the top view key point, and a BRIEF descriptor is generated based on the main direction to obtain the top view ORB feature point set; Repeat the above process for the preprocessed bottom view to obtain a bottom view ORB feature point set.

7. The coffee bean grading and screening method according to claim 6, characterized in that: The screening conditions of the random sampling consensus algorithm RANSAC are to meet the epipolar geometry constraints, including: Calculate the initial matching point set M using the eight-point method raw The basic matrix F is a matrix used to describe the relationship between the corresponding point sets between the top view and the bottom view, and the function is solved by the least squares method. Get, and Q t =(u t ,v t ,1) T ,Q b =(u b ,v,1) T ; For each pair of initial matching points (p1, p2) ∈ M raw ,judge Is the absolute value of greater than the preset threshold? If yes, the initial matching point pair (p1, p2) is marked as a wrong matching point pair and removed; if no, (p1, p2) is marked as satisfying the epipolar geometry constraint and retained as a valid matching point pair.

8. The coffee bean grading and screening method according to claim 1, wherein: The hierarchical screening rules include: Set the equivalent area thresholds of different levels: A1<A2<A3; Set different levels of height thresholds: H1<H2<H3; Normal coffee beans that meet A≥A3 and H≥H3 are marked as first-grade beans; where A represents the equivalent area and H represents the height of the coffee beans; Normal coffee beans that satisfy A2≤A<A3 and H2≤H<H3 are marked as secondary beans; Normal coffee beans that meet A1≤A<A2 and H2≤H<H3 or A2≤A<A3 and H1≤H<H2 are marked as third-grade beans; Normal coffee beans that meet A<A1 or H<H1 are marked as fourth-grade beans.

9. A coffee bean grading and screening system, applied to a coffee bean grading and screening method according to claims 1-8, characterized in that: include: Airflow sorter: used to calculate the target air speed according to the preset critical airflow speed formula, screen the coffee beans by density, and retain the coffee beans with a density reaching the preset density threshold to obtain primary coffee beans; Image acquisition device: used for acquiring top view and bottom view of primary coffee beans through a top view camera and a bottom view camera; Computer processing equipment: used for running a multi-branch network model to process the top view and the bottom view of the primary coffee beans, screening out normal coffee beans, and calculating the equivalent area and height parameters of the normal coffee beans; The output of the multi-branch network model is a classification result and a segmentation mask of the coffee beans. The classification result includes defective and normal. The segmentation mask includes a top view mask and a bottom view mask. The equivalent area is calculated based on the segmentation mask. The height parameter is calculated based on the top view and the bottom view. Grading and screening device: used to execute grading and screening rules according to the equivalent area and height parameters of normal coffee beans and perform grading and screening.

10. A computer-readable storage medium comprising: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the coffee bean grading and screening method according to claims 1 to 8 are specifically including: The airflow sorting machine is controlled to calculate the target air speed according to the preset critical airflow speed formula, and the coffee beans are density screened. The coffee beans with a density reaching the preset density threshold are retained to obtain primary coffee beans. Controlling the image acquisition device to obtain a top view and a bottom view of the primary coffee beans through a top view camera and a bottom view camera; Running a multi-branch network model to process the top view and the bottom view of the primary coffee beans, obtaining classification results and segmentation masks of the coffee beans, wherein the classification results include defects and normal, and the segmentation masks include a top view mask and a bottom view mask; Calculating the equivalent area of ​​normal coffee beans based on the segmentation mask, and calculating the height parameters of the normal coffee beans based on the top view and the bottom view using a stereo matching algorithm; According to the equivalent area and height parameters of normal coffee beans, the grading and screening rules are implemented to perform grading and screening to obtain the coffee bean grading results; The computer-readable storage medium includes a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, or an optical disk.