Grain center of mass positioning method, device, electronic device and storage medium
By acquiring and processing grain images, combining contour positioning and semantic segmentation models, the center of mass fusion coordinates are calculated to determine the removed points, which solves the problem of inaccurate center positioning of grain materials in the prior art, and improves the accuracy and damage of grain sorting Calculation accuracy of grain indicators.
Patent Information
- Application Number
- CN202411156252.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-08-22
AI Technical Summary
When dealing with large, medium and small particles and damaged particles, it is difficult to take into account efficiency and accuracy, resulting in inaccurate calculation of the grain index of broken grains, affecting the accuracy of detection.
By obtaining the target grain image, judging its width and the width of the removal paddle, using contour positioning and semantic segmentation models to identify edge features, calculate the first center of mass and the second center of mass, and determine the removal point through the fusion coordinates of the center of mass, which is suitable for damaged grains Center of mass positioning.
It improves the accuracy of grain sorting and the calculation accuracy of damaged grain grain indicators, reduces the dependence of computing resources, and avoids the problem of flying materials.
Smart Images

Figure CN118674773B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of agricultural machinery, and in particular to a method for locating the centroid of grains, a device for locating the centroid of grains, an electronic device and a computer-readable storage medium. Background Art
[0002] At present, in the final stage of inspection, visual inspection equipment for damaged grains with sorting function needs to accurately remove the identified damaged grains to the corresponding sorting ports, and then weigh each sorting port to calculate the indicators of various imperfect grains. The ideal rejection point should be the center of mass position of the grain grains to ensure that the grain grains enter the sorting port according to the preset trajectory. When the center of mass position is misjudged, the rejection action acting on the non-center of mass will cause the movement trajectory of the grains to deviate, causing flying and bouncing of materials. This will not only cause the number of damaged grain grains to not match the number of inspection images, but also affect the weighing information, reduce the detection accuracy of the equipment, and further affect the calculation of the damaged grain index.
[0003] When calculating the centroid of an object, it is usually necessary to go through the process of object segmentation, contour extraction, and contour centroid calculation. However, these methods face challenges in detecting a large number of damaged grains, especially when dealing with large, medium, small grains and damaged grains, it is difficult to balance efficiency and accuracy. In particular, damaged grains have a large projected area but uneven weight distribution, which makes it more difficult to calculate the centroid and affects the removal effect. Summary of the invention
[0004] The present invention aims to solve one of the technical problems in the related art at least to a certain extent.
[0005] To this end, the first purpose of the present invention is to propose a method for locating the centroid of grains, which can to a certain extent solve the problem of large-grain damaged grains flying due to inaccurate centroid positioning when a large amount of grains need to be quickly detected, thereby affecting the calculation problem of damaged grain kernel indicators.
[0006] A method for locating the centroid of grains, comprising: acquiring a target grain image; wherein the target grain image includes a grain region mapping a single grain; determining whether the width of the target grain image is smaller than the width of a grain rejection paddle; if the width of the target grain image is not smaller than the width of the grain rejection paddle, contour locating the grain region, and determining a first centroid coordinate of the single grain according to a result of the contour locating; determining whether the single grain is a damaged grain; if the single grain is a damaged grain, contour locating a non-damaged portion in the grain region, and determining a second centroid coordinate of the non-damaged portion of the single grain according to a result of the contour locating; determining a centroid fusion coordinate according to the first centroid coordinate and the second centroid coordinate, and using the centroid fusion coordinate as a working point coordinate indicating the grain rejection paddle.
[0007] In addition, the method for locating the centroid of grains in the above embodiment of the present invention may also have the following additional technical features:
[0008] According to some embodiments of the present invention, the method further comprises:
[0009] If the width of the target grain image is smaller than the width of the grain rejection paddle, the center of the target grain image is used as the working point for indicating the grain rejection paddle to reject a single grain.
[0010] According to some embodiments of the present invention, the method further comprises:
[0011] If the single grain is not a damaged grain, the first centroid coordinate is used as the working point for indicating the grain rejection paddle to reject the single grain.
[0012] According to some embodiments of the present invention, contour positioning is performed on a grain region, and the first centroid coordinates of a single grain are determined according to the contour positioning result, including:
[0013] The target grain image is input into a pre-built grain semantic segmentation model, the first edge feature in the grain area is identified, and the first edge segmentation of the grain area is performed according to the first edge feature to obtain the result of contour positioning; wherein the first edge feature represents the overall edge contour of a single grain;
[0014] The centroid of the single grain is calculated based on the result of contour positioning to obtain the first centroid coordinates.
[0015] According to some embodiments of the present invention, contour positioning is performed on the non-damaged portion in the grain region, and the second centroid coordinates of the non-damaged portion of the single grain are determined according to the contour positioning result, including:
[0016] The target grain image is input into a pre-built grain semantic segmentation model, the second edge feature in the grain area is identified, and the second edge segmentation of the grain area is performed according to the second edge feature to obtain the result of contour positioning; wherein the second edge feature represents the partial edge contour of the non-damaged part of a single grain;
[0017] The centroid of the non-damaged part of the single grain is calculated based on the result of the contour positioning to obtain the second centroid coordinates.
[0018] According to some embodiments of the present invention, a cereal semantic segmentation model includes an encoder and a decoder;
[0019] The input of the encoder is the original feature map of the target grain image;
[0020] The encoder is used to reduce the spatial resolution of the original feature map by half and expand the channel dimension to four times the original to obtain the first feature map; half of the channels of the first feature map are extracted at intervals to restore the spatial resolution of the encoder to obtain the second feature map;
[0021] The input of the decoder is a low-resolution feature map of the target grain image; the spatial resolution of the low-resolution feature map is half of the original feature map;
[0022] The decoder is used to reduce the channel dimension of the low-resolution feature map to half of the original one to obtain a third feature map; upsample the third feature map to obtain a fourth feature map; wherein the spatial resolution and channel dimension of the fourth feature map are the same as those of the second feature map.
[0023] According to some embodiments of the present invention, the method further comprises:
[0024] The second feature map and the fourth feature map are spliced to obtain a target feature map; wherein the target feature map represents the first edge feature or the second edge feature in the grain region.
[0025] According to some embodiments of the present invention, the centroid fusion coordinates are calculated by the following formula:
[0026]
[0027]
[0028]
[0029] in, is the first centroid coordinate, is the coordinate of the second centroid, is the centroid fusion coordinate, is the correction coefficient of the valley mass center, The area of the grain area occupied by the undamaged part of a single grain. The area of the grain region for a single grain.
[0030] According to a method for locating the centroid of grains in an embodiment of the present invention, a target grain image is first obtained through an image; wherein the target grain image includes a grain area that maps a single grain. Further, the width of the target grain image is compared with the width of the grain rejection paddle. If the width of the target grain image is less than the width of the grain rejection paddle, the center of the target grain image is directly used as the centroid. If the width of the target grain image is not less than the width of the grain rejection paddle, it is further determined whether the single grain is damaged. If the single grain is not a damaged grain, the centroid coordinates of the single grain are directly determined, and the centroid coordinates are used as the working point coordinates of the grain rejection paddle. If the single grain is a damaged grain, the centroid fusion coordinates are calculated based on the non-damaged part of the single grain, and the centroid fusion coordinates are used as the working point coordinates of the grain rejection paddle. The present invention can adopt different contour positioning and centroid calculation methods according to whether a single grain of grain is damaged. In the grain sorting process, especially when processing large-grain damaged grains, the centroid of the grain can be accurately positioned to avoid the problem of flying materials during sorting. The comprehensive accuracy of equipment sorting is significantly improved, and the accuracy of damaged grain kernel index calculation is improved. In addition, by introducing an optimized lightweight U-Net segmentation network and a centroid weighted fusion strategy, the accuracy of centroid positioning is further improved, and the dependence on computing resources is significantly reduced.
[0031] The second purpose of the present invention is to propose a grain centroid positioning device, which can to a certain extent solve the problem of large-particle broken grain flying due to inaccurate centroid positioning when a large amount of grain needs to be quickly detected, thus affecting the calculation of the broken grain kernel index.
[0032] A centroid positioning device for grains, comprising: an acquisition module, configured to acquire a target grain image; wherein the target grain image includes a grain area mapping a single grain; a first judgment module, configured to determine whether the width of the target grain image is less than the width of a grain rejection paddle; a first response module, configured to perform contour positioning on the grain area if the width of the target grain image is not less than the width of the grain rejection paddle, and determine a first centroid coordinate of the single grain according to the result of the contour positioning; a second judgment module, configured to determine whether the single grain is a damaged grain; a second response module, configured to perform contour positioning on a non-damaged part in the grain area if the single grain is a damaged grain, and determine a second centroid coordinate of the non-damaged part of the single grain according to the result of the contour positioning; a centroid fusion module, configured to determine a centroid fusion coordinate based on the first centroid coordinate and the second centroid coordinate, and use the centroid fusion coordinate as a working point coordinate indicating the grain rejection paddle.
[0033] According to a centroid positioning device for grains of an embodiment of the present invention, a target grain image is first obtained through an image; wherein the target grain image includes a grain area that maps a single grain. Further, the width of the target grain image is compared with the width of the grain rejection paddle. If the width of the target grain image is less than the width of the grain rejection paddle, the center of the target grain image is directly used as the centroid. If the width of the target grain image is not less than the width of the grain rejection paddle, it is further determined whether the single grain is damaged. If the single grain is not a damaged grain, the centroid coordinates of the single grain are directly determined, and the centroid coordinates are used as the working point coordinates of the grain rejection paddle. If the single grain is a damaged grain, the centroid fusion coordinates are calculated based on the non-damaged part of the single grain, and the centroid fusion coordinates are used as the working point coordinates of the grain rejection paddle. The present invention can adopt different contour positioning and centroid calculation methods according to whether a single grain of grain is damaged. In the grain sorting process, especially when processing large-grain damaged grains, the centroid of the grain can be accurately positioned to avoid the problem of flying materials during sorting. The comprehensive accuracy of equipment sorting is significantly improved, and the accuracy of damaged grain kernel index calculation is improved. In addition, by introducing an optimized lightweight U-Net segmentation network and a centroid weighted fusion strategy, the accuracy of centroid positioning is further improved, and the dependence on computing resources is significantly reduced.
[0034] To achieve the above-mentioned purpose, the third aspect of the present invention proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the method for locating the center of mass of grains as described above is implemented when the processor executes the program.
[0035] To achieve the above-mentioned purpose, a fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the above-mentioned method for locating the center of mass of grains.
[0036] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 Schematic diagram of the steps for sorting grain kernels.
[0039] Figure 2 Schematic diagram of the trajectory for sorting grain kernels.
[0040] Figure 3 Schematic diagram of the preprocessing method for calculating the overall centroid of cereal kernels.
[0041] Figure 4 A schematic flow chart of a method for locating the centroid of grains provided in an embodiment of the present invention.
[0042] Figure 5 Schematic diagram of the jump connection method of the U-Net network architecture in the prior art.
[0043] Figure 6 A schematic diagram of a jump connection method provided in an embodiment of the present invention.
[0044] Figure 7 A schematic diagram of a process for locating the center of mass of damaged grains is provided for an embodiment of the present invention.
[0045] Figure 8 A flowchart of sorting damaged grains provided in an embodiment of the present invention.
[0046] Fig. 9 A schematic diagram of the trajectory of sorting damaged grains is provided for an embodiment of the present invention.
[0047] Fig.10 A schematic diagram of a device for locating the center of mass of damaged grains provided in an embodiment of the present invention.
[0048] Fig.11 A more specific schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention.
[0049] Figure markings: 1001 - acquisition module, 1002 - first judgment module, 1003 - first response module, 1004 - second judgment module, 1005 - second response module, 1006 - centroid fusion module, 1110 - processor, 1120 - memory, 1130 - input / output interface, 1140 - communication interface, 1150 - bus. DETAILED DESCRIPTION
[0050] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
[0051] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0052] As mentioned in the background technology section, in the field of grain processing and inspection, accurate identification and removal of imperfect kernels (such as broken, deformed or discolored kernels) is an important part of ensuring grain quality and food safety. Traditional visual inspection equipment uses image analysis to identify imperfect kernels, but accurately removing the identified imperfect kernels to the corresponding sorting ports and ensuring the accuracy and efficiency of the removal action is still a technical challenge.
[0053] In the process of realizing the present invention, the applicant discovered that the difficulty of removing imperfect grains in existing visual inspection equipment lies in how to accurately calculate the optimal removal action point of the material, that is, the center of mass position of the material. The ideal removal point should be located at the center of mass of the grain to ensure that the material can be removed to the material distribution port according to the designed trajectory. However, in actual operation, due to the unevenness of the shape, size and texture of the material, especially the uneven actual weight distribution of large particle broken grain samples, it becomes difficult to judge the center of mass position. Traditional object center of mass calculation methods, such as object segmentation, object contour extraction and contour center of mass calculation, are more effective when processing materials of the same size or uniform texture, but when faced with the detection of imperfect grains of multiple grains, these methods cannot be compatible with large, medium and small grains and broken grains at the same time, and it is difficult to ensure the accuracy and efficiency of the center of mass calculation, making it difficult to achieve an ideal sorting effect.
[0054] refer to Figure 1 , a schematic diagram of the grain grain sorting steps.
[0055] In the specific implementation, the sorting steps of grains are divided into grain-by-grain feeding, induction feeding, image acquisition, algorithm recognition and sorting and rejection. Grain-by-grain feeding is the starting stage of grain sorting, and the purpose is to feed the grains into the sorting system one by one. The grains may be fed into the sorting machine evenly and orderly through a feeder or similar equipment to ensure that the grains can be sensed or recognized in an orderly manner later; induction feeding uses sensors to sense the key characteristic information of the grains in real time, and transmits the sensed information to the processing unit for subsequent algorithm recognition; image acquisition obtains detailed image information of the grains by taking pictures, which is applied to subsequent algorithm recognition; algorithm recognition uses image processing algorithms and machine learning technologies to identify the collected grain images, and can identify impurities, imperfect grains or other grains that do not meet the requirements in the grains; sorting and rejection separates the grains that do not meet the requirements from the qualified grains according to the results of algorithm recognition, and processes or discards the grains of different qualities after sorting.
[0056] refer to Figure 2 , is a schematic diagram of the trajectory of sorting grain kernels.
[0057] Figure 2 The upper middle part shows the movement trajectory of normal grain kernels in the sorter. The coordinates of the center of mass calculated based on the projection area are basically consistent with the actual center of mass coordinates. When the rejection paddle performs a rejection action on the center of mass, the flight trajectory of the kernels is an ideal flight trajectory and can be correctly put into the receiving box.
[0058] Figure 2 The lower middle part shows damaged grain kernels whose projection area is close to that of normal grains. At this time, calculating the overall center of mass based on the projection area in the traditional way will result in a large deviation between the calculated center of mass and the actual center of mass, and the flight trajectory will deviate from the ideal trajectory. At this time, the grain kernels will fly and bounce, and cannot be correctly put into the receiving box.
[0059] In order to overcome the above defects, although the width of the rejection paddle can be designed to be 1.5-2 times the size of the grain, the entire grain can be included in it, which can ensure the accuracy of rejection. However, due to the large number of grain categories, the size of grains usually ranges from 2mm to 15mm. That is, if the rejection paddle is designed to be relatively wide, in order to ensure that two or more grains are not rejected at one time, the detection distance of the grains needs to be widened. This method will greatly reduce the efficiency of detection and cannot be applied to multi-grain sorting scenarios. The second method is to calculate the center of mass of the grain grain based on the image. The rejection action of the paddle hits the center of mass of the grain, and the trajectory of the grain movement is more ideal. Therefore, it is very important to calculate the center of mass of the particle. If the position of the center of mass of the object is not accurately judged, the paddle acts at a non-center of mass, and the movement trajectory of the grain will be offset, which will cause problems of flying and bouncing materials, and ultimately lead to inaccurate calculation results of imperfect grain indicators.
[0060] In specific implementation, during sorting and rejection, the offset calculation of the rejection paddle is crucial for grain rejection. In fact, it is impossible to ensure that the centroid of the grain coincides with the visual center when the image is captured, so it is necessary to calculate the coordinates of the real centroid of the grain on the image based on the image, and then convert the image coordinates into real distance values, thereby calculating the offset of the grain relative to the visual center, and thus calculating the real-time distance between the centroid of the grain and the rejection device, and transmitting the real-time distance to the sorting machine to compensate to the rejection motor to perform accurate grain sorting and rejection.
[0061] In the present invention, the application scenario of the removal action is a glass plane, so it is only necessary to calculate the coordinates in one direction, and the calculation formula is as follows:
[0062]
[0063] in, is the real-time distance between the centroid of the kernel and the reject paddle, It is the distance between the visual center of the image recognition camera and the center of the rejection paddle. It is a fixed distance calibrated after the equipment is installed. is the abscissa of the grain mass center (i.e. the abscissa of the first mass center coordinate below), is the horizontal coordinate corresponding to the camera visual center, is the coefficient for converting the image pixel value coordinates into the actual physical size. In the present invention, 45 pixels represent 1 mm, that is, , the value is approximately 0.022.
[0064] refer to Figure 3 , which is a schematic diagram of the preprocessing method for calculating the overall centroid of cereal grains.
[0065] Since the two-dimensional image processed by image processing has no depth information, the centroid of the grain is not the centroid in the actual sense, but the centroid obtained for the projected area of the grain. The centroid calculated in this way assumes that the texture of the grain is uniform. However, for larger damaged grains, there will be a large mass loss, and the mass of the missing area may be much smaller than the defective area. However, the projected area size of such damaged grains in the image is almost the same as the projected area size of the intact grains. This situation will cause the calculated centroid of the grain to deviate seriously from the actual centroid, resulting in flying and bouncing materials.
[0066] Therefore, in order to solve the problems existing in the above-mentioned sorting method, it is necessary to correct the centroid of the grains. The present invention proposes a method for locating the centroid of grains.
[0067] The technical solution of the present invention is further described in detail below through specific embodiments.
[0068] refer to Figure 4, which is a schematic flow chart of a method for locating the centroid of grains provided in an embodiment of the present invention.
[0069] Step S401, obtaining a target grain image; wherein the target grain image includes a grain area mapping a single grain.
[0070] Specifically, after the grain kernels enter the grain sorting machine, the grain sorting machine will take pictures of them through the built-in camera to obtain the original image of a single grain; the original image of a single grain is preprocessed, and these preprocessing steps mainly include grayscale, that is, converting the color image into a grayscale image to simplify the image information and reduce the computational complexity; and binarization, that is, converting the grayscale image into an image with only black and white colors, so that the grains are easier to distinguish from the background or other impurities; the preprocessed image is segmented, and the grain area in the image is separated from the background to obtain the target grain image. This image accurately maps the area of a single grain and is an important basis for subsequent processing.
[0071] Step S402, determining whether the width of the target grain image is smaller than the width of the grain rejection paddle.
[0072] In a specific implementation, after the grain area is identified, the size of the area needs to be measured. For a two-dimensional image, the main concern is the width of the area (or lateral size), which can be achieved by calculating the width of the region bounding box. The bounding box can be understood as the minimum rectangle surrounding the grain area. Further, the measured grain area width is compared with the width of the grain rejection paddle to determine whether the width of the target grain image is less than the width of the grain rejection paddle. It should be noted that the width of the grain rejection paddle can be a predefined fixed value, or it can be adjusted according to different situations.
[0073] Step S403: if the width of the target grain image is not less than the width of the grain removal paddle, contour positioning is performed on the grain area, and the first centroid coordinates of the single grain are determined according to the contour positioning result.
[0074] In a specific implementation, if the width of the target grain image is not less than the width of the grain rejection paddle, it means that the grain rejection paddle cannot fully cover the entire grain grain. Then it is necessary to further analyze whether the grain grain is damaged and decide whether to adjust the position of the grain rejection paddle or take other measures accordingly.
[0075] As an optional embodiment, if the width of the target grain image is smaller than the width of the grain rejection paddle, the center of the target grain image is used as a working point to instruct the grain rejection paddle to reject the single grain.
[0076] In a specific implementation, if the width of the grain area is smaller than the width of the grain rejection paddle, it can be considered that the grain rejection paddle can contain the entire grain particle, and the whole grain can be smoothly rejected. At this time, the centroid of the grain can be equivalent to half the width of the target grain image, that is, it can be understood that the center of the target grain image is used as the working point to indicate the grain rejection paddle to reject the single grain, so as to ensure the accuracy and efficiency of grain rejection.
[0077] Step S404, determining whether the single grain is a damaged grain.
[0078] Specifically, the embodiment of the present invention needs to determine whether a single grain is a damaged grain by using an image recognition algorithm, that is, the damaged area and the non-damaged area of the target grain image that has been preprocessed can be distinguished.
[0079] Specifically, the image features of the pixel are identified to determine whether the pixel is a non-damaged area: if the image features of the pixel meet the image features of damaged grains, the pixel is recorded as a damaged pixel; if the image features of the pixel do not meet the image features of damaged grains, the pixel is recorded as a non-damaged pixel. All damaged pixels and non-damaged pixels are integrated into two sub-areas, and the non-damaged sub-areas are non-damaged areas, and the damaged sub-areas are damaged areas.
[0080] As an optional embodiment, it is necessary to perform contour positioning on the grain area and determine the first center of mass coordinates of a single grain based on the result of contour positioning, including: inputting the target grain image into a pre-built grain semantic segmentation model, identifying the first edge feature in the grain area, performing a first edge segmentation on the grain area based on the first edge feature, and obtaining the result of contour positioning; wherein the first edge feature represents the overall edge contour of a single grain; and calculating the center of mass of a single grain based on the result of contour positioning to obtain the first center of mass coordinates.
[0081] In a specific implementation, if the width of the target grain image is greater than the width of the grain rejection paddle, and the grain area does not contain a damaged grain area, it can be understood that the grain particle is a larger "complete" grain particle. Then, when calculating the centroid coordinates of the grain particle, the target grain image can be firstly grayscaled, and the color image can be converted into a grayscale image. The grayscale image only contains brightness information, which can simplify subsequent processing; secondly, the grayscale image is binarized, and the image is converted into an image with only black and white colors, which helps to more clearly identify the outline of the grain. Furthermore, the binarized image is input into a pre-built grain semantic segmentation model to identify the first edge feature in the grain area, that is, the entire outline of a single grain is found on the binarized image, and the grain area is edge segmented based on the detected outline to obtain the result of contour positioning. The result of contour positioning can be understood as the result of "separating" the entire grain particle from the target grain image along the edge outline. Finally, the first center of mass coordinate of the grain is calculated based on the result. Since the grain particle is complete, the first center of mass coordinate can be used as the working point to indicate the grain rejection paddle to reject the single grain.
[0082] Step S405: if the single grain is a damaged grain, contour positioning is performed on the non-damaged portion in the grain region, and the second centroid coordinates of the non-damaged portion of the single grain are determined according to the contour positioning result.
[0083] As an optional embodiment, contour positioning is performed on the non-damaged part of the grain area, and the second center of mass coordinates of the non-damaged part of the single grain are determined based on the result of contour positioning, including: inputting the target grain image into a pre-built grain semantic segmentation model, identifying the second edge feature in the grain area, performing second edge segmentation on the grain area based on the second edge feature, and obtaining the result of contour positioning; wherein the second edge feature represents the partial edge contour of the non-damaged part of the single grain; and calculating the center of mass of the non-damaged part of the single grain based on the result of contour positioning to obtain the second center of mass coordinates.
[0084] In a specific implementation, if the width of the target grain image is greater than the width of the grain rejection paddle, and the grain area contains a damaged grain area, that is, it can be understood that the grain grain is a larger "damaged" grain grain, then when calculating the centroid coordinates of the grain grain, the target grain image can be first grayed to convert the color image into a grayscale image. The grayscale image only contains brightness information, which can simplify subsequent processing; secondly, the grayscale image is binarized to convert the image into an image with only black and white colors, which helps to more clearly identify the contour of the grain. Further, the binarized image is input into a pre-built grain semantic segmentation model to identify the second edge feature in the grain area, that is, to find the contour of the non-damaged part of the grain grain on the binarized image, and according to the detected contour of the non-damaged part, the grain area is edge segmented to obtain the result of contour positioning. The result of contour positioning can be understood as the result of "separating" the non-damaged part of a single grain from the target grain image along the edge contour of the non-damaged part. Finally, the second centroid coordinates of the grain are calculated based on the result.
[0085] As an optional embodiment, a grain semantic segmentation model includes an encoder and a decoder; the input of the encoder is an original feature map of a target grain image; the encoder is used to reduce the spatial resolution of the original feature map by half and expand the channel dimension to four times the original to obtain a first feature map; half of the channels of the first feature map are extracted at intervals to restore the spatial resolution of the encoder to obtain a second feature map; the input of the decoder is a low-resolution feature map of the target grain image; the spatial resolution of the low-resolution feature map is half of the original feature map; the decoder is used to reduce the channel dimension of the low-resolution feature map to half of the original to obtain a third feature map; the third feature map is upsampled to obtain a fourth feature map; wherein the spatial resolution and channel dimension of the fourth feature map are the same as those of the second feature map.
[0086] refer to Figure 5 , which is a schematic diagram of the jump connection method of the U-Net network architecture in the prior art.
[0087] Specifically, U-Net, as a general framework designed for image segmentation tasks, cleverly uses a top-down encoder path to extract multi-level feature representations in images. Subsequently, through a bottom-up decoder path, these learned features are mapped back to the original resolution, thereby achieving detailed pixel-level classification. In the U-Net network architecture, the skip connection acts as a bridge, connecting the corresponding levels between the encoder and the decoder. This connection method enables the decoder to directly use the feature information extracted by the encoder at an earlier level, which is crucial for improving segmentation accuracy and retaining more details.
[0088] The grain semantic segmentation model of the embodiment of the present invention includes an encoder that mainly extracts features of an input image, including edges, textures, shapes, etc., through a series of convolutional layers for subsequent image segmentation operations.
[0089] The grain semantic segmentation model of the embodiment of the present invention includes a decoder that gradually restores the original size of the feature map mainly through upsampling operations (such as transposed convolution or interpolation), and can map the abstract features extracted by the encoder part back to the size of the original image for pixel-level prediction.
[0090] In the prior art, when processing an attribute When the image is , the encoder directly inputs the attribute The image is extracted and the low-resolution attribute is input into the decoder. The image is decoded and upsampled, and the upsampled attributes are The properties of the image and encoder processing are The images are spliced to obtain an image with twice the channel dimension, that is, the image attribute is The channel dimension of the image obtained in this way is higher than that of the original image, and there is a difference in color from the original image, which may result in incorrect feature information when identifying damaged grain kernels.
[0091] In addition, although the skip connection mechanism in U-Net is a basic means of fusing shallow and deep features, in some cases, its simple fusion method may not be able to fully preserve the spatial location information in the image, which limits its segmentation effect to a certain extent.
[0092] In order to solve this problem, the present invention proposes an improved skip connection strategy, which is also called residual connection, and plays an important role in the deep neural network architecture. The core idea is to directly connect the input and output at a specific level in the network, so that information can flow directly between different network layers. This connection is usually achieved through an addition operation, that is, adding the input and output, so as to more effectively retain the spatial position information of the image, thereby improving the accuracy and effect of segmentation.
[0093] refer to Figure 6 , is a schematic diagram of a jump connection method provided in an embodiment of the present invention.
[0094] Step S601 first performs a BM (block merging) operation on the encoder to transform the input original feature map The spatial resolution is reduced by half, and the channel dimension is expanded to four times the original, resulting in a new feature map is the first feature map.
[0095] Step S602 performs feature fusion in the encoder, performs BR (Block Reverse) operation, and extracts the first feature map by interval extraction. The input attributes of half of the channels are feature map.
[0096] The encoder spatial resolution is then restored to the input, that is, the second feature map is output .
[0097] The BM operation corresponds to the BR operation, which can reduce network complexity, maintain network expressiveness, effectively reduce information loss, and provide accurate location information.
[0098] Step S603: Input a low-resolution feature map into the decoder. The spatial resolution of the low-resolution feature map is half of the original feature map. .
[0099] Step S604 reduces the channel dimension of the low-resolution feature map to half of the original channel dimension, i.e., the third feature map , and upsample the third feature map to obtain the fourth feature map .
[0100] As an optional embodiment, the second feature map and the fourth feature map are spliced to obtain a target feature map; wherein the target feature map represents the first edge feature or the second edge feature in the grain region.
[0101] By using the jump connection method provided by the embodiment of the present invention, the connection mechanism of the spatial position of the encoder and the decoder is optimized, which can not only retain a large number of original image features and ensure the integrity of image information, but also more accurately restore the resolution of the feature map during the upsampling stage, thereby significantly improving the quality of image reconstruction. In addition, the jump connection method provided by the embodiment of the present invention can well integrate the features of the encoder and the decoder, so that in the process of deepening the network depth, the detailed information lost by the network during the information transmission process is effectively reduced, while reducing the amount of calculation, improving the network's operating efficiency, so that it can complete high-quality image reconstruction in a shorter time.
[0102] Step S406, determining the centroid fusion coordinates according to the first centroid coordinates and the second centroid coordinates, and using the centroid fusion coordinates as the coordinates indicating the working point of the grain removal paddle.
[0103] Specifically, the centroid fusion coordinates are obtained by fusing the first centroid coordinates and the second centroid coordinates. Since the first centroid coordinates only represent the centroid coordinates of the kernel projection, and the second centroid coordinates only represent the centroid coordinates of the kernel non-damaged area, that is, the first centroid coordinates and the third centroid coordinates have large errors with the actual kernel centroid coordinates, and neither can represent the working point of grain fragment removal. Therefore, it is necessary to further calculate and process the first centroid coordinates and the second centroid coordinates to obtain the centroid fusion coordinates. The centroid fusion coordinates usually offset the area with larger mass. Therefore, when the area of the non-damaged area is larger, the mass of the non-damaged area will be greater, and the centroid fusion coordinates will be more biased towards the non-damaged area.
[0104] refer to Figure 7 , providing a schematic diagram of the center of mass positioning process of damaged grains in an embodiment of the present invention.
[0105] As an optional embodiment, the centroid fusion coordinates are calculated by the following formula:
[0106]
[0107]
[0108]
[0109] in, is the first centroid coordinate, is the coordinate of the second centroid, is the centroid fusion coordinate, is the correction coefficient of the valley mass center, The area of the grain area occupied by the undamaged part of a single grain. The area of the grain region for a single grain.
[0110] According to the calculation formula of the center of mass fusion coordinates, it can be concluded that according to the calculation formula of the center of mass correction coefficient, the larger the area of the non-damaged area, the larger the correction coefficient, and the center of mass will be closer to the non-damaged area or within the non-damaged area. When the correction coefficient is larger, the offset of the center of mass fusion coordinates relative to the second center of mass coordinates is smaller, that is, it is closer to the second center of mass; when the correction coefficient is smaller, the offset of the center of mass fusion coordinates relative to the second center of mass coordinates is larger, that is, it is farther away from the second center of mass coordinates.
[0111] After the first centroid coordinates are corrected according to the second centroid coordinates and the centroid fusion coordinates are obtained, the real-time distance between the centroid of the grain and the removal paddle can be re-determined. The specific formula is:
[0112]
[0113] in, is the real-time distance between the centroid of the kernel and the reject paddle, It is the distance between the visual center of the image recognition camera and the center of the rejection paddle. It is a fixed distance calibrated after the equipment is installed. is the abscissa of the standard centroid coordinates, is the abscissa of the second centroid coordinate, is the coefficient for converting the image pixel value coordinates into the actual physical size. In the embodiment of the present invention, 45 pixels represent 1 mm. = 1 / 45, which is 0.022.
[0114] refer to Figure 8 , which is a flow chart of sorting damaged grains provided in an embodiment of the present invention.
[0115] Specifically, when sorting damaged grains, first obtain the target grain image and input it to the image processing device, which determines whether the width of the single grain image is less than the width of the paddle; when the width of the target grain image is less than the width of the paddle, use the center of the target grain image as the centroid of the single grain, and use the center of the target grain image as the working point of the grain rejection paddle to reject the single grain. When the width of the single grain image is greater than the width of the paddle, determine whether the single grain is a damaged grain. If the single grain is a damaged grain, segment the non-damaged area of the grain area of the single grain, calculate the second centroid coordinate of the non-damaged area of the grain area, merge the first centroid coordinate with the second centroid coordinate to obtain the centroid fusion coordinate. Furthermore, the centroid fusion coordinate belongs to the centroid coordinate on the image level, which needs to be converted into physical coordinates, and the offset of the grain rejection paddle is calculated according to the physical coordinates, and the offset is sent to the sorting machine for execution.
[0116] refer to Fig. 9 , providing a schematic diagram of the trajectory of sorting damaged grains for an embodiment of the present invention.
[0117] The centroid fusion coordinates are obtained by fusion calculation of the damaged grains. The rejection action points of the sorting machine act on the physical points corresponding to the centroid fusion coordinates, so that the flight path of the damaged grain kernels is corrected, so that they can be correctly put into the corresponding receiving box.
[0118] From the above description, it can be seen that the present invention provides a method for locating the centroid of grains, firstly obtaining a target grain image through an image; wherein the target grain image includes a grain area that maps a single grain. Further, the width of the target grain image is compared with the width of the grain rejection paddle. If the width of the target grain image is less than the width of the grain rejection paddle, the center of the target grain image is directly used as the centroid. If the width of the target grain image is not less than the width of the grain rejection paddle, it is further determined whether the single grain is damaged. If the single grain is not a damaged grain, the centroid coordinates of the single grain are directly determined, and the centroid coordinates are used as the working point coordinates of the grain rejection paddle. If the single grain is a damaged grain, the centroid fusion coordinates are calculated based on the non-damaged part of the single grain, and the centroid fusion coordinates are used as the working point coordinates of the grain rejection paddle. The present invention can adopt different contour positioning and centroid calculation methods according to whether a single grain of grain is damaged. In the grain sorting process, especially when processing large-grain damaged grains, the centroid of the grain can be accurately positioned to avoid the problem of flying materials during sorting. The comprehensive accuracy of equipment sorting is significantly improved, and the accuracy of damaged grain kernel index calculation is improved. In addition, by introducing an optimized lightweight U-Net segmentation network and a centroid weighted fusion strategy, the accuracy of centroid positioning is further improved, and the dependence on computing resources is significantly reduced.
[0119] It should be noted that the method of the embodiment of the present invention can be performed by a single device, such as a computer or a server. The method of this embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present invention, and the multiple devices will interact with each other to complete the described method.
[0120] It should be noted that some embodiments of the present invention are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0121] Based on the same inventive concept, corresponding to the method provided in any of the above embodiments, the present invention also provides a device for locating the centroid of grains.
[0122] refer to Fig.10 , is a schematic diagram of a grain center of mass positioning device provided in an embodiment of the present invention.
[0123] The device comprises: an acquisition module 1001 , a first judgment module 1002 , a first response module 1003 , a second judgment module 1004 , a second response module 1005 , and a centroid fusion module 1006 .
[0124] The acquisition module 1001 is configured to acquire a target grain image; wherein the target grain image includes a grain area mapping a single grain;
[0125] A first determination module 1002 is configured to determine whether the width of the target grain image is smaller than the width of the grain rejection paddle;
[0126] The first response module 1003 is configured to perform contour positioning on the grain area if the width of the target grain image is not less than the width of the grain rejection paddle, and determine the first centroid coordinates of the single grain according to the result of the contour positioning;
[0127] The second determination module 1004 is configured to determine whether the single grain is a damaged grain;
[0128] The second response module 1005 is configured to perform contour positioning on the non-damaged portion in the grain area if the single grain is a damaged grain, and determine the second centroid coordinates of the non-damaged portion of the single grain according to the result of the contour positioning;
[0129] The centroid fusion module 1006 is configured to determine the centroid fusion coordinates according to the first centroid coordinates and the second centroid coordinates, and use the centroid fusion coordinates as the working point coordinates indicating the grain rejection paddle.
[0130] Optionally, the first determining module 1002 is further configured to:
[0131] If the width of the target grain image is smaller than the width of the grain rejection paddle, the center of the target grain image is used as the working point for indicating the grain rejection paddle to reject a single grain.
[0132] Optionally, the second determining module 1004 is further configured to:
[0133] If the single grain is not a damaged grain, the first centroid coordinate is used as the working point for indicating the grain rejection paddle to reject the single grain.
[0134] Optionally, the first response module 1003 is further configured to:
[0135] The target grain image is input into a pre-built grain semantic segmentation model, the first edge feature in the grain area is identified, and the first edge segmentation of the grain area is performed according to the first edge feature to obtain the result of contour positioning; wherein the first edge feature represents the overall edge contour of a single grain;
[0136] The centroid of the single grain is calculated based on the result of contour positioning to obtain the first centroid coordinates.
[0137] Optionally, the second response module 1005 is further configured to:
[0138] The target grain image is input into a pre-built grain semantic segmentation model, the second edge feature in the grain area is identified, and the second edge segmentation of the grain area is performed according to the second edge feature to obtain the result of contour positioning; wherein the second edge feature represents the partial edge contour of the non-damaged part of a single grain;
[0139] The centroid of the non-damaged part of the single grain is calculated based on the result of the contour positioning to obtain the second centroid coordinates.
[0140] Optionally, the grain semantic segmentation model includes an encoder and a decoder;
[0141] The input of the encoder is the original feature map of the target grain image;
[0142] The encoder is used to reduce the spatial resolution of the original feature map by half and expand the channel dimension to four times the original to obtain the first feature map; half of the channels of the first feature map are extracted at intervals to restore the spatial resolution of the encoder to obtain the second feature map;
[0143] The input of the decoder is a low-resolution feature map of the target grain image; the spatial resolution of the low-resolution feature map is half of the original feature map;
[0144] The decoder is used to reduce the channel dimension of the low-resolution feature map to half of the original one to obtain a third feature map; upsample the third feature map to obtain a fourth feature map; wherein the spatial resolution and channel dimension of the fourth feature map are the same as those of the second feature map.
[0145] Optionally, the centroid fusion module 1006 is further configured to:
[0146] The second feature map and the fourth feature map are spliced to obtain a target feature map; wherein the target feature map represents the first edge feature or the second edge feature in the grain region.
[0147] Optionally, the centroid fusion coordinates are calculated using the following formula:
[0148]
[0149]
[0150]
[0151] in, is the first centroid coordinate, is the coordinate of the second centroid, is the centroid fusion coordinate, is the correction coefficient of the valley mass center, The area of the grain area occupied by the undamaged part of a single grain. The area of the grain region for a single grain.
[0152] According to a centroid positioning device for grains of an embodiment of the present invention, a target grain image is first obtained through an image; wherein the target grain image includes a grain area that maps a single grain. Further, the width of the target grain image is compared with the width of the grain rejection paddle. If the width of the target grain image is less than the width of the grain rejection paddle, the center of the target grain image is directly used as the centroid. If the width of the target grain image is not less than the width of the grain rejection paddle, it is further determined whether the single grain is damaged. If the single grain is not a damaged grain, the centroid coordinates of the single grain are directly determined, and the centroid coordinates are used as the working point coordinates of the grain rejection paddle. If the single grain is a damaged grain, the centroid fusion coordinates are calculated based on the non-damaged part of the single grain, and the centroid fusion coordinates are used as the working point coordinates of the grain rejection paddle. The present invention can adopt different contour positioning and centroid calculation methods according to whether a single grain of grain is damaged. In the grain sorting process, especially when processing large-grain damaged grains, the centroid of the grain can be accurately positioned to avoid the problem of flying materials during sorting. The comprehensive accuracy of equipment sorting is significantly improved, and the accuracy of damaged grain kernel index calculation is improved. In addition, by introducing an optimized lightweight U-Net segmentation network and a centroid weighted fusion strategy, the accuracy of centroid positioning is further improved, and the dependence on computing resources is significantly reduced.
[0153] For the convenience of description, the above system is described as being divided into various modules according to their functions. Of course, when implementing the present invention, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0154] The system of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0155] Based on the same inventive concept, corresponding to the method described in any of the above embodiments, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any of the above embodiments when executing the program.
[0156] Fig.11A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1110, a memory 1120, an input / output interface 1130, a communication interface 1140, and a bus 1150. The processor 1110, the memory 1120, the input / output interface 1130, and the communication interface 1140 are connected to each other through the bus 1150 in the device.
[0157] The processor 1110 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0158] The memory 1120 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1120 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1120 and are called and executed by the processor 1110.
[0159] The input / output interface 1130 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0160] The communication interface 1140 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0161] The bus 1150 includes a path that transmits information between the various components of the device (eg, the processor 1110 , the memory 1120 , the input / output interface 1130 , and the communication interface 1140 ).
[0162] It should be noted that, although the above device only shows the processor 1110, the memory 1120, the input / output interface 1130, the communication interface 1140 and the bus 1150, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0163] The electronic device of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0164] Based on the same inventive concept, corresponding to the method described in any of the above embodiments, the present invention also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in any of the above embodiments.
[0165] The above-mentioned non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0166] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the method described in any embodiment of the above exemplary method part, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0167] In addition, although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flow chart can be performed in a different order. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0168] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0169] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the embodiments of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0170] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and this division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims. The scope of the attached claims conforms to the broadest interpretation, thereby including all such modifications and equivalent structures and functions.
Claims
1. A method for locating the centroid of grains, characterized in that: include: Acquire a target grain image; wherein the target grain image includes a grain area mapping a single grain; Determining whether the width of the target grain image is less than the width of the grain rejection paddle; If the width of the target grain image is not less than the width of the grain removal paddle, contour positioning is performed on the grain area, and the first centroid coordinates of the single grain are determined according to the contour positioning result, including: Input the target grain image into a pre-built grain semantic segmentation model, identify a first edge feature in the grain region, perform a first edge segmentation on the grain region according to the first edge feature, and obtain a contour positioning result; wherein the first edge feature represents the overall edge contour of a single grain; Calculating the center of mass of the single grain based on the result of the contour positioning to obtain the first center of mass coordinates; determining whether the single grain is a damaged grain; If the single grain is a damaged grain, contour positioning is performed on the non-damaged part in the grain region, and the second centroid coordinates of the non-damaged part of the single grain are determined according to the result of contour positioning, including: inputting the target grain image into a pre-constructed grain semantic segmentation model, identifying a second edge feature in the grain region, performing a second edge segmentation on the grain region according to the second edge feature, and obtaining a result of contour positioning; wherein the second edge feature represents a partial edge contour of the non-damaged part of the single grain; Calculating the center of mass of the non-damaged portion of the single grain based on the result of the contour positioning to obtain the second center of mass coordinates; The center of mass fusion coordinates are determined according to the first center of mass coordinates and the second center of mass coordinates, and the center of mass fusion coordinates are used as the coordinates of the working point indicating the grain rejection paddle, wherein the center of mass fusion coordinates are calculated by the following formula: in, is the first centroid coordinate, is the coordinate of the second centroid, is the centroid fusion coordinate, is the correction coefficient of the valley mass center, The area of the grain area occupied by the undamaged part of a single grain. The area of the grain region for a single grain.
2. The method for locating the centroid of grains according to claim 1, characterized in that: The method further comprises: If the width of the target grain image is smaller than the width of the grain rejection paddle, the center of the target grain image is used as a working point to indicate the grain rejection paddle to reject the single grain.
3. The method for locating the centroid of grains according to claim 1, characterized in that: The method further comprises: If the single grain is not a damaged grain, the first centroid coordinate is used as a working point to instruct the grain rejecting paddle to reject the single grain.
4. The method for locating the centroid of grains according to claim 1, characterized in that: The grain semantic segmentation model includes an encoder and a decoder; The input of the encoder is the original feature map of the target grain image; The encoder is used to reduce the spatial resolution of the original feature map by half and expand the channel dimension to four times the original, so as to obtain a first feature map; Extracting half of the channels of the first feature map at intervals to restore the spatial resolution of the encoder, thereby obtaining a second feature map; The input of the decoder is a low-resolution feature map of the target grain image; the spatial resolution of the low-resolution feature map is half of the original feature map; The decoder is used to reduce the channel dimension of the low-resolution feature map to half of the original one to obtain a third feature map; upsample the third feature map to obtain a fourth feature map; wherein the spatial resolution and channel dimension of the fourth feature map are the same as those of the second feature map.
5. The method for locating the centroid of grains according to claim 4, characterized in that: The method further comprises: The second feature map and the fourth feature map are spliced to obtain a target feature map; wherein the target feature map represents the first edge feature or the second edge feature in the grain region.
6. A device for locating the centroid of grains, characterized in that: include: An acquisition module is configured to acquire a target grain image; wherein the target grain image includes a grain area mapping a single grain; A first judgment module is configured to determine whether the width of the target grain image is smaller than the width of the grain rejection paddle; The first response module is configured to perform contour positioning on the grain area if the width of the target grain image is not less than the width of the grain rejection paddle, and determine the first centroid coordinates of the single grain according to the result of contour positioning, including: Input the target grain image into a pre-built grain semantic segmentation model, identify a first edge feature in the grain region, perform a first edge segmentation on the grain region according to the first edge feature, and obtain a contour positioning result; wherein the first edge feature represents the overall edge contour of a single grain; Calculating the center of mass of the single grain based on the result of the contour positioning to obtain the first center of mass coordinates; A second judgment module is configured to determine whether the single grain is a damaged grain; The second response module is configured to, if the single grain is a damaged grain, perform contour positioning on the non-damaged part in the grain area, and determine the second centroid coordinates of the non-damaged part of the single grain according to the result of contour positioning, including: inputting the target grain image into a pre-constructed grain semantic segmentation model, identifying a second edge feature in the grain area, performing a second edge segmentation on the grain area according to the second edge feature, and obtaining a result of contour positioning; wherein the second edge feature represents a partial edge contour of the non-damaged part of the single grain; Calculating the center of mass of the non-damaged portion of the single grain based on the result of the contour positioning to obtain the second center of mass coordinates; The centroid fusion module is configured to determine the centroid fusion coordinates according to the first centroid coordinates and the second centroid coordinates, and use the centroid fusion coordinates as the working point coordinates of the grain rejection paddle, wherein the centroid fusion coordinates are calculated by the following formula: in, is the first centroid coordinate, is the coordinate of the second centroid, is the centroid fusion coordinate, is the correction coefficient of the valley mass center, The area of the grain area occupied by the undamaged part of a single grain. The area of the grain region for a single grain.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for locating the center of mass of grains as described in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for locating the center of mass of grains as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Visual cooperative target feature point positioning method based on gray centroid extraction algorithm
CN116883498A
Centroid processing
US20100239139A1