Non-contact weight measurement method based on two-dimensional pig contour image information
By employing a non-contact weight measurement method based on two-dimensional pig contour images, and utilizing lightweight networks and multi-head attention mechanisms, the problems of pig activity constraints and high computational costs in existing technologies are solved, enabling real-time, rapid, and accurate measurement of pig weight.
Patent Information
- Application Number
- PCT/CN2024/128322
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-10-22
- Filing Date
- 2024-10-30
- Publication Date
- 2026-04-30
AI Technical Summary
Existing non-contact weight measurement methods require restricting pig activity, making it impossible to monitor pig weight in real-time in actual production environments, and the computational cost is high.
A non-contact weight measurement method based on two-dimensional pig contour image information is adopted. The method uses RGB camera and radio frequency identification technology to acquire pig images and numbers. Combined with a lightweight network and multi-head attention mechanism, the pig contour is quickly extracted and the weight is measured, eliminating the complex calculation of traditional deep neural networks.
It enables real-time, rapid, and accurate weight measurement of pigs while they are moving freely, reducing computational costs and making it suitable for actual production environments.
Smart Images

Figure CN2024128322_30042026_PF_FP_ABST
Abstract
Description
A non-contact method for measuring the weight of pigs based on two-dimensional pig contour images Technical Field
[0001] This invention relates to the field of intelligent livestock and poultry farming technology, specifically to a non-contact weight measurement method based on two-dimensional pig outline image information. Background Technology
[0002] Pig weight is a crucial indicator in the livestock industry, directly impacting farm profitability, breeding costs, and pork quality. Frequent weight measurements are necessary during pig farming. Traditionally, pig weight is measured manually. In recent years, with the development of intelligent livestock farming technologies, non-contact weight measurement has emerged. Compared to traditional manual weighing, non-contact weight measurement eliminates contact with the pig's body, reducing animal stress and potential injury, while also minimizing monitoring and data collection time and labor costs. In recent years, non-contact weight measurement methods have developed two main branches: morphological methods and deep learning methods.
[0003] The focus of morphological methods is to extract morphological features of pigs, such as body length and width, and then establish regression equations based on these features before measuring the pig's weight. Morphological methods require the pig to maintain a specific posture and be within a certain area, especially when using two-dimensional images, where the requirements are even more stringent. This limitation makes the method less applicable and flexible in actual production.
[0004] Deep learning methods can overcome the aforementioned limitations. They can measure the weight of unconstrained pigs using a whole or segmented image of a single pig as input. However, a significant drawback of this method is that it typically requires deep neural networks for learning and inference, leading to increased computation time, making real-time weight measurement impossible, and requiring the purchase of computing equipment, thus increasing the economic burden on farms. Technical issues
[0005] Existing non-contact weight measurement methods still have some technical problems and cannot be deployed in actual production environments. For example, they require restraint of pig activity and require pigs to maintain a specific posture, and cannot monitor pig weight in real time in actual production environments. Technical solutions
[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a non-contact weight measurement method based on two-dimensional pig outline image information. This method can monitor the weight of pigs in the actual production environment in real time without restricting the pigs' activities or requiring them to maintain a specific posture.
[0007] The objective of this invention is achieved through the following technical solution: a non-contact weight measurement method based on two-dimensional pig contour image information, comprising the following steps:
[0008] a. Data collection:
[0009] a1. Use a camera installed above the pigpen to acquire two-dimensional images of the pig's back, stream the video stream from the camera via the RTSP protocol, and use perceptual hashing technology to filter similar frames in the video stream to obtain images of the pig and visual marking information of the pig's back.
[0010] a2. Use radio frequency identification (RFID) technology to obtain pig identification numbers and record them in a database;
[0011] a3. Combine the visual marking information on the back of the pigs to obtain the number of each pig in the pig image;
[0012] b. Contour extraction:
[0013] b1. Use a lightweight network as the backbone network to process the image, obtain feature sets at different resolutions, and then use iterative deep fusion technology to fuse the feature sets to obtain the feature map of the image.
[0014] b2. Use convolutional layers to process the feature maps to obtain the heatmap of the pig's center point and the corresponding contour coordinate map. Then, based on these two maps, use the center point to perform regression to obtain the initial contour of each pig in the image.
[0015] b3. Extract the corresponding features from the feature map using the initial contour, and perform image normalization processing on the initial contour as a position code. Concatenate the features and the position code and input them into the multi-head attention layer to obtain the offset of the initial contour, and finally obtain the fine back contour.
[0016] c. Weight measurement:
[0017] c1. Perform image normalization and self-normalization on the fine contour information of the pig's back, and then stitch the obtained information together;
[0018] c2. Using linear projection, the information is mapped to a high-dimensional feature space;
[0019] c3. Use a multi-head attention mechanism to complete information fusion and capture feature dependencies;
[0020] c4. Use adaptive pooling to reduce dimensionality along the feature dimension;
[0021] c5. Use fully connected layers to regress pig weight.
[0022] In step a1, the perceptual hashing technology includes the following steps:
[0023] The first Frame of images Convert to grayscale image and resize the image. Then, apply the discrete cosine transform and take the top left corner. coefficient matrix ;
[0024] right Based on its mean Apply a threshold to obtain the hash string. ,in:
[0025]
[0026] Use the same steps as described above to process the first... Frame of images Process and obtain Then, Hamming distance was used to calculate the similarity between the two hash strings. :
[0027]
[0028] If similarity If the value is greater than 15, the two frames are considered dissimilar; otherwise, the current frame will be filtered out, and the next frame will be captured, repeating all the above steps.
[0029] In step a1, the visual marker information is uniformly sampled from the silhouette of the pig's back. The set of coordinates of points .
[0030] In step a2, the pig number is obtained using radio frequency identification technology, and the RFID data of the pig's ear tag is read using an ear tag reader.
[0031] It also includes step a4, which uses a scale to obtain the weight information of the pigs, and combines the pig images and pig numbers to label the data and generate a dataset for subsequent network training.
[0032] In step c, the fine back contour information is obtained by uniformly sampling from the back contour of the pig. The set of coordinates of points .
[0033] In the contour extraction step, this invention uses a contour extraction network (CIEN) to acquire the contour information of the pig's back. It initializes the contour and iteratively refines the coarse contour, enabling efficient extraction of the pig's contour. Its main innovation lies in employing Contour Self-attention, utilizing contour coordinate normalization as positional information and concatenating it with contour features. Multi-head attention is then used to predict the contour offset, resulting in the final refined contour.
[0034] In the weight measurement step, the weight estimation network (LWEN) is used to directly measure the weight of pigs using the pig's back contour information. It abandons the convolutional neural network structure widely used in existing research. Since it uses the pig's back contour information as input information, the weight of pigs can be measured in just a few steps, without the need for time-consuming and laborious calculations through a large number of convolutional layers. Beneficial effects
[0035] This invention allows for the measurement of the weight of freely moving and feeding pigs in a real-world production environment without restricting their movement or requiring them to maintain a specific posture, without causing any stimulation to the pigs. This invention is fast, efficient, and highly accurate, providing real-time monitoring of pig weight. It uses non-contact weight measurement based on two-dimensional images, significantly reducing computational costs. This invention can be deployed on a large scale in actual pig farm production, providing decision support for pig farming enterprises. Attached Figure Description
[0036] Figure 1 is a schematic diagram of the present invention;
[0037] Figure 2 is a block diagram illustrating the principle of data acquisition;
[0038] Figure 3 is a block diagram illustrating the principle of contour extraction;
[0039] Figure 4 is a block diagram illustrating the principle of weight measurement. Embodiments of the present invention
[0040] The present invention will now be described in detail with reference to the accompanying drawings.
[0041] As shown in Figure 1, a non-contact weight measurement method based on two-dimensional pig contour image information includes data acquisition, contour extraction, and weight measurement. The data acquisition process is completed by an RGB camera and an ear tag reader. Contour extraction includes feature extraction, contour initialization, and contour evolution. Weight measurement includes information fusion and regression of contour information to measure the weight of pigs.
[0042] As shown in Figure 2, data collection includes the following steps:
[0043] An RGB camera was installed above the pigpen, and the pigs' numbers were marked on their backs using crayons or other tools. The camera stream was then captured via the RTSP protocol, and a perceptual hashing algorithm was used to filter similar frames.
[0044] The first Frame of images Convert to grayscale image and resize the image. ,get ;
[0045] For images Apply the discrete cosine transform and take the top left corner. coefficient matrix ;
[0046] Calculate the mean of the coefficient matrix The coefficients greater than the mean are set to 1, and the others are set to 0, resulting in two hash strings of length 64. ,in:
[0047]
[0048] Use the same steps as described above to process the first... Frame of images Process it to obtain its hash string. ;
[0049] Calculate the similarity between two hash strings using Hamming distance. :
[0050]
[0051] If similarity If the value is greater than 15, the two frames are considered dissimilar; otherwise, the current frame will be filtered out.
[0052] After filtering similar frames, images of pigs and visual marking information on the backs of pigs can be obtained.
[0053] The RFID data from pig ear tags is read using an ear tag reader and saved to a MySQL database. Combined with visual tags on the pigs' backs, the individual pig numbers in the images can be obtained. Then, tools such as scales are used to obtain the pigs' weight information. This data, along with the aforementioned pig images and numbers, is then labeled to generate a dataset for subsequent network training.
[0054] As shown in Figure 3, the contour extraction step includes the following steps:
[0055] Pig images are input into the backbone network MobileNetV2 to obtain the feature set;
[0056] Feature maps are obtained using iterative deep fusion techniques. ,in The size is 4 times the size of the image downsampled;
[0057] right Convolution is applied to obtain the central heat map and the contour coordinate map, respectively. Then, based on the center point regression, the initial contour coordinate set of the pigs is obtained. ;
[0058] Will Normalization is performed to obtain the position code. :
[0059]
[0060] in , for The corresponding minimum value, and , It is the maximum value;
[0061] according to from Extract contour features ;
[0062] contour features With position encoding The data is concatenated along the feature dimension, and information fusion and dependency capture are performed using a multi-head attention mechanism.
[0063] Get contour offset The initial contour is added to the offset to obtain the final fine contour.
[0064] As shown in Figure 4, weight estimation includes the following steps:
[0065] Using the above-mentioned fine contour coordinate information Normalize it relative to the image and itself, where the image is normalized as follows:
[0066]
[0067] in These are the width and height of the image, respectively, and the normalization in the self-normalized reference contour extraction module;
[0068] The two normalized pieces of information are concatenated to obtain the input features.
[0069] Input features Perform linear projection to map to a high-dimensional space to obtain high-dimensional features. :
[0070]
[0071] in It is a learnable parameter matrix;
[0072] High-dimensional features Input multi-head attention mechanism for feature fusion and learning;
[0073] The feature matrix output from the previous step Pooling is performed along the feature dimension to obtain dimensionality-reduced feature data. ;
[0074] Using fully connected layers to process dimensionality-reduced feature data Perform regression analysis to determine the pig's weight. Measurement:
[0075]
[0076] in For activation function, , This represents the learnable parameter matrix in the two fully connected layers.
[0077] Finally, it should be noted that the above content is only used to illustrate the technical solution of the present invention, and is not intended to limit the scope of protection of the present invention. Simple modifications or equivalent substitutions made by those skilled in the art to the technical solution of the present invention do not depart from the essence and scope of the technical solution of the present invention.
Claims
1. A non-contact method for determining body weight based on two-dimensional pig contour image information, characterized in that... Includes the following steps: a. Data collection: a1. Use a camera installed above the pigpen to acquire two-dimensional images of the pig's back, stream the video stream from the camera via the RTSP protocol, and use perceptual hashing technology to filter similar frames in the video stream to obtain images of the pig and visual marking information of the pig's back. a2. Use radio frequency identification (RFID) technology to obtain pig identification numbers and record them in a database; a3. Combine the visual marking information on the back of the pigs to obtain the number of each pig in the pig image; b. Contour extraction: b1. Use a lightweight network as the backbone network to process the image, obtain feature sets at different resolutions, and then use iterative deep fusion technology to fuse the feature sets to obtain the feature map of the image. b2. Use convolutional layers to process the feature maps to obtain the heatmap of the pig's center point and the corresponding contour coordinate map. Then, based on these two maps, use the center point to perform regression to obtain the initial contour information of each pig in the image. b3. Extract the corresponding features from the feature map using the initial contour information, and perform image normalization processing on the initial contour information as a position code. Concatenate the features and the position code and input them into the multi-head attention layer to obtain the offset of the initial contour, and finally obtain the fine back contour information. c. Weight measurement: c1. Perform image normalization and self-normalization on the fine contour information of the pig's back, and then stitch the obtained information together; c2. Using linear projection, the information is mapped to a high-dimensional feature space; c3. Use a multi-head attention mechanism to complete information fusion and capture feature dependencies; c4. Use adaptive pooling to reduce dimensionality along the feature dimension; c5. Use fully connected layers to regress pig weight.
2. The non-contact weight measurement method based on two-dimensional pig contour image information according to claim 1, characterized in that: In step a1, the perceptual hashing technology includes the following steps: The first Frame of images Convert to grayscale image and resize the image. Then, apply the discrete cosine transform and take the top left corner. coefficient matrix ; right Based on its mean Apply a threshold to obtain the hash string. ,in: Use the same steps as above to process the first... Frame of images Process and obtain Then, Hamming distance was used to calculate the similarity between the two hash strings. : If similarity If the value is greater than 15, the two frames are considered dissimilar; otherwise, the current frame will be filtered out, and the next frame will be captured, repeating all the above steps.
3. The non-contact weight measurement method based on two-dimensional pig contour image information according to claim 1, characterized in that: In step a1, the visual marking information is the pig's identification number marked on the back of the pig using tools such as spray paint or markers.
4. The non-contact weight measurement method based on two-dimensional pig contour image information according to claim 1, characterized in that: In step a2, the pig number is obtained using radio frequency identification technology, and the RFID data of the pig's ear tag is read using an ear tag reader.
5. The non-contact weight measurement method based on two-dimensional pig contour image information according to claim 1, characterized in that: It also includes step a4, which uses a scale to obtain the weight information of the pigs, and combines the pig images and pig numbers to label the data and generate a dataset for subsequent network training.
6. The non-contact weight measurement method based on two-dimensional pig contour image information according to claim 1, characterized in that: In step c, the fine back contour information is obtained by uniformly sampling from the back contour of the pig. The set of coordinates of points .
Citation Information
Patent Citations
Pig weight estimation method, device and equipment and storage medium
CN113096178A
Method for estimating weight of pig and related equipment
CN115294185A
Non-contact body weight measurement method and system for live pigs, electronic equipment and storage medium
CN116485823A
Pig weight intelligent estimation method based on three-dimensional point cloud data
CN118052768A