A livestock feeding preference monitoring method and system based on machine vision

By using machine vision technology and sensors and cameras to collect data, combined with image preprocessing and deep learning algorithms, the problems of real-time monitoring of livestock feeding behavior and identification of forage species have been solved, thereby improving the efficiency of livestock management and resource utilization.

CN121392970BActive Publication Date: 2026-05-05LANZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LANZHOU UNIV
Filing Date
2025-11-21
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing technologies struggle to capture livestock grazing behavior in real time and dynamically and accurately identify forage species in complex natural environments, resulting in low efficiency in livestock management and grassland resource protection.

Method used

Using a machine vision-based approach, video data is collected by sensors and cameras worn on livestock. Combined with image preprocessing, convolutional neural networks, and random forest classifiers, the feeding frequency and preference patterns of livestock are identified.

Benefits of technology

It enables real-time and dynamic monitoring of livestock grazing behavior, accurately identifies forage species, improves livestock management and grassland resource utilization efficiency, and optimizes feeding decisions and livestock health outcomes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121392970B_ABST
    Figure CN121392970B_ABST
Patent Text Reader

Abstract

This invention provides a machine vision-based method and system for monitoring livestock feeding preferences. It collects real-time video and location information using sensors and cameras worn on livestock to obtain movement trajectories and feeding action sequences, forming a preliminary dataset. Subsequently, image preprocessing is used to remove noise and enhance contrast, identifying clear feeding frame sequences. A convolutional neural network is used to extract plant contours and texture features from keyframes to segment potential pasture areas. Color and shape information is then matched with a pre-set database to confirm specific pasture species. Finally, a random forest classifier is used to integrate time-series data to calculate feeding frequency and preference indicators, solving the problems of inaccurate data collection, difficulty in pasture identification, and incomplete behavioral analysis. This invention significantly improves the level of intelligence in animal husbandry, enables precise feeding decisions, optimizes pasture resource utilization, and improves livestock health and productivity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of animal husbandry technology, specifically relating to a method and system for monitoring livestock feed preferences based on machine vision. Background Technology

[0002] In agriculture and animal husbandry, research on livestock grazing behavior is of great significance, as it directly relates to the rational utilization of grassland resources and the healthy growth of livestock. Especially in pastoral areas, selective grazing by livestock not only affects the ecological balance of grasslands but may also lead to the overconsumption of certain grass species, thereby threatening the sustainable development of pastoral areas. Therefore, a deep understanding and monitoring of livestock grazing preferences has become a key issue for improving livestock management and protecting the ecological environment.

[0003] However, current research methods for livestock foraging behavior still have significant shortcomings. Many traditional methods rely on manual observation or simple recording, making it difficult to comprehensively capture the true foraging dynamics of livestock in their natural environment. These methods often fall short when faced with complex terrain and diverse grassland environments, failing to accurately reflect livestock preferences for different forages and providing real-time, continuous monitoring data, thus limiting the exploration of deeper patterns in foraging behavior.

[0004] A deeper technical challenge lies in accurately recording the specific process of livestock grazing in dynamic and complex natural environments. The primary challenge is capturing grazing behavior in real time. Because livestock activity on grasslands is highly random and mobile, traditional fixed-point observations struggle to cover their entire behavioral trajectory, leading to significant data omissions. This problem further complicates the identification of grazing targets, as livestock select from a wide variety of forage grasses during rapid movement, making it difficult for humans or simple equipment to distinguish specific grass species and their grazing frequency in a short period. For example, in a mixed grassland, a sheep may switch between different types of grass within minutes, but current technology cannot accurately record its preference for a particular grass or determine whether this choice is related to the grassland's distribution characteristics.

[0005] Therefore, how to capture livestock grazing behavior in real time and dynamically in natural environments, and accurately identify the types of forage they graze on, has become a key issue in improving livestock management and grassland resource protection. Solving this problem requires not only overcoming the challenge of the dynamism of behavioral recording, but also achieving precise identification of grazing targets in complex environments, providing a reliable basis for subsequent scientific guidance and resource optimization. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides a method and system for monitoring livestock feeding preferences based on machine vision. The aim is to capture livestock feeding behavior in real time and dynamically in a natural environment, accurately identify the types of forage they feed on, improve livestock management and grassland resource protection, and provide a reliable basis for subsequent scientific guidance and resource optimization.

[0007] To achieve the above objectives, the present invention provides the following solution:

[0008] A machine vision-based method for monitoring livestock feed preferences, the method comprising:

[0009] By collecting real-time video data and location information by wearable sensors and camera devices worn on livestock, the movement trajectory and feeding action sequence of livestock in the grassland environment are obtained, and a preliminary behavioral dataset is obtained.

[0010] Based on the preliminary behavioral dataset, image preprocessing techniques were used to remove noise and enhance contrast to obtain a feeding frame sequence.

[0011] Convolutional neural networks were used to extract features from key frames of the foraging frame sequence. Potential pasture areas were identified based on plant outlines and texture features appearing in the key frames, and segmented image regions were obtained.

[0012] Obtain color and shape information within the segmented image region. If the color and shape information matches the preset forage species database with a degree higher than a threshold, then confirm the specific forage species and obtain the recognition result set.

[0013] Based on the identification result set, a random forest classifier is used to integrate time series data to determine the feeding frequency and preference patterns of livestock for different types of forage grass, and to obtain a comprehensive preference index.

[0014] Preferably, the method for obtaining a feeding frame sequence by using image preprocessing techniques to remove noise and enhance contrast based on a preliminary behavioral dataset includes:

[0015] Image preprocessing methods were used to preliminarily clean the original images of the preliminary behavioral dataset, resulting in a first set of denoised images.

[0016] For the first image set, contrast enhancement techniques are applied to adjust the brightness and darkness distribution of the images to determine the second image set after contrast enhancement;

[0017] From the second image set, the salient feature regions of feeding behavior are obtained, and the target frames are separated by segmentation methods to obtain preliminary frame sequence fragments;

[0018] For the initial frame sequence segment, if noise interference is detected to exceed a preset threshold, the image quality is further optimized through smoothing to obtain an optimized third image set.

[0019] Based on the third image set, key time points with clear frame sequences are extracted to determine the continuous frame sequence associated with feeding behavior, thus obtaining the feeding frame sequence.

[0020] Preferably, the method of using a convolutional neural network to extract features from key frames of the foraging frame sequence, and determining potential pasture regions based on plant contours and texture features appearing in the key frames to obtain segmented image regions includes:

[0021] A convolutional neural network was used to process the key frames in the foraging frame sequence. Plant contour information and texture information were extracted for each frame image to obtain image classification and recognition results.

[0022] Based on the image classification and recognition results, potential pasture areas are identified, and the image portions that may contain pasture are determined.

[0023] For potential pasture areas, the intra-frame information processing results are obtained, and image data processing technology is used to refine the area boundaries to determine a more accurate pasture area range.

[0024] If the refined pasture area does not match the preset threshold conditions, the image data processing results are corrected a second time, and the data is processed in combination with intra-frame information to obtain the adjusted area range.

[0025] Based on the adjusted region range, image region segmentation is performed, and each region is independently labeled to obtain the segmented image region.

[0026] Preferably, the specific process of using a convolutional neural network to process keyframes in the foraging frame sequence, extracting plant contour and texture information for each frame image, and obtaining image classification and recognition results includes:

[0027] The image data of the keyframes is input into the CAM ResNet 18 network structure. First, it passes through a convolutional layer conv1 with a kernel size of 7×7 and a stride of 2. Then, it undergoes batch normalization, activation function, and downsampling by a 3×3 max pooling layer to transform the input image into a feature image.

[0028] Convolutional blocks with residual structures are added to conv2~conv5. The four convolutional modules perform feature extraction from shallow to deep layers. Each convolutional block includes two residual units, and each residual unit includes two convolutional layers. That is, plant contour information and texture information are extracted by stacking 3×3 convolutions. Residual structures are introduced every two convolutional layers.

[0029] Attention units are introduced after the first and last convolutional layers;

[0030] The image output after residual convolution is then processed by data normalization and global adaptive smoothing pooling, and then input into the flattening layer for convolution to convert multidimensional data into one dimension.

[0031] Finally, the one-dimensional image is input into the fully connected layer, and the classification and recognition results are output through the softmax classifier.

[0032] Preferably, the attention unit includes a channel attention module and a spatial attention module;

[0033] The channel attention module includes:

[0034] Mc(F)=σ(MLP(A(F))+MLP(M(F)));

[0035] F1′=Mc(F) F;

[0036] In the formula, Mc(·) is the channel attention weight function, F is the image input feature, A(·) is the average pooling layer function, M(·) is the max pooling layer function, MLP(·) is the multilayer perceptron function, σ(·) is the sigmoid function, and F1′ is the feature obtained using the channel attention module. This indicates pixel-by-pixel multiplication;

[0037] The spatial attention module includes:

[0038] Learnable Gaussian kernel Gσ:

[0039] Gσ(i,j)=exp(-(ic) 2 +(jc) 2 ) / (2σ 2 ));

[0040] In the formula, (i,j) is the pixel position of the image, c is the kernel center, σ is the standard deviation, which is updated through backpropagation along with the network, and exp(·) is the natural exponential function;

[0041] Smooth convolution:

[0042] Asmooth=A Gσ;

[0043] In the formula, Asmooth is the smoothed attention map, and A is the coarse attention map output by the network. This represents a 2D convolution with padding.

[0044] min-max normalization:

[0045] Anorm=(Asmooth-minA) / (maxA-minA+ε);

[0046] In the formula, Anorm represents the normalized attention map, minA and maxA are the global minimum and maximum values ​​on the smoothed attention map; ε is a constant to prevent division by zero.

[0047] Weighted image input features:

[0048] F2′=F Anorm;

[0049] In the formula, F2′ represents the feature obtained using the spatial attention module;

[0050] Finally, the image features F′ output by the attention unit are obtained through weighted fusion:

[0051] F′=aF1′+bF2′;

[0052] In the formula, a and b are weighting coefficients.

[0053] Preferably, the method for obtaining color and shape information within the segmented image region, and confirming the specific forage species by matching the color and shape information with a preset forage species database to a higher degree than a threshold, includes:

[0054] Color and shape information are extracted from the segmented image regions. The color distribution is recorded using a pixel-level analysis method, and the shape contour is outlined using a geometric algorithm to obtain the region feature dataset.

[0055] For the regional feature dataset, feature comparison is performed using a pre-set forage species database, and support vector machine algorithm is used to classify and match color and shape information to obtain a preliminary matching result set;

[0056] If the matching degree in the preliminary matching result set is higher than the preset threshold, the corresponding forage grass type is recorded as a candidate type, and a candidate type list is obtained.

[0057] The candidate species list is verified a second time. Combined with the distribution information of forage species stored in the preset forage species database, if the candidate species are consistent with the distribution information of forage species, the final forage species are determined and the confirmed species set is obtained.

[0058] Based on the confirmed species set, the identification information of all image regions is integrated to obtain a set of identification results for pasture species.

[0059] Preferably, based on the identification result set, a random forest classifier is used to integrate time series data to determine the grazing frequency and preference patterns of livestock for different forage species, and to obtain a comprehensive preference index. This includes the following methods:

[0060] The original dataset containing timestamps is collected from the recognition results set. By cleaning and formatting the original dataset, structured time series data is obtained.

[0061] For structured time series data, a preset segmentation method is used to divide the data into multiple subsets according to time periods. Features are extracted from each subset to obtain the activity pattern features of livestock in different time periods.

[0062] Based on the activity pattern characteristics, a random forest classifier was used to classify each subset, analyze the interaction between livestock and different forage species, and determine the grazing frequency distribution.

[0063] Key data are extracted from the grazing frequency distribution and combined with forage species information. If the grazing frequency of a certain forage species is higher than a preset threshold, it is marked as a high-preference species, and the preference pattern classification result is obtained.

[0064] Based on the preference pattern classification results, the preference weight of each type of forage is calculated, and a comprehensive preference index is obtained through a weighted aggregation method.

[0065] The present invention also provides a machine vision-based livestock feeding preference monitoring system, the system being used to implement the aforementioned method, the system comprising: a data acquisition module, an image preprocessing module, a feature extraction module, a forage identification module, and a behavior analysis module;

[0066] The data acquisition module is used to collect real-time video data and location information through wearable sensors and camera devices worn on livestock, to obtain the movement trajectory and feeding action sequence of livestock in the grassland environment, and to obtain a preliminary behavioral dataset.

[0067] The image preprocessing module is used to remove noise and enhance contrast based on the preliminary behavioral dataset to obtain a feeding frame sequence;

[0068] The feature extraction module is used to extract features from key frames of the foraging frame sequence using a convolutional neural network. Based on the plant outline and texture features appearing in the key frames, potential pasture areas are identified, and segmented image regions are obtained.

[0069] The forage identification module is used to acquire color and shape information within the segmented image region. If the color and shape information matches the preset forage type database with a degree higher than a threshold, the specific forage type is confirmed and an identification result set is obtained.

[0070] The behavior analysis module is used to integrate time series data based on the identification result set using a random forest classifier to determine the feeding frequency and preference patterns of livestock for different types of forage, and obtain a comprehensive preference index.

[0071] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0072] This invention discloses a machine vision-based method and system for monitoring livestock feeding preferences. It addresses the unique business scenario in traditional animal husbandry where real-time monitoring of livestock feeding frequency and preference patterns for different forage species in grassland environments is difficult, leading to inefficient feeding management and nutritional optimization. This problem combines the logical challenges of inaccurate data collection, difficulty in forage identification, and incomplete behavioral analysis. This invention uses sensors and cameras worn on livestock to collect real-time video and location information, obtaining movement trajectories and feeding action sequences to form a preliminary dataset. Subsequently, image preprocessing is used to remove noise and enhance contrast, identifying clear feeding frame sequences. A convolutional neural network is used to extract plant contours and texture features from keyframes to segment potential forage areas. Color and shape information is then matched with a pre-set database to confirm specific forage species. Finally, a random forest classifier is used to integrate time-series data and calculate feeding frequency and preference indicators, thereby solving the aforementioned problems. This invention significantly improves the level of intelligence in animal husbandry, enables precise feeding decisions, optimizes forage resource utilization, and improves livestock health outcomes. Attached Figure Description

[0073] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0074] Figure 1 This is a schematic diagram of a machine vision-based livestock feeding preference monitoring method according to an embodiment of the present invention;

[0075] Figure 2 This is a schematic diagram of the CAM ResNet 18 network structure according to an embodiment of the present invention;

[0076] Figure 3 This is a schematic diagram of a machine vision-based livestock feed preference monitoring system according to an embodiment of the present invention. Detailed Implementation

[0077] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0078] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0079] Example 1

[0080] This invention provides a machine vision-based method for monitoring livestock feed preferences, comprising:

[0081] By collecting real-time video data and location information by wearable sensors and camera devices worn on livestock, the movement trajectory and feeding action sequence of livestock in the grassland environment are obtained, and a preliminary behavioral dataset is obtained.

[0082] Based on the preliminary behavioral dataset, image preprocessing techniques were used to remove noise and enhance contrast to obtain a feeding frame sequence.

[0083] Convolutional neural networks were used to extract features from key frames of the foraging frame sequence. Potential pasture areas were identified based on plant outlines and texture features appearing in the key frames, and segmented image regions were obtained.

[0084] Obtain color and shape information within the segmented image region. If the color and shape information matches the preset forage species database with a degree higher than a threshold, then confirm the specific forage species and obtain the recognition result set.

[0085] Based on the identification result set, a random forest classifier is used to integrate time series data to determine the feeding frequency and preference patterns of livestock for different types of forage grass, and to obtain a comprehensive preference index.

[0086] like Figure 1 As shown, the specific implementation process of the present invention is as follows:

[0087] S101. Real-time video data and location information are collected by wearing sensors and cameras on livestock to obtain the movement trajectory and grazing action sequence of livestock in the grassland environment, resulting in a preliminary behavioral dataset. Specifically:

[0088] Wearable sensors and camera devices are used to collect real-time video data and location tracking data of livestock in grassland environments, obtaining raw records of livestock movement trajectories and foraging action sequences, and constructing a preliminary behavioral dataset.

[0089] For example, when collecting livestock data through wearable sensors and camera devices, one can imagine monitoring a herd of cattle in real time on a vast grassland. Each cow wears a sensor with GPS positioning capabilities to record its location information, while camera devices, such as neck-mounted cameras, capture the cow's movement and feeding actions.

[0090] S102. Based on the preliminary behavior dataset, image preprocessing techniques are used to remove noise and enhance contrast to obtain a feeding frame sequence. Specifically:

[0091] Image preprocessing methods were used to preliminarily clean the original images of the preliminary behavioral dataset, resulting in a first set of denoised images.

[0092] For the first image set, contrast enhancement techniques are applied to adjust the brightness and darkness distribution of the images to determine the second image set after contrast enhancement;

[0093] From the second image set, the salient feature regions of feeding behavior are obtained, and the target frames are separated by segmentation methods to obtain preliminary frame sequence fragments;

[0094] For the initial frame sequence segment, if noise interference is detected to exceed a preset threshold, the image quality is further optimized through smoothing to obtain an optimized third image set.

[0095] Based on the third image set, key time points with clear frame sequences are extracted to determine the continuous frame sequence associated with feeding behavior, thus obtaining the feeding frame sequence.

[0096] S103. A convolutional neural network is used to extract features from key frames of the foraging frame sequence. Based on the plant outlines and texture features appearing in the key frames, potential pasture areas are identified, and segmented image regions are obtained. Specifically:

[0097] A convolutional neural network was used to process the key frames in the foraging frame sequence. Plant contour information and texture information were extracted for each frame image to obtain image classification and recognition results.

[0098] Based on the image classification and recognition results, potential pasture areas are identified, and the image portions that may contain pasture are determined.

[0099] For potential pasture areas, the intra-frame information processing results are obtained, and image data processing technology is used to refine the area boundaries to determine a more accurate pasture area range.

[0100] If the refined pasture area does not match the preset threshold conditions, the image data processing results are corrected a second time, and the data is processed in combination with intra-frame information to obtain the adjusted area range.

[0101] Based on the adjusted region range, image region segmentation is performed, and each region is independently labeled to obtain the segmented image region.

[0102] Furthermore, the convolutional neural network used in this invention is an improved and adjusted version of the classic ResNet 18 model, resulting in the CAM ResNet 18 network structure, as follows: Figure 2As shown, the input image is a keyframe image from the feeding frame sequence. After the keyframe image data enters the CAM ResNet 18 network structure, it first passes through a convolutional layer conv1 with a 7×7 kernel and a stride of 2. Then, it undergoes batch normalization, activation function, and downsampling with a 3×3 max pooling layer to transform the input image into a feature image, greatly reducing the storage space required. conv2~conv5 represent convolutional blocks with added residual structures. The four convolutional modules perform feature extraction from shallow to deep layers. Each convolutional block includes two residual units, and each residual unit includes two convolutional layers. That is, plant contour and texture information are extracted by stacking 3×3 convolutions, and residual structures are introduced every two convolutional layers. Attention units are introduced after the first and last convolutional layers to enhance the extraction of effective information, improve the network model's expressive power, and facilitate the loading of pre-training parameters. The output image after the continuous residual convolution is then subjected to data normalization and global adaptive smooth pooling. The data normalization algorithm can accelerate the convergence speed and improve the model accuracy. At this point, due to continuous convolution, the data cannot be fully connected. To address this, the data is input into a flattening layer for convolution, transforming the multidimensional data into a one-dimensional structure. Finally, the resulting image is input into a fully connected layer. To prevent overfitting of the neural network, a random deactivation method is used, with the parameter set to 0.6, randomly discarding 1 / 3 of the neurons. The image classification and recognition results are then output through a softmax classifier.

[0103] The attention unit consists of two sub-modules: the channel attention module and the spatial attention module. The channel attention module focuses on meaningful features in the image, while the spatial attention module focuses on the most informative areas.

[0104] The channel attention module compresses the feature map space into a one-dimensional vector. In this process, global average pooling and parallel global max pooling are used to compress the channel features, which better aggregates feature mapping information. The input features, after two parallel pooling operations (average pooling and max pooling), are fed into a weight-shared multilayer perceptron (MLP). Then, the output features of the MLP are summed element-wise, and after passing through a sigmoid non-linear activation function, a channel attention Mc(F) is generated. This Mc(F) is then multiplied element-wise with the input feature map to obtain feature F1′, which serves as the input to the next convolutional block. The formula for this process is as follows:

[0105] Mc(F)=σ(MLP(A(F))+MLP(M(F)));

[0106] F1′=Mc(F) F;

[0107] In the formula, Mc(·) is the channel attention weight function, F is the image input feature, A(·) is the average pooling layer function, M(·) is the max pooling layer function, MLP(·) is the multilayer perceptron function, σ(·) is the sigmoid function, and F1′ is the feature obtained using the channel attention module. This indicates pixel-by-pixel multiplication.

[0108] The spatial attention module uses a learnable Gaussian kernel Gσ to "smooth" the feature map, removing noise and spikes; then it uses min-max normalization to compress the values ​​back to [0,1], resulting in an attention map Anorm with natural edge transitions and normalized numerical ranges; finally, it uses weighted image input features to achieve a "soft mask".

[0109] Learnable Gaussian kernel Gσ:

[0110] Gσ(i,j)=exp(-(ic) 2 +(jc) 2 ) / (2σ 2 ));

[0111] In the formula, (i,j) represents the pixel position of the image, c is the kernel center, σ is the standard deviation, which is updated through backpropagation along with the network, and exp(·) is the natural exponential function.

[0112] The learnable Gaussian kernel Gσ can smooth out the jagged edges of the target without blurring the entire image.

[0113] Smooth convolution:

[0114] Asmooth=A Gσ;

[0115] In the formula, Asmooth is the smoothed attention map, and A is the coarse attention map output by the network. This represents a 2D convolution with padding.

[0116] This invention suppresses high-frequency noise through smooth convolution, and the target edge changes from the original "step-like" to "slope-like".

[0117] min-max normalization:

[0118] Anorm=(Asmooth-minA) / (maxA-minA+ε);

[0119] In the formula, Anorm represents the normalized attention map, minA and maxA are the global minimum and maximum values ​​on the smoothed attention map, and ε is a constant to prevent division by zero.

[0120] This invention uses min-max normalization to ensure that the value range strictly falls within [0,1]; even if all attention values ​​in a certain image are almost the same (maxA-minA≈0), ε can still maintain a stable value.

[0121] Weighted image input features:

[0122] F2′=F Anorm;

[0123] In the formula, F2′ represents the feature obtained using the spatial attention module. This invention uses weighted original feature maps to allow important regions (Anorm≈1) to pass through almost without loss.

[0124] Finally, the image features F′ output by the attention unit are obtained through weighted fusion:

[0125] F′=aF1′+bF2′;

[0126] In the formula, a and b are weighting coefficients.

[0127] The Adam optimizer can calculate adaptive learning rates for different parameters, offering advantages such as low memory footprint, ease of application, and high computational efficiency. It can be applied to sparse gradients and non-stationary objectives. Simultaneously using an adaptive learning rate with learning rate decay promotes better model convergence; cosine annealing reduces the learning rate using a cosine function. This invention introduces cosine annealing to decay the learning rate in the Adam optimizer, which helps to quickly reach the optimal solution and reduces later oscillations.

[0128] S104. Obtain the color and shape information within the segmented image region. If the color and shape information matches the preset forage type database with a degree higher than a threshold, confirm the specific forage type and obtain the recognition result set. Specifically:

[0129] Color and shape information are extracted from the segmented image regions. The color distribution is recorded using a pixel-level analysis method, and the shape contour is outlined using a geometric algorithm to obtain the region feature dataset.

[0130] For the regional feature dataset, feature comparison is performed using a pre-set forage species database, and support vector machine algorithm is used to classify and match color and shape information to obtain a preliminary matching result set;

[0131] If the matching degree in the preliminary matching result set is higher than the preset threshold, the corresponding forage grass type is recorded as a candidate type, and a candidate type list is obtained.

[0132] The candidate species list is verified a second time. Combined with the distribution information of forage species stored in the preset forage species database, if the candidate species are consistent with the distribution information of forage species, the final forage species are determined and the confirmed species set is obtained.

[0133] Based on the confirmed species set, the identification information of all image regions is integrated to generate a complete set of pasture species identification results.

[0134] S105. Based on the identification result set, a random forest classifier is used to integrate time series data to determine the grazing frequency and preference patterns of livestock for different types of forage grasses, obtaining a comprehensive preference index, specifically:

[0135] The original dataset containing timestamps is collected from the recognition results set. By cleaning and formatting the original dataset, structured time series data is obtained.

[0136] For structured time series data, a preset segmentation method is used to divide the data into multiple subsets according to time periods. Features are extracted from each subset to obtain the activity pattern features of livestock in different time periods.

[0137] Based on the activity pattern characteristics, a random forest classifier was used to classify each subset, analyze the interaction between livestock and different forage species, and determine the grazing frequency distribution.

[0138] Key data are extracted from the grazing frequency distribution and combined with forage species information. If the grazing frequency of a certain forage species is higher than a preset threshold, it is marked as a high-preference species, and the preference pattern classification result is obtained.

[0139] Based on the preference pattern classification results, the preference weight of each type of forage is calculated, and a comprehensive preference index is obtained through a weighted aggregation method.

[0140] In summary, this invention proposes a machine vision-based method for monitoring livestock feeding preferences. It addresses the unique business scenario in traditional animal husbandry where real-time monitoring of livestock feeding frequency and preference patterns for different forage species in grassland environments is difficult, leading to inefficient feeding management and nutritional optimization. This problem combines the logical challenges of inaccurate data collection, difficulty in forage identification, and incomplete behavioral analysis. This invention uses sensors and cameras worn on livestock to collect real-time video and location information, obtaining movement trajectories and feeding action sequences to form a preliminary dataset. Subsequently, image preprocessing is used to remove noise and enhance contrast, identifying clear feeding frame sequences. A convolutional neural network is used to extract plant contours and texture features from keyframes to segment potential forage areas. Color and shape information is then matched with a pre-set database to confirm specific forage species. Finally, a random forest classifier is used to integrate time-series data and calculate feeding frequency and preference indicators, thereby solving the aforementioned problems. This invention significantly improves the intelligence level of animal husbandry, enables precise feeding decisions, optimizes forage resource utilization, and improves livestock health outcomes.

[0141] Example 2

[0142] like Figure 3 As shown, based on the same inventive concept, the present invention also provides a machine vision-based livestock feeding preference monitoring system for implementing the methods described in the foregoing embodiments. The system includes: a data acquisition module, an image preprocessing module, a feature extraction module, a forage identification module, and a behavior analysis module.

[0143] The data acquisition module is used to collect real-time video data and location information through wearable sensors and camera devices worn on livestock, to obtain the movement trajectory and feeding action sequence of livestock in the grassland environment, and to obtain a preliminary behavioral dataset.

[0144] The image preprocessing module is used to remove noise and enhance contrast based on the preliminary behavioral dataset to obtain a feeding frame sequence;

[0145] The feature extraction module is used to extract features from key frames of the foraging frame sequence using a convolutional neural network. Based on the plant outline and texture features appearing in the key frames, potential pasture areas are identified, and segmented image regions are obtained.

[0146] The forage identification module is used to acquire color and shape information within the segmented image region. If the color and shape information matches the preset forage type database with a degree higher than a threshold, the specific forage type is confirmed and an identification result set is obtained.

[0147] The behavior analysis module is used to integrate time series data based on the identification result set using a random forest classifier to determine the feeding frequency and preference patterns of livestock for different types of forage, and obtain a comprehensive preference index.

[0148] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for monitoring livestock feed preferences based on machine vision, characterized in that, The method includes: By collecting real-time video data and location information by wearable sensors and camera devices worn on livestock, the movement trajectory and feeding action sequence of livestock in the grassland environment are obtained, and a preliminary behavioral dataset is obtained. Based on the preliminary behavioral dataset, image preprocessing techniques were used to remove noise and enhance contrast to obtain a feeding frame sequence. Convolutional neural networks were used to extract features from key frames of the foraging frame sequence. Potential pasture areas were identified based on plant outlines and texture features appearing in the key frames, and segmented image regions were obtained. Obtain color and shape information within the segmented image region. If the color and shape information matches the preset forage species database with a degree higher than a threshold, then confirm the specific forage species and obtain the recognition result set. Based on the identification result set, a random forest classifier is used to integrate time series data to determine the feeding frequency and preference patterns of livestock for different types of forage grass, and to obtain a comprehensive preference index. Methods for extracting features from keyframes of a foraging frame sequence using convolutional neural networks, identifying potential pasture regions based on plant contours and textures in the keyframes, and obtaining segmented image regions include: A convolutional neural network is used to process keyframes in the foraging frame sequence. Plant contour and texture information are extracted from each frame to obtain image classification and recognition results. The specific process includes: The image data of the keyframes is input into the CAM ResNet 18 network structure. First, it passes through a convolutional layer conv1 with a kernel size of 7×7 and a stride of 2. Then, it undergoes batch normalization, activation function, and downsampling by a 3×3 max pooling layer to transform the input image into a feature image. Convolutional blocks with residual structures are added to conv2~conv5. The four convolutional modules perform feature extraction from shallow to deep layers. Each convolutional block includes two residual units, and each residual unit includes two convolutional layers. That is, plant contour information and texture information are extracted by stacking 3×3 convolutions. Residual structures are introduced every two convolutional layers. Attention units are introduced after the first and last convolutional layers; The image output after residual convolution is then processed by data normalization and global adaptive smoothing pooling, and then input into the flattening layer for convolution to convert multidimensional data into one dimension. Finally, the one-dimensional image is input into the fully connected layer, and the classification and recognition results are output through the softmax classifier; The attention unit includes a channel attention module and a spatial attention module; The channel attention module includes: Mc(F)=σ(MLP(A(F))+MLP(M(F))); F1′=Mc(F) F; In the formula, Mc(·) is the channel attention weight function, F is the image input feature, A(·) is the average pooling layer function, M(·) is the max pooling layer function, MLP(·) is the multilayer perceptron function, σ(·) is the sigmoid function, and F1′ is the feature obtained using the channel attention module. This indicates pixel-by-pixel multiplication; The spatial attention module includes: Learnable Gaussian kernel Gσ: Gσ(i,j)=exp(-((i-c) 2 +(j-c) 2 ) / (2σ 2 )); In the formula, (i,j) is the pixel position of the image, c is the kernel center, σ is the standard deviation, which is updated through backpropagation along with the network, and exp(·) is the natural exponential function; Smooth convolution: Asmooth=A Gσ; In the formula, Asmooth is the smoothed attention map, and A is the coarse attention map output by the network. This represents a 2D convolution with padding. min-max normalization: Anorm=(Asmooth-minA) / (maxA-minA+ε); In the formula, Anorm represents the normalized attention map, minA and maxA are the global minimum and maximum values ​​on the smoothed attention map; ε is a constant to prevent division by zero. Weighted image input features: F2′=F Anorm; In the formula, F2′ represents the feature obtained using the spatial attention module; Finally, the image features F′ output by the attention unit are obtained through weighted fusion: F′=aF1′+bF2′; In the formula, a and b are weighting coefficients.

2. The method according to claim 1, characterized in that, Based on the preliminary behavioral dataset, the methods for obtaining the feeding frame sequence using image preprocessing techniques to remove noise and enhance contrast include: Image preprocessing methods were used to preliminarily clean the original images of the preliminary behavioral dataset, resulting in a first set of denoised images. For the first image set, contrast enhancement techniques are applied to adjust the brightness and darkness distribution of the images to determine the second image set after contrast enhancement; From the second image set, the salient feature regions of feeding behavior are obtained, and the target frames are separated by segmentation methods to obtain preliminary frame sequence fragments; For the initial frame sequence segment, if noise interference is detected to exceed a preset threshold, the image quality is further optimized through smoothing to obtain an optimized third image set. Based on the third image set, key time points with clear frame sequences are extracted to determine the continuous frame sequence associated with feeding behavior, thus obtaining the feeding frame sequence.

3. The method according to claim 1, characterized in that, Methods that use convolutional neural networks to extract features from keyframes of foraging frame sequences, identify potential pasture regions based on plant contours and texture features appearing in the keyframes, and obtain segmented image regions also include: Based on the image classification and recognition results, potential pasture areas are identified, and the image portions that may contain pasture are determined. For potential pasture areas, the intra-frame information processing results are obtained, and image data processing technology is used to refine the area boundaries to determine a more accurate pasture area range. If the refined pasture area does not match the preset threshold conditions, the image data processing results are corrected a second time, and the data is processed in combination with intra-frame information to obtain the adjusted area range. Based on the adjusted region range, image region segmentation is performed, and each region is independently labeled to obtain the segmented image region.

4. The method according to claim 1, characterized in that, The method for obtaining the identification result set includes: acquiring color and shape information within the segmented image region; if the color and shape information matches a preset forage species database with a degree higher than a threshold; and then confirming the specific forage species. Color and shape information are extracted from the segmented image regions. The color distribution is recorded using a pixel-level analysis method, and the shape contour is outlined using a geometric algorithm to obtain the region feature dataset. For the regional feature dataset, feature comparison is performed using a pre-set forage species database, and support vector machine algorithm is used to classify and match color and shape information to obtain a preliminary matching result set; If the matching degree in the preliminary matching result set is higher than the preset threshold, the corresponding forage grass type is recorded as a candidate type, and a candidate type list is obtained. The candidate species list is verified a second time. Combined with the distribution information of forage species stored in the preset forage species database, if the candidate species are consistent with the distribution information of forage species, the final forage species are determined and the confirmed species set is obtained. Based on the confirmed species set, the identification information of all image regions is integrated to obtain a set of identification results for pasture species.

5. The method according to claim 1, characterized in that, Based on the identification result set, a random forest classifier is used to integrate time series data to determine the grazing frequency and preference patterns of livestock for different types of forage grasses, and the methods for obtaining comprehensive preference indices include: The original dataset containing timestamps is collected from the recognition results set. By cleaning and formatting the original dataset, structured time series data is obtained. For structured time series data, a preset segmentation method is used to divide the data into multiple subsets according to time periods. Features are extracted from each subset to obtain the activity pattern features of livestock in different time periods. Based on the activity pattern characteristics, a random forest classifier was used to classify each subset, analyze the interaction between livestock and different forage species, and determine the grazing frequency distribution. Key data are extracted from the grazing frequency distribution and combined with forage species information. If the grazing frequency of a certain forage species is higher than a preset threshold, it is marked as a high-preference species, and the preference pattern classification result is obtained. Based on the preference pattern classification results, the preference weight of each type of forage is calculated, and a comprehensive preference index is obtained through a weighted aggregation method.

6. A machine vision-based livestock feed preference monitoring system, said system being used to implement the method described in any one of claims 1-5, characterized in that, The system includes: a data acquisition module, an image preprocessing module, a feature extraction module, a pasture recognition module, and a behavior analysis module; The data acquisition module is used to collect real-time video data and location information through wearable sensors and camera devices worn on livestock, to obtain the movement trajectory and feeding action sequence of livestock in the grassland environment, and to obtain a preliminary behavioral dataset. The image preprocessing module is used to remove noise and enhance contrast based on the preliminary behavioral dataset to obtain a feeding frame sequence; The feature extraction module is used to extract features from key frames of the foraging frame sequence using a convolutional neural network. Based on the plant outline and texture features appearing in the key frames, potential pasture areas are identified, and segmented image regions are obtained. The forage identification module is used to acquire color and shape information within the segmented image region. If the color and shape information matches the preset forage type database with a degree higher than a threshold, the specific forage type is confirmed and an identification result set is obtained. The behavior analysis module is used to integrate time series data based on the identification result set using a random forest classifier to determine the feeding frequency and preference patterns of livestock for different types of forage, and obtain a comprehensive preference index.

Citation Information

Patent Citations

  • Strawberry development process objective classification evaluation method based on CBAM-ResNet34 model

    CN118447316A

  • Complex traffic road scene image segmentation detection method based on multi-scale network

    CN119445101A