A method, device and storage medium for obtaining target tobacco leaf ID
Through the target SAM model, the image segmentation of the drone aerial images is obtained, and the ID of the tobacco leaf leaves and the center point of the tobacco plant is solved, and the problem of difficulty in segmenting a single plant is achieved, which can achieve efficient and accurate segmentation and extraction of tobacco plants, satisfying large-scale , high efficiency and high precision requirements.
Patent Information
- Application Number
- CN202410513887.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-04-26
AI Technical Summary
The existing image segmentation method is difficult to effectively apply to the single-plane segmentation of tobacco plants on aerial images of drones. Due to irregular shapes, different sizes, uneven colors, different leaves of different tobacco plants block each other, and between tobacco plants. Similarity and other influences, and manual collection and statistical methods are time-consuming and labor-intensive, and there are uncontrollable and subjective errors, making it difficult to meet the needs of large-scale, high-efficiency and high-precision cigarette segmentation.
The target SAM (Segment Anything Model) model is used to segment the orthochrome image to obtain the initial spot ID list, and further obtain the target tobacco leaf leaf ID list based on the tobacco leaf pattern ID and the center point ID of the target tobacco plant to realize the tobacco plant The segmentation and extraction of individual plants does not require manual consideration of factors such as the shape, size, color, occlusion and shadow of tobacco leaves.
It realizes efficient and precise single-plant segmentation and extraction of tobacco plants in drone aerial images, meets the needs of large-scale, high efficiency and high precision, and reduces manual intervention and errors.
Smart Images

Figure CN118396955B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device and storage medium for obtaining a target tobacco leaf ID. Background Art
[0002] Tobacco yield, quality and variety have an important impact on the development of the tobacco industry. In order to effectively monitor and manage tobacco planting, it is necessary to accurately evaluate and predict the growth status of tobacco. Among them, the number, density, height, leaf area and other single-plant traits of tobacco plants are important indicators reflecting the growth status of tobacco, and are also the basic data for calculating tobacco yield and evaluating tobacco quality. With the development of remote sensing technology, drone aerial photography technology has gradually become an important means of tobacco monitoring. Drone aerial photography technology has the advantages of low cost, high resolution, good timeliness and flexible operation. It can obtain high-definition images of tobacco fields and segment individual tobacco plants. It provides a better data source. However, the segmentation of individual tobacco plants in drone aerial images still faces some challenges, such as the irregular shape, different sizes, uneven colors of tobacco leaves, mutual occlusion between leaves of different tobacco plants, and high similarity between tobacco plants. The existing image segmentation methods are difficult to be effectively applied to the segmentation of individual tobacco plants in drone images. Therefore, achieving the segmentation and extraction of individual tobacco plants is one of the key technologies for tobacco remote sensing monitoring. The segmentation and extraction of individual tobacco plants can be understood as obtaining the tobacco leaves of a single tobacco plant. The methods for achieving the segmentation and extraction of individual tobacco plants in the existing technology mainly rely on manual collection and statistics.
[0003] However, the above method also has the following technical problems:
[0004] It is very difficult to achieve individual tobacco plant segmentation through drone aerial images. It is necessary to consider the irregular shape, size, color, mutual occlusion between leaves of different tobacco plants, and high similarity between tobacco plants. The existing image segmentation methods are difficult to effectively apply to the segmentation of individual tobacco plants in drone images. It is very time-consuming and labor-intensive to achieve the segmentation and extraction of individual tobacco plants through manual collection and statistics. In addition, manual collection and statistics are uncontrollable. The subjective errors of the data obtained through manual statistics and collection are large, which makes it difficult to meet the needs of large-scale, high-efficiency and high-precision tobacco plant segmentation. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is:
[0006] According to a first aspect of the present invention, a method for obtaining a target tobacco leaf ID is provided, wherein the target tobacco leaf ID is a unique identification of the target tobacco leaf, the target tobacco leaf is a tobacco leaf on a target tobacco plant, and the target tobacco plant is a single tobacco plant planted in a target area, and the method comprises the following steps:
[0007] S1. Obtain an orthophoto color image A corresponding to the target area.
[0008] S2. Perform image segmentation on A according to the target SAM (Segment Anything Model) model to obtain the initial spot ID list B corresponding to A = {B1, B2, ..., B i , ..., B m}, where the initial spot ID is the unique identity of the initial spot, and the initial spot is the spot obtained by segmenting A according to the target SAM (Segment Anything Model) model, and B i is the initial spot ID of the i-th initial spot corresponding to A, i ranges from 1 to m, and m is the number of initial spots corresponding to A; before step S2, the target SAM (Segment Anything Model) is obtained through the following steps S10-S30:
[0009] S10. Obtain an initial SAM (Segment Anything Model) model.
[0010] S20. Adjust the parameter value of the first preset parameter in the initial SAM (Segment Anything Model) model to the first preset parameter value, adjust the parameter value of the second preset parameter to the second preset parameter value, and adjust the parameter value of the third preset parameter to α to obtain an intermediate SAM (Segment Anything Model) model, where the first preset parameter is a parameter for controlling the number of cropping layers used by the model when using the interactive mode of the frame, the second preset parameter is a parameter for controlling the downsampling factor of the pixels used by the model when using the interactive mode of the frame, the downsampling factor is a parameter for controlling the degree of downsampling, α is the third preset parameter value, and the third preset parameter is a parameter for filtering fine patches with too small an area.
[0011] S30, adjusting the parameter value of the fourth preset parameter in the intermediate SAM (Segment Anything Model) model to its corresponding fourth preset parameter value, where the fourth preset parameter is a parameter used to segment the image spots and is different from the first preset parameter, the second preset parameter, and the third preset parameter.
[0012] S3, according to B, obtain the tobacco leaf spot ID list C corresponding to A = {C1, C2, ..., C j , ..., C n}, where C jis the tobacco leaf spot ID of the j-th tobacco leaf spot corresponding to A, the value of j is 1 to n, n is the number of tobacco leaf spots corresponding to A, and the tobacco leaf spot ID is the unique identity of the tobacco leaf spot.
[0013] S4. Obtain the target tobacco plant center point ID list D = {D1, D2, ..., D e , ..., D f}, where D e is the target tobacco plant center point ID corresponding to the e-th target tobacco plant, the value of e ranges from 1 to f, f is the number of target tobacco plants, the target tobacco plant center point ID is the unique identity identifier of the target tobacco plant center point, and the target tobacco plant center point is the center point of the target tobacco plant.
[0014] S5. Obtain the target tobacco leaf ID list set E={E1, E2, ..., E e ,……,E f}, E e ={E e1 , E e2 ,……,E er ,……,E es(e)}, where E e D e The target tobacco leaf ID list corresponding to the target tobacco plant, E er D e The target tobacco leaf ID of the rth target tobacco leaf on the corresponding target tobacco plant, r ranges from 1 to s(e), s(e) is D e The number of target tobacco leaves on the corresponding target tobacco plants.
[0015] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, in which a computer program or at least one computer-executable instruction is stored. The computer program or at least one computer-executable instruction is loaded and executed by a processor to implement the aforementioned method.
[0016] According to a third aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned method when executing the computer program.
[0017] The present invention has at least the following beneficial effects:
[0018] The present invention provides a method, device and storage medium for obtaining the ID of a target tobacco leaf. The method can obtain an orthophoto color image corresponding to the target area, and according to the target SAM (Segment Anything The target tobacco leaf ID list is obtained by using a target SAM model and an orthophoto color image, a tobacco leaf spot ID list is obtained according to the initial spot ID list, a target tobacco plant center point ID list is obtained, and a target tobacco leaf ID list set is obtained according to the tobacco leaf spot ID list and the target tobacco plant center point ID list. The target tobacco leaf ID list set includes a target tobacco leaf ID list corresponding to several target tobacco plants. The target tobacco leaf ID list includes several target tobacco leaf IDs. The target tobacco leaf ID is a unique identity identifier of the target tobacco leaf. It can be seen that the present invention can perform image segmentation on the orthophoto color image through the target SAM model, further obtain the tobacco leaf spot ID, and obtain the target tobacco leaf ID list corresponding to the target tobacco plant based on the tobacco leaf spot ID and the target tobacco plant center point ID. The single tobacco plant segmentation and extraction can be achieved without relying on manual labor or considering the influencing factors such as the shape, size, color, occlusion and shadow of the tobacco leaf, and can meet the large-scale, high-efficiency and high-precision tobacco plant segmentation requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A flowchart of a method for obtaining a target tobacco leaf ID provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar tasks, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0023] The present invention provides a method for obtaining a target tobacco leaf ID, wherein the target tobacco leaf ID is a unique identification of the target tobacco leaf, the target tobacco leaf is a tobacco leaf on a target tobacco plant, and the target tobacco plant is a single tobacco plant planted in a target area. The method comprises the following steps: Figure 1 As shown:
[0024] S1. Obtain an orthophoto color image A corresponding to a target area, wherein the target area is a geographical area set by a person skilled in the art for growing tobacco crops according to actual needs; for example, a piece of land for growing tobacco crops.
[0025] Specifically, step S1 includes the following sub-steps S11-S12:
[0026] S11. Based on RTK positioning technology and target UAV, a plurality of multispectral images corresponding to the target area collected by the target UAV within a preset time slice are obtained, wherein the preset time slice is a time slice pre-set by a person skilled in the art according to actual needs. A person skilled in the art knows that any method for acquiring images based on RTK technology and UAV in the prior art belongs to the protection scope of the present invention and will not be described in detail herein.
[0027] Specifically, the target drone is a multispectral drone, such as a DJI Mavic 3M aerial survey drone.
[0028] Optionally, the start time point of the preset time slice is 10:00:00 and the end time point is 14:00:00.
[0029] Optionally, when the target UAV is collecting multispectral images, its flight altitude is set to a position of 20 meters from the ground.
[0030] S12. Obtain A according to the multispectral data corresponding to the plurality of multispectral images, wherein those skilled in the art know that any method of obtaining an orthophoto color image according to multispectral data in the prior art falls within the protection scope of the present invention and will not be described in detail herein.
[0031] Through the above steps, the target UAV is a multispectral UAV, which is highly flexible and can be used for remote sensing monitoring of agriculture and forestry. The airborne multispectral sensor in the multispectral UAV can accurately capture multispectral data containing spectral and texture information of crops. Positioning based on RTK positioning technology can ensure that the target UAV is accurately positioned when collecting images, and an orthophoto color image is obtained according to the multispectral data corresponding to the multispectral image collected by the target UAV, which is conducive to improving the accuracy of obtaining the orthophoto color image.
[0032] S2. Perform image segmentation on A according to the target SAM (Segment Anything Model) model to obtain the initial spot ID list B corresponding to A = {B1, B2, ..., B i , ..., B m}, where B i is the initial spot ID of the i-th initial spot corresponding to A, the value of i ranges from 1 to m, and m is the number of initial spots corresponding to A.
[0033] Specifically, the initial spot ID is a unique identification of the initial spot, and the initial spot is a spot obtained by performing image segmentation on A according to the target SAM (Segment Anything Model) model.
[0034] Specifically, before step S2, the target SAM (Segment Anything Model) model is obtained through the following steps S10-S30:
[0035] S10. Obtain an initial SAM (Segment Anything Model) model, where the initial SAM (Segment Anything Model) model is a SAM (Segment Anything Model) model in the prior art.
[0036] S20, adjusting the parameter value of the first preset parameter in the initial SAM (Segment Anything Model) model to the first preset parameter value, adjusting the parameter value of the second preset parameter to the second preset parameter value, and adjusting the parameter value of the third preset parameter to α to obtain an intermediate SAM (Segment Anything Model) model, wherein the first preset parameter is a parameter for controlling the number of cropping layers used by the model when using the interactive mode of the frame, and the second preset parameter is a parameter for controlling the downsampling factor of the pixel points used by the model when using the interactive mode of the frame, and the downsampling factor is a parameter for controlling the degree of downsampling, and α is a third preset parameter value, and the third preset parameter is a parameter for filtering fine and fragmented patches with too small an area, and α meets the following conditions:
[0037] α=β / fb 2 , wherein β is the preset minimum tobacco leaf area, the unit of measurement of the preset minimum tobacco leaf area is square meters, fb is the image resolution of A, and the unit of measurement of the image resolution is meter. Those skilled in the art know that the specific value of the preset minimum tobacco leaf area is set by those skilled in the art according to actual needs. Any method of obtaining the image resolution of an image in the prior art belongs to the protection scope of the present invention and will not be repeated here.
[0038] Specifically, the value range of the first preset parameter value is (1.5, 2.5).
[0039] Preferably, the first preset parameter value is 2. The first preset parameter is a parameter for controlling the number of cropping layers used by the model when using the interactive mode of the frame. It can be understood that: the model will divide the image into multiple sub-regions according to the parameter value of the first preset parameter, and perform segmentation on each sub-region. The larger the parameter value of the first preset parameter, the more sub-regions the model uses, the higher the segmentation accuracy, and the longer the time required. When the first preset parameter value is 2, the segmentation accuracy of the model can be higher and the time consumed is shorter, which can improve the model performance.
[0040] Specifically, the value range of the second preset parameter value is (0.5, 1.5).
[0041] Preferably, the second preset parameter value is 1. The second preset parameter is a parameter for controlling the downsampling factor of the pixel points used by the model when using the interactive mode of the frame. It can be understood that: the model will use the interactive mode of points to segment each sub-area. The larger the parameter value of the second preset parameter, the fewer points the model uses in each sub-area, and the faster the segmentation speed, but the segmentation accuracy will also be reduced. When the second preset parameter value is 1, the segmentation speed of the model can be faster while ensuring the segmentation accuracy is higher, which can improve the model performance.
[0042] S30. Adjust the parameter value of the fourth preset parameter in the intermediate SAM (Segment Anything Model) model to its corresponding fourth preset parameter value, wherein the fourth preset parameter is a parameter used to segment the pattern and is different from the first preset parameter, the second preset parameter, and the third preset parameter. Those skilled in the art know that the fourth preset parameter value corresponding to the fourth preset parameter is set by those skilled in the art according to actual needs and will not be repeated here.
[0043] With the development of remote sensing technology, drone aerial photography technology has gradually become an important means of tobacco monitoring. Drone aerial photography technology has the advantages of low cost, high resolution, good timeliness, and flexible operation. It can obtain high-definition images of tobacco fields and provide a better data source for individual tobacco plant segmentation. However, the segmentation of individual tobacco plants through drone aerial images will be affected by some factors, such as irregular shapes, different sizes, and uneven colors of tobacco leaves, mutual occlusion between leaves of different tobacco plants, and high similarity between tobacco plants. Existing image segmentation methods are difficult to effectively apply to the segmentation of individual tobacco plants on drone images.
[0044] Through the above steps, the parameter values of the first preset parameter, the second preset parameter and the third preset parameter in the initial SAM (Segment Anything Model) model are adjusted to obtain the intermediate SAM (Segment Anything Model) model, and the parameter value of the fourth preset parameter in the intermediate SAM (Segment Anything Model) model is adjusted to obtain the target SAM (Segment Anything Model) model, the fourth preset parameter is a parameter used to segment the image spots and is different from the first preset parameter, the second preset parameter and the third preset parameter, and the SAM (Segment Anything Model) model can be optimized by adjusting the parameter values to obtain the target SAM (Segment Anything Model) model, and according to the target SAM (Segment Anything Model) model, The orthophoto color image is segmented by a model to obtain initial spots, which can improve the accuracy of obtaining the initial spots and can obtain the initial spots without considering the influencing factors such as the shape, size, color, occlusion and shadow of the tobacco leaves. The tobacco leaf spot ID is obtained according to the initial spot ID of the initial spot, and the target tobacco leaf ID list corresponding to the target tobacco plant is further obtained according to the tobacco leaf spot ID and the target tobacco plant center point ID. The single tobacco plant segmentation and extraction can be achieved without relying on manual work or considering the influencing factors such as the shape, size, color, occlusion and shadow of the tobacco leaves, which can meet the large-scale, high-efficiency and high-precision tobacco plant segmentation needs.
[0045] S3, according to B, obtain the tobacco leaf spot ID list C corresponding to A = {C1, C2, ..., C j , ..., C n}, where C j is the tobacco leaf spot ID of the j-th tobacco leaf spot corresponding to A, the value of j is 1 to n, n is the number of tobacco leaf spots corresponding to A, and the tobacco leaf spot ID is the unique identity of the tobacco leaf spot.
[0046] Specifically, each tobacco leaf pattern corresponds to a tobacco leaf in a target area.
[0047] Specifically, step S3 also includes the following sub-steps S31-S35:
[0048] S31. Get B i The corresponding first vegetation index list F i ={F i1 , F i2 , ..., F ig , ..., F ih(i)}, where F ig For B i The first vegetation index corresponding to the g-th pixel in the corresponding initial patch, the value of g ranges from 1 to h(i), h(i) is B i The number of pixels in the corresponding initial spot, F ig Meet the following conditions:
[0049] F ig =2×ρ1 ig -ρ2 ig -ρ3 ig , where ρ1 ig For B i The green band reflectivity of the g-th pixel in the corresponding initial image spot, ρ2 ig For B i The red band reflectivity of the g-th pixel in the corresponding initial image spot, ρ3 ig For B i The blue band reflectivity of the g-th pixel point in the corresponding initial image patch, wherein those skilled in the art know that any method of obtaining the green band reflectivity, red band reflectivity and blue band reflectivity of a pixel point in the prior art falls within the protection scope of the present invention and will not be repeated here.
[0050] S32, get B i The corresponding second vegetation index F 0 i , where F 0 i Meet the following conditions:
[0051] F 0 i =∑ h(i) g=1 F ig / h(i).
[0052] S33, B i The average value of the RGB values of all pixels in the corresponding initial image spot is taken as B i The corresponding average RGB value G i .
[0053] S34, F 0 i and G i Input into the target classification model to obtain B i The corresponding spot type label H i .
[0054] Specifically, step S34 also includes the following steps to obtain the target classification model S341-S343:
[0055] S341, obtaining a preset tobacco leaf spot data list, wherein the preset tobacco leaf spot data list includes a plurality of preset tobacco leaf spot data, wherein the preset tobacco leaf spot data is data of preset tobacco leaf spots, and the preset tobacco leaf spot data includes key vegetation indices and average RGB values corresponding to the preset tobacco leaf spots, wherein the method for obtaining the key vegetation indices and average RGB values corresponding to the preset tobacco leaf spots is the same as that for obtaining B in steps S31-S33. i The method of obtaining the corresponding second vegetation index and average RGB value is basically the same. Those skilled in the art can refer to steps S31-S33 to obtain the key vegetation index and average RGB value corresponding to the preset tobacco leaf pattern, which will not be repeated here; it can be understood that the B in step S31 is i The corresponding initial pattern is replaced with the preset tobacco leaf pattern and steps S31-S33 are executed.
[0056] S342, obtaining a preset non-tobacco leaf spot data list, wherein the preset non-tobacco leaf spot data list includes a plurality of preset non-tobacco leaf spot data, wherein the preset non-tobacco leaf spot data is the data of the preset non-tobacco leaf spot, and the preset non-tobacco leaf spot data includes the key vegetation index and the average RGB value corresponding to the preset non-tobacco leaf spot, wherein the method for obtaining the key vegetation index and the average RGB value corresponding to the preset non-tobacco leaf spot is the same as that for obtaining B in steps S31-S33. i The method of obtaining the corresponding second vegetation index and average RGB value is basically the same. Those skilled in the art can refer to steps S31-S33 to obtain the key vegetation index and average RGB value corresponding to the preset non-tobacco leaf patch, which will not be repeated here; it can be understood that the B in step S31 isi The corresponding initial image spots are replaced with preset non-tobacco leaf image spots and steps S31-S33 are performed.
[0057] Specifically, the preset tobacco leaf pattern and the preset non-tobacco leaf pattern are patterns pre-set by those skilled in the art, and will not be described in detail here.
[0058] S343. Use the preset tobacco leaf pattern data list and the preset non-tobacco leaf pattern data list as training samples of the preset classification model to train the preset classification model to obtain a target classification model, wherein the preset classification model is a classification model pre-set by a technician in this field. The technicians in this field know that any method in the prior art for training a model according to training samples to obtain a new model falls within the scope of protection of the present invention and will not be repeated here.
[0059] Optionally, the preset classification model is a random forest classifier.
[0060] Specifically, the output result of the target classification model is a patch type label.
[0061] Through the above steps, a preset tobacco leaf spot data list and a preset non-tobacco leaf spot data list are obtained, and the preset tobacco leaf spot data list and the preset non-tobacco leaf spot data list are used as training samples of the preset classification model to train the preset classification model to obtain the target classification model, and the spot type label corresponding to the initial spot ID is obtained according to the target classification model, which is conducive to improving the accuracy of obtaining the spot type label corresponding to the initial spot ID.
[0062] S35, when H i =TB, B i The corresponding initial image spot is used as the tobacco leaf image spot corresponding to A and B i The tobacco leaf pattern ID of the tobacco leaf pattern is used to obtain C, wherein TB is a preset pattern type label, wherein the preset pattern type label is a pattern type label pre-set by technicians in this field according to actual needs, and will not be repeated here.
[0063] Through the above steps, the second vegetation index and average RGB value corresponding to the initial spot ID are obtained, the second vegetation index and average RGB value are input into the target model to obtain the spot type label corresponding to the initial spot ID, the spot type label is compared with the preset spot type label to obtain the tobacco leaf spot ID, which is conducive to improving the accuracy of obtaining the tobacco leaf spot ID.
[0064] S4. Obtain the target tobacco plant center point ID list D = {D1, D2, ..., D e , ..., D f}, where De is the target cigarette plant center point ID corresponding to the e-th target cigarette plant, the value of e is 1 to f, f is the number of target cigarette plants, the target cigarette plant center point ID is the unique identity identifier of the target cigarette plant center point, and the target cigarette plant center point is the center point of the target cigarette plant. Those skilled in the art know that any method for obtaining the center point of a cigarette plant in the prior art belongs to the protection scope of the present invention and will not be repeated here.
[0065] S5. Obtain the target tobacco leaf ID list set E={E1, E2, ..., E e ,……,E f}, E e ={E e1 , E e2 ,……,E er ,……,E es(e)}, where E e D e The target tobacco leaf ID list corresponding to the target tobacco plant, E er D e The target tobacco leaf ID of the rth target tobacco leaf on the corresponding target tobacco plant, r ranges from 1 to s(e), s(e) is D e The number of target tobacco leaves on the corresponding target tobacco plants.
[0066] Specifically, step S5 includes the following sub-steps S51-S56:
[0067] S51, obtain the leaf pattern center point ID list J corresponding to C = {J1, J2, ..., J j , ..., J n}, where J j C j The corresponding leaf pattern center point ID, the leaf pattern center point ID is the unique identity identifier of the leaf pattern center point, and the leaf pattern center point is the center point of the tobacco leaf pattern. Those skilled in the art know that any method of obtaining the center point of the pattern in the prior art belongs to the protection scope of the present invention and will not be repeated here.
[0068] S52, obtain the designated area ID list K corresponding to J = {K1, K2, ..., K j , ..., K n}, where K j For J j The corresponding designated area ID, which is the unique identifier of the designated area. j The corresponding designated area ID corresponds to the designated area in the target area. jThe corresponding location in the target area is the center of the circle, and the radius is the preset distance YR. YR meets the following conditions:
[0069] YR=γ×ZJ, wherein γ is a preset adjustment parameter for adjusting the preset distance, and ZJ is a preset plant spacing. The preset plant spacing can be understood as the preset distance between two adjacent tobacco plants. Those skilled in the art know that the preset plant spacing is set by those skilled in the art according to actual needs and will not be elaborated here.
[0070] Specifically, the value range of γ is [1.3, 1.6].
[0071] S53, traverse D and K, when D e The corresponding target tobacco plant center point is at K j When the corresponding specified area is within the range, D e The corresponding target tobacco plant center point is J j The corresponding first designated tobacco plant center point and D e As the first designated tobacco plant center point ID of the first designated tobacco plant center point, obtain the first designated tobacco plant center point ID list set L corresponding to J = {L1, L2, . . . , L j , ..., L n}, L j= {L j1 , L j2 , ..., L jx , ..., L jp(j)}, where L j For J j The corresponding first designated tobacco plant center point ID list, L jx For J j The first designated tobacco plant center point ID of the corresponding x-th first designated tobacco plant center point, where x ranges from 1 to p(j), and p(j) is J j The number of the center points of the corresponding first specified tobacco plant.
[0072] S54. According to J and L, obtain the first center point distance list set M corresponding to J = {M1, M2, ..., M j , ..., M n},M j ={M j1 , M j2 , ..., M jx , ..., M jp(j)},M j For J j The corresponding first center point distance list, M jx For J j and L jx The corresponding first center point distance, J j and Ljx The corresponding first center point distance is J j The corresponding location and L in the target area jx The straight-line distance between the center points of the corresponding first designated tobacco plants, wherein those skilled in the art know that any method of obtaining the straight-line distance between two points in an area in the prior art falls within the protection scope of the present invention and will not be described in detail here.
[0073] S55, when M jx =min(M j1 , M j2 , ..., M jx , ..., M jp(j) ), M jx The corresponding L jx As J j The corresponding second designated tobacco plant center point ID, M jx As J j The corresponding second center point distance is used to obtain the second designated tobacco plant center point ID list N={N1, N2, ..., N j , ..., N n} and J corresponding to the second center point distance list N 0 = {N 0 1, N 0 2, ..., N 0 j , ..., N 0 n}, where N j For J j The corresponding second designated tobacco plant center point ID, N 0 j For J j The corresponding second center point distance, min() is the minimum value acquisition function.
[0074] S56, traverse N and D, when N j =D e When C j The corresponding tobacco leaf in the target area is taken as D e The target tobacco leaf on the corresponding target tobacco plant is C j The tobacco leaf ID of the corresponding tobacco leaf is used as the target tobacco leaf ID of the target tobacco leaf to obtain E e .
[0075] Specifically, a tobacco leaf ID is set for each tobacco leaf in the target area, and the tobacco leaf IDs of any two tobacco leaves in the target area are different.
[0076] Through the above steps, the leaf pattern center point ID and the designated area ID corresponding to the leaf pattern center point ID are obtained, and according to the target tobacco plant center point ID and the designated area ID, the first designated tobacco plant center point ID list corresponding to the leaf pattern center point ID is obtained, and according to the leaf pattern center point ID and the leaf pattern center point ID list, the second designated tobacco plant center point ID corresponding to the leaf pattern center point ID is obtained. It can be understood that the first designated tobacco plant center point ID closest to the location corresponding to the leaf pattern center point in the target area is used as the leaf pattern center point. the second designated tobacco plant center point ID corresponding to the leaf pattern spot center point ID; when the target tobacco plant center point ID is the same as the second designated tobacco plant center point ID, the tobacco leaf blade corresponding to the leaf pattern spot ID corresponding to the second designated tobacco plant center point ID in the target area is used as the target tobacco leaf blade on the target tobacco plant corresponding to the target tobacco plant center point ID, without relying on manual labor or considering the influencing factors such as the shape, size, color, occlusion and shadow of the tobacco leaf blades, so that single plant segmentation and extraction of tobacco plants can be achieved, which can meet the needs of large-scale, high-efficiency and high-precision tobacco plant segmentation.
[0077] The present invention also provides a specific embodiment, which is different from the above embodiment in that after step S55 in step S5, the following steps S100-S500 are further included to obtain E e :
[0078] S100, obtain the core area ID list Q corresponding to D = {Q1, Q2, ..., Q e , ..., Q f}, where Q e D e The corresponding core area ID, the core area ID list is the unique identity of the core area.
[0079] Specifically, step S100 includes the following sub-steps S101-S108:
[0080] S101, obtain the first key area ID list T corresponding to D = {T1, T2, ..., T e , ..., T f}, T e D e The corresponding first key area ID, the first key area ID is the unique identity of the first key area, D e The first key area corresponding to the first key area ID is the target area with D e The corresponding target tobacco plant center point is the center of the circle, and the circular area with YR as the radius.
[0081] S102, traverse T and D, when the target tobacco plant center point corresponding to the target tobacco plant center point ID in D is in T e When the target tobacco plant center point ID is within the corresponding first key area, the target tobacco plant center point ID is used as T e The corresponding first middle tobacco plant center point ID is used to obtain T e A corresponding first intermediate cigarette strain center point ID list, wherein the first intermediate cigarette strain center point ID list includes a plurality of first intermediate cigarette strain center point IDs, each first intermediate cigarette strain center point ID corresponds to a target cigarette strain center point ID and the first intermediate cigarette strain center point ID is the same as its corresponding target cigarette strain center point ID.
[0082] S103, T e Any two first middle tobacco plant center point IDs in the corresponding first middle tobacco plant center point ID list form a T e The corresponding second middle tobacco plant center point ID combination is used to obtain T e The corresponding second intermediate cigarette strain center point ID combination list includes a plurality of second intermediate cigarette strain center point ID combinations.
[0083] Specifically, each combination of the second middle cigarette strain center point IDs includes two different first middle cigarette strain center point IDs.
[0084] S104, for T1, T2, ..., T e , ..., T f All the second middle tobacco plant center point ID combinations in the corresponding second middle tobacco plant center point ID combination list are deduplicated to obtain a third middle tobacco plant center point ID combination list P = {P1, P2, ..., P y , ..., P q}, where P y is the yth third-middle tobacco plant center point ID combination, y ranges from 1 to q, q is the number of third-middle tobacco plant center point ID combinations, P y Including P y1 and P y2 , P y1 P y The first middle tobacco plant center point ID, P y2 P yThe second first intermediate cigarette strain center point ID in the deduplication process, wherein, in the process of the deduplication processing, if the elements in the two second intermediate cigarette strain center point ID combinations are the same but the arrangement order of the elements is different, then the two second intermediate cigarette strain center point ID combinations are considered to be the same, and the element can be understood as the first intermediate cigarette strain center point ID in the second intermediate cigarette strain center point ID combination; for example: if one second intermediate cigarette strain center point ID combination includes the first intermediate cigarette strain center point a and the first intermediate cigarette strain center point b, and the other second intermediate cigarette strain center point ID combination includes the first intermediate cigarette strain center point b and the first intermediate cigarette strain center point a, then the two second intermediate cigarette strain center point ID combinations are the same, and one should be removed.
[0085] S105, P in the target area y1 The circular area enclosed by all the corresponding first designated locations is P y1 The corresponding second key area, where P y1 The corresponding first designated location is the location in the target area corresponding to P y1 The sum of the straight-line distances between the target tobacco plant center points corresponding to the target tobacco plant center point ID and P y2 The location where the ratio of the straight-line distances between the target tobacco plant center points corresponding to the target tobacco plant center point IDs is η, where η is a preset ratio.
[0086] Specifically, η≠0 and η<1.
[0087] S106: P in the target area y2 The circular area enclosed by all the corresponding second designated locations is P y2 The corresponding second key area, where P y2 The corresponding second designated location is the location in the target area corresponding to P y2 The sum of the straight-line distances between the target tobacco plant center points corresponding to the target tobacco plant center point ID and P y1 The location where the ratio of the straight-line distances between the corresponding target tobacco plant center points ID and the corresponding target tobacco plant center points is η.
[0088] S107, traverse P and D, when P y1 =D e When P y1 The corresponding second key area is D e The corresponding third key area, when P y2 =D e When P y2 The corresponding second key area is D e The corresponding third key area, wherein one target tobacco plant center point ID corresponds to at least one third key area.
[0089] S108, D e The corresponding overlapping area of all third key areas is taken as D e The corresponding core area and set the core area ID corresponding to the core area to Q e To obtain Q, where any two core area IDs in Q are different.
[0090] Through the above steps, the first key area ID corresponding to the target tobacco plant center point ID is obtained, the third intermediate tobacco plant center point ID combination is obtained according to the target tobacco plant center point ID and the first key area ID, the second key area corresponding to the first intermediate tobacco plant center point ID in the third intermediate tobacco plant center point ID combination is obtained, and the core area corresponding to the target tobacco plant center point ID and the core area ID corresponding to the core area are obtained according to the second key area. It can be ensured that the core area corresponding to the core area ID only includes the center point of the tobacco leaf blade on the target tobacco plant corresponding to its corresponding target tobacco plant center point ID, while including as many center points of the tobacco leaf blade as possible; according to The leaf pattern center point ID and the core area ID are used to obtain the first key tobacco plant center point ID corresponding to the leaf pattern center point ID. Further, the second key tobacco plant center point ID corresponding to the leaf pattern center point ID is obtained. When the target tobacco plant center point ID and the second key tobacco plant center point ID are the same, the tobacco leaf blade corresponding to the leaf pattern center point ID corresponding to the second key tobacco plant center point ID in the target area is used as the target tobacco leaf blade on the target tobacco plant corresponding to the target tobacco plant center point ID. This can reduce the error caused by the tobacco leaves being blocked by their adjacent tobacco leaves, which is beneficial to improving the accuracy of obtaining the target tobacco leaf blades of the target tobacco plant.
[0091] S200, when M jx =min(M j1 , M j2 , ..., M jx , ..., M jp(j) ), M j1 , M j2 , ..., M j(x-1) , M j(x+1) ,……,
[0092] M jp(j) The smallest first center point distance is taken as S 0 j , S 0 j For J j The corresponding third center point distance, M j1 , M j2 , ..., M j(x-1) , M j(x+1) , ..., M jp(j)The first designated tobacco plant center point ID corresponding to the smallest first center point distance is taken as S j , S j For J j The corresponding third designated tobacco plant center point ID is obtained to obtain the third designated tobacco plant center point ID list S corresponding to J and the third center point distance list S corresponding to J 0 , where S = {S1, S2, ..., S j , ..., S n},S 0 ={S 0 1, S 0 2, ..., S 0 j , ..., S 0 n},M j(x-1) For J j and L j(x-1) The corresponding first center point distance, L j(x-1) For J j The first designated tobacco plant center point ID of the corresponding x-1th first designated tobacco plant center point, M j(x+1) For J j and L j(x+1) The corresponding first center point distance, L j(x+1) For J j The first designated tobacco plant center point ID of the corresponding x+1th first designated tobacco plant center point.
[0093] S300, traverse J and Q, when J j The corresponding location of the leaf pattern center point in the target area is Q e When the corresponding core area is within the range, D e As R j , where R j For J j The corresponding first key tobacco plant center point ID; when J j The corresponding location of the leaf pattern center point in the target area is not in any Q e When the corresponding core area is within the range, determine R j is NULL, to obtain the first key tobacco plant center point ID list R corresponding to J = {R1, R2, ..., R j , ..., R n}, J j The corresponding location of the leaf pattern center point in the target area is not in any Q e The corresponding core area can be understood as: J j The corresponding location of the leaf pattern center point in the target area is not in Q1, Q2, ..., Q e , ..., Qf The core area range corresponds to any core area ID in .
[0094] S400, traverse R, when any R in R j When it is NULL, according to R, N, N 0 , S and S 0 Get the second key tobacco plant center point ID list R corresponding to J 0 = {R 0 1. R 0 2, ..., R 0 j , ..., R 0 n}, where R 0 j For J j The corresponding second key tobacco plant center point ID.
[0095] Specifically, step S400 includes the following steps S401-S405:
[0096] S401, when R j If not NULL, determine R 0 j =R j , when R j When NULL, R1, R2, ..., R (j-1) , R (j+1) , ..., R n Zhong and R j The corresponding N j The leaf spot center point ID corresponding to the same first key tobacco plant center point ID is used as J j The corresponding first spot center ID is used to obtain J j The corresponding first spot center point ID list U 1 j = {U 1 j1 , U 1 j2 , ..., U 1 jk , ..., U 1 jt(j)} and proceed to step S402, where R (j-1) For J (j-1) The corresponding first key tobacco plant center point ID, J (j-1) C (j-1) The corresponding leaf spot center point ID, C (j-1) is the tobacco leaf patch ID of the j-1th tobacco leaf patch corresponding to A, R (j+1) For J (j+1)The corresponding first key tobacco plant center point ID, J (j+1) C (j+1) The corresponding leaf spot center point ID, C (j+1) is the tobacco leaf patch ID of the j+1th tobacco leaf patch corresponding to A, U 1 jk For J j The corresponding k-th first spot center point ID, k ranges from 1 to t(j), t(j) is J j The number of corresponding first spot center point IDs.
[0097] S402, R1, R2, ..., R (j-1) , R (j+1) , ..., R n Zhong and R j The corresponding S j The leaf spot center point ID corresponding to the same first key tobacco plant center point ID is used as J j The corresponding second spot center ID is used to obtain J j The corresponding second spot center point ID list U 2 j = {U 2 j1 , U 2 j2 , ..., U 2 jv , ..., U 1 jz(j)}, where U 2 jv For J j The corresponding v-th second spot center point ID, v ranges from 1 to z(j), z(j) is J j The number of corresponding second spot center point IDs.
[0098] S403, according to U 1 jk , get J j with U 1 j The first leaf similarity W between 1 j , W 1 j Meet the following conditions:
[0099] W 1 j =∑ t(j) k=1 (|AJ 0 j -AJ 1 jk |×|N 0j -N 1 jk |) / t(j), where AJ 0 j For J j Corresponding C j Corresponding designated vegetation index, AJ 1 jk For U 1 jk The designated vegetation index corresponding to the tobacco leaf patch ID corresponding to the same leaf patch center point ID, N 1 jk For U 1 jk The distance between the second center point and the center point ID of the same leaf pattern is known to those skilled in the art. The method for obtaining the specified vegetation index corresponding to the tobacco leaf pattern ID is the same as that for obtaining B in steps S31-S32. i The method for obtaining the corresponding second vegetation index is basically the same. Those skilled in the art can refer to steps S31-S32 to obtain the designated vegetation index corresponding to the tobacco leaf patch ID, which will not be described in detail here. It can be understood that the B in step S31 is i Replace it with the tobacco leaf pattern ID and execute steps S31-S32.
[0100] Specifically, the smaller the absolute value of the difference between the specified vegetation indices corresponding to two different tobacco leaf spot IDs, the more similar the two tobacco leaf spots corresponding to the two different tobacco leaf spot IDs are; the smaller the absolute value of the difference between the second center point distances corresponding to the center point IDs of two different leaf spots, the more similar the two tobacco leaf spots corresponding to the two tobacco leaf spot IDs corresponding to the center point IDs of two different leaf spots are. Therefore, W 1 j The smaller it is, the more J j The corresponding tobacco leaf pattern and U 1 j The more similar the tobacco leaf spots corresponding to the leaf spot center point ID of the first spot center point ID in the image are, the more similar the tobacco leaf spots corresponding to the leaf spot center point ID are. Similarly, W 2 j The smaller it is, the more J j The corresponding tobacco leaf pattern and U 2 j The more similar the tobacco leaf spots corresponding to the leaf spot center point ID of the second spot center point ID in the image are, the more similar the tobacco leaf spots corresponding to the leaf spot center point ID are according to W 1 j and W 2 j Confirm J j The corresponding second key tobacco plant center point ID is conducive to improving the accuracy of obtaining the second key tobacco plant center point ID.
[0101] S404, according to U 2 jv , get J j with U 2 j The second leaf similarity W between 2 j , W 2 j Meet the following conditions:
[0102] W 2 j =∑ z(j) v=1 (|AJ 0 j -BJ 1 jk |×|S 0 j -S 1 jk |) / z(j), BJ 1 jk For U 2 jv The designated vegetation index corresponding to the tobacco leaf patch ID corresponding to the same leaf patch center point ID, S 1 jk For U 2 jv The third center point distance corresponding to the same leaf pattern center point ID.
[0103] S405, if W 1 j ≤W 2 j , then determine R 0 j =N j , if W 1 j >W 2 j , then determine R 0 j =S j .
[0104] Specifically, when W 1 j ≤W 2 j When J j The corresponding tobacco leaf pattern and U 1 j The more similar the tobacco leaf spots corresponding to the leaf spot center point ID corresponding to the first spot center point ID in J are, the more similar the tobacco leaf spots corresponding to the leaf spot center point ID are. j The corresponding tobacco leaf pattern should be consistent with U1 j The leaf corresponding to the center point ID of the first image spot in the image is the target tobacco leaf on the same target tobacco plant. When W 1 j >W 2 j When J j The corresponding tobacco leaf pattern and U 2 j The more similar the tobacco leaf spots corresponding to the leaf spot center point ID of the second spot center point ID in J are, the more similar the tobacco leaf spots corresponding to the leaf spot center point ID are. j The corresponding tobacco leaf pattern should be consistent with U 2 j The leaf pattern corresponding to the center point ID of the second pattern spot and the tobacco leaf pattern corresponding to the center point ID of the tobacco leaf pattern spot are the target tobacco leaves on the same target tobacco plant.
[0105] Through the above steps, when the first key tobacco plant center point ID corresponding to the leaf spot center point ID is not NULL, it is determined that the first key tobacco plant center point ID is the second key tobacco plant center point ID corresponding to the leaf spot center point ID; when the first key tobacco plant center point ID corresponding to the leaf spot center point ID is NULL, the first spot center point ID list and the second spot center point ID list corresponding to the leaf spot center point ID are obtained; the first leaf similarity between the leaf spot center point ID and the corresponding first spot center point ID list is obtained according to the specified vegetation index corresponding to the tobacco leaf spot corresponding to the leaf spot center point ID, the specified vegetation index corresponding to the tobacco leaf spot ID corresponding to the leaf spot center point ID which is the same as the first spot center point ID corresponding to the leaf spot center point ID, the second center point distance corresponding to the leaf spot center point ID, and the second center distance corresponding to the leaf spot center point ID which is the same as the first spot center point ID corresponding to the leaf spot center point ID; the first leaf similarity between the leaf spot center point ID and the corresponding first spot center point ID list is obtained according to the specified vegetation index corresponding to the tobacco leaf spot corresponding to the leaf spot center point ID, the specified vegetation index corresponding to the tobacco leaf spot ID corresponding to the leaf spot center point ID, the second center point distance corresponding to the leaf spot center point ID, and the second center distance corresponding to the leaf spot center point ID which is the same as the first spot center point ID corresponding to the leaf spot center point ID. The second leaf similarity between the leaf spot center point ID and the corresponding second spot center point ID list is obtained by comparing the first leaf similarity with the second leaf similarity, and determining the second key tobacco plant center point ID corresponding to the leaf spot center point ID, which is beneficial to improving the accuracy of obtaining the second key tobacco plant center point ID. When the target tobacco plant center point ID is the same as the second key tobacco plant center point ID, the tobacco leaf spot ID corresponding to the leaf spot center point ID corresponding to the second key tobacco plant center point ID in the target area is used as the target tobacco leaf on the target tobacco plant corresponding to the target tobacco plant center point ID, which can reduce the error caused by the tobacco leaf being blocked by its adjacent tobacco leaves, and is beneficial to improving the accuracy of obtaining the target tobacco leaf of the target tobacco plant.
[0106] S500, traverse R 0 and D, when R 0 j =D e When C j The corresponding tobacco leaf in the target area is taken as D e The target tobacco leaf on the corresponding target tobacco plant is C j The tobacco leaf ID of the corresponding tobacco leaf is used as the target tobacco leaf ID of the target tobacco leaf to obtain E e .
[0107] For some narrow and long tobacco leaves or those in the late growth period, since the leaves are too long, some tobacco leaves are blocked by their adjacent tobacco leaves, which easily causes most of the tobacco leaf pattern spots corresponding to the tobacco leaves on the target tobacco plant to be close to the target tobacco plant, and a small part to be close to other target tobacco plants. Therefore, it is easy to assign the tobacco leaves to other target tobacco plants, reducing the accuracy of obtaining the target tobacco leaves of the target tobacco plant.
[0108] Through the above steps, the core area ID corresponding to the target tobacco plant center point ID is obtained, and the first key tobacco plant center point ID corresponding to the leaf pattern center point ID is obtained according to the leaf pattern center point ID and the core area ID. Further, the second key tobacco plant center point ID corresponding to the leaf pattern center point ID is obtained. When the target tobacco plant center point ID and the second key tobacco plant center point ID are the same, the tobacco leaf spots corresponding to the leaf pattern center point ID corresponding to the second key tobacco plant center point ID in the target area are used as the target tobacco leaf spots on the target tobacco plant corresponding to the target tobacco plant center point ID. Compared with the above embodiment, the present embodiment can take into account the core area corresponding to the target tobacco plant center point, and obtain the target tobacco leaf spots corresponding to the target tobacco plant based on the core area, which can reduce the error caused by the tobacco leaves being blocked by their adjacent tobacco leaves, and is conducive to improving the accuracy of obtaining the target tobacco leaf spots of the target tobacco plant.
[0109] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store a computer program or at least one computer executable instruction related to implementing a method in a method embodiment. The computer program or at least one computer executable instruction is loaded and executed by the processor to implement the method provided in the above embodiment.
[0110] An embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method provided in the above embodiment when executing the computer program.
[0111] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0112] The present invention provides a method, device and storage medium for obtaining the ID of a target tobacco leaf. The method can obtain an orthophoto color image corresponding to the target area, and according to the target SAM (Segment Anything The target tobacco leaf ID list is obtained by using a target SAM model and an orthophoto color image, a tobacco leaf spot ID list is obtained according to the initial spot ID list, a target tobacco plant center point ID list is obtained, and a target tobacco leaf ID list set is obtained according to the tobacco leaf spot ID list and the target tobacco plant center point ID list. The target tobacco leaf ID list set includes a target tobacco leaf ID list corresponding to several target tobacco plants. The target tobacco leaf ID list includes several target tobacco leaf IDs. The target tobacco leaf ID is a unique identity identifier of the target tobacco leaf. It can be seen that the present invention can perform image segmentation on the orthophoto color image through the target SAM model, further obtain the tobacco leaf spot ID, and obtain the target tobacco leaf ID list corresponding to the target tobacco plant based on the tobacco leaf spot ID and the target tobacco plant center point ID. The single tobacco plant segmentation and extraction can be achieved without relying on manual labor or considering the influencing factors such as the shape, size, color, occlusion and shadow of the tobacco leaf, and can meet the large-scale, high-efficiency and high-precision tobacco plant segmentation requirements.
[0113] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are only for illustration, not for limiting the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention.
Claims
1. A method for obtaining a target tobacco leaf ID, wherein the target tobacco leaf ID is a unique identification of the target tobacco leaf, the target tobacco leaf is a tobacco leaf on a target tobacco plant, and the target tobacco plant is a single tobacco plant planted in a target area, characterized in that: The method comprises the following steps: S1. Obtain an orthophoto color image A corresponding to the target area; S2. Perform image segmentation on A according to the target SAM (Segment Anything Model) model to obtain the initial spot ID list B corresponding to A = {B1, B2, ..., B i , ..., B m }, where B i is the initial spot ID of the i-th initial spot corresponding to A, i ranges from 1 to m, m is the number of initial spots corresponding to A, the initial spot ID is the unique identification of the initial spot, and the initial spot is the spot obtained by performing image segmentation on A according to the target SAM (Segment Anything Model) model; before step S2, the target SAM (Segment Anything Model) model is also obtained through the following steps S10-S30: S10, obtaining an initial SAM (Segment Anything Model); S20, adjusting the parameter value of the first preset parameter in the initial SAM (Segment Anything Model) model to the first preset parameter value, adjusting the parameter value of the second preset parameter to the second preset parameter value, and adjusting the parameter value of the third preset parameter to α to obtain an intermediate SAM (Segment Anything Model) model, wherein the first preset parameter is a parameter for controlling the number of cropping layers used by the model when using the interactive mode of the frame, the second preset parameter is a parameter for controlling the downsampling factor of the pixel points used by the model when using the interactive mode of the frame, the downsampling factor is a parameter for controlling the degree of downsampling, α is a third preset parameter value, and the third preset parameter is a parameter for filtering fine and fragmented patches with too small an area; S30, adjusting the parameter value of the fourth preset parameter in the intermediate SAM (Segment Anything Model) model to its corresponding fourth preset parameter value, wherein the fourth preset parameter is a parameter used to segment the pattern and is different from the first preset parameter, the second preset parameter, and the third preset parameter; S3, according to B, obtain the tobacco leaf spot ID list C corresponding to A = {C1, C2, ..., C j , ..., C n }, where C j is the tobacco leaf spot ID of the j-th tobacco leaf spot corresponding to A, the value of j ranges from 1 to n, n is the number of tobacco leaf spots corresponding to A, and the tobacco leaf spot ID is the unique identity of the tobacco leaf spot; S4, obtain the target tobacco plant center point ID list D = {D1, D2, ..., D e , ..., D f }, where D e is the target tobacco plant center point ID corresponding to the e-th target tobacco plant, the value of e is 1 to f, f is the number of target tobacco plants, the target tobacco plant center point ID is the unique identity of the target tobacco plant center point, and the target tobacco plant center point is the center point of the target tobacco plant; S5. Obtain the target tobacco leaf ID list set E={E1, E2, ..., E e ,……,E f }, E e ={E e1 , E e2 ,……,E er ,……,E es(e) }, where E e D e The target tobacco leaf ID list corresponding to the target tobacco plant, E er D e The target tobacco leaf ID of the rth target tobacco leaf on the corresponding target tobacco plant, r ranges from 1 to s(e), s(e) is D e The number of target tobacco leaves on the corresponding target tobacco plant includes the following sub-steps S51-S56 in step S5: S51, obtain the leaf pattern center point ID list J={J1, J2, ..., J j , ..., J n }, where J j C j The corresponding leaf pattern center point ID, wherein the leaf pattern center point ID is a unique identity identifier of the leaf pattern center point, and the leaf pattern center point is the center point of the tobacco leaf pattern; S52, obtain the designated area ID list K corresponding to J = {K1, K2, ..., K j , ..., K n }, where K j For J j The corresponding designated area ID, which is the unique identifier of the designated area. j The corresponding designated area ID corresponds to the designated area in the target area. j The corresponding location in the target area is the center of the circle, and the radius is the preset distance YR; S53, traverse D and K, when D e The corresponding target tobacco plant center point is at K j When the corresponding specified area is within the range, D e The corresponding target tobacco plant center point is J j The corresponding first designated tobacco plant center point and D e As the first designated tobacco plant center point ID of the first designated tobacco plant center point, obtain the first designated tobacco plant center point ID list set L={L1, L2, . . . , L j , ..., L n }, L j= {L j1 , L j2 , ..., L jx , ..., L jp(j) }, where L j For J j The corresponding first designated tobacco plant center point ID list, L jx For J j The first designated tobacco plant center point ID of the corresponding x-th first designated tobacco plant center point, where x ranges from 1 to p(j), and p(j) is J j The number of the corresponding first designated tobacco plant center points; S54. According to J and L, obtain the first center point distance list set M corresponding to J = {M1, M2, ..., M j , ..., M n },M j ={M j1 , M j2 , ..., M jx , ..., M jp(j) },M j For J j The corresponding first center point distance list, M jx For J j and L jx The corresponding first center point distance, J j and L jx The corresponding first center point distance is J j The corresponding location and L in the target area jx The straight-line distance between the center points of the corresponding first designated tobacco plants; S55, when M jx =min(M j1 , M j2 , ..., M jx , ..., M jp(j) ), M jx The corresponding L jx As J j The corresponding second designated tobacco plant center point ID, M jx As J j The corresponding second center point distance is used to obtain the second designated tobacco plant center point ID list N={N1, N2, ..., N j , ..., N n } and J corresponding to the second center point distance list N 0 ={N 0 1, N 0 2, ..., N 0 j , ..., N 0 n }, where N j For J j The corresponding second designated tobacco plant center point ID, N 0 j For J j The corresponding second center point distance, min() is the minimum value acquisition function; S56, traverse N and D, when N j =D e When C j The corresponding tobacco leaf in the target area is taken as D e The target tobacco leaf on the corresponding target tobacco plant is C j The tobacco leaf ID of the corresponding tobacco leaf is used as the target tobacco leaf ID of the target tobacco leaf to obtain E e .
2. The method for obtaining the target tobacco leaf ID according to claim 1, characterized in that: Each tobacco leaf pattern corresponds to a tobacco leaf in the target area.
3. The method for obtaining the target tobacco leaf ID according to claim 2, characterized in that: A tobacco leaf ID is set for each tobacco leaf in the target area, and the tobacco leaf IDs of any two tobacco leaves in the target area are different.
4. The method for obtaining the target tobacco leaf ID according to claim 1, characterized in that: Step S3 also includes the following sub-steps S31-S35: S31. Get B i The corresponding first vegetation index list F i ={F i1 , F i2 , ..., F ig , ..., F ih(i) }, where F ig For B i The first vegetation index corresponding to the g-th pixel in the corresponding initial patch, the value of g ranges from 1 to h(i), h(i) is B i The number of pixels in the corresponding initial spot, F ig Meet the following conditions: F ig =2×ρ1 ig -ρ2 ig -ρ3 ig , where ρ1 ig For B i The green band reflectivity of the g-th pixel in the corresponding initial image spot, ρ2 ig For B i The red band reflectivity of the g-th pixel in the corresponding initial image spot, ρ3 ig For B i The blue band reflectivity of the g-th pixel in the corresponding initial image spot; S32, get B i The corresponding second vegetation index F 0 i , where F 0 i Meet the following conditions: F 0 i =∑ h(i) g=1 F ig / h(i); S33, B i The average value of the RGB values of all pixels in the corresponding initial image spot is taken as B i The corresponding average RGB value G i ; S34, F 0 i and G i Input into the target classification model to obtain B i The corresponding spot type label H i ; S35, when H i =TB, B i The corresponding initial image spot is used as the tobacco leaf image spot corresponding to A and B i The tobacco leaf spot ID of the tobacco leaf spot is used to obtain C, wherein TB is a preset spot type label.
5. The method for obtaining the target tobacco leaf ID according to claim 1, characterized in that: α meets the following conditions: α=β / fb 2 , where β is the preset minimum tobacco leaf area, the unit of measurement of the preset minimum tobacco leaf area is square meters, and fb is the image resolution of A, the unit of measurement of the image resolution is meter.
6. The method for obtaining the target tobacco leaf ID according to claim 1, characterized in that: YR meets the following conditions: YR=γ×ZJ, where γ is a preset adjustment parameter used to adjust the preset distance, and ZJ is the preset plant spacing.
7. The method for obtaining the target tobacco leaf ID according to claim 6, characterized in that: The value range of γ is [1.3, 1.6].
8. A non-transitory computer-readable storage medium, characterized in that: The storage medium stores a computer program or at least one computer executable instruction, and the computer program or at least one computer executable instruction is loaded and executed by a processor to implement the method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
Citation Information
Patent Citations
Method for identifying and detecting stems in tobacco leaves
CN113390799A
Tobacco leaf grading method and device and computer readable storage medium
CN114972770A
Method for judging maturity of tobacco leaves
CN117115664A
Tobacco leaf harvesting time determination method, electronic equipment and storage medium
CN117589767A
Plant body of genus nicotiana and production method therefor
WO2022181478A1
