CN112067616B - Real-time detection device and method for grain quality - Google Patents

Real-time detection device and method for grain quality Download PDF

Info

Publication number
CN112067616B
CN112067616B CN202011038631.4A CN202011038631A CN112067616B CN 112067616 B CN112067616 B CN 112067616B CN 202011038631 A CN202011038631 A CN 202011038631A CN 112067616 B CN112067616 B CN 112067616B
Authority
CN
China
Prior art keywords
grain
camera
grains
xgboost
training
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011038631.4A
Other languages
Chinese (zh)
Other versions
CN112067616A (en
Inventor
陈进
张帅
武志平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu University
Original Assignee
Jiangsu University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu University filed Critical Jiangsu University
Priority to CN202011038631.4A priority Critical patent/CN112067616B/en
Publication of CN112067616A publication Critical patent/CN112067616A/en
Application granted granted Critical
Publication of CN112067616B publication Critical patent/CN112067616B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/85Investigating moving fluids or granular solids
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/89Investigating the presence of flaws or contamination in moving material, e.g. running paper or textiles
    • G01N21/8914Investigating the presence of flaws or contamination in moving material, e.g. running paper or textiles characterised by the material examined
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/85Investigating moving fluids or granular solids
    • G01N2021/8592Grain or other flowing solid samples
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8854Grading and classifying of flaws
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8887Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Physics & Mathematics (AREA)
  • Pathology (AREA)
  • Immunology (AREA)
  • General Health & Medical Sciences (AREA)
  • Biochemistry (AREA)
  • Health & Medical Sciences (AREA)
  • Analytical Chemistry (AREA)
  • Chemical & Material Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Textile Engineering (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Artificial Intelligence (AREA)
  • Signal Processing (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)

Abstract

The invention provides a grain quality real-time detection device and method, and belongs to the field of agricultural intelligent equipment. The real-time detection device comprises a flowing grain image capturing device, an embedded processor and an interactive display screen, wherein a grain flow channel bottom plate in the flowing grain image capturing device is fixed with an outlet of a grain conveyor through a fixed iron wire, and the grain flow channel bottom plate is wound with elastic bolts at two sides of a grain collecting bin through an adjustable iron wire, so that the installation of the flowing grain image capturing device is realized; in the real-time detection process, grains in the grain conveyor flow out, part of the grains are intercepted by a lower bottom plate of a grain runner, a CCD industrial camera exposes and captures images in the runner at a fixed period and transmits the images to an embedded processor, and the processor processes the images by utilizing OPENCV and XGBoost algorithms to obtain the real-time quality of the grains. The invention is suitable for real-time detection of grains of different varieties in various application scenes.

Description

Real-time detection device and method for grain quality
Technical Field
The invention belongs to the field of agricultural intelligent equipment, and particularly relates to a grain quality real-time detection device and method.
Background
China is a large agricultural country, and the progress of agricultural mechanization has been greatly advanced, but the degree of agricultural mechanization is still low, mainly because of the fact that there are fewer sensors in the background of agriculture. Agricultural intelligent sensors are increasingly becoming important in the agricultural field, and the demand for intelligent sensors in the agricultural field is also increasing. Quality inspection of harvested grain has been a challenge in the operation of harvesting machinery, and how to obtain suitable grain characteristics for subsequent quality inspection has become a primary challenge.
The visual detection has become a popular detection means in recent years due to the characteristics of no contact, higher accuracy, simple principle and the like, but is less used in the intelligent agricultural detection field. At present, the visual processing method is mature, so that the key problem of grain quality detection can be solved as long as proper grain pictures can be obtained. But the acquisition of cereal picture adopts the picture of standing of shooting in prior art to carry out outward appearance detection to cereal, inefficiency, step are loaded down with trivial details, and gather the sample randomness of cereal not enough, can't satisfy the real-time quick detection demand of cereal quality.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a device and a method for detecting the quality of grains in real time, so as to realize the real-time and rapid detection of the quality of the grains.
The present invention achieves the above technical object by the following means.
The grain quality real-time detection device comprises a flowing grain image capturing device, an embedded processor and an interactive display screen, wherein the flowing grain image capturing device comprises a CCD (charge coupled device) industrial camera, the CCD industrial camera is in signal connection with the embedded processor, and the embedded processor is connected with the interactive display screen;
The CCD industrial camera is fixed inside the camera fixing support, the camera fixing support is fixed above the grain runner top plate horizontal plate, the grain runner top plate horizontal plate at the position of the camera fixing support is provided with a square opening, and a plurality of LED light sources are fixed on the inner side of the grain runner top plate horizontal plate close to the square opening; the vertical plates at two sides of the grain flow channel top plate are fixedly connected with the grain flow channel bottom plate, the length of one end of the grain flow channel bottom plate is larger than that of the grain flow channel top plate horizontal plate, the end is aligned with an outlet of the grain conveyor, a bent grain guide plate is welded at the lower end of the grain flow channel top plate horizontal plate corresponding to the end, the bending direction of the grain guide plate is far away from the outlet of the grain conveyor, and the bending angle of the grain guide plate is 45-65 degrees; the height of the bottom end of the grain guide plate from the grain flow channel bottom plate is 0.5-1.5cm;
a camera lens is fixed below the CCD industrial camera;
The grain runner bottom plate is fixed with an outlet of the grain conveyor through a fixed iron wire, and is also wound with elastic bolts at two sides of the grain collecting bin through an adjustable iron wire;
the mounting angle alpha of the flowing grain image capturing device is between 20 degrees and 90 degrees.
In the above technical scheme, a lens adjusting window is formed on one side surface of the lower half part of the camera fixing support.
In the technical scheme, the length of one end of the grain flow channel bottom plate is 3-8cm longer than that of the grain flow channel top plate horizontal plate.
In the above technical scheme, the grain guide plate is made of stainless steel plates.
The grain quality detection method includes that grains in a grain conveyor flow out, a lower bottom plate of a grain flow channel captures part of the grains, the grains flow on the lower bottom plate of the grain flow channel, flow to the position right below a square opening through a fixed flow form of a guide plate, a CCD industrial camera exposes and captures images in the flow channel in a fixed period and transmits the images to an embedded processor, and the embedded processor processes the images by utilizing OPENCV and XGBoost algorithms to obtain real-time quality of the grains.
Further, the processor processes the image using OPENCV and XGBoost algorithms, specifically:
s1, initializing a CCD industrial camera, and setting an exposure mode and exposure time of the CCD industrial camera when the CCD industrial camera works normally;
s2, exposing and collecting pictures by a CCD industrial camera, transmitting the pictures to an embedded processor, and storing the received pictures to a local place;
s3, after denoising, graying and binarizing the acquired picture, extracting and storing the characteristic data of the connected region;
S4, the extracted characteristic data is imported into a XGBoost classification recognition model which is trained by parameter automatic tuning, and XGBoost recognizes impurities, broken grains and complete grains in each communication area;
s5, counting the number of pixels in each category, and converting the number into a proportion.
Further, the exposure time satisfies v×t+.p, where v is the flow velocity of the grain, t is the exposure time, and p is the camera precision.
Furthermore, the process for acquiring the XGBoost classification recognition model with the trained parameter automatic tuning specifically comprises the following steps:
S1, collecting a sample image, processing the image, and extracting and storing communication areas in all pictures;
S2, sample data preparation: dividing the communication area into a training set and a testing set, and storing R, G, B, the number of pixels, the length-width ratio of the circumscribed rectangle and the curvature of each communication area into CSV data together with the manual judgment result of the communication area;
and S3, training the training set by using XGBoost algorithm, adjusting training parameters by combining parameter automatic tuning algorithm, improving XGBoost algorithm, obtaining XGBoost classification recognition model with parameter automatic tuning training, and testing the testing set by using XGBoost classification recognition model.
Still further, the adjusting training parameters are: setting a training parameter interval to be selected, continuously training parameters, scoring the identification result obtained by each training parameter through a scoring function, and finally obtaining the optimal training parameters.
The beneficial effects of the invention are as follows:
1. According to the invention, image processing and machine learning are combined, OPENCV and XGBoost algorithms are fused, and an automatic parameter adjustment algorithm is introduced in the training process, so that XGBoost algorithm is improved, characteristic information in a picture is extracted into data, the extracted characteristic data is introduced into a XGBoost classification recognition model with the automatic parameter adjustment and training, and classification recognition is performed more accurately; the invention has low data volume requirement, short training time, higher training precision and good flexibility, and is suitable for various grains.
2. The mobile grain image acquisition device designed by the invention can acquire and intercept grain images in the flow at a certain frequency, and transmit the acquired original images and detection results to the processor for image processing, and the acquired original images and detection results are displayed in real time.
3. The invention can be applied to a real-time detection scene of grain quality, such as detection of the operation performance index of the harvester at the outlet of the auger of the grain tank when the harvester is harvesting, detection of grain quality at the grain inlet of the grain storage granary, and the like.
Drawings
FIG. 1 is a side view of a mobile cereal image capturing apparatus of the present invention;
FIG. 2 is a perspective view of a mobile cereal image capturing apparatus of the present invention;
FIG. 3 is a schematic view of the installation of a mobile cereal image capturing apparatus according to the present invention;
FIG. 4 is a flow chart showing the real-time detection of grain quality according to the present invention;
FIG. 5 is a view of grain collected by the mobile grain image capture device of the present invention;
FIG. 6 is a flow chart of image processing in accordance with the present invention;
FIG. 7 is a flowchart of the process of obtaining the XGBoost classification recognition model trained in the automatic parameter tuning of the present invention.
Wherein: 1-CCD industry camera, 2-camera lens, 3-LED light source, 4-fastening bolt, 5-fixed screw, 6-camera fixed bolster, 7-cereal runner roof, 8-cereal runner bottom plate, 9-fixed bolt, 10-camera adjustment window, 11-square opening, 12-cereal guide plate, 13-cereal conveyer, 14-square groove, 15-fixed iron wire, 16-adjustable iron wire, 17-elasticity bolt, 18-cereal collection bin, 19-device installation angle alpha, 20-cereal, 21-lift scraper.
Detailed Description
The invention will be further described with reference to the drawings and the specific embodiments, but the scope of the invention is not limited thereto.
The invention relates to a grain quality real-time detection device, which comprises a flowing grain image capturing device, an embedded processor and an interactive display screen, wherein the flowing grain image capturing device comprises a CCD industrial camera 1, a camera lens 2, an LED light source 3, a fastening bolt 4, a fixing screw 5, a camera fixing bracket 6, a grain runner top plate 7, a grain runner bottom plate 8, a fixing bolt 9, a lens adjusting window 10, a square opening 11 and a grain guide plate 12, as shown in figures 1 and 2; the CCD industrial camera 1 is in signal connection with an embedded processor, and the embedded processor is connected with an interactive display screen.
As shown in fig. 1 and 2, a CCD industrial camera 1 is fixed inside a camera fixing bracket 6 by a fixing screw 5, and a camera lens 2 is fixed below the CCD industrial camera 1; the grain flow channel top plate 7 is formed by fixedly connecting a horizontal plate above and vertical plates at two sides, the camera fixing support 6 is fixed above the horizontal plate of the grain flow channel top plate 7 through the fixing bolt 9, and the fixing position of the camera fixing support 6 is positioned at a square opening 11 formed above the grain flow channel top plate 7; a lens adjusting window 10 is arranged on one side surface of the lower half part of the camera fixing bracket 6, and the lens adjusting window 10 is a square opening and is used for adjusting the focal length and the aperture of the camera lens 2; the inner side of a horizontal plate of the grain runner top plate 7 close to the square opening 11 is fixed with a plurality of LED light sources 3 through nano double sided adhesive tapes, and the LED light sources 3 are always on when the CCD industrial camera 1 works; the vertical plates at two sides of the grain flow channel top plate 7 are fixedly connected with the grain flow channel bottom plate 8 through the fastening bolts 4, one end of the grain flow channel bottom plate 8 is aligned with the vertical plates, the length of the other end of the grain flow channel bottom plate is 3-8cm (5 cm is preferred in the embodiment) longer than that of the horizontal plate of the grain flow channel top plate 7, and when the grain flow channel top plate is used, the longer end of the grain flow channel bottom plate 8 is aligned with the outlet of the grain conveyor 13, so that grain interception is realized; the lower end of the horizontal plate of the grain flow channel top plate 7 corresponding to the longer end of the grain flow channel bottom plate 8 is welded with a grain guide plate 12, the bending angle of the grain guide plate 12 towards the other end of the grain flow channel bottom plate 8 is 45-65 degrees (53 degrees are preferred in the embodiment), and the height from the bottom end of the grain guide plate 12 to the grain flow channel bottom plate 8 is 0.5-1.5cm (1 cm is preferred in the embodiment); in this embodiment, the square openings 11 are 5cm by 5cm, the grain deflector 12 is made of stainless steel plate, and the number of fastening bolts 4 is preferably 4.
As shown in fig. 3, a schematic installation diagram of the mobile grain image capturing device is shown, two sides of the outlet of the grain conveyor 13 are respectively provided with a square groove 14, one end of a fixed iron wire 15 is wound and fixed by the square groove 14, the other end of the fixed iron wire 15 is wound and fixed on a fastening bolt 4 at the longer end of the grain runner bottom plate 8, the other pair of fastening bolts 4 is wound and fixed on one end of an adjustable iron wire 16, the other end of the adjustable iron wire 16 is wound on an elastic bolt 17 at two sides of the grain collecting bin 18, and the angle between the mobile grain image capturing device and the horizontal plane is adjusted by adjusting the length of the adjustable iron wire 16 wound on the elastic bolt 17, so that the best image capturing effect is achieved. The grain flow speed is regulated by the conveying speed of the grain conveyor 13, the speed V 2 of the lifting scraper 21 of the conveyor can be regulated within the range of 10cm/s-60cm/s, the installation angle alpha 19 of the device is 20-90 degrees, and the proper grain conveying speed and the proper installation angle are regulated according to different application scenes, so that the collected pictures are distributed reasonably and are convenient for subsequent treatment; if the grain flow speed is high, the elastic bolt 17 is screwed down, so that the installation angle alpha 19 is reduced, and the excessive grain flow speed is slowed down; if the grain flow rate is slow, the tension bolt 17 is loosened, so that the installation angle alpha 19 becomes large, and the grain flow with slow flow rate is quickened.
As shown in fig. 4, which is a general flow chart of real-time detection of grain quality, firstly, grains 20 in a grain conveyor 13 flow out under the drive of an elevating scraper 21, part of grains are intercepted by a grain runner lower plate 8 and flow on the grain runner lower plate 8, then flow is fixed by a flow guide plate 12, the grains flow to the position right below a square opening 11, a CCD industrial camera 1 exposes and captures images in the runner at a fixed period and transmits the images to an embedded processor, the processor processes the images by utilizing OPENCV and XGBoost algorithms, the acquired original images and the processing results are displayed on an interactive display screen in real time, and then the grains flow out of the runner slide into a grain collection bin 18; as shown in FIG. 5, in the pictures acquired by the mobile grain image capturing device, grains are uniformly distributed in the acquired pictures, and the pictures are less stacked, so that the subsequent processing is greatly convenient.
As shown in fig. 6, the specific process of the processor processing the image using OPENCV and XGBoost algorithms is:
S1, initializing a CCD industrial camera 1, acquiring the state of the CCD industrial camera 1, if the connection of the CCD industrial camera 1 is abnormal, prompting no camera by an interactive display screen, and if the connection is normal, setting the exposure mode of the CCD industrial camera 1 to be soft triggering, namely triggering the CCD industrial camera 1 after receiving a trigger signal from an embedded processor, and then setting the exposure time; since the object photographed by the CCD industrial camera 1 is moving grain, if the set exposure time is inappropriate, the problem of smear and blurring of the image will be caused, so that the appropriate exposure time t needs to be set: namely, in the exposure time of the camera, the distance of the object movement is smaller than the precision of the camera, the camera cannot recognize the distance of the object movement, and smear is not generated, namely, the flow speed v of grains is less than or equal to the exposure time t and less than or equal to the precision p of the camera (v is less than or equal to p); in the invention, the grain movement speed v is not more than 100mm/s, namely 0.1mm/ms, the resolution of a camera is 200 ten thousand pixels (1600 x 1200), the visual field size is 60mm x 60mm, so the precision p=60/1600=0.0375 mm/pixel of the camera; according to t.v.ltoreq.p, t.ltoreq.0.375 ms is obtained, so that smear can be avoided as long as the exposure time of the camera is set within 0.375 ms.
S2, the CCD industrial camera 1 exposes and collects pictures according to the set exposure time, transmits the pictures to the embedded processor, and stores the received pictures locally.
S3, preprocessing the picture, denoising the image by using a function GaussianBlur of OPENCV, graying the image by using a BGR2GRAY function, binarizing the image by using a threshold|BINARY to distinguish the foreground and the background of the image, extracting the connected domain by using a FindContours function, storing the extracted connected domain into a container, and finally traversing all the connected domains, extracting characteristic data of each connected domain and storing the extracted characteristic data into a CSV file.
S4, the extracted characteristic data is imported into a XGBoost classification recognition model which is trained by parameter automatic tuning, and XGBoost recognizes impurities, broken grains and complete grains in each connected region.
And S5, counting the number of pixels of each category by using OPENCV, and converting the number into a proportion for obtaining the real-time quality of grains.
And S6, saving the obtained result in a local text, displaying the result on a display screen, returning to S2, and performing the next exposure.
As shown in fig. 7, the process of acquiring the XGBoost classification recognition model with the trained parameter automatic tuning includes the following steps:
S1, sample image acquisition: 100 pictures are acquired indoors by using a grain image acquisition device, the picture is preprocessed, binarized, background removed and foreground reserved by OPENCV, and then all connected areas in the pictures are extracted and stored.
S2, sample data preparation: the extracted connected areas are processed according to the following steps of 7:3, dividing the ratio into a training set and a testing set; respectively creating a training set and a test set CSV data file, and marking column labels, wherein the column labels are selected as characteristic bases capable of distinguishing different types of grains, and are R, G, B, the number of pixels, the external rectangular length-width ratio, the curvature and the manual judgment result respectively, then extracting R, G, B, the number of pixels, the external rectangular length-width ratio and the curvature of each communication area, and storing the extracted R, G, B, the number of pixels, the external rectangular length-width ratio and the manual judgment result of the communication area into one row of the CSV data file according to corresponding columns; the test set and training set all contained data that were manually judged as impurities, broken and intact grains.
S3, improving XGBoost algorithm through training set and testing set: training the training set by using XGBoost algorithm, adjusting training parameters by combining parameter automatic tuning algorithm, improving training accuracy, improving XGBoost algorithm, and storing improved XGBoost model, namely XGBoost classification recognition model with parameter automatic tuning training; and then testing the testing set by using the XGBoost classification recognition model with the automatically optimized and trained parameters, judging the precision (if the precision does not meet the requirement, training the training set again), and preventing the situation of over fitting.
The main idea of XGBoost algorithm is to perform a second-order taylor expansion on the target loss function loss according to the following formula:
the objective function is chosen logloss, so there are:
Where Obj (t) is the objective function, w (y i,yi t-1+ft(xi)) is the loss function, f t(xi) is the regularization function, ω (f t) is the structural function, C is a constant term, For the first order bias of each sample,Second order bias for each sample;
the training parameters that the XGBoost algorithm needs to adjust are as follows:
(1) n_ estimator: also called num_boosting_ rounds, is the number of maximum trees generated, i.e. the maximum number of iterations.
(2) Learning_rate: also known as eta, the step size of each iteration.
(3) Gamma: when a node splits, only if the value of the loss function after splitting drops, the node is split; gamma specifies the minimum loss function dip required for node splitting; the larger the value of gamma, the more conservative the algorithm; because the larger the gamma value, the more the loss function drops before the node can be split.
(4) Subsamples: the parameter controls the proportion of random sampling for each tree, and the value of subsamples is reduced, so that overfitting can be avoided; but if this value is set too small it may result in a under fit.
(5) Colsample _ bytree: default is 1, typically set to around 0.8, to control the duty cycle of the number of columns per random sample.
(6) Max_depth: the default value is 6, numbers between 3 and 10 are commonly used, and max_depth is the maximum depth of the tree and is used for controlling the overfitting; the greater the max_depth, the more specific the model learning.
(7) Max_delta_step: this parameter limits the maximum step size of the weight change per tree, meaning that there is no constraint if the value of this parameter is 0.
(8) Lambda: also known as reg lambda, default to 0, the L2 regularization term of the weights, which is used to control the regularization portion of XGBoost, is helpful in reducing overfitting.
(9) Alpha: also called reg_alpha, defaults to 0, the L1 regularization term of the weight.
The main ideas of the parameter automatic tuning algorithm are as follows: the initial set is randomly generated according to uniform distribution, then a proposed solution is selected from the current set, various selection methods which can adopt an evolutionary algorithm are selected, then a network probability model is built for the selected set, a new proposed solution is obtained from the sampling of the model, finally, the solution obtained by sampling is added into the original set again, and the process is repeated until the termination condition is met. The main flow of the algorithm is as follows: setting t=0, randomly generating an initial population p (0), and selecting a candidate solution S (t) from p (t); constructing a grid B meeting the requirements under certain selection rules and limiting conditions; generating a new solution O (t) according to the joint distribution function of the network B; substituting O (t) for part of the decomposition in p (t) to form a new population p (t+1); if the termination condition (training accuracy does not rise 50 times in succession) is not satisfied, S (t) is reselected and continued.
Setting a training parameter interval to be selected according to the thought of the parameter automatic tuning algorithm by combining the parameter automatic tuning algorithm with the XGBoost algorithm, continuously training parameters by combining the thought of the parameter automatic tuning algorithm in the process of training the XGBoost algorithm, and scoring the identification result obtained by each training parameter by a scoring function to finally obtain the optimal training parameter; the main flow is as follows: firstly, setting t=0, setting an initial combination P (0) of parameters, and selecting a planned solution S (t) from P (t); according to the formula:
Wherein X t is the next sampling position, mu t-1 (X) is the mean value on the position input position, sigma t-1 (X) is the standard deviation, Is a weight parameter. For the next sampling position X t, taking the condition of function maximization into consideration, constructing a regression model of a Gaussian process, predicting the average value and standard deviation on the input position, and selecting the input position with the maximum sum of the average value and the standard deviation as the point of the next sampling; then generating a new solution O (t) according to the joint distribution function of the network B, and replacing P (t) with O (t) to form a new combination P (t+1); and if the termination condition is not met, re-selecting S (t) and continuing.
The examples are preferred embodiments of the present invention, but the present invention is not limited to the above-described embodiments, and any obvious modifications, substitutions or variations that can be made by one skilled in the art without departing from the spirit of the present invention are within the scope of the present invention.

Claims (4)

1. The grain quality real-time detection method is characterized by being realized based on a grain quality real-time detection device, wherein the grain quality real-time detection device comprises a flowing grain image capturing device, an embedded processor and an interactive display screen, the flowing grain image capturing device comprises a CCD industrial camera (1), the CCD industrial camera (1) is in signal connection with the embedded processor, and the embedded processor is connected with the interactive display screen; the CCD industrial camera (1) is fixed inside the camera fixing support (6), the camera fixing support (6) is fixed above a horizontal plate of the grain runner top plate (7), the horizontal plate of the grain runner top plate (7) at the position of the camera fixing support (6) is provided with a square opening (11), and a plurality of LED light sources (3) are fixed on the inner side of the horizontal plate of the grain runner top plate (7) close to the square opening (11); the vertical plates at two sides of the grain flow channel top plate (7) are fixedly connected with the grain flow channel bottom plate (8), the length of one end of the grain flow channel bottom plate (8) is larger than that of the horizontal plate of the grain flow channel top plate (7), the end is aligned with the outlet of the grain conveyor (13), the bent grain guide plates (12) are welded at the lower ends of the horizontal plates of the grain flow channel top plate (7) corresponding to the end, the bending direction of the grain guide plates (12) is far away from the outlet of the grain conveyor (13), and the bending angle of the grain guide plates (12) is 45-65 degrees; the height of the bottom end of the grain guide plate (12) from the grain flow channel bottom plate (8) is 0.5-1.5cm; a camera lens (2) is fixed below the CCD industrial camera (1); the grain flow passage bottom plate (8) is fixed with an outlet of the grain conveyor (13) through a fixed iron wire (15), and the grain flow passage bottom plate (8) is also wound with elastic bolts (17) on two sides of the grain collecting bin (18) through adjustable iron wires (16); the installation angle alpha of the flowing grain image capturing device is 20-90 degrees;
The grain quality real-time detection method comprises the following steps: the grain (20) in the grain conveyor (13) flows out, a grain flow channel bottom plate (8) intercepts part of grain, the grain flows on the grain flow channel bottom plate (8), the grain flows to the position right below the square opening (11) through a fixed flow form of the guide plate (12), the CCD industrial camera (1) exposes and captures images in the flow channel at a fixed period and transmits the images to the embedded processor, and the embedded processor processes the images by utilizing OPENCV and XGBoost algorithms to obtain the real-time quality of the grain;
the processor processes the image by using OPENCV and XGBoost algorithms, specifically:
S1, initializing a CCD industrial camera (1), acquiring the state of the CCD industrial camera (1), if the connection of the CCD industrial camera (1) is abnormal, prompting no camera by an interactive display screen, and if the connection is normal, setting the exposure mode of the CCD industrial camera (1) to be soft triggering, namely triggering the CCD industrial camera (1) when receiving a triggering signal from an embedded processor, and then setting the exposure time; in the exposure time of the CCD industrial camera (1), the moving distance of the object is smaller than the precision of the camera, so that the camera cannot recognize the moving distance of the object and no smear is generated, namely the flow speed v of grains is less than or equal to the precision p of the camera; setting the exposure time of the camera to be within 0.375ms according to t.v.ltoreq.p, v.ltoreq.0.1 mm/ms, p=0.0375 mm/pixel;
S2, the CCD industrial camera (1) is used for exposing and collecting pictures according to the set exposure time, transmitting the pictures to the embedded processor and storing the received pictures to the local;
s3, preprocessing the acquired picture, denoising the image by using a function GaussianBlur of OPENCV, graying the image by using a BGR2GRAY function, binarizing the image by using a threshold|BINARY to distinguish the foreground and the background of the image, extracting connected domains by using a FindContours function, storing the connected domains into a container, traversing all the connected domains, extracting characteristic data of each connected domain, and storing the extracted characteristic data into a CSV file;
S4, the extracted characteristic data is imported into a XGBoost classification recognition model which is trained by parameter automatic tuning, and XGBoost recognizes impurities, broken grains and complete grains in each communication area;
s5, counting the number of pixels of each category by OPENCV, and converting the number into a proportion for obtaining the real-time quality of grains;
the process for acquiring the XGBoost classification recognition model trained by the automatic parameter tuning specifically comprises the following steps:
s1, collecting a sample image, preprocessing the image by OPENCV, binarizing, removing the background and reserving the foreground, extracting the connected areas in all pictures and storing the connected areas;
S2, sample data preparation: dividing the communication areas into training sets and test sets, respectively newly establishing CSV data files of the training sets and the test sets, and marking column labels, wherein the column labels are selected as characteristic bases which can distinguish different types of grains and are R, G, B, the number of pixels, the external rectangular length-width ratio, the curvature and the manual judgment result, extracting R, G, B, the number of pixels, the external rectangular length-width ratio and the curvature of each communication area, and storing the extracted R, G, B, the number of pixels, the external rectangular length-width ratio and the curvature and the manual judgment result of each communication area into one row of the CSV data file according to corresponding columns; the test set and the training set both contain data of manually judged impurities, broken grains and complete grains;
S3, training a training set by using XGBoost algorithm, adjusting training parameters by combining parameter automatic tuning algorithm, improving XGBoost algorithm to obtain XGBoost classification recognition model with parameter automatic tuning training, testing a testing set by using XGBoost classification recognition model, judging accuracy and preventing the situation of over fitting;
The XGBoost algorithm is a second order taylor expansion of the target loss function loss according to the following equation:
the objective function is chosen logloss, so there are:
where Obj (t) is the objective function, w (y i,yi t-1+ft(xi)) is the loss function, f t(xi) is the regularization function, ω (f t) is the structural function, C is a constant term, For the first order partial derivatives of each sample,/>Second order bias for each sample;
the training parameters that the XGBoost algorithm needs to adjust are as follows:
(1) n_ estimator: also called num_boosting_ rounds, is the number of maximum trees generated, i.e. the maximum number of iterations;
(2) learning_rate: also known as eta, the step size of each iteration;
(3) gamma: when a node splits, only if the value of the loss function after splitting drops, the node is split; gamma specifies the minimum loss function dip required for node splitting;
(4) subsamples: the parameter controls the ratio of random sampling for each tree;
(5) colsample _ bytree: default value is 1, and is set to about 0.8, so as to control the duty ratio of the number of columns of each random sampling;
(6) max_depth: the default value is 6, numbers between 3 and 10 are commonly used, and max_depth is the maximum depth of the tree and is used for controlling the overfitting;
(7) max_delta_step: this parameter limits the maximum step size of each tree weight change, meaning that there is no constraint if the value of this parameter is 0;
(8) lambda: also called reg_lambda, default value of 0, L2 regularization term of weight, which is used to control the regularization part of XGBoost, is helpful in reducing overfitting;
(9) alpha: also called reg_alpha, defaults to 0, L1 regularization term of the weight; the idea of the parameter automatic tuning algorithm is as follows: the initial set is randomly generated according to uniform distribution, then a proposed solution is selected from the current set, various selection methods capable of adopting an evolutionary algorithm are selected, then a network probability model is built for the selected set, a new proposed solution is obtained from the sampling of the model, finally, the solution obtained by sampling is added into the original set again, and the process is repeated until the termination condition is met;
Setting a training parameter interval to be selected according to the thought of the parameter automatic tuning algorithm by combining the parameter automatic tuning algorithm with the XGBoost algorithm, continuously training parameters by combining the thought of the parameter automatic tuning algorithm in the process of training the XGBoost algorithm, and scoring the identification result obtained by each training parameter by a scoring function to finally obtain the optimal training parameter; the main flow is as follows: firstly, setting t=0, setting an initial combination P (0) of parameters, and selecting a planned solution S (t) from P (t); according to the formula:
Wherein X t is the next sampling position, mu t-1 (X) is the mean value on the position input position, sigma t-1 (X) is the standard deviation, Is a weight parameter; for the next sampling position X t, taking the condition of function maximization into consideration, constructing a regression model of a Gaussian process, predicting the average value and standard deviation on the input position, and selecting the input position with the maximum sum of the average value and the standard deviation as the point of the next sampling; then generating a new solution O (t) according to the joint distribution function of the network B, and replacing P (t) with O (t) to form a new combination P (t+1); and if the termination condition is not met, re-selecting S (t) and continuing.
2. The method according to claim 1, wherein a lens adjusting window (10) is provided on a side of the lower half of the camera fixing frame (6).
3. The method for detecting the quality of grains in real time according to claim 1, wherein the length of one end of the grain flow channel bottom plate (8) is 3-8cm larger than the length of the horizontal plate of the grain flow channel top plate (7).
4. The method for detecting the quality of grains in real time according to claim 1, wherein the grain deflector (12) is made of stainless steel plate.
CN202011038631.4A 2020-09-28 2020-09-28 Real-time detection device and method for grain quality Active CN112067616B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011038631.4A CN112067616B (en) 2020-09-28 2020-09-28 Real-time detection device and method for grain quality

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011038631.4A CN112067616B (en) 2020-09-28 2020-09-28 Real-time detection device and method for grain quality

Publications (2)

Publication Number Publication Date
CN112067616A CN112067616A (en) 2020-12-11
CN112067616B true CN112067616B (en) 2024-06-11

Family

ID=73682973

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011038631.4A Active CN112067616B (en) 2020-09-28 2020-09-28 Real-time detection device and method for grain quality

Country Status (1)

Country Link
CN (1) CN112067616B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022137817A1 (en) * 2020-12-23 2022-06-30 株式会社サタケ Grain discerning device
CN113310986A (en) * 2021-07-13 2021-08-27 安徽中青检验检测有限公司 Quality detection device for grains
CN113780900B (en) * 2021-11-09 2022-04-12 深圳市裕展精密科技有限公司 Welding detection system and method based on edge calculation
CN114310955B (en) * 2021-12-31 2024-04-16 南京威迪特电子科技有限公司 Weed seed sampling robot for cereal grains

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103149131A (en) * 2013-01-31 2013-06-12 长安大学 Real-time data acquisition method and acquisition system of production field aggregation three-dimension test
CN104867023A (en) * 2015-06-04 2015-08-26 南京农业大学 Precise information acquisition and tracing system and tracing method based on DM (Data Matrix) two-dimension code grain tracing particles
CN105806401A (en) * 2016-03-03 2016-07-27 中国农业大学 Three-dimensional image detection system used for indoor quick seed test of maize ears
CN105806751A (en) * 2016-03-24 2016-07-27 江苏大学 On-line monitoring system and method for crushing of cereals in grain tank of combine harvester
CN107123115A (en) * 2017-04-25 2017-09-01 南京大学 A kind of grain harvest cleaning loss real-time on-line detecting method based on image procossing
CN107860431A (en) * 2017-11-08 2018-03-30 南京农业大学 A kind of measuring method for auger conveyor mass flow
CN111239133A (en) * 2020-02-15 2020-06-05 江苏大学 Rice processing quality online detection and control device and control method
CN212255107U (en) * 2020-09-28 2020-12-29 江苏大学 Real-time detection device for grain quality

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103149131A (en) * 2013-01-31 2013-06-12 长安大学 Real-time data acquisition method and acquisition system of production field aggregation three-dimension test
CN104867023A (en) * 2015-06-04 2015-08-26 南京农业大学 Precise information acquisition and tracing system and tracing method based on DM (Data Matrix) two-dimension code grain tracing particles
CN105806401A (en) * 2016-03-03 2016-07-27 中国农业大学 Three-dimensional image detection system used for indoor quick seed test of maize ears
CN105806751A (en) * 2016-03-24 2016-07-27 江苏大学 On-line monitoring system and method for crushing of cereals in grain tank of combine harvester
CN107123115A (en) * 2017-04-25 2017-09-01 南京大学 A kind of grain harvest cleaning loss real-time on-line detecting method based on image procossing
CN107860431A (en) * 2017-11-08 2018-03-30 南京农业大学 A kind of measuring method for auger conveyor mass flow
CN111239133A (en) * 2020-02-15 2020-06-05 江苏大学 Rice processing quality online detection and control device and control method
CN212255107U (en) * 2020-09-28 2020-12-29 江苏大学 Real-time detection device for grain quality

Also Published As

Publication number Publication date
CN112067616A (en) 2020-12-11

Similar Documents

Publication Publication Date Title
CN112067616B (en) Real-time detection device and method for grain quality
CN108875821A (en) The training method and device of disaggregated model, mobile terminal, readable storage medium storing program for executing
CN111652326B (en) Fruit maturity identification method and system based on MobileNet v2 network improvement
CN110427922A (en) One kind is based on machine vision and convolutional neural networks pest and disease damage identifying system and method
CN110570454B (en) Method and device for detecting foreign matter invasion
CN109447945B (en) Quick counting method for basic wheat seedlings based on machine vision and graphic processing
CN111178197A (en) Mass R-CNN and Soft-NMS fusion based group-fed adherent pig example segmentation method
CN103808723A (en) Exhaust gas blackness automatic detection device for diesel vehicles
CN109242826B (en) Mobile equipment end stick-shaped object root counting method and system based on target detection
CN104200457A (en) Wide-angle camera shooting based discrete type canopy leaf area index detection system and method
KR102002632B1 (en) Fruit monitoring system and method at the same
CN114882468B (en) Self-adaptive adjustment method for angle of sweeping brush of sweeper
CN109726665B (en) Agricultural pest detection method based on dynamic trajectory analysis
CN111462058A (en) Method for quickly detecting effective ears of rice
CN107464232B (en) Image detection method for planting quality of unmanned rice transplanter
CN112733958A (en) Greenhouse ozone concentration control method and system
CN114943923B (en) Method and system for recognizing explosion flare smoke of cannonball based on video of deep learning
CN110555371A (en) Wild animal information acquisition method and device based on unmanned aerial vehicle
CN113222959A (en) Fresh jujube wormhole detection method based on hyperspectral image convolutional neural network
CN212255107U (en) Real-time detection device for grain quality
CN110689022B (en) Method for extracting images of crops of each plant based on blade matching
CN111222360B (en) Method, equipment and storage medium for detecting molten state of silicon material
CN111476119A (en) Insect behavior identification method and device based on space-time context
RU2616152C1 (en) Method of spatial position control of the participants of the sports event on the game field
CN110428374A (en) A kind of small size pest automatic testing method and system

Legal Events

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