Intelligent sheep house environment automatic regulation method and system
By acquiring environmental parameters of the sheepfold and image data of sheep activities, environmental status information is generated, and strategy scoring and fusion are performed. This enables multi-strategy evaluation and comprehensive control of the intelligent sheepfold environment, solving the problem of inaccurate environmental control in existing technologies and improving the accuracy and stability of control.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GANSU SHEEP BREEDING TECH PROMOTION STATION
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies lack the ability to systematically quantify and optimize sheepfold environmental control measures, resulting in low energy efficiency, poor environmental stability, and an inability to perceive sheep status in real time for intelligent decision-making and precise execution.
By acquiring environmental parameters inside the sheepfold and image data of sheep activities, environmental status information is generated. Based on the control target range, an initial control strategy is generated. Adaptability scoring and dynamic weighted fusion are performed to generate comprehensive control parameters. The sheepfold is then controlled to perform environmental regulation operations, and feedback data is collected to generate a control result report.
It has achieved an upgrade from single physical field perception to "physical-biological" coupled field environmental perception, realizing multi-feature input, multi-strategy evaluation, and comprehensive decision output, avoiding contradictions in equipment actions and oscillations in environmental parameters, and improving the accuracy and stability of environmental regulation.
Smart Images

Figure CN122172908A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent sheepfold technology, and in particular to an automatic control method and system for the environment of an intelligent sheepfold. Background Technology
[0002] In modern intensive animal husbandry, the internal environment of sheep pens is a core factor affecting sheep health, growth performance, and farming efficiency. Key environmental parameters such as temperature, humidity, light, and harmful gas concentrations directly influence sheep's physiological state, feeding behavior, rest quality, and disease incidence. Current technologies lack the ability to systematically quantify and optimize the actual effects of control measures, resulting in low energy efficiency and poor environmental stability. Therefore, the animal husbandry industry urgently needs an automated control technology that can deeply integrate multi-source environmental information, perceive sheep status in real time, and make intelligent decisions and precise executions accordingly. This technology can improve farm efficiency and sustainable development while ensuring animal welfare. Summary of the Invention
[0003] Therefore, it is necessary to provide an intelligent sheepfold environment automatic control method and system to solve at least one of the above-mentioned technical problems.
[0004] To achieve the above objectives, an intelligent sheepfold environment automatic control method includes the following steps:
[0005] Step S1: Obtain environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information;
[0006] Step S2: Generate an initial set of control strategies based on the control target range in the environmental status information;
[0007] Step S3: Based on environmental state information, perform adaptive scoring on each parameter in the initial set of control strategies, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters;
[0008] Step S4: Control the sheepfold to perform environmental regulation operations according to the comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.
[0009] The present invention also provides an intelligent sheepfold environment automatic control system for performing the intelligent sheepfold environment automatic control method described above. The intelligent sheepfold environment automatic control system includes:
[0010] The data acquisition module is used to acquire environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information.
[0011] The initial control strategy generation module is used to generate an initial control strategy set based on the control target range in the environmental state information;
[0012] The adaptive scoring module is used to adaptively score each parameter in the initial set of control strategies based on environmental state information, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters.
[0013] The environmental regulation operation module is used to control the sheepfold to perform environmental regulation operations based on comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.
[0014] The beneficial effects of this invention are as follows: By establishing a spatiotemporal correlation mapping between environmental parameter data and sheep behavioral characteristic data, the generated fused environmental state information can truly reflect environmental suitability from the perspective of livestock's own response. This overcomes the limitations of traditional methods that rely solely on physical parameters for judgment, expanding the environmental perception dimension from a single physical field to a "physical-biological" coupled field, thus laying a data foundation for precise regulation. Based on the technical path of extracting dynamic target intervals and generating multi-strategy sets based on fused environmental state information, and then generating comprehensive regulation parameters through matching degree evaluation and dynamic weighted fusion, this invention achieves an upgrade from simple "single input, single output" control to intelligent decision-making of "multi-feature input - multi-strategy evaluation - comprehensive decision output." The system can automatically weigh the expected effects and potential conflicts of different regulation methods, generate coordinated and optimized control commands, and avoid contradictory equipment actions and environmental parameter oscillations. Attached Figure Description
[0015] Figure 1 A schematic diagram illustrating the steps of an intelligent automatic control method for sheepfold environment;
[0016] Figure 2 for Figure 1 A detailed flowchart illustrating the implementation steps of step S2.
[0017] Figure 3 A schematic diagram of the automatic environmental control process in an intelligent sheepfold.
[0018] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0019] The technical method of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present 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.
[0020] Furthermore, the accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor methods and / or microcontroller methods.
[0021] It should be understood that although the terms "first," "second," etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are used merely to distinguish one unit from another. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0022] To achieve the above objectives, please refer to Figures 1 to 3 A method for automatic environmental control in intelligent sheepfolds includes the following steps:
[0023] Step S1: Obtain environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information;
[0024] Step S2: Generate an initial set of control strategies based on the control target range in the environmental status information;
[0025] Step S3: Based on environmental state information, perform adaptive scoring on each parameter in the initial set of control strategies, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters;
[0026] Step S4: Control the sheepfold to perform environmental regulation operations according to the comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.
[0027] All specific values involved in this embodiment are exemplary parameters used to clearly illustrate the technical operation process and are not the only limitation of the present invention.
[0028] In one embodiment, a sensor network consisting of a temperature sensor, a humidity sensor, a carbon dioxide sensor, an ammonia sensor, and a light sensor collects values from various monitoring points within the sheepfold at 5-minute intervals to form environmental parameter data. A camera installed in the sheepfold captures a video stream at 25 frames per second, generating sheep activity image data. The program compares the collected environmental parameter data with a preset normal range. For data points exceeding the range, the linear interpolation result of two adjacent normal cycle values from the sensor is used to replace the data, generating corrected environmental data. The YOLOv5 target detection algorithm is used to identify the bounding box positions of all sheep in each frame of the image, generating a list containing coordinate information to form target recognition data. The Kalman filter algorithm is used to predict and track the position of each sheep based on the target recognition data, and the position is matched with the detection result of the next frame using the Hungarian algorithm to form a sequence of movement trajectories for each sheep. Histogram of Oriented Gradients (HGP) features are extracted from each bounding box and input into a trained Support Vector Machine (SVM) classifier. This classifier outputs one of six behavioral labels: "standing," "lying down," "walking," "running," "drinking," and "feeding." This process generates sheep behavior feature data containing time series, coordinate series, and behavior label series. When establishing associations between the two types of data, alignment is achieved using a unified timestamp, and the sheepfold floor is divided into 1m x 1m grids. For each 5-minute time interval, the average value of each environmental parameter within each grid is calculated, and the frequency of behaviors such as "lying down" and "walking" within that grid is also statistically analyzed. Spearman's rank correlation coefficients are calculated between indicators such as "temperature" and "lying down frequency," and "ammonia concentration" and "average movement speed" within each grid, generating a correlation matrix. The environmental parameter matrices, behavioral statistics matrices, and correlation matrices of each grid are integrated and packaged to generate environmental state information containing spatiotemporal coupling information.
[0029] The main behavioral patterns are identified from the environmental status information generated in step S1. When the "lying down" behavior accounts for more than 60%, it is determined to be "resting mode". The program accesses a preset rule table, which is indexed by "growing sheep - daytime - resting mode", and extracts the corresponding target temperature range [15,20] degrees Celsius, target humidity range [50,65]%, target light range [15,30] Lux, and upper limit of ammonia 15 ppm, and combines them into target parameter ranges. The average temperature of 22 degrees Celsius and the average light of 10 Lux for the latest time period are read from the environmental status information. The current value of 22 degrees Celsius is compared with the target range [15,20], and a positive deviation of +2 degrees Celsius is calculated; 10 Lux is compared with [15,30], and a negative deviation of -5 Lux is calculated, generating deviation quantification data containing the direction and magnitude of deviation for each parameter. The deviation quantification data is partially matched with the conditions of the preset rule base, which includes rules such as "if the positive temperature deviation is >1.5 degrees Celsius, start fan No. 1 to 50% power and turn on water curtain No. 1 to 30% flow rate". The matching process finds all rules that meet the conditions, collects the control command groups corresponding to each rule, and forms an initial control strategy set. This set contains a combination of equipment control schemes to correct various deviations.
[0030] The current feature vector is extracted from environmental state information, including the proportion of "lying down," "grazing," and "walking" behaviors, the distribution density of sheep in resting and grazing areas, and the spatial standard deviations of temperature and ammonia concentration. For each strategy in the initial set of control strategies, its execution effect is simulated. For example, for a strategy including "opening side windows for ventilation," the increase in wind speed and the decrease in ammonia concentration are predicted based on the equipment impact model, and the impact on the proportion of "lying down" behavior is estimated. The prediction results are compared with the current feature vector to calculate a matching score. The scoring rule is: a high score is awarded if the strategy prediction significantly improves the most undesirable indicator, and a deduction is applied if it causes new adverse changes. Each strategy receives an adaptability score of 0-100. Strategies with scores higher than 60 are weighted according to their scores. A weighted average is calculated for the equipment control parameters in all strategies with non-zero weights. For example, if Strategy A (score 80) recommends 50% wind turbine power and Strategy B (score 70) recommends 30%, then the final wind turbine power will be (80×50%+70×30%)÷(80+70)≈41%. Perform this calculation on all equipment parameters to generate comprehensive control parameters that include a table of target state instructions for each piece of equipment.
[0031] The central controller sends comprehensive control parameter command tables to the actuators of each device via the fieldbus protocol. The command "Fan 1 power 41%" is converted into a frequency setpoint for the inverter, and "Side window opening 60%" is converted into a pulse command for the servo motor. All commands are issued synchronously within a millisecond time window. After the equipment starts execution, the sensor network collects real-time environmental feedback data once per minute. After a preset 15-minute evaluation cycle, the feedback data for that cycle is summarized, and the average value of each parameter after control is calculated. The average temperature of 19.5 degrees Celsius and the average ammonia concentration of 12 ppm after control are compared with the original 22 degrees Celsius and 18 ppm, and the changes are calculated. The percentage of "lying down" behavior after control is statistically analyzed, changing from 65% to 72%. The actual operating status of each device is compared with the command, and the deviation between the actual average power of Fan 1 (40.5%) and the command (41%) is recorded. By integrating the above comparative data, equipment status, and changes in key indicators, an environmental control result report is generated, which includes a comparison table of values before and after control and a report on the compliance of equipment performance. This report is stored in the database and displayed on the monitoring interface, thus completing closed-loop control.
[0032] Please refer to [link / reference needed] for further information. Figure 3 The process involves collecting environmental parameters and sheep images; analyzing the collected data to generate control strategies; integrating multi-source data and optimizing control parameters; and finally generating equipment control commands and providing feedback on the control effects.
[0033] Preferably, step S1 includes the following steps:
[0034] Step S11: Obtain environmental parameter data and sheep activity image data inside the sheepfold;
[0035] Step S12: Detect outliers in the environmental parameter data, correct the outliers, and generate corrected environmental data;
[0036] Step S13: Perform target behavior analysis on sheep activity image data to generate sheep behavior feature data;
[0037] Step S14: Establish a spatiotemporal correlation mapping between the corrected environmental data and sheep behavioral characteristic data to generate fused environmental state information.
[0038] In one embodiment, data acquisition is accomplished using physical devices deployed within the sheepfold. Temperature, humidity, carbon dioxide, ammonia, and light sensors are installed at fixed, equidistant locations on the ceiling inside the sheepfold. These sensors are connected to a central controller via a data bus. Network cameras are installed at the four corners and the center of the sheepfold. The sensor network collects data at a fixed 5-minute interval. The central controller reads the temperature, humidity, carbon dioxide, ammonia, and light intensity values from each sensor, adding a timestamp and device number to form environmental parameter data. The network cameras capture video streams at 25 frames per second. The video streams are transmitted to a video processing server, which decodes the video streams to generate a continuous sequence of video frames, forming sheep activity image data. The environmental parameter data is stored in the raw data table of the database, while the video frame sequence is stored in a designated directory of the file system.
[0039] The environmental parameter data obtained in step S11 is processed. The program reads data sequences from each sensor within a specified time period from the database. The data processing unit detects each data sequence and sets a normal value range for each type of sensor data. This range is based on long-term historical data statistics of the sensor. Each measured value in the data sequence is compared with the corresponding normal value range. Values exceeding the range are marked as outliers, generating a data anomaly marker record. After detection, each marked outlier is corrected. The correction method is to find the preceding and following normal measured values in the time series for each outlier, and replace the value of the outlier with the arithmetic mean of these two normal values. The same anomaly detection and value correction process is performed on all sensor data sequences to generate corrected environmental data, which is stored in the corrected data table. This process eliminates erroneous data caused by momentary sensor failures or interference.
[0040] The sheep activity image data acquired in step S11 is processed. The video processing server loads the stored video frame sequence. For each frame, the target detection module runs a trained recognition model trained on the sheep image data, capable of identifying the position of each sheep in the image. The model outputs the bounding box coordinates of each detected sheep. The bounding box information of all sheep in a frame, together with the frame timestamp, constitutes the target recognition data. The tracking module associates the target recognition data of consecutive frames, assigning a unique identification number to each sheep appearing in the image, and connecting the positions of the same sheep in different frames to form a motion trajectory coordinate sequence for each sheep. The behavior analysis module analyzes the image region of each bounding box in the trajectory sequence, extracts image features, and uses a classifier to classify the features, determining whether the sheep's behavior at that moment belongs to one of "standing," "lying down," "walking," "running," "drinking," or "grazing," and assigns a behavior label to each time point in the trajectory sequence. Sheep behavior feature data containing sheep identification numbers, timestamp sequences, coordinate sequences, and behavior label sequences is generated and stored in a specified file.
[0041] Based on the corrected environmental data generated in step S12 and the sheep behavior characteristic data generated in step S13, a correlation is established between the two. The spatiotemporal alignment procedure reads the corrected environmental data from the database and the sheep behavior characteristic data from the file. Using a unified system time base, the two types of data are divided into the same fixed time window. Spatial processing divides the sheepfold floor into grids of equal area, each grid with a unique number. For each time window, the behavior of all sheep falling into each grid is counted, and the frequency of each type of behavior is calculated. The average values of each environmental parameter within the same time window and the same grid area are obtained from the corrected environmental data. Correlation analysis calculates the correlation coefficient between the average value of each environmental parameter and the frequency of each type of behavior for each grid within each time window. For example, the correlation coefficient between the average temperature of the grid and the frequency of the sheep's "lying down" behavior is calculated. A relation matrix is generated for each grid. The rows of the matrix correspond to different environmental parameters, the columns correspond to different behaviors, and the values in the matrix are correlation coefficients. The fusion program packages the grid number, time window identifier, set of average environmental parameter values, set of behavior statistics, and relation matrix for each grid to generate fused environmental state information containing multi-dimensional information of time, space, environment, and behavior, and stores it in a new data table.
[0042] Preferably, step S12 includes the following steps:
[0043] Step S121: Perform extreme value analysis on the environmental parameter data, identify data points that exceed the preset normal range, and generate data anomaly markers;
[0044] Step S122: Based on the data anomaly marking, interpolate and fill the abnormal data points to generate corrected environmental data.
[0045] In one embodiment, the process is based on the environmental parameter data obtained in step S11. The data processing program reads the temperature data sequence of a specified sensor over the past 24 hours from the raw data table in the database. The program calculates the arithmetic mean and standard deviation of the temperature data sequence. The upper limit of the preset normal range is set to the average value plus three times the standard deviation, and the lower limit is set to the average value minus three times the standard deviation. The program compares each measured value in the temperature data sequence with the preset normal range, determining whether the measured value is less than the lower limit or greater than the upper limit. When a temperature measured value is less than the lower limit or greater than the upper limit, the program sets a flag in the record corresponding to that measured value, marking the record as abnormal. The program also records the acquisition timestamp, sensor device number, original measured value, and calculated upper and lower limits for the abnormal data point. The data anomaly marking information generated in this process is a structured record list containing timestamp, device number, parameter type, original value, marking status, upper limit, and lower limit. The program repeatedly performs the same extreme value analysis and labeling process on the data sequences of four parameters: humidity, carbon dioxide concentration, ammonia concentration, and light intensity. All abnormal labeling records of the five environmental parameters are organized and written into the data table, completing the identification and recording of data points that exceed the preset normal range.
[0046] The calibration process is based on the data anomaly markings generated in step S121. The calibration procedure reads all data records marked as anomaly from the data table. Based on the timestamp and device number in the anomaly record, the program locates the corresponding anomaly data point in the original data sequence. For each anomaly data point, the program searches forward and backward along the time axis in the sensor's data sequence to find the closest preceding and following normally marked measurement values. The program calculates the arithmetic mean of these two normally marked measurements and replaces the anomaly value in the original data sequence with this calculated arithmetic mean. Interpolation filling is performed point-by-point on all marked anomaly data points, overwriting the old values in the original database with the calculated new values. After processing, the program generates a new dataset containing timestamps, sensor numbers, parameter types, and calibrated measurement values; this dataset is the calibrated environmental data. The program writes this dataset into the database table, replacing the original records containing erroneous values. This process ensures that all environmental parameter data upon which subsequent processing and analysis are based are within a reasonable and normal range defined by historical data statistics, thus preventing erroneous data caused by momentary sensor interference or reading errors from entering the subsequent analysis process.
[0047] Preferably, step S13 includes the following steps:
[0048] Step S131: Perform target recognition on sheep activity image data, extract sheep target location and contour information, and generate target recognition data;
[0049] Step S132: Perform time-series analysis on the target recognition data to identify the sheep's movement trajectory and posture change patterns, and generate sheep behavior feature data.
[0050] In one embodiment, the implementation is based on sheep activity image data obtained in step S11. A video processing server loads the stored video stream file and decodes it into a continuous image sequence in chronological order. The target recognition module processes each frame of the color image, scaling each frame to a standard size of 640 pixels in both width and height, and inputs it into a pre-trained recognition neural network. This neural network is trained on tens of thousands of images labeled with sheep locations and can identify sheep in the images. The neural network outputs the coordinates of each box identified as a sheep, its recognition confidence level, and its category label. The program filters recognition results with the category label "sheep" and a recognition confidence level greater than 50%. For each retained recognition result, the box coordinates are represented in the format of center point x-coordinate, center point y-coordinate, box width, and box height. The center point x-coordinate and center point y-coordinate represent the position of the box center point in the original image, and the box width and height represent the size of the box. After processing each frame, a list containing the frame timestamp and the box coordinates of all identified sheep in that frame is generated. This data structure, which contains timestamps and a series of coordinate information, is defined as target identification data and stored in a specific format.
[0051] The implementation is based on the target recognition data generated in step S131. The multi-target tracking program reads target recognition data from multiple consecutive frames. For the first frame of the video, the program initializes an independent state tracker for each sheep bounding box listed in the frame and assigns a unique trajectory number to each tracker. Starting from the second frame, the program compares all bounding boxes identified in the current frame with the predicted positions of existing trajectories. The predicted positions are calculated by the state tracker corresponding to each trajectory based on the position in the previous frame. The program calculates the overlap ratio between each identified bounding box and each predicted trajectory bounding box in the current frame. Through a matching algorithm, the program optimizes the pairing of the identified bounding boxes in the current frame with existing trajectories, thus establishing the association between the identified bounding boxes and trajectories. Successfully paired bounding boxes are used to update the state tracker of the corresponding trajectory, while unpaired bounding boxes are used to create new trajectories. Unpaired trajectories retain their predictions in subsequent frames. This process generates a trajectory sequence for each sheep, containing continuous timestamps and corresponding bounding box coordinates. Subsequently, the behavior classification module processes each bounding box in the trajectory sequence. The program extracts the image region corresponding to the bounding box from the original video frame and calculates the directional gradient features of the image region. The calculation process involves dividing the image region into multiple small units, statistically analyzing the direction of pixel gradients within each unit, and concatenating the statistical results from multiple units into a feature array. This feature array is then input into a pre-trained multi-class behavior classifier. The classifier outputs the distribution of six behaviors: standing, lying down, walking, running, drinking, and eating. The behavior with the highest value is used as the behavior label for that bounding box at that moment. For each trajectory, a data record is generated containing a trajectory number, a timestamp sequence, a bounding box coordinate sequence, and a corresponding behavior label sequence. This record constitutes the sheep behavior feature data.
[0052] Preferably, step S14 includes the following steps:
[0053] Step S141: Perform timestamp alignment processing on the corrected environmental data and sheep behavioral characteristic data to generate spatiotemporally aligned data;
[0054] Step S142: Based on the spatiotemporal aligned data, calculate the correlation matrix between environmental parameters and sheep behavior within a unit time space, and generate fused environmental state information.
[0055] In one embodiment, the corrected environmental data generated in step S12 and the sheep behavior feature data generated in step S13 are implemented. The time alignment program reads data records containing acquisition timestamps, sensor numbers, temperature values, humidity values, carbon dioxide concentration values, ammonia concentration values, and light intensity values from the corrected environmental data table, and reads data records containing trajectory numbers, timestamp sequences, box coordinate sequences, and behavior label sequences from the sheep behavior feature data file. The alignment process uses a fixed five-minute time window to divide the two types of data into the same window. For each time window, the program filters all environmental data records whose acquisition timestamps fall within the window, calculates the arithmetic mean of all recorded values for each environmental parameter within the window, and obtains the representative values of the environmental parameters for that time window, including average temperature, average humidity, average carbon dioxide concentration, average ammonia concentration, and average light intensity. At the same time, it filters all sheep behavior records whose timestamp sequences fall within the window, counts the behavior labels of each sheep within the window, calculates the frequency of each of the six behaviors (standing, lying down, walking, running, drinking, and eating), and records the average pixel coordinates of the center points of all sheep boxes within the window. Spatial alignment processing divides the sheepfold floor into 1-meter by 1-meter squares, each with a unique row and column number. For each time window, the number of sheep whose center point falls within each square in the behavior records is counted, and the total number of occurrences of each type of sheep behavior within that square is calculated. From representative environmental parameter values, all sensor data within a 3-meter radius of the square's center point are extracted, and the quadratic average of these sensor values for that window is calculated as the environmental parameter value for that square within that window. The generated data includes the time window identifier, square number, set of environmental parameter values for that square, number of sheep within that square, and number of occurrences of each type of sheep behavior within that square. This collection of data constitutes the spatiotemporally aligned data.
[0056] This is implemented based on the spatiotemporally aligned data generated in step S141. The correlation calculation program reads the spatiotemporally aligned data. The program selects data records with the same time window and the same grid number for processing. The data sequence of each grid within 20 consecutive time windows is analyzed. The average temperature and average ammonia concentration from the environmental parameter value set are selected as the environmental factors to be analyzed, and the number of lying down behaviors and the number of walking behaviors from the behavior frequency set are selected as the behavioral factors to be analyzed. The correlation coefficients between the average temperature sequence and the lying down behavior frequency sequence, the average temperature sequence and the walking behavior frequency sequence, the average ammonia concentration sequence and the lying down behavior frequency sequence, and the average ammonia concentration sequence and the walking behavior frequency sequence are calculated. The correlation coefficient calculation uses statistical methods to measure the consistency of the changing trends of the two data sequences. The calculation result is a value between -1 and 1; a positive value indicates the same trend, a negative value indicates the opposite trend, and a larger absolute value indicates a stronger correlation. For each square, the four calculated correlation coefficient values are arranged into a two-row, two-column matrix. The first row of the matrix corresponds to the correlation coefficient between average temperature and the two behaviors, and the second row corresponds to the correlation coefficient between average ammonia concentration and the two behaviors. The square's number, the environmental parameter value for that square in the most recent time window, the number of sheep and the number of behaviors for that square in the most recent time window, and the calculated correlation coefficient matrix are integrated to generate a complete record. All square records are arranged in numerical order to form fused environmental state information, which is then written to the state information table in the database.
[0057] Preferably, step S2 includes the following steps:
[0058] Step S21: Extract the preset control target ranges of temperature, humidity, and light intensity from the fused environmental state information, and generate the target parameter range;
[0059] Step S22: Based on the target parameter range, calculate the difference between the actual measured value of the current environment and the target parameter range, and generate deviation quantification data;
[0060] Step S23: Based on the deviation quantification data, match the corresponding control parameter group in the preset environmental adjustment parameter library to generate an initial control strategy set.
[0061] In one embodiment, the fused environmental state information generated in step S1 is implemented. The interval extraction program reads the latest state record from the data table, which contains statistics on sheep behavior within each grid. The program calculates the proportion of "lying down" behavior in the total number of behaviors; if the proportion is greater than 60%, the current state is determined to be "resting mode". The program queries the control rule table, which is indexed by "growth stage - time period - behavior mode". Assuming the current state is "growing sheep - daytime - resting mode", the query returns the target temperature range of [15, 20] degrees Celsius, the target humidity range of [50, 65]%, and the target light range of [15, 30] lux. The program combines these value ranges to generate target parameter range data containing upper and lower limits of the three parameters.
[0062] The program is implemented based on the target parameter range. It extracts environmental data for all grid cells within the most recent 5-minute time window from the latest status information. The average temperature value for all grid cells is calculated to be 22 degrees Celsius, the average humidity to be 55%, and the average illumination to be 10 lux. The comparison module compares 22 degrees Celsius with the target range [15,20], resulting in a positive deviation of +2 degrees Celsius. It compares 10 lux with the target range [15,30], resulting in a negative deviation of -5 lux. The average humidity of 55% falls within the target range [50,65], with a deviation of 0, generating quantified deviation data including a temperature deviation of +2, a humidity deviation of 0, and an illumination deviation of -5.
[0063] Implementation is based on deviation quantification data. The strategy matching engine loads the environmental adjustment parameter library, with one rule being "IF temperature deviation > 1.5 THEN: Fan 1 power = 50%; Water curtain 1 flow rate = 30%". Another rule is "IF illumination deviation < -3 THEN: Supplemental lighting group A brightness = 70%". The matching engine compares the deviation quantification data with the rule conditions. A temperature deviation of +2 satisfies the first rule condition, and an illumination deviation of -5 satisfies the second rule condition. Both rules are triggered, generating control strategies containing corresponding control commands. The two strategies form the initial control strategy set: the first strategy command is to start fan 1 to 50% power and turn on water curtain 1 to 30% flow rate; the second strategy command is to turn on supplemental lighting group A to 70% brightness.
[0064] Preferably, step S22 includes the following steps:
[0065] Step S221: Obtain the actual measured values of current temperature, humidity, and light intensity from the fused environmental status information, and generate the actual measured values of the current environment;
[0066] Step S222: Compare the actual measured values of the current environment with the upper and lower boundaries of the target parameter range, calculate the upper and lower deviations respectively, and generate deviation quantification data.
[0067] In one embodiment, the fused environmental state information generated in step S1 is implemented. The numerical extraction program queries the latest data record from the data table recording the fused environmental state information. This record contains the environmental parameter values of all 1m × 1m grids in the sheepfold within the most recent 5-minute time window. The program iterates through the data of all grids in the record, reading the "temperature" field value of each grid. The arithmetic mean of these temperature values is calculated to obtain the current average temperature value of the sheepfold, which is recorded as the current actual temperature measurement value. The program iterates through all grids again, reading the "humidity" field value of each grid, and calculates the arithmetic mean of these humidity values to obtain the current actual humidity measurement value. The program iterates through all grids a third time, reading the "light intensity" field value of each grid, and calculates the arithmetic mean of these light intensity values to obtain the current actual light intensity measurement value. The calculated average temperature value, average humidity value, and average light intensity value are integrated into a data structure. This data structure containing three specific values is defined as the current actual environmental measurement value.
[0068] In one embodiment, the implementation is based on the actual measured value of the current environment generated in step S221 and the target parameter range generated in step S21. The comparison module reads the average temperature value from the actual measured value of the current environment, and simultaneously reads the temperature target range stored in the target parameter range, for example, a lower limit of 15 degrees Celsius and an upper limit of 20 degrees Celsius. The comparison module performs a comparison operation: if the average temperature value is greater than 20 degrees Celsius, the difference between the average temperature and 20 is calculated and recorded as the upper temperature deviation, while the lower temperature deviation is recorded as 0; if the average temperature value is less than 15 degrees Celsius, the difference between 15 and the average temperature is calculated and recorded as the lower temperature deviation, while the upper temperature deviation is recorded as 0; if the average temperature value is between 15 and 20, both the upper and lower temperature deviations are recorded as 0. The same comparison logic is performed for humidity and light intensity. For example, if the average humidity is 55%, compared with the target range [50, 65], since 55 is greater than 50 and less than 65, both the upper and lower humidity deviations are 0. The average illumination is 10 lux. Compared with the target range [15,30], since 10 is less than 15, we calculate 15-10=5, which is recorded as the lower illumination deviation. The upper illumination deviation is recorded as 0. A data record is generated that records the upper and lower deviations of each parameter. For example, the upper deviation of temperature is +2 and the lower deviation is 0, the upper / lower deviation of humidity is 0, and the upper illumination deviation is 0 and the lower deviation is +5. This record is the deviation quantification data.
[0069] Preferably, step S23 includes the following steps:
[0070] Step S231: Based on the deviation quantification data, determine the direction and magnitude of the deviation of each environmental factor, and generate deviation level and direction signals;
[0071] Step S232: Based on the deviation level and direction signal, query the corresponding control parameter group in the preset environmental adjustment parameter library to generate an initial control strategy set.
[0072] In one embodiment, the deviation quantification data generated in step S22 is implemented. The signal generation program reads the deviation quantification data, which records the values of the upper and lower deviations of temperature, humidity, and illumination. The program determines the deviation direction of each environmental factor. For the temperature factor, its upper deviation value is checked. If it is greater than 0, the temperature deviation direction is determined to be positive, i.e., too high; if the lower deviation value is greater than 0, it is determined to be negative, i.e., too low; if both are 0, it is determined to be no deviation. The program also determines the deviation amplitude level, which is based on comparing the deviation value with a preset threshold. For example, the temperature deviation amplitude determination rule is: if the absolute value of the deviation is between 0 and 1, the level is level 1; between 1 and 2, the level is level 2; and greater than 2, the level is level 3. For a temperature upper deviation of +2, the program determines the direction to be positive and the amplitude to be level 2. For the humidity factor, both its upper and lower deviations are 0, the program determines the direction to be none and the amplitude to be level 0. For an illumination lower deviation of +5, the program determines the direction to be negative and the amplitude to be level 3. The program integrates the direction and amplitude information of each factor to generate a set of structured signals containing three elements. Each element contains an environmental factor name, a direction identifier, and an amplitude level value. This set of signals is defined as the deviation level and direction signal.
[0073] The program is implemented based on the deviation level and direction signals generated in step S231. It loads a preset environmental control parameter library, which stores multiple records in list form. Each record contains a deviation condition and a set of control parameters. The deviation condition describes a combination of a specific environmental factor, a specific direction, and a specific amplitude level. The control parameter set describes a series of equipment control commands to be executed. The query engine precisely matches the signals generated in step S231 with the deviation conditions of each record in the parameter library. For example, if the signal indicates "temperature, positive, level 2," and there is a record in the parameter library with the condition "when the temperature deviation is positive and the amplitude is greater than or equal to level 2," the query engine determines that they match. The signal indicating "illuminance, negative, level 3" also matches the record with the condition "when the illuminance deviation is negative and the amplitude is greater than or equal to level 2." The query engine collects all successfully matched records. The control parameter set corresponding to each matched record is extracted. For example, the control parameter set matching "temperature, positive, level 2" is "fan 1 power = 50%, water curtain 1 flow rate = 30%." The control parameter set matching "illuminance, negative, level 3" is "supplementary light group A brightness = 70%". The program integrates these control parameter sets obtained from the parameter library into a list. This list contains the equipment control schemes to be executed to correct the currently identified environmental deviations. This list is defined as the initial control strategy set.
[0074] Preferably, step S3 includes the following steps:
[0075] Step S31: Extract the current distribution characteristics of sheep behavior and environmental parameters from the fused environmental state information to generate dynamic environmental features;
[0076] Step S32: Evaluate the matching degree between the dynamic environmental characteristics and each control parameter group in the initial control strategy set to generate an adaptability score result;
[0077] Step S33: Based on the adaptability score results, dynamically assign weights to each control parameter group and generate comprehensive control parameters through a weighted fusion algorithm.
[0078] In one embodiment, the fused environmental state information generated in step S1 is implemented. A feature extraction program extracts specific fields from the latest data record of this information for calculation. The program extracts the total number of times sheep exhibit the "lie down" behavior across all grids, divides it by the total number of all behaviors to obtain the current proportion of lying down behavior. It extracts the spatial distribution coordinates of sheep across all grids and calculates the proportion of sheep concentrated in the resting area grids. It extracts the temperature values of all grids and calculates the standard deviation of these temperature values to obtain a temperature spatial distribution uniformity index. It extracts the ammonia concentration values of all grids and calculates the average value of these concentrations. These calculated values, including the proportion of lying down behavior, sheep resting area concentration, temperature spatial standard deviation, and average ammonia concentration, are combined into a four-dimensional vector. This vector reflects the sheep's behavioral preferences, spatial aggregation state, and the spatial variation and average level of key environmental parameters at the current moment; this vector is defined as a dynamic environmental feature.
[0079] The program implements the dynamic environmental features generated in step S31 and the initial control strategy set generated in step S2. The evaluation program processes each control parameter group in the set sequentially. For each control parameter group, the program estimates the impact on the dynamic environmental features after execution, based on the included equipment control instructions. For example, for a control strategy containing "turn on the fan for ventilation," the estimated logic is: ventilation will cause the average temperature to decrease by 1 degree Celsius, the ammonia concentration to decrease by 2 ppm, and a slight decrease in the proportion of sheep lying down. The program compares the estimated changes with the current dynamic environmental feature vector. The scoring rule is: if the estimated change improves the current undesirable features, points are added; if the current average ammonia concentration is high, and the strategy is estimated to reduce the ammonia concentration, then this strategy scores points in the ammonia improvement category. If the estimated change leads to new adverse changes, points are deducted. For example, if the current lying-down proportion is moderate, and the strategy is estimated to slightly reduce the lying-down proportion, then points are deducted in this category. The program calculates a comprehensive score for each strategy, with a score range of 0 to 100 points. Perform this evaluation process on all policies in the set, generating a score from 0 to 100 for each policy. The set of these scores constitutes the adaptive scoring results.
[0080] The implementation is based on the adaptive scoring results generated in step S32. The weight allocation program reads each control strategy and its corresponding score. The program sets a threshold of 60 points. Strategies with scores below 60 points have their weights set to 0. Strategies with scores above or equal to 60 points have their weights allocated proportionally to their scores relative to the total scores of all qualified strategies. For example, if strategy A scores 80 and strategy B scores 70, both are qualified, and the total score is 150, then the weight of strategy A is 80 / 150≈0.533, and the weight of strategy B is 70 / 150≈0.467. The weighted fusion algorithm processes all strategies with non-zero weights. The algorithm calculates independently for each controlled device parameter. Taking the "fan 1 power" parameter as an example, strategy A's instruction is 50%, and strategy B's instruction is 30%. The weighted calculation is: 50%*0.533 + 30%*0.467 = 40.6%. Perform the same weighted calculation on the control parameters of all devices in the set to obtain a unique, integrated control parameter value for each device. Integrate all the calculated device control parameter values to form a new control command table, which is defined as the integrated control parameter.
[0081] The present invention also provides an intelligent sheepfold environment automatic control system for performing the intelligent sheepfold environment automatic control method described above. The intelligent sheepfold environment automatic control system includes:
[0082] The data acquisition module is used to acquire environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information.
[0083] The initial control strategy generation module is used to generate an initial control strategy set based on the control target range in the environmental state information;
[0084] The adaptive scoring module is used to adaptively score each parameter in the initial set of control strategies based on environmental state information, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters.
[0085] The environmental regulation operation module is used to control the sheepfold to perform environmental regulation operations based on comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.
[0086] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.
Claims
1. A method for automatic environmental control in an intelligent sheepfold, characterized in that, Includes the following steps: Step S1: Obtain environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information; Step S2: Generate an initial set of control strategies based on the control target range in the environmental status information; Step S3: Based on environmental state information, perform adaptive scoring on each parameter in the initial set of control strategies, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters; Step S4: Control the sheepfold to perform environmental regulation operations according to the comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.
2. The intelligent sheepfold environment automatic control method according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Obtain environmental parameter data and sheep activity image data inside the sheepfold; Step S12: Detect outliers in the environmental parameter data, correct the outliers, and generate corrected environmental data; Step S13: Perform target behavior analysis on sheep activity image data to generate sheep behavior feature data; Step S14: Establish a spatiotemporal correlation mapping between the corrected environmental data and sheep behavioral characteristic data to generate fused environmental state information.
3. The intelligent sheepfold environment automatic control method according to claim 2, characterized in that, Step S12 includes the following steps: Step S121: Perform extreme value analysis on the environmental parameter data, identify data points that exceed the preset normal range, and generate data anomaly markers; Step S122: Based on the data anomaly marking, interpolate and fill the abnormal data points to generate corrected environmental data.
4. The intelligent sheepfold environment automatic control method according to claim 2, characterized in that, Step S13 includes the following steps: Step S131: Perform target recognition on sheep activity image data, extract sheep target location and contour information, and generate target recognition data; Step S132: Perform time-series analysis on the target recognition data to identify the sheep's movement trajectory and posture change patterns, and generate sheep behavior feature data.
5. The intelligent sheepfold environment automatic control method according to claim 2, characterized in that, Step S14 includes the following steps: Step S141: Perform timestamp alignment processing on the corrected environmental data and sheep behavioral characteristic data to generate spatiotemporally aligned data; Step S142: Based on the spatiotemporal aligned data, calculate the correlation matrix between environmental parameters and sheep behavior within a unit time space, and generate fused environmental state information.
6. The intelligent sheepfold environment automatic control method according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Extract the preset control target ranges of temperature, humidity, and light intensity from the fused environmental state information, and generate the target parameter range; Step S22: Based on the target parameter range, calculate the difference between the actual measured value of the current environment and the target parameter range, and generate deviation quantification data; Step S23: Based on the deviation quantification data, match the corresponding control parameter group in the preset environmental adjustment parameter library to generate an initial control strategy set.
7. The intelligent sheepfold environment automatic control method according to claim 6, characterized in that, Step S22 includes the following steps: Step S221: Obtain the actual measured values of current temperature, humidity, and light intensity from the fused environmental status information, and generate the actual measured values of the current environment; Step S222: Compare the actual measured values of the current environment with the upper and lower boundaries of the target parameter range, calculate the upper and lower deviations respectively, and generate deviation quantification data.
8. The intelligent sheepfold environment automatic control method according to claim 6, characterized in that, Step S23 includes the following steps: Step S231: Based on the deviation quantification data, determine the direction and magnitude of the deviation of each environmental factor, and generate deviation level and direction signals; Step S232: Based on the deviation level and direction signal, query the corresponding control parameter group in the preset environmental adjustment parameter library to generate an initial control strategy set.
9. The intelligent sheepfold environment automatic control method according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: Extract the current distribution characteristics of sheep behavior and environmental parameters from the fused environmental state information to generate dynamic environmental features; Step S32: Evaluate the matching degree between the dynamic environmental characteristics and each control parameter group in the initial control strategy set to generate an adaptability score result; Step S33: Based on the adaptability score results, dynamically assign weights to each control parameter group and generate comprehensive control parameters through a weighted fusion algorithm.
10. An intelligent automatic environmental control system for sheep pens, characterized in that, For performing the intelligent sheepfold environment automatic control method as described in claim 1, the intelligent sheepfold environment automatic control system comprises: The data acquisition module is used to acquire environmental parameter data and sheep activity video data inside the sheepfold, process the environmental parameter data and sheep activity video data inside the sheepfold, and generate environmental status information. The initial control strategy generation module is used to generate an initial control strategy set based on the control target range in the environmental state information; The adaptive scoring module is used to adaptively score each parameter in the initial set of control strategies based on environmental state information, and dynamically weight and fuse each parameter according to the scoring results to generate comprehensive control parameters. The environmental regulation operation module is used to control the sheepfold to perform environmental regulation operations based on comprehensive regulation parameters, collect environmental feedback data after execution, and generate an environmental regulation result report.