A machine vision inspection method for detecting behaviors of farm goats

By combining autonomous orbital navigation with multi-source visual data acquisition, along with a customized CP-YOLO algorithm and lightweight optimization, a closed loop for behavioral time-series analysis and health early warning is constructed. This solves the problems of low efficiency, misjudgment and missed detection, and poor algorithm adaptability in existing technologies, and achieves accurate identification of goat behavior and early warning of diseases.

CN122289873APending Publication Date: 2026-06-26SHANDONG AGRICULTURAL UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG AGRICULTURAL UNIVERSITY
Filing Date
2026-04-23
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing technologies cannot meet the needs of intelligent farming. They suffer from problems such as low efficiency of manual inspection, misjudgment and missed detection, poor adaptability of machine vision algorithms, insufficient real-time performance, and lack of behavior-health correlation closed loop, resulting in delayed early warning of goat diseases and high false alarm rate.

Method used

By employing autonomous orbital navigation and multi-source visual data acquisition, combined with a customized CP-YOLO algorithm and lightweight optimization, real-time edge processing is achieved, constructing a closed loop for behavioral temporal analysis and health early warning. Through cross-level feature fusion, deformable attention downsampling, and multi-branch dilatation feature extraction, combined with infrared body temperature data for individual binding and secondary re-inspection, a complete machine vision inspection method is formed.

Benefits of technology

It has achieved unmanned visual data collection across the entire area, improved the accuracy and real-time performance of behavior recognition, reduced the false alarm rate, enabled early detection and accurate warning of goat diseases, and met the intelligent management needs of large-scale breeding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289873A_ABST
    Figure CN122289873A_ABST
Patent Text Reader

Abstract

This invention relates to the field of intelligent monitoring technology for large-scale goat farming, and provides a machine vision inspection method for goat behavior detection in farms. Its core features include track-based autonomous navigation, multi-source machine vision acquisition, customized CP-YOLO algorithm recognition, and behavioral temporal health correlation. The method achieves unmanned acquisition of multi-source visual data on goat behavior in the farming area through track-based autonomous navigation. It utilizes a lightweight CP-YOLO algorithm that combines cross-level adaptive feature fusion, deformable attention downsampling, and multi-branch dilated feature extraction to achieve high-precision real-time visual recognition of goat behavior in complex farming environments. Furthermore, it establishes a closed-loop transformation from abnormal behavior to health warnings through quantitative judgment of behavioral temporal anomalies and a secondary review mechanism. This invention completely replaces manual inspections, overcoming challenges such as variable lighting, dust interference, and limb occlusion, enabling automated detection, real-time recognition, and early disease warning of goats, thus meeting the intelligent inspection needs of large-scale goat farms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent monitoring technology for large-scale goat farming, and particularly relates to a machine vision inspection method for detecting goat behavior in a farm. Background Technology

[0002] With the large-scale and intensive development of my country's livestock industry, goat farming has become one of the core branches of animal husbandry. Goat behavioral characteristics are the core basis for judging their health status and achieving early disease warning; therefore, behavioral detection and inspection are key links in large-scale farming management. Currently, goat behavioral detection and inspection technologies in farms have four core deficiencies, failing to meet the needs of intelligent farming upgrades: First, manual inspection methods are inefficient and unreliable: traditional goat behavior inspections rely on manual inspection of each pen and visual observation, which requires a large amount of human resources, has a limited coverage area, and is extremely inefficient; at the same time, the inspection results are greatly affected by the experience, work status, and subjective judgment of the personnel, which can easily lead to inspection omissions, misjudgments, and missed judgments, directly resulting in delayed early warning of goat diseases, triggering the spread of group diseases and causing serious economic losses.

[0003] Second, existing machine vision inspection methods lack adaptability: most existing machine vision inspection methods use general target detection algorithms and have not been customized and optimized for goat body shape features, limb movement patterns, and group occlusion characteristics. In complex scenarios such as variable lighting, dust interference, and overlapping occlusion of goat limbs in farms, the algorithms have weak ability to extract key features of goat behavior, low behavior recognition accuracy, and poor scene generalization ability, and cannot reliably complete accurate detection of goat behavior.

[0004] Third, existing visual algorithms are not lightweight and lack real-time performance: Most existing behavior recognition visual algorithms are general models with a large number of parameters. They have not been optimized for lightweighting due to the computing power limitations of edge computing units. When deployed on embedded edge devices, they have slow inference speed and high latency, and cannot process high-definition video streams in real time. This results in significant lag in behavior detection and inspection, which cannot meet the engineering requirements for real-time inspection.

[0005] Fourth, the lack of a closed-loop link between behavior and health means that detection alone does not provide early warning: Existing machine vision inspection methods can only classify and identify basic behaviors of goats, but have not built a quantitative mapping model between behavioral temporal features, physiological indicators and health status. This makes it impossible to convert abnormal behaviors such as lameness, refusal to eat, and prolonged lying down into early warnings of diseases. At the same time, the lack of an abnormal re-inspection mechanism leads to a high false alarm rate, and the failure to achieve individual identification makes it impossible to accurately locate abnormal targets. The lack of a complete inspection closed loop of "visual acquisition - behavior recognition - temporal analysis - health warning - decision feedback" makes it difficult to achieve precise disease prevention and control in large-scale farming.

[0006] Therefore, a machine vision inspection method for detecting goat behavior in farms is needed to solve the above problems. Summary of the Invention

[0007] The purpose of this invention is to provide a machine vision inspection method for detecting goat behavior in a farm to solve the problems mentioned in the background art.

[0008] To achieve the above objectives, the present invention provides the following technical solution: A machine vision inspection method for detecting goat behavior in a livestock farm includes the following steps: S1. System initialization and environmental perception: Complete hardware initialization and operation parameter configuration for the track-type inspection robot, visual perception module, edge computing unit, central control module, behavior time sequence health association module, early warning component and power management module. Collect track and breeding area environmental data in real time through pathfinding and obstacle avoidance component to build environmental perception map and realize the forward perception of inspection path. S2. Autonomous cruise and multi-source visual data acquisition: The central control module dispatches the track walking mechanism to perform full-coverage cruise along the complex curvature track of the farm from 0° to 180°. The visual perception module simultaneously collects RGB image data of goat behavior and infrared body temperature image data. After multi-dimensional data enhancement preprocessing, the timestamp-aligned visual data is transmitted to the edge computing unit in real time. S3. Edge-side machine vision behavior recognition: The edge computing unit calls the CP-YOLO goat behavior recognition algorithm to process the visual data. The algorithm sequentially completes the extraction and classification of goat behavior features through cross-level adaptive feature fusion, deformable attention downsampling, and multi-branch dilatation feature extraction, and simultaneously realizes the binding of individual goat IDs and behavior data. The algorithm is optimized for lightweight edge hardware computing power to realize real-time inference processing of high-definition video streams at the edge. S4. Behavioral temporal analysis and health early warning judgment: The behavioral temporal health association module compares the real-time identification results, individual ID, infrared body temperature data with the preset goat health behavior benchmark library and abnormal behavior feature library. Based on the continuous frame judgment rule under the standard frame rate, it distinguishes between normal and abnormal behaviors. Abnormal behaviors trigger secondary re-examination and verification. After the verification is passed, multi-channel early warning operations are executed, and normal behavior data is uploaded to the visual monitoring terminal. S5, Endurance Guarantee and Full-Process Inspection Monitoring: The power management module monitors the robot's power status and the power consumption of each module in real time. When the power is low, the robot is scheduled to mark the inspection breakpoint and then return to charge autonomously. Throughout the process, the inspection status, visual recognition results, individual health data, and early warning information are synchronized to the visual monitoring terminal to form a closed-loop machine vision inspection and control system.

[0009] The three-layer core architecture of this invention is as follows: First layer (basic layer): Autonomous orbital navigation + multi-source visual acquisition → Achieve unmanned visual data acquisition in the whole area through automated navigation, and simultaneously integrate RGB visual and infrared body temperature dual-dimensional data to fundamentally solve the problems of inefficiency, missed detection and subjective misjudgment of manual inspection.

[0010] The second level (advanced level): Customized CP-YOLO algorithm + lightweight optimization → Through the collaborative optimization of three feature extraction modules, customized improvements are made for goat behavior features to improve the accuracy of behavior recognition in complex scenarios; lightweight optimization enables real-time inference on edge devices, solving the problems of inaccuracy and inference delay of general algorithms.

[0011] The third layer (core layer): Behavioral time sequence analysis + individual binding + secondary re-examination + multi-channel early warning → constructing a quantitative closed loop from visual recognition to health early warning, solving the problems of detection without early warning, delayed early warning, high false alarm rate, and inability to locate abnormal individuals.

[0012] Further technical solutions: In S2, the visual perception module integrates a 1080P resolution RGB camera, an uncooled infrared thermal imager, a 2-axis motorized gimbal, and an optical zoom lens. It performs multi-dimensional data enhancement processing on the acquired images, including spatial enhancement, pixel enhancement, and Mosaic enhancement, to eliminate image noise caused by uneven lighting and dust interference, and improve the generalization ability of visual data in complex breeding scenarios. The goat body temperature data acquired by the infrared thermal imager is simultaneously incorporated into the health early warning judgment system and matched with the normal body temperature threshold range of goats.

[0013] In the further technical solution S3, the CP-YOLO goat behavior recognition algorithm is based on the YOLOv8 backbone network and customized for goat behavior features. It is built on a deep learning framework and uses a stochastic gradient descent optimizer to complete model training. Through a multi-dimensional joint loss function, it achieves joint convergence constraints for target localization, confidence prediction, behavior classification and individual weight recognition, ensuring stable model training convergence and simultaneously constraining the accuracy of target localization, confidence, behavior classification and individual recognition, thereby comprehensively improving the accuracy of visual recognition.

[0014] In the further technical solution S3, the CP-YOLO goat behavior recognition algorithm can identify the normal / abnormal states of five typical behaviors of goats: standing, walking, running, lying down, and foraging. Based on a standard frame rate of 25 FPS, each type of behavior is configured with quantitative feature definition, continuous frame judgment rules, and abnormal behavior judgment thresholds to avoid misjudgment of single-frame images, accurately match goat behavior features with health association logic, and improve the reliability of abnormal behavior detection.

[0015] Further technical solution: In S3, the CP-YOLO goat behavior recognition algorithm is optimized by channel pruning based on BN layer scaling factor and TensorRT precision quantization lightweight optimization. Under the premise of accuracy loss ≤1%, the model volume is compressed and the inference speed is improved. It is adapted to the hardware computing power of the edge computing unit and realizes real-time inference processing of 1080P video stream at more than 25FPS on the edge side, which meets the real-time requirements of inspection.

[0016] Further technical solution: In S2, the track walking mechanism is adapted to the complex curvature track of the breeding farm from 0° to 180°. With the help of the path finding and obstacle avoidance components and the multi-degree-of-freedom gimbal camera, it can realize full coverage of visual data collection of preset monitoring points in the breeding area without blind spots, and ensure the integrity of visual data collection.

[0017] Further technical solutions: In S4, after abnormal behavior is determined, the central control module immediately suspends the current patrol mission, prioritizes scheduling the gimbal to turn to the abnormal area, and uses the zoom lens to magnify and collect high-definition images to complete secondary verification; if the robot has left the abnormal area, it immediately returns to the abnormal coordinates at the highest speed, locks the abnormal individual through the target tracking algorithm to complete secondary visual data collection and recognition verification, eliminates environmental interference and single-frame misjudgment, and reduces the false alarm rate of inspection.

[0018] In the further technical solution S4, the early warning operation includes the simultaneous execution of local audible and visual alarms and remote information push. The pushed information includes the abnormal individual ID, abnormal behavior type, associated health risk, abnormal location and body temperature data, realizing multi-channel health early warning notification, ensuring that early warning information reaches the public in a timely manner, and enabling rapid handling of potential epidemic risks.

[0019] Further technical solutions: In S5, autonomous return charging is performed in collaboration between the autonomous charging component and the power management module. After the robot is fully charged, it automatically returns to the inspection breakpoint to continue the task, enabling continuous unmanned machine visual inspection operations with a single flight time of ≥8 hours, thereby improving the continuity of inspection.

[0020] Further technical solutions: In S5, the visualization monitoring terminal realizes the visualization display of inspection data, monitoring of system operation status, query of individual goat health records, tracing of historical early warning information, and issuance of remote inspection instructions, completing the digital control of the entire machine vision inspection process and improving the convenience of breeding management.

[0021] Compared with the prior art, the beneficial effects of the present invention are: This invention completely replaces manual inspection by autonomous orbital navigation and multi-source visual data acquisition, eliminating reliance on manpower, inspection oversights, and subjective misjudgments. It simultaneously collects dual-dimensional data of RGB vision and infrared body temperature, fundamentally solving the problems of low efficiency, missed inspections, misjudgments, and high costs associated with manual inspection. This invention, through the collaborative optimization of three major modules of the CP-YOLO algorithm—cross-level adaptive feature fusion, deformable attention downsampling, and multi-branch dilatation feature extraction—is customized to improve the body shape and behavioral characteristics of goats. It specifically enhances the ability to extract key behavioral features of goats, effectively overcoming interference from scenes such as lighting, dust, and occlusion. In complex environments, the mAP@0.5 for behavior recognition reaches 94.2%, solving the problems of poor adaptability, low recognition accuracy, and weak generalization ability of general vision algorithms. This invention achieves a 40% reduction in model size and a 50% increase in inference speed with a loss of ≤1% through channel pruning and TensorRT quantization lightweight optimization. It is adapted to the hardware conditions of edge computing units and enables real-time inference of 1080P video streams at more than 25 FPS on Jetson edge devices, solving the problems of slow inference and delayed inspection in existing algorithms. This invention, through quantitative judgment of behavioral anomalies, individual ID binding, and a secondary re-examination mechanism, integrates infrared body temperature data to transform visual recognition results into accurate and actionable health warnings, forming a complete closed loop of "collection-identification-analysis-early warning-re-examination-treatment". This enables early detection and early warning of goat diseases, solving the problems of existing methods that only detect without warning, delayed warnings, high false alarm rates, and inability to locate abnormal individuals, thus promoting the upgrading of goat farming towards precision and intelligence.

[0022] To more clearly illustrate the structural features and effects of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. Attached Figure Description

[0023] Figure 1 This is a schematic diagram of the overall process of the present invention, which fully demonstrates the five core steps S1-S5 and presents the core working closed loop of "data collection - intelligent analysis - decision feedback - battery life guarantee". Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0025] The specific implementation of the present invention will be described in detail below with reference to specific embodiments.

[0026] like Figure 1As shown, this invention provides a machine vision inspection method for detecting goat behavior in a farm. It relies on a track-mounted inspection robot, a visual perception module, an edge computing unit, a central control module, a behavior-sequence health correlation module, an early warning component, a power management module, and a visual monitoring terminal working together. The implementation process of this invention will be described in detail below, combining the specific application of the core formulas and parameter definitions: In this embodiment, the track-based inspection robot body adopts a track-based cruising device specifically designed for large-scale livestock farming. The track walking mechanism is a dual-drive tracked structure, adaptable to complex curvature tracks of 0°-180° in livestock farms. The pathfinding and obstacle avoidance component uses a LiDAR + visual fusion perception module to collect track obstacle information in real time. The autonomous charging component is a spring-loaded contact charging structure that matches and docks with the charging base at the end of the track. The visual perception module integrates a 1080P resolution RGB camera, an uncooled infrared thermal imager, a 2-axis motorized gimbal, an optical zoom lens, and an image preprocessing unit. The edge computing unit uses an NVIDIA Jetson Xavier NX embedded chip and is equipped with the CP-YOLO goat behavior recognition algorithm. The central control module uses an industrial-grade STM32H7 main control chip and has a built-in anomaly re-inspection unit. The behavior time-series health association module has a built-in goat health behavior benchmark library, an abnormal behavior feature library, and early warning mapping rules. The early warning component integrates an audible and visual alarm unit and a remote information push unit. The power management module is a lithium battery intelligent management system. The visual monitoring terminal is a PC-based web platform + mobile app.

[0027] S1. System Initialization and Environmental Awareness: In this embodiment, the first step is as follows: After the system is powered on, the power management module starts the full hardware initialization process to complete the parameter configuration of the clock signal, communication interface, and control module; the central control module reads the preset cruise path, behavior judgment threshold, and algorithm running parameters to complete the system self-check; the pathfinding and obstacle avoidance component starts to collect real-time track and aquaculture area environmental data to build an environmental perception map, ensuring accurate obstacle avoidance during subsequent cruise processes and providing a stable operating foundation for machine vision inspection.

[0028] S2, Autonomous Cruise and Multi-Source Visual Data Acquisition: In this embodiment, the second step is executed: the central control module issues a cruise command to the track-walking mechanism, and the robot moves at a constant speed along a complex curvature track of 0°-180°, achieving full coverage of the preset monitoring points in the breeding area without blind spots, in conjunction with a multi-degree-of-freedom gimbal camera; the visual perception module works simultaneously, with an RGB camera acquiring color images and video streams of goat behavior, and an infrared thermal imager acquiring body temperature data and low-light environment behavior images, and the two types of data are time-stamped and strictly aligned through hardware triggering; the image preprocessing unit performs multi-dimensional data enhancement processing on the acquired raw images, including spatial enhancement, pixel enhancement, and Mosaic enhancement, to eliminate image noise caused by uneven lighting and dust interference, and improve the scene generalization ability of visual data; the processed visual data is transmitted to the edge computing unit in real time via gigabit Ethernet to provide standardized input data for subsequent behavior recognition; the normal body temperature threshold for goats is set at 38.5-40℃, and those exceeding this range are directly included in the health abnormality judgment dimension.

[0029] S3, Edge-side machine vision behavior recognition: In this embodiment, the third step is performed: After receiving visual data, the edge computing unit starts the CP-YOLO goat behavior recognition algorithm to complete real-time inference. The algorithm is built on the PyTorch deep learning framework and trained using an NVIDIA RTX 4090 GPU. The training batch size is 16, the initial learning rate is 0.01, and a cosine annealing learning rate adjustment strategy is used. The training epochs are 300. The core formula is applied in the following way: Multi-dimensional joint loss function (model training convergence constraint): During the algorithm training phase, the total loss function is used to constrain model convergence, and the formula is as follows: ; in: This represents the total loss value of the algorithm. The target localization loss for goats is responsible for constraining the positional matching degree between the predicted bounding box and the ground truth bounding box. This is the behavior confidence loss, responsible for constraining the confidence accuracy of behavior recognition; The behavior classification loss is responsible for constraining the accuracy of goat behavior classification; The weight recognition loss is used to constrain the distinguishability of individual goat features and to bind individual IDs to behavioral data.

[0030] Detailed implementation of the sub-formula: (1) CIoU positioning loss formula: ; in: This is the intersection-union ratio (IoU) between the predicted bounding box and the ground truth bounding box. The distance between the center points of the predicted bounding box and the ground truth bounding box is Euclidean distance. The length of the diagonal of the minimum bounding rectangle; The actual frame width and height; To predict the width and height of the bounding box; These are the weighting coefficients; This is a parameter for aspect ratio consistency.

[0031] Implementation results: This sub-formula accurately constrains the positioning accuracy of the goat target, solving the positioning offset problem caused by limb occlusion.

[0032] (2) Confidence loss formula: ; in: This represents the number of training samples; True confidence level label; The confidence level is predicted for the algorithm.

[0033] Implementation effect: The confidence output of constraint behavior recognition reduces the probability of false recognition with low confidence.

[0034] (3) Classification loss formula: ; in: There are a total of 10 categories for the normal / abnormal states of 5 types of behavior: standing, walking, running, lying down, and foraging. For the first The first sample The true label of class behavior; To predict probabilities for the algorithm.

[0035] Implementation results: It enables accurate classification of five types of behaviors into normal / abnormal states, and distinguishes the characteristic differences and health attributes of different behaviors.

[0036] (4) Formula for weight recognition loss: ; in: The number of individual goat IDs; For the first The first sample The true label of an individual; To predict probabilities for the algorithm.

[0037] Implementation results: It enables accurate identification and ID binding of individual goats, solving the problem of being unable to locate abnormal individuals in large-scale farming.

[0038] Cross-level adaptive feature fusion (feature enhancement): During algorithm inference, the 16x downsampled feature map is used as the baseline feature map among the three scale feature maps output by the YOLOv8 backbone network (downsampled by 8x, 16x, and 32x). Perform adaptive weighted fusion: ; in: For the first Adaptive weights for layer feature maps; For the first Layer feature map; This is the fused feature map.

[0039] Implementation results: Dynamically enhances key behavioral features such as the goat's mouth, limbs, and torso, suppresses invalid background features, and improves feature representation capabilities in complex scenarios.

[0040] Deformable attention downsampling (occlusion adaptation): Instead of the traditional downsampling layer, deformable attention-weighted downsampling is performed based on the 3×3 receptive field region. This combines the adaptive sampling of deformable convolution with the feature weighting capabilities of the attention mechanism, as shown in the formula: ; in: For feature map pixels; This refers to the sampling point offset for network adaptive learning; The receptive field area is 3×3. It is a 1×1 convolutional feature mapping function; Pixel attention weights; This represents the downsampled output features.

[0041] Implementation results: By using adaptive offset sampling to focus on key parts of the goat's limbs, joints, mouth, etc., the feature loss caused by group occlusion is reduced, and the robustness of recognition in occluded scenes is improved.

[0042] Multi-branch dilation feature extraction (pose capture): A three-parallel dilated convolution branch + residual connection structure is adopted, with dilation rates of 1, 2, and 3, respectively, to avoid the mesh effect caused by a large dilation rate. The formula is as follows: ; in: , , For convolution operations with dilation rates of 1, 2, and 3; Input feature map; For channel-dimensional splicing; This is a feature of multi-branch fusion.

[0043] Implementation results: Branch 1 of the expansion rate captures local details such as mouth opening and closing, branch 2 of the expansion rate captures mesoscale features such as trunk posture, and branch 3 of the expansion rate captures macroscale features such as overall movement. Simultaneously, it captures multiscale behavioral features of goats and completes accurate classification of 5 types of normal / abnormal behavioral states.

[0044] Sparse training loss (lightweight optimization): The algorithm is optimized by channel pruning based on BN layer scaling factor and lightweight quantization using TensorRTFP16 precision quantization. The sparse training loss formula is as follows: ; in: The sparsity coefficient; This is the scaling factor for the BN layer; This is the set of scaling factors for all BN layers; This represents the total loss due to sparsification.

[0045] Implementation results: By removing redundant channels, the model volume was compressed by 40% and the inference speed was increased by 50% while the accuracy loss was ≤1%. Real-time inference of 1080P video stream at more than 25 FPS was achieved on Jetson Xavier NX, meeting the real-time requirements of inspection.

[0046] Behavior quantification and continuous frame determination: After the algorithm completes inference, it outputs the normal / abnormal state identification results for five types of goat behaviors: standing, walking, running, lying down, and foraging. Simultaneously, it binds the individual goat ID and performs a preliminary judgment based on continuous frame judgment rules at a standard frame rate of 25 FPS. The results are transmitted to the central control module in real time. The specific definition rules are as follows: (1) Foraging behavior: In a normal state, the goat's head is tilted downwards at 30°-75°, the mouth is in continuous contact with the feed and the lower jaw opens and closes regularly at 1.2-2.5 times / second, the limbs are standing and supporting the body without tilting to the side, and a single foraging lasts for ≥15 seconds; if the three consecutive frames are within the normal range, it is considered normal; abnormal states are head tilt angle <10° or >85°, mouth not in contact with feed but making opening and closing movements, lower jaw opening and closing frequency <0.5 times / second or >4 times / second, no foraging within 10 minutes after feeding, single foraging lasts <5 seconds and is frequently interrupted; if any abnormal feature is captured in five consecutive frames, it is considered abnormal and associated with loss of appetite and oral disease health warning.

[0047] (2) Running behavior: In the normal state, the goat alternately pushes off the ground with its four limbs and leaps into the air. The leap distance is 0.8-1.2 times the body length. The body lunges forward horizontally, and the angle between the head and the body's central axis is ≤10°. The running speed is 1.5-3m / s. It is mostly a group play and lasts for 5-30 seconds. Four consecutive frames that meet the normal range are considered normal. Abnormal state is uncoordinated limb movement, dragging a single limb on the ground, body arching / sinking angle ≥20°, running continuously for more than 60 seconds without cause, speed >4m / s and sudden stopping to hit an obstacle. If any abnormal feature is detected in three consecutive frames, it is considered abnormal and associated with limb injury, stress response and health warning.

[0048] (3) Standing behavior: In the normal state, the goat’s four limbs are evenly supported vertically on the ground, the deviation of the body’s central axis from the ground is ≤5°, the head can turn naturally left and right 0°-90°, and there is no frequent leg-changing action; two consecutive frames that meet the normal range are judged as normal; the abnormal state is that one or both limbs are raised without touching the ground, the deviation of the body’s verticality is ≥15°, the head is stiff and the turning angle is <10°, and the goat stands continuously for more than 120 minutes without any cause; if any abnormal feature is captured in four consecutive frames, it is judged as abnormal and associated with limb joint diseases and abnormal nervous system health warnings.

[0049] (4) Walking behavior: In the normal state, the goat walks slowly and alternately with its four limbs, with a stride length of 2-3 times the hoof length, a stride frequency of 0.8-1.5 steps / second, a stable body without swaying, a walking speed of 0.3-0.8m / s and a regular trajectory; three consecutive frames that meet the normal range are considered normal; abnormal states are stride length / stride frequency exceeding the normal range, body swaying amplitude ≥10° during walking, lameness, aimless circling in place, and sudden increase in speed; any abnormal feature detected in three consecutive frames is considered abnormal, and associated with limb lameness and eye disease health warnings.

[0050] (5) Lying down behavior: The normal state is that the goat lies on its side / prone. When lying on its side, the angle between the body and the ground is 15°-30°, the limbs are naturally bent and tucked in, and it can lie down and rest for 10-60 minutes at a time and can get up smoothly on its own. Two consecutive frames that meet the normal range are judged as normal. Abnormal state is when the angle between the body and the ground is <5° or >45°, the limbs are stiff and extended, lying down continuously for more than 120 minutes without cause, unable to get up on its own, accompanied by body twitching. If any abnormal feature is captured in five consecutive frames, it is judged as abnormal and associated with serious physical diseases and high risk of high fever.

[0051] S4. Behavioral Sequence Analysis and Health Early Warning Judgment: This embodiment executes the fourth step: the behavior time-series health association module calls the behavior time-series anomaly degree formula to complete the quantitative judgment of abnormal behavior. The formula is: ; in: Determining the degree of behavioral abnormality; To determine the number of consecutive frames; For the first Frame action recognition results; This is a database of abnormal behavior characteristics. This is an indicator function that takes the value 1 when an abnormal condition is met and 0 when it is normal.

[0052] Threshold setting and implementation: Foraging anomaly threshold 0.6, running anomaly threshold 0.5, standing anomaly threshold 0.7, walking anomaly threshold 0.6, lying down anomaly threshold 0.8; if Any temperature exceeding the corresponding threshold, or infrared body temperature data exceeding the normal range of 38.5-40℃, is considered abnormal behavior.

[0053] Re-inspection and early warning implementation: After an anomaly is triggered, the anomaly re-inspection unit immediately suspends the current patrol mission, prioritizes the gimbal to turn to the anomaly area, and uses the zoom lens to magnify and collect high-definition images to complete secondary recognition and verification; if the robot has left the anomaly area, it immediately returns to the anomaly coordinates at the highest speed, uses the target tracking algorithm to lock the anomaly individual to complete secondary acquisition and verification, and eliminates environmental interference and single-frame misjudgment; after the secondary verification confirms the anomaly, the early warning component simultaneously activates the local alarm unit of the sound and light alarm unit and the mobile terminal push of the remote information push unit, and synchronously uploads the anomaly individual ID, abnormal behavior type, associated health risk, abnormal location, and body temperature data to the visual monitoring terminal.

[0054] S5, Battery Life Guarantee and Full-Process Inspection and Monitoring: In this embodiment, the fifth step is performed: the power management module monitors the robot's battery voltage, current, remaining power, and power consumption of each module in real time. When the power is below 20%, a charging signal is sent to the central control module. After the central control module marks the current inspection breakpoint, it dispatches the track walking mechanism to autonomously return to the charging base. The autonomous charging component completes automatic charging. After being fully charged, it automatically returns to the breakpoint to continue the inspection task, ensuring that the robot can continuously perform inspection operations for ≥8 hours on a single charge. Throughout the process, the inspection progress, algorithm recognition status, battery power, individual health data, and early warning information are synchronized to the visual monitoring terminal. Farmers can use the terminal to query the individual health records of goats, trace historical early warning information, and remotely issue commands to adjust the cruise path and calibrate recognition parameters, realizing the full-process digital and remote control of machine vision inspection.

[0055] This embodiment fully implements the method of the present invention through the above steps. After on-site testing in a large-scale goat farm, under complex scenarios with variable lighting, dust interference, and limb occlusion, the behavior recognition mAP@0.5 reaches 94.2%, the edge inference latency is ≤40ms, and the health warning accuracy rate is over 92%, which fully meets the machine vision inspection needs for goat behavior detection in the farm.

[0056] This invention uses "visual data acquisition - machine vision recognition - time-series analysis and early warning - battery life monitoring" as its core working loop, and combines a core algorithm model to achieve automated machine vision inspection of goat behavior in livestock farms. The detailed working principle is as follows: 1. System Initialization and Environmental Awareness: After the power management module is powered on, it starts a full hardware initialization process to complete the configuration of clock, communication interface, and control module parameters; the central control module loads operating parameters such as inspection path and recognition threshold and completes system self-test; the pathfinding and obstacle avoidance component collects track and aquaculture environment data in real time to provide an environmental awareness basis for autonomous navigation and ensure accurate obstacle avoidance during the inspection process.

[0057] 2. Autonomous navigation and multi-source visual data acquisition: The central control module sends navigation commands to the track walking mechanism, and the robot moves smoothly along the complex curvature track to achieve full coverage of the breeding area; the RGB camera of the visual perception module collects high-definition images of goat behavior, and the infrared thermal imager collects body temperature data and low-light environment images. After preprocessing, the two types of visual data are transmitted to the edge computing unit in real time to provide a standardized data source for visual recognition.

[0058] 3. Edge-side machine vision behavior recognition: The edge computing unit calls the CP-YOLO algorithm to complete real-time processing of visual data. The algorithm training adopts a multi-dimensional joint loss function to achieve convergence constraints, and simultaneously constrains the accuracy of localization, confidence, classification and individual recognition. In the inference stage, key features are strengthened through cross-level adaptive feature fusion, deformable attention downsampling is adapted to occlusion scenes, and multi-branch dilatation feature extraction is used to capture multi-scale behavioral features, so as to complete the accurate identification and individual binding of goat behavior in normal / abnormal states.

[0059] 4. Behavioral temporal analysis and health early warning judgment: The behavioral temporal health correlation module completes the quantitative judgment of abnormal behavior through the abnormality formula and integrates infrared body temperature data to improve the accuracy of early warning; after the abnormal behavior is triggered, the gimbal zoom and target tracking complete the secondary review, and after confirming the abnormality, the dual-channel early warning is triggered to complete the complete closed loop from visual recognition to health early warning.

[0060] 5. Endurance Guarantee and Full-Process Inspection and Monitoring: The power management module monitors the battery level in real time and sends a charging signal when the battery is low. The central control module schedules the robot to mark the breakpoint and return to charge autonomously. Once fully charged, the task is resumed. The inspection status, identification results, and early warning information are synchronized to the visualization terminal throughout the process. Farmers can remotely monitor and issue control commands to achieve closed-loop management of the entire process.

[0061] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A machine vision inspection method for detecting farm goat behavior, characterized in that, Comprise the following steps: S1, system initialization and environment perception: the track inspection robot, visual perception module, edge computing unit, central control module, behavior timing health correlation module, early warning component and power management module complete hardware initialization and running parameter configuration, real-time collection of track and breeding area environment data through the path finding and obstacle avoidance component, build environment perception map, realize the pre-sensing of the inspection path; S2, autonomous cruise and multi-source visual data collection: the central control module dispatches the track walking mechanism to execute full coverage cruise along the 0°-180° complex curvature track of the breeding farm, the visual perception module synchronously collects RGB image data and infrared body temperature image data of goat behavior, after multi-dimensional data enhancement preprocessing, the timestamp aligned visual data is transmitted to the edge computing unit in real time; S3, edge side machine vision behavior recognition: the edge computing unit calls the CP-YOLO goat behavior recognition algorithm to process the visual data, the algorithm sequentially completes goat behavior feature extraction and classification recognition through cross-level adaptive feature fusion, deformable attention downsampling and multi-branch inflation feature extraction, and synchronously realizes the binding of goat individual ID and behavior data; The algorithm is optimized and adapted to the edge hardware computing power, realizing the real-time inference processing of high-definition video stream on the edge side; S4, behavior timing analysis and health early warning determination: the behavior timing health correlation module compares the real-time recognition result, individual ID, infrared body temperature data with the preset goat health behavior benchmark library and abnormal behavior feature library, distinguishes normal and abnormal behavior based on the continuous frame determination rule under the standard frame rate, and executes multi-channel early warning operation after the secondary review verification, and the normal behavior data is uploaded to the visual monitoring terminal; S5, endurance guarantee and whole process inspection monitoring: the power management module monitors the robot power state and module power consumption in real time, and when the power is low, it dispatches the robot to mark the inspection breakpoint and returns to charge autonomously, and the inspection state, visual recognition result, individual health data and early warning information are synchronously uploaded to the visual monitoring terminal to form a closed loop machine vision inspection control.

2. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S2, the visual perception module integrates 1080P resolution RGB camera, uncooled infrared thermal imager, 2-axis electric pan-tilt and optical zoom lens, performs multi-dimensional data enhancement processing of spatial enhancement, pixel enhancement and Mosaic enhancement on the collected images, eliminates image noise caused by uneven light and dust interference, and improves the generalization ability of visual data in complex breeding scenes; The goat body temperature data collected by the infrared thermal imager is synchronously included in the health early warning determination system, and matched with the normal goat body temperature threshold range.

3. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S3, the CP-YOLO goat behavior recognition algorithm is based on the YOLOv8 backbone network and customized for goat behavior features, based on a deep learning framework, using a stochastic gradient descent optimizer to complete model training, and realizing joint convergence constraint of target positioning, confidence prediction, behavior classification and individual recognition through a multi-dimensional joint loss function.

4. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S3, the CP-YOLO goat behavior recognition algorithm can identify the normal / abnormal states of five typical behaviors of goats: standing, walking, running, lying down, and foraging. Based on a standard frame rate of 25 FPS, each type of behavior is configured with quantitative feature definition, continuous frame judgment rules and abnormal behavior judgment thresholds to avoid misjudgment of single frame images and accurately match goat behavior features with health association logic.

5. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S3, the CP-YOLO goat behavior recognition algorithm, after channel pruning based on BN layer scaling factor and TensorRT precision quantization lightweight optimization, compresses the model volume and improves the inference speed under the premise of accuracy loss ≤1%, adapts to the hardware computing power of edge computing unit, and realizes real-time inference processing of 1080P video stream at more than 25FPS on the edge side.

6. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S2, the track walking mechanism is adapted to the complex curvature track of the breeding farm from 0° to 180°. With the help of the path finding and obstacle avoidance components and the multi-degree-of-freedom gimbal camera, it can realize the full coverage of visual data collection of the preset monitoring points in the breeding area without blind spots, and ensure the integrity of visual data collection.

7. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S4, after abnormal behavior is determined, the central control module immediately suspends the current patrol mission, prioritizes scheduling the gimbal to turn to the abnormal area, and uses the zoom lens to magnify and collect high-definition images to complete secondary verification; if the robot has left the abnormal area, it immediately returns to the abnormal coordinates at the highest speed, locks the abnormal individual through the target tracking algorithm to complete secondary visual data collection and recognition verification, eliminates environmental interference and single-frame misjudgment, and reduces the inspection false alarm rate.

8. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S4, the early warning operation includes the simultaneous execution of local audible and visual alarms and remote information push. The push information includes the abnormal individual ID, abnormal behavior type, associated health risk, abnormal location and body temperature data, realizing multi-channel health early warning notification.

9. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S5, autonomous return charging is performed in collaboration between the autonomous charging component and the power management module. After the robot is fully charged, it automatically returns to the inspection breakpoint to continue the task, enabling continuous unmanned machine visual inspection operations with a single flight time of ≥8 hours.

10. The machine vision inspection method for detecting the behavior of farm goats according to claim 1, characterized in that, In S5, the visualization monitoring terminal realizes the visualization display of inspection data, monitoring of system operation status, query of individual goat health records, tracing of historical early warning information, and issuance of remote inspection instructions, thus completing the digital management and control of the entire machine vision inspection process.