Method, system and electronic equipment for automatic seed identification
By detecting and annotating images to be detected using detection classifiers for N preset seed types, the problem of excessive background and lighting conditions in existing technology is solved, and the speed and flexibility of automatic seed identification are achieved.
Patent Information
- Application Number
- CN202011608846.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-12-30
AI Technical Summary
The existing automatic seed recognition technology has too high requirements for background and lighting conditions, which limits its promotion and popularity.
A seed automatic identification method is used to detect and label it by obtaining the image waiting to be detected and entering the Nables of N -type preset seed types to achieve automatic identification of the seeds. This method does not require the background and light conditions of the image to be detected.
The rapid recognition of the seeds that meet the preset seed types in the detection image, reduce the requirements for background and light conditions, and improve the promotion and popularity of technology.
Smart Images

Figure CN112668488B_ABST
Abstract
Description
Background Art
[0002] In the agricultural field, it is usually necessary to classify different types of seeds, so as to further guide sorting or other applications. The existing classification technology mainly adopts image analysis, that is, by comprehensively analyzing the color, shape and other characteristics of the seeds, different varieties of seeds are classified. In addition, in breeding work, it is usually necessary to obtain the thousand-grain weight parameters of the seeds. At present, there are also special thousand-grain weight meters of this type. First, the seed area is determined according to the target color, and then the single seed is divided for counting by analyzing the length, width, aspect ratio, area, equivalent diameter, circumference and other information of the seeds.
[0003] Both the classification and counting methods are very sensitive to background noise. When acquiring the image to be detected, specific color or lighting conditions are usually required. For example, the existing thousand-grain weight meter requires the seeds to be placed on a customized backlight source board.
[0004] Since the existing technology for automatic seed recognition and classification has very high requirements for background, lighting and other conditions, it has caused great limitations in the promotion and popularization of the existing technology for automatic seed recognition and classification. Summary of the invention
[0005] In order to overcome the problem that the existing automatic seed recognition technology has too high requirements on background, lighting and other conditions, thereby limiting its promotion and popularization, the present invention provides a method, system and electronic equipment for automatic seed recognition.
[0006] In a first aspect, in order to solve the above technical problem, the present invention provides a method for automatic seed identification, comprising the following steps:
[0007] Obtain an image to be detected containing seeds;
[0008] The image to be detected is input into a detection classifier for N preset seed types; when the detection classifier for N preset seed types detects seeds of the N preset seed types in the image to be detected, the detected seeds are marked by using the detection classifier for N preset seed types to obtain a detection result, where N is a positive integer. The detection result includes a result image and the number of seeds that meet each preset seed type contained in the result image.
[0009] The beneficial effect of the automatic seed identification method provided by the present invention is that by using a detection classifier for N preset seed types to detect all seeds in the image to be detected, the seeds that meet the preset seed types in the image to be detected can be easily and quickly identified. At the same time, the detection classifier for the N preset seed types has no strict requirements on the background, lighting, etc. of the image to be detected, thereby facilitating promotion and popularization.
[0010] On the basis of the above technical solution, the automatic seed identification method of the present invention can also be improved as follows.
[0011] Furthermore, the automatic seed identification method further comprises:
[0012] Collecting seed images under different backgrounds to obtain multiple first seed images containing seeds;
[0013] Using LabelImg image annotation software, adding seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels;
[0014] According to the plurality of second seed images containing seed type labels and the TensorFlow training model, a detection classifier for N preset seed types is trained, wherein N≤K, and K is a positive integer.
[0015] The beneficial effects of adopting the above further scheme are: by collecting seed images under different backgrounds, the detection classifier trained subsequently can have higher universality and be able to detect images under various background conditions; by using LabelImg image annotation software to add seed type labels, multiple second seed images for K preset target seed types can be obtained, thereby facilitating subsequent training to detect detection classifiers for N preset seed types; through multiple second seed images containing seed type labels and TensorFlow training models, corresponding detection classifiers can be trained according to human needs, making the detection classifier more targeted and customizable.
[0016] Further, the detected seeds are labeled using the detection classifier for the N preset seed types, including:
[0017] Acquire high-level features of the image to be detected, and segment each seed in the image to be detected separately according to the high-level features to obtain M single seed images, where M is a positive integer;
[0018] Using the detection classifier for the N preset seed types, each single seed image in the M single seed images is matched with each preset seed type in the N preset seed types to obtain M×N first matching degrees;
[0019] When it is determined that only one first matching degree among the first matching degrees corresponding to any single seed image is greater than the preset matching degree of the preset seed type, the single seed image is marked as the matched preset seed type;
[0020] When it is determined that at least two of the first matching degrees corresponding to any single seed image are greater than the preset matching degree of the preset seed type, the single seed image is detected using a preset strategy;
[0021] This continues until all the single seed images have been determined.
[0022] The preset strategy includes using existing classification technology such as image analysis to detect the single seed image;
[0023] Alternatively, at least two contradictory preset seed types are obtained based on the at least two first matching degrees of the single seed image that are greater than the preset matching degrees of the preset seed types, and a detection classifier for the at least two contradictory preset seed types is trained,
[0024] Using the detection classifier for the at least two contradictory preset seed types, the single seed image is matched with each of the at least two contradictory preset seed types to obtain at least two second matching degrees,
[0025] When it is determined that only one of the second matching degrees corresponding to the single seed image is greater than the preset matching degree of the contradictory preset seed type, the single seed image is marked as the matched contradictory preset seed type; when it is determined that at least two of the second matching degrees corresponding to the single seed image are greater than the preset matching degree of the contradictory preset seed type, the single seed image can be detected again using the preset strategy; until the determination of all the single seed images is completed.
[0026] The beneficial effect of adopting the above further scheme is: the high-level features of the image to be detected are a combination of the color, texture and other features of the image to be detected. Therefore, the outline of each seed in the image to be detected can be identified through the high-level features, thereby obtaining M single-grain seed images; each single-grain seed image in the M single-grain seed images is matched with each of the N preset seed types by a detection classifier for N preset seed types, so that it can be identified whether each single-grain seed image conforms to one of the N preset seed types, thereby facilitating the subsequent annotation of the image to be detected; in addition, the accuracy of automatic seed recognition can be effectively improved by re-detecting the single-grain seed image through a preset strategy.
[0027] Further, the step of obtaining the image to be detected containing the seed includes:
[0028] When a video containing seeds is collected, the video containing seeds is segmented to obtain multiple single-frame images containing seeds, and an image to be detected is selected from the multiple single-frame images containing seeds according to user needs.
[0029] The beneficial effect of adopting the above further scheme is: by segmenting the collected video containing seeds, the scheme has higher universality, and can identify videos or images containing seeds; in addition, the image to be detected can be selected from the multiple single-frame images containing seeds according to user needs, making the automatic seed recognition of this scheme more targeted, and also convenient for users, thereby optimizing the user experience.
[0030] Further, the step of obtaining the image to be detected containing the seed includes:
[0031] The image to be detected is acquired by offline acquisition and online acquisition.
[0032] The beneficial effect of adopting the above further solution is that the image to be detected can be obtained by selecting offline acquisition or online acquisition according to user needs, making the solution more universal and convenient for users, thereby optimizing the user experience.
[0033] Furthermore, it also includes:
[0034] When the detection classifier for N preset seed types does not detect any seed of the N preset seed types in the image to be detected, the image to be detected is directly outputted.
[0035] The beneficial effect of adopting the above further solution is that the detection efficiency of the detection classifier for N preset seed types can be improved, and at the same time, the detection results can be fed back to the user in a timely manner, thereby achieving convenience and speed.
[0036] In a second aspect, the present invention provides a seed automatic identification system, including a collection module and a detection module.
[0037] The acquisition module is used to obtain the seed image to be detected;
[0038] The detection module is used to input the image to be detected into a detection classifier for N preset seed types; when the detection classifier for N preset seed types detects seeds of the N preset seed types in the image to be detected, the detected seeds are marked using the detection classifier for the N preset seed types to obtain a detection result, where N is a positive integer.
[0039] The beneficial effect of the automatic seed identification system provided by the present invention is that by using a detection classifier for N preset seed types to detect all seeds in the image to be detected, the seeds that meet the preset seed types in the image to be detected can be easily and quickly identified. At the same time, the detection classifier for the N preset seed types has no strict requirements on the background, lighting, etc. of the image to be detected, thereby facilitating promotion and popularization.
[0040] On the basis of the above technical solution, the automatic seed identification system of the present invention can also be improved as follows.
[0041] Furthermore, it also includes a result display module,
[0042] The result display module is used to display the detection result.
[0043] The result display module can provide users with feedback on the test results in a variety of ways, such as images and data, thus providing convenience for the display of the test results.
[0044] Furthermore, it also includes a model training module.
[0045] The model training module is used to collect seed images under different backgrounds to obtain multiple first seed images containing seeds;
[0046] Using LabelImg image annotation software, adding seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels;
[0047] According to the plurality of second seed images containing seed type labels and the TensorFlow training model, a detection classifier for N preset seed types is trained, wherein N≤K, and K is a positive integer.
[0048] The beneficial effects of adopting the above further scheme are: by collecting seed images under different backgrounds, the detection classifier trained subsequently can have higher universality and be able to detect images under various background conditions; by using LabelImg image annotation software to add seed type labels, multiple second seed images for K preset target seed types can be obtained, thereby facilitating subsequent training to detect detection classifiers for N preset seed types; through multiple second seed images containing seed type labels and TensorFlow training models, corresponding detection classifiers can be trained according to human needs, making the detection classifier more targeted and customizable.
[0049] In a third aspect, the present invention further provides an electronic device comprising a memory, a processor, and a program stored in the memory and running on the processor, wherein the processor implements the steps of any of the above-mentioned automatic seed identification methods when executing the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0051] Figure 1A schematic diagram of a flow chart of a method for automatic seed identification according to an embodiment of the present invention;
[0052] Figure 2 A schematic diagram of the automatic seed recognition detection results provided by an embodiment of the present invention;
[0053] Figure 3 A schematic diagram of the structure of an automatic seed identification system according to an embodiment of the present invention;
[0054] Figure 4 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The following examples are provided to further explain and supplement the present invention and do not constitute any limitation to the present invention.
[0056] The automatic seed identification method according to an embodiment of the present invention is described below with reference to the accompanying drawings.
[0057] like Figure 1 As shown, a seed automatic identification method according to an embodiment of the present invention comprises the following steps:
[0058] S2, obtaining an image to be detected containing seeds;
[0059] S3. Input the image to be detected into a detection classifier for N preset seed types; when the detection classifier for N preset seed types detects seeds of the N preset seed types in the image to be detected, use the detection classifier for the N preset seed types to mark the detected seeds to obtain a detection result, where N is a positive integer.
[0060] Among them, the detection results can include result images and statistical data, such as Figure 2 As shown, the result image is an image to be detected with all seeds that meet the preset seed types marked, and the statistical data is the number of seeds of each preset seed type contained in the result image.
[0061] By using a detection classifier for N preset seed types to detect all seeds in the image to be detected, the seeds that meet the preset seed types in the image to be detected can be easily and quickly identified. At the same time, the detection classifier for N preset seed types has no strict requirements on the background, lighting, etc. of the image to be detected, which facilitates promotion and popularization.
[0062] Specifically, the step of obtaining an image to be detected containing seeds includes:
[0063] When a video containing seeds is collected, the video containing seeds is segmented to obtain multiple single-frame images containing seeds, and an image to be detected is selected from the multiple single-frame images containing seeds according to user needs.
[0064] By segmenting the collected videos containing seeds, this solution has higher universality and can identify videos or images containing seeds. In addition, the image to be detected can be selected from the multiple single-frame images containing seeds according to user needs, making the automatic seed recognition of this solution more targeted and convenient for users, thereby optimizing the user experience.
[0065] Specifically, the step of obtaining an image to be detected containing seeds includes:
[0066] The image to be detected is acquired by offline acquisition and online acquisition.
[0067] The image to be detected can be acquired by offline or online acquisition according to user needs, which makes the solution more universal and convenient for users, thereby optimizing the user experience.
[0068] Specifically, it also includes:
[0069] When the detection classifier for N preset seed types does not detect any seed of the N preset seed types in the image to be detected, the image to be detected is directly outputted.
[0070] The detection efficiency of the detection classifier for N preset seed types can be improved, and the detection results can be fed back to the user in a timely manner, thereby achieving convenience and speed.
[0071] Preferably, it also includes:
[0072] S11, collecting seed images under different backgrounds to obtain multiple first seed images containing seeds;
[0073] S12, using LabelImg image annotation software to add seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels;
[0074] S13. According to the plurality of second seed images containing seed type labels and the TensorFlow training model, a detection classifier for N preset seed types is trained, wherein N≤K, and K is a positive integer.
[0075] Among them, various devices that can collect images can be used to collect seed images, such as mobile phones, web cameras or professional cameras. In addition, the collected multiple first seed images are composed of images with complex conditions and environments such as different backgrounds and lighting.
[0076] Specifically, K=4 is set, that is, there are 4 preset target seed types, namely rapeseed, soybean, corn and peanut, and N=3 is set, that is, there are 3 preset seed types, namely rapeseed, soybean and corn.
[0077] 1) Check each first seed image, and when the seeds in the first seed image belong to the four preset target seed types of rapeseed, soybean, corn, and peanut, use LabelImg image annotation software to add corresponding seed type labels in the first seed image.
[0078] For example, a seed type label of "rapeseed" is added to the rapeseed in the first seed image, and a seed type label of "peanut" is added to the peanut seeds in the first seed image.
[0079] 2) After the seed type labels of all first seed images are added, multiple second seed images containing seed type labels are obtained, and an .xml file is generated for each second seed image, each .xml file containing the seed type label data of the corresponding second seed image.
[0080] 3) Convert all .xml files corresponding to the second seed images into TFRecords format as input data for the TensorFlow training model.
[0081] 4) Modify the parameters of the TensorFlow training model;
[0082] ① Find the labelmap.pbtxt file in the object_detection module and change the parameter id and parameter name in each item function in the labelmap.pbtxt file to the corresponding preset seed type. For example:
[0083]
[0084] ② Find the generate_tfrecord.py file in the object_detection module and modify the parameter row_label of the generate_tfrecord.py file to the corresponding preset seed type, for example:
[0085]
[0086]
[0087] ③Change the detection category in the fast_rcnn_inception_v2_pets.config file to 3.
[0088] 5) Run the train.py program in the TensorFlow training model to train your own classifier based on the labeled data and generate the frozen_inference_graph.pb file, which contains the detection classifiers trained for the three preset seed types: rapeseed, soybean, and corn.
[0089] By collecting seed images under different backgrounds, the subsequently trained detection classifier can have higher universality and be able to detect images under various background conditions; by using LabelImg image annotation software to add seed type labels, multiple second seed images for K preset target seed types can be obtained, thereby facilitating subsequent training to detect detection classifiers for N preset seed types; through multiple second seed images with seed type labels and the TensorFlow training model, the corresponding detection classifier can be trained according to human needs, making the detection classifier more targeted and customizable.
[0090] Preferably, in S3 of the above technical solution, labeling the detected seeds by using the detection classifier for the N preset seed types includes:
[0091] Acquire high-level features of the image to be detected, and segment each seed in the image to be detected separately according to the high-level features to obtain M single seed images, where M is a positive integer;
[0092] Using the detection classifier for the N preset seed types, each single seed image in the M single seed images is matched with each preset seed type in the N preset seed types to obtain M×N first matching degrees;
[0093] When it is determined that only one first matching degree among the first matching degrees corresponding to any single seed image is greater than the preset matching degree of the preset seed type, the single seed image is marked as the matched preset seed type;
[0094] When it is determined that at least two of the first matching degrees corresponding to any single seed image are greater than the preset matching degree of the preset seed type, the single seed image is detected using a preset strategy;
[0095] This continues until all the single seed images have been determined.
[0096] The preset strategy includes using existing classification technology such as image analysis to detect the single seed image;
[0097] Alternatively, at least two contradictory preset seed types are obtained based on the at least two first matching degrees of the single seed image that are greater than the preset matching degrees of the preset seed types, and a detection classifier for the at least two contradictory preset seed types is trained,
[0098] Using the detection classifier for the at least two contradictory preset seed types, the single seed image is matched with each of the at least two contradictory preset seed types to obtain at least two second matching degrees,
[0099] When it is determined that only one of the second matching degrees corresponding to the single seed image is greater than the preset matching degree of the contradictory preset seed type, the single seed image is marked as the matched contradictory preset seed type; when it is determined that at least two of the second matching degrees corresponding to the single seed image are greater than the preset matching degree of the contradictory preset seed type, the single seed image can be detected again using the preset strategy until the determination of all the single seed images is completed.
[0100] The high-level features are a combination of the color and texture of the seeds, and each seed in the image to be detected can be segmented individually according to the high-level features.
[0101] like Figure 2 As shown, there are 16 seeds in the image to be detected. According to the high-level feature segmentation, 16 single seed images can be obtained. The detection classifier trained for the three preset seed types of rapeseed, soybean and corn is used to match each of the 16 single seed images with each of the three preset seed types, and 16×3 first matching degrees are obtained, as shown in Table 1.
[0102]
[0103]
[0104] Table 1
[0105] 1) Set the preset matching degree of all preset seed types to 50%. According to Table 1, it can be determined that the first matching degree obtained by matching the first, third, sixth, fourteenth and sixteenth single seed images with the preset seed type of "soybean" is greater than 50%. Therefore, these five single seed images are marked as "soybean" in the image to be detected. At the same time, Figure 2 As shown, the first matching degree of each single seed image is marked;
[0106] 2) The preset matching degrees of all preset seed types are set to 30%. According to Table 1, it can be determined that the first matching degrees obtained by matching the first and 14 single seed images with the two preset seed types "soybean" and "corn" are both greater than 30%. At this time, the two preset seed types "soybean" and "corn" are contradictory preset seed types;
[0107] A detection classifier for the two contradictory preset seed types of "soybean" and "corn" was trained. The detection classifier matched the first single seed image and the 14th single seed image with the two contradictory preset seed types of "soybean" and "corn" respectively. The first single seed image obtained two second matching degrees, and the 14th single seed image obtained two second matching degrees, as shown in Table 2:
[0108] Corn is the second most compatible "Soybean" second matching degree The first single seed image 24% 98% Image 14 of a single seed 23% 99%
[0109] Table 2
[0110] The preset matching degree of the conflicting preset seed type is set to 30%. Therefore, it can be seen from Table 2 that the second matching degree obtained by matching the first single seed image and the 14th single seed image with the preset seed type of "soybean" is greater than 30%. Therefore, these two single seed images are marked as "soybean" in the image to be detected. Figure 2 As shown, the first matching degree of each single seed image is marked;
[0111] 3) A preset matching degree is set for each preset seed type. For example, the preset matching degree of "corn" is set to 40%, the preset matching degree of "soybean" is set to 90%, and the preset matching degree of "rapeseed" is set to 50%. According to Table 1, it can be obtained that the 8th and 12th single seed images are "corn", the 1st, 3rd, 6th, 14th and 16th single seed images are "soybean", and the 4th, 5th, 7th and 10th single seed images are "rapeseed".
[0112] In the above embodiments, although the steps are numbered, such as S1, S2, etc., these are only specific embodiments given in the present application. Those skilled in the art may adjust the execution order of S1, S2, etc. according to actual conditions, which is also within the scope of protection of the present invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.
[0113] like Figure 3 As shown, a seed automatic identification system according to an embodiment of the present invention includes a collection module 210 and a detection module 220.
[0114] The acquisition module 210 is used to acquire the seed image to be detected;
[0115] The detection module 220 is used to input the image to be detected into a detection classifier for N preset seed types; when the detection classifier for N preset seed types detects seeds of the N preset seed types in the image to be detected, the detected seeds are marked using the detection classifier for the N preset seed types to obtain a detection result, where N is a positive integer.
[0116] The detection module 220 detects all seeds in the image to be detected by using a detection classifier for N preset seed types, so that the seeds that meet the preset seed types in the image to be detected can be easily and quickly identified. At the same time, since the detection classifier for the N preset seed types has no strict requirements on the background, lighting, etc. of the image to be detected, it is easy to promote and popularize.
[0117] Preferably, if Figure 3 As shown, it also includes a result display module 230,
[0118] The result display module 230 is used to display the detection result.
[0119] Among them, Figure 2 As shown, the detection result may include a result image and statistical data. The result image is an image to be detected with all seeds that meet the preset seed types marked, and the statistical data is the number of seeds of each preset seed type contained in the result image.
[0120] Furthermore, it also includes a model training module 200,
[0121] The model training module 200 is used to collect seed images under different backgrounds to obtain multiple first seed images containing seeds;
[0122] Using LabelImg image annotation software, adding seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels;
[0123] According to the plurality of second seed images containing seed type labels and the TensorFlow training model, a detection classifier for N preset seed types is trained, wherein N≤K, and K is a positive integer.
[0124] The model training module 200 can collect seed images under different backgrounds to make the subsequently trained detection classifier have higher universality and be able to detect images under various background conditions; by using the LabelImg image annotation software to add seed type labels, multiple second seed images for K preset target seed types can be obtained, thereby facilitating subsequent training to detect detection classifiers for N preset seed types; through multiple second seed images containing seed type labels and the TensorFlow training model, corresponding detection classifiers can be trained according to human needs, making the detection classifiers more targeted and customizable.
[0125] Preferably, the model training module 200 further includes an image segmentation module 201 and a matching module 202.
[0126] The image segmentation module 201 is used to obtain high-level features of the image to be detected, and to segment each seed in the image to be detected separately according to the high-level features to obtain M single seed images, where M is a positive integer;
[0127] The matching module 202 is used to match each single seed image in the M single seed images with each preset seed type in the N preset seed types by using the detection classifier for the N preset seed types, to obtain M×N first matching degrees;
[0128] When it is determined that only one first matching degree among the first matching degrees corresponding to any single seed image is greater than the preset matching degree of the preset seed type, the single seed image is marked as the matched preset seed type;
[0129] When it is determined that at least two of the first matching degrees corresponding to any single seed image are greater than the preset matching degree of the preset seed type, the single seed image is detected using a preset strategy;
[0130] This continues until all the single seed images have been determined.
[0131] The preset strategy includes using existing classification technology such as image analysis to detect the single seed image;
[0132] Alternatively, at least two contradictory preset seed types are obtained based on the at least two first matching degrees of the single seed image that are greater than the preset matching degrees of the preset seed types, and a detection classifier for the at least two contradictory preset seed types is trained,
[0133] Using the detection classifier for the at least two contradictory preset seed types, the single seed image is matched with each of the at least two contradictory preset seed types to obtain at least two second matching degrees,
[0134] When it is determined that only one of the second matching degrees corresponding to the single seed image is greater than the preset matching degree of the contradictory preset seed type, the single seed image is marked as the matched contradictory preset seed type; when it is determined that at least two of the second matching degrees corresponding to the single seed image are greater than the preset matching degree of the contradictory preset seed type, the single seed image can be detected again using the preset strategy; until the determination of all the single seed images is completed.
[0135] The high-level features of the image to be detected are a combination of the color, texture and other features of the image to be detected. Therefore, the outline of each seed in the image to be detected can be identified through the high-level features, thereby obtaining M single-grain seed images; each single-grain seed image in the M single-grain seed images is matched with each of the N preset seed types by a detection classifier for N preset seed types, so that it can be identified whether each single-grain seed image conforms to one of the N preset seed types, thereby facilitating the subsequent annotation of the image to be detected; in addition, by performing a second matching on single-grain seed images having at least two first matching degrees greater than the preset matching degree of the preset seed type, the accuracy of automatic seed recognition can be effectively improved.
[0136] The above-mentioned parameters and steps for each unit module to realize corresponding functions in a seed automatic identification system of the present invention can refer to the parameters and steps in the embodiment of a seed automatic identification method mentioned above, and will not be repeated here.
[0137] like Figure 4 As shown, an electronic device 300 of an embodiment of the present invention includes a memory 310, a processor 320, and a program 330 stored in the memory 310 and running on the processor 320. When the processor 320 executes the program 330, it implements part or all of the steps of any of the above-mentioned seed automatic identification methods.
[0138] Among them, the electronic device 300 can be a computer, a mobile phone, etc. Correspondingly, its program 330 is computer software or a mobile phone APP, etc., and the above-mentioned parameters and steps in an electronic device 300 of the present invention can refer to the parameters and steps in an embodiment of a seed automatic identification method above, and will not be repeated here.
[0139] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software, generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code. Computer-readable storage media can be, for example, but not limited to - electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above.
[0140] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0141] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A seed automatic identification method, characterized in that: The following steps are involved: Obtain an image to be detected containing seeds; Input the image to be detected into a detection classifier for N preset seed types; when the detection classifier for the N preset seed types detects seeds of the N preset seed types in the image to be detected, use the detection classifier for the N preset seed types to mark the detected seeds to obtain a detection result, wherein N is a positive integer; Among them, it also includes: Collecting seed images under different backgrounds to obtain multiple first seed images containing seeds; Using LabelImg image annotation software, adding seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels; According to the plurality of second seed images containing seed type labels and the TensorFlow training model, the detection classifier for N preset seed types is trained, wherein: , K is a positive integer; The first seed image is composed of images with different backgrounds and different illuminations; The step of training the detection classifier for the N preset seed types specifically includes: Generate an XML file corresponding to the second seed image from each second seed image, where each XML file contains a seed type label of the corresponding second seed image; Convert all XML files corresponding to the second seed images into TFRecords format files as input data for the TensorFlow training model; modify the parameters of the TensorFlow training model according to the preset seed type; The TensorFlow training model with modified parameters is trained according to the TFRecords format file to obtain the detection classifier for the N preset seed types; Using the detection classifier for the N preset seed types to label the detected seeds includes: Acquire high-level features of the image to be detected, and segment each seed in the image to be detected separately according to the high-level features to obtain M single-seed images, where M is a positive integer, and the high-level features include the color of the seed and the texture of the seed; Using the detection classifier for N preset seed types, each single seed image in the M single seed images is matched with each preset seed type in the N preset seed types to obtain The first matching degree; When it is determined that only one first matching degree among the first matching degrees corresponding to any single seed image is greater than the preset matching degree of the preset seed type, the single seed image is marked as the matched preset seed type; When it is determined that at least two of the first matching degrees corresponding to any single seed image are greater than the preset matching degree of the preset seed type, the single seed image is detected using a preset strategy; the preset strategy includes: according to the at least two first matching degrees of the single seed image that are greater than the preset matching degree of the preset seed type, at least two contradictory preset seed types are obtained, and a detection classifier for the at least two contradictory preset seed types is trained; the single seed image is matched with each of the at least two contradictory preset seed types using the detection classifier for the at least two contradictory preset seed types to obtain at least two second matching degrees; when it is determined that only one of the second matching degrees corresponding to the single seed image is greater than the preset matching degree of the contradictory preset seed type, the single seed image is marked as the matched contradictory preset seed type; when it is determined that at least two of the second matching degrees corresponding to the single seed image are greater than the preset matching degree of the contradictory preset seed type, the single seed image is detected again using the preset strategy until all the single seed images are determined; Until all the single seed images are labeled.
2. The automatic seed identification method according to claim 1, characterized in that: The step of obtaining an image to be detected containing seeds includes: When a video containing seeds is collected, the video containing seeds is segmented to obtain multiple single-frame images containing seeds, and an image to be detected is selected from the multiple single-frame images containing seeds according to user needs.
3. The automatic seed identification method according to claim 1, characterized in that: The step of obtaining an image to be detected containing seeds includes: The image to be detected is acquired by offline acquisition and online acquisition.
4. The automatic seed identification method according to claim 1, characterized in that: Also includes: When the detection classifier for N preset seed types does not detect any seed of the N preset seed types in the image to be detected, the image to be detected is directly outputted.
5. A seed automatic identification system, characterized in that: Including acquisition module and detection module, The acquisition module is used to acquire the image to be detected; The detection module is used to input the image to be detected into a detection classifier for N preset seed types; when the detection classifier for N preset seed types detects seeds of the N preset seed types in the image to be detected, the detected seeds are marked using the detection classifier for the N preset seed types to obtain a detection result, wherein N is a positive integer; It also includes the model training module: The model training module is used to collect seed images under different backgrounds to obtain multiple first seed images containing seeds; Using LabelImg image annotation software, adding seed type labels to seeds of K preset target seed types in all first seed images, to obtain multiple second seed images containing seed type labels; According to the plurality of second seed images containing seed type labels and the TensorFlow training model, a detection classifier for N preset seed types is trained, wherein: , K is a positive integer; The first seed image is composed of images with different backgrounds and different illuminations; The step of training the detection classifier for the N preset seed types specifically includes: Generate an XML file corresponding to the second seed image from each second seed image, where each XML file contains a seed type label of the corresponding second seed image; Convert all XML files corresponding to the second seed images into TFRecords format files as input data for the TensorFlow training model; modify the parameters of the TensorFlow training model according to the preset seed type; The TensorFlow training model with modified parameters is trained according to the TFRecords format file to obtain the detection classifier for the N preset seed types; The model training module includes an image segmentation module and a matching module: The image segmentation module is used to obtain high-level features of the image to be detected, and to segment each seed in the image to be detected separately according to the high-level features to obtain M single seed images, where M is a positive integer, and the high-level features include the color of the seed and the texture of the seed; The matching module is used to use the detection classifier for the N preset seed types to match each single seed image in the M single seed images with each preset seed type in the N preset seed types, to obtain The first matching degree; When it is determined that only one first matching degree among the first matching degrees corresponding to any single seed image is greater than the preset matching degree of the preset seed type, the single seed image is marked as the matched preset seed type; When it is determined that at least two of the first matching degrees corresponding to any single seed image are greater than the preset matching degree of the preset seed type, the single seed image is detected using a preset strategy; the preset strategy includes: according to the at least two first matching degrees of the single seed image that are greater than the preset matching degree of the preset seed type, at least two contradictory preset seed types are obtained, and a detection classifier for the at least two contradictory preset seed types is trained; the single seed image is matched with each of the at least two contradictory preset seed types using the detection classifier for the at least two contradictory preset seed types to obtain at least two second matching degrees; when it is determined that only one of the second matching degrees corresponding to the single seed image is greater than the preset matching degree of the contradictory preset seed type, the single seed image is marked as the matched contradictory preset seed type; when it is determined that at least two of the second matching degrees corresponding to the single seed image are greater than the preset matching degree of the contradictory preset seed type, the single seed image is detected again using the preset strategy until all the single seed images are determined; Until all the single seed images are labeled.
6. The automatic seed identification system according to claim 5, characterized in that: It also includes a result display module. The result display module is used to display the detection result.
7. An electronic device comprising a memory, a processor, and a program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the steps of the automatic seed identification method as described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Weed seed detection method
CN110188609A
Image classification method, device and equipment and readable storage medium
CN111626371A