Animal delivery automatic counting method and system based on image recognition and threshold adjustment
An automatic animal parturition counting method based on adaptive interval frames and confidence threshold adjustment solves the problems of low efficiency and insufficient accuracy in monitoring parturition in high-yielding mammals. It achieves high-precision, low-false-detection identification and counting of parturition events, thereby improving the level of intelligence in breeding management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies for monitoring parturition in high-yielding mammals suffer from low efficiency, insufficient accuracy, and the need for human intervention. In particular, the number of parturition events is not accurately counted in complex environments. Existing systems lack adaptive adjustment mechanisms, leading to decreased recognition accuracy and frequent false positives and false negatives.
An automatic animal parturition counting method based on adaptive interval frames and confidence threshold adjustment is adopted. By combining a target detection model with a bounding box similarity algorithm and adaptive parameter adjustment, the method can accurately identify and count parturition segments, including interval threshold calculation, dynamic confidence threshold setting, and determination of valid parturition events.
It significantly improves the accuracy and counting ability of childbirth identification, reduces the false detection rate, enhances the intelligence level and management efficiency of the system, and can maintain high identification accuracy and reliability in complex environments.
Smart Images

Figure CN121767903A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology and relates to an automatic counting method and system for animal births. Specifically, it relates to an automatic counting method and system for animal births based on adaptive interval frames and confidence threshold adjustment, which is mainly applied to high-yielding mammals. Background Technology
[0002] With the continuous development of modern science and technology, my country's livestock industry is gradually moving towards large-scale and automated production. In the breeding of high-yield mammals such as pigs, rats, rabbits, and weasels, animal farrowing plays a vital role in the development of the livestock industry.
[0003] High-producing mammals' reproductive performance directly impacts the overall efficiency and economic benefits of production systems. However, with the expansion of high-producing mammal production scale and the shortening of reproductive cycles, the monitoring and management of their parturition process faces significant challenges. Traditional methods for monitoring parturition in high-producing mammals rely on manual observation, with farmers judging the timing of parturition based on experience. This method suffers from high labor intensity, strong subjectivity, and low monitoring efficiency. Especially in large-scale farms, manual observation is insufficient to meet real-time monitoring needs, leading to the failure to detect abnormalities during parturition in a timely manner, increasing piglet mortality, and impacting the farm's economic benefits.
[0004] Existing manual observation methods suffer from drawbacks such as the inability to record data in real time and the inability to accurately assess the birthing process, leading to the loss or distortion of a large amount of crucial data and hindering the provision of reliable data for subsequent breeding and husbandry management. Reliance on rudimentary manual recording makes data tracking difficult and prone to human error, further impacting the accuracy of management and decision-making. Furthermore, the timing of human intervention is difficult to determine; intervention that is too early or too late can negatively affect the health of high-producing mammals and their offspring. Traditional methods have failed to effectively address these issues, necessitating a more efficient, precise, and intelligent monitoring method to replace manual observation.
[0005] In recent years, some automated labor monitoring methods based on computer vision and deep learning have emerged, attempting to use image recognition technology to automatically identify labor behaviors. However, existing technologies mostly focus on the identification and early warning of labor behaviors, while lacking the ability to accurately count the number of labor events. Especially in situations with complex inter-frame changes and numerous environmental interference factors, the systems often rely on statically set frame intervals and confidence thresholds, lacking adaptive adjustment mechanisms. This leads to decreased recognition accuracy, frequent false positives and false negatives, and fails to meet the intelligent and precise management needs for the number of labor events in modern aquaculture.
[0006] Therefore, there is an urgent need for a new technical solution that can integrate image recognition capabilities, adaptive parameter adjustment mechanisms, and labor behavior counting logic to improve the accuracy and counting ability of the labor identification system in judging key periods, reduce reliance on human experience, and realize a truly efficient, intelligent, and traceable labor monitoring system. Summary of the Invention
[0007] To address the issues of low efficiency, insufficient accuracy, and manual intervention in traditional methods for monitoring parturition in high-yielding mammals, this invention provides an automatic animal parturition counting method and system based on adaptive interval frames and confidence threshold adjustment.
[0008] The technical solution adopted by the present invention is: an automatic animal parturition counting method based on image recognition and threshold adjustment, comprising the following steps: Step 1: Real-time acquisition of delivery segment video, use object detection model combined with bounding box similarity algorithm to obtain video detection results; use preset interval values to perform preliminary segmentation of the detection frame sequence, and calculate the interval threshold based on the interval between candidate segments; Step 2: Using the extracted interval threshold, identify abnormally short interval segments and merge them into adjacent segments to generate a set of valid delivery segments corresponding to a single actual delivery event. Step 3: Calculate the dynamic confidence threshold based on the local sliding window average and the preset minimum confidence, and set the continuous frame requirements according to the confidence level classification; Step 4: Combining the results of the birthing segment division, the confidence dynamic threshold, and the continuous frame requirement, the validity of each candidate birthing segment is judged, and the number of valid births is counted to calculate the total number of offspring.
[0009] Preferably, in step 1, the bounding box similarity algorithm, denoted as box1 = (x1, y1, x2, y2) and box2 = (x3, y3, x4, y4), is defined as follows:
[0010] ; In the formula, This represents the Euclidean distance between the center points of box1 and box2, i.e., the distance between the center points of the two boxes. and This represents the x and y coordinates of the center point of box1. and Indicate the x and y coordinates of the center point of box2; and These represent the width and height of box1, respectively. and These represent the width and height of box2, respectively. This indicates the difference in width and height between box1 and box2.
[0011] Preferably, in step 1, the interval threshold is calculated using a progressive dual-threshold dynamic segmentation algorithm; ; ; In the formula, The basic threshold for dividing the initial fixed frame interval. For the first frame difference set The short-interval dynamic threshold is calculated from percentiles, where The difference in the number of frames between adjacent segments. This indicates the first frame number of the (i+1)th segment. Let m be the last frame number of the i-th segment, and m be the number of segments obtained from the initial segmentation.
[0012] Preferably, in step 1, all image frames that detect childbirth behavior and their corresponding bounding box confidence information are extracted, and similar detection boxes are removed by combining the bounding box similarity algorithm to construct a list of childbirth detection frames arranged in time series; the childbirth frames are divided into basic segments by setting frame intervals; the time interval between each candidate childbirth segment is counted, and the interval threshold is calculated using the percentile method.
[0013] Preferably, in step 2, the frame interval between adjacent candidate segments is calculated, and this interval is compared with the interval threshold calculated in step 1. If the interval is less than the threshold, it means that the time between the two segments is too short to be regarded as two independent delivery events. Accordingly, the two segments are merged and regarded as continuous detection frames of the same delivery. Finally, the set of delivery segments after inter-segment merging optimization is output.
[0014] Preferably, in step 3, the confidence dynamic threshold is calculated using the sliding window local density method and is defined as follows: ; ; Where N represents the number of windows that satisfy the constraints. To adjust the sliding window size, Let be the confidence level of childbirth in the i-th frame. This is the set of window indices that satisfy the condition that the window mean is greater than or equal to a preset value.
[0015] Preferably, in step 3, the sliding window local density method is used to analyze the confidence of the detection frames in each candidate delivery segment. The confidence sequence is calculated by moving average with a window size of M to extract the effective windows that meet the set minimum confidence standard. The mean of all effective windows is averaged as the adaptive confidence threshold of the current delivery segment. Subsequently, according to the interval in which the confidence threshold is located, gradient-triggered continuous frame verification is used to determine the corresponding number of continuous frames required. Here, M is a preset value.
[0016] Preferably, in step 4, the confidence sequence of all detected frames within the birthing segment is first extracted to determine whether it meets the requirements of the adaptive confidence threshold. Furthermore, it is counted whether there are high-confidence frame segments in the segment that meet the consecutive frame count requirement. Only when a birthing segment meets both the confidence threshold and the consecutive frame count threshold is it determined to be a valid birthing event. The system records the segment as a valid birth and includes it in the statistics accordingly. Finally, the total number of offspring born in this birthing process is calculated by accumulating the number of all valid birthing segments.
[0017] Preferably, in step 1, the target detection model consists of a feature extraction network, a morphological awareness feature encoding layer, a spatiotemporally consistent feature coupling layer, and a perception discrimination mapping layer. The feature extraction network is the network obtained by removing the average pooling layer and the fully connected layer from ResNet18; The morphology-aware feature encoding layer takes the convolutional feature map obtained by the feature extraction network, processes it through the first morphology discrimination feature enhancement module and F3.3N128 to obtain a local morphological detail feature map; the local morphological detail feature map is then processed by the second morphology discrimination feature enhancement module and F3.3N256 to obtain a regional morphological structure feature map; the regional morphological structure feature map is then processed by the third morphology discrimination feature enhancement module and F3.3N512 to obtain a global morphological semantic feature map; wherein, the first, second, and third morphology discrimination feature enhancement modules all first perform downsampling through F3.3S2P1, then process it through F1.3N128 and F3.1N128 respectively, and then perform pixel-by-pixel addition, followed by batch normalization and SiLU activation function processing, and finally concatenate the output after passing through three groups of ResNet with different group numbers that are converted to group convolutions; The spatiotemporal consistent feature coupling layer, after being processed by the morphology-aware feature encoding layer, yields a local morphological detail feature map, a regional morphological structure feature map, and a global morphological semantic feature map. The global morphological semantic feature map is upsampled and concatenated with the regional morphological structure feature map, then processed by F3.3N512 to obtain a mid-level feature map. This mid-level feature map is upsampled and concatenated with the local morphological detail feature map, then processed by F3.3N256 to output a fine-grained event-aware feature map. The fine-grained event-aware feature map is downsampled and concatenated with the mid-level feature map, then processed by F3.3N512 to obtain a structured event context feature map. Finally, the structured event context feature map is downsampled and concatenated with the global morphological semantic feature map, then processed by F3.3N512 to output a global event discrimination feature map. The perception and discrimination mapping layer, through the spatiotemporal consistent feature coupling layer, obtains a fine event perception feature map, a structured event context feature map, and a global event discrimination feature map, which are then output by two sets of convolutional layers to produce detection coordinates and detection categories.
[0018] The technical solution adopted by the system of the present invention is: an automatic animal parturition counting system based on image recognition and threshold adjustment, comprising: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the automatic animal parturition counting method based on image recognition and threshold adjustment.
[0019] Compared with existing methods for monitoring sow farrowing, this invention has the following advantages and positive technical effects: (1) The present invention adopts an original target detection model to realize real-time automated monitoring of the animal parturition process, which significantly reduces the need for manual intervention and improves the efficiency of farrowing room management; (2) The present invention automatically generates the interval frame threshold and confidence threshold through adaptive calculation, without the need for manual parameter setting, which overcomes the problem of relying on experience to adjust the threshold in the traditional method, simplifies the usage process, and significantly improves the practicality and intelligence level of the system. (3) The invention adopts an original target detection model, which significantly improves the detection accuracy and can effectively distinguish real childbirth behavior from other similar behaviors, reducing false alarms; (4) The invention adopts an original target detection model, which significantly reduces the rate of missed delivery and can capture actual delivery events more comprehensively and stably. (5) The invention has significantly improved overall performance and can still maintain high recognition accuracy and reliability in complex aquaculture environments. Attached Figure Description
[0020] The technical solutions described herein are further illustrated below using examples and specific implementation methods. Additionally, accompanying drawings are used in the description of the technical solutions. Those skilled in the art can, without any creative effort, obtain other drawings and the intent of the present invention based on these drawings.
[0021] Figure 1 : Flowchart of the method according to an embodiment of the present invention; Figure 2 The morphological feature encoding layer of the target detection model in this embodiment of the invention; Figure 3 The spatiotemporally consistent feature coupling layer of the target detection model in this embodiment of the invention; Figure 4 : A schematic diagram of bounding box similarity discrimination according to an embodiment of the present invention; Figure 5 : A schematic diagram illustrating the calculation of the interval frame number threshold in an embodiment of the present invention; Figure 6 : A schematic diagram illustrating the calculation of the confidence threshold in an embodiment of the present invention; Figure 7 : Schematic diagram of valid delivery event determination in an embodiment of the present invention. Detailed Implementation
[0022] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings, but this does not limit the scope of protection of the present invention. Those skilled in the art can make various modifications or substitutions without departing from the principles and spirit of the present invention, and all such modifications or substitutions should fall within the scope of protection of the present invention.
[0023] This embodiment further describes the solution of the present invention by using automatic counting of sow farrowings.
[0024] Please see Figure 1 This embodiment provides an automatic counting method for sow farrowing based on adaptive interval frames and confidence threshold adjustment, including the following steps: Step 1: Preliminary segmentation of delivery segments and calculation of interval threshold. A target detection model combined with a bounding box similarity algorithm is used to obtain video detection results. A preset, relatively small interval value is used to initially segment the detection frame sequence, and an interval threshold is calculated based on the interval between candidate segments for subsequent determination of whether merging is necessary.
[0025] In one embodiment, the target detection model comprises a feature extraction network, a morphological awareness feature encoding layer, a spatiotemporally consistent feature coupling layer, and a perception discrimination mapping layer; In one implementation, the feature extraction network is a ResNet18 network obtained by removing the average pooling layer and the fully connected layer.
[0026] In one implementation, please see Figure 2 The morphology-aware feature encoding layer processes the convolutional feature map obtained from the feature extraction network through the morphology-discrimination feature enhancement module one and F3.3N128 to obtain a local morphological detail feature map; through the morphology-discrimination feature enhancement module two and F3.3N256 to obtain a regional morphological structure feature map; and through the morphology-discrimination feature enhancement module three and F3.3N512 to obtain a global morphological semantic feature map. The morphology-discrimination feature enhancement module first performs downsampling using F3.3S2P1, then processes it through F1.3N128 and F3.1N128 respectively, followed by pixel-by-pixel addition. It then sequentially undergoes batch normalization and SiLU activation function processing, and is processed through three groups of ResNet convolutions with different group numbers (replaced with group convolutions). The output is obtained by concatenating the blocks; where F3·3N128 represents a convolutional layer with a kernel of 3×3 and 128 output channels; F3·3N512 represents a convolutional layer with a kernel of 3×3 and 512 output channels; F3·3S2P1 represents a pooling layer with a kernel of 3×3, a stride of 2, and padding of 1; F1·3N128 represents a convolutional layer with a kernel of 1×3 and 128 output channels; and F3·1N128 represents a convolutional layer with a kernel of 3×1 and 128 output channels.
[0027] In one implementation, please see Figure 3 The spatiotemporal consistent feature coupling layer, after processing by the morphology-aware feature encoding layer, yields local morphological detail feature maps, regional morphological structure feature maps, and global morphological semantic feature maps. The global morphological semantic feature map is upsampled and concatenated with the regional morphological structure feature map, then processed by F3.3N512 to obtain a mid-level feature map. After upsampling and concatenation with the local morphological detail feature map, it is processed by F3.3N256 to output a fine-grained event-aware feature map. The fine-grained event-aware feature map is downsampled and concatenated with the mid-level feature map, then processed by F3.3N512 to obtain a structured event context feature map. The structured event context feature map is downsampled and concatenated with the global morphological semantic feature map, then processed by F3.3N512 to output a global event discrimination feature map. Here, F3.3N512 represents a convolutional layer with a 3×3 kernel and 512 output channels; F3.3N256 represents a convolutional layer with a 3×3 kernel and 216 output channels.
[0028] In one implementation, the perception and discrimination mapping layer obtains the fine event perception feature map, structured event context feature map, and global event discrimination feature map through the spatiotemporal consistent feature coupling layer, and then outputs the detection coordinates and detection category through two sets of convolutional layers.
[0029] In one implementation, please see Figure 4 Based on the trained YOLOv8 object detection model, frame-by-frame detection was performed on sow farrowing monitoring videos. All image frames that detected farrowing behavior and their corresponding bounding box confidence information were extracted. Similar detection boxes were removed using a bounding box similarity algorithm to construct a list of farrowing detection frames arranged in time series. The farrowing frames were divided into basic segments by setting a reasonable and small frame interval. The time interval between each candidate farrowing segment was calculated, and the interval threshold was calculated using the percentile method. In one implementation, the bounding box similarity algorithm, denoted as box1 = (x1, y1, x2, y2) and box2 = (x3, y3, x4, y4), is defined as follows:
[0030] ; In the formula, This represents the Euclidean distance between the center points of box1 and box2, i.e., the distance between the center points of the two boxes. and This represents the x and y coordinates of the center point of box1. and Indicate the x and y coordinates of the center point of box2; and These represent the width and height of box1, respectively. and These represent the width and height of box2, respectively. This indicates the difference in width and height between box1 and box2.
[0031] In one implementation, the interval threshold is calculated using a progressive dual-threshold dynamic segmentation algorithm; ; ; In the formula, The basic threshold for dividing the initial fixed frame interval. For the first frame difference set The short-interval dynamic threshold is calculated from percentiles, where The difference in the number of frames between adjacent segments. This indicates the first frame number of the (i+1)th segment. Let m be the last frame number of the i-th segment, and m be the number of segments obtained from the initial segmentation.
[0032] Step 2: Labor Segment Correction and Division. Using the extracted interval thresholds, abnormally short interval segments are identified and merged into adjacent segments to generate a set of valid frame segments corresponding to a single actual labor event.
[0033] In one implementation, please see Figure 5 Calculate the frame interval between adjacent candidate segments and compare it with the global interval threshold calculated in step 1. If the interval is less than the threshold, it means that the time between the two segments is too short to be regarded as two independent labor events. Based on this, the two segments are merged and regarded as continuous detection frames of the same labor. Finally, the set of labor segments after inter-segment merging optimization is output. Step 3: Adaptive calculation of confidence threshold and consecutive frame count. Based on the local sliding window average and the preset minimum confidence, calculate the dynamic confidence threshold, and set the consecutive frame requirement according to the confidence level classification.
[0034] In one implementation, please see Figure 6 The system employs a sliding window local density method to analyze the confidence of detection frames in each candidate delivery segment. A moving average is calculated on the confidence sequence with a window size of 5 to extract valid windows that meet the set minimum confidence standard. The average of all valid windows is then used as the adaptive confidence threshold for the current delivery segment, with the final result rounded to two decimal places to ensure stability. Subsequently, based on the interval of the confidence threshold, the system uses gradient-triggered continuous frame verification to determine the corresponding number of consecutive frames. When the confidence threshold is greater than or equal to 0.9, the consecutive frame requirement is 1 frame; 0.8 to 0.9 requires 3 frames; 0.7 to 0.8 requires 5 frames; and below 0.7, the default setting is 999 frames.
[0035] In one implementation, the confidence dynamic threshold is calculated using the sliding window local density method and is defined as: ; ; Where N represents the number of windows that satisfy the constraints. To adjust the sliding window size, Let be the confidence level of childbirth in the i-th frame. This is the set of window indices that satisfy the condition that the window mean is ≥ 0.5.
[0036] Step 4: Valid Farrowing Identification and Piglet Count. Based on the farrowing segment division results, confidence threshold, and continuous frame requirements, the validity of each candidate farrowing segment is assessed, and the number of valid farrowings is counted to estimate the total number of piglets.
[0037] In one implementation, please see Figure 7First, the confidence sequence of all detected frames within the farrowing segment is extracted to determine whether it meets the requirements of the adaptive confidence threshold. Then, it is further counted whether there are high-confidence frame segments in the segment that meet the consecutive frame count requirement. Only when a farrowing segment meets both the confidence threshold and the consecutive frame count threshold is it determined to be a valid farrowing event. The system records the segment as a valid farrowing and includes it in the statistics. Finally, the total number of piglets born in the sow's farrowing process is calculated by accumulating the number of all valid farrowing segments, thus realizing the intelligent identification and automatic statistics function of the number of farrowings.
[0038] Compared with existing technologies, this invention achieves high-precision automatic identification of female animal parturition behavior through an original target detection network. Performance comparisons of different model versions (YOLOv8m) under the same test dataset and environmental conditions demonstrate that the target detection network used in this invention significantly outperforms the comparative models in terms of detection accuracy, recall, and overall recognition capability.
[0039] Specifically, the target detection network used in this invention detected 456 childbirth events, including 374 accurate detections (TP), 84 false positives (FP), and 41 false negatives (FN). Compared to the YOLOv8m model (TP = 321, FP = 183, FN = 94), the precision improved from 0.64 to 0.82, and the recall improved from 0.77 to 0.90. Therefore, the target detection network used in this invention significantly reduces the incidence of false positives and false negatives while maintaining high sensitivity.
[0040] In summary, the technical solution of this invention achieves high-precision, low-false-detection, and low-miss-detection automatic identification of female animal parturition behavior, providing more accurate and real-time data support for intelligent breeding systems, effectively improving the automation and intelligence level of parturition management, and has significant value for promotion and application.
[0041] It should be understood that the embodiments described above are only some, not all, of the embodiments of the present invention. Furthermore, the technical features of the various embodiments or individual embodiments provided by the present invention can be arbitrarily combined to form feasible technical solutions. Such combinations are not constrained by the order of steps and / or structural composition patterns, but must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0042] It should be understood that the above description of the preferred embodiments is quite detailed, but it should not be considered as a limitation on the scope of protection of this invention. Those skilled in the art, under the guidance of this invention, can make substitutions or modifications without departing from the scope of protection of the claims of this invention, and all such substitutions or modifications fall within the scope of protection of this invention. The scope of protection of this invention should be determined by the appended claims.
Claims
1. An automatic counting method of animal delivery based on image recognition and threshold adjustment, characterized in that, The method comprises the following steps: Step 1: Real-time acquisition of delivery stage video, use of a target detection model combined with a bounding box similarity algorithm to obtain video detection results; preliminary segmentation of the detection frame sequence using a preset interval value, and calculation of an interval threshold value based on the interval between candidate segments; Step 2: Use of the extracted interval threshold value to identify an abnormally short interval segment, and merging of the same into adjacent segments to generate an effective delivery segment set corresponding to an actual delivery event; Step 3: Calculation of a confidence dynamic threshold value based on local sliding window averaging and a preset minimum confidence level, and determination of a continuous frame requirement according to the confidence level classification; Step 4: Combination of the delivery segment division results, the confidence dynamic threshold value and the continuous frame requirement to determine the effectiveness of each candidate delivery segment, and counting of the number of effective deliveries to calculate the total number of pups.
2. The method of claim 1, wherein: In step 1, the bounding box similarity algorithm is denoted as box1 = (x1, y1, x2, y2) and box2 = (x3, y3, x4, y4), and is defined as: ; wherein, represents the Euclidean distance between the two center points of box1 and box2, i.e. the distance between the center points of the two boxes, and represents the horizontal and vertical coordinates of the center point of box1, and represents the horizontal and vertical coordinates of the center point of box2; and respectively represent the width and height of box1, and respectively represent the width and height of box2, represents the difference in width and height scale between box1 and box2.
3. The method of claim 1, wherein: In step 1, the interval threshold value is calculated using a progressive double-threshold dynamic segmentation algorithm. ; ; wherein, is a base threshold for initial fixed frame interval division, is a short interval dynamic threshold calculated by the first percentile of the inter-frame difference set, wherein is the frame number difference between adjacent segments, denotes the first frame number of the i+1th segment, is the last frame number of the ith segment, and m is the number of segments obtained by preliminary segmentation.
4. The method for automatic counting of animal deliveries based on image recognition and threshold adjustment according to claim 1, characterized in that: In step 1, all image frames in which a delivery behavior is detected and the corresponding bounding box confidence information are extracted, similar detection boxes are removed using the bounding box similarity algorithm, and a delivery detection frame list arranged in time sequence is constructed; the delivery frames are preliminarily divided by setting the frame number interval; the time interval between each candidate delivery segment is counted, and the interval threshold value is calculated using the percentile method.
5. The method for automatic counting of animal deliveries based on image recognition and threshold adjustment according to claim 1, characterized in that: In step 2, the frame number interval between adjacent candidate segments is calculated, and the interval is compared with the interval threshold value calculated in step 1; if the interval is less than the threshold value, it indicates that the time between the two segments is too short to be considered as two independent delivery events, and the two segments are merged to be considered as continuous detection frames of the same delivery; finally, the delivery segment set after the segment merging optimization is output.
6. The method for automatic counting of animal deliveries based on image recognition and threshold adjustment according to claim 1, characterized in that: In step 3, the confidence dynamic threshold value is calculated using a sliding window local density method, and is defined as: ; ; wherein N represents the number of windows satisfying the constraint condition, is the sliding window size, is the delivery confidence of the i-th frame, is the set of window indexes satisfying the window mean ≥ preset value.
7. The method for automatic counting of animal deliveries based on image recognition and threshold adjustment according to claim 1, characterized in that: In step 3, the detection frame confidence in each candidate delivery segment is analyzed using a sliding window local density method; the confidence sequence is calculated using a sliding average with a window size of M; the effective window that meets the set minimum confidence standard is extracted; the average of the mean values of all effective windows is taken as the adaptive confidence threshold value of the current delivery segment; then, according to the interval in which the confidence threshold value is located, the gradient trigger type continuous frame verification is used to determine the corresponding continuous frame number requirement; wherein M is a preset value.
8. The method for automatic counting of animal deliveries based on image recognition and threshold adjustment according to claim 1, characterized in that: In step 4, the confidence sequence of all detection frames in the delivery segment is first extracted, and it is determined whether the confidence sequence meets the requirements of the adaptive confidence threshold value; further, it is determined whether there is a confidence high frame segment that meets the continuous frame number requirement in the segment; only when a delivery segment meets both the confidence threshold value and the continuous frame number threshold value, is the delivery segment determined to be an effective delivery event, and the system records the segment as an effective delivery and includes it in the statistics; finally, the total number of pups born in the delivery process of the animal is calculated by counting the cumulative number of all effective delivery segments.
9. The method of claim 1-8, wherein: In step 1, the target detection model is composed of a feature extraction network, a morphology perception feature encoding layer, a spatio-temporal consistent feature coupling layer, and a perception discriminant mapping layer; The feature extraction network is a network obtained by removing the average pooling layer and the fully connected layer from the resnet18; The morphology perception feature encoding layer processes the convolution feature map obtained by the feature extraction network through a first morphology discriminant feature enhancement module and F3·3N128 to obtain a local morphology detail feature map; the local morphology detail feature map is processed through a second morphology discriminant feature enhancement module and F3·3N256 to obtain a regional morphology structure feature map; the regional morphology structure feature map is processed through a third morphology discriminant feature enhancement module and F3·3N512 to obtain a global morphology semantic feature map; wherein the first, second, and third morphology discriminant feature enhancement modules are all down-sampled through F3·3S2P1, processed through F1·3N128 and F3·1N128 respectively, and then pixel-by-pixel added, sequentially processed through batch normalization and SiLU activation function, and finally concatenated after being processed through three groups of ResNet group convolution Bottleneck Block to obtain the output; The spatio-temporal consistent feature coupling layer processes the local morphology detail feature map, the regional morphology structure feature map, and the global morphology semantic feature map obtained by the morphology perception feature encoding layer, wherein the global morphology semantic feature map is up-sampled and concatenated with the regional morphology structure feature map, then processed through F3·3N512 to obtain a middle layer feature map, which is up-sampled and concatenated with the local morphology detail feature map, then processed through F3·3N256 to output a fine event perception feature map; the fine event perception feature map is down-sampled and concatenated with the middle layer feature map, then processed through F3·3N512 to obtain a structured event context feature map; the structured event context feature map is down-sampled and concatenated with the global morphology semantic feature map, then processed through F3·3N512 to output a global event discriminant feature map; The perception discriminant mapping layer outputs the detection coordinates and the detection category through two groups of convolution layers respectively based on the fine event perception feature map, the structured event context feature map, and the global event discriminant feature map obtained by the spatio-temporal consistent feature coupling layer.
10. An automatic animal farrowing counting system based on image recognition and threshold adjustment, characterized in that, comprise: one or more processors; a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the animal delivery automatic counting method based on image recognition and threshold adjustment according to any one of claims 1 to 9.