Cow house leaving track identification method

By using an improved YOLOv8 model and Deepsort algorithm, combined with a single wide-angle camera, high-precision identification of cattle's trajectories can be achieved. This solves the problem of existing systems being unable to judge the dynamic behavior of cattle in real time, reduces equipment complexity and energy consumption, and improves monitoring accuracy and animal welfare.

CN120673447AActive Publication Date: 2025-09-19CHANGZHOU WUITU SMART TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511188520.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-25
Publication Date
2025-09-19
Estimated Expiration
2045-08-25

AI Technical Summary

Technical Problem

The existing cattle entry and exit monitoring system is unable to judge the dynamic behavior of cattle in real time. The hardware settings are complex and prone to human errors, resulting in a high rate of stress in cattle and insufficient animal welfare.

Method used

A single wide-angle camera is combined with an improved YOLOv8 model. The P-CBS module and I-MAB multi-scale attention mechanism are used to identify the key points of the cattle's head and torso. The Deepsort algorithm is used to track the cattle's movement trajectory, achieving high-precision cattle out-of-shed trajectory identification.

Benefits of technology

Real-time inference is achieved on edge devices, which reduces the number of devices and energy consumption, improves the accuracy of cattle behavior recognition, reduces false detection rates, reduces overall costs, and improves animal welfare.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673447A_ABST
    Figure CN120673447A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of animal behavior monitoring, in particular to a cattle out-of-house track recognition method, which comprises the following steps of: acquiring an entrance and exit position image in a cattle house by adopting a single wide-angle camera; based on the improved YOLOv8 model, identifying cattle head and trunk key points, and obtaining a cattle head detection frame and a trunk detection frame; a convolutional layer in a backbone network of the improved YOLOv8 model is replaced by a P-CBS module, an I-MAB multi-scale attention mechanism is added in a neck network, and the MAB comprises two parts, namely a lightweight multi-scale large kernel attention (I-MLKA) module and a gate space attention unit (I-GSAU); and judging the motion trail of the cattle based on the cattle head detection frame and the trunk detection frame. By adopting a hardware deployment scheme of a single camera and an edge calculation box, convenient equipment installation is realized, model pruning is performed by adopting P-CBS + lightweight check, lightweight calculation is realized, real-time reasoning is achieved on edge equipment, and the identification accuracy is improved while the model parameter quantity is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of animal behavior monitoring, and in particular to a method for identifying cattle trajectories leaving a barn. Background Art

[0002] In modern dairy farming, cattle must enter and exit the barn multiple times daily to complete standardized activities such as milking and feeding. Traditionally, equipment control relies heavily on manual operation, either through the use of multiple cameras monitoring entrances and exits or sensors detecting the presence of cattle.

[0003] However, existing cattle entry and exit monitoring systems can only determine the presence of a target object, not the dynamic behavior of cattle. Furthermore, multi-camera monitoring methods require complex hardware setup and must be performed in an empty barn. To achieve real-time monitoring of cattle's dynamic behavior and avoid human error, a high-precision method for monitoring cattle entering and exiting the barn is urgently needed to reduce stress and improve animal welfare. Summary of the Invention

[0004] The present invention aims to solve one of the problems existing in the background technology.

[0005] To this end, the present invention provides a method for identifying cattle trajectories leaving the shed.

[0006] The technical solution adopted by the present invention to solve its technical problem is: A method for identifying cattle trajectories leaving a shed, comprising: Step 1: Use a single wide-angle camera to obtain images of the entrance and exit locations of the cowshed; Step 2: Identify the key points of the cow's head and torso based on the improved YOLOv8 model, and obtain the cow's head detection frame and torso detection frame; The convolutional layers in the backbone network of the improved YOLOv8 model are replaced with P-CBS modules, and the I-MAB multi-scale attention mechanism is added to the neck network. The I-MAB multi-scale attention mechanism consists of two parts: a lightweight multi-scale large-core attention module and a gated spatial attention unit. Step 3: Determine the cow's movement trajectory based on the cow's head detection frame and torso detection frame.

[0007] Furthermore, the lightweight multi-scale large-core attention module includes a GhostConv branch, an expanded DW-Conv branch, and a re-parameterized large-core branch. The features are processed by the GhostConv branch, the expanded DW-Conv branch, and the re-parameterized large-core branch respectively, and then spliced ​​and output.

[0008] Furthermore, the GhostConv branch compresses the channel with 1×1 point-by-point convolution and then uses 3×3 depth-wise separable convolution to generate pseudo features; the dilated DW-Conv branch uses 7×7 depth-wise separable convolution with an expansion rate of 2 to 3, so that the equivalent receptive field reaches approximately 19×19; the re-parameterized large kernel branch uses two-level 3×3 or 5×5 separable convolution stacks during training, and merges them into a static 11×11 depth-wise convolution kernel at one time during inference.

[0009] Furthermore, in the gated spatial attention unit, a dual-branch prior is first performed after the feature input, and the dual-branch prior includes a spatial / directional prior and a channel prior. After completing the dual-branch prior, the output results of the two branches are fused through multiplicative gating; the fused features are convolved in a geometrically aligned manner, and finally the output after the geometrically aligned convolution is added to the residual of the original input and added element-by-element as the final output of the gated spatial attention unit.

[0010] Furthermore, in step three, the center points of the cow's head detection frame and the torso detection frame are respectively taken to obtain the head coordinates and the tail coordinates, which are then connected into a straight line L, with the head coordinates as the front, to determine the direction of the cow.

[0011] Furthermore, in step three, when the cow moves, Deepsort is used to track the unique ID on the ear tag of each cow, and the pixel value of the position movement is obtained. The points whose movement positions exceed the threshold are added to the trajectory calculation, the trajectory is smoothed, and the entry and exit directions are determined by the offset direction of the straight line L. The initial judgment window is set to 10, and the movement threshold is set to 25. When the judgment window reaches the set value, the head and tail coordinates are subtracted, the tangent value is calculated, and a straight line of the direction is fitted.

[0012] Furthermore, the feature map is input into the P-CBS module in the backbone network, the feature map is first divided, then passes through sparse partial conv to reduce parameters, passes through batchnorm and silu activation functions, and finally obtains the feature map.

[0013] A computer device comprising: processor; a memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the cattle exit trajectory identification method as described above.

[0014] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor implements the cattle-outlet trajectory identification method as described above.

[0015] The beneficial effect of the present invention is that by adopting P-CBS+ lightweight neck for model pruning, lightweight computing is achieved, and real-time reasoning (response delay ≤ 200ms) is achieved on edge devices. Specifically, this application uses the P-CBS module to replace some convolutional layers and improve the backbone structure, thereby reducing the number of model parameters while improving the accuracy by 3%. By adding the I-MAB multi-scale attention mechanism to the neck part and designing the I-MLKA and I-GSAU modules, more accurate extraction and recognition of cattle head and torso features are achieved. By increasing the IOU threshold of the preliminary data of the YOLO model and combining it with the Deepsort tracking algorithm, accurate judgment and tracking of cattle trajectories are achieved, with a false detection rate of <1%.

[0016] By combining target detection with a multi-target Deepsort tracking algorithm, we achieved high-accuracy recognition of cattle entry and exit behavior in high-density cattle herd scenarios (up to 98.7%), and maintained an accuracy of 97% when multiple cattle overlapped.

[0017] By adopting a hardware deployment solution of a single camera and an edge computing box, convenient equipment installation is achieved (the construction window is shortened to 20 minutes), the number of devices is reduced by 90%, energy consumption is reduced by 95%, and the overall cost is reduced by 90%, while redundant data is avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The present invention will be further described below with reference to the accompanying drawings and examples.

[0019] Figure 1 It is a structural diagram of the improved YOLOv8 model in the present invention.

[0020] Figure 2 It is a structural diagram of the P-CBS module in the present invention.

[0021] Figure 3 It is a structural diagram of the lightweight multi-scale large-core attention module in the present invention.

[0022] Figure 4 It is a structural diagram of the gate spatial attention unit in the present invention.

[0023] Figure 5 It is a schematic diagram of the implementation process of the I-MAB multi-scale attention mechanism in the present invention.

[0024] Figure 6 This is a schematic diagram of the trajectory identification of cattle leaving the shed in the present invention.

[0025] Figure 7 This is a schematic diagram of the trajectory identification of cattle entering the shed in the present invention. DETAILED DESCRIPTION

[0026] The present invention will now be described in further detail with reference to the accompanying drawings, which are simplified schematic diagrams that illustrate the basic structure of the present invention in a schematic manner.

[0027] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, features defined as "first" or "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0028] In the description of the present invention, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they may refer to fixed, detachable, or integral connections; mechanical or electrical connections; direct or indirect connections through an intermediate medium; and internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on the specific circumstances.

[0029] A method for identifying cattle trajectories after leaving a shed comprises the following steps: Step 1: Image acquisition and preprocessing A single wide-angle camera should be installed above the entrance and exit of the cattle barn, covering the gate area and capturing real-time video streams. The camera must be able to adapt to low light conditions (≤1 Lux), maintain a frame rate ≥30 fps, and a resolution ≥1080P. Background modeling should be used to eliminate environmental interference (such as lighting changes and fixed obstacles) and extract dynamic targets (cattle outlines).

[0030] Step 2: Trajectory Recognition Algorithm Identify the key points of the cow's head and torso based on the improved YOLOv8 model.

[0031] S2.1YOLOv8 model includes backbone network (backbone), neck network (neck) and head network (head). Specifically, this application proposes a new module P-CBS in the head part, such as Figure 2As shown in the figure, the convolutional layer of the backbone part of the yolov8 model is converted into a P-CBS module. The specific P-CBS process is as follows: the input feature map is then reduced by sparse partial conv, and then the batchnorm and silu activation functions are used to obtain the feature map. The multi-layer superposition forms the backbone of the variant yolo, which improves the accuracy by 3% while ensuring the reduction of the original parameters. The subsequent features of different scales enter the improved I-MAB module of the neck part.

[0032] The feature input and output process in backbone is as follows: The image (640×640) is input and enters C2f: 1×1 convolution is first used to expand the channel to a wider intermediate dimension (to facilitate information mixing), and then split into multiple sub-branches, one of which is directly connected and retained, and the remaining branches enter P-CBS in sequence; The P-CBS sub-branch first divides channels into the backbone and identical bypasses for "convolution" according to a ratio of r (e.g., 0.5–0.6). A 3×3 lightweight convolution is performed on the backbone channels, using Partial-Conv → Batch Normalization (BN) → SiLU activation function, with bypasses directly added. This only computes r·Cin convolutions (Cin: the number of channels in the input feature map, r: the ratio of Partial-Conv participation (between 0 and 1), meaning "only r proportion of channels are convolved, and the remaining (1-r) channels take the identical bypass." r·Cin is the number of channels actually participating in the 3×3 convolution). This significantly reduces parameters and the number of Multiply–Accumulate operations (used to measure the computational complexity of convolution / networks). Concat & 1×1 back-compression: concatenate the directly connected branch with each P-CBS output, and then use 1×1 convolution to compress the channel back to 256, obtaining C3 (80×80×256); StageC4 (40×40×512) Downsample: Downsample C3 by 3×3 and stride=2 to obtain 40×40 features; Entering C2f (same as above): the same "1×1 expansion → Split → Multi-channel P-CBS → Concat → 1×1 backpressure" process is repeated, outputting C4 (40×40×512). Stage C5 (20×20×1024) is downsampled to 20×20. Entering C2f + Multi-channel P-CBS: the same process is repeated, outputting C5 (20×20×1024).

[0033] The input feature map is first divided into three scales. Then, in the backbone P-CBS part, sparse lightweight convolution partial conv (P-Conv) is used to reduce parameters. The main idea is that backbones generally have redundant features. Secondly, for edge deployment, parameters must be reduced. To compensate for the accuracy loss caused by reducing parameters, "wide" is replaced by "deep + residual + multi-scale". P-Conv removes redundant convolution weights to make the channels sparse. Three scales are processed in parallel, decomposing the missing spatial semantics into different resolutions. Multiple layers of residual stacking make up for the lost expressive power in the depth direction. SiLU + BN recalibration maintains the dynamic range of features. The result: nearly half the number of operators is reduced, while the information flow is more focused and regularization is stronger. Objective indicators have not only improved, but not decreased.

[0034] After BN and Silu activation functions, the feature map is finally obtained. Multiple layers are superimposed to form the backbone of the variant YOLO. While ensuring the reduction of the original parameters, the accuracy is improved by 3%. Subsequently, features of different scales enter the I-MAB module of the neck part.

[0035] The YOLOv8 model in this application designs a special feature extraction neck network for the head and torso features of cattle, and adds the I-MAB multi-scale attention mechanism to the original neck network. The I-MAB consists of two parts: the lightweight multi-scale large kernel attention module (I-MLKA) and the gated spatial attention unit (I-GSAU). Figure 3 shown.

[0036] (1) (2) (3) (4) Among them, LN represents layernorm, and feature X is normalized by ln to obtain N, as shown in formula (1); then enter the I-MLKA module, the multi-head I-MLKA, divides the feature into two in the channel dimension, and obtains sub-features , is a learnable scaling factor, where one of the sub-features After different convolution groups, the final Multiply, add the residual feature X, corresponding to formula (2); as shown in formula (4), where As a learnable scaling factor, I-GSAU uses ghost to double the channel, half of which is used for depth convolution and half for feature weighting, and finally residual connection, where is to fuse the results of the I-MLKA branch and project them back to the channel consistent with X, is a spatial prior, is the channel prior, It is geometrically aligned DCN-Lite refinement with channel projection.

[0037] The designed I-MLKA combines large kernel decomposition and multi-scale learning. It consists of a GhostConv branch, a dilated DW-Conv (DilatedDW) branch, and a reparameterized large kernel (RepLK) branch. The GhostConv branch compresses the channel using 1×1 point-by-point convolutions, followed by 3×3 depthwise separable convolutions to generate "cheap" pseudo-features. The dilated DW-Conv branch uses 7×7 depthwise separable convolutions with a dilation ratio of 2 to 3, resulting in an equivalent receptive field of approximately 19×19. The reparameterized large kernel (RepLK) branch stacks two levels of 3×3 or 5×5 separable convolutions during training, which are then merged into a static 11×11 depthwise convolution kernel during inference.

[0038] Compared with the original MLKA, the I-MLKA module Ghost+DilatedDW+RepLK (small core for training, large core for inference) has the same equivalent receptive field, but the parameters / FLOPs are reduced by about 35–45%, which is cache-friendly.

[0039] Specifically, I-GSAU includes the following process: After feature input, a two-branch prior is first applied, consisting of spatial / directional and channel priors. After this, the outputs of the two branches are fused using multiplicative gating (Multiply). The fused features are then convolved using geometric alignment (DCN-Lite). Finally, the DCN-Lite output is added to the residual of the original input (Skip), performing an element-by-element addition to provide the final output of I-GSAU.

[0040] Spatial / Directional Prior (CoordAtt): Global aggregation along the height and width axes is performed to obtain row and column context, which is then restored to a spatial attention map using a lightweight 1×1 convolution. This step encodes strong directional structures such as corridors and railings, informing the network of "where is more important."

[0041] Channel prior (ECA): Global average pooling is performed on the input to obtain per-channel statistics. Small convolutions (1D, k=3 / 5) are then used to interact with adjacent channels, outputting a channel weight vector. This approach is extremely cost-effective and can capture the importance of channels (e.g., pattern, fur color, edge texture).

[0042] Multiplicative gating (Multiply) broadcasts and multiplies the spatial attention map and channel weights to produce a position-by-channel gating map; this is used to perform element-by-element scaling of input features. Intuitively, features must satisfy both "position-important" and "channel-important" requirements to be amplified, while noise and irrelevant regions are suppressed.

[0043] Geometric alignment (DCN-Lite) performs a lightweight deformable convolution (3×3, grouped or depthwise separable, offset predicted by a small convolution layer, and an optional modulation mask) on the de-noised features. This step allows the sampling points to be micro-aligned to account for oblique shots, edge distortion, and light occlusion, making the features more closely aligned with the actual boundaries and contours. Residual addition (Skip) adds the DCN-Lite output to the original input element-by-element (if the number of channels is different, a 1×1 alignment is performed first) to produce the final output of I-GSAU. The residual ensures direct gradient transmission, avoiding information loss caused by over-suppression through gating.

[0044] The original GSAU uses a single-path spatial attention algorithm, while I-GSAU utilizes multiple paths, considering both "where" and "what type of features." DCN-Lite is also incorporated for micro-alignment, specifically addressing oblique shots, perspective, and edge distortion, providing enhanced robustness against situations like cattle grazing against edges or walking through fences. All components utilize 1×1, 1D convolution, grouped / depthwise convolution, and DCN-Lite, and are compatible with INT8 / FP16 quantization, minimizing incremental performance on edge devices.

[0045] The specific process of feature processing in the Neck network is as follows. The feature map is output through the backbone at three scales: C3, C4, and C5: Among them, C5 size is 20×20×1024→I-MLKA5. C5 enhances long-term dependencies in the I-MLKA multi-scale large kernel attention module, with unchanged size and rich feature context. I-MLKA5 (20×20×1024)→Up2 is upsampled by ×2 to 40×40×1024, and then compressed to 256 channels by 1×1. C4 is 40×40×512 in size. I-MLKA4 is enhanced as above and remains at 40×40×512. Upsampled C5 (40×40×256) is then concatenated to 40×40×768, and then compressed to 256 in 1×1 order. Finally, P4 (40×40×256) is obtained. P4 (40×40×256) → Up2 upsampled by ×2 to 80×80×256; C3 (80×80×256) → After I-MLKA3 enhancement, it is still 80×80×256 → Upsampling to obtain P4 (80×80×256) ⊕ I-MLKA3 (80×80×256) → Concat splicing 80×80×512, 1×1 compression to 256 → obtain P3 (80×80×256); P3 (80×80×256) → Down2 downsamples by ×2 to 40×40×256 and feeds it into Add4 (simple feature matrix summation). P4 (40×40×256) → I-GSAU4 coordinates + channel attention + lightweight DCN correction distortion, output 40×40×256; Add4: Down-P3 (40×40×256) ⊕ I-GSAU4 (40×40×256) element-wise addition and fusion to generate P4′ (40×40×256); P4′ (40×40×256) → Down2 downsamples by ×2 to 20×20×256 and feeds it into Add5; P5 (20×20×1024) (p5 is the structure of yolov8 itself) → 1×1 is compressed to 256, and then output to 20×20×256 through I-GSAU5; Add5: Down-P4′ (20×20×256) ⊕ I-GSAU5 (20×20×256) elements are added and fused to generate P5′ (20×20×256) (last level of Neck).

[0046] The final model structure is as follows Figure 1 shown.

[0047] Step 3: Trajectory judgment After the image is detected by the Yolo model, two types of targets are obtained. One is the head detection frame of the cow, and the other is the torso detection frame. The center points of the frames are taken as the head coordinates and the tail coordinates, and then connected into a straight line L. When the cow moves, because Deepsort tracks the unique ID on each cow's ear tag, the pixel value of the position movement can be obtained, and the points whose movement position exceeds the threshold are added to the trajectory calculation. Furthermore, the IOU threshold is increased for the data initially obtained by the Yolo model to better serve Deepsort tracking.

[0048] The trajectory is smoothed, and the entry and exit directions (in / out) are determined by the offset direction of the straight line L. The initial judgment window is set to 10, and the movement threshold is set to 25. When the judgment window reaches the set value, the head and tail coordinates are subtracted, the tangent value is calculated, and a straight line is fitted in the direction, with the head end in front, and an arrow is used to indicate the direction of the cattle's movement trajectory.

[0049] When a cow is detected to have completed entry or exit (e.g., completely passed through a gate), a command can be sent to the controller (e.g., starting milking equipment or closing the gate). Response time: The delay from recognition to signal transmission is ≤ 200ms, meeting real-time requirements.

[0050] Taking a 200-meter-long cattle shed on a ranch as an example, a single camera (model: HikvisionDS-2CD2347G2-LSU / SL) is installed directly above the gate, with a field of view covering a range of 10 meters. Only a single camera and an edge computing box (processor) are needed to realize cattle behavior recognition and calculation. Figure 4 、 5 , the above-mentioned cattle out-of-shed trajectory recognition method was used to monitor cattle, and 500 entry and exit behaviors were detected, with a behavior recognition accuracy of 98.7%. The existing conventional model recognition rate is only 95%, and when multiple cows overlap, the missed detection rate is 10%. Our model can still guarantee an accuracy rate of 97% even in the face of multiple cows overlapping. The application scheme is used for cattle behavior recognition. In terms of hardware equipment deployment, a single camera is deployed. Installation does not require a cattle-free environment, which is easy to operate and the construction window is shortened to 20 minutes, adapting to the daily management rhythm of the ranch. Furthermore, the number of devices is reduced by 90%, and the computing power requirement only requires an edge computing box (RK3588 chip). The edge computing device consumes only 10W, which is 95% less energy than the traditional server solution (200W), and the overall cost is reduced by 90%. In addition, a single camera covers key areas through a wide-angle lens, avoiding redundant data caused by overlapping perspectives of multiple cameras.

[0051] In this application, target detection + multi-target DeepSort tracking algorithm is adopted, with a false detection rate of <1%. Compared with traditional DeepSort, this part is mainly based on the dense distribution characteristics of cattle herds. The YOLO output box coordinates are re-sorted by vertical segmentation + adjacent IoU and then fed to DeepSort to reduce redundant matching in the same frame. This is mainly to adapt to the cattle herd scene and prevent the trajectory from being broken due to short occlusion of multiple cattle. The solution meets the needs of high-density cattle herd scenes. P-CBS + lightweight neck is used for model pruning, which reduces calculation parameters, realizes lightweight calculation, and realizes real-time inference on edge devices.

[0052] Example 2 An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement a method for identifying cattle trajectories as provided in the above method embodiment.

[0053] Example 3 The embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to a method for implementing a cattle-out-of-house trajectory identification method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement a cattle-out-of-house trajectory identification method provided in the above method embodiment. Optionally, in this embodiment, the above-mentioned storage medium can be located in at least one network server among a plurality of network servers in a computer network. Optionally, in this embodiment, the above-mentioned storage medium can include but is not limited to: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0054] With the above-described preferred embodiments of the present invention as a guide, and with reference to the above description, relevant personnel are fully capable of making various changes and modifications without departing from the technical spirit of this invention. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.

Claims

1. A method for identifying cattle trajectories, characterized in that: include, Step 1: Use a single wide-angle camera to obtain images of the entrance and exit locations of the cowshed; Step 2: Identify the key points of the cow's head and torso based on the improved YOLOv8 model, and obtain the cow's head detection frame and torso detection frame; The convolutional layers in the backbone network of the improved YOLOv8 model are replaced with P-CBS modules, and the I-MAB multi-scale attention mechanism is added to the neck network. The I-MAB multi-scale attention mechanism consists of two parts: a lightweight multi-scale large-core attention module and a gated spatial attention unit. The lightweight multi-scale large-core attention module includes a GhostConv branch, an expanded DW-Conv branch, and a re-parameterized large-core branch. The features are processed by the GhostConv branch, the expanded DW-Conv branch, and the re-parameterized large-core branch respectively, and then spliced ​​and output; In the gated spatial attention unit, a dual-branch prior is first performed after feature input. The dual-branch prior includes a spatial / directional prior and a channel prior. After completing the dual-branch prior, the output results of the two branches are fused through multiplicative gating; the fused features are convolved using a geometric alignment method, and finally the output of the geometrically aligned convolution is added to the residual of the original input and element-wise added as the final output of the gated spatial attention unit; Step 3: Determine the cow's movement trajectory based on the cow's head detection frame and torso detection frame.

2. The method for identifying cattle shed trajectories according to claim 1, characterized in that: The GhostConv branch compresses the channel with 1×1 point-by-point convolution and then uses 3×3 depth-wise separable convolution to generate pseudo features; the dilated DW-Conv branch uses 7×7 depth-wise separable convolution with an expansion rate of 2 to 3, so that the equivalent receptive field reaches approximately 19×19; the re-parameterized large kernel branch uses two-level 3×3 or 5×5 separable convolution stacks during training, and merges them into a static 11×11 depth-wise convolution kernel at one time during inference.

3. The method for identifying cattle shed trajectories according to claim 1, characterized in that: In step three, the center points of the cow's head detection frame and the torso detection frame are respectively taken to obtain the head coordinates and the tail coordinates, which are then connected into a straight line L, with the head coordinates as the front, to determine the direction of the cow.

4. The method for identifying cattle shed trajectories according to claim 3, characterized in that: In step three, when the cow moves, Deepsort is used to track the unique ID on each cow's ear tag, and the pixel value of the position movement is obtained. The points whose movement positions exceed the threshold are added to the trajectory calculation, the trajectory is smoothed, and the entry and exit directions are determined by the offset direction of the straight line L. The initial judgment window is set to 10, and the movement threshold is set to 25. When the judgment window reaches the set value, the head and tail coordinates are subtracted, the tangent value is calculated, and a straight line of the direction is fitted.

5. The method for identifying cattle shed trajectories according to claim 1, characterized in that: The feature map is input into the P-CBS module, the feature map is first divided, then passed through sparse partial conv to reduce parameters, passed through batchnorm and silu activation functions, and finally the feature map is obtained.

6. A computer device, characterized in that: include: processor; a memory for storing executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the cattle exit trajectory identification method according to any one of claims 1 to 5.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the cattle-outlet trajectory identification method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Construction method of lightweight algae target detection algorithm Alga-YOLO based on YOLOv5

    CN115601559A

  • Multi-head cattle identification and tracking algorithm based on improved YOLOv10s

    CN119418396A

  • Transformer substation secondary circuit intelligent identification method based on multi-scale large kernel attention YOLOV8

    CN119625708A

  • Method for recognizing abnormal driving posture of personnel in cab based on improved YOLOv8

    CN120071426A