Adaptive non-contact yak weight analysis method and system based on SAM
Through an adaptive contactless method based on SAM, yak weight recognition is solved by using top-view images, many challenges of traditional measurement methods are solved, and high accuracy, fast, safe and cost-effective weight measurement is achieved.
Patent Information
- Application Number
- CN202410520466.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-04-28
AI Technical Summary
Traditional yak weight measurement methods have many challenges, including time-consuming and labor-intensive driving yaks, operating safety risks, large measurement errors, reduced accuracy and high cost and low efficiency.
Adaptive non-contact yak weight analysis method based on SAM is adopted, and the yak's top view image is obtained, pre-processing and mask extraction are performed, the contour is identified and the activity points are formed, and the relevant features are extracted, and the recognition model is trained to achieve non-contact weight recognition.
Highly accurate weight measurements are achieved in the natural state of yaks without interference, which improves data collection speed and work efficiency, and greatly improves applicability.
Smart Images

Figure CN118447533B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of yak intelligent identification, and in particular to a SAM-based adaptive non-contact yak weight analysis method and system. Background Art
[0002] As an indispensable livestock resource in high-altitude areas, yaks not only provide basic living materials such as milk and meat for local residents, but also play an important role in labor and economic value-added. Scientific classification and management of yaks and optimization of breeding conditions and feeding strategies based on the characteristics of different yak groups are the key to improving breeding efficiency and yak health. With the advancement of agricultural technology, the automation of yak sorting, especially the use of contactless methods, is the core way to promote the production efficiency and management level of the breeding industry.
[0003] In the traditional farming model, measuring the weight of yaks through weight sensors and other equipment, and classifying them according to different attributes such as breed and gender, is a crucial link in production management. However, given the large size of yaks, this process faces multiple challenges: driving yaks to the measurement point is time-consuming and laborious; yaks are prone to stress reactions during the measurement process, endangering the safety of operators; the movement of yaks during the measurement process may cause errors, and the reduced accuracy of the scales used for a long time and the difference in operator skills will also affect the accuracy of the results; in addition, high-intensity manual work is not only costly but also inefficient.
[0004] In the prior art, a Chinese patent application numbered CN201710281943.X discloses a method for estimating the body size of a yak based on 3D vision, including: using an image acquisition device to collect a side image of a yak; extracting a foreground image from the side image; identifying key points of the yak body in the extracted foreground image; and automatically extracting the body size information of the yak using the identified key point information of the yak body. A method for estimating the weight of a yak based on 3D vision is also proposed, including executing the aforementioned method for estimating the body size of a yak based on 3D vision; using the extracted body size information of the yak as input, and using a yak weight estimation model to predict the weight value of the yak. Although it can also estimate the weight of a yak based on image data, it relies on images of the yak in all directions and cannot be promoted in batches in breeding grounds where yaks are herded. Summary of the invention
[0005] In order to at least overcome the above-mentioned deficiencies in the prior art, the purpose of the present application is to provide an adaptive non-contact yak weight analysis method and system based on SAM.
[0006] In a first aspect, the present application provides an adaptive non-contact yak weight analysis method based on SAM, comprising:
[0007] Obtain a top-view image of a yak in a shaved state as a sample image;
[0008] Preprocessing the sample image and extracting the yak mask in the sample image;
[0009] Identify a yak outline from the yak mask, and restrict the yak outline with a preset number of fixed points to form a plurality of active points covering the yak outline;
[0010] A first feature is obtained according to the yak contour, and a second feature is obtained according to the positional relationship between the multiple active points; the first feature includes the contour perimeter, the complete area and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points;
[0011] Extracting, from the first feature and the second feature, a feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature as a sample feature, and a correlation between different sample features being lower than a preset feature;
[0012] The recognition model is trained by using a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and the weight corresponding to the sample features;
[0013] A top view image of the target yak in a shaved state is collected as an image to be identified, and the weight corresponding to the image to be identified is identified by using the recognition model.
[0014] When implementing the embodiment of the present application, it is necessary to first collect samples and features, so it is necessary to first obtain a top-view image of the yak in the shaved state as a sample image. In the yak breeding process, yak wool will be shaved and sold. At this time, it is necessary to weigh the yaks and manage them in pens based on weight. The embodiment of the present application provides a technical solution for estimating the weight of yaks that only requires a top-view image in this application scenario. At the same time, in a yak herd, the difficulty of obtaining a complete top-view image is much lower than the difficulty of obtaining images in other directions. Therefore, in the embodiment of the present application, a solution for weight recognition using a top-view image that does not rely on other data is adopted.
[0015] In the embodiment of the present application, it is necessary to process the yak mask according to the sample image, which can adopt the mask extraction technology in the prior art, and the embodiment of the present application does not make much limitation. Based on the identified yak contour, in order to capture more features that can be correlated with weight, the method of covering the yak contour with active points is adopted. Through the positional relationship between different active points, the features used for identification can be enriched. When performing feature extraction, the embodiment of the present application adopts two feature extraction schemes, in which the first feature is obtained based on the contour, such as the contour perimeter, the complete area, the number of convex hull defects, the area without convex defects, etc., and the second feature is realized through the Euclidean distance between different active points. Generally speaking, all Euclidean distances can be evaluated for weight correlation first, and then the distance between appropriate active points can be selected as the second feature to reduce the number of features.
[0016] In the embodiment of the present application, in order to screen the first feature and the second feature, it is necessary to select features that are highly correlated with weight and have strong mutual independence for subsequent model training. In the subsequent recognition model training, various existing existing technologies that can make decisions can be used. For example, the following three algorithms are used and performance evaluation is performed using nested 10-fold cross validation and 100 random repetitions. At the same time, the prediction error is quantified by calculating the mean absolute error (MAE), root mean square error (RMSE), mean absolute percentage error (MAPE), root mean square error of prediction (RMSEP) and correlation coefficient (CC). REPTree's Bagging ensemble learning algorithm: Using REPTree decision trees and Bagging ensemble learning methods, it is intended to construct multiple decision trees by resampling multiple training sets to improve the stability and accuracy of the prediction. Discrete regression algorithm of decision tree: regression prediction of yak weight is performed by using a decision tree algorithm, especially by discretizing continuous variables to simplify the complexity of the model. Random forest algorithm: using an integrated method of multiple decision trees to enhance the accuracy and generalization ability of the prediction model, it is one of the most widely used efficient machine learning algorithms. It should be understood that the input data of the recognition model is image data, and the output data is weight. After the training of the recognition model is completed, the image to be recognized can be used as input data, and the weight can be used as output data to recognize the image to be recognized. When the embodiment of the present application is implemented, the yaks can be measured in an undisturbed natural state, which can improve the accuracy of the data. The automated image analysis system does not need to rest, which greatly improves the speed and work efficiency of data collection, and only a bird's-eye view image is needed to recognize the weight of the yak, which greatly improves the applicability.
[0017] In a possible implementation manner, preprocessing the sample image and extracting the yak mask in the sample image includes:
[0018] Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image;
[0019] Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code;
[0020] After fusing the image code and the text code, performing mask decoding to form a mask foreground probability;
[0021] A yak mask is generated according to the mask foreground probability.
[0022] In a possible implementation manner, identifying a yak outline from the yak mask includes:
[0023] Extracting a boundary of the yak mask from the yak mask by edge detection;
[0024] Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary;
[0025] The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
[0026] In a possible implementation, the yak outline is restricted by a preset number of fixed points to form a plurality of active points covering the yak outline, including:
[0027] The fixed points are evenly arranged in a circle outside the yak outline, and the energy function is minimized and iteratively updated until convergence to form the active points.
[0028] In a possible implementation, the energy function adopts the following formula:
[0029] E(C)=∫ 0 1 E int (C(s))+E image (C(s))+E con (C(s))ds
[0030] Where E(C) is the energy functional, C(s) is the contour with curve length s as parameter, and E int is the smoothness and continuity of the contour, E image For the contour to be close to the edge of the object, E con For external constraints.
[0031] In a possible implementation, a feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature is extracted from the first feature and the second feature as a sample feature, and the correlation between different sample features is lower than the preset feature, including:
[0032] The first feature and the second feature are combined to form a feature set, the correlation between each feature in the feature set and the weight of the yak is calculated as a first correlation, and the correlation between the features in the feature set is calculated as a second correlation;
[0033] Add or remove features in the feature set through a greedy algorithm, and optimize the evaluation function;
[0034] The evaluation function is used to evaluate the quality of the feature set and the best feature set is selected as the sample feature set.
[0035] In a possible implementation, the evaluation function adopts the following formula:
[0036]
[0037] In the formula, Merit s is the quality of the feature set, k is the number of features, r cf is the first correlation, r ff is the second correlation.
[0038] In a second aspect, the embodiment of the present application further provides an adaptive non-contact yak weight analysis system based on SAM, comprising:
[0039] An image unit is configured to obtain a top view image of the yak in a shaved state as a sample image;
[0040] A mask unit, configured to preprocess the sample image and extract a yak mask from the sample image;
[0041] a contour unit configured to identify a yak contour from the yak mask and to restrict the yak contour with a preset number of fixed points to form a plurality of active points covering the yak contour;
[0042] A feature unit is configured to obtain a first feature according to the yak contour, and obtain a second feature according to the positional relationship between multiple active points; the first feature includes the contour perimeter, the complete area and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points;
[0043] an optimization unit, configured to extract, from the first feature and the second feature, a feature having a correlation with the weight of the yak corresponding to the sample image higher than a preset value as a sample feature, and a correlation between different sample features lower than a preset value;
[0044] A training unit is configured to train a recognition model through a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and a weight corresponding to the sample features;
[0045] The recognition unit is configured to collect a top view image of the target yak in a shaved state as an image to be recognized, and recognize the weight corresponding to the image to be recognized through the recognition model.
[0046] In a possible implementation manner, the mask unit is further configured as:
[0047] Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image;
[0048] Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code;
[0049] After fusing the image code and the text code, performing mask decoding to form a mask foreground probability;
[0050] A yak mask is generated according to the mask foreground probability.
[0051] In a possible implementation, the contour unit is further configured as:
[0052] Extracting a boundary of the yak mask from the yak mask by edge detection;
[0053] Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary;
[0054] The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
[0055] In a possible implementation, the contour unit is further configured as:
[0056] The fixed points are evenly arranged in a circle outside the yak outline, and the energy function is minimized and iteratively updated until convergence to form the active points.
[0057] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0058] The SAM-based adaptive non-contact yak weight analysis method and system of the present invention can perform measurements when the yaks are in an undisturbed natural state, which can improve the accuracy of the data. The automated image analysis system does not need to rest, which greatly improves the speed of data collection and work efficiency. In addition, only a bird's-eye view image is required for yak weight identification, which greatly improves applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0060] Figure 1 This is a schematic diagram of the steps of the method of the embodiment of the present application;
[0061] Figure 2 A schematic diagram of yak mask generation in an embodiment of the present application;
[0062] Figure 3 A schematic diagram of activity point generation for an embodiment of the present application;
[0063] Figure 4 This is a schematic diagram of the numbering of activity points in an embodiment of the present application;
[0064] Figure 5 This is a schematic diagram of active point segments in an embodiment of the present application. DETAILED DESCRIPTION
[0065] To make the purpose, technical scheme and advantages of the embodiment of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the embodiment of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0066] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0067] Please refer to Figure 1 , which is a flow chart of the SAM-based adaptive non-contact yak weight analysis method provided in an embodiment of the present invention. Furthermore, the SAM-based adaptive non-contact yak weight analysis method may specifically include the contents described in the following steps S1 to S7.
[0068] S1: Obtain a top view image of a yak in a shaved state as a sample image;
[0069] S2: preprocessing the sample image and extracting the yak mask in the sample image;
[0070] S3: identifying a yak outline from the yak mask, and limiting the yak outline with a preset number of fixed points to form a plurality of active points covering the yak outline;
[0071] S4: obtaining a first feature according to the yak contour, and obtaining a second feature according to the positional relationship between the multiple active points; the first feature includes the contour perimeter, the complete area, and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points;
[0072] S5: extracting, from the first feature and the second feature, a feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature as a sample feature, and the correlation between different sample features is lower than a preset feature;
[0073] S6: training a recognition model through a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and a weight corresponding to the sample features;
[0074] S7: collecting a top view image of the target yak in a shaved state as an image to be recognized, and identifying the weight corresponding to the image to be recognized by using the recognition model.
[0075] When implementing the embodiment of the present application, it is necessary to first collect samples and features, so it is necessary to first obtain a top-view image of the yak in the shaved state as a sample image. In the yak breeding process, yak wool will be shaved and sold. At this time, it is necessary to weigh the yaks and manage them in pens based on weight. The embodiment of the present application provides a technical solution for estimating the weight of yaks that only requires a top-view image in this application scenario. At the same time, in a yak herd, the difficulty of obtaining a complete top-view image is much lower than the difficulty of obtaining images in other directions. Therefore, in the embodiment of the present application, a solution for weight recognition using a top-view image that does not rely on other data is adopted.
[0076] In the embodiment of the present application, it is necessary to process the yak mask according to the sample image, which can adopt the mask extraction technology in the prior art, and the embodiment of the present application does not make much limitation. Based on the identified yak contour, in order to capture more features that can be correlated with weight, the method of covering the yak contour with active points is adopted. Through the positional relationship between different active points, the features used for identification can be enriched. When performing feature extraction, the embodiment of the present application adopts two feature extraction schemes, in which the first feature is obtained based on the contour, such as the contour perimeter, the complete area, the number of convex hull defects, the area without convex defects, etc., and the second feature is realized through the Euclidean distance between different active points. Generally speaking, all Euclidean distances can be evaluated for weight correlation first, and then the distance between appropriate active points can be selected as the second feature to reduce the number of features.
[0077] In the embodiment of the present application, in order to screen the first feature and the second feature, it is necessary to select features that are highly correlated with weight and have strong mutual independence for subsequent model training. In the subsequent recognition model training, various existing existing technologies that can make decisions can be used. For example, the following three algorithms are used and performance evaluation is performed using nested 10-fold cross validation and 100 random repetitions. At the same time, the prediction error is quantified by calculating the mean absolute error (MAE), root mean square error (RMSE), mean absolute percentage error (MAPE), root mean square error of prediction (RMSEP) and correlation coefficient (CC). REPTree's Bagging ensemble learning algorithm: Using REPTree decision trees and Bagging ensemble learning methods, it is intended to construct multiple decision trees by resampling multiple training sets to improve the stability and accuracy of the prediction. Discrete regression algorithm of decision tree: regression prediction of yak weight is performed by using a decision tree algorithm, especially by discretizing continuous variables to simplify the complexity of the model. Random forest algorithm: using an integrated method of multiple decision trees to enhance the accuracy and generalization ability of the prediction model, it is one of the most widely used efficient machine learning algorithms. It should be understood that the input data of the recognition model is image data, and the output data is weight. After the training of the recognition model is completed, the image to be recognized can be used as input data, and the weight can be used as output data to recognize the image to be recognized. When the embodiment of the present application is implemented, the yaks can be measured in an undisturbed natural state, which can improve the accuracy of the data. The automated image analysis system does not need to rest, which greatly improves the speed and work efficiency of data collection, and only a bird's-eye view image is needed to recognize the weight of the yak, which greatly improves the applicability.
[0078] In a possible implementation manner, preprocessing the sample image and extracting the yak mask in the sample image includes:
[0079] Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image;
[0080] Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code;
[0081] After fusing the image code and the text code, performing mask decoding to form a mask foreground probability;
[0082] A yak mask is generated according to the mask foreground probability.
[0083] When implementing the embodiments of this application, please refer to Figure 2 , shows the generation process of the yak mask, where histogram equalization can be used to improve contrast, denoising can be achieved through a denoising function, and resizing can be achieved through a resizing function. At the same time, the image encoding and text encoding in SAM are combined to improve the overall mask generation accuracy. The image encoding uses the MAE pre-trained visual transformer (ViT) to encode the image, while the text encoding constructs appropriate prompts such as "yak" according to the yak image segmented as needed, and uses the CLIP text encoder to represent it. If there are specific position prompts (sparse prompts), they are encoded accordingly, such as points and boxes, which are encoded using position encoding and learned embedding. Then, the image embedding and the prompt embedding are fused to prepare the input of the mask decoder, and the mask decoder processes the fused embedding to generate the corresponding mask foreground probability, and finally forms the yak mask.
[0084] In a possible implementation manner, identifying a yak outline from the yak mask includes:
[0085] Extracting a boundary of the yak mask from the yak mask by edge detection;
[0086] Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary;
[0087] The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
[0088] When the embodiment of the present application is implemented, in order to enrich the features of the yak outline, it is necessary to first extract the boundary through edge detection, then find the convex hull, and quantize these image data through Hu moments. These descriptors provide a robust basis for yak shape analysis and help to accurately predict the weight of the yak. At the same time, the task of the embodiment of the present application is to predict the weight of the yak, so the hair color and texture on the back of the yak are not concerned, only the outline of the cow is concerned. After the outline of the cow is segmented, a convex hull is created around the outline of the cow as a feature of the entire area. The convex defect is the space between the contour line obtained using the convex hull technology and the outline of the cow. Therefore, the entire area of the outline is composed of the area of the cow's back area plus the area of the convex defect.
[0089] In a possible implementation, the yak outline is restricted by a preset number of fixed points to form a plurality of active points covering the yak outline, including:
[0090] The fixed points are evenly arranged in a circle outside the yak outline, and the energy function is minimized and iteratively updated until convergence to form the active points.
[0091] When implementing the embodiments of this application, please refer to Figure 3 , shows the process of generating active points. In the initialization stage, a scattered circle outside the yak outline is first constructed. The scattered circle is composed of fixed points. After multiple rounds of iterations, the fixed points will converge on the outline. For an example, please refer to Figure 4 , shows the final active point result, where 50 fixed points were taken as active point limits for the back region images in 20,000 iterations and these fixed points were evenly distributed in all images using the active contour model. In each iteration, a search is performed to determine the location of the point that will minimize the contour size. This process is repeated until the notified number of iterations is reached so that the points are distributed on the mask contour of the cow's back region and the right point farthest from the centroid, corresponding to the insertion point of the cow's tail, is considered as the zero point and starting from it, the points are numbered clockwise on each cow's image.
[0092] In a possible implementation, the energy function adopts the following formula:
[0093] E(C)=∫ 0 1 E int (C(s))+E image (C(s))+E con (C(s))ds
[0094] Where E(C) is the energy functional, C(s) is the contour with curve length s as parameter, and E int is the smoothness and continuity of the contour, E imageFor the contour to be close to the edge of the object, E con For external constraints.
[0095] In a possible implementation, a feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature is extracted from the first feature and the second feature as a sample feature, and the correlation between different sample features is lower than the preset feature, including:
[0096] The first feature and the second feature are combined to form a feature set, the correlation between each feature in the feature set and the weight of the yak is calculated as a first correlation, and the correlation between the features in the feature set is calculated as a second correlation;
[0097] Add or remove features in the feature set through a greedy algorithm, and optimize the evaluation function;
[0098] The evaluation function is used to evaluate the quality of the feature set and the best feature set is selected as the sample feature set.
[0099] When implementing the embodiments of this application, please refer to Figure 5 When acquiring the second feature, the Euclidean distance between different activity points is used as the feature, which will be specifically expressed in the form of a line segment, and the correlation is calculated, which can effectively screen the features related to the weight of yaks and make up for the lack of features.
[0100] In a possible implementation, the evaluation function adopts the following formula:
[0101]
[0102] In the formula, Merit s is the quality of the feature set, k is the number of features, r cf is the first correlation, r ff is the second correlation.
[0103] Based on the same inventive concept as above, the embodiment of the present application also provides an adaptive non-contact yak weight analysis system based on SAM, including:
[0104] An image unit is configured to obtain a top view image of the yak in a shaved state as a sample image;
[0105] A mask unit, configured to preprocess the sample image and extract a yak mask from the sample image;
[0106] a contour unit configured to identify a yak contour from the yak mask and to restrict the yak contour with a preset number of fixed points to form a plurality of active points covering the yak contour;
[0107] A feature unit is configured to obtain a first feature according to the yak contour, and obtain a second feature according to the positional relationship between multiple active points; the first feature includes the contour perimeter, the complete area and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points;
[0108] an optimization unit, configured to extract, from the first feature and the second feature, a feature having a correlation with the weight of the yak corresponding to the sample image higher than a preset value as a sample feature, and a correlation between different sample features lower than a preset value;
[0109] A training unit is configured to train a recognition model through a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and a weight corresponding to the sample features;
[0110] The recognition unit is configured to collect a top view image of the target yak in a shaved state as an image to be recognized, and recognize the weight corresponding to the image to be recognized through the recognition model.
[0111] In a possible implementation manner, the mask unit is further configured as:
[0112] Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image;
[0113] Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code;
[0114] After fusing the image code and the text code, performing mask decoding to form a mask foreground probability;
[0115] A yak mask is generated according to the mask foreground probability.
[0116] In a possible implementation, the contour unit is further configured as:
[0117] Extracting a boundary of the yak mask from the yak mask by edge detection;
[0118] Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary;
[0119] The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
[0120] In a possible implementation, the contour unit is further configured as:
[0121] The fixed points are evenly arranged in a circle outside the yak outline, and the energy function is minimized and iteratively updated until convergence to form the active points.
[0122] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0123] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0124] The units described as separate components may or may not be physically separated. As units, it is obvious that a person of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0125] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0126] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a grid device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0127] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. The adaptive non-contact yak weight analysis method based on SAM is characterized by: include: Obtain a top-view image of a yak in a shaved state as a sample image; Preprocessing the sample image and extracting the yak mask in the sample image; Identify a yak outline from the yak mask, and restrict the yak outline with a preset number of fixed points to form a plurality of active points covering the yak outline; A first feature is obtained according to the yak contour, and a second feature is obtained according to the positional relationship between the multiple active points; the first feature includes the contour perimeter, the complete area and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points; Extracting, from the first feature and the second feature, a feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature as a sample feature, and a correlation between different sample features being lower than a preset feature; The recognition model is trained by using a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and the weight corresponding to the sample features; A top view image of the target yak in a shaved state is collected as an image to be identified, and the weight corresponding to the image to be identified is identified by using the recognition model.
2. The SAM-based adaptive non-contact yak weight analysis method according to claim 1, characterized in that: Preprocessing the sample image and extracting the yak mask in the sample image includes: Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image; Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code; After fusing the image code and the text code, performing mask decoding to form a mask foreground probability; A yak mask is generated according to the mask foreground probability.
3. The SAM-based adaptive non-contact yak weight analysis method according to claim 1, characterized in that: Identifying a yak outline from the yak mask comprises: Extracting a boundary of the yak mask from the yak mask by edge detection; Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary; The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
4. The SAM-based adaptive non-contact yak weight analysis method according to claim 3, characterized in that: The yak outline is restricted by a preset number of fixed points to form a plurality of active points covering the yak outline, including: The fixed points are evenly arranged in a circle outside the yak outline, and the energy function is minimized and iteratively updated until convergence to form the active points.
5. The SAM-based adaptive non-contact yak weight analysis method according to claim 4, characterized in that: The energy function adopts the following formula: Where E(C) is the energy functional, C(s) is the contour with curve length s as parameter, and E int is the smoothness and continuity of the contour, E image For the contour to be close to the edge of the object, E con For external constraints.
6. The SAM-based adaptive non-contact yak weight analysis method according to claim 1, characterized in that: A feature having a higher correlation with the weight of the yak corresponding to the sample image than a preset feature is extracted from the first feature and the second feature as a sample feature, and the correlation between different sample features is lower than the preset feature, including: The first feature and the second feature are combined to form a feature set, the correlation between each feature in the feature set and the weight of the yak is calculated as a first correlation, and the correlation between the features in the feature set is calculated as a second correlation; Add or remove features in the feature set through a greedy algorithm, and optimize the evaluation function; The evaluation function is used to evaluate the quality of the feature set and the best feature set is selected as the sample feature set.
7. The SAM-based adaptive non-contact yak weight analysis method according to claim 6, characterized in that: The evaluation function adopts the following formula: In the formula, Merits s is the quality of the feature set, k is the number of features, r cf is the first correlation, r ff is the second correlation.
8. The SAM-based adaptive non-contact yak weight analysis system is characterized by: Using the method according to any one of claims 1 to 7, the system comprises: An image unit is configured to obtain a top view image of the yak in a shaved state as a sample image; A mask unit, configured to preprocess the sample image and extract a yak mask from the sample image; a contour unit configured to identify a yak contour from the yak mask and to restrict the yak contour with a preset number of fixed points to form a plurality of active points covering the yak contour; A feature unit is configured to obtain a first feature according to the yak contour, and obtain a second feature according to the positional relationship between multiple active points; the first feature includes the contour perimeter, the complete area and the number of convex hull defects; the second feature includes the Euclidean distance between two of the active points; an optimization unit configured to extract, from the first feature and the second feature, a feature having a correlation with the weight of the yak corresponding to the sample image that is higher than a preset value as a sample feature, and a correlation between different sample features that is lower than a preset value; A training unit is configured to train a recognition model through a plurality of sample feature sets; each of the sample feature sets includes a plurality of the sample features and a weight corresponding to the sample features; The recognition unit is configured to collect a top view image of the target yak in a shaved state as an image to be recognized, and recognize the weight corresponding to the image to be recognized through the recognition model.
9. The SAM-based adaptive non-contact yak weight analysis system according to claim 8, characterized in that: The mask unit is further configured as: Improving the contrast of the sample image, reducing noise and adjusting the size to form a pre-processed image; Encoding the preprocessed image through a visual converter in SAM to obtain an image code, and constructing a text prompt according to the image parts that need to be segmented to form a text code; After fusing the image code and the text code, performing mask decoding to form a mask foreground probability; A yak mask is generated according to the mask foreground probability.
10. The SAM-based adaptive non-contact yak weight analysis system according to claim 8, characterized in that: The contour unit is further configured to: Extracting a boundary of the yak mask from the yak mask by edge detection; Extracting a convex hull through the boundary; the convex hull being a minimum convex shape surrounding the boundary; The convex hull and the boundary are combined to form the yak contour, and the yak contour is quantized as a normalized central moment.
Citation Information
Patent Citations
Method of estimating the body size and the weight of yak, and corresponding portable computer device of the same
CN107180438A
Apparatus and method for estimation of livestock weight
US20120275659A1
Systems and methods for biometric identification
US20170243042A1