Method and system for recognizing stereotyped behavior of captive goats based on time sequence video analysis
By analyzing time-series video, the static structure of the captive environment is used to separate the foreground target of goats, extract movement patterns and interaction dynamics features, and generate stereotyped behavior segments. This solves the problem of real-time monitoring of stereotyped behaviors in captive goats and enables all-weather, objective monitoring and precise intervention.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANCHONG ACAD OF AGRI SCI
- Filing Date
- 2026-04-22
- Publication Date
- 2026-06-16
AI Technical Summary
Existing technologies cannot effectively, in real time, and continuously monitor and identify stereotyped behaviors in captive goats, resulting in a lack of all-time, objective, and quantifiable monitoring methods for breeding management, making it impossible to intervene in stressed individuals in a timely manner and assess the effects of improvements to the feeding environment.
By analyzing time-series video, the static spatial structure of fences and fixed facilities is used to separate foreground targets, extract the motion pattern codes and interaction dynamics features of individual goats, and fuse them to generate stereotyped behavior fragments to achieve automated recognition.
It enables 24/7 objective monitoring of stereotyped behaviors in goats, accurately identifies the type and timing of stereotyped behaviors in each goat, supports scientific evaluation of improvements to the feeding environment and management strategies, and promotes the transformation of breeding decisions towards data-driven approaches.
Smart Images

Figure CN122223784A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to a method and system for recognizing stereotyped behaviors of captive goats based on time-series video analysis. Background Technology
[0002] In the field of animal behavior analysis, especially in welfare monitoring and health management, the use of computer vision technology to achieve automated behavior recognition has become an important development trend.
[0003] Stereotypical behaviors in animals refer to simple, monotonous, and purposeless behavioral patterns that animals repeatedly exhibit under captive or limited environmental conditions (such as repeatedly biting the fence, circling, or pacing). It is generally considered an important indicator of poor animal welfare, suggesting that the animal is experiencing physiological or psychological distress. Stereotypical behaviors are characterized by high repetition, fixed patterns, and regular spatiotemporal trajectories, which make them relatively easy targets for computer vision algorithms to capture and classify.
[0004] Goats are naturally active and energetic, adept at climbing and jumping; there's a saying in the industry: "Elite goats, lethargic sheep." However, with intensive penning, insufficient space for movement severely suppresses their natural instincts, leading to restlessness and stereotyped behaviors. These stereotyped behaviors are not only a sign of poor animal welfare but also directly impact the growth rate, health, and profitability of goats, especially meat goats. They continuously deplete the energy that goats should be using for growth, resulting in decreased feed conversion ratios, manifesting as "eating a lot but not growing" or slow weight gain. Over time, this also suppresses the goats' immune system, making them more prone to lethargy, loss of appetite, and ultimately, poor body condition, respiratory diseases, and other health problems.
[0005] Therefore, monitoring stereotyped behaviors in animals under intensive farming environments is a key requirement for improving the level of refined farming management. Achieving automatic and accurate identification of stereotyped behaviors in captive goats is significant for shifting farming management from "experience-driven" to "data-driven."
[0006] In existing technologies, there are two main technical approaches: For example, Chinese patent CN120236223A discloses a method and device for rapid assessment of abnormal animal behavior phenotypes, which obtains macroscopic behavioral characteristics by tracking key points on the animal's body and assesses its state based on the ratio of specific behavioral parameters; another example is Chinese patent CN112734275A, which discloses an evaluation method for hunger-related stereotyped behaviors in pregnant sows, using a method based on manual observation at fixed time points and statistical analysis of the proportion of individuals performing specific actions within a group to evaluate hunger-related stereotyped behaviors in specific animals (such as sows). However, the former is prone to key point tracking failure due to occlusion in scenarios with complex structured backgrounds, such as captive goats, and cannot effectively distinguish behaviors that appear similar but have different motivations; the latter relies entirely on manual observation and statistics, which is highly subjective and inefficient, unable to achieve real-time, continuous, and individualized accurate behavioral event detection and segment generation, and its method is also difficult to transfer to automated analysis processes based on video streams.
[0007] The aforementioned limitations have resulted in a long-standing lack of technical tools for monitoring stereotyped behaviors of individual animals in a timely, objective, and quantifiable manner. This has made it impossible to provide timely and precise intervention for individuals exhibiting stress, and also makes it difficult to scientifically evaluate the effectiveness of improvements to the rearing environment and management strategies based on objective behavioral data.
[0008] Given the shortcomings of current technologies, there is an urgent need for a method and system for recognizing stereotypical behaviors in captive goats based on time-series video analysis. Summary of the Invention
[0009] The purpose of this invention is to provide a method and system for recognizing stereotyped behaviors in captive goats based on time-series video analysis, in order to improve the aforementioned problems. To achieve the above objective, the technical solution adopted by this invention is as follows: In a first aspect, this application provides a method for recognizing stereotypical behaviors of captive goats based on temporal video analysis, including: Acquire raw surveillance video data containing individual captive goats, fence structures, and internal fixed facilities. Based on the original surveillance video data, foreground targets are separated. By using the static spatial structure of the fence and fixed facilities as a position reference, dynamic pixel areas that continuously overlap with the structural positions are separated to obtain a foreground sequence of goats that are spatially associated with the environmental facilities. Based on the foreground sequence of the individual goat, the facility constraint trajectory is extracted. By calculating the change sequence of the angle between the individual's movement direction and the geometric orientation of the nearest facility surface, and analyzing the degree of periodic closure of the movement path in the fixed facility coordinate system, the motion pattern encoding that integrates environmental structural constraints is obtained. Based on the foreground sequence of the individual goat, location-specific interactive features are extracted. By analyzing the consistent change patterns of pixel intensity and motion flow in the contact area between the goat's head region and body side region and the facility, an interactive dynamic feature sequence representing the mouth biting action and the body side friction action is generated. By fusing temporal causal features based on the motion pattern encoding and the interaction dynamics feature sequence, a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction is obtained. Based on the composite behavioral representation, stereotyped behavior segments are generated by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with neck swallowing movement characteristics, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with head turning cleaning movement characteristics, thereby generating stereotyped biting behavior segments and stereotyped friction behavior segments.
[0010] Secondly, this application also provides a system for recognizing stereotypical behaviors of captive goats based on temporal video analysis, including: The acquisition module is used to acquire raw surveillance video data containing individual captive goats, fence structures, and internal fixed facilities. The separation module is used to separate foreground targets based on the original monitoring video data. By using the static spatial structure of the fence and fixed facilities as a position reference, the dynamic pixel area that continuously overlaps with the position of the structure is separated to obtain a foreground sequence of individual goats that are spatially associated with the environmental facilities. The first extraction module is used to extract the facility constraint trajectory based on the foreground sequence of the individual goat. By calculating the angle change sequence of the individual's movement direction relative to the geometric orientation of the nearest facility surface and analyzing the periodic closure degree of the movement path in the fixed facility coordinate system, the motion pattern code that integrates environmental structural constraints is obtained. The second extraction module is used to extract part-specific interactive features based on the individual goat foreground sequence. By analyzing the consistent change patterns of pixel intensity and motion flow between the goat's head region and body side region and the contact area with the facility, an interactive dynamic feature sequence representing the mouth biting action and the body side friction action is generated. The fusion module is used to perform temporal causal feature fusion based on the motion pattern encoding and the interaction dynamics feature sequence to obtain a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction. The generation module is used to generate stereotyped behavior segments based on the composite behavioral representation. It generates stereotyped biting behavior segments and stereotyped friction behavior segments by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with the neck swallowing movement characteristics, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with the head turning cleaning movement characteristics.
[0011] The beneficial effects of this invention are as follows: This invention effectively overcomes the drawbacks of the industry's long-standing reliance on manual inspections, including high subjectivity, low efficiency, and inability to conduct continuous monitoring. It achieves 24 / 7, objective monitoring of abnormal behavior in individual sheep flocks. By accurately outputting the specific type and duration of stereotyped behaviors in each goat, managers can promptly locate and intervene in individuals with stress or health risks, realizing a shift from extensive group management to precise individual care. Simultaneously, this invention provides a basis for scientifically assessing the feeding environment, improving daily feed formulations, and refining management strategies, driving a fundamental shift in livestock decision-making from experience-based judgment to data-driven approaches. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating a method for recognizing stereotypical behaviors of captive goats based on temporal video analysis, as described in an embodiment of the present invention. Figure 2 This is a schematic diagram of the structure of a captive goat stereotype recognition system based on time-series video analysis, as described in an embodiment of the present invention. Figure 3 This is an inter-frame difference heatmap; Figure 4 This is a diagram of the trajectory of an individual movement within a local facility coordinate system. Figure 5 This is a sequence diagram showing the change in the angle between the direction of movement and the surface of the facility; Figure 6 A periodic closed-loop measurement curve of the motion path; Figure 7 Diagram of pulse signals for a mouth contact event; Figure 8 This is a diagram of the pulse signal of a lateral contact event.
[0014] The diagram is labeled as follows: 901, Acquisition module; 902, Separation module; 903, First extraction module; 904, Second extraction module; 905, Fusion module; 906, Generation module. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0016] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0017] Example 1
[0018] This embodiment provides a method for recognizing stereotyped behaviors in captive goats based on temporal video analysis.
[0019] See Figure 1 The figure shows that the method includes steps S100 to S600.
[0020] Step S100: Obtain raw surveillance video data containing individual captive goats, fence structures, and internal fixed facilities. Understandably, the data comprises: an uncompressed video stream continuously captured by surveillance cameras fixed above the goats' enclosures. This video stream fully covers the goat activity area and clearly presents two core elements: first, the multiple captive goats acting as the actors; and second, the standardized fence structure (such as the geometry and spatial location of the fence) and internal fixed facilities (such as the edges of feed troughs, watering points, and railings) serving as the background and objects of the behavior. The data acquisition method relies on the farm's existing security monitoring system, achieved by directly accessing the video stream output from the cameras, providing a foundation for subsequent specialized processing.
[0021] Step S200: Separate foreground targets based on the original monitoring video data. By using the static spatial structure of the fence and fixed facilities as a position reference, separate the dynamic pixel areas that continuously overlap with the structural position to obtain the foreground sequence of individual goats that are spatially associated with the environmental facilities. It's important to note that the core of this step lies in initially identifying the analysis target from a complex static background. Leveraging the prior knowledge that fixed facilities such as fences and feeding troughs in a captive setting have stable spatial positions, the algorithm uses the structural information of these facilities as a positional benchmark. The algorithm focuses on separating dynamic pixel regions whose positions continuously overlap with these facilities over time. The direct effect of this is to initially filter out central activities unrelated to the facilities, concentrating the subsequent analysis on individual goats that may interact with the facilities, thus obtaining a sequence of foreground targets with a clear spatial association with the environmental facilities.
[0022] Step S300: Extract facility constraint trajectory based on the individual goat foreground sequence. Calculate the angle change sequence between the individual's movement direction and the geometric orientation of the nearest facility surface, and analyze the periodic closure degree of the movement path in the fixed facility coordinate system to obtain the motion pattern code that integrates environmental structural constraints. Understandably, this step aims to quantify an individual's movement patterns under specific environmental constraints. By binding the goat's movement to the surface geometry of the nearest facility, the sequence of changes in the angle between the movement direction and that orientation is calculated, thus distinguishing "walking along the railing" from "circling in the open space" at the data level. Furthermore, within a local coordinate system established with the aforementioned facility as a reference, the degree of periodic closure of the movement path is analyzed to capture the spatial characteristics of the typical stereotypical behavior of "aimless circling." The resulting movement pattern encoding, with its "periodicity" and "closure" characteristics defined under the constraints of the facility's spatial relationships, deeply integrates scene structural information.
[0023] Step S400: Extract part-specific interactive features based on the foreground sequence of individual goats. By analyzing the consistent change patterns of pixel intensity and motion flow in the contact area between the goat's head region and body side region and the facility, generate an interactive dynamic feature sequence representing the bite action of the mouth and the friction action of the body side. It should be noted that this step, based on prior knowledge of goat anatomy, specifically focuses on two key body parts where stereotyped behaviors may occur: the head (mouth) and the sides. By analyzing the temporal consistency of pixel intensity (reflecting the tightness of contact) and motion flow (reflecting the direction and pattern of contact actions) at the contact points between these specific areas and the facility, an interactive dynamic feature sequence representing the two typical stereotyped actions of "biting" and "rubbing" is generated. This step advances behavior recognition from the overall "movement" level to the fine "interaction" level of "body part-facility".
[0024] Step S500: Perform temporal causal feature fusion based on motion pattern encoding and interaction dynamics feature sequence to obtain a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction; Understandably, this step is crucial in distinguishing between purposeful and stereotyped behaviors. The idea is that simple periodic movements or contact with a facility are not sufficient criteria for stereotyped behavior; for example, eating also involves repetitive biting, and scratching involves rubbing against the sides of the body. Therefore, this step deeply integrates the features obtained in the first two steps, aiming to uncover the causal and temporal relationships between actions and underlying physiological responses.
[0025] Step S600: Generate stereotyped behavior segments based on composite behavioral representations. Generate stereotyped biting behavior segments and stereotyped friction behavior segments by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with neck swallowing movement features, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with head turning cleaning movement features.
[0026] It should be noted that this step, based on a composite representation that already includes motivational discrimination, sets specific detection rules to generate behavioral segments. The rules simultaneously detect two types of signal intervals: first, intervals where the movement path exhibits periodic closure and the mouth contact signal is not associated with swallowing actions, corresponding to "stereotypical biting without feeding purpose"; second, intervals where the movement path exhibits periodic closure and the body side contact signal is not associated with cleaning actions, corresponding to "stereotypical rubbing without cleaning purpose." By detecting and defining these qualifying continuous time intervals, a structured recognition result is ultimately output, namely, the specific start and end time segments of various stereotyped behaviors occurring in each individual goat, achieving automated conversion from continuous video to discrete behavioral events.
[0027] Further, step S200 includes steps S210 to S230.
[0028] Step S210: Static scene modeling is performed based on the original surveillance video data. By performing pixel value stability statistics on multiple frames of images containing no goats, a background model including the spatial location of fences and internal fixed facilities is obtained. Step S220: Based on the original monitoring video data and background model, extract the motion region of the facility neighborhood. By calculating the inter-frame difference between the video sequence and the background model, and based on the prior spatial location of the fixed facility in the background model, filter out the differential pixel connected regions that overlap with the edge region of the facility to obtain a set of candidate motion regions. Step S230: Generate foreground targets of goats based on the candidate motion region set. By analyzing the temporal consistency of appearance, motion continuity and the matching degree of the outline with the morphological prior of goats in the candidate motion regions, and filtering out interference regions, a foreground sequence of individual goats that are spatially associated with the environmental facilities is obtained.
[0029] Specifically, firstly, static scene modeling is used. Leveraging the long-term static nature of fixed structures like fences and feed troughs in a captive environment, a video clip excluding individual goats is analyzed. The stability of the color or brightness value of each pixel across multiple frames is statistically analyzed, and the most stable and frequently occurring value is used as the background pixel value for that location. This constructs a high-precision background model that only includes the fence structure and the spatial locations of its internal fixed structures. The formula for calculating pixel stability is as follows: ; In the formula, B(x, y) represents the background pixel value at coordinate position (x, y); V represents the candidate pixel value, which takes the range of all possible brightness or color values in the image; N represents the total number of video frames participating in the statistics. δ represents the pixel value at coordinate position (x, y) of the Kth frame image; δ represents the Kronecker delta function, which takes the value 1 when its two independent variables are equal and takes the value 0 when they are not equal, and is used to determine whether a specific pixel value is equal to a candidate value. This represents the candidate value that maximizes the objective function, i.e., the pixel value that appears most frequently.
[0030] Based on this, the algorithm extracts the motion region in the vicinity of the facility. It calculates the difference between each frame of the real-time video sequence and the corresponding pixel in the aforementioned background model. However, instead of processing the entire image, it only performs the difference calculation within a defined neighborhood around the facility, based on the known spatial location of the fixed facility edges in the background model. Adjacent pixels with differences exceeding a threshold are aggregated into connected components. This approach accurately filters out all candidate motion regions occurring near the facility edges, significantly reducing motion interference from irrelevant areas such as the center of the site. See also Figure 3 , Figure 3 The image shows an inter-frame difference heatmap. The horizontal axis represents the pixel coordinates in the horizontal direction, and the vertical axis represents the pixel coordinates in the vertical direction. The grayscale value represents the pixel difference between the current frame and the background model. High grayscale areas are concentrated near the edges of fixed structures, indicating spatial overlap between the moving target and the structure's edge, corresponding to candidate motion regions in the structure's neighborhood. Finally, goat foreground targets are generated. Temporal analysis is performed on the candidate motion region set obtained in the previous step to evaluate whether the appearance features of each region remain stable and consistent across multiple consecutive images, and whether the motion trajectory is smooth and continuous. The region contours are then matched with predefined morphological prior knowledge of goats (such as approximate body aspect ratio and head contour). By integrating these temporal consistency, motion continuity, and shape matching indices, transient interference regions caused by changes in lighting, floating feed bags, or birds can be effectively filtered out. Ultimately, the true individual goat foreground sequences with a continuous spatial association with the fixed structures are identified and output.
[0031] Further, step S300 includes steps S310 to S330.
[0032] Step S310: Construct a facility surface orientation reference system based on the foreground sequence of individual goats. By extracting the principal direction of the pixel gradient of the edge of the fence or fixed facility that is spatially closest to the individual goat in the foreground sequence, the local geometric orientation reference of the target facility surface is obtained. Step S320: Quantize the relative motion direction based on the foreground sequence of individual goats and the local geometric orientation reference. Calculate the motion direction vector of the individual goat between consecutive frames and solve the real-time angle between the motion direction vector and the local geometric orientation reference to obtain the sequence of changes in the angle between the motion direction and the facility surface. Step S330: Perform periodic closed path analysis based on the angle change sequence and the individual goat center point position sequence. In the local coordinate system with the nearest fixed facility as the origin, map the individual position sequence into a path and analyze whether the path forms a closed loop around the facility or along the surface of the facility within the time window to obtain the motion pattern code that integrates environmental structural constraints.
[0033] Specifically, the process first addresses the close relationship between goat behavior and fixed facilities in captivity scenarios by constructing a reference system for the orientation of facility surfaces. The technical approach is as follows: in the processed foreground sequence, the Euclidean distance between individual goats and the edge pixels of each fixed facility in the background model is calculated in real time to find the spatially closest facility edge point. Then, the gradient direction distribution of pixels in the neighborhood of this point is analyzed, and the gradient direction with the highest frequency (i.e., the direction of the most drastic change in pixel brightness) is extracted as the geometric orientation reference of the facility edge in the current local area. This effectively transforms the fixed facility structure into a calculable data reference system with directional attributes. Next, relative motion direction quantization is performed. Using the obtained local geometric orientation reference, the algorithm calculates the motion direction vector defined by the displacement of the goat's center point between consecutive frames in each frame. It then uses vector operations to solve for the real-time angle between this motion direction and the aforementioned facility orientation reference, thus generating a time-varying angle sequence. The physical meaning of this sequence is that it transforms the goat's absolute motion direction into a relative measure relative to the tangent or normal direction of the nearest facility surface. This makes "walking along the railing" appear as an angle consistently close to zero degrees, while "moving towards the railing" appears as an angle close to ninety degrees, thus achieving a data-level binding between motion and facility geometry. The formula for calculating the real-time angle between the motion direction and the facility surface orientation is: ; In the formula, This represents the angle between the direction of motion and the orientation of the facility surface at time t. The vector representing the direction of motion of the goat at time t is defined by the difference between the coordinates of the center point of the goat in this frame and the coordinates of the center point of the goat in the previous frame. The local geometric orientation reference vector of the nearest facility edge at time t is defined by the principal direction of the pixel gradient that appears most frequently in the neighborhood of the facility edge; This represents the dot product operation of two vectors; represents the magnitude of a vector (i.e., the Euclidean norm); arccos represents the inverse cosine function, which maps the normalized inner product result to an angle value.
[0034] Figure 5 This diagram illustrates the real-time sequence of changes in the angle between the direction of movement and the geometric orientation of the facility surface. The shaded areas represent time periods where the angle remains close to zero degrees, corresponding to the stereotypical pacing behavior of a goat moving parallel to the facility surface; the unshaded areas show a dispersed distribution of angles, corresponding to the normal behavior of free movement. This sequence visually reflects the process of converting the absolute direction of movement into a measurement relative to the facility surface. Based on this, periodic closed-path analysis is performed, the core of which is constructing a local coordinate system with the nearest fixed facility edge point at the current moment as the origin. (See [link to relevant documentation]). Figure 4 , Figure 4 The figure shows the movement trajectory of an individual goat within a time window in a local coordinate system with reference to the edge of a fixed facility. As can be seen, the individual's movement trajectory exhibits a reciprocating back-and-forth motion along the facility surface, with the starting and ending points distinguished by different markers. This trajectory characteristic is consistent with the spatial pattern of "walking back and forth close to the fence" in stereotyped pacing behavior. The sequence of the goat's center point positions within a time window is transformed into this coordinate system, forming a relative path. The analysis examines whether this path forms a closed loop in the facility coordinate system with similar beginning and end positions and an overall shape reciprocating around the facility point or along its edge. This is achieved by calculating the path's closure degree and the number of loops. The formula for calculating the path closure degree is: ; In the formula, This represents the path closure index, with a value range of [0,1]. When the value is close to 1, it indicates that the beginning and end of the path almost overlap, forming a closed loop. Represents the starting coordinates of the sequence of center point positions of individual goats within the time window; Indicates the ending coordinates of this position sequence; The distance between the starting and ending points of the path is represented by L, which is the length of the open gap in the path; L represents the total number of location sampling points within this time window. This shows the coordinates of the individual center point of the j-th sampling point; This represents the coordinates of the individual center point of the (j-1)th sampling point; The denominator represents the Euclidean distance between two adjacent sampling points, i.e., the single-step displacement length; the denominator represents the arithmetic mean of all single-step displacement lengths within the time window, i.e., the average step size; when the open gap length is much smaller than the average step size, the closure degree... Approaching 1.
[0035] The resulting motion pattern code not only includes the abstract features of "periodicity" and "closure," but more importantly, these features are defined and calculated in a local space with the facility as the reference, thus naturally incorporating environmental structural constraints. This effectively distinguishes between two motion patterns that have similar trajectories but completely different behavioral meanings in the absolute world coordinate system: "wandering aimlessly in an open space" and "stereotypically pacing back and forth close to the railing." Figure 6 The figure shows a periodic closure metric curve for motion paths. The horizontal axis represents the frame number, the vertical axis represents the closure index (ranging from 0 to 1), and the dashed line represents a preset first threshold (0.65). Areas on the curve above the threshold and filled indicate that the path forms a closed loop in the local facility coordinate system, corresponding to stereotyped reciprocating motion; areas below the threshold indicate open, non-repetitive motion. This metric curve provides a quantitative basis for the generation of motion pattern encoding.
[0036] Further, step S400 includes steps S410 to S430.
[0037] Step S410: Locate the body parts of the goat based on the foreground sequence of the individual goat, calculate the pixel spatial distribution of the head region and the side region based on the contour pose of the individual goat, and obtain the head region mask and the side region mask. Step S420: Detect facility contact events based on the head region mask, body side region mask, and the foreground sequence of the goat individual. By analyzing the consistency of pixel intensity temporal fluctuations and dense optical flow motion patterns in the overlapping parts of the mask-covered area and the edge of the fixed facility in the background, obtain the mouth candidate contact event sequence and the body side candidate contact event sequence. Step S430: Generate interactive dynamic features based on the candidate contact event sequence of the mouth and the candidate contact event sequence of the body. By analyzing the contact frequency, duration and main direction distribution pattern of the motion flow in the contact area of the two types of event sequences respectively, the interactive dynamic feature sequence characterizing the mouth biting action and the body friction action is obtained.
[0038] Specifically, based on the segmented foreground sequence of individual goats, the algorithm first uses a pose estimation algorithm to infer the rough body axis and orientation of the individual based on information such as the shape, aspect ratio, and pose angle of the foreground region contour. Then, according to the standard anatomical proportion model of goats, the algorithm calculates the pixel range most likely to be covered by the head (roughly including the mouth, eyes, and corners) and the sides of the body (roughly the side of the middle section of the body) in the image space, and generates the corresponding binarized head region mask and side region mask. This allows the subsequent analysis to focus from the "entire individual goat" to the key anatomical sites where specific interactions may occur. Subsequently, facility contact event detection is performed. This step comprehensively utilizes the fixed facility edge information in the aforementioned part mask, foreground sequence, and background model. Specifically, the algorithm determines in real time whether the image area covered by the head mask or body side mask spatially overlaps with the known facility edge location. If they overlap, the algorithm further analyzes the temporal fluctuation pattern of pixel intensity in the overlapping area (which can reflect the local texture brightness changes caused by contact pressure) and the pixel motion pattern calculated by dense optical flow (which reflects the small tangential or normal motion of the contact part). Only when the intensity fluctuation and the specific motion pattern (for example, for the mouth area, there is a high-frequency, small-amplitude reciprocating motion; for the body side area, there is a unidirectional, continuous sliding motion) show significant temporal consistency, a valid candidate contact event is determined to have occurred, and it is recorded as a mouth candidate contact event or a body side candidate contact event, respectively, thus obtaining two parallel temporal event sequences.
[0039] The formula for calculating the consistency metric between pixel intensity fluctuations and motion flow patterns is as follows: ; In the formula, C represents the consistency metric between pixel intensity fluctuations and motion flow patterns. A higher value indicates a more significant temporal consistency between the two. W represents the length of the time window for consistency analysis, i.e., the number of consecutive frames involved in the calculation. q represents the frame index within the time window. It represents the change in pixel intensity within the overlapping region in the q-th frame, and is defined as the absolute value of the difference between the average pixel value of the overlapping region in that frame and the average pixel value of the reference pixel value in the non-contact state. This represents the average motion vector calculated by dense optical flow within the overlapping region of the q-th frame; The Pearson correlation coefficient, representing the relationship between two input variables, measures the degree of linear correlation between the intensity change sequence and the motion vector magnitude sequence; when When the calculation result exceeds the preset threshold, a valid candidate contact event is determined to have occurred.
[0040] Finally, interactive dynamics feature generation is performed. This step quantifies and describes the above event sequences, rather than simply counting them. Instead, it deeply analyzes the micro-patterns of each event sequence: for candidate mouth contact event sequences, it analyzes the frequency distribution of the events, the duration distribution of individual events, and the statistical characteristics of the main direction of motion flow in the contact area when the event occurs (e.g., whether it is mainly perpendicular to the railing). These statistical characteristics are then integrated into a feature vector sequence characterizing the dynamics of the "biting" action. Figure 7 The pulse signals of mouth contact events are shown. In the left shaded area (stereotypical biting segment), the signal exhibits high-frequency, short-duration pulse characteristics, with short pulse intervals and brief durations, corresponding to stereotyped biting actions without feeding purpose. In the right shaded area (normal feeding segment), the signal exhibits low-frequency, long-duration pulse characteristics, with longer pulse intervals and significant single-pulse durations, corresponding to purposeful normal feeding behavior. Similar analysis was performed on candidate body contact event sequences to extract feature vector sequences representing "friction" actions, thus providing a quantitative basis based on interaction dynamics for distinguishing between stereotyped and purposeful interactions. Figure 8 The pulse signals of lateral contact events are shown. In the left shaded area (stereotyped rubbing segment), the signal exhibits a persistent, medium-to-high intensity long-duration characteristic, corresponding to stereotyped fence-rubbing behavior in goats without cleaning purpose; in the right shaded area (normal scratching segment), the signal exhibits a transient, low-intensity discrete characteristic, corresponding to occasional normal scratching behavior. The significant differences in duration and intensity distribution between the two signal types, combined with... Figure 7 The mouth contact signals together form the data basis for distinguishing between the two types of interactive dynamic features: biting and friction.
[0041] Further, step S500 includes steps S510 to S530.
[0042] Step S510: Extract behavioral pattern features based on motion pattern coding and interaction dynamics feature sequence. Extract path periodic closure features from motion pattern coding and extract mouth contact features and body side contact features from interaction dynamics feature sequence to obtain periodic motion features, mouth contact behavior features and body side contact behavior features. Step S520: Based on the periodic movement characteristics, mouth contact behavior characteristics and body side contact behavior characteristics, perform physiological feedback correlation analysis. By aligning the mouth contact behavior characteristics with a predefined neck swallowing movement template in time and calculating the correlation, and by aligning the body side contact behavior characteristics with a predefined head turning and cleaning movement template in time and calculating the correlation, the first correlation judgment result between mouth contact behavior and swallowing movement and the second correlation judgment result between body side contact behavior and cleaning movement are obtained. Step S530: Based on the periodic motion characteristics, the first correlation discrimination result and the second correlation discrimination result, the behavior motivation fusion discrimination is performed. By logically fusing the periodic motion characteristics with the low correlation mouth contact behavior and the low correlation body side contact behavior in the time sequence, a composite behavior representation that distinguishes between purposeful interaction and stereotyped interaction is obtained.
[0043] Specifically, the above processing steps involve refining key information from the higher-level codes and sequences obtained in the previous steps: from the motion pattern codes that incorporate environmental structural constraints, the path periodic closure features that quantify the "purposeless repetition" characteristic are parsed out; at the same time, from the interaction dynamics feature sequence, mouth contact behavior features describing the intensity and rhythm of mouth-to-facility contact, and body side contact behavior features describing the intensity and rhythm of body side-to-facility contact, are extracted respectively, thus obtaining three parallel and more focused core feature streams. Subsequently, physiological feedback correlation analysis is performed, which is the key mechanism for discerning behavioral motivation. The technical approach involves introducing action templates based on animal behavior knowledge as a reference: for mouth contact behavior characteristics, the algorithm aligns and calculates the correlation with a predefined standardized temporal template representing a complete swallowing action (accompanied by specific movement patterns of the larynx and neck) to quantify the probability of an effective swallowing action after each mouth contact behavior; for body contact behavior characteristics, it is similarly analyzed with a predefined action template representing effective cleaning adjustments (usually manifested as the head and neck turning to the contacting body side for licking after contact); through the calculated correlation coefficient or matching degree, the algorithm finally outputs the first discrimination result of the strength of the correlation between mouth contact behavior and swallowing action, and the second discrimination result of the strength of the correlation between body contact behavior and cleaning action.
[0044] The formula for calculating the temporal correlation between mouth contact behavior characteristics and neck swallowing action templates is as follows: ; In the formula, R represents the maximum temporal correlation between the characteristics of mouth contact behavior and the motor template of neck swallowing action, that is, the maximum correlation coefficient under all possible time shifts; It represents the time offset, which is used to align the mouth contact feature sequence with the swallowing action template sequence in time. The search range covers a reasonable delay interval from before the mouth contact event to after the event. This indicates that the maximum value is calculated for all candidate time offsets. This represents the total number of sampling points for the mouth contact behavior characteristic sequence; Indicates the index of the sampling point in the sequence; Indicates the first The characteristic values of mouth contact behavior at each sampling point reflect the contact intensity between the mouth area and the facility at that moment; This represents the arithmetic mean of the mouth contact behavior feature sequence within the window; Indicates time offset After alignment, the first The neck swallowing action template feature values at each sampling point are predefined standardized temporal sequences that characterize the motion features of the neck region during complete swallowing. The R value represents the arithmetic mean of the swallowing action template sequence; the denominator is the product of the standard deviations of the two sequences, which is used to normalize the covariance of the numerator to the [-1,1] interval; when the R value is lower than the preset second threshold, it is determined that the mouth contact behavior is not effectively associated with the swallowing action.
[0045] The formula for detecting and determining the candidate interval for stereotyped biting behavior is as follows: ; In the formula, Indicates the first The result of the stereotyped biting behavior determination at frame time, when the value is true, indicates that the frame belongs to the candidate interval of stereotyped biting behavior; Indicates the first The periodic closure metric of the motion path at each frame time is output from the aforementioned path closure calculation process; This represents a preset first threshold, used to define whether the motion path exhibits significant periodic closure characteristics. When the closure metric exceeds this threshold, the motion is considered to be a repetitive pattern. Indicates the first The temporal correlation metric between mouth contact behavior and neck swallowing movement characteristics at a given frame time is output by the aforementioned temporal correlation calculation process; The second threshold is a preset threshold used to define whether mouth contact behavior is effectively associated with swallowing physiological feedback. When the correlation metric is below this threshold, it is considered that there is a lack of effective swallowing action after contact. The "AND" operation indicates that a frame is marked as a candidate frame for stereotyped biting behavior only when both conditions are met simultaneously. By merging all frames that consecutively meet the above conditions, the candidate interval for stereotyped biting behavior is obtained.
[0046] Finally, behavioral motivation fusion and discrimination are performed. This step executes the final logical decision: the algorithm simultaneously examines the periodic motion features, the first correlation discrimination result, and the second correlation discrimination result. Its core rule is to logically "AND" the high-intensity periodic closing motion features with the low correlation (i.e., no effective association with swallowing after mouth contact, or no effective association with cleaning after body contact) interaction behavioral features under strict time alignment conditions. Through this fusion, the system can identify behavioral patterns with "high repetition" and "low physiological feedback," thereby distinguishing between "purposeless, stereotyped interactions" and "purposeful, functional interactions" at the data representation level, generating the final composite behavioral representation that includes motivation discrimination.
[0047] Further, step S600 includes steps S610 to S640.
[0048] Step S610: Perform periodicity and correlation feature analysis based on the composite behavioral representation. By extracting the periodic closure metric of the movement path, the temporal correlation metric of mouth contact behavior and neck swallowing movement features, and the temporal correlation metric of body side contact behavior and head turning cleaning movement features from the composite behavioral representation, the periodicity metric, mouth contact correlation metric, and body side contact correlation metric are obtained. Step S620: Based on the periodicity measurement, mouth contact correlation measurement and body side contact correlation measurement, stereotyped biting behavior interval detection is performed. By detecting continuous time intervals where the periodicity measurement is continuously higher than the first threshold and the mouth contact correlation measurement is continuously lower than the second threshold, the candidate intervals of stereotyped biting behavior are obtained. Step S630: Perform stereotyped friction behavior interval detection processing based on periodicity measurement, mouth contact correlation measurement and body side contact correlation measurement. By detecting continuous time intervals where periodicity measurement is continuously higher than the first threshold and body side contact correlation measurement is continuously lower than the third threshold, candidate intervals of stereotyped friction behavior are obtained. Step S640: Aggregate and output behavioral segments based on the candidate intervals of stereotyped biting behavior and the candidate intervals of stereotyped friction behavior. By merging adjacent candidate intervals of the same type with an interval smaller than the time window, generate and output the final stereotyped biting behavior segments and stereotyped friction behavior segments.
[0049] Specifically, firstly, numerical sequences that can specifically measure the degree of "periodic closure" of the movement path (periodic measure), numerical sequences that quantify the temporal correlation strength between mouth contact behavior and neck swallowing movement features (mouth contact correlation measure), and numerical sequences that quantify the temporal correlation strength between body contact behavior and head turning cleaning movement features (body contact correlation measure) are extracted from the representation, thereby transforming the fused and abstract behavior discrimination into three independent temporal signal streams. Based on this, two types of stereotyped behavior intervals are detected: For stereotyped biting behavior, the algorithm simultaneously scans two sequences: periodic measurement and mouth contact correlation measurement. It looks for continuous time intervals where the periodic measurement value is consistently higher than a preset first threshold (indicating significant repetitiveness of the movement) and the mouth contact correlation measurement value is consistently lower than a preset second threshold (indicating a long-term lack of effective swallowing feedback after mouth contact). These intervals are marked as candidate intervals for stereotyped biting behavior. For stereotyped friction behavior, a similar simultaneous scanning logic is used, but the correlation object is changed to body contact correlation measurement. It detects continuous time intervals where the periodic measurement is consistently higher than the first threshold and the body contact correlation measurement is consistently lower than another preset third threshold. This yields candidate intervals for stereotyped friction behavior. The independent setting of the thresholds here reflects the differentiated consideration of different stereotyped behavior discrimination criteria. Finally, the behavior segments are aggregated and output. Since the aforementioned detection may divide a continuous behavior into multiple adjacent short intervals due to instantaneous signal fluctuations, the algorithm merges candidate intervals of the same type (biting or rubbing): if the interval between the end time and start time of two intervals of the same type is less than a preset time window, they are considered to belong to the same behavior event and should be merged into a longer behavior segment. By performing this kind of aggregation processing on all candidate intervals, smooth and complete stereotyped biting behavior segments and stereotyped rubbing behavior segments are finally generated and output. Each segment clearly indicates the start and end time of the behavior, realizing the final transformation from time-series signals to structured behavior events.
[0050] Example 2: like Figure 2 As shown, this embodiment provides a system for recognizing stereotypical behaviors of captive goats based on temporal video analysis. The system includes: The acquisition module 901 is used to acquire raw surveillance video data containing individual captive goats, fence structures, and areas with internal fixed facilities. The separation module 902 is used to separate foreground targets based on the original monitoring video data. By using the static spatial structure of the fence and fixed facilities as a position reference, the dynamic pixel area that continuously overlaps with the position of the structure is separated to obtain the foreground sequence of individual goats that are spatially related to the environmental facilities. The first extraction module 903 is used to extract the facility constraint trajectory based on the foreground sequence of the individual goat. By calculating the angle change sequence of the individual's movement direction relative to the geometric orientation of the nearest facility surface and analyzing the periodic closure degree of the movement path in the fixed facility coordinate system, the motion mode code that integrates environmental structural constraints is obtained. The second extraction module 904 is used to extract part-specific interactive features based on the foreground sequence of individual goats. By analyzing the consistent change patterns of pixel intensity and motion flow in the contact area between the goat's head region and body side region and the facility, an interactive dynamic feature sequence representing the bite action of the mouth and the friction action of the body side is generated. The fusion module 905 is used to perform temporal causal feature fusion based on motion pattern encoding and interaction dynamics feature sequence to obtain a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction. The generation module 906 is used to generate stereotyped behavior segments based on composite behavioral representations. It generates stereotyped biting behavior segments and stereotyped friction behavior segments by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with neck swallowing movement features, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with head turning cleaning movement features.
[0051] In one specific embodiment of this application, the separation module 902 includes: The first separation unit is used to perform static scene modeling based on the original surveillance video data. By performing pixel value stability statistics on multiple frames of images containing no goats, a background model including the spatial location of fences and internal fixed facilities is obtained. The second separation unit is used to extract the motion region of the facility neighborhood based on the original monitoring video data and the background model. By calculating the inter-frame difference between the video sequence and the background model, and based on the spatial location prior of the fixed facility in the background model, the differential pixel connected regions that overlap with the edge region of the facility are selected to obtain a set of candidate motion regions. The third separation unit is used to generate goat foreground targets based on the candidate motion region set. By analyzing the temporal appearance consistency, motion continuity and the matching degree between the outline of the candidate motion regions and the morphological prior of the goat, and filtering out interference regions, a sequence of individual goat foreground targets that are spatially associated with the environmental facilities is obtained.
[0052] In one specific embodiment of this application, the first extraction module 903 includes: The first extraction unit is used to construct a facility surface orientation reference system based on the foreground sequence of individual goats. By extracting the principal direction of the pixel gradient of the edge of the fence or fixed facility that is spatially closest to the individual goat in the foreground sequence, the local geometric orientation reference of the target facility surface is obtained. The second extraction unit is used to quantize the relative motion direction based on the foreground sequence of the goat individual and the local geometric orientation reference. By calculating the motion direction vector of the goat individual between consecutive frames and solving the real-time angle between the motion direction vector and the local geometric orientation reference, the sequence of changes in the angle of motion direction relative to the facility surface is obtained. The third extraction unit is used to perform periodic closed path analysis based on the angle change sequence and the position sequence of the individual goat's center point. By mapping the individual position sequence into a path in a local coordinate system with the nearest fixed facility as the origin, it analyzes whether the path forms a closed loop around the facility or along the surface of the facility within the time window, and obtains the motion pattern code that integrates environmental structural constraints.
[0053] In one specific embodiment of this application, the second extraction module 904 includes: The fourth extraction unit is used to locate the body parts of the goat based on the foreground sequence of the individual goat, and calculate the pixel spatial distribution of the head region and the side region based on the contour pose of the individual goat to obtain the head region mask and the side region mask. The fifth extraction unit is used to detect facility contact events based on the head region mask, the body side region mask, and the foreground sequence of the goat individual. By analyzing the consistency of the pixel intensity temporal fluctuation and dense optical flow motion pattern of the overlapping part of the mask coverage area and the edge of the fixed facility in the background, the candidate contact event sequence of the mouth and the candidate contact event sequence of the body side are obtained. The sixth extraction unit is used to generate interactive dynamic features based on the candidate contact event sequence of the mouth and the candidate contact event sequence of the body. By analyzing the contact frequency, duration and main direction distribution pattern of the motion flow in the contact area of the two types of event sequences respectively, the interactive dynamic feature sequence characterizing the mouth biting action and the body friction action is obtained.
[0054] In one specific embodiment of this application, the fusion module 905 includes: The first fusion unit is used to extract behavioral pattern features based on motion pattern encoding and interaction dynamics feature sequence. By extracting path periodic closure features from motion pattern encoding and mouth contact features and body side contact features from interaction dynamics feature sequence, periodic motion features, mouth contact behavior features and body side contact behavior features are obtained. The second fusion unit is used to perform physiological feedback correlation analysis based on periodic movement characteristics, mouth contact behavior characteristics and body side contact behavior characteristics. By performing temporal alignment and correlation calculation on mouth contact behavior characteristics and predefined neck swallowing movement templates, and performing temporal alignment and correlation calculation on body side contact behavior characteristics and predefined head turning and cleaning movement templates, the first correlation judgment result between mouth contact behavior and swallowing movement and the second correlation judgment result between body side contact behavior and cleaning movement are obtained. The third fusion unit is used to perform behavioral motivation fusion and discrimination based on periodic motion features, the first correlation discrimination result and the second correlation discrimination result. By logically fusing periodic motion features with low-correlation mouth contact behavior and low-correlation body contact behavior in time sequence, a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction is obtained.
[0055] In one specific embodiment of this application, the generation module 906 includes: The first generation unit is used to analyze the periodic and correlation features based on the composite behavioral representation. By extracting the periodic closure measure of the movement path, the temporal correlation measure of the mouth contact behavior and the neck swallowing movement feature, and the temporal correlation measure of the body side contact behavior and the head turning cleaning movement feature from the composite behavioral representation, the periodic measure, the mouth contact correlation measure, and the body side contact correlation measure are obtained. The second generation unit is used to detect stereotype biting behavior intervals based on periodicity measurement, mouth contact correlation measurement and body side contact correlation measurement. By detecting continuous time intervals where the periodicity measurement is continuously higher than the first threshold and the mouth contact correlation measurement is continuously lower than the second threshold, candidate intervals for stereotype biting behavior are obtained. The third generation unit is used to perform stereotyped friction behavior interval detection processing based on periodicity measurement, mouth contact correlation measurement and body side contact correlation measurement. By detecting continuous time intervals where periodicity measurement is continuously higher than the first threshold and body side contact correlation measurement is continuously lower than the third threshold, candidate intervals of stereotyped friction behavior are obtained. The fourth generation unit is used to aggregate and output behavioral segments based on the candidate intervals of stereotyped biting behavior and stereotyped friction behavior. By merging adjacent candidate intervals of the same type with an interval smaller than the time window, the final stereotyped biting behavior segments and stereotyped friction behavior segments are generated and output.
[0056] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for recognizing stereotyped behaviors in captive goats based on temporal video analysis, characterized in that, include: Acquire raw surveillance video data containing individual captive goats, fence structures, and internal fixed facilities. Based on the original surveillance video data, foreground targets are separated. By using the static spatial structure of the fence and fixed facilities as a position reference, dynamic pixel areas that continuously overlap with the structural positions are separated to obtain a foreground sequence of goats that are spatially associated with the environmental facilities. Based on the foreground sequence of the individual goat, the facility constraint trajectory is extracted. By calculating the change sequence of the angle between the individual's movement direction and the geometric orientation of the nearest facility surface, and analyzing the degree of periodic closure of the movement path in the fixed facility coordinate system, the motion pattern encoding that integrates environmental structural constraints is obtained. Based on the foreground sequence of the individual goat, location-specific interactive features are extracted. By analyzing the consistent change patterns of pixel intensity and motion flow in the contact area between the goat's head region and body side region and the facility, an interactive dynamic feature sequence representing the mouth biting action and the body side friction action is generated. By fusing temporal causal features based on the motion pattern encoding and the interaction dynamics feature sequence, a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction is obtained. Based on the composite behavioral representation, stereotyped behavior segments are generated by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with neck swallowing movement characteristics, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with head turning cleaning movement characteristics, thereby generating stereotyped biting behavior segments and stereotyped friction behavior segments.
2. The method for recognizing stereotyped behaviors of captive goats based on temporal video analysis according to claim 1, characterized in that, Foreground target separation based on the original surveillance video data includes: Static scene modeling is performed based on the original surveillance video data. By performing pixel value stability statistics on multiple frames of images containing no goats, a background model including the spatial location of fences and internal fixed facilities is obtained. Based on the original surveillance video data and the background model, the motion region of the facility neighborhood is extracted. By calculating the inter-frame difference between the video sequence and the background model, and based on the prior spatial position of the fixed facility in the background model, the differential pixel connected components that overlap with the edge region of the facility are selected to obtain a set of candidate motion regions. Based on the set of candidate motion regions, goat foreground targets are generated. By analyzing the temporal consistency of appearance, motion continuity and the matching degree of the outline with the morphological prior of the goat in the candidate motion regions, and filtering out interference regions, a sequence of individual goat foreground targets that are spatially associated with the environmental facilities is obtained.
3. The method for recognizing stereotyped behaviors of captive goats based on temporal video analysis according to claim 1, characterized in that, Based on the foreground sequence of the individual goats, facility constraint trajectory extraction is performed, including: Based on the foreground sequence of the goat individuals, a facility surface orientation reference system is constructed. By extracting the principal direction of the pixel gradient of the edge of the fence or fixed facility that is spatially closest to the goat individual in the foreground sequence, a local geometric orientation reference for the target facility surface is obtained. The relative motion direction is quantized based on the foreground sequence of the individual goat and the local geometric orientation reference. By calculating the motion direction vector of the individual goat between consecutive frames and solving the real-time angle between the motion direction vector and the local geometric orientation reference, the sequence of changes in the angle of motion direction relative to the facility surface is obtained. Based on the angle change sequence and the individual goat center point position sequence, periodic closed path analysis is performed. By mapping the individual position sequence to a path in a local coordinate system with the nearest fixed facility as the origin, and analyzing whether the path forms a closed loop around the facility or along the surface of the facility within the time window, motion pattern coding that incorporates environmental structural constraints is obtained.
4. The method for recognizing stereotyped behaviors of captive goats based on temporal video analysis according to claim 1, characterized in that, Based on the foreground sequence of the individual goat, site-specific interaction features are extracted, including: Based on the foreground sequence of the goat individual, the body parts of the goat are located, and the pixel spatial distribution of the head region and the side region is calculated based on the outline pose of the goat individual to obtain the head region mask and the side region mask. Based on the head region mask, the body side region mask, and the foreground sequence of the goat individual, facility contact events are detected. By analyzing the consistency of pixel intensity temporal fluctuations and dense optical flow motion patterns in the overlapping parts of the mask-covered area and the edge of the fixed facility in the background, candidate contact event sequences for the mouth and body side are obtained. Interactive dynamic features are generated based on the candidate mouth contact event sequence and the candidate body contact event sequence. By analyzing the contact frequency, duration and main direction distribution pattern of motion flow in the contact area of the two types of event sequences, an interactive dynamic feature sequence characterizing the mouth biting action and the body friction action is obtained.
5. The method for recognizing stereotyped behaviors of captive goats based on temporal video analysis according to claim 1, characterized in that, Temporal causal feature fusion based on the motion pattern encoding and the interaction dynamics feature sequence includes: Behavioral pattern features are extracted based on the motion pattern encoding and the interaction dynamics feature sequence. By extracting path periodic closure features from the motion pattern encoding and mouth contact features and body side contact features from the interaction dynamics feature sequence, periodic motion features, mouth contact behavior features and body side contact behavior features are obtained. Based on the periodic movement characteristics, the mouth contact behavior characteristics, and the body side contact behavior characteristics, a physiological feedback correlation analysis is performed. By aligning the mouth contact behavior characteristics with a predefined neck swallowing movement template in time and calculating the correlation, and by aligning the body side contact behavior characteristics with a predefined head turning and cleaning movement template in time and calculating the correlation, the first correlation judgment result between mouth contact behavior and swallowing movement and the second correlation judgment result between body side contact behavior and cleaning movement are obtained. Based on the periodic motion characteristics, the first correlation discrimination result, and the second correlation discrimination result, behavioral motivation fusion discrimination is performed. By logically fusing the periodic motion characteristics with low-correlation mouth contact behavior and low-correlation body side contact behavior in time sequence, a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction is obtained.
6. A system for recognizing stereotyped behaviors in captive goats based on temporal video analysis, characterized in that, include: The acquisition module is used to acquire raw surveillance video data containing individual captive goats, fence structures, and internal fixed facilities. The separation module is used to separate foreground targets based on the original monitoring video data. By using the static spatial structure of the fence and fixed facilities as a position reference, the dynamic pixel area that continuously overlaps with the position of the structure is separated to obtain a foreground sequence of individual goats that are spatially associated with the environmental facilities. The first extraction module is used to extract the facility constraint trajectory based on the foreground sequence of the individual goat. By calculating the angle change sequence of the individual's movement direction relative to the geometric orientation of the nearest facility surface and analyzing the periodic closure degree of the movement path in the fixed facility coordinate system, the motion pattern code that integrates environmental structural constraints is obtained. The second extraction module is used to extract part-specific interactive features based on the individual goat foreground sequence. By analyzing the consistent change patterns of pixel intensity and motion flow between the goat's head region and body side region and the contact area with the facility, an interactive dynamic feature sequence representing the mouth biting action and the body side friction action is generated. The fusion module is used to perform temporal causal feature fusion based on the motion pattern encoding and the interaction dynamics feature sequence to obtain a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction. The generation module is used to generate stereotyped behavior segments based on the composite behavioral representation. It generates stereotyped biting behavior segments and stereotyped friction behavior segments by simultaneously detecting continuous signal intervals where the movement path is periodically closed and the mouth contact pulse signal is not associated with the neck swallowing movement characteristics, and continuous signal intervals where the movement path is periodically closed and the body side contact pulse signal is not associated with the head turning cleaning movement characteristics.
7. The system for recognizing stereotyped behaviors of captive goats based on temporal video analysis according to claim 6, characterized in that, The separation module includes: The first separation unit is used to perform static scene modeling based on the original monitoring video data. By performing pixel value stability statistics on multiple frames of images containing no goats, a background model including the spatial location of fences and internal fixed facilities is obtained. The second separation unit is used to extract the motion region of the facility neighborhood based on the original monitoring video data and the background model. By calculating the inter-frame difference between the video sequence and the background model, and based on the spatial location prior of the fixed facility in the background model, the differential pixel connected components that overlap with the edge region of the facility are selected to obtain a set of candidate motion regions. The third separation unit is used to generate goat foreground targets based on the set of candidate motion regions. By analyzing the temporal consistency of appearance, motion continuity and the matching degree of the outline with the morphological prior of the goat in the candidate motion regions, and filtering out interference regions, a sequence of individual goat foreground targets that are spatially associated with the environmental facilities is obtained.
8. The system for recognizing stereotypical behaviors of captive goats based on time-series video analysis according to claim 6, characterized in that, The first extraction module includes: The first extraction unit is used to construct a facility surface orientation reference system based on the foreground sequence of the goat individual. By extracting the main direction of the pixel gradient of the edge of the fence or fixed facility that is spatially closest to the goat individual in the foreground sequence, the local geometric orientation reference of the target facility surface is obtained. The second extraction unit is used to quantize the relative motion direction based on the foreground sequence of the goat individual and the local geometric orientation reference. By calculating the motion direction vector of the goat individual between consecutive frames and solving the real-time angle between the motion direction vector and the local geometric orientation reference, the sequence of changes in the angle of the motion direction relative to the facility surface is obtained. The third extraction unit is used to perform periodic closed path analysis based on the angle change sequence and the position sequence of the individual goat's center point. By mapping the individual position sequence into a path in a local coordinate system with the nearest fixed facility as the origin, and analyzing whether the path forms a closed loop around the facility or along the surface of the facility within the time window, the motion pattern code that integrates environmental structural constraints is obtained.
9. The system for recognizing stereotyped behaviors of captive goats based on time-series video analysis according to claim 6, characterized in that, The second extraction module includes: The fourth extraction unit is used to locate the body parts of the goat based on the foreground sequence of the goat individual, calculate the pixel spatial distribution of the head region and the side region based on the contour pose of the goat individual, and obtain the head region mask and the side region mask. The fifth extraction unit is used to detect facility contact events based on the head region mask, the body side region mask, and the foreground sequence of the goat individual. By analyzing the consistency of the pixel intensity temporal fluctuation and dense optical flow motion pattern of the overlapping part of the mask coverage area and the edge of the fixed facility in the background, the candidate contact event sequence of the mouth and the candidate contact event sequence of the body side are obtained. The sixth extraction unit is used to generate interactive dynamic features based on the candidate mouth contact event sequence and the candidate body contact event sequence. By analyzing the contact frequency, duration and main direction distribution pattern of the motion flow in the contact area of the two types of event sequences respectively, an interactive dynamic feature sequence characterizing the mouth biting action and the body friction action is obtained.
10. The system for recognizing stereotypical behaviors of captive goats based on temporal video analysis according to claim 6, characterized in that, The fusion module includes: The first fusion unit is used to extract behavioral pattern features based on the motion pattern encoding and the interaction dynamics feature sequence. By extracting path periodic closure features from the motion pattern encoding and extracting mouth contact features and body side contact features from the interaction dynamics feature sequence, periodic motion features, mouth contact behavioral features and body side contact behavioral features are obtained. The second fusion unit is used to perform physiological feedback correlation analysis based on the periodic movement characteristics, the mouth contact behavior characteristics, and the body side contact behavior characteristics. By performing temporal alignment and correlation calculation between the mouth contact behavior characteristics and a predefined neck swallowing movement template, and performing temporal alignment and correlation calculation between the body side contact behavior characteristics and a predefined head turning and cleaning movement template, the first correlation judgment result between the mouth contact behavior and the swallowing movement and the second correlation judgment result between the body side contact behavior and the cleaning movement are obtained. The third fusion unit is used to perform behavioral motivation fusion and discrimination based on the periodic motion features, the first correlation discrimination result and the second correlation discrimination result. By logically fusing the periodic motion features with low-correlation mouth contact behavior and low-correlation body side contact behavior in time sequence, a composite behavioral representation that distinguishes between purposeful interaction and stereotyped interaction is obtained.