Pig crowding condition detection method and system and storage medium

By combining rotating target detection and sort tracking algorithms with distance and overlap detection, dynamically adjusting detection standards, and introducing manual review, the problems of high false detection and missed detection rates in pig detection are solved, and efficient and accurate pig crowding detection is achieved.

CN120726544AActive Publication Date: 2025-09-30厦门农芯数字科技有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511222466.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2025-09-30
Estimated Expiration
2045-08-29

AI Technical Summary

Technical Problem

Existing technologies have high false detection and missed detection rates in pig detection, especially in scenarios with narrow passages and dense pig populations. Detection algorithms based on horizontal bounding boxes have limited ability to recognize rotated, overlapping, and occluded targets.

Method used

A rotating target detection algorithm is used to obtain the rotating bounding box of pigs, which is then counted in combination with a sort tracking algorithm. The crowding of pigs is judged in parallel through a distance detection mechanism and an overlap detection mechanism. The detection standard is dynamically adjusted, and a manual review step is introduced for secondary confirmation.

Benefits of technology

It significantly improves detection efficiency, reduces false detection and missed detection rates, achieves rapid response and accurate detection of pig crowding, improves the robustness and adaptability of the system, and ensures the accuracy and reliability of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120726544A_ABST
    Figure CN120726544A_ABST
Patent Text Reader

Abstract

The invention discloses a pig crowding condition detection method and system and a storage medium, and the method comprises the steps: obtaining a real-time video stream, and obtaining a rotation bounding box of each pig through a rotation target detection algorithm; counting the pigs by adopting a sort tracking algorithm on the basis of the rotating bounding box to obtain the counting number of the pigs; whether the pigs are crowded or not is judged in parallel through a distance detection mechanism and an overlapping rate detection mechanism; calculating the central point distance of each pig pair in each video frame in the real-time video stream, and judging and counting the number of first pig pairs of which the central point distance is smaller than a distance threshold; calculating an overlapping rate between the rotation bounding boxes of the pig pairs in each video frame in the real-time video stream, and judging and counting the number of second pig pairs greater than an overlapping rate threshold; when the first pig logarithm number and the second pig logarithm number are both greater than or equal to the corresponding threshold values, determining that a pig crowding condition exists and acquiring a crowding frame; based on the crowded frame, intercepting a crowded video clip containing the crowded frame; and performing enhancement processing on the crowded video clip, and pushing the crowded video clip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of pig target detection, and in particular to a method, system and storage medium for detecting pig crowding. Background Art

[0002] Currently, farms rely heavily on video surveillance systems for manual observation. However, due to the diverse camera angles, the ever-changing pig shapes, and severe obstructions, manual monitoring suffers from low efficiency, delayed response, and the tendency to miss detections.

[0003] Although some studies have used deep learning-based target detection algorithms for pig counting and behavior analysis, most of them are based on horizontal bounding box detection and have limited ability to recognize rotated, overlapping, and occluded targets. In particular, in scenarios with narrow passages and dense pig populations, the false detection rate and missed detection rate are high.

[0004] Therefore, the existing technology has the problem of high false detection and missed detection rates in pig crowding detection. Summary of the Invention

[0005] To solve the above technical problems, the present invention provides a method for detecting pig crowding, which comprises the following steps: Obtain real-time video stream and use rotating object detection algorithm to obtain the rotating bounding box of each pig; Based on the rotation bounding box, the sort tracking algorithm is used to count the pigs and obtain the number of pigs counted; Based on the rotating bounding box and real-time video stream, the distance detection mechanism and the overlap detection mechanism are used to determine whether there is pig crowding. The distance detection mechanism includes: calculating the distance between the center points of the pig pairs in each video frame in the real-time video stream; based on the distance threshold, determining and counting the number of the first pig pairs whose center point distance is less than the distance threshold; The overlap rate detection mechanism includes: calculating the overlap rate between the rotated bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap rate threshold, determining and counting the number of second pig pairs with an overlap rate greater than the overlap rate threshold; When the number of the first pig pairs is greater than or equal to the first pig pair threshold, and the number of the second pig pairs is greater than or equal to the second pig pair threshold, it is determined that there is pig crowding and a crowding frame is obtained; Based on the crowded frames, a crowded video segment containing the crowded frames is intercepted; Enhance the crowded video clips and push the enhanced crowded video clips.

[0006] Optionally, the distance detection mechanism specifically includes the following steps: Calculate the pixel width of each pig in each video frame in the live video stream based on the rotated bounding box; Calculate the average pixel width of all pigs in each video frame; Calculate the center point coordinates of the rotated bounding box of each pig in each video frame, and calculate the center point distances between all pairs of pigs in each video frame; Based on the distance threshold, the number of first pig pairs whose center point distance is less than the distance threshold is counted; Determine whether the number of the first pig pair is greater than or equal to the first pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the overlap rate detection mechanism.

[0007] Optionally, the distance threshold is a preset multiple of the average pixel width.

[0008] Optionally, the pixel width of each pig in each video frame in the real-time video stream is calculated based on the rotated bounding box, specifically comprising the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box and the rotation angle; Based on the four vertex coordinates and the rotation angle, the pixel width perpendicular to the pig's body length is calculated.

[0009] Optionally, the overlap detection mechanism specifically includes the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box; Calculate the overlapping area between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream according to a preset overlapping area calculation formula; Based on the overlapping area, the overlap ratio between the rotation bounding boxes of the pig pairs in each video frame was calculated; Based on the overlap rate threshold, the number of second pig pairs with a rate greater than the overlap rate threshold is determined and counted; Determine whether the number of the second pig pairs is greater than or equal to the second pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the distance detection mechanism.

[0010] Optionally, performing enhancement processing on the crowded video clip includes at least one of the following steps: Superimposing at least one of the pig's rotation bounding box, ID identification information, distance detection result, and overlap rate detection result in the video frame; Use the preset video coding format to compress crowded video clips; The recognition confidence corresponding to each rotated bounding box is obtained, and a timestamp is added to the video frame whose recognition confidence is less than the confidence threshold.

[0011] Optionally, also include: Obtaining manual review results of the crowding video clips; the manual review results shall at least include the actual number of pigs, the authenticity confirmation of the crowding event, and the crowding level labeling; Compare the manual review results with the pig crowding test results, and determine whether a second review is needed based on the comparison results; According to the comparison results, the training data set corresponding to the pig crowding detection method is updated, and the pig crowding detection model corresponding to the pig crowding detection method is optimized.

[0012] Optionally, the manual review result is compared with the pig crowding detection result, and based on the comparison result, it is determined whether a second review is required, which at least includes the following steps: Compare the actual number of pigs with the number of pigs counted and obtain the difference between the two; if the difference between the two is greater than the preset difference threshold, a second review is required; Compare the authenticity confirmation results of the crowding event with the pig crowding detection results to determine whether there is a misjudgment of the pig crowding detection results; if so, a second review is required.

[0013] Corresponding to the pig crowding detection method, the present invention provides a pig crowding detection system, which includes: The pig detection module is used to obtain the real-time video stream and use the rotating object detection algorithm to obtain the rotating bounding box of each pig; The counting module is used to count the pigs based on the rotation bounding box and the sort tracking algorithm to obtain the number of pigs counted; The pig crowding detection module is used to determine whether there is pig crowding based on the rotating bounding box and the real-time video stream through a distance detection mechanism and an overlap rate detection mechanism in parallel; the distance detection mechanism includes: calculating the center point distance of the pig pairs in each video frame in the real-time video stream; based on a distance threshold, determining and counting the number of first pig pairs whose center point distance is less than the distance threshold; the overlap rate detection mechanism includes: calculating the overlap rate between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap rate threshold, determining and counting the number of second pig pairs whose center point distance is greater than the overlap rate threshold; wherein, when the number of first pig pairs is greater than or equal to the first pig pair threshold, and the number of second pig pairs is greater than or equal to the second pig pair threshold, it is determined that pig crowding exists and a crowding frame is obtained; A crowded video segment acquisition module is used to intercept a crowded video segment containing a crowded frame based on the crowded frame; The crowded video segment processing module is used to perform enhancement processing on the crowded video segment and push the enhanced crowded video segment.

[0014] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a pig crowding detection program is stored. When the pig crowding detection program is executed by a processor, the steps of the pig crowding detection method described above are implemented.

[0015] Compared with the existing technology, the present invention adopts a rotating target detection algorithm to automatically obtain the rotating bounding box of each pig; based on the rotating bounding box, a sort tracking algorithm is used to count the pigs to obtain the pig count number, replacing manual counting and observation, significantly improving detection efficiency, and avoiding the lag and missed detection problems of manual observation; and, through the parallel judgment of the distance detection mechanism and the overlap rate detection mechanism, the pig crowding situation is judged with high real-time detection, so that the present invention can quickly detect and respond at the moment of crowding, effectively solving the problem of delayed manual response and reducing the false detection and missed detection rates.

[0016] Compared with the existing technology, the present invention provides a dynamic distance threshold basis for subsequent distance detection by calculating the pixel width of each pig and the average pixel width of all pigs, so that the detection mechanism can automatically adjust the detection standard according to the size of the pig, thereby enhancing the system's adaptability to pigs of different sizes.

[0017] Compared to existing technologies, this invention provides a simple and effective method for dynamically determining the distance threshold by setting it as a preset multiple of the average pixel width. This method automatically adjusts the detection criteria based on the overall body shape of the pig population, avoiding misjudgments due to individual body size differences. It also enhances the system's robustness and versatility across various farming scenarios.

[0018] Compared with the prior art, the present invention can more accurately identify scenes where real crowding occurs by precisely calculating the overlap rate between pairs of pigs.

[0019] Compared with the existing technology, the present invention superimposes at least one of the pig's rotation bounding box, ID identification information, distance detection results, and overlap rate detection results in the video frame, so that reviewers can intuitively understand the AI's judgment basis and improve review efficiency and accuracy; the present invention uses a preset video encoding format to compress crowded video clips, reducing storage occupancy and transmission time while ensuring video clarity; the present invention obtains the recognition confidence corresponding to the rotation bounding box and adds a timestamp mark to the video frame with lower confidence, so as to guide reviewers to focus on frame segments that may have detection errors and optimize the review process.

[0020] Compared with the existing technology, the present invention introduces a manual review process to conduct a second confirmation of the test results to ensure the accuracy and reliability of the test results. By manually reviewing the actual number of pigs, confirming the authenticity of the crowding event, and marking the crowding level, a more realistic and detailed decision-making basis is provided for breeding management. Furthermore, the manual review results are compared with the AI ​​test results, and the need for a second review is determined based on the comparison differences. The review process is further refined to ensure that each test result is fully verified. Based on the comparison results, the training data set is updated and the detection model is optimized to achieve continuous improvement and optimization of the detection method, and continuously improve the performance and accuracy of pig crowding detection.

[0021] Compared with the existing technology, the present invention provides specific comparison logic between the actual number of pigs and the AI ​​counting results, as well as a comparison method between the authenticity confirmation results of crowding events and the AI ​​detection results. It clarifies the triggering conditions for secondary review, enhances the system's intelligent decision-making ability in the review link, avoids unnecessary review work, and improves overall work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 This is a simplified flow chart of an embodiment of a method for detecting pig crowding of the present invention; Figure 2 This is a schematic diagram showing the effect of an embodiment of enhanced processing in the method for detecting pig crowding of the present invention; Figure 3 This is a framework diagram of an embodiment of a pig crowding detection system of the present invention. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0024] like Figure 1 As shown, a method for detecting pig crowding of the present invention comprises the following steps: Obtain real-time video stream and use rotating object detection algorithm to obtain the rotating bounding box of each pig; Based on the rotation bounding box, the sort tracking algorithm is used to count the pigs and obtain the number of pigs counted; Based on the rotating bounding box and real-time video stream, the distance detection mechanism and the overlap detection mechanism are used to determine whether there is pig crowding. The distance detection mechanism includes: calculating the distance between the center points of the pig pairs in each video frame in the real-time video stream; based on the distance threshold, determining and counting the number of the first pig pairs whose center point distance is less than the distance threshold; The overlap rate detection mechanism includes: calculating the overlap rate between the rotated bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap rate threshold, determining and counting the number of second pig pairs with an overlap rate greater than the overlap rate threshold; When the number of the first pig pairs is greater than or equal to the first pig pair threshold, and the number of the second pig pairs is greater than or equal to the second pig pair threshold, it is determined that there is pig crowding and a crowding frame is obtained; Based on the crowded frames, a crowded video segment containing the crowded frames is intercepted; Enhance the crowded video clips and push the enhanced crowded video clips.

[0025] It is understood that a pig pair is any two different pigs.

[0026] In this embodiment, the first pig pair threshold and the second pig pair threshold may be the same preset value, preferably 5.

[0027] It should be noted that obtaining a rotating bounding box for each pig using a rotating object detection algorithm can be achieved using existing technologies and will not be elaborated on here. The rotating object detection algorithm outputs an angled bounding box, providing basic data for subsequent pig counting and crowding assessment. Based on the rotating bounding box, the present invention uses a sort tracking algorithm to count pigs, and the number of pigs is determined by counting across the line.

[0028] Preferably, the crowded video segment containing the crowded frame is intercepted, and the specific interception range is "the pig segment containing the crowded frame". The core relies on the recording control interface of deepstream: If you choose to capture the clip before the congestion frame, you need to call DeepStream's retroactive recording function (based on the video data stored in the ring buffer) when congestion is detected to extract the video stream N seconds before the congestion frame. This mode is suitable for tracing the cause of the congestion event. The buffer size must be configured in advance to balance storage usage and the retroactive recording time (typically 5-10 seconds). By calling DeepStream's start_recording() and stop_recording() methods, no additional algorithm adjustments are required.

[0029] The present invention adopts a rotating target detection algorithm to automatically obtain a rotating bounding box of each pig; based on the rotating bounding box, a sort tracking algorithm is used to count the pigs to obtain the pig count number, replacing manual counting and observation, significantly improving detection efficiency, and avoiding the lag and missed detection problems of manual observation; and, through the parallel judgment of the distance detection mechanism and the overlap rate detection mechanism, the pig crowding situation is judged with high real-time detection performance, so that the present invention can quickly detect and respond at the moment of crowding, effectively solving the problem of delayed manual response and reducing the false detection and missed detection rates.

[0030] In this embodiment, the distance detection mechanism specifically includes the following steps: Calculate the pixel width of each pig in each video frame in the live video stream based on the rotated bounding box; Calculate the average pixel width of all pigs in each video frame; Calculate the center point coordinates of the rotated bounding box of each pig in each video frame, and calculate the center point distances between all pairs of pigs in each video frame; Based on the distance threshold, the number of first pig pairs whose center point distance is less than the distance threshold is counted; Determine whether the number of the first pig pair is greater than or equal to the first pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the overlap rate detection mechanism.

[0031] Preferably, the coordinates of the center point of the rotation bounding box of each pig in each video frame are calculated as follows: obtaining the coordinates of the four vertices of the rotation bounding box of each pig (X1, Y1), (X2, Y2), (X3, Y3), (X4, Y4); Based on the coordinates of the four vertices, calculate the coordinates of the center point of the rotation bounding box (X center ,Y center ); Among them, X center =(X1+X2+X3+X4) / 4,Y center =(Y1+Y2+Y3+Y4) / 4.

[0032] In this embodiment, the center point distance d between all pig pairs in each video frame is calculated. ij , specifically: ;in, 、 are the X coordinate values ​​of the center points of the rotation bounding boxes of the two pigs in the pig pair, 、 They are the Y coordinate values ​​of the center points of the rotation bounding boxes of the two pigs in the pig pair.

[0033] The present invention calculates the pixel width of each pig and the average pixel width of all pigs to provide a dynamic distance threshold basis for subsequent distance detection, so that the detection mechanism can automatically adjust the detection standard according to the size of the pig, enhancing the system's adaptability to pigs of different sizes.

[0034] In this embodiment, the distance threshold is a preset multiple of the average pixel width, preferably 2 times.

[0035] By setting the distance threshold as a preset multiple of the average pixel width, this invention provides a simple and effective method for dynamically determining the distance threshold. This method automatically adjusts the detection criteria based on the overall body shape of the pig population, avoiding misjudgments due to individual body size differences and enhancing the system's robustness and versatility across various farming scenarios.

[0036] In this embodiment, the pixel width of each pig in each video frame in the real-time video stream is calculated based on the rotated bounding box, which specifically includes the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box and the rotation angle; Based on the four vertex coordinates and the rotation angle, the pixel width perpendicular to the pig's body length is calculated.

[0037] In this embodiment, the overlap rate detection mechanism specifically includes the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box; Calculate the overlapping area between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream according to a preset overlapping area calculation formula; Based on the overlapping area, the overlap ratio between the rotation bounding boxes of the pig pairs in each video frame was calculated; Based on the overlap rate threshold, determine and count the number of second pig pairs whose number is greater than the overlap rate threshold; preferably, the overlap rate threshold is 0.3; Determine whether the number of the second pig pairs is greater than or equal to the second pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the distance detection mechanism.

[0038] Preferably, the overlapping area between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream is calculated according to a preset overlapping area calculation formula, which specifically includes the following steps: For the two rotation bounding boxes of the two pigs, obtain their four vertex coordinates, which are recorded as: ; as well as ; The overlapping area between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream is calculated according to the preset overlapping area calculation formula. The preset overlapping area calculation formula S is as follows:

[0039] ; In this embodiment, the overlap ratio P between the rotation bounding boxes of the pig pairs in each video frame is calculated based on the overlap area, specifically: ; Where W is the sum of the areas of the two rotated bounding boxes of the two pigs, which can be calculated using the polygon area calculation formula (such as the shoelace formula).

[0040] The present invention can more accurately identify scenes where real crowding occurs by accurately calculating the overlap rate between pairs of pigs.

[0041] In this embodiment, performing enhancement processing on a crowded video segment includes at least one of the following steps: At least one of the pig rotation bounding box, ID identification information, distance detection result, and overlap detection result is superimposed on the video frame (the superposition effect can be referred to Figure 2 ); Use the preset video coding format to compress crowded video clips; The recognition confidence corresponding to each rotated bounding box is obtained, and a timestamp is added to the video frames whose recognition confidence is less than a confidence threshold. Preferably, the confidence threshold is 0.5.

[0042] The present invention superimposes at least one of the pig's rotation bounding box, ID identification information, distance detection results, and overlap rate detection results in the video frame, so that reviewers can intuitively understand the AI's judgment basis and improve review efficiency and accuracy; the present invention uses a preset video encoding format to compress crowded video clips, reducing storage occupancy and transmission time while ensuring video clarity; the present invention obtains the recognition confidence corresponding to the rotation bounding box and adds a timestamp mark to the video frame with lower confidence, guiding reviewers to focus on frame segments that may have detection errors and optimizing the review process.

[0043] In this embodiment, it also includes: Obtain the results of manual review of the crowding video clips (this can be obtained by issuing a notification for manual data entry, or by manual self-reporting). The manual review results should at least include the actual number of pigs, the authenticity confirmation of the crowding event, and the crowding level labeling; Compare the manual review results with the pig crowding test results, and determine whether a second review is needed based on the comparison results; According to the comparison results, the training data set corresponding to the pig crowding detection method is updated, and the pig crowding detection model corresponding to the pig crowding detection method is optimized.

[0044] The present invention introduces a manual review process to conduct a second confirmation of the test results to ensure the accuracy and reliability of the test results. By manually reviewing the actual number of pigs, confirming the authenticity of the crowding event, and marking the crowding level, a more realistic and detailed decision-making basis is provided for breeding management. Furthermore, the manual review results are compared with the AI ​​test results, and the need for a second review is determined based on the comparison differences. The review process is further refined to ensure that each test result is fully verified. Based on the comparison results, the training data set is updated and the detection model is optimized to achieve continuous improvement and optimization of the detection method, and continuously improve the performance and accuracy of pig crowding detection.

[0045] In this embodiment, the manual review result is compared with the pig crowding detection result, and based on the comparison result, it is determined whether a second review is required, which at least includes the following steps: The actual number of pigs is compared with the number of pigs counted to obtain the difference between the two; if the difference between the two is greater than the preset difference threshold, a second review is required; preferably, the preset difference threshold is ±1.

[0046] Compare the authenticity confirmation results of the crowding event with the pig crowding detection results to determine whether there is a misjudgment of the pig crowding detection results; if so, a second review is required.

[0047] The present invention provides specific comparison logic between the actual number of pigs and the AI ​​counting results, as well as a comparison method between the authenticity confirmation results of crowding events and the AI ​​detection results. It clarifies the triggering conditions for secondary review, enhances the system's intelligent decision-making ability in the review link, avoids unnecessary review work, and improves overall work efficiency.

[0048] like Figure 3 As shown, the present invention also provides a pig crowding detection system, which includes: The pig detection module 10 is used to obtain the real-time video stream and use the rotating object detection algorithm to obtain the rotating bounding box of each pig; A counting module 20 is configured to count the pigs using a sort tracking algorithm based on the rotated bounding box to obtain the number of pigs counted; The pig crowding detection module 30 is configured to determine whether there is pig crowding based on the rotating bounding boxes and the real-time video stream using a distance detection mechanism and an overlap detection mechanism in parallel. The distance detection mechanism includes calculating the center point distance of the pig pairs in each video frame in the real-time video stream; and based on a distance threshold, determining and counting the number of first pig pairs whose center point distance is less than the distance threshold. The overlap detection mechanism includes calculating the overlap rate between the rotated bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap threshold, determining and counting the number of second pig pairs whose center point distance is greater than the overlap threshold. When the number of first pig pairs is greater than or equal to the first pig pair threshold, and the number of second pig pairs is greater than or equal to the second pig pair threshold, it is determined that pig crowding exists and a crowding frame is obtained. A crowded video segment acquisition module 40 is configured to capture a crowded video segment containing a crowded frame based on the crowded frame; The crowded video segment processing module 50 is configured to perform enhancement processing on the crowded video segment and push the enhanced crowded video segment.

[0049] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The computer readable storage medium may be a read-only memory, a magnetic disk or an optical disk.

[0050] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between the various embodiments can be referred to in conjunction with each other. The system and storage medium embodiments are described briefly because they are generally similar to the method embodiments. For relevant parts, refer to the description of the method embodiments.

[0051] Furthermore, in this document, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0052] While the foregoing description shows and describes preferred embodiments of the present invention, it should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments, and can be modified within the scope of the present invention by the teachings herein or by techniques or knowledge in the relevant art. Modifications and variations made by those skilled in the art without departing from the spirit and scope of the present invention are intended to be within the scope of the appended claims.

Claims

1. A method for detecting pig crowding, characterized in that: The following steps are involved: Obtain real-time video stream and use rotating object detection algorithm to obtain the rotating bounding box of each pig; Based on the rotation bounding box, the sort tracking algorithm is used to count the pigs and obtain the number of pigs counted; Based on the rotating bounding box and real-time video stream, the distance detection mechanism and the overlap detection mechanism are used to determine whether there is pig crowding. The distance detection mechanism includes: calculating the distance between the center points of the pig pairs in each video frame in the real-time video stream; based on the distance threshold, determining and counting the number of the first pig pairs whose center point distance is less than the distance threshold; The overlap rate detection mechanism includes: calculating the overlap rate between the rotated bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap rate threshold, determining and counting the number of second pig pairs with an overlap rate greater than the overlap rate threshold; When the number of the first pig pairs is greater than or equal to the first pig pair threshold, and the number of the second pig pairs is greater than or equal to the second pig pair threshold, it is determined that there is pig crowding and a crowding frame is obtained; Based on the crowded frames, a crowded video segment containing the crowded frames is intercepted; Enhance the crowded video clips and push the enhanced crowded video clips.

2. The method for detecting pig crowding according to claim 1, characterized in that: The distance detection mechanism specifically includes the following steps: Calculate the pixel width of each pig in each video frame in the live video stream based on the rotated bounding box; Calculate the average pixel width of all pigs in each video frame; Calculate the center point coordinates of the rotated bounding box of each pig in each video frame, and calculate the center point distances between all pairs of pigs in each video frame; Based on the distance threshold, the number of first pig pairs whose center point distance is less than the distance threshold is counted; Determine whether the number of the first pig pair is greater than or equal to the first pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the overlap rate detection mechanism.

3. The method for detecting pig crowding according to claim 2, wherein: The distance threshold is a preset multiple of the average pixel width.

4. The method for detecting pig crowding according to claim 2, wherein: Calculate the pixel width of each pig in each frame of the live video stream based on the rotated bounding box. This involves the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box and the rotation angle; Based on the four vertex coordinates and the rotation angle, the pixel width perpendicular to the pig's body length is calculated.

5. The method for detecting pig crowding according to claim 1, wherein: The overlap detection mechanism specifically includes the following steps: Based on the rotation bounding box, obtain the coordinates of the four vertices of the rotation bounding box; Calculate the overlapping area between the rotating bounding boxes of the pig pairs in each video frame in the real-time video stream according to a preset overlapping area calculation formula; Based on the overlapping area, the overlap ratio between the rotation bounding boxes of the pig pairs in each video frame was calculated; Based on the overlap rate threshold, the number of second pig pairs with a rate greater than the overlap rate threshold is determined and counted; Determine whether the number of the second pig pairs is greater than or equal to the second pig pair threshold. If not, there is no pig crowding. If so, determine whether there is pig crowding in parallel with the distance detection mechanism.

6. The method for detecting pig crowding according to claim 1, wherein: The method of enhancing a crowded video clip includes at least one of the following steps: Superimposing at least one of the pig's rotation bounding box, ID identification information, distance detection result, and overlap rate detection result in the video frame; Use the preset video coding format to compress crowded video clips; The recognition confidence corresponding to each rotated bounding box is obtained, and a timestamp is added to the video frame whose recognition confidence is less than the confidence threshold.

7. The method for detecting pig crowding according to claim 1, wherein: Also includes: Obtain manual review results of crowded video clips; The manual review results shall at least include the actual number of pigs, the authenticity confirmation of the crowding incident, and the crowding level labeling; Compare the manual review results with the pig crowding test results, and determine whether a second review is needed based on the comparison results; According to the comparison results, the training data set corresponding to the pig crowding detection method is updated, and the pig crowding detection model corresponding to the pig crowding detection method is optimized.

8. The method for detecting pig crowding according to claim 7, characterized in that: Comparing the manual review results with the pig crowding detection results and determining whether a second review is required based on the comparison results includes at least the following steps: Compare the actual number of pigs with the number of pigs counted and obtain the difference between the two; if the difference between the two is greater than the preset difference threshold, a second review is required; Compare the authenticity confirmation results of the crowding event with the pig crowding detection results to determine whether there is a misjudgment of the pig crowding detection results; if so, a second review is required.

9. A pig crowding detection system, characterized in that: include: The pig detection module is used to obtain the real-time video stream and use the rotating object detection algorithm to obtain the rotating bounding box of each pig; The counting module is used to count the pigs based on the rotation bounding box and the sort tracking algorithm to obtain the number of pigs counted; Pig crowding detection module, which is used to determine whether there is pig crowding based on the rotating bounding box and real-time video stream, using the distance detection mechanism and the overlap detection mechanism in parallel; The distance detection mechanism includes: calculating the center point distance of the pig pairs in each video frame in the real-time video stream; based on the distance threshold, determining and counting the number of first pig pairs whose center point distance is less than the distance threshold; the overlap rate detection mechanism includes: calculating the overlap rate between the rotated bounding boxes of the pig pairs in each video frame in the real-time video stream, and based on the overlap rate threshold, determining and counting the number of second pig pairs whose overlap rate is greater than the overlap rate threshold; wherein, when the number of first pig pairs is greater than or equal to the first pig pair threshold, and the number of second pig pairs is greater than or equal to the second pig pair threshold, it is determined that pig crowding exists and a crowding frame is obtained; A crowded video segment acquisition module is used to intercept a crowded video segment containing a crowded frame based on the crowded frame; The crowded video segment processing module is used to perform enhancement processing on the crowded video segment and push the enhanced crowded video segment.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a pig crowding detection program, which, when executed by a processor, implements the steps of the pig crowding detection method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Breeding environment information prompting method and device, medium and electronic equipment

    CN112101290A

  • Method and system for counting pigs in field

    CN115311546A

  • Pig rotating target detection method, system and device and storage medium

    CN117809330A

  • Adaptive bounding box merge method in blob analysis for video analytics

    US20180047193A1