A method and system for counting corn ears and kernels based on dual plane mirrors
Through a corn ear kernel panoramic counting system based on dual plane mirrors, combined with a deep learning algorithm, it solves the problems of traditional corn ear kernel counting perspective limitations and high hardware costs, achieves fast and accurate corn ear kernel panoramic counting, and meets the needs of corn yield estimation. needs.
Patent Information
- Application Number
- CN202410842103.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-08-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional corn ear counting methods have viewing angle limitations, resulting in inaccurate counting. Existing multi-view collection methods have high hardware costs or time-consuming data collection, making it difficult to achieve fast and accurate panoramic counting of corn ears.
Design a panoramic corn ear counting system based on dual plane mirrors. Through two vertically placed plane mirrors and cameras, combined with slide rails and baffles, three non-overlapping perspective images are obtained, and deep learning algorithms are used for data processing and Analysis to achieve rapid and accurate counting of corn ears.
It achieves the acquisition and accurate counting of corn ear images from multiple viewing angles. The system is fast, highly precise, and easy to operate. It meets actual needs and has important corn yield estimation significance.
Smart Images

Figure CN118379728B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a method and a system for counting corn cobs based on a double-plane mirror. Background Art
[0002] Corn is one of China's important food crops and one of the main pillars of China's agricultural economy. Corn kernel counting is of great significance for corn breeding and yield prediction. The traditional manual kernel counting method is not only time-consuming and labor-intensive, but also prone to counting errors. With the rapid development of computer vision technology, some scholars have collected images of corn to be tested and used image processing or deep learning algorithms to achieve rapid and accurate counting of corn kernels under a single perspective and estimate the number of kernels in the whole corn. However, the above method can only obtain corn kernel information under a single perspective, and the information of corn kernels under other perspectives is missing, resulting in inaccurate kernel counting of the whole corn. Some scholars placed the corn to be tested on a turntable, set the turntable to rotate at a fixed angle, and then took images of the corn, and then generated a panoramic image of the corn through an image stitching algorithm, thereby achieving panoramic counting of corn kernels, but the data acquisition of this method is relatively time-consuming and has high requirements for the image stitching algorithm. Some scholars use multiple cameras to collect images of the corn to be tested from different perspectives, but this method has high hardware costs and there is a problem of corn image overlap.
[0003] Therefore, it is urgent to design a corn kernel panoramic counting system to obtain corn panoramic images from multiple perspectives and realize fast and accurate counting of corn kernels. Summary of the invention
[0004] In order to solve the technical problems raised in the background technology, the present invention provides a corn kernel panoramic counting method and counting system based on double plane mirrors.
[0005] The present invention is implemented by the following technical solutions:
[0006] The invention proposes a corn ear kernel panoramic counting system based on double plane mirrors, the counting system comprises a bottom plate, two plane mirrors, a supporting base, a camera, three slide rails, three baffles and a light source; the two plane mirrors are of the same size and are vertically placed on the bottom plate, one side of the two plane mirrors are in contact and the angle between the two is 120 degrees, the camera is installed in front of the supporting base; the three baffles are respectively installed on the three slide rails, the three slide rails are uniformly arrayed around the supporting base in the circumferential direction, one of the slide rails is located on the angular bisector of the angle between the two plane mirrors, the supporting base is fixed on the bottom plate, the three slide rails are all slidably connected to the bottom plate, and the slide rails are made to slide along the length direction thereof, and the light source is located directly above the bottom plate;
[0007] Among them, two plane mirrors are used to reflect the images of corn kernels at corresponding viewing angles, the camera is used to collect the images of corn kernels, and the slide rails and baffles are combined into three movable baffles to divide the corn kernels into three non-overlapping parts.
[0008] The present invention also proposes a method for panoramic counting of corn kernels based on a double plane mirror, comprising the following steps:
[0009] Step 1: construct a corn kernel panoramic counting system in the above scheme, wherein the panoramic counting system can divide the corn kernel into three non-overlapping parts and obtain a corn kernel image composed of the images of the three non-overlapping parts;
[0010] The corn ear kernel image includes two corn ear kernel images 1 reflected by two plane mirrors and one corn ear kernel image 2 facing the camera viewing angle, and the camera can simultaneously obtain the corn ear kernel image composed of the two corn ear kernel images 1 and one corn ear kernel image 2;
[0011] Step 2: Prepare a corn kernel dataset, fix the corns on the support base in sequence, use a camera to shoot to obtain a corn kernel dataset, and mark the points on it;
[0012] Step 3: Using the improved point-to-point network to obtain a corn kernel detection model, the corn kernel data set is divided into a training set, a test set, and a validation set according to a certain ratio; the images in the training set are input into the improved point-to-point network for training, the model is evaluated with the validation set, and the model is tested with the test set to obtain the final corn kernel detection model;
[0013] Step 4, collect a panoramic picture of the corn kernels to be tested and calculate the total number of kernels; specifically, first, fix the corn to be tested on a supporting base, move the baffle to be perpendicular to the side contour of the corn, and then use a camera to shoot to obtain a panoramic picture of the corn kernels to be tested, and finally input the panoramic picture of the corn kernels to be tested into the final corn cob detection model to obtain the total number of corn kernels to be tested.
[0014] Specifically, in step 1, the camera is installed in front of the support base so that the camera optical axis and the central axis of the support base are in the same plane, and from the camera's viewing angle, it can be seen that the baffle divides the object to be measured into three non-overlapping areas.
[0015] Specifically, in step 2, the corn is fixed vertically on a supporting base, and then photographed with a camera to obtain the required corn kernel dataset. Labelme annotation software is used to point-mark each corn kernel in the corn kernel dataset and generate a json file. The coordinate information in the json file is then extracted and placed in a txt file with the same file name. The txt file serves as the label of the final corn kernel dataset. In order to increase the diversity of the corn kernel dataset, the images in the corn kernel dataset can be flipped upside down, flipped left to right, randomly rotated, randomly scaled, and noised.
[0016] Specifically, in step 3, the corn kernel dataset is divided into a training set, a test set, and a validation set in a ratio of 8:1:1, and the point-to-point network can classify and locate the target objects in the training set;
[0017] In order to achieve better training results, a plug-and-play convolutional attention module is added to the feature extraction part of the original point-to-point network. The module consists of two parts in series, namely the channel attention module and the spatial attention module. The channel attention module can adaptively learn the importance of each channel to improve the network's perception of channel features. The spatial attention module can adaptively learn the importance of each spatial position to improve the network's perception of spatial features. Through the combination of the two attention modules, the convolutional attention module can effectively improve the network's ability to express features, thereby improving the performance of the network.
[0018] More specifically, in step 3, first, the first round of training is performed, a certain number of pictures are extracted from the training set and input into the improved point-to-point network for training, and the corn kernel detection model of the first iteration and the corresponding loss value are obtained; the corn kernel model of the first iteration is verified by the pictures in the validation set, and the accuracy and recall of the validation set are obtained, and then the same number of pictures are extracted from the remaining pictures in the training set as the training set for the next iteration, and the above operation is repeated until the pictures in the training set are trained, and the loss values obtained in each iteration are added as the loss value of this round, and the model of the last iteration is used as the corn kernel detection model of this round. When the round of training is completed, the detection model of this round is tested using the test set, where the loss value can be expressed as:
[0019] ;
[0020] ;
[0021] ;
[0022] Among them, the cross entropy loss Used to train candidate box classification, Euclidean loss To supervise point regression;
[0023] is the actual number of corn kernels in the picture. is the predicted number of kernels in an ear of corn; Refers to the number marked in the picture The position coordinates of each spikelet, Refers to the corresponding predicted position coordinates, It refers to the confidence level of the corresponding prediction point;
[0024] represents the Euclidean distance, is the weighted value of the negative candidate box, is the weighted value to balance the regression loss;
[0025] After the first round of training, the next round of training begins. The operation is the same as the first round. The corn kernel detection model obtained in the first round of training is used as the model for the second round of training. The previous operation is repeated. If the training reaches the preset rounds and the loss value of this round is still lower than the loss value of the previous round, the model corresponding to the loss value of this round is used as the final corn kernel detection model.
[0026] In step 4, specifically, the panoramic picture of the corn kernels to be tested is input into the corn kernel detection model to obtain a feature map, and then the 1v1 Hungarian algorithm is used for matching to obtain the final total number of corn kernels.
[0027] Specifically, the 1v1 Hungarian matching algorithm comprehensively considers the pixel distance and the candidate point confidence, so a single candidate point can only be matched to one real point, and a real point can only be matched to one candidate point, to ensure that all candidate points have clear prediction targets, and unmatched candidate points will be classified as background.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The invention provides a corn cob kernel panoramic counting system, which can obtain corn cob kernel images at three different viewing angles and quantitatively calculate the number of whole corn cob kernels, and is of great significance for estimating corn yield.
[0030] The counting method proposed in the present invention can simultaneously obtain corn kernel image information from multiple perspectives, and process and analyze the images through a deep learning algorithm, thereby accurately calculating the number of whole corn kernels. Compared with other counting systems, this system has significant advantages such as high speed, high accuracy, and simple operation, and can better meet actual needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1The workflow diagram of the corn kernel panoramic counting system is shown;
[0032] Figure 2 It shows pictures of corn ears and kernels from three viewing angles;
[0033] Figure 3 The kernel locations and count results in a panoramic image of corn ears are shown. DETAILED DESCRIPTION
[0034] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0035] Embodiment 1:
[0036] Please refer to Figure 2 , this scheme proposes a corn kernel panoramic counting system based on double plane mirrors, which is used for the above counting method. The counting system includes a base plate, two plane mirrors, a supporting base, a camera, three slide rails, three baffles and a light source; two plane mirrors of the same size are placed vertically on the base plate, one side of the two plane mirrors is in contact and the angle between the two is 120°, the plane mirrors can be installed and fixed with buckles or other detachable structures and the base plate, and the camera is installed in front of the supporting base; three baffles are respectively installed on three slide rails, and the baffles and the slide rails can be fixed with bolts. The baffles are opaque products, and the three slide rails are uniformly distributed in an array around the supporting base in the circumferential direction, one of the slide rails is located on the bisector of the angle between the two plane mirrors, the supporting base is fixed on the base plate, the three slide rails are all slidably connected to the base plate, and slide along the length direction of the slide rails, and the light source is located directly above the base plate;
[0037] The plane mirror is used to reflect the corn kernel images from other perspectives, the camera is used to collect the corn kernel images, and the slide rail and the baffle are combined into three movable baffles to divide the corn kernels into three non-overlapping parts.
[0038] Embodiment 2:
[0039] Reference Figure 1-3 , a method for counting corn ears based on a double plane mirror is proposed in this scheme, comprising the following steps:
[0040] Step 1: construct a corn kernel panoramic counting system as in Example 1, wherein the panoramic counting system can divide the corn kernels into three non-overlapping parts and obtain a corn kernel image consisting of images of the three non-overlapping parts;
[0041] The corn ear kernel image includes two corn ear kernel images 1 reflected by two plane mirrors and one corn ear kernel image 2 facing the camera viewing angle, and the camera can simultaneously obtain the corn ear kernel image composed of the two corn ear kernel images 1 and one corn ear kernel image 2;
[0042] Step 2: Prepare a corn kernel dataset, fix the corns on the support base in sequence, use a camera to shoot to obtain a corn kernel dataset, and mark the points on it;
[0043] Step 3: Using the improved point-to-point network to obtain a corn kernel detection model, the corn kernel data set is divided into a training set, a test set, and a validation set according to a certain ratio; the images in the training set are input into the improved point-to-point network for training, the model is evaluated with the validation set, and the model is tested with the test set to obtain the final corn kernel detection model;
[0044] Step 4, collect a panoramic picture of the corn kernels to be tested and calculate the total number of kernels; specifically, first, fix the corn to be tested on a supporting base, move the baffle to be perpendicular to the side contour of the corn, and then use a camera to shoot to obtain a panoramic picture of the corn kernels to be tested, and finally input the panoramic picture of the corn kernels to be tested into the final corn cob detection model to obtain the total number of corn kernels to be tested.
[0045] Specifically, in step 1, the camera is installed in front of the support base so that the camera optical axis and the central axis of the support base are in the same plane, and from the camera's viewing angle, it can be seen that the baffle divides the object to be measured into three non-overlapping areas.
[0046] Specifically, in step 2, the corn is fixed vertically on a supporting base, and then photographed with a camera to obtain the required corn kernel dataset. Labelme annotation software is used to point-mark each corn kernel in the corn kernel dataset and generate a json file. The coordinate information in the json file is then extracted and placed in a txt file with the same file name. The txt file serves as the label of the final corn kernel dataset. In order to increase the diversity of the corn kernel dataset, the images in the corn kernel dataset can be flipped upside down, flipped left to right, randomly rotated, randomly scaled, and noisy.
[0047] Specifically, in step 3, the corn kernel dataset is divided into a training set, a test set, and a validation set in a ratio of 8:1:1, and the point-to-point network can classify and locate the target objects in the training set;
[0048] In order to achieve better training results, a plug-and-play convolutional attention module is added to the feature extraction part of the original point-to-point network. The module consists of two parts in series, namely the channel attention module and the spatial attention module. The channel attention module can adaptively learn the importance of each channel to improve the network's perception of channel features. The spatial attention module can adaptively learn the importance of each spatial position to improve the network's perception of spatial features. Through the combination of the two attention modules, the convolutional attention module can effectively improve the network's ability to express features, thereby improving the performance of the network.
[0049] More specifically, in step 3, first, the first round of training is performed, a certain number of pictures are extracted from the training set and input into the improved point-to-point network for training, and the corn kernel detection model of the first iteration and the corresponding loss value are obtained; the corn kernel model of the first iteration is verified by the pictures in the validation set, and the accuracy and recall of the validation set are obtained, and then the same number of pictures are extracted from the remaining pictures in the training set as the training set for the next iteration, and the above operation is repeated until the pictures in the training set are trained, and the loss values obtained in each iteration are added as the loss value of this round, and the model of the last iteration is used as the corn kernel detection model of this round. When the round of training is completed, the detection model of this round is tested using the test set, where the loss value can be expressed as:
[0050] ;
[0051] ;
[0052] ;
[0053] Among them, the cross entropy loss Used to train candidate box classification, Euclidean loss To supervise point regression;
[0054] is the actual number of corn kernels in the picture. is the predicted number of kernels in an ear of corn; Refers to the number marked in the picture The position coordinates of each spikelet, Refers to the corresponding predicted position coordinates, It refers to the confidence level of the corresponding prediction point;
[0055] represents the Euclidean distance, is the weighted value of the negative candidate box, is the weighted value to balance the regression loss;
[0056] After the first round of training, the next round of training begins. The operation is the same as the first round. The corn kernel detection model obtained in the first round of training is used as the model used in the second round of training. The previous operation is repeated. If the training reaches the preset rounds and the loss value of this round is still lower than the loss value of the previous round, the model corresponding to the loss value of this round is used as the final corn kernel detection model. From the above scheme, it can be seen that this model uses two variables to control the training process, namely the loss value difference and the number of training rounds.
[0057] In step 4, specifically, the panoramic picture of the corn kernels to be tested is input into the corn kernel detection model to obtain a feature map, and then the 1v1 Hungarian algorithm is used for matching to obtain the final total number of corn kernels.
[0058] Specifically, the 1v1 Hungarian matching algorithm comprehensively considers the pixel distance and the candidate point confidence, so a single candidate point can only be matched to one real point, and a real point can only be matched to one candidate point, to ensure that all candidate points have clear prediction targets, and unmatched candidate points will be classified as background.
[0059] The counting method proposed in the present invention can simultaneously obtain corn kernel image information from multiple perspectives, and process and analyze the images through a deep learning algorithm, thereby accurately calculating the number of whole corn kernels. Compared with other counting systems, this system has significant advantages such as high speed, high accuracy, and simple operation, and can better meet actual needs.
[0060] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A corn kernel panoramic counting system based on a double plane mirror, characterized in that: The counting system comprises a bottom plate, two plane mirrors, a supporting base, a camera, three slide rails, three baffles and a light source; the two plane mirrors are of the same size and are vertically placed on the bottom plate, one side of the two plane mirrors touches each other and the angle between the two is 120°, and the camera is installed in front of the supporting base; the optical axis of the camera and the central axis of the supporting base are in the same plane, and from the camera's viewing angle, it can be seen that the baffle divides the measured object into three non-overlapping areas; The three baffles are respectively mounted on three slide rails, which are evenly distributed in an array around the support base along the circumferential direction, one of the slide rails is located on the angle bisector of the angle between the two plane mirrors, the support base is fixed on the bottom plate, the three slide rails are slidably connected to the bottom plate, and the slide rails are slid along their length directions, and the light source is located directly above the bottom plate; The two plane mirrors are used to reflect the corn kernel images of the corresponding viewing angles, the camera is used to collect the corn kernel images, and the slide rails and baffles are combined into three movable baffles to divide the corn kernels into three non-overlapping parts; so as to obtain the corn kernel images composed of the images of the three non-overlapping parts. The corn kernel image includes two corn kernel images 1 reflected by two plane mirrors and one corn kernel image 2 facing the camera viewing angle. The camera can simultaneously obtain the corn kernel image composed of the two corn kernel images 1 and one corn kernel image 2.
2. A method for counting corn kernels in a panoramic manner based on a double plane mirror, characterized in that: The steps include: Step 1, constructing the corn kernel panoramic counting system as claimed in claim 1, wherein the panoramic counting system can divide the corn kernel into three non-overlapping parts and obtain a corn kernel image composed of images of the three non-overlapping parts; Step 2: Prepare a corn kernel dataset, fix the corns on the support base in sequence, use a camera to shoot to obtain a corn kernel dataset, and mark the points on it; Step 3: Using the improved point-to-point network to obtain a corn kernel detection model, the corn kernel data set is divided into a training set, a test set, and a validation set according to a certain ratio; the images in the training set are input into the improved point-to-point network for training, the model is evaluated with the validation set, and the model is tested with the test set to obtain the final corn kernel detection model; Step 4, collect a panoramic picture of the corn kernels to be tested and calculate the total number of kernels; specifically, first, fix the corn to be tested on a supporting base, move the baffle to be perpendicular to the side contour of the corn, and then use a camera to shoot to obtain a panoramic picture of the corn kernels to be tested, and finally input the panoramic picture of the corn kernels to be tested into the final corn cob detection model to obtain the total number of corn kernels to be tested.
3. A method for counting corn kernels in a panoramic manner based on a double plane mirror as claimed in claim 2, characterized in that: In step 2, specifically, the corn is fixed vertically on a supporting base, and then photographed with a camera to obtain the required corn kernel dataset, and Labelme annotation software is used to point-annotate each corn kernel in the corn kernel dataset and generate a json file, and then the coordinate information in the json file is extracted and placed in a txt file with the same file name, and the txt file is used as the label of the final corn kernel dataset.
4. A method for counting corn kernels in a panoramic manner based on a double plane mirror as claimed in claim 2, characterized in that: In step 3, the corn kernel dataset is divided into a training set, a test set, and a validation set in a ratio of 8:1:1, and the point-to-point network can classify and locate the target objects in the training set; A plug-and-play convolutional attention module is added to the feature extraction part of the original point-to-point network. The module consists of two parts in series, namely the channel attention module and the spatial attention module. The channel attention module can adaptively learn the importance of each channel to improve the network's perception of channel features. The spatial attention module can adaptively learn the importance of each spatial position to improve the network's perception of spatial features.
5. A method for counting corn kernels in a panoramic manner based on a double plane mirror as claimed in claim 4, characterized in that: In step 3, first, the first round of training is performed, a certain number of images are extracted from the training set and input into the improved point-to-point network for training, and the corn ear detection model and the corresponding loss value of the first iteration are obtained; The corn kernel model of the first iteration is verified by the pictures in the validation set to obtain the accuracy and recall of the validation set. Then, the same number of pictures are extracted from the remaining pictures in the training set as the training set for the next iteration. The above operation is repeated until the pictures in the training set are trained. The loss values obtained in each iteration are added as the loss value of this round, and the model of the last iteration is used as the corn kernel detection model of this round. When the training of this round is completed, the detection model of this round is tested using the test set, where the loss value can be expressed as: ; ; ; Among them, the cross entropy loss Used to train candidate box classification, Euclidean loss To supervise point regression; is the actual number of corn kernels in the picture. is the predicted number of kernels in an ear of corn; Refers to the number marked in the picture The position coordinates of each spikelet, Refers to the corresponding predicted position coordinates, It refers to the confidence level of the corresponding prediction point; represents the Euclidean distance, is the weighted value of the negative candidate box, is the weighted value to balance the regression loss; After the first round of training, the next round of training begins. The operation is the same as the first round. The corn kernel detection model obtained in the first round of training is used as the model for the second round of training. The previous operation is repeated. If the training reaches the preset rounds and the loss value of this round is still lower than the loss value of the previous round, the model corresponding to the loss value of this round is used as the final corn kernel detection model.
6. A method for counting corn kernels in a panoramic manner based on a double plane mirror as claimed in claim 5, characterized in that: In the step 4, specifically, the panoramic picture of the corn kernels to be tested is input into the corn kernel detection model to obtain a feature map, and then the 1v1 Hungarian algorithm is used for matching to obtain the final total number of corn kernels.
7. A method for counting corn kernels in a panoramic manner based on a double plane mirror as claimed in claim 6, characterized in that: The 1v1 Hungarian matching algorithm comprehensively considers the pixel distance and the candidate point confidence, so a single candidate point can only be matched to one real point, and a real point can only be matched to one candidate point, to ensure that all candidate points have clear prediction targets, and unmatched candidate points will be classified as background.
