Automatic detection and analysis method and system for sow squeezing piglet events

By using a deep learning network to identify the sow's posture and fatal area, the occlusion problem of piglet compression detection when the sow is lying on its side is solved, and accurate detection and quantitative analysis of sow squeezing piglet events are achieved.

CN119229530BActive Publication Date: 2025-09-19SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411288008.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-09-19
Estimated Expiration
2044-09-13

AI Technical Summary

Technical Problem

Existing technologies make it difficult to accurately detect the squeezing behavior of sows on piglets when they lie on their side, especially when the sow's back is blocked, making it difficult to timely monitor the number of piglets under pressure.

Method used

By building a deep learning network, we can identify video data of lactating sows and piglets, determine the sow's posture and mask outline, accurately locate the fatal area, calculate the arc-shaped and back-shaped fatal areas based on key points, track the position of piglets in these areas, and automatically detect crushing events.

Benefits of technology

It achieves accurate detection of sow squeezing piglets incidents, solves the monitoring difficulties caused by the sow's back being blocked, and can efficiently and accurately determine the number of squeezing piglets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119229530B_ABST
    Figure CN119229530B_ABST
Patent Text Reader

Abstract

The present invention discloses an automatic detection and analysis method for sow-piglet squeezing events, comprising: obtaining video data of lactating sows and piglets living together as an initial data set; identifying the piglet mask outline, sow posture, sow mask outline, and key points of all video frames based on the initial data set; filtering the initial data set based on the sow posture to obtain a basic data set; obtaining different lethal areas based on the basic data set and the corresponding sow mask outline and key points; determining a final lethal area based on the lethal areas; tracking piglets within the final lethal area based on the basic data set and the piglet mask outline to obtain a tracking result; and obtaining the number of squeezed piglets based on the tracking result. The method can accurately locate the lethal area where the sow squeezes the piglets and thus detect the number of piglets squeezed by the sow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and more particularly to an automatic detection and analysis method and system for sow squeezing piglet events. Background Art

[0002] Extensive research has shown that sow crushing is a leading cause of piglet mortality, particularly in the early pre-weaning period. While there are multiple risks associated with piglet crushing, suffocation and physical injuries from sow crushing are direct causes of mortality. While manual monitoring can prevent crushing incidents to some extent, this approach is neither efficient nor cost-effective in modern large-scale farming systems.

[0003] While computer vision-based intelligent devices have begun to be applied to smart farming, they primarily focus on simple analysis of pig behavior. Existing technologies for detecting and predicting complex interactions, such as piglet compression during sow side-lying, remain exploratory and lack in-depth research. This type of interaction, called piglet compression, represents a complex interaction between sow and piglet, and its detection requires careful consideration of the interaction between piglets and sow.

[0004] When a sow lies on her side and her back squeezes piglets, due to the sow's large body, her back often creates a visual obstruction, making it difficult to monitor the specific number of piglets under pressure in a timely and accurate manner.

[0005] Therefore, how to accurately locate the fatal area where the sow squeezes the piglets and then detect the number of piglets squeezed by the sow is a problem that technicians in this field urgently need to solve. Summary of the Invention

[0006] In view of this, the present invention provides an automatic detection and analysis method and system for sow squeezing piglet events, which can accurately locate the fatal area where sows squeeze piglets and then detect the number of piglets squeezed by sows.

[0007] In order to achieve the above object, the present invention adopts the following technical solutions:

[0008] An automatic detection and analysis method for sow squeezing piglets event, comprising:

[0009] Obtain video data of lactating sows and piglets living together as the initial dataset;

[0010] Recognize the piglet mask outline, sow posture, sow mask outline and key points of all video frames based on the initial data set;

[0011] Filtering the initial data set based on the sow posture to obtain a basic data set;

[0012] Obtaining different fatal areas based on the basic data set and the corresponding sow mask contour and the key points;

[0013] determining a final lethal area based on the lethal area;

[0014] Tracking the piglet within the final lethal area based on the basic data set and the piglet mask outline to obtain a tracking result;

[0015] The number of crushed piglets was obtained based on the tracking results.

[0016] Preferably, obtaining the piglet mask outline, sow posture, sow mask outline and key points of all video frames specifically includes:

[0017] Build a deep learning network and perform pre-training to obtain a trained deep learning network;

[0018] Processing is performed based on the initial data set to obtain a plurality of video frame images;

[0019] The video frame image is input into the trained deep learning network to obtain the piglet mask contour, the sow posture, the sow mask contour and the key points.

[0020] Preferably, obtaining the basic data set specifically includes:

[0021] The sow posture includes: side lying and non-side lying;

[0022] A video frame image F of the sow lying on its side is obtained by screening the initial data set;

[0023] The N frames of video images preceding the video frame image F are selected as the basic data set.

[0024] Preferably, the key points include: the intersection T of the sow's tail and the sow's body and the key point E at the base of the ear.

[0025] Preferably, the different lethal areas include: an arc-shaped lethal area and a back-shaped lethal area;

[0026] The method for determining the arc-shaped fatal area is:

[0027] Get the midpoint M of the line connecting the intersection point T and the key point E at the base of the ear;

[0028] A line passing through the midpoint M and perpendicular to ET intersects the back and abdomen of the sow mask contour respectively, obtaining a back intersection point V and an abdomen intersection point U;

[0029] The measuring point P is obtained after the back intersection point V is offset by a distance b along the direction from V to M;

[0030] The arc obtained by connecting the three points E, P, and T intersects with the sow mask outline to obtain an intersection point R;

[0031] The arc-shaped fatal area is formed by sequentially connecting the intersection point R, the key point E at the base of the ear, the measurement point P, the intersection point T, the abdomen intersection point U and the intersection point R.

[0032] Preferably, the method for determining the fatal back area is:

[0033] After the abdominal intersection U is offset by a distance k along the UV direction, a node O is obtained;

[0034] Draw a straight line parallel to the ET line through the node O within the sow mask outline;

[0035] The straight line divides the sow mask outline into an upper region and a lower region;

[0036] The upper area is used as the back-shaped fatal area.

[0037] Preferably, determining the final lethal area specifically includes:

[0038] Obtaining a camera position C, and obtaining a vector CV based on connecting the camera position C with the back intersection point V;

[0039] A vector MT is obtained by connecting the midpoint M and the intersection point T;

[0040] Based on the vector MT, the vector MT is first rotated around the midpoint M toward the outside of the sow's body until the angle swept when it is in the same direction as the vector CV is used as the evaluation angle;

[0041] Determine whether the evaluation angle within the sow mask outline is greater than 180°. If so, determine that the sow's back is visible, and use the back-shaped lethal area as the final lethal area. Otherwise, determine that the sow's back is not visible, and use the arc-shaped lethal area as the final lethal area.

[0042] Preferably, obtaining the number of squeezed piglets based on the tracking results specifically includes:

[0043] Based on the basic data set, calculating the IOU values ​​of the piglet mask outline and the final fatal area in all video frame images to obtain multiple IOU values;

[0044] Determine whether the IOU value gradually decreases to 0, and if so, determine that the piglet is not in the final lethal area;

[0045] Otherwise, it is determined that the piglets are located in the final lethal area, and the number of piglets is accumulated into the set of squeezed piglets as the tracking result;

[0046] Determine whether the tracking result is ≥1, if so, determine that piglet squeezing has occurred, and use the tracking result as the number of squeezing piglets;

[0047] Otherwise, it is determined that piglet crushing has not occurred.

[0048] Preferably, after determining that piglet squeezing has occurred, the method further comprises:

[0049] Determine whether the piglets in the final lethal area are visible; if not, count the number of squeezed piglets as the number of invisible squeezed piglets and add them to the invisible set;

[0050] If yes, then determine whether the back contour line of the final fatal area passes through the piglet mask contour. If yes, determine it as a visible squeezed piglet and accumulate the number to obtain a visible set;

[0051] Otherwise, the piglets are determined to be overlapping but not squeezed and the number is accumulated to obtain the filtered set.

[0052] An automatic detection and analysis system for sow squeezing piglet events, comprising: a data acquisition module, a data processing module, a fatal area determination module, and a result output module;

[0053] The data acquisition module is used to acquire video data of lactating sows and piglets living together as an initial data set;

[0054] The data processing module is used to identify the piglet mask outline, sow posture, sow mask outline and key points of all video frames based on the initial data set; filter the initial data set based on the sow posture to obtain a basic data set;

[0055] The fatal area determination module is configured to obtain different fatal areas based on the basic data set and the corresponding sow mask outline and key points; and determine a final fatal area based on the fatal areas;

[0056] The result output module is used to track the piglets in the final fatal area based on the basic data set and the piglet mask outline to obtain a tracking result; and obtain the number of squeezed piglets based on the tracking result.

[0057] It can be seen from the above technical solutions that, compared with the prior art, the present invention provides a method and system for automatically detecting and analyzing sow squeezing piglets, which has the following beneficial effects:

[0058] 1. The present invention accurately determines the fatal area where the sow squeezes the piglets when lying on its side based on the method of adaptive fatal area positioning, solves the occlusion problem during the event of the sow squeezing the piglets on its back, and can accurately detect the number of squeezed piglets.

[0059] 2. The present invention realizes efficient automatic analysis of the behavior of sows squeezing piglets in side-lying position, provides a technical reference for automatic evaluation of sow maternal qualities, and provides a new method for automatic detection and analysis of sow squeezing piglet behavior. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0061] Figure 1 This is a flow chart of the automatic detection and analysis method for sow squeezing piglets provided by the present invention.

[0062] Figure 2 A cross-sectional view of a sow lying on its side provided by the present invention.

[0063] Figure 3 Schematic diagram of the key points and fatal areas of a side-lying sow provided by the present invention.

[0064] Figure 4 This is a visual graph of the regression relationship between the key points b, d, and h provided by the present invention.

[0065] Figure 5 This is a flow chart of the method for determining the final fatal area provided by the present invention.

[0066] Figure 6 This is a flow chart of the method for tracking the number of squeezed piglets provided by the present invention.

[0067] Figure 7 This is a schematic structural diagram of an automatic detection and analysis system for sow squeezing piglets provided by the present invention. DETAILED DESCRIPTION

[0068] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0069] Example 1

[0070] like Figure 1 As shown, the embodiment of the present invention discloses a method for automatically detecting and analyzing a sow squeezing piglet event, comprising:

[0071] Obtain video data of lactating sows and piglets living together as the initial dataset;

[0072] Based on the initial dataset, the piglet mask outline, sow posture, sow mask outline and key points of all video frames are identified;

[0073] The initial data set was screened based on the sow's posture to obtain a basic data set;

[0074] Different fatal areas are obtained based on the basic data set and the corresponding sow mask contours and key points;

[0075] Determining a final lethal area based on the lethal area;

[0076] Track the piglet in the final lethal area based on the basic data set and the piglet mask outline to obtain the tracking result;

[0077] The number of crushed piglets was obtained based on the tracking results.

[0078] Example 2

[0079] The embodiment of the present invention discloses a method for automatically detecting and analyzing a sow squeezing piglet event, comprising:

[0080] Obtain video data of lactating sows and piglets living together as the initial dataset:

[0081] Preferably, this embodiment is implemented by a high-definition video acquisition system and a data storage system built in a pig farm, and the recorded video data is organized to form an initial data set.

[0082] Preferably, the high-definition video acquisition system of this embodiment adopts: Dahua camera, model: DH-IPC-HFW3441E-SA.

[0083] Based on the initial dataset, the piglet mask outline, sow posture, sow mask outline and key points of all video frames are identified:

[0084] Preferably, obtaining the piglet mask outline, sow posture, sow mask outline and key points of all video frames specifically includes:

[0085] Build a deep learning network and perform pre-training to obtain a trained deep learning network;

[0086] Processing is performed based on the initial data set to obtain multiple video frame images;

[0087] The video frame image is input into the trained deep learning network to obtain the piglet mask contour, sow posture, sow mask contour and key points.

[0088] Preferably, the deep learning network pre-training process is:

[0089] Obtain video data of lactating sows and piglets living together;

[0090] The video data was edited into 238 video clips of several minutes in length;

[0091] Use the open source Labelme software to perform amodal instance segmentation and annotation on the video clips to obtain a labeled dataset;

[0092] The labeled dataset is divided into a training set and a test set in a ratio of 7:3;

[0093] The training set is used to train the deep learning network, and the test set verifies the effect of the deep learning network. At the same time, 4 long video clips are obtained in the test set to test the detection effect of the deep learning network, and finally a trained deep learning network is obtained.

[0094] Preferably, in this embodiment, the acquired video data relates to 61 Danish genetics sows, which are free to move and are individually raised with their piglets in farrowing pens; each pen is approximately 2.5 meters by 2.8 meters, with a floor that is 70% concrete and 30% plastic slats; an overhead camera (DH-IPC-HFW3441E-SA, Dahua Camera) is fixed to one corner of each pen, at a height of 2 meters and a shooting angle of 70°; the video data is recorded at a frame rate of 30 frames per second and a resolution of 1920×1080 pixels.

[0095] The initial dataset was filtered based on the sow’s posture to obtain the basic dataset:

[0096] Preferably, obtaining the basic data set specifically includes:

[0097] Sow postures include: side-lying and non-side-lying;

[0098] Based on the initial data set, a video frame image F of a sow lying on its side is obtained;

[0099] The N frames of video images before the video frame image F are selected as the basic data set.

[0100] Different fatal areas are obtained based on the basic data set and the corresponding sow mask contours and key points:

[0101] Preferably, Figure 2-Figure 3 As shown, the key points include: the intersection T of the sow's tail and the sow's body and the key point E at the base of the ear.

[0102] Preferably, the contact edge point P' of the sow with the ground can be projected to the visible side of the sow (point P) along the camera's viewing angle. Since the height and shooting angle of the camera are fixed in all pig pens, an approximate evaluation can be made through the regression equation of the sow's body shape and the distance between the camera and the sow.

[0103] Preferably, the different lethal areas include: an arc-shaped lethal area and a dorsal-shaped lethal area;

[0104] The method for determining the arc-shaped lethal area is:

[0105] Get the midpoint M of the line connecting the intersection point T and the key point E at the base of the ear;

[0106] The line passing through the midpoint M and perpendicular to ET intersects with the back and abdomen of the sow mask outline respectively, and the back intersection point V and the abdomen intersection point U are obtained accordingly;

[0107] The measuring point P is obtained after the back intersection point V is offset by a distance b along the V to M direction;

[0108] The arc obtained by connecting the three points E, P, and T intersects with the sow mask outline to obtain the intersection point R;

[0109] An arc-shaped fatal area is formed by connecting the intersection point R, the key point E at the base of the ear, the measurement point P, the intersection point T, the abdominal intersection point U and the intersection point R in sequence.

[0110] Preferably, the length of the line connecting the back intersection point V and the abdomen intersection point U is h. Based on the camera position C, the length of the line connecting the back intersection point V is d. The regression relationship between b, d and h is:

[0111] b=(855100-7255d+26710h+4.966×d 2 +0.665dh-15.160h 2 )×10 -5 ;

[0112] The visual representation of the regression relationship between b, d and h is as follows Figure 4 shown.

[0113] Preferably, the method for determining the back-shaped fatal area is:

[0114] The node O is obtained by offsetting the intersection point U of the abdomen by a distance k along the UV direction;

[0115] Draw a straight line parallel to the ET line through node O within the sow mask outline;

[0116] The straight line divides the sow mask outline into upper and lower regions;

[0117] Use the upper area as the fatal area of ​​the back shape.

[0118] Preferably, the value of k in this embodiment is: 0.25h.

[0119] Preferably, based on dividing the sow mask contour into upper and lower regions, the piglets whose lower region, ie, the suckling region, overlaps with the lethal region can be filtered.

[0120] Determine the final lethal area based on the lethal area:

[0121] Preferably, Figure 5 As shown, determine the final lethal area, including:

[0122] Get the camera position C, and obtain the vector CV based on the connection between the camera position C and the back intersection point V;

[0123] Vector MT is obtained by connecting the midpoint M and the intersection point T;

[0124] Based on the vector MT, first rotate it around the midpoint M toward the outside of the sow's body until the angle swept when it is in the same direction as the vector CV is used as the evaluation angle;

[0125] Determine whether the evaluation angle within the sow mask outline is greater than 180°. If so, the sow's back is determined to be visible, and the back-shaped lethal area is used as the final lethal area. Otherwise, the sow's back is determined to be invisible, and the arc-shaped lethal area is used as the final lethal area.

[0126] The piglet is tracked within the final lethal area based on the basic dataset and the piglet mask outline to obtain the tracking result.

[0127] The number of crushed piglets based on the tracking results:

[0128] Preferably, Figure 6 As shown in the figure, the number of crushed piglets was obtained based on the tracking results, including:

[0129] Based on the basic data set, the IOU values ​​between the piglet mask outline and the final fatal area in all video frame images are calculated to obtain multiple IOU values;

[0130] Determine whether the IOU value gradually decreases to 0. If so, it is determined that the piglet is not in the final lethal area;

[0131] Otherwise, the piglets are determined to be in the final lethal area, and the number of piglets is accumulated to the set of squeezed piglets as the tracking result;

[0132] Determine whether the tracking result is ≥ 1. If so, it is determined that piglet squeezing has occurred, and the tracking result is used as the number of squeezing piglets;

[0133] Otherwise, it is determined that piglet crushing has not occurred.

[0134] Preferably, after determining that piglet squeezing has occurred, the method further comprises:

[0135] Determine whether the piglets in the final lethal area are visible. If not, treat the number of squeezed piglets as the number of invisible squeezed piglets and add them to the invisible set.

[0136] If so, determine whether the back contour line of the final fatal area passes through the piglet mask contour. If so, determine it as a visible squeezed piglet and accumulate the number to obtain the visible set;

[0137] Otherwise, the piglets are determined to be overlapping but not squeezed and the number is accumulated to obtain the filtered set.

[0138] Preferably, after it is determined that piglet squeezing has occurred, if the piglets in the final fatal area are not visible, it is proved that all squeezing piglets are not visible. At this time, the number of squeezing piglets Q is equal to the number of invisible squeezing piglets Q z .

[0139] Preferably, after determining that piglet squeezing has occurred, if the piglets in the final fatal area are visible, then continue to determine whether the back contour line of the final fatal area passes through the piglet mask contour. If so, the number of visible squeezed piglets Q is accumulated. v Otherwise, it is determined as overlapping but not squeezed piglets and the cumulative number Q n , based on the number of crushed piglets Q, the number of visible crushed piglets Q v and the cumulative number of piglets that overlap but are not squeezed, Q n Get the number of invisible squeezed piglets Q z =QQ v -Q n .

[0140] Example 3

[0141] The method of the present invention was tested:

[0142] Segmentation performance evaluation of deep learning networks for instance segmentation of sows and piglets:

[0143] When performing instance segmentation on sows, the intersection over union (IoU) between the predicted mask and the ground truth mask of the sow is used to evaluate the segmentation performance. The IoU calculation expression is as follows:

[0144]

[0145] Among them, TP a Indicates the number of correct detections, FP a Indicates the number of false positives, FN a Indicates the number of missed detections;

[0146] The test results show that the IoU of piglet and sow segmentation are 0.871 and 0.951 respectively, which fully reflects the accuracy of sow and piglet instance segmentation.

[0147] Keypoint detection performance evaluation:

[0148] The precision P kand recall R k Used to evaluate keypoint detection performance. A keypoint is considered correctly detected if the Euclidean distance between a detected keypoint and the corresponding ground truth keypoint is less than 10% d.

[0149] Precision P k The calculation expression is as follows:

[0150]

[0151] Recall R k The calculation expression is as follows:

[0152]

[0153] The test results show that the precision and recall of key point detection are 97.8% and 96.5% respectively, which fully reflects the accuracy of the adaptive lethal area positioning method in detecting sow key points.

[0154] Accuracy assessment of piglet tracking in the lethal zone:

[0155] When tracking piglets within the lethal zone, the multi-target tracking method MOT is used. The MOTA score and IDF1 score are the two most important indicators in the field of MOT (multi-target tracking).

[0156]

[0157] Among them, MOTA represents the number of discrete errors of the tracker, FP represents the number of false detections, FN represents the number of missed detections, IDS represents the number of times the ID of one piglet is incorrectly assigned to another piglet, and GT represents the true value.

[0158]

[0159] Among them, the IDF1 score is the ratio of the number of correctly identified detections to the average of the actual number of ground detections and the calculated number of detections; IDTP not only means that the ratio area of ​​the intersection of the detection box and the actual ground box is greater than the threshold r, but also means that the piglet ID is the same as the initial piglet ID; IDFP means that the overlap requirement may be met, but the piglet IDs are not the same; IDFN means that the detection failed.

[0160] The IDF1 score is the ratio of the number of correctly identified detections to the average of the number of ground truth detections and the number of calculated detections. IDTP not only means that the ratio area of ​​the intersection of the detection box and the ground truth box is greater than the threshold r, but also means that the piglet ID is the same as the initial piglet ID.

[0161] The test results show that for tracking piglets in the lethal area, the MOTA is 0.946 and the IDF1 is 0.950, which fully reflects the accuracy of tracking piglets in the lethal area.

[0162] Squeeze event detection performance evaluation:

[0163] For the detection of piglet squeezing events, precision, recall, and F1score are used to evaluate the performance of squeezing event detection:

[0164]

[0165]

[0166]

[0167] Among them, TP c represents the number of correctly detected piglet crushing events, FP c represents the number of falsely detected piglet crush events, FN c represents the number of missed piglet crushing events, R C Represents the recall rate recall, P C Indicates precision.

[0168] The temporal-spatial intersection-over-union (TIoU) is introduced to evaluate the accuracy of detecting piglet squeezing events in long videos:

[0169]

[0170] Among them, CE det Indicates the detected squeeze event, CE gt Indicates actual events on the ground.

[0171] The piglet crushing event in the short video clips in the dataset was tested, and the classification results are shown in Table 1:

[0172] Table 1 Classification results of piglet crushing events in short video clips

[0173]

[0174] CE represents a squeeze event, and NCE represents a non-squeeze event. The test results show a recall rate of 0.919, a precision rate of 0.895, and an F1 score of 0.906.

[0175] The piglet crushing event in the long video clip was tested. The results of the crushing event are shown in Table 2:

[0176] Table 2 Classification results of piglet crush events in long video clips

[0177]

[0178] The test results showed an average TIoU of 0.968. The duration of the real and detected crush events was 9,346 seconds and 9,331 seconds, respectively. The total number of real and detected crush events was 14 and 14, respectively. The total number of real and detected crushed piglets was 9 and 10, respectively. The test results demonstrate that this method for automatically detecting and analyzing sow-piglet crushing events has high accuracy.

[0179] Example 4

[0180] like Figure 7 As shown, an automatic detection and analysis system for sow squeezing piglet events includes: a data acquisition module, a data processing module, a fatal area determination module and a result output module;

[0181] A data acquisition module is used to obtain video data of lactating sows and piglets living together as an initial data set;

[0182] The data processing module is used to identify the piglet mask outline, sow posture, sow mask outline and key points of all video frames based on the initial data set; the initial data set is filtered based on the sow posture to obtain the basic data set;

[0183] A fatal region determination module is used to obtain different fatal regions based on the basic data set and the corresponding sow mask contours and key points; and to determine the final fatal region based on the fatal regions;

[0184] The result output module is used to track the piglets in the final lethal area based on the basic data set and the piglet mask outline to obtain the tracking results; and the number of squeezed piglets is obtained based on the tracking results.

[0185] Preferably, each module of the automatic detection and analysis system for sow squeezing piglets in this embodiment executes the method described in Example 2 accordingly.

[0186] Example 5

[0187] Based on the same inventive concept, the present invention further provides a computer device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0188] Memory for storing computer programs;

[0189] The processor, when used to execute the program stored in the memory, can implement a method for automatically detecting and analyzing an event of sow squeezing piglets as in Example 1 or 2.

[0190] The electronic device may include a processor, a communications interface, a memory, and a communications bus, wherein the processor, the communications interface, and the memory communicate with each other via the communications bus. The processor may invoke logic instructions in the memory to execute the method for automatically detecting and analyzing a sow squeezing piglet event described in Example 1 or 2.

[0191] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0192] It can be seen from the above technical solutions that, compared with the prior art, the present invention provides a method and system for automatically detecting and analyzing sow squeezing piglets, which has the following beneficial effects:

[0193] 1. The present invention accurately determines the fatal area where the sow squeezes the piglets when lying on its side based on the method of adaptive fatal area positioning, solves the occlusion problem during the event of the sow squeezing the piglets on its back, and can accurately detect the number of squeezed piglets.

[0194] 2. The present invention realizes efficient automatic analysis of the behavior of sows squeezing piglets in side-lying position, provides a technical reference for automatic evaluation of sow maternal qualities, and provides a new method for automatic detection and analysis of sow squeezing piglet behavior.

[0195] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0196] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for automatically detecting and analyzing sow squeezing piglets, characterized in that: include: Obtain video data of lactating sows and piglets living together as the initial dataset; Recognize the piglet mask outline, sow posture, sow mask outline and key points of all video frames based on the initial data set; The key points include: the intersection T of the sow's tail and the sow's body and the key point E at the base of the ear; Filtering the initial data set based on the sow posture to obtain a basic data set; Obtaining different fatal areas based on the basic data set and the corresponding sow mask contour and the key points; The different lethal areas include: an arc-shaped lethal area and a back-shaped lethal area; The method for determining the arc-shaped fatal area is: Get the midpoint M of the line connecting the intersection point T and the key point E at the base of the ear; A line passing through the midpoint M and perpendicular to ET intersects the back and abdomen of the sow mask contour respectively, obtaining a back intersection point V and an abdomen intersection point U; The measuring point P is obtained after the back intersection point V is offset by a distance b along the direction from V to M; The arc obtained by connecting the three points E, P, and T intersects with the sow mask outline to obtain an intersection point R; The arc-shaped fatal area is formed by sequentially connecting the intersection point R, the key point E at the base of the ear, the measurement point P, the intersection point T, the abdomen intersection point U, and the intersection point R; The method for determining the fatal back area is as follows: After the abdominal intersection U is offset by a distance k along the UV direction, a node O is obtained; Draw a straight line parallel to the ET line through the node O within the sow mask outline; The straight line divides the sow mask outline into an upper region and a lower region; Using the upper area as the dorsal fatal area; determining a final lethal area based on the lethal area; Determine the final lethal zone, including: Obtaining a camera position C, and obtaining a vector CV based on connecting the camera position C with the back intersection point V; A vector MT is obtained by connecting the midpoint M and the intersection point T; Based on the vector MT, the vector MT is first rotated around the midpoint M toward the outside of the sow's body until the angle swept when it is in the same direction as the vector CV is used as the evaluation angle; Determine whether the evaluation angle within the sow mask outline is greater than 180°; if so, determine that the sow's back is visible, and use the back-shaped lethal area as the final lethal area; otherwise, determine that the sow's back is not visible, and use the arc-shaped lethal area as the final lethal area; Tracking the piglet within the final lethal area based on the basic data set and the piglet mask outline to obtain a tracking result; The number of crushed piglets was obtained based on the tracking results.

2. The automatic detection and analysis method for sow squeezing piglet events according to claim 1 is characterized in that: Obtain the piglet mask outline, sow posture, sow mask outline and key points of all video frames, including: Build a deep learning network and perform pre-training to obtain a trained deep learning network; Processing is performed based on the initial data set to obtain a plurality of video frame images; The video frame image is input into the trained deep learning network to obtain the piglet mask contour, the sow posture, the sow mask contour and the key points.

3. The automatic detection and analysis method for sow squeezing piglet events according to claim 2 is characterized in that: The basic data set includes: The sow posture includes: side lying and non-side lying; A video frame image F of the sow lying on its side is obtained by screening the initial data set; The N frames of video images preceding the video frame image F are selected as the basic data set.

4. The automatic detection and analysis method for sow squeezing piglet events according to claim 3 is characterized in that: The number of crushed piglets is obtained based on the tracking results, specifically including: Based on the basic data set, calculating the IOU values ​​of the piglet mask outline and the final fatal area in all video frame images to obtain multiple IOU values; Determine whether the IOU value gradually decreases to 0, and if so, determine that the piglet is not in the final lethal area; Otherwise, it is determined that the piglets are located in the final lethal area, and the number of piglets is accumulated into the set of squeezed piglets as the tracking result; Determine whether the tracking result is ≥1, if so, determine that piglet squeezing has occurred, and use the tracking result as the number of squeezing piglets; Otherwise, it is determined that piglet crushing has not occurred.

5. The automatic detection and analysis method for sow squeezing piglet events according to claim 4 is characterized in that: After determining that piglet crush has occurred, it also includes: Determine whether the piglets in the final lethal area are visible; if not, count the number of squeezed piglets as the number of invisible squeezed piglets and add them to the invisible set; If yes, then determine whether the back contour line of the final fatal area passes through the piglet mask contour. If yes, determine it as a visible squeezed piglet and accumulate the number to obtain a visible set; Otherwise, the piglets are determined to be overlapping but not squeezed and the number is accumulated to obtain the filtered set.

6. An automatic detection and analysis system for sow squeezing piglet events, applied to the automatic detection and analysis method for sow squeezing piglet events according to any one of claims 1 to 5, characterized in that: include: Data acquisition module, data processing module, fatal area determination module and result output module; The data acquisition module is used to acquire video data of lactating sows and piglets living together as an initial data set; The data processing module is used to identify the piglet mask outline, sow posture, sow mask outline and key points of all video frames based on the initial data set; Filtering the initial data set based on the sow posture to obtain a basic data set; The fatal area determination module is used to obtain different fatal areas based on the basic data set and the corresponding sow mask outline and the key points; determining a final lethal area based on the lethal area; The result output module is used to track the piglet in the final lethal area based on the basic data set and the piglet mask outline to obtain a tracking result; The number of crushed piglets was obtained based on the tracking results.

Citation Information

Patent Citations

  • Method and device for monitoring piglet compression

    CN110598643A

  • Convolutional network identification method for sow lactation behaviors

    CN110598658A