CN113808153A - Tomato maturity detection method and device, computer equipment and storage medium - Google Patents
Tomato maturity detection method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN113808153A CN113808153A CN202111108492.2A CN202111108492A CN113808153A CN 113808153 A CN113808153 A CN 113808153A CN 202111108492 A CN202111108492 A CN 202111108492A CN 113808153 A CN113808153 A CN 113808153A
- Authority
- CN
- China
- Prior art keywords
- tomato
- detected
- target image
- pixel
- maturity
- 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.)
- Pending
Links
- 235000007688 Lycopersicon esculentum Nutrition 0.000 title claims abstract description 224
- 238000001514 detection method Methods 0.000 title claims abstract description 74
- 238000003860 storage Methods 0.000 title claims abstract description 15
- 240000003768 Solanum lycopersicum Species 0.000 title claims description 218
- 238000000034 method Methods 0.000 claims abstract description 33
- 230000015654 memory Effects 0.000 claims description 22
- 238000003708 edge detection Methods 0.000 claims description 12
- 238000009432 framing Methods 0.000 claims description 4
- 238000013178 mathematical model Methods 0.000 claims description 3
- 238000007781 pre-processing Methods 0.000 claims description 3
- 238000013473 artificial intelligence Methods 0.000 abstract description 2
- 241000227653 Lycopersicon Species 0.000 abstract 6
- 238000003062 neural network model Methods 0.000 description 14
- 230000008569 process Effects 0.000 description 13
- 230000008859 change Effects 0.000 description 6
- 238000012545 processing Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 238000013528 artificial neural network Methods 0.000 description 4
- 238000012549 training Methods 0.000 description 4
- 238000005286 illumination Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 239000003086 colorant Substances 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000007613 environmental effect Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000002372 labelling Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 239000007787 solid Substances 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 240000005561 Musa balbisiana Species 0.000 description 1
- 241000146226 Physalis ixocarpa Species 0.000 description 1
- 238000012271 agricultural production Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 235000021015 bananas Nutrition 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013135 deep learning Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000009499 grossing Methods 0.000 description 1
- 238000010191 image analysis Methods 0.000 description 1
- 229910052500 inorganic mineral Inorganic materials 0.000 description 1
- 239000002932 luster Substances 0.000 description 1
- 230000035800 maturation Effects 0.000 description 1
- 239000011707 mineral Substances 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000000050 nutritive effect Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004321 preservation Methods 0.000 description 1
- 238000002310 reflectometry Methods 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
- 229940088594 vitamin Drugs 0.000 description 1
- 229930003231 vitamin Natural products 0.000 description 1
- 235000013343 vitamin Nutrition 0.000 description 1
- 239000011782 vitamin Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30181—Earth observation
- G06T2207/30188—Vegetation; Agriculture
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30204—Marker
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Health & Medical Sciences (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
Abstract
The invention relates to the field of artificial intelligence, in particular to a tomato maturity detection method, a device, computer equipment and a storage medium, which comprises the following steps: acquiring a target image containing a tomato to be detected; determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement; and judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirement. Compared with the prior art which solely depends on the color characteristics to judge the maturity, the method can more objectively judge whether the tomatoes to be detected are mature, thereby increasing the accuracy of judging whether the tomatoes to be detected are in the mature stage.
Description
Technical Field
The invention relates to the field of artificial intelligence, in particular to a tomato maturity detection method, a tomato maturity detection device, computer equipment and a storage medium.
Background
The tomato is rich in vitamins and minerals, and has high nutritive value. The quality of tomatoes evaluated at home and abroad generally takes the maturity as a main reference index, and the ripe tomatoes have high reflectivity to natural light, so the maturity of the tomatoes is generally judged according to the color and luster. The maturity of the tomato is related to the picking time of the tomato besides the variety, culture conditions, illumination and the like of the tomato, the maturity of the tomato is an important period for measuring whether the tomato is mature, and the tomato is accurately identified whether the tomato is in the maturity period so as to ensure the taste, quality, preservation period and the like of the tomato.
For a long time, the observation of the tomato maturation period is mainly completed manually, and the whole process has the problems of complexity, low efficiency and the like. Meanwhile, under the influence of human factors, the objectivity and standardization of the maturity of the tomatoes cannot be guaranteed. With the development of neural networks, image processing techniques have played an important role in agricultural production, for example, image processing techniques are used to determine whether tomatoes are in the mature stage.
Because the growth of crops is a continuous gradual change process, the existing tomato maturity detection method independently depends on color characteristics to judge maturity, is influenced by environmental factors such as external illumination and the like and also artificial subjective factors, and if the maturity judgment condition is not appropriate, the detection of the maturity has a large error.
Disclosure of Invention
Therefore, the invention provides a tomato maturity detection method, aiming at solving the technical problem that detection of a maturity period has a large error if a maturity judging condition is not appropriate due to the influence of human subjective factors in the prior art, and comprising the following steps:
acquiring a target image containing a tomato to be detected;
determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement;
and judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirement.
Preferably, the determining the pixel information corresponding to the tomato to be detected in the target image includes:
detecting and determining the edge of the tomato to be detected in the target image to form a region to be detected;
and calculating the total number and the number of pixels of which the chromatic values meet the preset requirements in the region to be detected.
Preferably, the calculating the total number and the number of pixels whose chromatic values meet preset requirements in the region to be detected includes:
converting the image in the region to be detected into an HSV color space;
determining the chromatic value of each pixel and the total number of pixel points in the region to be detected;
and calculating the number of pixel points with the chromatic values meeting the preset requirement based on the color comparison table of the HSV color space.
Preferably, the calculating the total number and the number of pixels whose chromatic values meet preset requirements in the region to be detected includes:
converting the image in the region to be detected into an RGB color space;
determining the chromatic value of each pixel and the total number of pixel points in the region to be detected;
and calculating the number of pixel points with the chromatic values meeting preset requirements based on the color comparison table of the RGB color space.
Preferably, before the edge of the tomato to be detected in the target image is detected and determined, the method further comprises the following steps:
preprocessing the target image to obtain a processed target image;
and detecting the position of the tomato to be detected in the processed target image, and framing the tomato to be detected in the processed target image based on the position to obtain a tomato detection frame.
Preferably, after the tomato to be detected is framed and selected in the processed target image based on the position to obtain a tomato detection frame, the method further includes:
calculating the confidence of the tomato to be detected; wherein the mathematical model of the confidence coefficient is:
C=P*I
in the formula, C represents the confidence coefficient, I represents the intersection ratio of a tomato detection frame and a tomato prediction frame, and when the tomato to be detected exists in the tomato detection frame, P is 1; when the tomato to be detected does not exist in the tomato detection frame, P is 0;
and determining whether to carry out edge detection and determination on the tomatoes to be detected in the tomato detection frame based on the confidence coefficient.
The invention also provides a tomato maturity detection device, comprising:
the acquisition module is used for acquiring a target image containing the tomato to be detected;
the determining module is used for determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement;
and the judging module is used for judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirement.
Preferably, the method further comprises the following steps:
the forming module is used for detecting and determining the edge of the tomato to be detected in the target image to form a region to be detected;
and the calculating module is used for calculating the number of the pixel points of which the total number and the chromatic value meet the preset requirements in the region to be detected.
The present invention also provides a computer apparatus comprising: the tomato maturity detection method comprises a memory and a processor, wherein the memory and the processor are connected in a communication mode, the memory stores computer instructions, and the processor executes the computer instructions so as to execute the tomato maturity detection method.
The present invention also provides a computer-readable storage medium storing computer instructions for causing a computer to perform the tomato maturity detection method described above.
The technical scheme of the invention has the following advantages:
1. the tomato maturity detection method provided by the invention processes a target image containing a tomato to be detected to obtain the number of pixels of which the total pixel number and the chromatic value meet the preset requirements and which correspond to the tomato to be detected, and judges whether the tomato to be detected is in the maturity stage or not based on the number of pixels of which the total pixel number and the chromatic value meet the preset requirements. Compared with the prior art which solely depends on the color characteristics to judge the maturity, the method can more objectively judge whether the tomatoes to be detected are mature, thereby increasing the accuracy of judging whether the tomatoes to be detected are in the mature stage.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a tomato maturity detection method of example 1 of the present invention;
fig. 2 is a scene diagram of one application of the method for detecting tomato maturity in embodiment 1 of the present invention;
FIG. 3 is a schematic diagram of a target image in the tomato maturity detection method of embodiment 1 of the present invention;
FIG. 4 is a flowchart of step S102 in FIG. 1;
FIG. 5 is a flowchart of step S202 in FIG. 4;
FIG. 6 is another flowchart of step S202 in FIG. 4;
fig. 7 is a flowchart before step S201 in fig. 4;
fig. 8 is a block diagram of a tomato maturity detection apparatus in embodiment 2 of the present invention;
FIG. 9 is a block diagram of the structure of the determination module of FIG. 8;
fig. 10 is a schematic configuration diagram of a computer device according to embodiment 3 of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "first", "second", and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Whether tomatoes are mature or not needs to be judged by human eyes and experience for a long time, however, with the rapid development of a neural network, an image processing technology plays an increasingly important role in judging whether agricultural products are mature or not.
One measures the surface color of the agricultural product from the color image of the agricultural product, and tests are carried out on mature bananas and immature tomatoes to determine that the hue represents the color change of the agricultural product from the stage of maturity and the chroma represents the color change of the agricultural product from the stage of maturity to the stage of softness. Further, image analysis is used to detect the maturity of tomatoes, and the tomato image at each maturity stage is transformed into HIS color space to determine the maturity index of tomatoes, which is used to indicate the maturity at each stage. And some have used computer vision and HIS color models to color grade them to find the relationship between the chroma features and the defined maturity in the HIS color model.
The existing tomato maturity detection method has the problems of complex process and large influence of environmental condition factors such as external illumination and the like when the maturity is judged by independently depending on color characteristics, and has low universality in practical application. When the tomato maturity detection is carried out, a label meeting the maturity judging condition needs to be manufactured, the process is greatly influenced by artificial subjective factors, and if the label is unqualified to be manufactured, the detection of the maturity stage has a large error;
example 1
Fig. 1 is a flowchart illustrating that, according to some embodiments of the present invention, a target image including a tomato to be detected is processed to obtain the number of pixels in the target image, where the total number of pixels and the chromatic value of the target image of the tomato to be detected meet preset requirements, and whether the tomato is in a mature period is determined by the number of pixels, where the total number of pixels and the chromatic value meet the preset requirements. Although the processes described below include operations that occur in a particular order, it should be clearly understood that the processes may include more or fewer operations that are performed sequentially or in parallel (e.g., using parallel processors or a multi-threaded environment).
The embodiment provides a tomato maturity detection method, which is used for accurately and quickly judging whether tomatoes are in a mature period. As shown in fig. 1, the method comprises the following steps:
s101, acquiring a target image containing the tomato to be detected.
In the above implementation steps, the target image includes the tomato to be detected. The method provided by the embodiment can be executed by adopting a neural network, and the pre-trained neural network model obtains the target image, so as to process the tomato to be detected in the target image, wherein the neural network model can adopt a YOLOV3 model, a tiny YOLOV4 model and the like, and the pre-trained neural network model can be stored in a host, a mobile terminal device, a server and the like.
Before training, a data set needs to be made for the neural network model, a labeling tool LabelImg is used for labeling the collected image, all tomatoes which can be distinguished in the image are labeled as targets (including green tomatoes and red tomatoes), all labeled data sets are proportionally divided into a training set, a verification set and a test set, the image is compressed into 832, the 832 is input into the neural network model, for example, the training set is input into a YOLOV3 network model to obtain an initial neural network model, then, end-to-end tuning training is carried out on the neural network model, and a final neural network model is determined. The tomato image sequence from the immature stage to the mature stage can be shot, the collected images are compressed according to a fixed size, and the compressed images are input into the final neural network model to obtain a classification result so as to verify the accuracy of the final neural network model.
The target image can be an image shot by a mobile phone, a graph shot by a camera or an image downloaded by the internet. The video may be formed by combining a plurality of frames of images, and the target image may be a video including a plurality of frames of images.
For example, as shown in fig. 2, a pre-trained neural network model is stored in a host 102, and a camera 101 is installed in a tomato garden and used for shooting a target image containing a tomato to be detected. The camera 101 transmits the target image to a pre-trained neural network model in the host 102 through a wireless signal 104, and the neural network model processes the target image. It should be noted that the camera may also be transmitted to the host 102 by way of wired transmission.
S102, determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement.
In the above implementation steps, not all the pixel information in the target image is determined, but the pixel information corresponding to the tomato to be detected in the target image is determined. As shown in fig. 3, the target image 201 includes a to-be-detected tomato, the to-be-detected tomato forms a to-be-detected region 203 in the target image, and what needs to be determined is pixel information of the to-be-detected region 203, that is, the number of pixels whose total pixel number and chromatic value of the image in the to-be-detected region 203 meet preset requirements is determined.
The chromaticity value satisfying the preset requirement may be a chromaticity value in a red range, or a chromaticity value in a range other than red. For example, the colors corresponding to the colorimetric values R255, G0, and B0 are in the red range, and the colors corresponding to the colorimetric values R0, G0, and B255 are in the range other than red. It should be noted that, those skilled in the art can reasonably select the chromaticity value belonging to the red color range according to the actual situation, and the chromaticity value is not limited herein.
S103, judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirements.
In the implementation steps, whether the tomato to be detected is in the mature period is judged according to the total pixel number and the pixel number of which the chromatic value meets the preset requirement, namely whether the tomato to be detected is in the mature period is judged according to the proportion of the pixel number of which the chromatic value meets the preset requirement to the total pixel number. When a tomato in the mature stage is detected, information about the mature tomato can be displayed in the display 103 (fig. 2), such as the ratio of the red area of the mature tomato to the total area, an image of the mature tomato, etc.
When the chromatic value meets the preset requirement and is in a red range, if the ratio of the number of the pixels of which the chromatic value meets the preset requirement to the total number of the pixels is more than or equal to the preset ratio, the tomato to be detected is in a mature period; and if the ratio of the number of the pixels with the chromatic values meeting the preset requirement to the total number of the pixels is smaller than the preset ratio, determining that the tomato to be detected is in the immature stage.
When the chromatic value meets the preset requirement and is in a range except red, if the ratio of the number of the pixel points of which the chromatic value meets the preset requirement to the total number of the pixel points is more than or equal to the preset ratio, the tomato to be detected is in an immature period; and if the ratio of the number of the pixels with the chromatic values meeting the preset requirement to the total number of the pixels is smaller than the preset ratio, determining that the tomato to be detected is in the mature period.
The growth of crops is a continuous gradual change process, the mature period can be divided into a color change period and a hard period, and the color change period or the hard period of the tomatoes to be detected can be automatically distinguished by setting different preset proportions. For example, when the chromatic value meets the preset requirement and the chromatic value is in a red range, if the ratio of the number of the pixels of which the chromatic value meets the preset requirement to the total number of the pixels is greater than or equal to a first preset ratio, the tomato to be detected is in a color-changing period; if the ratio of the number of the pixels with the chromatic values meeting the preset requirement to the total number of the pixels is smaller than a first preset ratio, determining that the tomato to be detected is in an immature stage; and if the ratio of the number of the pixels with the chromatic values meeting the preset requirement to the total number of the pixels is more than or equal to a second preset ratio, the tomato to be detected is in the hard stage.
It should be noted that, a person skilled in the art may reasonably select the first preset proportion and the second preset proportion according to actual situations, for example, the first preset proportion and the second preset proportion are determined according to national standards.
In the above embodiment, the target image including the tomato to be detected is processed to obtain the number of pixels whose total pixel number and chromatic value meet the preset requirements, and whether the tomato to be detected is in the mature period is determined based on the number of pixels whose total pixel number and chromatic value meet the preset requirements. Compared with the prior art which solely depends on the color characteristics to judge the maturity, the method can more objectively judge whether the tomatoes to be detected are mature, thereby increasing the accuracy of judging whether the tomatoes to be detected are in the mature stage.
In one or more embodiments, in order to determine the pixel information corresponding to the to-be-detected tomato in the target image, as shown in fig. 4, the method includes the following steps:
s201, detecting and determining the edge of the tomato to be detected in the target image to form a region to be detected.
In the implementation steps, the edge detection algorithm can be used for performing edge detection on the tomatoes to be detected, so as to determine the edges of the tomatoes to be detected in the target image, and thus, the area to be detected is formed. The edge detection algorithm includes, but is not limited to, a Canny detection algorithm, a Laplace detection algorithm, and a Sobel detection algorithm.
For example, as shown in fig. 3, a Canny detection algorithm is used to process a target image 201 to obtain an edge 202 of a tomato to be detected, and an area surrounded by the edge 202 is an area 203 to be detected.
S202, calculating the number of pixels of which the total number and the chromatic value meet preset requirements in the region to be detected.
In the implementation steps, the total number of the pixel points in the region to be detected and the number of the pixel points with chromatic values meeting the preset requirements are calculated, and the pixel points outside the region to be detected are excluded. For example, as shown in fig. 3, it is only necessary to calculate the total number and the number of pixels whose chromatic values meet the preset requirement in the region 203 to be detected.
In one or more embodiments, as shown in fig. 5, calculating the number of pixels whose total number and chrominance values meet preset requirements in the region to be detected includes the following steps:
s301, converting the image in the area to be detected into an HSV color space.
In the implementation step, the image in the region to be detected in the target image is converted into an HSV color space, that is, the image corresponding to the tomato to be detected in the target image is converted into the HSV color space. For example, as shown in fig. 3, the image of the region 203 to be detected is converted into HSV color space.
S302, determining the chromatic value of each pixel in the region to be detected and the total number of the pixel points.
In the implementation steps, the total number of the pixel points in the region to be detected is determined, that is, the total area of the tomato to be detected in the target image is determined. And determining the chrominance value of each pixel point. For example, as shown in fig. 3, the total number of pixels in the region 203 to be detected is determined, and the chromaticity value of each pixel in the region 203 to be detected is determined.
S303, calculating the number of pixel points of which the chromatic values meet preset requirements based on the color comparison table of the HSV color space.
In the implementation step, the pixel points with the chrominance values meeting the preset requirement in the region to be detected are extracted through the color comparison table of the HSV color space, and the number of the pixel points meeting the preset requirement is counted, namely the area of the pixel points meeting the preset requirement in the target image is calculated. For example, red pixel points in the area to be detected are extracted through a color comparison table of an HSV color space, and the number of the red pixel points is counted.
The HSV color space is a color space created according to the intuitive nature of color, also known as a hexagonal pyramid model. The color parameters in the HSV color space are hue (H), saturation (S) and value (V), so the image in the region to be detected is transformed into the HSV color space because the color threshold is not applicable if the light is not good, shadowed, mottled or too bright. In the HSV color space, the lightness (V) channel is most affected by light, while the hue (H) channel is not affected by shadows or excessive brightness, so that the lightness (V) channel is abandoned by the hue (H) channel, and the detection of a color object can make the effect more reliable.
In one or more embodiments, as shown in fig. 6, calculating the number of pixels whose total number and chrominance values meet preset requirements in the region to be detected includes the following steps:
s401, converting the image in the area to be detected into an RGB color space.
In the implementation step, the image in the target image to be detected in the area to be detected is converted into the RGB color space, that is, the image corresponding to the tomato to be detected in the target image is converted into the RGB color space. For example, as shown in fig. 3, the image of the region 203 to be detected is converted into an RGB color space.
S402, determining the chromatic value of each pixel and the total number of pixel points in the area to be detected. The step can refer to the related description of step S302, and is not described herein again.
And S403, calculating the number of pixel points with the chromatic values meeting preset requirements based on the color comparison table of the RGB color space.
In the implementation steps, the pixel points with the chrominance values meeting the preset requirements in the region to be detected are extracted through the color comparison table of the RGB color space, and the number of the pixel points meeting the preset requirements is counted, namely the area of the pixel points meeting the preset requirements in the target image is calculated. For example, red pixel points in the region to be detected are extracted through a color comparison table of an RGB color space, and the number of the red pixel points is counted.
In one or more embodiments, as shown in fig. 7, before detecting and determining the edge of the tomato to be detected in the target image, the method further includes the following steps:
s501, preprocessing the target image to obtain a processed target image.
In the above implementation steps, the edge detection algorithm is usually susceptible to noise interference from the image itself, especially if the edge is not continuous when the partial differential equation is used to obtain the image edge, which may even result in the function level set failing to stop converging. The interference such as noise can be removed by using a geometric active contour model, a Gaussian smoothing filter and the like to obtain a processed target image, and the accuracy of edge detection can be improved by using the processed target image to perform edge detection.
S502, detecting the position of the tomato to be detected in the processed target image, and framing the tomato to be detected in the processed target image based on the position to obtain a tomato detection frame.
In the above implementation steps, in order to increase the detection speed, the position of the tomato to be detected may be detected in the processed target image, the tomato to be detected is selected from the processed image based on the position of the tomato to be detected, and a tomato detection frame is obtained from the processed image.
For example, as shown in fig. 3, the target image 201 is a preprocessed target image, the position of the to-be-detected tomato in the target image 201 is detected, the to-be-detected tomato is framed, and a tomato detection frame 204 is obtained in the target image 201.
And counting the positions of the tomatoes detected in the target image to obtain the position information of each tomato detection frame, and only carrying out edge detection on the image information in the tomato detection frame, thereby reducing the system calculation amount. For example, Canny detection is performed only on the image in each tomato detection frame, and edge information of the tomato to be detected in the tomato detection frame is detected by adjusting parameters.
Because the area of the detected tomatoes needs to be calculated, in order to ensure the accuracy of calculation, the detected tomatoes need to be screened according to confidence, and the tomatoes with serious shielding are removed. In one or more embodiments, after the tomatoes to be detected are framed and selected in the processed target image based on the positions to obtain a tomato detection frame, the method further includes the following steps:
calculating the confidence of the tomato to be detected; wherein the mathematical model of the confidence coefficient is:
C=P*I
in the formula, C represents the confidence coefficient, I represents the intersection ratio of a tomato detection frame and a tomato prediction frame, and when the tomato to be detected exists in the tomato detection frame, P is 1; when the tomato to be detected does not exist in the tomato detection frame, P is 0;
and determining whether to carry out edge detection and determination on the tomatoes to be detected in the tomato detection frame based on the confidence coefficient.
The confidence is an important parameter output by each tomato detection box, and the role definition of the confidence is twofold: the method comprises the steps of firstly, representing the probability of whether a current tomato detection frame has tomatoes, namely, the probability is used for explaining whether the current tomato detection frame is only a background or has tomatoes; and II, when the tomatoes exist in the current tomato detection frame, comparing the tomato detection frame with the tomato prediction frame. It should be noted that the tomato prediction box (Ground-tomato prediction box) is a neural network model expression box that expresses the confidence level of the target object.
And screening the selected objects by using confidence coefficient, wherein when the objects have occlusion, the confidence coefficient is definitely lower because the target object part features are occluded. For example, the confidence is 0.80 when a tomato in the image is occluded; the confidence is greater than 0.90 when the tomato is relatively intact in the image. In order to calculate the proportion of the red area of the tomatoes more accurately, the confidence coefficient of 0.90 can be used as a critical value, when the confidence coefficient is less than 0.90, the tomatoes are considered to be seriously shielded, and the edge detection and the determination are not carried out on the tomatoes to be detected in the tomato detection frame; when the confidence coefficient is greater than or equal to 0.90, the tomatoes are considered to be relatively complete, and edge detection and determination can be performed on the tomatoes to be detected in the tomato detection frame. It should be noted that the confidence threshold can be determined by those skilled in the art according to practical situations, and is not limited herein.
The tomato maturity detection method provided by the embodiment has stronger robustness, and the identification precision is improved.
Example 2
The embodiment provides a tomato maturity detection device for accurately and rapidly judging whether tomatoes are in a mature period. As shown in fig. 8, includes:
the acquiring module 301 is configured to acquire a target image containing a tomato to be detected. For details, please refer to the related description of step S101 in embodiment 1, which is not repeated herein.
A determining module 302, configured to determine pixel information corresponding to the to-be-detected tomato in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement. For details, please refer to the related description of step S102 in embodiment 1, which is not repeated herein.
And the judging module 303 is configured to judge whether the tomato to be detected is in a mature period based on the number of the pixels of which the total number of the pixels and the chromatic value meet preset requirements. For details, please refer to the related description of step S103 in embodiment 1, which is not repeated herein.
In the above embodiment, the determining module 302 processes the target image, which is obtained by the obtaining module 301 and contains the to-be-detected tomato, to obtain the number of pixels, which is corresponding to the to-be-detected tomato, and the number of pixels, of which the chromatic value meets the preset requirement, and the determining module 303 determines whether the to-be-detected tomato is in the mature period based on the number of pixels, which is corresponding to the to-be-detected tomato, and the number of pixels, which is corresponding to the to-be-detected tomato, of which the chromatic value meets the preset requirement. Compared with the prior art that the maturity is judged by solely depending on the color characteristics, the scheme can objectively judge whether the tomatoes to be detected are mature, so that the accuracy of judging whether the tomatoes to be detected are in the mature period is improved.
In one or more embodiments, as shown in fig. 9, further comprising:
a forming module 3021, configured to detect and determine an edge of the tomato to be detected in the target image, and form a region to be detected. For details, please refer to the related description of step S201 in embodiment 1, which is not repeated herein.
The calculating module 3022 is configured to calculate the number of pixels, where the total number and the chromatic value of the pixels in the region to be detected meet preset requirements. For details, please refer to the related description of step S202 in embodiment 1, which is not repeated herein.
Example 3
The present embodiment provides a computer device, as shown in fig. 10, the computer device includes a processor 401 and a memory 402, where the processor 401 and the memory 402 may be connected by a bus or by other means, and fig. 10 takes the connection by the bus as an example.
The memory 402, which is a non-transitory computer-readable storage medium, may be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules corresponding to the tomato maturity detection method in the embodiment of the present invention (e.g., the acquiring module 301, the determining module 302, and the determining module 303, and/or the forming module 3021 and the calculating module 3022 shown in fig. 8). The processor 401 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 402, so as to implement the tomato maturity detection method in the above method embodiment 1.
The memory 402 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor 401, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 402 may optionally include memory located remotely from processor 401, which may be connected to processor 401 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 402 and when executed by the processor 401 perform the tomato maturity detection method as in the embodiment shown in fig. 1.
In this embodiment, the memory 402 stores a program instruction or a module of the tomato maturity detection method, and when the processor 401 executes the program instruction or the module stored in the memory 402, the processor 401 processes a target image containing a tomato to be detected to obtain the number of pixels whose total pixel number and chromatic value correspond to the tomato to be detected meet the preset requirements, and determines whether the tomato to be detected is in the maturity stage based on the number of pixels whose total pixel number and chromatic value meet the preset requirements. Compared with the prior art which solely depends on the color characteristics to judge the maturity, the method can more objectively judge whether the tomatoes to be detected are mature, thereby increasing the accuracy of judging whether the tomatoes to be detected are in the mature stage.
The embodiment of the invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions can execute the tomato maturity detection method in any method embodiment. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.
Claims (10)
1. A tomato maturity detection method is characterized by comprising the following steps:
acquiring a target image containing a tomato to be detected;
determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement;
and judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirement.
2. The method for detecting tomato maturity as claimed in claim 1, wherein said determining pixel information corresponding to the tomato to be detected in the target image comprises:
detecting and determining the edge of the tomato to be detected in the target image to form a region to be detected;
and calculating the total number and the number of pixels of which the chromatic values meet the preset requirements in the region to be detected.
3. The tomato maturity detection method of claim 2, wherein the calculating the total number and the number of pixels whose chromatic values meet preset requirements in the area to be detected comprises:
converting the image in the region to be detected into an HSV color space;
determining the chromatic value of each pixel and the total number of pixel points in the region to be detected;
and calculating the number of pixel points with the chromatic values meeting the preset requirement based on the color comparison table of the HSV color space.
4. The tomato maturity detection method of claim 2, wherein the calculating the total number and the number of pixels whose chromatic values meet preset requirements in the area to be detected comprises:
converting the image in the region to be detected into an RGB color space;
determining the chromatic value of each pixel and the total number of pixel points in the region to be detected;
and calculating the number of pixel points with the chromatic values meeting preset requirements based on the color comparison table of the RGB color space.
5. The tomato maturity detection method of any one of claims 2-4, further comprising, before detecting and determining the edge of the tomato to be detected in the target image:
preprocessing the target image to obtain a processed target image;
and detecting the position of the tomato to be detected in the processed target image, and framing the tomato to be detected in the processed target image based on the position to obtain a tomato detection frame.
6. The tomato maturity detection method of claim 5, wherein after framing said tomato to be detected in said processed target image based on said location, obtaining a tomato detection frame, further comprising:
calculating the confidence of the tomato to be detected; wherein the mathematical model of the confidence coefficient is:
C=P*I
in the formula, C represents the confidence coefficient, I represents the intersection ratio of a tomato detection frame and a tomato prediction frame, and when the tomato to be detected exists in the tomato detection frame, P is 1; when the tomato to be detected does not exist in the tomato detection frame, P is 0;
and determining whether to carry out edge detection and determination on the tomatoes to be detected in the tomato detection frame based on the confidence coefficient.
7. A tomato maturity detection device, comprising:
the acquisition module is used for acquiring a target image containing the tomato to be detected;
the determining module is used for determining pixel information corresponding to the tomatoes to be detected in the target image; the pixel information comprises the total pixel number and the pixel number of which the chromatic value meets the preset requirement;
and the judging module is used for judging whether the tomato to be detected is in the mature period or not based on the number of the pixels of which the total pixel number and the chromatic value meet the preset requirement.
8. The tomato maturity detection apparatus of claim 7 further comprising:
the forming module is used for detecting and determining the edge of the tomato to be detected in the target image to form a region to be detected;
and the calculating module is used for calculating the number of the pixel points of which the total number and the chromatic value meet the preset requirements in the region to be detected.
9. A computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the tomato maturity detection method of any one of claims 1-6.
10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the method of detecting tomato maturity as claimed in any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111108492.2A CN113808153A (en) | 2021-09-22 | 2021-09-22 | Tomato maturity detection method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111108492.2A CN113808153A (en) | 2021-09-22 | 2021-09-22 | Tomato maturity detection method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113808153A true CN113808153A (en) | 2021-12-17 |
Family
ID=78939985
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111108492.2A Pending CN113808153A (en) | 2021-09-22 | 2021-09-22 | Tomato maturity detection method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113808153A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114304699A (en) * | 2021-12-27 | 2022-04-12 | 上海创和亿电子科技发展有限公司 | Method for extracting green and yellow ratio of primary flue-cured tobacco leaves |
CN117292248A (en) * | 2023-10-30 | 2023-12-26 | 吉林农业大学 | Deep learning-based farmland pesticide spraying system and weed detection method |
CN117766061A (en) * | 2024-01-12 | 2024-03-26 | 广州新民培林医药科技有限公司 | Artificial intelligence-based tomato extract purity detection method and system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109115771A (en) * | 2018-07-03 | 2019-01-01 | 广西壮族自治区气象减灾研究所 | Sugarcane technical maturity automatic observation process |
CN111126316A (en) * | 2019-12-27 | 2020-05-08 | 湖南省农业信息与工程研究所 | Four-leaf grass positioning and identifying method based on image processing |
-
2021
- 2021-09-22 CN CN202111108492.2A patent/CN113808153A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109115771A (en) * | 2018-07-03 | 2019-01-01 | 广西壮族自治区气象减灾研究所 | Sugarcane technical maturity automatic observation process |
CN111126316A (en) * | 2019-12-27 | 2020-05-08 | 湖南省农业信息与工程研究所 | Four-leaf grass positioning and identifying method based on image processing |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114304699A (en) * | 2021-12-27 | 2022-04-12 | 上海创和亿电子科技发展有限公司 | Method for extracting green and yellow ratio of primary flue-cured tobacco leaves |
CN117292248A (en) * | 2023-10-30 | 2023-12-26 | 吉林农业大学 | Deep learning-based farmland pesticide spraying system and weed detection method |
CN117292248B (en) * | 2023-10-30 | 2024-04-26 | 吉林农业大学 | Deep learning-based farmland pesticide spraying system and weed detection method |
CN117766061A (en) * | 2024-01-12 | 2024-03-26 | 广州新民培林医药科技有限公司 | Artificial intelligence-based tomato extract purity detection method and system |
CN117766061B (en) * | 2024-01-12 | 2024-05-14 | 广州新民培林医药科技有限公司 | Artificial intelligence-based tomato extract purity detection method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113808153A (en) | Tomato maturity detection method and device, computer equipment and storage medium | |
CN108686978B (en) | ARM-based fruit category and color sorting method and system | |
CN111091109B (en) | Method, system and equipment for predicting age and gender based on face image | |
CN109740721B (en) | Wheat ear counting method and device | |
US8483480B2 (en) | Method and system for factoring an illumination image | |
US9396411B2 (en) | Method and system for generating intrinsic images using a single reflectance technique | |
CN114066857A (en) | Infrared image quality evaluation method and device, electronic equipment and readable storage medium | |
CN111028222A (en) | Video detection method and device, computer storage medium and related equipment | |
CN114519698A (en) | Equipment oil leakage detection method, device, equipment and storage medium in dark environment | |
CN112634274B (en) | Machine vision-based fattening pork quality evaluation method and system | |
CN113920057A (en) | Method, device and system for identifying color of product indicator light | |
CN113065454A (en) | High-altitude parabolic target identification and comparison method and device | |
US11776114B2 (en) | Information processing method and computer program | |
CN109102486A (en) | Detection method of surface flaw and device based on machine learning | |
CN112184627A (en) | Citrus fresh-keeping quality detection method based on image processing and neural network and application | |
CN112686851B (en) | Image detection method, device and storage medium | |
CN115294440A (en) | Power transmission line identification method and device and electronic equipment | |
CN114494405A (en) | Strawberry shape estimation and automatic grading method and device and computer storage medium | |
CN114700941A (en) | Strawberry picking method based on binocular vision and robot system | |
CN112115824A (en) | Fruit and vegetable detection method and device, electronic equipment and computer readable medium | |
CN104915959A (en) | Aerial image quality evaluation method and system | |
CN113933294B (en) | Concentration detection method and device | |
CN109544505A (en) | Detection method, device and the electronic equipment in coffee florescence | |
KR102284155B1 (en) | Method and system using deep learning of multi-view image | |
CN118348016A (en) | LED panel defect detection method and device and electronic equipment |
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 |