Method and device for detecting activity level of a flock of birds
Patent Information
- Application Number
- CN202311540763.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-17
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2043-11-17
AI Technical Summary
[0002]研究表明,在长期的高温环境下,会导致鸡的活动水平降低
Smart Images

Figure CN117765430B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and more specifically, to a method and apparatus for detecting the activity level of chicken flocks. Background Technology
[0002] Studies have shown that prolonged exposure to high temperatures can lead to decreased activity levels in chickens. This decreased activity level disrupts the balance between growth rate and activity level, increasing metabolic and motor sensitivity and ultimately harming the chickens' health. Conversely, excessively high activity levels are also detrimental to growth. Therefore, timely monitoring of chicken activity levels to ensure they remain within appropriate activity levels at all times is crucial for successful chicken farming. Summary of the Invention
[0003] The purpose of this disclosure is to provide a method and apparatus for detecting the activity level of chicken flocks, so as to solve the above-mentioned technical problems.
[0004] To achieve the above objectives, the first aspect of this disclosure provides a method for detecting the activity level of a chicken flock, the method comprising:
[0005] Obtain video footage of the chickens during the time period to be detected;
[0006] The chicken flock video is input into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period.
[0007] The activity level detection model is used to obtain the target instability index through the following operations:
[0008] Determine the position information of each chicken in the target video frame, wherein the target video frame is any one of multiple video frames in the chicken flock video;
[0009] Based on the position information of each chicken in the target video frame, determine the target position information of each chicken in the next video frame;
[0010] Based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame, the instability index corresponding to the target video frame is determined.
[0011] The target instability index is determined based on the instability indices corresponding to the multiple video frames.
[0012] Optionally, determining the position information of each chicken in the target video frame includes:
[0013] The target video frame is subjected to feature extraction at different levels to obtain hierarchical feature maps corresponding to different levels;
[0014] Feature fusion processing is performed on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales;
[0015] Target detection is performed on the scale feature maps at different scales to obtain the position information of each chicken in the target video frame.
[0016] Optionally, the step of extracting features from the target video frame at different levels to obtain hierarchical feature maps corresponding to different levels includes:
[0017] The target video frame is subjected to binary feature extraction processing to obtain a first binary feature map;
[0018] Hierarchical feature extraction is performed on the first binary feature map to obtain the first-level feature map;
[0019] Hierarchical feature extraction is performed on the first-level feature map to obtain the second-level feature map;
[0020] Hierarchical feature extraction is performed on the second-level feature map to obtain the third-level feature map;
[0021] The first-level feature map, the second-level feature map, and the third-level feature map are determined as the level feature maps corresponding to the different levels.
[0022] Optionally, the step of performing hierarchical feature extraction on the first binary feature map to obtain a first-level feature map includes:
[0023] The first binary feature map is subjected to feature dimensionality reduction processing to obtain the second binary feature map;
[0024] The second binary feature map is subjected to binary feature extraction processing to obtain the third binary feature map;
[0025] The main features of the third binary feature map are extracted to obtain the main feature map, and the secondary features of the third binary feature map are extracted to obtain the secondary feature map.
[0026] The third binary feature map, the main feature map, and the secondary feature map are subjected to feature fusion processing to obtain the first-level feature map.
[0027] Optionally, the step of performing feature fusion processing on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales includes:
[0028] The third-level feature map is subjected to binary feature extraction and feature fusion processing to obtain the fourth binary feature map;
[0029] The fourth binary feature map and the second-level feature map are subjected to feature fusion processing to obtain a second fused feature map. The second fused feature map and the first-level feature map are subjected to feature fusion processing to obtain a third fused feature map. The third fused feature map is subjected to scale feature extraction to obtain a first scale feature map.
[0030] The third fused feature map is subjected to binary feature extraction processing to obtain a fifth binary feature map, and the fifth binary feature map and the second fused feature map are subjected to feature fusion processing to obtain a fourth fused feature map, and the fourth fused feature map is subjected to scale feature extraction to obtain a second scale feature map;
[0031] The fourth fused feature map is subjected to binary feature extraction processing to obtain the sixth binary feature map, and the sixth binary feature map and the fourth binary feature map are subjected to feature fusion processing to obtain the fifth fused feature map. The fifth fused feature map is subjected to scale feature extraction to obtain the third scale feature map.
[0032] The first scale feature map, the second scale feature map, and the third scale feature map are determined as scale feature maps of different scales.
[0033] Optionally, the step of performing binary feature extraction and feature fusion processing on the third-level feature map to obtain a fourth binary feature map includes:
[0034] The third-level feature map is subjected to binary feature extraction processing to obtain the first binary feature sub-map;
[0035] The first binary feature sub-image is pooled based on different pooling window sizes to obtain multiple different second binary feature sub-images.
[0036] The first binary feature sub-map and the plurality of different second binary feature sub-maps are subjected to feature fusion processing to obtain a third binary sub-map;
[0037] The third binary sub-graph is subjected to binary feature extraction processing to obtain the fourth binary feature sub-graph, and the fourth binary feature sub-graph and the first binary feature sub-graph are subjected to feature fusion processing to obtain the fifth binary feature sub-graph.
[0038] The fifth binary feature sub-map is subjected to binary feature extraction processing to obtain the fourth binary feature map.
[0039] Optionally, the step of performing target detection on the scale feature maps at different scales to obtain the position information of each chicken in the target video frame includes:
[0040] Intrinsic features are extracted from the first scale feature map to obtain the first intrinsic feature map;
[0041] Intrinsic feature extraction is performed on the second-scale feature map to obtain the second intrinsic feature map;
[0042] Intrinsic feature extraction is performed on the third-scale feature map to obtain the third intrinsic feature map;
[0043] Target detection is performed on the first intrinsic feature map, the second intrinsic feature map, and the third intrinsic feature map to obtain the position information of each chicken in the target video frame;
[0044] The step of extracting features from the first scale feature map to obtain the first intrinsic feature map includes:
[0045] The first intrinsic feature sub-map is obtained by performing feature extraction and feature dimensionality reduction on the first-scale feature map.
[0046] The first intrinsic feature sub-graph is subjected to dimensionality upscaling to obtain the second intrinsic feature sub-graph.
[0047] The first intrinsic feature sub-map and the second intrinsic feature sub-map are subjected to feature fusion processing to obtain the first intrinsic feature map.
[0048] Optionally, the location information includes the center coordinates, length, and height of the detection box. The step of determining the target location information of each chicken in the next video frame based on the location information of each chicken in the target video frame includes:
[0049] Determine the center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame;
[0050] For each chicken in the target video frame, perform the following steps:
[0051] Based on the center coordinates, length, and height of the detection box corresponding to the current chicken, predict the center coordinates, length, and height of the detection box corresponding to the current chicken in the next video frame.
[0052] Based on the predicted center coordinates, length, and height of the detection box corresponding to the current chicken, as well as the predicted center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame, the tracking result of the current chicken is determined. The tracking result is used to characterize whether the current chicken is detected in the next video frame.
[0053] When the matching result indicates that the current chicken is detected in the next video frame, the predicted center coordinates, predicted length, and predicted height of the detection box corresponding to the current chicken are determined as the target position information of the current chicken.
[0054] Optionally, determining the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame includes:
[0055] Based on the target position information of each chicken in the target video frame and the target position information of each chicken in the next video frame, determine the displacement of each chicken in the target video frame.
[0056] The instability index corresponding to the target video frame is determined based on the displacement of each chicken in the target video frame and a preset scaling factor.
[0057] A second aspect of this disclosure provides a device for detecting the activity level of a flock of chickens, the device comprising:
[0058] The acquisition module is used to acquire videos of chickens during the time period to be detected.
[0059] The first determining module is used to input the chicken flock video into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period.
[0060] The activity level detection model includes:
[0061] The second determining module is used to determine the position information of each chicken in the target video frame, wherein the target video frame is any one of the multiple video frames in the chicken flock video;
[0062] The third determining module is used to determine the target position information of each chicken in the next video frame based on the position information of each chicken in the target video frame.
[0063] The fourth determining module is used to determine the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame.
[0064] The fifth determining module is used to determine the target instability index based on the instability indices corresponding to the plurality of video frames.
[0065] The above technical solution allows inputting chicken flock videos of the target time period into an activity level detection model to obtain a target instability index characterizing the activity level of the chicken flock during that period. This enables the detection of chicken flock activity levels by acquiring chicken flock videos. Furthermore, when obtaining the target instability index from chicken flock videos, the activity level detection model first determines the positional information of each chicken in each video frame, then determines the accurate displacement of each chicken in adjacent video frames based on its positional information, and finally calculates the flock's instability index based on the accurate displacement of each chicken. Therefore, compared to related technologies that only calculate the distance between the closest chickens in adjacent frames to obtain the flock's instability index, the technical solution disclosed here can improve the accuracy of the flock's instability index calculation, thereby better detecting the activity level of the chicken flock.
[0066] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0067] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0068] Figure 1 This is a flowchart illustrating a method for detecting the activity level of a flock of chickens according to an exemplary embodiment of the present disclosure;
[0069] Figure 2 This is a schematic diagram illustrating the structure of an improved YOLOv7 network according to an exemplary embodiment of the present disclosure;
[0070] Figure 3 This is a schematic diagram of the structure of an ELAN-SA module according to an exemplary embodiment of the present disclosure;
[0071] Figure 4 This is a schematic diagram of the structure of a CBS module according to an exemplary embodiment of the present disclosure;
[0072] Figure 5 This is a schematic diagram of the structure of an SPPC module according to an exemplary embodiment of the present disclosure;
[0073] Figure 6 This is a schematic diagram of the structure of an SSGConv module according to an exemplary embodiment of the present disclosure;
[0074] Figure 7 This is a flowchart illustrating an optimized StrongSort algorithm according to an exemplary embodiment of the present disclosure;
[0075] Figure 8 This is a flowchart illustrating a Kalman filter according to an exemplary embodiment of the present disclosure;
[0076] Figure 9 This is a graph illustrating the calculation of the instability index proportionality coefficient according to an exemplary embodiment of this disclosure;
[0077] Figure 10 This is a schematic diagram illustrating an improved YOLOv7 detection result according to an exemplary embodiment of the present disclosure;
[0078] Figure 11 This is a schematic diagram illustrating the detection results of different trackers according to an exemplary embodiment of the present disclosure;
[0079] Figure 12 This is a schematic diagram illustrating the instability index of a chicken flock video with different disturbances, according to an exemplary embodiment of this disclosure;
[0080] Figure 13 This is a block diagram illustrating a flock activity level detection method according to an exemplary embodiment of the present disclosure;
[0081] Figure 14 This is a block diagram illustrating an electronic device according to an exemplary embodiment;
[0082] Figure 15 This is a block diagram illustrating another electronic device according to an exemplary embodiment. Detailed Implementation
[0083] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0084] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0085] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0086] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0087] As mentioned in the background section, prolonged exposure to high temperatures can lead to a decrease in the activity level of chickens. This decrease in activity level causes an imbalance between growth rate and activity level, resulting in increased metabolic and motor sensitivity, which in turn harms the chickens' health. Conversely, excessively high activity levels are also detrimental to chicken growth. Therefore, timely monitoring of chicken activity levels to ensure that chickens remain within an appropriate activity range at all times is crucial for successful chicken farming.
[0088] Currently, a large number of studies have focused on detecting activity levels in chickens.
[0089] For example, a related technique proposes an image analysis method based on the area occupied by the animal and the number of image pixels. This method formats the image into a binary image and calculates the activity level index by measuring the proportion of moving pixels to all pixels in the image. However, traditional thresholding segmentation methods are highly dependent on lighting and background conditions, resulting in a high error rate when segmenting chickens.
[0090] For example, related technologies have proposed using optical flow to assess flock behavior, gait, and welfare. However, this method only captures changes in pixel brightness between frames, making it insufficiently sensitive and unable to detect subtle changes in bird movement.
[0091] For example, related technologies also propose cropping the image through a series of preprocessing steps to remove difficult-to-segment regions and converting the image to grayscale, using Gaussian filtering to reduce the impact of noise. Furthermore, the center position of each chicken is obtained through segmentation, and the distance between the nearest chickens in adjacent frames is calculated to obtain the flock's instability index, which reflects the chickens' activity level.
[0092] The inventors discovered in their research that although this method is more accurate in calculating activity levels than the previous two methods, it uses the movement distance of the closest chickens between adjacent frames to calculate the instability index, which has a large error.
[0093] In view of the above, this disclosure provides a method and apparatus for detecting the activity level of chicken flocks to overcome the aforementioned technical problems.
[0094] The embodiments of this disclosure will be further explained below with reference to the accompanying drawings.
[0095] Figure 1 This is a flowchart illustrating a method for detecting the activity level of a chicken flock according to an exemplary embodiment of this disclosure, with reference to... Figure 1 The method may include the following steps:
[0096] S101: Obtain video of chickens during the period to be detected.
[0097] The detection period and detection duration can be set according to the actual situation, and this embodiment does not impose any restrictions on them.
[0098] S102: Input the chicken flock video into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period;
[0099] The activity level detection model is used to obtain the target instability index through the following operations:
[0100] The location information of each chicken in the target video frame is determined, wherein the target video frame is any one of multiple video frames in the chicken flock video; based on the location information of each chicken in the target video frame, the target location information of each chicken in the next video frame is determined; based on the location information of each chicken in the target video frame and the target location information of each chicken in the next video frame, the instability index corresponding to the target video frame is determined; based on the instability indices corresponding to the multiple video frames, the target instability index is determined.
[0101] The above technical solution allows inputting chicken flock videos of the target time period into an activity level detection model to obtain a target instability index characterizing the activity level of the chicken flock during that period. This enables the detection of chicken flock activity levels by acquiring chicken flock videos. Furthermore, when obtaining the target instability index from chicken flock videos, the activity level detection model first determines the positional information of each chicken in each video frame, then determines the accurate displacement of each chicken in adjacent video frames based on its positional information, and finally calculates the flock's instability index based on the accurate displacement of each chicken. Therefore, compared to related technologies that only calculate the distance between the closest chickens in adjacent frames to obtain the flock's instability index, the technical solution disclosed here can improve the accuracy of the flock's instability index calculation, thereby better detecting the activity level of the chicken flock.
[0102] To better understand the chicken activity level detection method in this disclosure, the following provides a detailed explanation of the process by which the activity level detection model processes chicken videos.
[0103] In a possible implementation, determining the position information of each chicken in the target video frame may include:
[0104] Feature extraction is performed on the target video frame at different levels to obtain hierarchical feature maps corresponding to different levels; feature fusion processing is performed on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales; target detection is performed on the scale feature maps of different scales to obtain the position information of each chicken in the target video frame.
[0105] It should be understood that different levels of feature extraction can be set according to actual conditions, and this disclosure does not impose any limitations on this. In a possible implementation, in order to accurately determine the location information of each chicken based on the extracted features, low-level features can be extracted for precise localization of the chicken's bounding box, while high-level features can be extracted to identify different chickens. This allows for more accurate acquisition of the location information of each chicken during subsequent target detection.
[0106] It should also be understood that determining the position information of each chicken in the target video frame can be achieved based on object detection models in related technologies, such as You Only Look Once (YOLOv7), RetinaNet, or Mask Region-based Convolutional Neural Network (Mask R-CNN). It can also be achieved based on improved object detection models, and this disclosure does not impose any limitations on this approach. In possible implementations, to improve the detection speed and accuracy of object detection, this embodiment proposes a new lightweight spatially separable and ghost convolution (SSGConv) module and an efficient long-range spatial aggregation network (ELAN-SA) module based on the YOLOv7 network in related technologies, and performs object detection based on the improved YOLOv7 network.
[0107] Specifically, the improved YOLOv7 network is as follows: Figure 2 As shown, it includes an input module, a feature extraction module, a feature fusion module, and an output module.
[0108] The input module is used to input multiple video frames from the chicken flock video into the feature extraction module in the order of the video frames.
[0109] The feature extraction module includes the ELAN-SA module (corresponding to...) Figure 2 (Numbers 3, 5, 7, and 9 in the original text), and the Maxpool module (corresponding to...) Figure 2Numbers 4, 6, and 8 in the original text) and the Cross Stage Binary (CBS, corresponding to Figure 2 (as shown in numbers 1 and 2). The CBS module, as the basic module, adjusts the network, and its structure is as follows: Figure 4 As shown. The Maxpool module is used to divide the input image into several non-overlapping small blocks of the same size, and only takes the largest number in each block, thus maintaining invariance and increasing the receptive field. The structure of the ELAN-SA module is as follows. Figure 3 As shown, the system includes three CBS modules (denoted as CBS1, CBS2, and CBS3), two SSGConv modules (denoted as SSGConv1 and SSGConv2), and one feature fusion module, concat. CBS1, SSGConv1, SSGConv2, concat, and CBS3 are connected sequentially. The input of CBS3 is connected to the input of CBS1, and the output of CBS3 is connected to the input of concat. Because the SSGConv module significantly reduces the number of model parameters, the entire feature extraction module can improve the detection accuracy and speed of chickens with fewer parameters and faster detection speed. Therefore, the feature extraction module can perform feature extraction at different levels on the input target video frame to obtain hierarchical feature maps corresponding to different levels for use in subsequent target detection tasks. Specifically, the step of performing feature extraction at different levels on the target video frame to obtain hierarchical feature maps corresponding to different levels can include:
[0110] The target video frame is processed by binary feature extraction using the CBS module to obtain a first binary feature map. The first binary feature map is then processed by the Maxpool and ELAN-SA modules to obtain a first-level feature map. The first-level feature map is then processed by the Maxpool and ELAN-SA modules to obtain a second-level feature map. The second-level feature map is then processed by the Maxpool and ELAN-SA modules to obtain a third-level feature map. The first-level feature map, the second-level feature map, and the third-level feature map are then identified as the corresponding level-specific feature maps.
[0111] The processes of extracting hierarchical features from the first binary feature map using the Maxpool and ELAN-SA modules, extracting hierarchical features from the first-level feature map, and extracting hierarchical features from the second-level feature map are all the same. Therefore, the following explanation uses the extraction of hierarchical features from the first binary feature map using the Maxpool and ELAN-SA modules as an example to illustrate the processing procedures of the Maxpool and ELAN-SA modules.
[0112] When the first binary feature map is input to the Maxpool module, it first undergoes feature dimensionality reduction processing to obtain the second binary feature map. Then, the second binary feature map is split into two outputs. One output is processed by CBS module 1, SSGConv module 1, and SSGConv module 2 before being transmitted to the concat module. The other output is processed by CBS module 3 before being transmitted to the concat module. Finally, the two outputs are fused by the concat module and transmitted to CBS module 2 for processing to obtain the first-level feature map. That is, the step of performing hierarchical feature extraction on the first binary feature map to obtain the first-level feature map may include:
[0113] The first binary feature map is subjected to feature dimensionality reduction processing to obtain a second binary feature map; the second binary feature map is subjected to binary feature extraction processing to obtain a third binary feature map; the main features of the third binary feature map are extracted to obtain a main feature map, and the secondary features of the third binary feature map are extracted to obtain a secondary feature map; the third binary feature map, the main feature map, and the secondary feature map are subjected to feature fusion processing to obtain the first-level feature map.
[0114] After obtaining the hierarchical feature maps corresponding to different levels, the hierarchical feature maps of different levels can be input into the feature fusion network. The feature fusion network then merges the hierarchical feature maps corresponding to different levels to generate feature maps with multi-scale information, thereby improving the accuracy of target detection.
[0115] according to Figure 2 It can be seen that the feature fusion module mainly includes Spatial Pyramid Pooling (SPPCSPC) and Cross-Stage Partial Channel (SPPCSPC) modules. Figure 2 (Number 10 in the middle), ELAN-SA module (corresponding to) Figure 2 (Items 13, 16, 18, and 20 in the original text), the concat module, and the feature processing module (convolution Conv + upsampling module Unsample, corresponding to...) Figure 2 (Numbers 11 and 15 in the text), CBS module (corresponding to...) Figure 2 (Numbers 12, 14, 17, and 19 in the original text). The SPPC module consists of a Spatial Pyramid Module (SPP) and a Cross-Stage Local Network Module (CSP). The SPP module is used for multi-scale object detection and classification tasks. It adds pooling layers to the network to divide the input feature map into multiple sub-regions and pools each sub-region to obtain a fixed-size feature vector. The CSP module is used to reduce network parameters and computational complexity. Therefore, the feature fusion module can improve the accuracy and efficiency of object detection. Specifically, the feature fusion module performs feature fusion processing on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales, which may include:
[0116] The third-level feature map is processed by the SPPCSPC module to perform binary feature extraction and feature fusion to obtain a fourth binary feature map. The fourth binary feature map and the second-level feature map are then fused using the feature processing module, CBS module, and concat module to obtain a second fused feature map. The second fused feature map and the first-level feature map are then fused using the same module to obtain a third fused feature map. The third fused feature map is then processed by the ELAN-SA module to extract scale features to obtain a first scale feature map. Finally, the third fused feature map is processed by the ELAN-SA module and CBS module to perform binary feature extraction to obtain a fifth binary feature map. The `cat` module performs feature fusion processing on the fifth binary feature map and the second fused feature map to obtain a fourth fused feature map. The `ELAN-SA` module then extracts scale features from the fourth fused feature map to obtain a second scale feature map. The `ELAN-SA` and `CBS` modules perform binary feature extraction processing on the fourth fused feature map to obtain a sixth binary feature map. The `concat` module then performs feature fusion processing on the sixth binary feature map and the fourth binary feature map to obtain a fifth fused feature map. The `ELAN-SA` module then extracts scale features from the fifth fused feature map to obtain a third scale feature map. The first scale feature map, the second scale feature map, and the third scale feature map are then identified as scale feature maps of different scales.
[0117] At the same time, according to Figure 5As shown, the SPPCSPC module includes four CBS modules (denoted as CBS4, CBS5, CBS6, and CBS7), three Maxpool modules (denoted as MP1, MP2, and MP3), and two concat modules (denoted as concat1 and concat2). CBS4, MP2, concat1, CBS5, concat2, and CBS6 are connected sequentially. The input of MP1 is connected to the output of CBS4, and the output of MP1 is connected to the input of concat1. The input of MP3 is connected to the output of CBS4, and the output of MP3 is connected to the input of concat1. The input of CBS7 is connected to the input / output of CBS4, the output of CBS7 is connected to the input of concat2, and the output of CBS4 is connected to the input of concat1. Therefore, by performing binary feature extraction and feature fusion processing on the third-level feature map using the SPPCSPC module, a fourth binary feature map is obtained, which may include:
[0118] The third-level feature map is processed by CBS4 to extract binary features, resulting in a first binary feature sub-map. Based on different pooling window sizes (i.e., different Maxpool modules), the first binary feature sub-map is pooled to obtain multiple different second binary feature sub-maps. The first binary feature sub-map and the multiple different second binary feature sub-maps are then fused using concat1 to obtain a third binary sub-map. The third binary sub-map is then processed by CBS5 to extract binary features, resulting in a fourth binary feature sub-map. The fourth binary feature sub-map and the first binary feature sub-map are then fused using concat2 to obtain a fifth binary feature sub-map. Finally, the fifth binary feature sub-map is processed by CBS7 to extract binary features, resulting in the fourth binary feature map.
[0119] After obtaining scale feature maps of different scales through the feature fusion module, the scale feature maps of different scales can then be input into the output module, so that the output module can perform target detection on the scale feature maps of different scales and obtain the position information of each chicken in the target video frame.
[0120] Specifically, according to Figure 2As shown, the output module includes three SSGConv modules and one detection head IDetect. First, the SSGConv modules convert each scale feature map into an intrinsic feature map for target detection. Then, the detection head IDetect performs target detection on all intrinsic feature maps to obtain the position information of each chicken. That is, the step of performing target detection on the scale feature maps of different scales to obtain the position information of each chicken in the target video frame can include:
[0121] Intrinsic feature extraction is performed on the first scale feature map to obtain a first intrinsic feature map; intrinsic feature extraction is performed on the second scale feature map to obtain a second intrinsic feature map; intrinsic feature extraction is performed on the third scale feature map to obtain a third intrinsic feature map; target detection is performed on the first intrinsic feature map, the second intrinsic feature map, and the third intrinsic feature map to obtain the position information of each chicken in the target video frame.
[0122] Among them, the SSGConv module is a newly proposed lightweight convolution in this disclosure, and its processing of scale feature maps is as follows: Figure 6 As shown, according to Figure 6 As can be seen, when generating intrinsic feature maps from scaled feature maps, the SSGConv module replaces k*k convolutions with two k*1 and 1*k convolutions, thereby reducing convolutional computations and compressing the input c-dimensional features to m. Then, the generated m-dimensional intrinsic feature map is expanded into a new m*s-dimensional feature map using layer-by-layer convolutions, where s is the cheap operation number. Finally, the m-dimensional intrinsic feature map is concatenated with the new m*s-dimensional feature map to obtain the final output intrinsic feature map. Because the SSGConv module utilizes simple linear operations to obtain the required similarity feature maps and optimizes convolutions using spatially separable operations, it significantly reduces the computational cost and complexity of convolutional operations, thus improving the efficiency of object detection.
[0123] It should be understood that the SSGConv module processes the first-scale feature map, the second-scale feature map, and the third-scale feature map in the same way. Therefore, the following explanation uses the SSGConv module to extract features from the first-scale feature map to obtain the intrinsic feature map as an example. That is, the extraction of features from the first-scale feature map to obtain the first intrinsic feature map may include:
[0124] Feature extraction and dimensionality reduction are performed on the first-scale feature map to obtain a first intrinsic feature sub-map; the first intrinsic feature sub-map is then subjected to dimensionality increase to obtain a second intrinsic feature sub-map; the first intrinsic feature sub-map and the second intrinsic feature sub-map are then subjected to feature fusion to obtain the first intrinsic feature map.
[0125] After the position information of each chicken is detected based on the output module, the displacement of each chicken between adjacent frames can be counted by the target tracking algorithm, and then the instability index can be calculated.
[0126] It should be understood that the statistical analysis of the displacement of each chicken between adjacent frames using a target tracking algorithm can be implemented based on target tracking algorithms in related technologies, such as Kalman filters, particle filters, or strongSort. It can also be implemented based on an improved target detection model, and this disclosure does not impose any limitations on this approach. In a possible implementation, to improve the tracking performance, this embodiment optimizes the StrongSort algorithm in related technologies by replacing the estimation of the aspect ratio of the predicted bounding box by the Kalman filter with a direct estimation of the width and height of the predicted bounding box. This reduces the error present in the original Kalman filter when matching the predicted and detected bounding boxes, thereby improving the tracking performance.
[0127] The optimized StrongSort algorithm is explained in detail below:
[0128] The optimized StrongSort algorithm incorporates Kalman filtering and the Hungarian algorithm. Kalman filtering is a highly efficient autoregressive filter that continuously updates the system's current data and uses this to predict the system's state at the next moment. Its function boils down to predicting the position of a moving target and using the prediction results to correct the target. Through prediction and updating, it achieves the best possible estimate of the dynamic system's state value, making it an optimal state estimation method. Kalman filtering has strong fault tolerance, accurately predicting and updating even in the presence of parameter noise or inaccurate observations. For these reasons, Kalman filtering plays a crucial role in tracking algorithms. In the prediction phase, it first inputs the object's state information at time t-1 into a predefined physical model and predicts the object's state information at time t, ultimately obtaining the Kalman gain corrected by the Kalman filtering algorithm. The update phase mainly involves converting between observation results and state variables, obtaining the observed state distribution and observation process distribution, and combining the multidimensional Bayesian fusion distribution results to obtain the optimal estimate of the system state. This disclosure replaces the Kalman filter's estimation of the aspect ratio of the predicted box with direct estimation of the width and height of the predicted box, reducing the error in the original Kalman filter when matching the predicted box and the detection box, and improving the tracking effect.
[0129] The flowchart of Kalman filtering is as follows Figure 7As shown. The detailed calculation formula is as follows, where equation (1) represents the state vector of a chicken at time t, equation (2) represents the observed value of the chicken at time t, and equations (3) and (4) are the process noise covariance matrix Q, respectively. k And the measurement noise covariance matrix R k .
[0130]
[0131]
[0132]
[0133]
[0134] Where, x t Let x represent the state vector of a chicken at time t. c (t) and y c w(t) represents the x and y coordinates of the center of the predicted bounding box for the chicken at time t, w(t) represents the width of the predicted bounding box for the chicken at time t, and h(t) represents the height of the predicted bounding box for the chicken at time t. This represents the rate of change of the center x-coordinate of the prediction box for the chicken at time t. This represents the rate of change of the center ordinate of the prediction box for the chicken at time t. This represents the rate of change of the prediction box width for the chicken at time t. z represents the rate of change of the predicted bounding box height for the chicken at time t. t This represents the observation value of the chicken at time t. and This represents the coordinates of the center point of the detection box for the chicken at time t, z. w (t) represents the width of the detection box for the chicken at time t, z h (t) represents the height of the detection box for the chicken at time t. and This represents the optimal state estimate of the target at time t-1, where the noise factor σ p =0.05, σ v =0.00625, σ m =0.05. By modifying the state vector and covariance formula, the entire Kalman filter can be reduced to the following recursive equation:
[0135]
[0136]
[0137]
[0138]
[0139] P t|t =(IK t H t )P t|t-1 (9)
[0140] in, F represents the state estimate from time t-1 to time t. t This represents the transition matrix at time t. P represents the state estimate at time t-1. t|t-1 Let represent the covariance matrix from time t-1 to time t. P represents the transpose of the transition matrix at time t. t-1|t-1 Let Q represent the covariance matrix at time t-1. t K represents the process noise covariance matrix at time t. t This represents the Kalman gain at time t. H represents the transpose of the observation matrix at time t. t R represents the observation matrix at time t. t This represents the measurement noise covariance at time t. Let z represent the state estimate of t. t P represents the measurement value at time t. t|t Let represent the covariance matrix at time t, and I represent a constant.
[0141] Therefore, at time t, we can first obtain the prior estimate based on the Kalman filter prediction state and the covariance matrix, and then update the posterior state estimate of the given observation and covariance based on the optimal Kalman gain.
[0142] The Hungarian algorithm, used to solve the minimum-cost assignment problem, is a combinatorial optimization algorithm that utilizes augmented paths to solve the task assignment problem. In its tracking algorithm, it matches objects detected by the detector with predicted objects from the previous frame, seeking more matching values by lowering the confidence level. The matching method is based on the Mahalanobis distance and IOU cost matrix calculated from the detection and tracking results.
[0143] Combination Figure 8It can be seen that StrongSort's matching process has two scenarios: First, the Kalman filter's predicted value successfully matches the object detected by the YOLO detector, in which case the observation, prediction, and matching cycle continues normally. Second, the Kalman filter and the YOLO detector fail to match. Matching failure can be due to either predicted value matching failure or detected value matching failure. Predicted value matching failure may be caused by missed detections, meaning that the predicted trajectory still exists at a certain moment, but the detector does not detect the corresponding target. Detected value matching failure can also be caused by two reasons: one, the object is appearing for the first time, and the detection result lacks a matching tracking trajectory; two, the object has been occluded for a long time, exceeding the consecutive matching limit, and the algorithm deletes the object's trajectory, thus the detected object has no matching trajectory. After the first matching failure, StrongSort will perform a second matching using the IOU cost matrix to reduce the number of remaining detection and tracking results.
[0144] Since the target tracking algorithm in this embodiment changes the estimation of the aspect ratio of the predicted bounding box by the Kalman filter in the StrongSort algorithm to the direct estimation of the width and height of the predicted bounding box, the target position information of each chicken in the next video frame can be determined based on the position information of each chicken in the target video frame. This can include:
[0145] Determine the center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame;
[0146] For each chicken in the target video frame, perform the following steps:
[0147] Based on the center coordinates, length, and height of the detection box corresponding to the current chicken, predict the center coordinates, length, and height of the detection box corresponding to the current chicken in the next video frame. Based on the predicted center coordinates, length, and height of the detection box corresponding to the current chicken, as well as the center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame, determine the tracking result of the current chicken. The tracking result is used to indicate whether the current chicken is detected in the next video frame. When the matching result indicates that the current chicken is detected in the next video frame, determine the predicted center coordinates, length, and height of the detection box corresponding to the current chicken as the target position information of the current chicken.
[0148] It should be understood that replacing the Kalman filter's estimation of the predicted box's aspect ratio with direct estimation of the predicted box's width and height has two advantages. First, by directly estimating the predicted box's width and height, the estimation of the aspect ratio is reduced, thus minimizing error accumulation during the estimation process. This results in more accurate predicted box dimensions, allowing the tracking algorithm to more closely approximate the target's actual shape and size. Second, changes in the predicted box's shape can lead to changes in the aspect ratio, and directly estimating the width and height can better suppress deformation effects. Therefore, by directly estimating the width and height, the tracking algorithm can better adapt to changes in the target's shape, improving its robustness to target deformation.
[0149] After determining the target position information of each chicken in the next video frame through the tracking algorithm, the accurate displacement of each chicken between adjacent frames can be determined based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame. This allows for the determination of the instability index corresponding to the target video frame, and the determination of the instability index of the flock based on the instability index corresponding to all video frames.
[0150] That is, in a possible implementation, determining the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame may include:
[0151] Based on the target position information of each chicken in the target video frame and the target position information of each chicken in the next video frame, the displacement of each chicken in the target video frame is determined; based on the displacement of each chicken in the target video frame and a preset scaling factor, the instability index corresponding to the target video frame is determined.
[0152] For example, based on the target position information of each chicken in adjacent video frames, the Euclidean distance of each chicken between adjacent frames can be determined, thus obtaining the displacement of each chicken between adjacent frames. After obtaining the displacement of each chicken between adjacent frames, the instability index corresponding to the target video frame can be determined based on the displacement of each chicken in the target video frame and a preset scaling factor. That is, the instability index corresponding to the target video frame can be determined by the following formula:
[0153]
[0154] Where, Unrest index(i,i-1) represents the instability index between frame i and frame i-1, i.e., the instability index corresponding to frame i, k represents the scaling factor, n represents the total number of chickens in the target video frame, and A i (j) represents the j-th chicken in the i-th frame, A i-1 (j) represents the j-th chicken in the (i-1)-th frame, d(Ai (j),A i-1 (j) represents the Euclidean distance between the j-th chicken in the i-th frame and the (i-1)-th frame.
[0155] It should be understood that the preset scaling factor can be set according to actual conditions, and this disclosure does not impose any limitations on it. In a possible implementation, the preset scaling factor can be determined by the position and angle of the camera in the chicken farm. Specifically, as shown in the figure, at camera position point p, the scaling factor can be obtained using the camera height H and the width C covered by the camera:
[0156]
[0157] Since the formula for calculating the instability index can be expressed as:
[0158] x = 2H tan(α / 2)
[0159]
[0160] Therefore, we can conclude that:
[0161]
[0162] Where x is the length of the ground that the camera can capture, y is the width of the ground that the camera can capture, w is the length of the photo, h is the width of the photo, and k represents the scale factor.
[0163] After obtaining the scaling factor, the instability index of each video frame can be obtained by substituting the scaling factor into the instability index calculation formula of the video frame. Finally, the instability indices of all video frames are added together to obtain the instability index of the chicken flock video during the period to be detected.
[0164] In a possible implementation, to verify the beneficial effects of the chicken flock activity level detection method disclosed herein, this embodiment compares the improved YOLOv7 model and the optimized StrongSort algorithm with related models or algorithms in related technologies, as follows:
[0165] This embodiment compares the improved YOLOv7 model with other lightweight methods in related technologies. The comparison results are shown in Table 1.
[0166] The comparison results of the improved YOLOv7 model with other lightweight methods are shown in Table 1.
[0167] Table 1 Comparison of the effects of the improved YOLOv7 with other lightweight methods.
[0168]
[0169] As shown in Table 1, the SSGConv proposed in this disclosure, when used in YOLOv7, reduces the number of parameters by 48.83%, computation by 44.62%, and increases the frame rate (FPS) by 42.28% compared to the original model. Compared to GhostConv, it reduces the number of parameters by 26.90%, computation by 22.58%, and increases the frame rate (FPS) by 19.10%. The reduction in convolutional parameters and the increase in speed are attributed to SSGConv's targeted use of spatially separable convolutions on top of GhostConv, splitting the multiplication operation of convolutions to further reduce the number of model operations. Furthermore, the convolutions used for connection operations are changed to 5x5 kernels, reducing the accuracy loss caused by spatially separable operations. SSGConv enables the model to quickly and accurately detect chicken flocks and calculate the instability index of activity levels.
[0170] Meanwhile, YOLOv7 was compared with other detectors on the market, and the comparison results are shown in Table 2.
[0171] Table 2 Comparison of the performance of the improved YOLOv7 and its detection method.
[0172]
[0173] As shown in Table 2, our improved YOLOv7 model exhibits the best performance in terms of parameter count, computational cost, and speed. Specifically, compared to YOLOv8s, our model has only 3.07M parameters, a 72.3% reduction in size, a 74.6% reduction in computational cost, and a 37.1% improvement in running speed. Compared to v6s, our model has 1.56M fewer parameters, a 33.7% reduction in size, a 36.6% reduction in computational cost, and a 19.5% improvement in running speed. Furthermore, our model outperforms Faster R-CNN in both accuracy and size.
[0174] Based on the above results, the YOLOv7 model optimized in this proposal exhibits the best overall performance. The optimized YOLOv7 detection results are as follows: Figure 10 As shown.
[0175] The improved StrongSort algorithm was compared across three videos with different chicken flock conditions. The three videos showed significant differences: Video 1, a 14-second (350 frames) video of a chicken flock with minimal disturbance, was shot from above; Video 2, a 14-second (344 frames) video of a chicken flock with greater disturbance, was also shot from above; and Video 3, a 14-second (331 frames) video of a larger flock with greater disturbance, shot from the side. Tables 3, 4, and 5 show the comparison results for Video 1, Video 2, and Video 3, respectively. Table 3 shows that for cases with minimal chicken flock disturbance, the Kalman filter using aspect ratio estimation performed better than the aspect ratio estimation, showing improvement across all metrics. The improved algorithm reduced the number of ID jumps by 26.2% compared to the original algorithm. Table 4 shows that for scenarios with significant disturbance in the flock of chickens captured from above, the improved model improves performance by 7.27%, 18.87%, and 10.60% in HOTA, IDF_1, and ASSA, respectively, while reducing IDS by 28.8%. Table 5 shows that the tracking performance remains excellent even when the flock size is large and the shooting angle changes. Therefore, the improved StrongSort exhibits strong robustness and superior tracking performance, making it suitable for various scenarios. Analysis of the three comparative results demonstrates that the improved StrongSort performs well in different scenarios, exhibiting superior robustness.
[0176] Table 3 Comparison of StrongSort performance before and after improvement for overhead shots of chickens with minimal disturbance.
[0177]
[0178] Table 4 Comparison of StrongSort performance before and after improvement for overhead shots of chicken flocks with significant disturbance.
[0179]
[0180] Table 5 Comparison of the effects of side-view chicken flock videos on StrongSort before and after improvement.
[0181]
[0182] Meanwhile, this embodiment compares the improved StrongSort with trackers on the market, and the results are shown in Table 6.
[0183] Table 6 compares the performance of the improved StrongSort with other trackers.
[0184]
[0185]
[0186] As shown in Table 6, the tracker used in this disclosure has the best overall performance.
[0187] Both of the above results (the improved StrongSort exhibits stronger robustness and superior tracking performance, is suitable for various scenarios, and boasts the best overall tracker performance) benefit from the fact that the Kalman filter based on aspect ratio estimation no longer estimates the aspect ratio of the bounding box, but directly estimates the width and height, thus improving the accuracy of the bounding box prediction and consequently improving the matching between the predicted and detected boxes. The algorithm further improves tracking accuracy by fusing the observations of the current frame with the predicted values of the previous frame and by fusing the uncertainty of each estimation by the system. The optimized StrongSort tracking results are shown in the figure below. Figure 11 As shown in the figure, all other trackers experienced tracking errors, which are represented by truncated dashed lines.
[0188] The final instability index was verified using aerial videos of chicken flocks under two different disturbance conditions, and the results are as follows: Figure 12 As shown in the figure, for video output2, which shows a larger disturbance in the flock, the instability index exhibits three peaks, with the index around 2.5 during the non-peak phase. For video output1, which shows a relatively smaller disturbance, the instability index only shows one relatively violent movement in the final time period, while the flock remains relatively stable at other times, with the index around 1.0 during the non-peak phase. This figure demonstrates that the instability index reflects the actual disturbance situation of the flock.
[0189] Based on the same concept, this disclosure also provides a flock activity level detection device, the flock activity level detection device 1300 may include:
[0190] The acquisition module 1301 is used to acquire videos of chickens during the period to be detected;
[0191] The first determining module 1302 is used to input the chicken flock video into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period.
[0192] The activity level detection model includes:
[0193] The second determining module is used to determine the position information of each chicken in the target video frame, wherein the target video frame is any one of the multiple video frames in the chicken flock video;
[0194] The third determining module is used to determine the target position information of each chicken in the next video frame based on the position information of each chicken in the target video frame.
[0195] The fourth determining module is used to determine the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame.
[0196] The fifth determining module is used to determine the target instability index based on the instability indices corresponding to the plurality of video frames.
[0197] In a possible implementation, the second determining module may include:
[0198] The first feature extraction submodule is used to extract features from the target video frame at different levels to obtain hierarchical feature maps corresponding to different levels.
[0199] The feature fusion submodule is used to perform feature fusion processing on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales.
[0200] The target detection submodule is used to perform target detection on the scale feature maps of different scales to obtain the position information of each chicken in the target video frame.
[0201] In a possible implementation, the first feature extraction submodule may include:
[0202] The first feature extraction unit is used to perform binary feature extraction processing on the target video frame to obtain a first binary feature map;
[0203] The second feature extraction unit is used to perform hierarchical feature extraction on the first binary feature map to obtain a first-level feature map;
[0204] The third feature extraction unit is used to perform hierarchical feature extraction on the first-level feature map to obtain the second-level feature map;
[0205] The fourth feature extraction unit is used to perform hierarchical feature extraction on the second-level feature map to obtain the third-level feature map;
[0206] The first determining unit is used to determine the first layer feature map, the second layer feature map, and the third layer feature map as the layer feature maps corresponding to the different layers.
[0207] In a possible implementation, the second feature extraction unit may include:
[0208] The feature dimensionality reduction subunit is used to perform feature dimensionality reduction processing on the first binary feature map to obtain the second binary feature map;
[0209] The first feature extraction subunit is used to perform binary feature extraction processing on the second binary feature map to obtain the third binary feature map;
[0210] The second feature extraction subunit is used to extract the main features of the third binary feature map to obtain the main feature map, and to extract the secondary features of the third binary feature map to obtain the secondary feature map.
[0211] The first feature fusion subunit is used to perform feature fusion processing on the third binary feature map, the main feature map, and the secondary feature map to obtain the first-level feature map.
[0212] In a possible implementation, the feature fusion submodule may include:
[0213] The first feature processing unit is used to perform binary feature extraction and feature fusion processing on the third-level feature map to obtain a fourth binary feature map.
[0214] The second feature processing unit is used to perform feature fusion processing on the fourth binary feature map and the second hierarchical feature map to obtain a second fused feature map, and to perform feature fusion processing on the second fused feature map and the first hierarchical feature map to obtain a third fused feature map, and to perform scale feature extraction on the third fused feature map to obtain a first scale feature map.
[0215] The third feature processing unit is used to perform binary feature extraction processing on the third fused feature map to obtain a fifth binary feature map, and to perform feature fusion processing on the fifth binary feature map and the second fused feature map to obtain a fourth fused feature map, and to perform scale feature extraction on the fourth fused feature map to obtain a second scale feature map.
[0216] The fourth feature processing unit is used to perform binary feature extraction processing on the fourth fused feature map to obtain a sixth binary feature map, and to perform feature fusion processing on the sixth binary feature map and the fourth binary feature map to obtain a fifth fused feature map, and to perform scale feature extraction on the fifth fused feature map to obtain a third scale feature map.
[0217] The second determining unit is used to determine the first scale feature map, the second scale feature map, and the third scale feature map as scale feature maps of different scales.
[0218] In a possible implementation, the first feature processing unit may include:
[0219] The third feature extraction subunit is used to perform binary feature extraction processing on the third-level feature map to obtain the first binary feature sub-map;
[0220] The pooling processing subunit is used to perform pooling processing on the first binary feature sub-map based on different pooling window sizes to obtain multiple different second binary feature sub-maps.
[0221] The second feature fusion subunit is used to perform feature fusion processing on the first binary feature subgraph and the plurality of different second binary feature subgraphs to obtain a third binary subgraph.
[0222] The third feature fusion subunit is used to perform binary feature extraction processing on the third binary subgraph to obtain a fourth binary feature subgraph, and to perform feature fusion processing on the fourth binary feature subgraph and the first binary feature subgraph to obtain a fifth binary feature subgraph.
[0223] The fourth feature extraction subunit performs binary feature extraction processing on the fifth binary feature sub-map to obtain the fourth binary feature map.
[0224] In a possible implementation, the second determining module may include:
[0225] The second feature extraction submodule is used to extract intrinsic features from the first scale feature map to obtain the first intrinsic feature map.
[0226] The third feature extraction submodule is used to extract intrinsic features from the second scale feature map to obtain the second intrinsic feature map.
[0227] The fourth feature extraction submodule is used to extract intrinsic features from the third-scale feature map to obtain the third intrinsic feature map;
[0228] The target detection submodule is used to perform target detection on the first intrinsic feature map, the second intrinsic feature map and the third intrinsic feature map to obtain the position information of each chicken in the target video frame;
[0229] The second feature extraction submodule may include:
[0230] The fifth feature processing unit is used to perform feature extraction and feature dimensionality reduction on the one-scale feature map to obtain the first intrinsic feature sub-map;
[0231] The feature upscaling unit is used to upscale the first intrinsic feature sub-map to obtain the second intrinsic feature sub-map.
[0232] The feature fusion unit is used to perform feature fusion processing on the first intrinsic feature sub-map and the second intrinsic feature sub-map to obtain the first intrinsic feature map.
[0233] In a possible implementation, the location information includes the center coordinates, length, and height of the detection box; correspondingly, the third determining module may include:
[0234] The first determination submodule is used to determine the center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame;
[0235] The prediction submodule is used to predict the center coordinates, length, and height of the detection box corresponding to the current chicken in the next video frame based on the center coordinates, length, and height of the detection box corresponding to the current chicken.
[0236] The second determining submodule is used to determine the tracking result of the current chicken based on the predicted center coordinates, predicted length, and predicted height of the detection box corresponding to the current chicken, as well as the predicted center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame. The tracking result is used to characterize whether the current chicken is detected in the next video frame.
[0237] The third determining submodule is used to determine the center coordinate prediction value, length prediction value, and height prediction value of the detection box corresponding to the current chicken as the target position information of the current chicken when the matching result characterizes the detection of the current chicken in the next video frame.
[0238] In a possible implementation, the fourth determining module may include:
[0239] The fourth determining submodule is used to determine the displacement of each chicken in the target video frame based on the target position information of each chicken in the target video frame and the target position information of each chicken in the next video frame.
[0240] The fifth determining submodule is used to determine the instability index corresponding to the target video frame based on the displacement of each chicken in the target video frame and a preset scaling factor.
[0241] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0242] Based on the same concept, this disclosure also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the chicken flock activity level detection method provided in the disclosed embodiments.
[0243] Based on the same concept, this disclosure also provides an electronic device, including: a memory storing a computer program thereon; and a processor for executing the computer program in the memory to implement the steps of the chicken activity level detection method provided in this disclosure.
[0244] Figure 14 This is a block diagram illustrating an electronic device 1400 according to an exemplary embodiment. For example... Figure 14 As shown, the electronic device 1400 may include a processor 1401 and a memory 1402. The electronic device 1400 may also include one or more of a multimedia component 1403, an input / output (I / O) interface 1404, and a communication component 1405.
[0245] The processor 1401 controls the overall operation of the electronic device 1400 to complete all or part of the steps in the above-described method for detecting the activity level of chickens. The memory 1402 stores various types of data to support the operation of the electronic device 1400. This data may include, for example, instructions for any application or method operating on the electronic device 1400, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 1402 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 1403 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 1402 or transmitted via communication component 1405. The audio component also includes at least one speaker for outputting audio signals. I / O interface 1404 provides an interface between processor 1401 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 1405 is used for wired or wireless communication between the electronic device 1400 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IoT, eMTC, or other 5G technologies, or combinations thereof, is not limited here. Therefore, the corresponding communication component 1405 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0246] In an exemplary embodiment, the electronic device 1400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described chicken flock activity level detection method.
[0247] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the chicken activity level detection method described above. For example, the computer-readable storage medium may be the memory 1402 including the program instructions described above, which may be executed by the processor 1401 of the electronic device 1400 to complete the chicken activity level detection method described above.
[0248] Figure 15 This is a block diagram illustrating an electronic device 1500 according to an exemplary embodiment. For example, the electronic device 1500 may be provided as a server. (Refer to...) Figure 15 The electronic device 1500 includes a processor 1522, which may be one or more, and a memory 1532 for storing a computer program executable by the processor 1522. The computer program stored in the memory 1532 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processor 1522 may be configured to execute the computer program to perform the aforementioned method for detecting the activity level of chicken flocks.
[0249] Additionally, the electronic device 1500 may also include a power supply component 1526 and a communication component 1550. The power supply component 1526 can be configured to perform power management of the electronic device 1500, and the communication component 1550 can be configured to enable communication of the electronic device 1500, such as wired or wireless communication. Furthermore, the electronic device 1500 may also include an input / output (I / O) interface 1558. The electronic device 1500 can operate on an operating system stored in the memory 1532.
[0250] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the chicken activity level detection method described above. For example, the non-transitory computer-readable storage medium may be the memory 1532 including the program instructions, which may be executed by the processor 1522 of the electronic device 1500 to complete the chicken activity level detection method described above.
[0251] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the above-described chicken flock activity level detection method when executed by the programmable device.
[0252] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0253] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0254] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A method for detecting the activity level of a chicken flock, characterized in that, The method includes: Obtain video footage of the chickens during the time period to be detected; The chicken flock video is input into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period. The activity level detection model is used to obtain the target instability index through the following operations: The improved YOLOv7 network is used to determine the position information of each chicken in the target video frame, wherein the target video frame is any one of multiple video frames in the chicken flock video; The improved YOLOv7 network includes an input module, a feature extraction module, a feature fusion module, and an output module; The feature extraction module includes an ELAN-SA module, which includes three CBS modules (CBS1, CBS2, and CBS3), two SSGConv modules (SSGConv1 and SSGConv2), and one feature fusion module (concat). CBS1, SSGConv1, SSGConv2, concat, and CBS3 are connected in sequence. The input of CBS3 is connected to the input of CBS1, and the output of CBS3 is connected to the input of concat. The feature fusion module includes a spatial pyramid pooling and cross-stage partial channel connection module, an ELAN-SA module, a concat module, a feature processing module, and a CBS module; The output module includes three SSGConv modules and one detection head IDetect. The SSGConv modules convert each scale feature map into an intrinsic feature map for target detection, and the detection head IDetect performs target detection on all intrinsic feature maps to obtain the location information of each chicken. When the SSGConv module generates the intrinsic feature map based on the scale feature map, it replaces the k×k convolution with two k×1 and 1×k convolutions, compresses the input c-dimensional features to m-dimensional features, expands the generated m-dimensional intrinsic feature map to a new m×s-dimensional feature map using layer-by-layer convolution, and concatenates the m-dimensional intrinsic feature map with the new m×s-dimensional feature map to obtain the final output intrinsic feature map, where s is the cheap operation number; Based on the position information of each chicken in the target video frame, the improved StrongSort algorithm is used to determine the target position information of each chicken in the next video frame. In the improved StrongSort algorithm, the estimation of the aspect ratio of the prediction box by the Kalman filter in the StrongSort algorithm is changed to the direct estimation of the width and height of the prediction box. Based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame, the instability index corresponding to the target video frame is determined. The target instability index is determined based on the instability indices corresponding to the multiple video frames.
2. The method according to claim 1, characterized in that, The determination of the position information of each chicken in the target video frame includes: The target video frame is subjected to feature extraction at different levels to obtain hierarchical feature maps corresponding to different levels; Feature fusion processing is performed on the hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales; Target detection is performed on the scale feature maps at different scales to obtain the position information of each chicken in the target video frame.
3. The method according to claim 2, characterized in that, The step of extracting features from the target video frame at different levels to obtain hierarchical feature maps corresponding to different levels includes: The target video frame is subjected to binary feature extraction processing to obtain a first binary feature map; Hierarchical feature extraction is performed on the first binary feature map to obtain the first-level feature map; Hierarchical feature extraction is performed on the first-level feature map to obtain the second-level feature map; Hierarchical feature extraction is performed on the second-level feature map to obtain the third-level feature map; The first-level feature map, the second-level feature map, and the third-level feature map are determined as the level feature maps corresponding to the different levels.
4. The method according to claim 3, characterized in that, The step of performing hierarchical feature extraction on the first binary feature map to obtain a first-level feature map includes: The first binary feature map is subjected to feature dimensionality reduction processing to obtain the second binary feature map; The second binary feature map is subjected to binary feature extraction processing to obtain the third binary feature map; The main features of the third binary feature map are extracted to obtain the main feature map, and the secondary features of the third binary feature map are extracted to obtain the secondary feature map. The third binary feature map, the main feature map, and the secondary feature map are subjected to feature fusion processing to obtain the first-level feature map.
5. The method according to claim 3, characterized in that, The feature fusion processing of hierarchical feature maps corresponding to different levels to obtain scale feature maps of different scales includes: The third-level feature map is subjected to binary feature extraction and feature fusion processing to obtain the fourth binary feature map; The fourth binary feature map and the second-level feature map are subjected to feature fusion processing to obtain a second fused feature map. The second fused feature map and the first-level feature map are subjected to feature fusion processing to obtain a third fused feature map. The third fused feature map is subjected to scale feature extraction to obtain a first scale feature map. The third fused feature map is subjected to binary feature extraction processing to obtain a fifth binary feature map, and the fifth binary feature map and the second fused feature map are subjected to feature fusion processing to obtain a fourth fused feature map, and the fourth fused feature map is subjected to scale feature extraction to obtain a second scale feature map; The fourth fused feature map is subjected to binary feature extraction processing to obtain the sixth binary feature map, and the sixth binary feature map and the fourth binary feature map are subjected to feature fusion processing to obtain the fifth fused feature map. The fifth fused feature map is subjected to scale feature extraction to obtain the third scale feature map. The first scale feature map, the second scale feature map, and the third scale feature map are determined as scale feature maps of different scales.
6. The method according to claim 5, characterized in that, The process of performing binary feature extraction and feature fusion on the third-level feature map to obtain a fourth binary feature map includes: The third-level feature map is subjected to binary feature extraction processing to obtain the first binary feature sub-map; The first binary feature sub-image is pooled based on different pooling window sizes to obtain multiple different second binary feature sub-images. The first binary feature sub-map and the plurality of different second binary feature sub-maps are subjected to feature fusion processing to obtain a third binary sub-map; The third binary sub-graph is subjected to binary feature extraction processing to obtain the fourth binary feature sub-graph, and the fourth binary feature sub-graph and the first binary feature sub-graph are subjected to feature fusion processing to obtain the fifth binary feature sub-graph. The fifth binary feature sub-map is subjected to binary feature extraction processing to obtain the fourth binary feature map.
7. The method according to claim 5, characterized in that, The step of performing target detection on the scale feature maps of different scales to obtain the position information of each chicken in the target video frame includes: Intrinsic features are extracted from the first scale feature map to obtain the first intrinsic feature map; Intrinsic feature extraction is performed on the second-scale feature map to obtain the second intrinsic feature map; Intrinsic feature extraction is performed on the third-scale feature map to obtain the third intrinsic feature map; Target detection is performed on the first intrinsic feature map, the second intrinsic feature map, and the third intrinsic feature map to obtain the position information of each chicken in the target video frame; The step of extracting features from the first scale feature map to obtain the first intrinsic feature map includes: The first intrinsic feature sub-map is obtained by performing feature extraction and feature dimensionality reduction on the first-scale feature map. The first intrinsic feature sub-graph is subjected to dimensionality upscaling to obtain the second intrinsic feature sub-graph. The first intrinsic feature sub-map and the second intrinsic feature sub-map are subjected to feature fusion processing to obtain the first intrinsic feature map.
8. The method according to any one of claims 1-7, characterized in that, The location information includes the center coordinates, length, and height of the detection box. Determining the target location information of each chicken in the next video frame based on the location information of each chicken in the target video frame includes: Determine the center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame; For each chicken in the target video frame, perform the following steps: Based on the center coordinates, length, and height of the detection box corresponding to the current chicken, predict the center coordinates, length, and height of the detection box corresponding to the current chicken in the next video frame. Based on the predicted center coordinates, length, and height of the detection box corresponding to the current chicken, as well as the predicted center coordinates, length, and height of the detection box corresponding to each chicken in the next video frame, the tracking result of the current chicken is determined. The tracking result is used to characterize whether the current chicken is detected in the next video frame. When the tracking result indicates that the current chicken is detected in the next video frame, the predicted center coordinates, predicted length, and predicted height of the detection box corresponding to the current chicken are determined as the target position information of the current chicken.
9. The method according to any one of claims 1-7, characterized in that, The step of determining the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame includes: Based on the target position information of each chicken in the target video frame and the target position information of each chicken in the next video frame, determine the displacement of each chicken in the target video frame. The instability index corresponding to the target video frame is determined based on the displacement of each chicken in the target video frame and a preset scaling factor.
10. A device for detecting the activity level of a flock of chickens, characterized in that, The device includes: The acquisition module is used to acquire videos of chickens during the time period to be detected. The first determining module is used to input the chicken flock video into the activity level detection model to obtain the target instability index, which is used to characterize the activity level of the chicken flock during the detection period. The activity level detection model includes: The second determining module is used to determine the position information of each chicken in the target video frame using the improved YOLOv7 network, wherein the target video frame is any one of the multiple video frames in the chicken flock video; The improved YOLOv7 network includes an input module, a feature extraction module, a feature fusion module, and an output module; The feature extraction module includes an ELAN-SA module, which includes three CBS modules (CBS1, CBS2, and CBS3), two SSGConv modules (SSGConv1 and SSGConv2), and one feature fusion module (concat). CBS1, SSGConv1, SSGConv2, concat, and CBS3 are connected in sequence. The input of CBS3 is connected to the input of CBS1, and the output of CBS3 is connected to the input of concat. The feature fusion module includes a spatial pyramid pooling and cross-stage partial channel connection module, an ELAN-SA module, a concat module, a feature processing module, and a CBS module; The output module includes three SSGConv modules and one detection head IDetect. The SSGConv modules convert each scale feature map into an intrinsic feature map for target detection, and the detection head IDetect performs target detection on all intrinsic feature maps to obtain the location information of each chicken. When the SSGConv module generates the intrinsic feature map based on the scale feature map, it replaces the k×k convolution with two k×1 and 1×k convolutions, compresses the input c-dimensional features to m-dimensional features, expands the generated m-dimensional intrinsic feature map to a new m×s-dimensional feature map using layer-by-layer convolution, and concatenates the m-dimensional intrinsic feature map with the new m×s-dimensional feature map to obtain the final output intrinsic feature map, where s is the cheap operation number; The third determining module is used to determine the target position information of each chicken in the next video frame based on the position information of each chicken in the target video frame using an improved StrongSort algorithm. In the improved StrongSort algorithm, the estimation of the aspect ratio of the prediction box by the Kalman filter in the StrongSort algorithm is changed to the direct estimation of the width and height of the prediction box. The fourth determining module is used to determine the instability index corresponding to the target video frame based on the position information of each chicken in the target video frame and the target position information of each chicken in the next video frame. The fifth determining module is used to determine the target instability index based on the instability indices corresponding to the plurality of video frames.