Non-contact body weight measuring method based on two-dimensional pig contour image information
Through a non-contact weight measurement method based on two-dimensional pig outline image information, a lightweight network and iterative deep fusion technology are used to extract the pig outline, and a multi-head attention mechanism and a fully connected layer are used for weight regression to solve the existing problems. The technology solves the problem of not being able to monitor pig weight in real time, achieving fast, efficient and accurate weight measurement and reducing calculation costs.
Patent Information
- Application Number
- CN202411471521.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-24
AI Technical Summary
The existing non-contact pig weight measurement methods cannot monitor pig weight in real time without restricting pig activity, and the calculation time is long and the cost is high, making it difficult to deploy in the actual production environment.
A non-contact weight measurement method based on two-dimensional pig outline image information is adopted. Through the steps of data collection, outline extraction and weight measurement, lightweight network and iterative deep fusion technology are used to extract the pig outline, and the pig outline is extracted through the multi-head attention mechanism and Fully connected layer for weight regression.
It achieves real-time monitoring of pig weight without restricting pig activities, is fast, efficient, highly accurate, reduces computing costs, and is suitable for large-scale deployment in actual pig farm production.
Smart Images

Figure CN119360040A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent livestock and poultry breeding technology, and in particular to a non-contact weight measurement method based on two-dimensional pig contour image information. Background Art
[0002] Pig weight is a crucial indicator in the breeding industry. It is directly related to the operating efficiency of the farm, breeding costs and pork quality. In the process of pig breeding, the weight of pigs needs to be measured frequently. The traditional way to measure the weight of pigs is manual weighing. In recent years, with the development of intelligent livestock and poultry breeding technology, non-contact weight measurement has begun to appear. Compared with traditional manual weighing, non-contact weight measurement does not require contact with the pig's body, which can reduce the animal's stress and potential harm. At the same time, it also minimizes the time for monitoring and data collection and reduces 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 the morphological method is to extract the morphological characteristics of pigs, such as body length and body width, and to establish a regression equation based on these characteristics, and then measure the weight of the pigs. The morphological method requires the pigs to maintain a specific posture and be in a certain area, especially when using two-dimensional images, the requirements are more stringent. This limitation makes the applicability and flexibility of this method in actual production not good enough.
[0004] The deep learning method can get rid of the above limitations. It uses the entire image or segmented image of a single pig as input and can measure the weight of unrestrained pigs. However, the significant disadvantage of this method is that it usually requires learning and reasoning through deep neural networks, which increases the computing time and cannot achieve real-time weight measurement. In addition, it requires the purchase of computing equipment, which increases the economic burden of the farm.
[0005] The non-contact weight measurement method in the prior art still has some technical problems and cannot be deployed in an actual production environment. Therefore, there is an urgent need in the prior art for a non-contact weight measurement method that can monitor the weight of pigs in an actual production environment in real time without restricting the pigs' activities or requiring the pigs to maintain a specific posture. Summary of the invention
[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and to provide a non-contact weight measurement method based on two-dimensional pig contour image information, which can monitor the weight of pigs in an actual production environment in real time without restricting the pigs' activities or requiring the pigs to maintain a specific posture.
[0007] The object of the present invention is achieved through the following technical solution: a non-contact weight measurement method based on two-dimensional pig outline image information, comprising the following steps: a. Data collection: a1. Use a camera installed above the pig pen to obtain a two-dimensional image of the pig's back, use the RTSP protocol to obtain the camera stream, use the perceptual hashing technology to filter similar frames in the video stream, and obtain the pig image and visual marking information on the pig's back; a2. Use radio frequency identification technology to obtain the pig number and record it in the database; a3. Combining the visual marking information on the pig's back, 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 heat map of the center point of the pig and the corresponding contour coordinate map. Then, based on these two maps, use the center point for regression to obtain the initial contour of each pig in the image. b3. Use the initial contour to extract the corresponding features in the feature map, and perform image normalization on the initial contour as the 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; c. Body weight measurement: c1. Perform image normalization and self-normalization processing on the fine contour information of the pig's back, and splice the obtained information; c2. Use linear projection to map the information into a high-dimensional feature space; c3. Use multi-head attention mechanism to complete information fusion and capture feature dependencies; c4. Use adaptive pooling to reduce dimension along the feature dimension; c5. Use the fully connected layer to regress the pig weight.
[0008] In step a1, the perceptual hashing technique comprises the following steps: Frames for pictures Convert to grayscale and resize to , then apply the discrete cosine transform and take the upper left corner The coefficient matrix of ; right Based on its mean Apply threshold interception to obtain hash string ,in: ; Use the same steps as above to Frames for pictures Process and obtain , and then use the Hamming distance to calculate the similarity of the two hash strings : If the similarity If the value is greater than 15, the two frames are considered to be dissimilar. Otherwise, the current frame is filtered out and the next frame is captured to repeat all the above steps. In step a1, the visual marker information is uniformly sampled from the back contour of the pig. The coordinate set of points .
[0009] In step a2, the pig number is obtained by using radio frequency identification technology to read the pig ear tag RFID data using an ear tag reader.
[0010] The method also includes step a4, using a floor scale to obtain the weight information of the pigs, and combining the pig images and pig numbers to label the data and generate a data set for subsequent network training.
[0011] In step c, the fine back contour information is uniformly sampled from the pig's back contour. The coordinate set of points .
[0012] In the contour extraction step, the present invention uses the contour extraction network (CIEN) to obtain the pig back contour information. It uses the initial contour and iteratively refines the rough contour to efficiently extract the pig contour. Its main innovation is to use the Contour Self-attention mechanism, use the contour coordinate normalization as position information and splice it with the contour feature, input the multi-head attention to predict the contour offset, and obtain the final refined contour.
[0013] In the weight measurement step, the weight estimation network (LWEN) is used to directly measure the pig's weight 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 pig's weight can be measured in just a few steps, without the need for time-consuming and labor-intensive calculations through a large number of convolutional layers.
[0014] The beneficial effects of the present invention are as follows: the present invention can measure the weight of pigs that are free to move and eat in an actual production environment without restricting the pigs' activities or requiring the pigs to maintain a specific posture, and will not cause any stimulation to the pigs. The present invention is fast, efficient, highly accurate, and can monitor the weight of pigs in real time. It performs non-contact weight measurement based on two-dimensional images, greatly reducing the computing cost. The present invention can be deployed on a large scale in actual production in pig farms to provide decision support for pig breeding enterprises. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a principle block diagram of the present invention; Figure 2 It is the principle block diagram of data acquisition; Figure 3 This is the principle block diagram of contour extraction; Figure 4 It is a principle block diagram of body weight determination. DETAILED DESCRIPTION
[0016] The present invention is described in detail below with reference to the accompanying drawings.
[0017] like Figure 1 As shown, 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; the contour extraction includes feature extraction, contour initialization and contour evolution; the weight measurement includes information fusion and regression of the contour information to measure the weight of the pig.
[0018] like Figure 2 As shown, data collection includes the following steps: Install an RGB camera above the pig pen, and use a crayon or other tool to mark the pig number on the back of the pig. Then use the RTSP protocol to obtain the camera stream, and then use the perceptual hash algorithm to filter similar frames: The first Frames for pictures Convert to grayscale and resize to ,get ; For images Apply the discrete cosine transform and take the upper left corner The coefficient matrix of ; Compute the mean of the coefficient matrix , and set the coefficients greater than the mean to 1, and the others to 0, to obtain two hash strings of length 64 ,in:
[0019] Use the same steps as above to Frames for pictures Process it and get its hash string ; Calculate the similarity between two hash strings using Hamming distance :
[0020] If the similarity If it is greater than 15, the two frames are considered dissimilar, otherwise the current frame will be filtered out.
[0021] After filtering similar frames, pig images and visual marking information on the pig's back can be obtained.
[0022] The ear tag reader is used to read the pig ear tag RFID data and save it to the MySQL database. Combined with the visual mark on the pig's back, the number of each pig in the pig image can be obtained. Then, the weight information of the pig is obtained using tools such as a floor scale, and the data is annotated in combination with the aforementioned pig image and number to generate a data set for subsequent network training.
[0023] like Figure 3 As shown, the contour extraction step includes the following steps: Input the pig image into the backbone network MobileNetV2 to obtain the feature set; Use iterative deep fusion technology to obtain feature maps ,in The size is 4 times the downsampled image; right Convolution is applied to obtain the center hotspot map and contour coordinate map respectively, and then the initial contour coordinate set of the pig is obtained based on the center point regression. ; Will Normalize and get the position encoding :
[0024] in , for The corresponding minimum value is , is the maximum value; according to from Extract contour features ; Contour feature With position encoding Splicing is performed by feature dimension, and multi-head attention mechanism is used for information fusion and dependency capture; Get the contour offset , add the initial contour and the offset to finally obtain the refined contour.
[0025] like Figure 4 As shown, weight estimation includes the following steps: Using the above-mentioned fine contour coordinate information , normalize it relative to the image and itself, where the image is normalized as:
[0026] in are the width and height of the image respectively, and their normalization refers to the normalization in the contour extraction module; Concatenate the two normalized information to obtain the input features
[0027] The input features Perform linear projection, map to high-dimensional space, and obtain high-dimensional features :
[0028] in is the learnable parameter matrix; High-dimensional features Input multi-head attention mechanism for feature fusion and learning; The feature matrix output from the previous step , pooling is performed along the feature dimension to obtain dimension-reduced feature data ; Use fully connected layers to reduce the dimension of feature data Perform regression to complete pig weight Determination of:
[0029] in is the activation function, , is the learnable parameter matrix in the two fully connected layers.
[0030] Finally, it should be noted that the above content is only used to illustrate the technical solution of the present invention, rather than to limit the scope of protection of the present invention. Simple modifications or equivalent substitutions of the technical solution of the present invention by ordinary technicians in this field do not deviate from the essence and scope of the technical solution of the present invention.
Claims
1. A non-contact weight measurement method based on two-dimensional pig contour image information, characterized in that The steps include: a. Data collection: a1. Use a camera installed above the pig pen to obtain a two-dimensional image of the pig's back, use the RTSP protocol to obtain the camera stream, use the perceptual hashing technology to filter similar frames in the video stream, and obtain the pig image and visual marking information on the pig's back; a2. Use radio frequency identification technology to obtain the pig number and record it in the database; a3. Combining the visual marking information on the pig's back, 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 heat map of the center point of the pig and the corresponding contour coordinate map. Then, based on these two maps, use the center point for regression to obtain the initial contour information of each pig in the image. b3. Use the initial contour information to extract the corresponding features in the feature map, and perform image normalization on the initial contour information as the 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. Body weight measurement: c1. Perform image normalization and self-normalization processing on the fine contour information of the pig's back, and splice the obtained information; c2. Use linear projection to map the information into a high-dimensional feature space; c3. Use multi-head attention mechanism to complete information fusion and capture feature dependencies; c4. Use adaptive pooling to reduce dimension along the feature dimension; c5. Use the fully connected layer to regress the pig weight.
2. The non-contact weight measurement method based on two-dimensional pig outline image information according to claim 1, characterized in that: In step a1, the perceptual hashing technique comprises the following steps: The first Frames for pictures Convert to grayscale and resize to , then apply the discrete cosine transform and take the upper left corner The coefficient matrix of ; right Based on its mean Apply threshold interception to obtain hash string ,in: ; Use the same steps as above to Frames for pictures Process and obtain , and then use the Hamming distance to calculate the similarity of the two hash strings : If the similarity If it is greater than 15, the two frames are considered to be dissimilar, otherwise the current frame will be filtered out and the next frame will be captured to repeat all the above steps.
3. The non-contact weight measurement method based on two-dimensional pig outline image information according to claim 1, characterized in that: In step a1, the visual marking information is the pig's identity number marked on the pig's back using tools such as spray paint or a marker pen.
4. The non-contact weight measurement method based on two-dimensional pig outline image information according to claim 1, characterized in that: In step a2, the pig number is obtained by using radio frequency identification technology to read the pig ear tag RFID data using an ear tag reader.
5. The non-contact weight measurement method based on two-dimensional pig outline image information according to claim 1, characterized in that: The method also includes step a4, using a floor scale to obtain pig weight information, and combining the pig image and pig number to label the data and generate a data set for subsequent network training.
6. The non-contact weight measurement method based on two-dimensional pig outline image information according to claim 1, characterized in that: In step c, the fine back contour information is uniformly sampled from the pig's back contour. The coordinate set of points .
Citation Information
Cited By
Live pig weight detection method and system based on back image recognition
CN120183003A