A method and system for monitoring body temperature in group-raised pigs
By combining deep learning algorithms and linear interpolation with the YOLOv8-OBB model, the temperature at the base of the pig's ear is identified and extracted, solving the problems of time consumption, low accuracy, and software limitations in existing pig body temperature monitoring technologies, and achieving high-precision pig body temperature monitoring.
Patent Information
- Application Number
- CN202411346796.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Existing technologies for monitoring pig body temperature are time-consuming and labor-intensive, and can easily trigger stress responses and cross-infection of diseases. Furthermore, the accuracy of infrared thermal imaging methods is not high, especially when extracting temperature from the ear base area, where there is a lot of background noise and software limitations, making it difficult to meet the needs of large-scale intelligent farming.
A deep learning object detection algorithm was used to identify the ear base of pigs. The temperature of the ear base was extracted by acquiring bispectral video data and using linear interpolation. The YOLOv8-OBB model was used for ear base identification and temperature extraction. The prediction box with the smaller standard deviation was selected as the optimal box. Correlation analysis was used to select the statistical features within the optimal box to characterize the pig's body temperature.
It improves the precision and accuracy of pig body temperature monitoring, breaks free from the limitations of thermal imaging camera manufacturers' software, and is suitable for intelligent body temperature monitoring of group-raised pigs.
Smart Images

Figure CN119418365B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of livestock breeding and pig temperature measurement technology, specifically relating to a method and system for monitoring the body temperature of group-raised pigs. Background Technology
[0002] With the development of the pig farming industry, large-scale, intensive, and intelligent farming methods have been widely adopted. During the farming process, the health of pigs is of paramount importance. A pig's body temperature is a crucial indicator of its health; timely and accurate monitoring of body temperature can effectively prevent diseases and improve farming efficiency and quality. Traditional methods of measuring pig temperature involve using mercury or electronic thermometers to measure rectal temperature. These methods are time-consuming and labor-intensive, easily causing stress in pigs and increasing the risk of cross-infection, making them unsuitable for large-scale, intelligent farming methods.
[0003] In recent years, infrared thermal imaging technology, as a non-contact method for measuring body surface temperature, has been widely used in fields such as body temperature detection and disease diagnosis in livestock and poultry. This method employs a combination of deep learning and machine vision. It uses cameras to collect images of pigs to construct a dataset, trains a deep learning model to detect regions of interest (ROIs) for pig temperature measurement, and extracts the temperature values of these ROIs from the thermal images as the pig's body temperature. The ear root area is the part of the pig's body surface most closely related to rectal temperature; therefore, it is very suitable as a ROI for detecting pig body temperature using infrared thermal imaging. For example, CN110200596A, "Infrared Rapid Temperature Measurement Device and Method for Pig Body Temperature Monitoring," describes a method where live pigs enter a gate-shaped frame along a main channel. Various rocker arms move, and an electronic identification device and a reading probe read the pig's identification information, measure its temperature, and record the data.
[0004] When detecting pig body temperature using infrared thermal imaging, existing methods often employ deep learning object detection algorithms to detect the pig's ears or head and extract the temperature of that area directly as the pig's body temperature. These methods detect regions of interest containing a large number of background pixels and even more noise points, resulting in lower temperature measurement accuracy compared to directly detecting the base of the ear. Furthermore, due to the numerous thermal imager brands on the market and the relatively unique formats of stored thermal images, existing methods often require the use of software provided by the thermal imager manufacturers for temperature extraction. This software is subject to numerous limitations and makes secondary development difficult. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method and system for monitoring the body temperature of group-raised pigs, so as to realize the extraction of temperature at the base of the ear of group-raised pigs and intelligent monitoring of the body temperature of pigs based on the temperature monitoring system at the base of the ear of group-raised pigs.
[0006] To address the aforementioned technical problems, this invention provides a method and system for monitoring the body temperature of group-raised pigs, comprising the following specific processes:
[0007] S1. Collect bispectral video data of group-raised pigs through a pig video data acquisition system. Then, perform time-lapse frame extraction on the thermal infrared video data in the bispectral video data and input the selected frame images into the offline trained pig ear root recognition model to obtain the predicted image img of each pig and the ear root detection results, including left and right ear category information and ear root prediction box.
[0008] S2. Extract temperature values from the ear root region of the predicted image (img) of each pig and construct the temperature matrix (Temp()) of the predicted bounding box at the left ear root region. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R ;
[0009] S3, Temperature matrix of the prediction box at the left ear root area (Temp()) L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R Calculate the standard deviation σ of the statistical characteristics respectively. L σ R Choose σ L σ R The prediction box for the ear root region with the smaller standard deviation σ is taken as the optimal box;
[0010] S4. Calculate the maximum, mode, second largest and average values of the statistical features using the optimal bounding box, and use the maximum value of the statistical features as the temperature at the base of the pig's ear.
[0011] As an improvement to the method for monitoring body temperature in group-raised pigs according to the present invention:
[0012] The specific method for extracting the temperature value at the base of the ear in step S2 is as follows:
[0013] In the predicted image `img`, all pixel values within the bounding box of the ear root region are extracted as a point set `Pixel()`. Linear interpolation is then used to calculate the corresponding temperature values for all pixel values within the point set `Pixel()`, resulting in a temperature matrix `Temp()`, including the temperature matrix `Temp()` of the predicted box for the left ear root region. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
[0014] As a further improvement to the group-raised pig body temperature monitoring method of the present invention:
[0015] The temperature matrix Temp() of the prediction box at the left ear root area L And the temperature matrix Temp() of the predicted bounding box at the right ear root regionR The specific calculation method is as follows:
[0016] (1) Create a mask with all pixel values of 0, and the size is the same as the predicted image img;
[0017] (2) Set the pixel value of the predicted box area of the pig's ear root on the mask to 255;
[0018] (3) Perform a bitwise AND operation on the predicted image img and the mask, and retain the pixel values in the predicted box area of the pig's ear root on the mask, while the pixel values in other areas are 0;
[0019] (4) Obtain the coordinate index values of non-zero pixels on the mask, and extract the pixel values at the corresponding positions in the predicted image img based on the coordinate index values; save the extracted pixel values in list form P[]. L ,P[] R , which is the pixel value within the predicted bounding box at the base of the ear;
[0020] (5) Based on the thermal infrared video data, the frame images selected by time-interval frame extraction are mapped one by one to temperature values using the linear interpolation method.
[0021]
[0022] Among them, P max P min These represent the maximum and minimum pixel values in the thermal imaging grayscale image, T. max T min These represent the maximum and minimum temperatures in the thermal imaging grayscale image, respectively; T is the predicted temperature value, and P is the grayscale value of each pixel.
[0023] (6) Calculate P[] L ,P[] R The temperature value corresponding to the middle pixel value is used to obtain the temperature matrix Temp() of the predicted bounding box at the left ear root area. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
[0024] As a further improvement to the group-raised pig body temperature monitoring method of the present invention:
[0025] The model for identifying the ear root area of pigs is the YOLOv8-OBB model.
[0026] As a further improvement to the group-raised pig body temperature monitoring method of the present invention:
[0027] The offline training process for the pig ear root recognition model is as follows:
[0028] Bispectral video data of group-raised pigs from piglets to fattening pigs during their normal feeding cycle was collected using a pig video data acquisition system. Then, time-separated frame extraction was performed, and a set of typical frame images was selected as the dataset. The ear base of the pigs in all images in the dataset was labeled, and then the dataset was divided into training set, validation set, and test set. The training set and validation set were used to train the optimal model parameters, and the test set was used to test the performance of the optimal model parameters.
[0029] This invention also provides a pig video data acquisition system, comprising:
[0030] A dual-spectrum camera is installed at the top of the cultivation room. The dual-spectrum camera is electrically connected to a network hard disk recorder via a network. The network hard disk recorder is electrically connected to a computer via a network.
[0031] The dual-spectrum camera is installed above the water trough in the pigpen, taking pictures of the entire pigpen from a top-down angle.
[0032] The beneficial effects of this invention are mainly reflected in:
[0033] This invention proposes a method and system for monitoring body temperature in group-raised pigs. First, a deep learning object detection algorithm is used to identify the ear root region of the pig, accurately fitting ear root regions in different directions. Then, based on the linear transformation relationship between pixel values and temperature values in thermal images, linear interpolation is used to directly extract the temperature value corresponding to the predicted box at the ear root region. By comparing the standard deviation of the predicted boxes at the left and right ear roots, the temperature of the optimal predicted box is selected to characterize the pig's body temperature, improving the accuracy of body temperature extraction. This method has significant application value in areas such as target detection at the ear root region of group-raised pigs and infrared thermal imaging temperature measurement of group-raised pigs.
[0034] Compared with existing methods that directly extract the maximum temperature value as the pig's body temperature after predicting the left and right ear regions, this invention first identifies the optimal prediction box in the left and right ear root regions, and then uses correlation analysis to select the statistical feature with the highest correlation in the optimal box in the left and right ear root regions to characterize the pig's body temperature, thereby improving the accuracy of body temperature detection in group-raised pigs. Attached Figure Description
[0035] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0036] Figure 1 This is a schematic diagram of the pig video data acquisition system of the present invention;
[0037] Figure 2 This is a schematic diagram of a method for monitoring the body temperature of group-raised pigs according to the present invention;
[0038] Figure 3 This is a schematic diagram of the structure of the pig ear root identification model of the present invention;
[0039] Figure 4 This is a schematic diagram of the temperature extraction process of the pig ear root part according to the present invention;
[0040] Figure 5 This is a schematic diagram illustrating the visualization of temperature detection at the base of the pig's ear according to the present invention. Detailed Implementation
[0041] The present invention will be further described below with reference to specific embodiments, but the scope of protection of the present invention is not limited thereto:
[0042] Example 1
[0043] Pig video data acquisition system, such as Figure 1 As shown, a dual-spectrum camera is installed in the rearing room. The dual-spectrum camera is electrically connected to a network video recorder (VVR) via a network, and the VVR is electrically connected to a computer via a network. The dual-spectrum camera collects real-time dual-spectrum video data of the group-raised pigs in the rearing room, transmits it via the network, and stores it on the VVR. The computer is used to monitor and view the dual-spectrum video data of the pigs, and the body temperature of the group-raised pigs is detected in real time using a body temperature monitoring method of this invention.
[0044] A method for monitoring body temperature in group-raised pigs, such as Figure 2 As shown, the specific process is as follows:
[0045] Offline training of pig ear root recognition model
[0046] 1 Data Collection
[0047] A pig video data acquisition system was used to monitor the daily behavior and activities of 20 pigs in a pen in the nursery. Dual-spectrum video data was collected 24 hours a day for a period of 5-6 months, covering the normal feeding cycle from piglet to finishing pig. The dual-spectrum camera, a Hikvision DS-2TD2636B-13 / P thermometer dual-spectrum bullet camera, was installed above the water trough in the pigpen. Its horizontal and vertical field of view were 28.8° and 21.6°, respectively, providing a top-down view to ensure all pigs were within the field of view. The camera's thermal resolution was 384×288, and its visible light resolution was 2688×1520. A network video recorder, model DS-7608N-I3-V3, was used for multi-channel, multi-disk video storage, capable of storing multi-spectral video data and simultaneously acquiring infrared and visible spectrum video data of the pigs.
[0048] 2. Dataset Creation and Partitioning
[0049] The bispectral video data collected in step 1 was subjected to time-lapse frame extraction. A set of typical frame images was selected as the dataset. The images should contain pigs in different poses and in different numbers to make the dataset contain more information. The open-source annotation software ro-labelimg was used to annotate the ear root area of pigs in all images in the dataset. The ear root area is the connection between the pig's ear and body. When annotating, the annotation box should be as parallel as possible to the ear root line and include the ear root line and the areas to its left and right. After the annotation is completed, XML format labels are generated. According to the needs of the deep learning model, the XML labels are converted into TXT format that can be recognized by the YOLOv8-OBB model. Finally, the dataset is divided into training set, validation set and test set in a ratio of 8:1:1.
[0050] 3. Construction of a model for recognizing the ear root of pigs
[0051] This invention employs the YOLOv8-OBB model as the pig ear root recognition model to identify the pig ear root region. The pig ear root recognition model mainly consists of three modules: Backbone, Neck, and Head. The Backbone part is the backbone network responsible for feature extraction; the CBS module combines convolution, pooling, and activation functions; the C2f module serves as the basic building block, featuring residual connections and a bottleneck structure. The Neck part is responsible for multi-scale feature fusion, enhancing feature representation capabilities. It includes the following components: the SPPF module is spatial pyramid pooling, used for pooling operations at different scales; the Concat module concatenates feature maps of different scales; Upsample changes the feature map size through upsampling; the Head part is responsible for the final object detection and classification tasks. The model outputs three prediction results of different sizes, each including a detection head, a classification head, and an angle head. All three are composed of two CBS modules and a separate Conv2d convolutional layer. The angle head is an addition to the OBB model by modifying the Head module. It is used to predict the rotation angle of the feature map. It can identify the pig ear root area at different angles in the image and generate the corresponding directional rotation prediction box, i.e., the ear root area prediction box.
[0052] 4. Training and Testing of Pig Ear Base Recognition Model
[0053] Set up the configuration files for the dataset and model structure, as well as the terminal commands for training and prediction scripts, to prepare for model training. The model directly predicts the ear base of pigs in images in an end-to-end mode and generates prediction results. The training set and validation set are used to train and obtain the optimal model parameters, and the test set is used to verify the performance of the optimal model parameters.
[0054] The training and validation sets obtained in step 2 are used as inputs for model training. Hyperparameters such as the number of epochs (300), batch size (16), and initial learning rate (lr) are set to 0.01. The hyperparameters are optimized through 300 iterations and backpropagation to achieve the best training effect. After training, the best weight parameter file (best.pt) is generated, which can be used for subsequent model prediction.
[0055] 5. Test of pig ear root region recognition model
[0056] The optimal weight parameter model obtained from the training is used on the test set divided in step 2. The detection results of the ear root region in each image of the test set are output, and the left and right ear category information of the predicted ear root region is returned: left_earroot or right_earroot, as well as the coordinate values of the four vertices of the predicted box of the ear root region.
[0057] Group II pig body temperature monitoring
[0058] When used in an online production environment, the method in step 1 is first employed to monitor and record the daily behavior and activities of group-housed pigs in the rearing room using a pig video data acquisition system. This yields bispectral video data of the group-housed pigs. Then, time-lapse frame extraction is performed on the thermal infrared video data within the bispectral video data to select typical frame images, such as... Figure 5 As shown in (a), the pig ear root recognition model trained in step 5 is input to obtain the predicted image (img) of each pig and the ear root detection results, including left and right ear category information: left_earroot or right_earroot, and the coordinate values of the four vertices of the predicted box of the ear root, and then further processing is performed:
[0059] 6. Temperature extraction from the base of the pig's ear
[0060] In a group-raising environment for pigs, the predicted image (img) contains multiple pigs. The pig ear root recognition model predicts the left and right ear roots for each pig, and then extracts the temperature value from these ear roots. The temperature extraction steps are: first, create a mask; then, extract the pixels within the predicted bounding box of the ear root area; finally, convert the temperature value and display the highest temperature at the ear root area, such as... Figure 4 As shown.
[0061] In the predicted image (img), the coordinates of the four vertices of the predicted bounding box at the base of the ear are used as the specific boundary range of the predicted bounding box. All pixel values within this boundary range are extracted as the point set (Pixel()). The maximum temperature value T within the thermal imaging grayscale image of a typical frame image obtained by extracting frames from thermal infrared video data is used. max and minimum temperature value T min The maximum pixel value P in the thermal imaging grayscale image maxand minimum pixel value P min A linear mapping relationship between them, where P max and P min Typically, the values are 255 and 0. A linear interpolation method is used to calculate the corresponding temperature value for all pixel values within the pixel set (Pixel()), which is then used as the temperature matrix (Temp()), including the temperature matrix (Temp()) of the predicted bounding box at the left ear root region. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
[0062] The detailed implementation method for converting pixel values to temperature values is as follows:
[0063] 6.1 Create a mask with all pixel values set to 0 (black), with the same size as the predicted image (img). Both the mask and the predicted image (img) are single-channel grayscale images.
[0064] 6.2 Using the vertex coordinates of the predicted bounding box at the base of the pig's ear, set the pixel value within the predicted bounding box area of the pig's ear base to 255 (white) on the mask.
[0065] 6.3 Perform a bitwise AND (&) operation on the predicted image img and the mask. Specifically, convert each pixel value of the predicted image img and the mask into a binary number, and then perform a logical operation on the two images, performing a bitwise AND (&). The result bit will be 1 only when both corresponding binary bits are 1. After the operation, the pixel values of the predicted box area of the pig's ear root are retained on the mask, and the pixel values of other areas are 0.
[0066] 6.4 Obtain the coordinate index values of non-zero pixels on the mask, and extract the pixel values at the corresponding positions in the predicted image (img) based on the coordinate index values; save the extracted pixel values as a list (P[]). L and P[] R This refers to all pixel values within the predicted bounding box at the base of the ear;
[0067] 6.5 Obtain the maximum and minimum pixel values P in the thermal imaging grayscale image max P min and maximum and minimum temperature values T max T min The linear interpolation method is used to map each pixel value to a temperature value; the specific formula is as follows:
[0068]
[0069] Where T is the predicted temperature value and P is the grayscale value of each pixel.
[0070] Existing methods for extracting temperature from thermal images typically rely on software provided by thermal imager manufacturers. However, due to the large number of thermal imager manufacturers and software available, coupled with numerous software limitations and difficulties in secondary development, this invention employs a linear interpolation method based on the linear transformation relationship between thermal image pixel values and temperature values. This method directly extracts the temperature value corresponding to the predicted bounding box at the base of the ear, thus overcoming the limitations of manufacturer-specific software and offering a simpler and more convenient approach.
[0071] 6.6 Calculate P[] L ,P[] R The temperature value corresponding to the middle pixel value is used to obtain the temperature matrix Temp() of the predicted bounding box at the left ear root area. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
[0072] 7. Optimal Box Selection for Ear Root Prediction
[0073] Because the temperature at the base of the left and right ears of the pig is inconsistent, it is necessary to select the best prediction box for each ear base; the temperature matrix Temp() of the prediction box for the left ear base in step 6 is used. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R Calculate the standard deviation σ of the statistical characteristics respectively. L σ R The closer the predicted bounding box is to the ear root region, the smaller the dispersion of the temperature values within the predicted bounding box. Therefore, σ is chosen. L σ R The prediction box for the ear root region with the smaller standard deviation σ is taken as the optimal box.
[0074] In the optimal bounding box selection method, each ear root prediction box contains M = 1500 to 2000 pixel values, and its temperature matrix Temp() also contains corresponding M = 1500 to 2000 temperature values. The selected optimal bounding box indicates that the ear root prediction box has better positional accuracy, and the temperature value of the ear root is more consistent with the actual temperature of the pig than the temperature value of another ear root of the pig.
[0075] 8. Temperature characterization of the ear root area of pigs
[0076] For the optimal box in step 7, calculate the maximum, mode, second largest and average statistical features, use these statistical features as statistical feature prediction values, and use the maximum statistical feature as the temperature at the base of the pig's ear.
[0077] In addition, the ear root line of the pig was manually extracted from the thermal imaging grayscale image. The baseline value mentioned in the temperature characterization section of the pig ear root area was manually drawn in the thermal image with a width of 3 pixels, representing the connection between the pig's ear and body, and the shape was a line. Then, the temperature was extracted as the baseline value using the method in step 5. The temperature value of the pig ear root line was calculated using the method in step 5, and its statistical characteristics, including the maximum value, mode, second largest value, and mean value, were calculated. These statistical characteristics were used as the statistical characteristic baseline values. The predicted values of the statistical characteristics and the statistical characteristic baseline values of N pigs were statistically analyzed, with N ranging from 50 to 100. In this case, N=75. The correlation was analyzed. The correlation analysis was performed by calculating the coefficient of determination R between various statistical characteristics (maximum value, mode, second largest value, and mean value). 2 The maximum temperature T_pred within the optimal bounding box of the prediction frame for the ear base of 75 pigs was statistically analyzed. max And manually plotting the maximum temperature T_true on the ear root line max The coefficient of determination R for both 2 The value is 0.9535, which is an ideal result. The maximum temperature value in the optimal box of the automatically identified ear root prediction box can be used to characterize the temperature of the pig's ear root area.
[0078] The temperature at the base of the pig's ear is characterized by the statistical feature with the highest correlation. The statistical feature of the ear base prediction box is the predicted value T_pred, and the statistical feature of the pig's ear base line is the baseline value T_true.
[0079] 9. Visualized temperature detection at the base of the pig's ear
[0080] like Figure 5 As shown, the predicted frame of the ear base and the temperature detection are extracted and visualized to display the temperature value of the ear base of the pig. Among them, (a) is a typical frame image selected by time-interval frame extraction operation from the thermal infrared video data in the dual-spectrum video data, and (b) is an image of the predicted frame of the ear base and the predicted temperature value obtained by the group-raised pig body temperature monitoring method of the present invention.
[0081] Experiment: Comparative Experiment of Ear Root Temperature Extraction
[0082] 1. Data source: In a group-raising environment for pigs, a dual-spectrum thermal imager was used to take aerial photos of the pigs, collecting thermal and visible light image data. The images contained multiple pigs, and the thermal image data was used as the data for this experiment. Thermal image data of 75 pigs were collected.
[0083] 2. Comparison of experimental methods:
[0084] Method a is derived from Liu Gang's "A Method for Detecting Temperature at the Base of the Ear of Pigs Based on Improved YOLO v4":
[0085] The head and ear base of the pig are key areas for temperature measurement. The temperature is extracted from the thermal image, and the maximum temperature at the left and right ear bases is used as the pig's body temperature measurement value. The maximum temperature at the ear base is manually counted as the pig's body temperature baseline value.
[0086] Method b, the method used in this invention:
[0087] The ear base of the pig is used as the key area for measuring the pig's temperature. The temperature is extracted from the thermal image, and then the statistical feature with the highest correlation within the optimal box of the left and right ear bases is selected to represent the pig's body temperature through correlation analysis. The experiment showed that the statistical feature with the highest correlation is the maximum value within the optimal prediction box, which is used as the measured value of the pig's body temperature. The maximum temperature value of the ear base is manually counted as the baseline value of the pig's body temperature.
[0088] 3. Overview of the experimental procedure:
[0089] 1) Use a Hikvision DS-2TD2636B-13 / P thermal imager to take top-down photos of pigs in a group-housed environment, and collect 1200 images. These images are then divided into training, validation, and test sets in a ratio of 8:1:1.
[0090] 2) Use deep learning models to train and detect the left and right ear roots of pigs;
[0091] 3) Extract the detected temperature value of the ear root area from the thermal image;
[0092] Method a:
[0093] The temperature values of the two ear base prediction frames were statistically analyzed, and the maximum value of all temperature values was selected as the body temperature measurement value of the pig.
[0094] Method b:
[0095] For the temperature prediction boxes at the two ear root regions, the optimal box is selected based on variance and standard deviation. The statistical characteristics of the optimal box and the manually counted ear root line temperature values are calculated, and the statistical characteristic with the highest correlation is selected as the pig body temperature measurement value.
[0096] 4) Extract the temperature reference value
[0097] Method a and Method b are the same in obtaining the baseline body temperature of pigs, which is obtained by manually extracting the maximum temperature of the ear root line as the baseline body temperature of pigs;
[0098] 6) Calculate the coefficient of determination between the measured body temperature of pigs and the baseline value.
[0099] 4. Results Analysis:
[0100] Method a:
[0101] The maximum temperature value of the predicted frame at the base of the left and right ears is used as the measured value, and then the coefficient of determination R with the baseline value is calculated. 2 It is 0.681;
[0102] Method b:
[0103] First, select the optimal prediction frame for the left and right ear roots. Then, use the maximum temperature value of the optimal prediction frame for the left and right ear roots as the measured value, and then calculate the coefficient of determination R with the reference value. 2 It is 0.953;
[0104] It can be seen that the coefficient of determination R of method b used in this invention is... 2 The value superior to that of method a can be used to characterize the body temperature of pigs using the temperature measurement values of the optimal prediction boxes at the left and right ear roots.
[0105] In summary, compared with existing methods that directly extract the maximum temperature value as the body temperature of pigs after predicting the left and right ear regions, the present invention proposes an optimal prediction box recognition method for the left and right ear root regions, and a method for characterizing pig body temperature by selecting the statistical feature with the highest correlation within the optimal box of the left and right ear root regions through correlation analysis, which improves the accuracy of body temperature detection in group-raised pigs.
[0106] Finally, it should be noted that the above examples are merely some specific embodiments of the present invention. Obviously, the present invention is not limited to the above embodiments and many variations are possible. All variations that can be directly derived or conceived by those skilled in the art from the disclosure of the present invention should be considered within the scope of protection of the present invention.
Claims
1. A method for monitoring body temperature in group-raised pigs, characterized in that: The specific process includes the following: S1. Collect bispectral video data of group-raised pigs through a pig video data acquisition system. Then, perform time-lapse frame extraction on the thermal infrared video data in the bispectral video data and input the selected frame images into the offline trained pig ear root recognition model to obtain the predicted image img of each pig and the ear root detection results, including left and right ear category information and ear root prediction box. S2. Extract temperature values from the ear root region of the predicted image (img) of each pig and construct the temperature matrix (Temp()) of the predicted bounding box at the left ear root region. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R ; S3, Temperature matrix of the prediction box at the left ear root area (Temp()) L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R Calculate the standard deviation σ of the statistical characteristics respectively. L σ R Choose σ L σ R The prediction box for the ear root region with the smaller standard deviation σ is taken as the optimal box; S4. Calculate the maximum, mode, second largest and average values of the statistical features using the optimal bounding box, and use the maximum value of the statistical features as the temperature at the base of the pig's ear.
2. The method for monitoring body temperature in group-raised pigs according to claim 1, characterized in that: The specific method for extracting the temperature value at the base of the ear in step S2 is as follows: In the predicted image `img`, all pixel values within the bounding box of the ear root region are extracted as a point set `Pixel()`. Linear interpolation is then used to calculate the corresponding temperature values for all pixel values within the point set `Pixel()`, resulting in a temperature matrix `Temp()`, including the temperature matrix `Temp()` of the predicted box for the left ear root region. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
3. The method for monitoring body temperature in group-raised pigs according to claim 2, characterized in that: The temperature matrix Temp() of the prediction box at the left ear root area L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R The specific calculation method is as follows: (1) Create a mask with all pixel values of 0, and the size is the same as the predicted image img; (2) Set the pixel value of the predicted box area of the pig's ear root on the mask to 255; (3) Perform a bitwise AND operation on the predicted image img and the mask, and retain the pixel values in the predicted box area of the pig's ear root on the mask, while the pixel values in other areas are 0; (4) Obtain the coordinate index values of non-zero pixels on the mask, and extract the pixel values at the corresponding positions in the predicted image img based on the coordinate index values; save the extracted pixel values in list form P[]. L ,P[] R , which is the pixel value within the predicted bounding box at the base of the ear; (5) Based on the thermal infrared video data, the frame images selected by time-interval frame extraction are mapped one by one to temperature values using the linear interpolation method. Among them, P max P min These represent the maximum and minimum pixel values in the thermal imaging grayscale image, T. max T min These represent the maximum and minimum temperatures in the thermal imaging grayscale image, respectively; T is the predicted temperature value, and P is the grayscale value of each pixel. (6) Calculate P[] L ,P[] R The temperature value corresponding to the middle pixel value is used to obtain the temperature matrix Temp() of the predicted bounding box at the left ear root area. L And the temperature matrix Temp() of the predicted bounding box at the right ear root region R .
4. The method for monitoring body temperature in group-raised pigs according to claim 3, characterized in that: The model for identifying the ear root area of pigs is the YOLOv8-OBB model.
5. The method for monitoring body temperature in group-raised pigs according to claim 4, characterized in that: The offline training process for the pig ear root recognition model is as follows: Bispectral video data of group-raised pigs from piglets to fattening pigs during their normal feeding cycle was collected using a pig video data acquisition system. Then, time-separated frame extraction was performed, and a set of typical frame images was selected as the dataset. The ear base of the pigs in all images in the dataset was labeled, and then the dataset was divided into training set, validation set, and test set. The training set and validation set were used to train the optimal model parameters, and the test set was used to test the performance of the optimal model parameters.
6. The pig video data acquisition system used in the method for monitoring body temperature in group-raised pigs as described in any one of claims 1-5, characterized in that: This includes a dual-spectrum camera installed on the top of the cultivation room. The dual-spectrum camera is electrically connected to a network hard disk recorder via a network, and the network hard disk recorder is electrically connected to a computer via a network. The dual-spectrum camera is installed above the water trough in the pigpen, taking pictures of the entire pigpen from a top-down angle.
Citation Information
Patent Citations
Infrared fast temperature measuring device and temperature measuring method for live pig body temperature monitoring
CN110200596A
Pig body temperature detection method in multi-pig scene based on infrared image
CN111145205A
Moving target body surface temperature rapid detection method and system based on thermal infrared video
CN111982296A