A meal feeding amount dynamic adjustment method and system for pig individual identification
Patent Information
- Application Number
- CN202611161197.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-10-20
AI Technical Summary
[0005]因此,本发明解决的技术问题是:现有猪只图像数据处理方法仍存在非刚性轮廓条件下局部图像区域几何基准不统一、不同可见区域组合的数据结构不一致、缺失区域和遮挡区域容易干扰图像特征生成、异常局部图像数据难以从多图像融合过程中剔除,以及经处理得到的轨迹级图像数据稳定性不足的问题,难以为猪只餐次数据归属和后续饲喂量调整提供具有一致空间基准和稳定数据结构的图像处理结果
通过按照吻部进入和离开时序、躯干中心点驻留状态及帧间位移连续性分割餐次轨迹,并利用稳定驻留区间两侧的槽重中位基准扣除竞争轨迹对应的槽重变化,实现了餐次时间边界与重量归属边界的同步确定,使短时抬头、称重波动和多猪竞争采食能够分别处理,从而为每条餐次轨迹形成具有明确来源和有效标记的校正槽重下降量。
Smart Images

Figure FT_1 
Figure SMS_1 
Figure SMS_17
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, specifically to a method and system for dynamically adjusting the feeding amount per meal for individual pigs. Background Technology
[0002] Image data processing techniques can transform raw pig images into image features with a unified spatial structure and comparable data format through image segmentation, contour extraction, key location localization, geometric transformation, image registration, texture analysis, and multi-region image fusion. In pig feeding scenarios, it is typically necessary to separate the pig's outline from image data containing the pig, feeding trough, and surrounding background. Local image regions such as the pig's head, ears, and back are then cropped, scaled, oriented, and transformed. Local image data generated at different times are aligned and fused to obtain trajectory image data that characterizes the pig's appearance and movement. The processing results from image segmentation, image transformation, and image fusion can serve as the image data basis for dividing pig meal intervals, comparing local image features, and processing related feeding data.
[0003] However, pigs are image objects with significant non-rigid deformation. Their outline shape, local scale, texture direction, and spatial position continuously change during head lowering, head shaking, turning, and trunk movement. Using fixed rectangular regions for cropping easily includes background pixels, feed trough edge pixels, or pixels of adjacent pigs in the target image area. Using overall outline scaling easily causes head and face texture stretching, ear edge curve distortion, and back stripe position shift, making it difficult to maintain consistent geometric relationships between corresponding areas in different images. Existing image processing methods typically organize local pig image data using uniform size, fixed coordinates, or fixed image regions, making it difficult to establish stable orientation and positional references for different regions such as the head, ears, and back. This results in rotational, scale, and positional deviations in the cropped or scaled local image data. Furthermore, local areas in pig images may be partially missing due to overlapping outlines, pose changes, or areas exceeding the effective outline. Existing methods for processing incomplete image regions typically employ zero-value padding, fixed-length stitching, full-image scaling, or uniform weighting to incorporate missing, occluded, and valid regions into the same image data structure. Zero-value padding alters the original distribution of image features; fixed-length stitching results in inconsistent data positions for different visible region combinations; and uniform weighting allows regions with low integrity, strong occlusion, or unstable image details to have the same impact on the fusion result as valid regions. Therefore, even if different pig images contain the same valid local regions, inconsistencies in image feature data may arise due to differences in padding values, region arrangement, or fusion ratios. Summary of the Invention
[0004] In view of the above-mentioned problems, the present invention is proposed.
[0005] Therefore, the technical problem solved by this invention is that existing pig image data processing methods still have problems such as inconsistent geometric benchmarks of local image regions under non-rigid contour conditions, inconsistent data structures of different visible region combinations, the ease with which missing and occluded regions can interfere with image feature generation, difficulty in removing abnormal local image data from the multi-image fusion process, and insufficient stability of the processed trajectory-level image data. These problems make it difficult to provide image processing results with consistent spatial benchmarks and stable data structures for pig meal data attribution and subsequent feed amount adjustment.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a method for dynamically adjusting the feeding amount of individual pigs based on individual identification, including acquiring continuous images of the feed trough inlet and the trough weight sequence, segmenting the feeding trajectory according to the snout entry and exit sequence, and correcting the trough weight decrease according to the stable residence interval.
[0007] The visible area fusion features of the meal trajectory are constructed to determine the trajectory identity confidence through cross-frame mutual verification, and the correction slot weight drop amount is assigned when the confirmation conditions are met.
[0008] The candidate amount for the next meal is calculated based on the cumulative amount of meals for the corresponding pigs, the target daily feed curve, and the trajectory identity confidence level. The feed intake is then controlled after the target amount for the next meal is limited by the boundary of the change between adjacent meals.
[0009] As a preferred embodiment of the method for dynamically adjusting the feeding amount of individual pigs based on individual pig identification according to the present invention, the segmentation of the feeding trajectory according to the snout entry and exit sequence includes locating the feeding trough opening area, the key point of the pig's snout, and the center point of the torso in each frame of a continuous image of the feeding trough entrance. The first frame moment when the key point of the snout enters the feeding trough opening area from the outside and the center point of the torso is continuously located within the feeding channel is recorded as the starting point of the feeding session. The first frame moment when the key point of the snout leaves the feeding trough opening area and the center point of the torso is continuously left the feeding channel is recorded as the ending point of the feeding session. The pig contours between the starting point and the ending point of the feeding session are connected according to the inter-frame displacement continuity of the same center point of the torso to form the feeding trajectory, and other pig contours that simultaneously enter the feeding trough opening area are marked as competing trajectories.
[0010] As a preferred embodiment of the method for dynamically adjusting the feeding amount per meal for individual pig identification according to the present invention, the step of correcting the trough weight decrease based on the stable residence interval includes: aligning the timestamp of the trough weight sequence with the frame time of the meal trajectory; selecting the interval after the meal start point where the meal trajectory continuously occupies the feeding channel and the trough weight continuously decreases as the stable residence interval; calculating the median value of the fixed-length trough weight window located before the start boundary and after the end boundary of the stable residence interval to obtain the start trough weight reference and the end trough weight reference; identifying the trough weight change segment corresponding to the competitive trajectory entering the feeding trough opening area; and subtracting the trough weight difference corresponding to the trough weight change segment from the trough weight difference between the start trough weight reference and the end trough weight reference to obtain the corrected trough weight decrease.
[0011] As a preferred embodiment of the method for dynamically adjusting feeding amounts at meal times for individual pig identification described in this invention, the visible region fusion feature for constructing the meal trajectory includes: locating the bases of both ears, the line connecting the eyes, the tip of the nose, and the midline of the back within the pig's outline in each frame of the meal trajectory; and dividing the area into a head and face texture region, an ear edge shape region, and a back marking region based on the bases of both ears, the line connecting the eyes, the tip of the nose, and the midline of the back. For the head and face texture region, the ear edge shape region, and the back marking region, the complete proportion of the region falling into the pig's outline, the coverage proportion covered by competing trajectories, and the sharpness consistency value with the corresponding region in adjacent frames are calculated respectively. The difference between the complete proportion and the coverage proportion is combined with the sharpness consistency value to generate a region visibility weight. In the head and face texture region, a grayscale direction arrangement with the line connecting the eyes as the directional reference is extracted; in the ear edge shape region, a boundary curvature sequence with the line connecting the bases of both ears as the position reference is extracted; and in the back marking region, a texture distribution sequence with the back midline as the position reference is extracted. The gray-level orientation, boundary curvature sequence, and texture distribution sequence are transformed to the local coordinates established by the corresponding position references, and intra-frame weighting is performed according to the corresponding regional visibility weights to obtain frame-level regional features. The median feature is calculated for the same region's frame-level regional features in the meal trajectory in chronological order. Frame-level regional features whose deviation from the median feature exceeds the trajectory deviation threshold are marked as anomalous features and removed. Region combinations with regional visibility weights greater than the region activation threshold are recorded as visible combination codes. When the regional visibility weight of a region is not greater than the region activation threshold, the regional visibility weights are renormalized only among the remaining activated regions; zero values from inactive regions are not written into the fusion result. The retained gray-level orientation, boundary curvature sequence, and texture distribution sequence are concatenated according to the renormalized regional visibility weights and associated with the visible combination codes to form frame-level fusion features and trajectory-level fusion features, respectively. The trajectory-level fusion features are used as the visible region fusion features.
[0012] As a preferred embodiment of the method for dynamically adjusting the feeding amount of individual pigs for identification according to the present invention, the method for determining the trajectory identity confidence through cross-frame mutual verification includes: establishing an identity template set corresponding to the visible combination code based on the registration image of each pig; each identity template records the head and face texture features, ear edge shape features, back marking features, and the local coordinates of the corresponding features. For the frame-level fusion features of each retained frame, an identity template with the same visible combination code or containing all enabled areas is selected from the identity template set; the region correspondence distance between the frame-level fusion features and the selected identity template is calculated; and the first and second candidate identities in the region correspondence distance ranking and the distance difference between the first and second distances are obtained. When the temporally continuous frame-level fusion features have the same first candidate identity, the feeding trajectory satisfies the inter-frame displacement constraint, and the first candidate identity does not correspond to a competing trajectory at the same frame time, a positive mutual verification record is generated. When the first candidate identity switches between adjacent frames, the same candidate identity simultaneously corresponds to the feeding trajectory and the competing trajectory at the same frame time, or the region correspondence distance exceeds the matching threshold, a conflict mutual verification record is generated. Accumulate positive cross-verification records sequentially along the meal trajectory and deduct conflicting cross-verification records. Combine the accumulated results with the distance difference to generate a frame-level identity score for each candidate identity. Backtrack the frame-level identity scores from the meal endpoint to the meal origin, merging frames that continuously maintain the same candidate identity and do not contain conflicting cross-verification records. Generate a trajectory-level candidate identity score based on the duration of the merged frame segments and the frame-level identity score. Normalize each trajectory-level candidate identity score among all candidate identities, using the normalized result as the trajectory identity confidence level. When the trajectory identity confidence level of the top-scoring identity reaches the confirmation threshold, the top-scoring identity is identified as the corresponding pig, and the correction trough weight reduction is assigned to that pig. When the trajectory identity confidence level does not reach the confirmation threshold, the correction trough weight reduction is marked as an unconfirmed meal amount and is not included in the cumulative meal amount for any pig.
[0013] As a preferred embodiment of the method for dynamically adjusting the feeding amount of individual pigs for individual identification as described in this invention, the step of calculating the candidate amount for the next meal based on the cumulative meal amount, target diet curve, and trajectory identity confidence level of the corresponding pig includes: reading the target diet curve corresponding to the corresponding pig at the current age and current feeding period, and determining the cumulative target amount corresponding to the target diet curve at the start time of the next meal as the cumulative benchmark for the next meal. The corrected trough weight reduction amount assigned to the corresponding pig is summarized and confirmed in chronological order to form the confirmed cumulative meal amount. For the confirmed meal closest to the start time of the next meal, the corrected trough weight reduction amount corresponding to that meal is multiplied by the corresponding trajectory identity confidence level to obtain the confidence corrected meal amount. For each confirmed meal before this most recent meal, the corrected trough weight reduction amount recorded at the time of identity confirmation is accumulated, without repeated confidence level calculation. The confidence corrected meal amount replaces the corrected trough weight reduction amount corresponding to the most recent meal in the confirmed cumulative meal amount to form the confidence corrected cumulative meal amount. Subtract the confidence-corrected cumulative meal amount from the cumulative baseline for the next meal to obtain the amount of supplementary feed up to the start of the next meal. Obtain the curve increment of the target diet curve during the next meal period and the remaining curve increment from the start of the next meal to the end of the current feeding period. Determine the ratio of the curve increment during the next meal period to the remaining curve increment as the allocation coefficient for the next meal. Combine the amount of supplementary feed with the allocation coefficient for the next meal to generate the basic candidate amount. Read the actual feed amount of the previous meal and the corresponding correction trough weight decrease of the previous meal. Subtract the corresponding correction trough weight decrease of the previous meal from the actual feed amount of the previous meal. If the difference is positive, the difference is determined as the uneaten surplus; if the difference is not positive, the uneaten surplus is determined as zero. Multiply the uneaten surplus by the trajectory identity confidence level corresponding to the previous meal to obtain the confidence-corrected surplus. Subtract the confidence-corrected surplus from the basic candidate amount. When the deduction result is less than zero, the candidate quantity for the next meal is set to zero; when the deduction result is not less than zero, the deduction result is set as the candidate quantity for the next meal. The candidate quantity for the next meal is then input into the boundary processing for changes between adjacent meals.
[0014] As a preferred embodiment of the method for dynamically adjusting the feeding amount per meal for individual pig identification described in this invention, the step of controlling feeding after limiting the target amount of the next meal by the boundary of adjacent meal changes includes: reading the target amount of the previous meal and the curve increments of the target diet curve in the previous meal period and the next meal period; adding the absolute value of the difference between the two curve increments to a preset basic step size; and combining the sum with the trajectory identity confidence to obtain the boundary amplitude. Subtracting the boundary amplitude from the target amount of the previous meal yields the lower boundary, and adding the boundary amplitude to the target amount of the previous meal yields the upper boundary. When the candidate amount of the next meal is less than the lower boundary, the lower boundary is determined as the target amount of the next meal. When the candidate amount of the next meal is greater than the upper boundary, the upper boundary is determined as the target amount of the next meal. When the candidate amount of the next meal is between the lower boundary and the upper boundary, the candidate amount of the next meal is determined as the target amount of the next meal. Based on the unit drive quantity calibration relationship of the feeding execution mechanism, the target amount of the next meal is converted into a drive sequence, and the feeding execution mechanism is controlled to feed according to the drive sequence, while simultaneously reading the trough weight sequence. When the increase in trough weight during the feeding process reaches the target amount for the next meal, the drive is stopped. The increase in trough weight at the time of stopping the drive is recorded as the actual feeding amount for this meal, and the actual feeding amount for this meal is used for the calculation of the candidate amount for the next meal.
[0015] As a preferred embodiment of the dynamic adjustment system for individual pig identification and feeding amount according to the present invention, it includes a snout trajectory calibration module, a cross-frame identity verification module, and a feeding amount limiting module.
[0016] The module is used to acquire continuous images of the feed trough inlet and the trough weight sequence, segment the meal trajectory according to the snout entry and exit time sequence, and correct the trough weight drop according to the stable residence interval.
[0017] The module is used to construct visible area fusion features of meal trajectories, determine the trajectory identity confidence through cross-frame mutual verification, and assign the correction slot weight reduction amount when the confirmation conditions are met.
[0018] The module is used to calculate the candidate amount of the next meal based on the cumulative amount of meals for the corresponding pig, the target daily feed curve, and the trajectory identity confidence level, and then control the feeding after limiting the target amount of the next meal by the boundary of the change between adjacent meals.
[0019] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement a method for dynamically adjusting the amount of feed per meal based on individual pig identification.
[0020] A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of a method for dynamically adjusting the amount of feed per meal based on individual pig identification are disclosed.
[0021] The beneficial effects of this invention are: By segmenting the meal trajectory according to the snout entry and exit sequence, the dwell state of the trunk center point, and the inter-frame displacement continuity, and by subtracting the trough weight change corresponding to the competing trajectory using the trough weight median benchmark on both sides of the stable dwell interval, the meal time boundary and weight attribution boundary are synchronously determined. This allows short-term head raising, weighing fluctuations, and multi-pig competitive feeding to be handled separately, thereby forming a corrected trough weight decrease with a clear source and effective marker for each meal trajectory.
[0022] By calculating the visibility weights of the head and face texture area, ear edge shape area, and back pattern area respectively, and using visibility combination coding to limit the template comparison range, and accumulating positive mutual verification records and deducting conflicting mutual verification records along the meal trajectory, cross-frame identity judgment is realized that adjusts with the occlusion state. This ensures that missing areas do not pollute the fusion features with zero values, and conflicts of the same identity corresponding to competing trajectories can be included in the confidence calculation, thereby improving the reliability and traceability of the basis for attributing the correction slot weight reduction.
[0023] By using the cumulative target amount, confirmed cumulative meal amount, latest meal trajectory identity confidence level, and remaining curve increment to form the basic candidate amount, and then using the uneaten surplus amount converted by trajectory identity confidence level to deduct the basic candidate amount, and then using the previous meal target amount, adjacent time period curve increment, and basic step size to form the change boundary, the controllable transmission of identity uncertainty to the feeding adjustment range is realized. This allows the existing surplus feed in the trough to be deducted before the next feeding, avoiding the accumulation of surplus feed and the sudden change in subsequent feeding amount caused by single meal identification or feeding abnormalities, thereby maintaining the continuity of individual ration allocation and feeding execution process. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is an overall flowchart of a method for dynamically adjusting the feeding amount of individual pigs based on individual identification, as provided in Embodiment 1 of the present invention. Detailed Implementation
[0026] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0027] Example 1, referring to Figure 1 As an embodiment of the present invention, a method for dynamically adjusting the feeding amount per meal for individual pigs is provided, comprising: S1: Acquire continuous images of the feed trough inlet and the trough weight sequence, segment the meal trajectory according to the snout entry and exit time sequence, and correct the trough weight decrease according to the stable residence interval.
[0028] In each frame of a continuous image of the feed trough entrance, the feed trough opening region, the snout keypoint, and the torso center point are located. The first frame in which the snout keypoint enters the feed trough opening region from the outside and the torso center point is continuously located within the feeding channel is recorded as the start of the meal. The first frame in which the snout keypoint leaves the feed trough opening region and the torso center point is continuously located outside the feeding channel is recorded as the end of the meal. The pig contours from the start to the end of the meal are connected according to the inter-frame displacement continuity of the same torso center point to form the meal trajectory. Other pig contours that simultaneously enter the feed trough opening region are marked as competing trajectories.
[0029] Furthermore, the feeding trough opening area is a fixed image area obtained through equipment installation and calibration, and the feeding channel is a monitoring area extending outward from the feeding trough opening, allowing only the pig's head or forequarters to approach the feeding trough. During installation, calibration points are set at both ends of the trough opening and on both sides of the channel, converting their pixel coordinates in the image to planar coordinates of the feeding area. The image acquisition frame rate can be set to 25 to 30 frames per second, and the image resolution can be set to no less than 1280×720 pixels. Continuous images and the trough weight sequence use the same system clock to record timestamps, with the time deviation between the two controlled within 20 milliseconds. The range is derived from the duration of the pig's snout entering and exiting movements and the sampling cycle of the weighing device. This setting can preserve the details of the entry and exit timing while avoiding excessive duplicate frames.
[0030] Furthermore, the feeding trough opening area, pig outline, snout key points, and torso center point can be localized using an image processing network consisting of a shared encoder and multiple output branches. The shared encoder includes four levels of convolutional feature extraction layers, with the number of output channels for each level set to 32, 64, 128, and 256. The outline branch outputs a pig outline mask, the region branch outputs a feeding trough opening area mask, and the key point branches output heatmaps of the snout key points and torso center point, respectively. The network input image can be uniformly scaled to 640×384 pixels, and the key points are taken from the peak positions of the corresponding heatmaps, which are then converted into planar coordinates of the feeding area through a calibration relationship. The training data comes from calibration samples formed by manually annotating the outline and key points of the feeding trough inlet image, without using personnel identification information. The calibration samples cover frontal, side, head-down, head-up, and partially occluded states, establishing a direct technical correlation between the output results and specific pig feeding scenarios.
[0031] Furthermore, entry is considered complete when the snout key point is outside the feeding trough opening area in the previous frame and inside the feeding trough opening area in the current frame, and remains within the area for at least 3 consecutive frames. The frame moment where both conditions are first met is recorded as the start of the meal if the torso center point is continuously within the feeding channel for at least 3 consecutive frames within the same time period. The first departure frame moment is recorded as the end of the meal if the snout key point leaves the feeding trough opening area and the torso center point continuously leaves the feeding channel for at least 5 consecutive frames. The 3 and 5 frames correspond to durations of approximately 0.10 to 0.20 seconds, respectively, derived from the image sampling frequency and the duration boundary of the pig's short-term head-shaking movements. Using a longer duration for departure determination helps avoid incorrectly segmenting the same meal into multiple meals due to a single head-shaking movement or partial missed detection.
[0032] Furthermore, considering the potential for misconnection of adjacent frame contours due to changes in pig movement speed and short-term jitter in the detection coordinates, this embodiment uses the ratio of the actual displacement of the torso center point to the achievable displacement to determine the continuity of inter-frame displacement. Specifically:
[0033] in, Indicates the first Frame to the The inter-frame displacement is a continuous amount that applies to the pig silhouettes to be connected, and its value is not less than 0. The smaller the value, the more likely the two silhouettes are to come from the same pig. Indicates the first The plane coordinates of the torso center point corresponding to the outline of the pig in the frame are derived from the key point branch output and converted by installation calibration, and the unit is meters. Indicates the first The frame has been connected to the plane coordinates of the center point of the torso of the meal trajectory, in meters. This indicates the frame number in the meal sequence, which is incremented according to the timestamps of consecutive images. This represents the maximum allowable movement speed of the pig's trunk center point within the feeding passage. In this embodiment, it can be set to 0.8 m / s to 1.5 m / s. This setting is derived from the 99th percentile of the inter-frame velocity in the normal entry and exit calibration trajectory collected after equipment installation, with an added 10% safety margin. This setting covers normal rapid turns while excluding pig skipping. This represents the difference between the timestamps of two adjacent frames. It originates from the image acquisition device and is normally 0.8 to 1.2 times the frame period. This indicates a positive number that should not be divided by zero due to an abnormally zero time interval; in this embodiment, it is set to... Second.
[0034] when When multiple contours exist to be connected, select the corresponding contours and include them in the same meal sequence trajectory. The smallest contour. If the time difference between adjacent frames exceeds 0.2 seconds, or if none of the candidate contours meet the minimum requirement. If the connection fails, the current connection will be terminated and the endpoint condition of the next meal will be confirmed to avoid forcibly connecting across the frame loss interval.
[0035] Furthermore, between the start and end points of a feeding session, the main feeding session trajectory corresponds to the pig profile that first meets the snout entry condition and whose trunk center point remains continuously within the feeding channel. When the snout key points of other pigs enter the feeding trough opening area within the same time range, competing trajectories are established, and their entry time, exit time, contour coverage area, and corresponding trough weight time period are recorded. When two contours briefly overlap, the trajectory number established before the overlap is retained, and the connection is restored based on the consistency between the trunk center point and the movement direction before the overlap after the overlap ends. If restoration is not possible, the frame segment is marked as a trajectory uncertainty segment and is not used for identity feature extraction, but the competing time period information is still retained for trough weight correction.
[0036] Align the timestamps of the trough weight sequence with the frame timestamps of the meal trajectory. Select the interval after the meal start point where the meal trajectory continuously occupies the feeding channel and the trough weight continuously decreases as the stable residence interval. Calculate the median value of the fixed-length trough weight window located before the start boundary and after the end boundary of the stable residence interval to obtain the initial trough weight reference and the end trough weight reference. Identify the trough weight change segment corresponding to the period when the competing trajectory enters the feeding trough opening area, and subtract the trough weight difference corresponding to the trough weight change segment from the trough weight difference between the initial trough weight reference and the end trough weight reference to obtain the corrected trough weight decrease.
[0037] Furthermore, the sampling frequency of the slot weight sequence can be set to 10 to 20 times per second, and the weighing resolution can be set to 1 gram to 5 grams. During time alignment, the sample value with the smallest time difference is selected from the slot weight sequence, using the timestamp of each image frame as the target time. If two adjacent slot weight sampling points are located on opposite sides of the target time, linear interpolation is used to obtain aligned slot weights. The maximum allowed alignment time difference is set to one slot weight sampling period; frames exceeding this time difference are marked as having no valid slot weight. This range is derived from the sampling capability of the weighing sensor and the rate of weight change caused by a single chewing motion by the pig, which helps maintain the temporal correspondence between image events and weight changes.
[0038] Furthermore, the stable residence interval begins from the first continuously decreasing window after the start of the feeding period. Using a 1-second window as the judgment window, a continuous decrease in trough weight is considered to have occurred when at least 80% of the weight differences between adjacent troughs are non-positive, and the net decrease in trough weight at the beginning and end of the window is at least 10 grams. Simultaneously, the trunk center point of the main feeding trajectory must remain within the feeding channel, and the key snout point must remain within the trough opening area. The 80% ratio and the 10-gram net decrease are derived from weighing resolution, short-term fluctuations caused by pig touch, and the minimum discernible weight change during normal feeding. This setting allows for a small amount of upward noise while avoiding the identification of periods with only mechanical vibration without actual feeding as stable residence intervals.
[0039] Furthermore, the initial sink weight window is located before the starting boundary of the stable residence interval, and the final sink weight window is located after the ending boundary of the stable residence interval. Both window lengths can be set to 2 to 4 seconds; this embodiment uses 3 seconds. Each window contains at least 20 valid sink weight samples. If there are fewer than 20, the window extends away from the stable residence interval, but the total extended length does not exceed 5 seconds. The initial and final sink weight references are respectively based on the median sink weight within the window. The median value reduces the impact of instantaneous contact, falling particle impact, and individual abnormal sample values on the reference. The window length is derived from the vibration decay time and sampling frequency of the weighing device, balancing the stability of the reference with the locality of the meal boundary.
[0040] Furthermore, considering that the weight changes corresponding to the competition trajectory may overlap with the weight changes of the main meal, and that directly using the weight difference between the first and last meals would include the competitive feed intake in the main meal, this embodiment first merges the competition periods that overlap in time or have an interval of less than 0.5 seconds, and then obtains the corrected trough weight drop amount according to the following formula:
[0041] in, This represents the correction weight drop of the current meal, applied to the main meal trajectory, in kilograms, and is used for subsequent identity attribution and cumulative meal quantity calculation. The starting slot weight reference for the stable residence interval is derived from the median value of the slot weight window of a fixed length before the starting boundary, and the unit is kilograms. The end slot weight reference for the stable residence interval is derived from the median value of the fixed-length slot weight window after the end boundary, and the unit is kilograms. This represents the number of segments with repeated changes in the competing slots after merging, and its value is a non-negative integer. It is 0 when there is no competing trajectory. Indicates the sequence number of the competing slot repetition segment, with a value ranging from 1 to... . Indicates the first The decrease in tank weight corresponding to each competitive tank weight change segment, in kilograms. A value of 0 is used when the tank weight does not decrease during that segment. Indicates the first The local trough weight benchmark corresponding to each competing trajectory entering the feed trough opening area is taken as the median value of the effective trough weight 0.5 seconds before and after the entry time. Indicates the first The local trough weight benchmark corresponding to each competitive trajectory when it leaves the feed trough opening area is taken as the median value of the effective trough weight 0.5 seconds before and after the departure time. This indicates taking the maximum value among the values in parentheses, used to truncate the negative drop caused by weighing rebound or noise to 0.
[0042] After calculation, if the competing period completely covers the stable residence interval, or if the result after deducting the competing trough weight change is 0, then the trajectory of that meal is retained, but the corrected trough weight decrease is recorded as 0. This avoids extrapolating the main meal intake by expanding the weight change of the uncovered period, thus preventing fictitious attribution when direct weighing data is lacking.
[0043] Furthermore, the competitive trough weight change segment is only established when the snout key point of the competitive trajectory is within the trough opening area. Trajectories where the trunk center point only passes through the feeding channel but the snout does not enter the trough opening are not deducted for trough weight changes. For cases where two or more competitive trajectories enter simultaneously, their time intervals are first unioned, and then the trough weight decrease in the union interval is calculated to avoid the same weight change being repeatedly deducted. If there is a trough weight increase caused by feeding in the local trough weight benchmark window, the corresponding competitive period is marked as a feeding interference period, and the calculation of the corrected trough weight decrease for this meal is paused. The benchmark is re-established after feeding ends and the trough weight remains stable for at least 2 seconds.
[0044] Furthermore, the correction of the sink weight decrease is simultaneously linked to the meal trajectory number, meal start point, meal end point, stable residence interval, starting sink weight baseline, ending sink weight baseline, competition period set, and data validity marker. If the proportion of missing valid sink weight samples exceeds 20% of the total number of sampling points in the stable residence interval, or if neither the starting nor ending window can obtain at least 20 valid sample values, then this meal is marked as an invalid sink weight meal and will not be included in subsequent identity assignment. The 20% missing boundary is derived from the effective sample coverage required for median value statistics. This setting can prevent a small amount of communication packet loss from invalidating the meal, while also preventing the estimation of actual feed intake based on sparse sink weight data.
[0045] It should be noted that this step does not simply divide video segments according to the detected pig outlines, nor does it directly use the difference in trough weight at the start and end of each meal as the individual's feed intake. Instead, it utilizes the snout entry and exit sequence, trunk dwell state, inter-frame reachable displacement, and competitive trajectory periods to jointly establish meal boundaries and trough weight attribution boundaries. This overcomes the coupling interference between short-term head raising, outline overlap, and competitive feeding, providing input with a clear time and weight range for subsequent identification.
[0046] S2: Construct visible area fusion features of meal trajectories, determine trajectory identity confidence through cross-frame mutual verification, and assign correction slot weight reduction amount when the confirmation conditions are met.
[0047] Within each frame of the pig's outline in the meal trajectory, the bases of both ears, the line connecting the eyes, the tip of the snout, and the midline of the back are located. Based on these points, the area is divided into a head and face texture region, an ear edge shape region, and a back marking region. For each of the head and face texture region, ear edge shape region, and back marking region, the complete proportion of the region falling within the pig's outline, the coverage proportion covered by competing trajectories, and the sharpness consistency value with the corresponding region in adjacent frames are calculated. The difference between the complete proportion and the coverage proportion is combined with the sharpness consistency value to generate a region visibility weight. Gray-level directional alignment with the line connecting the eyes is extracted in the head and face texture region; boundary curvature sequence with the line connecting the ear roots is extracted in the ear edge shape region; and texture distribution sequence with the back midline is extracted in the back marking region. The gray-level directional alignment, boundary curvature sequence, and texture distribution sequence are transformed to the local coordinates established by the corresponding position references, and intra-frame weighting is performed according to the corresponding region visibility weights to obtain frame-level region features. The median feature is calculated for the same region within the meal trajectory in chronological order at the frame level. Frame-level region features whose deviation from the median feature exceeds the trajectory deviation threshold are marked as anomalous features and removed. Region combinations with a visibility weight greater than the region activation threshold are recorded as visibility combination codes. When the visibility weight of a region is not greater than the region activation threshold, the visibility weight is renormalized only among the remaining activated regions, and zero values from inactivated regions are not written into the fusion result. The gray-scale direction arrangement, boundary curvature sequence, and texture distribution sequence are concatenated according to the renormalized visibility weights and associated with the visibility combination codes to form frame-level fusion features and trajectory-level fusion features, respectively. The trajectory-level fusion features are used as the visibility region fusion features.
[0048] Furthermore, the two ear roots are the intersections of the outer contours of the left and right ears with the head contour, the line connecting the two eyes is the directed line segment between the keypoints of the left and right eyes, the snout tip is the foremost keypoint of the snout, and the back midline point is the midpoint of the pig's contour in the shoulder and back region. The head and face texture area is defined by the line connecting the two ear roots, the line connecting the two eyes, and the snout tip; the ear edge shape area is defined by the contour band from the two ear roots to the ear tips; and the back marking area is defined by the area on each side of the back midline, each occupying 30% of the torso width. When the keypoint confidence is below 0.6, the corresponding region is not directly used, but its position is reserved for interpolation in adjacent frames. When the confidence is below 0.6 for three consecutive frames, the region is marked as unlocalizable. The threshold is derived from the output boundary when the keypoint coordinates in the calibration samples begin to show significant jumps, which helps to avoid amplifying feature deviations by erroneous local coordinates.
[0049] Furthermore, the region integrity ratio is the proportion of pixels actually falling within the current pig's outline in the divided region to the theoretical number of pixels in the region. The coverage ratio is the proportion of pixels simultaneously falling within competing trajectory outlines in the region to the theoretical number of pixels in the region. Both are set to 0 to 1. The sharpness consistency value is obtained by comparing the Laplacian variance of the current region with the median Laplacian variance of the corresponding regions in the two frames before and after: 1 is taken when the relative difference is 0, 0 is taken when the relative difference reaches or exceeds 50%, and the range in between decreases linearly according to the relative difference. The range of the two frames before and after is derived from a short-term attitude stabilization period of approximately 0.16 seconds under sampling conditions of 25 frames / second to 30 frames / second. This setting can identify motion-blurred frames while avoiding misjudging normal, slow head turns of pigs as sharpness abnormalities.
[0050] Furthermore, considering that the degree of regional occlusion, the degree of contour integrity, and the short-term imaging sharpness have different physical meanings and cannot be directly represented by a single area ratio, this embodiment limits the three quantities to the same dimensionless range of 0 to 1, and generates the regional visibility weight according to the following formula:
[0051] in, Indicates the trajectory of the meal. Mid-frame region The region visibility weight ranges from 0 to 1. A larger value indicates that the region is more suitable for participating in the feature fusion of the current frame. Indicates the region category, such as the head and face texture area, the ear edge shape area, or the back markings area. This indicates the frame number in the meal sequence. Indicates the area In the The full proportion of the frame falling within the outline of the main pig is derived from the intersection pixel statistics of the region mask and the main pig outline mask, with a value ranging from 0 to 1. Indicates the area In the The coverage ratio of a frame by the competition trajectory is derived from the intersection pixel statistics of the union of the region mask and the competition trajectory outline, and the value ranges from 0 to 1. Indicates the area In the The sharpness consistency value between the corresponding regions of a frame and its adjacent frames is formed by the relative difference between the current region's sharpness and the median sharpness of the two frames before and after it, and the value ranges from 0 to 1. This indicates that the result within the parentheses is limited to 0 to 1. A result less than 0 is taken as 0, and a result greater than 1 is taken as 1.
[0052] Region visibility weights are used to determine whether a region is enabled and its relative contribution to intra-frame fusion. When the coverage ratio is greater than the full ratio, the result within parentheses is truncated to 0, thus preventing image content occupied by competing trajectories from entering the primary and secondary trajectory features.
[0053] Furthermore, the head and face texture area is first rotated horizontally along the line connecting the eyes, then divided into 4×4 grids. Within each grid, the arrangement values of 8 gray-level gradient direction intervals are statistically analyzed, forming a 128-dimensional gray-level direction arrangement. For the ear edge shape area, the midpoint of the line connecting the two ear roots is used as the origin. 32 points of equal arc length are sampled from each ear edge, and a 64-dimensional boundary curvature sequence is obtained based on the angle formed by three adjacent sampling points. The back markings area is divided into 8×8 grids with the back central axis as the vertical axis. The normalized gray-level mean and local gray-level difference of each grid are statistically analyzed, forming a 128-dimensional texture distribution sequence. These dimensions are derived from the region size and the scale of local texture spatial changes, which can control the amount of template matching computation while maintaining contour and texture order information.
[0054] Furthermore, the median feature of the frame-level regional features within the same area is calculated within their respective fixed dimensions. The feature deviation is calculated using the mean of the normalized absolute difference. The deviation threshold within the trajectory is determined by the 90th percentile of all effective deviations in the corresponding region of the current trajectory, and is limited to the range of 0.2 to 0.35. When there are fewer than 10 effective frames, 0.3 is used as the engineering preset value. The region activation threshold is set to 0.4 in this embodiment, which is derived from the fact that the boundaries of the main regional structure can still be preserved after the combined effect of the full ratio, coverage ratio, and sharpness consistency value. Using quantiles and setting upper and lower limits is beneficial for adapting to the overall sharpness differences of different meals, while avoiding the threshold from increasing indefinitely with abnormal values when there are too many abnormal frames.
[0055] A set of identity templates corresponding to visible combination codes is established based on the registered image of each pig. Each identity template records the head and face texture features, ear edge shape features, back marking features, and the local coordinates of the corresponding features. For the frame-level fusion features of each retained frame, identity templates with the same visible combination code or containing all enabled regions are selected from the identity template set. The region correspondence distance between the frame-level fusion features and the selected identity templates is calculated, and the first and second candidate identities in the region correspondence distance ranking and the distance difference between the first and second distances are obtained. When temporally continuous frame-level fusion features have the same first candidate identity, the meal trajectory satisfies the inter-frame displacement constraint, and the first candidate identity does not correspond to a competing trajectory at the same frame time, a positive mutual verification record is generated. When the first candidate identity switches between adjacent frames, the same candidate identity corresponds to both the meal trajectory and the competing trajectory at the same frame time, or the region correspondence distance exceeds the matching threshold, a conflict mutual verification record is generated. Positive mutual verification records are accumulated along the time sequence of the meal trajectory, and conflict mutual verification records are subtracted. The accumulated result is combined with the distance difference to generate the frame-level identity score for each candidate identity. Starting from the end of the meal and tracing back to the beginning of the meal, frame-level identity scores are used to merge frames that continuously maintain the same candidate identity and do not contain conflicting verification records. Trajectory-level candidate identity scores are generated based on the duration of the merged frame segments and the frame-level identity scores. Each trajectory-level candidate identity score is normalized across all candidate identities, and the normalized result is used as the trajectory identity confidence level. When the trajectory identity confidence level of the top-scoring identity reaches the confirmation threshold, the top-scoring identity is identified as the corresponding pig, and the correction trough weight reduction is assigned to that pig. When the trajectory identity confidence level does not reach the confirmation threshold, the correction trough weight reduction is marked as an unconfirmed meal amount and is not included in the cumulative meal amount for any pig.
[0056] Furthermore, images of each pig are captured during registration in four positions: front, left, right, head down, and naturally standing. Two to five frames are captured for each position. The registration images are processed using the same keypoint, region division, local coordinate transformation, and feature extraction rules as the feed trough inlet images. For each visible combination code, the median feature of the included region is calculated to form a corresponding identity template. When the visible weight of a region in a registration image is not greater than 0.4, that region is not written into the corresponding template. The identity template records the pig registration number, visible combination code, region features, local coordinate direction, and template creation date, but not personnel information. Multi-pose registration allows the template set to cover possible region combinations during a meal, without requiring missing regions to be padded with zero values.
[0057] Furthermore, the corresponding distances between regions are calculated within the same region and under the same local coordinates. Each feature dimension is first scaled according to the median absolute deviation of the corresponding dimension in the pig registration template. The median absolute deviation is less than... Press at time To avoid division by zero caused by stable dimensions, the distance of each region is normalized to 0 to 1, where 0 indicates complete consistency and 1 indicates reaching or exceeding the 99th percentile of the distance of the calibrated sample in that region. Frame-level fusion features and templates with the same visible combination encoding are directly compared. When the template contains all enabled regions, only the currently enabled region is selected for comparison, and additional regions in the template are not included in the distance calculation. The matching threshold can be set to 0.35 to 0.55; this embodiment uses 0.45, derived from the boundary interval between the distances of the same pig and the distances of different pigs in the registered calibration samples. This setting helps prevent obviously mismatched frames from generating positive records.
[0058] Furthermore, a positive mutual verification record corresponds to the following states simultaneously: the first candidate identity in the current frame and the previous retained frame are the same, the inter-frame displacement continuity in S1 is not greater than 1, and this identity was not selected as the first candidate by the competing trajectory at the same frame time. A conflict mutual verification record corresponds to any of the following states: candidate identity switching, conflict between the same identity in the same frame, or the distance between the first and second position regions being greater than 0.45. The distance difference between the first and second position distances is first divided by the second position distance and limited to 0 to 1 to form the distance difference. The second position distance is less than... The time-distance difference is set to 0 to avoid erroneous amplification of two nearly identical templates. Positive records indicate that cross-frame identity information mutually supports each other, while conflicting records indicate that there is evidence that trajectory or template matching cannot be simultaneously true.
[0059] Furthermore, considering that a small distance in a single frame does not necessarily indicate the reliability of the identity for the entire meal trajectory, and that the duration of positive evidence and conflicting evidence should have different levels of influence, this embodiment generates trajectory-level candidate identity scores and trajectory identity confidence levels according to the following formula:
[0060] in, Indicates candidate status The trajectory-level candidate identity score is a dimensionless quantity. A larger value indicates stronger continuous support for that identity throughout the entire meal trajectory. This represents the candidate identity number, corresponding to a registered pig in the identity template set. This represents the total number of retained frames in the meal trajectory that participated in identity calculation. This indicates that the frame sequence number is reserved. The weight of the distance base item corresponding to the region is set to 0.4 in this embodiment, which is derived from the result of the unified numerical range of the distance item and the mutual verification record item in the calibration trajectory. Indicates the first Frame fusion features and candidate identities The distance corresponds to the region and takes a value between 0 and 1. It is set to 1 if no template satisfies the visible combination condition. This represents the increase coefficient for positive mutual verification records, which is set to 1 in this embodiment. Indicates candidate status In the Whether to generate a positive mutual verification record for the frame. Set to 1 if generated, otherwise set to 0. This represents the deduction coefficient for conflict verification records. In this embodiment, it is set to 1.5 to 2.5, and 2 can be selected. It is greater than the positive coefficient, so that conflicts between the same identity and the same frame cannot be easily canceled out by multiple ordinary positive frames. Indicates candidate status In the Whether to generate a conflict verification record for the frame. Set to 1 if generated, otherwise set to 0. This represents the enhancement coefficient of the distance difference in the forward mutual verification, which is set to 0.6 in this embodiment. Indicates the first The normalized distance difference between the first and second position distances in a frame, with a value between 0 and 1. It only applies to the first candidate identity in that frame. The enhancement factor represents the duration of conflict-free continuous frame segments. In this embodiment, it is set to 0.02 per frame and is derived from the engineering boundary where stable temporal evidence can be formed in 10 to 30 consecutive frames. This indicates the candidate identities after tracing back from the end of the meal. The corresponding number of merged frame segments that do not contain conflicting records. This indicates the sequence number of the merged frame segment. Indicates candidate status The The number of frames contained in a merged frame segment. Indicates the first The average of the frame-level identity scores shown in square brackets within each merged frame segment. Indicates candidate status The trajectory identity confidence score is between 0 and 1, and the sum of the trajectory identity confidence scores of all candidate identities is 1. The normalized temperature parameter represents the score, which is set to 0.25 to 0.5 in this embodiment, and can be selected as 0.35. The smaller the parameter, the more prominent the differences in candidate scores are, and its range comes from the number of candidate identities and the score range in the calibration trajectory. This represents the total number of candidate identities participating in the current meal identity normalization. This represents the candidate identity index in the normalized summation. This represents the natural exponential function, used to convert candidate identity scores into non-negative normalized results.
[0061] To avoid overflow in exponentiation, the actual calculation starts from all... Subtracting the maximum score from the result and then performing the exponential operation does not change the normalization result. If there is no identity template that meets the visible combination condition, or if all retained frames are conflicting mutual verification records, the meal is directly marked as unconfirmed, and single candidate normalization is not performed.
[0062] Furthermore, the backtracking process starts from the last retained frame corresponding to the end of the meal and reads the first candidate identity and mutual verification record frame by frame from the start of the meal. Frames with consecutive identical candidate identities and no conflicting records are merged into one frame segment. When the time interval between adjacent frames exceeds 0.2 seconds, the connection is forcibly broken. Frame segments with a duration of less than 3 frames still participate in the basic distance term, but do not enter the duration enhancement term. 3 frames correspond to a minimum continuous observation time of approximately 0.1 seconds, which is derived from the S1 meal entry confirmation time, which helps to avoid isolated clear frames contributing too much to the trajectory-level score. The confirmation threshold is set to 0.85 in this embodiment, which is derived from the requirement that the first candidate after normalization must be significantly higher than the engineering confidence boundary of the other candidates.
[0063] Furthermore, when the confidence level of the trajectory identity of the top-scoring identity reaches 0.85, that identity is confirmed as the corresponding pig, and the corrected trough weight reduction, meal start and end times, visible combination code, and trajectory identity confidence level obtained from S1 are written into the pig's meal record. If the confidence level is less than 0.85, the weight record is written into the unconfirmed meal queue, and the confirmed cumulative meal quantity of any pig is not updated. Subsequently, the unconfirmed meal quantity cannot be forcibly allocated solely due to insufficient feed for a particular pig. If both the primary meal trajectory and the competing trajectory at the same time use the same identity as the top candidate, a conflict record is generated in the corresponding frame, deducting its trajectory-level score, thus preventing a registered identity from corresponding to two entity trajectories at the same time from the data stream perspective.
[0064] It should be noted that this step does not fix the head, face, ear edges, and back features into a complete pig feature of uniform length. Instead, it establishes a combined encoding based on the truly visible area of each frame and performs template comparison within the same visible information range. Furthermore, cross-frame mutual verification is performed through positive recording, conflict recording, and the duration of conflict-free frame segments. This ensures that occlusion conditions, competition trajectory conditions, and identity confidence have a reproducible quantitative relationship, preventing a single clear frame or zero value in a missing region from having a decisive impact on the identity of the entire meal trajectory.
[0065] S3: Calculate the candidate amount for the next meal based on the cumulative amount of meals for the corresponding pigs, the target daily feed curve, and the trajectory identity confidence level. Then control the feed intake after limiting the target amount for the next meal by the boundary of the change between adjacent meals.
[0066] Read the target diet curve for the corresponding pig at the current age and feeding time, and determine the cumulative target amount corresponding to the target diet curve at the start of the next meal as the cumulative baseline for the next meal. Summarize the corrected trough weight decreases assigned to the corresponding pigs in chronological order to form the confirmed cumulative meal amount. For the meal closest to the start of the next meal, combine the corrected trough weight decrease corresponding to that meal with the trajectory identity confidence level to obtain the confidence-corrected meal amount. Replace the corrected trough weight decrease of the corresponding meal in the confirmed cumulative meal amount with the confidence-corrected meal amount to form the confidence-corrected cumulative meal amount. Subtract the confidence-corrected cumulative meal amount from the cumulative baseline for the next meal to obtain the amount of feed to be supplemented up to the start of the next meal. Obtain the curve increment of the target diet curve during the next meal period and the remaining curve increment from the start of the next meal to the end of the current feeding period. Determine the ratio of the curve increment during the next meal period to the remaining curve increment as the allocation coefficient for the next meal. Combine the amount of feed to be supplemented with the allocation coefficient for the next meal to generate the basic candidate amount. Read the actual feed amount from the previous meal and the corresponding correction trough weight drop. Subtract the corresponding correction trough weight drop from the actual feed amount from the previous meal. If the difference is positive, the difference is determined as the uneaten feed balance; if the difference is not positive, the uneaten feed balance is determined as zero. Multiply the uneaten feed balance by the trajectory identity confidence level corresponding to the previous meal to obtain the confidence-corrected balance. Subtract the confidence-corrected balance from the basic candidate balance. If the subtraction result is less than zero, the candidate balance for the next meal is determined as zero; if the subtraction result is not less than zero, the subtraction result is determined as the candidate balance for the next meal. Input the candidate balance for the next meal into the adjacent meal change boundary processing.
[0067] Furthermore, the target ration curve is a configuration curve showing that the cumulative target feed intake for each pig within a feeding day remains monotonically constant over time. The curve is generated based on the ration plan corresponding to the pig's registered age, breed, or production stage. The ration plan is entered into the farm's nutrition configuration system, specifying the daily target amount and the allocation ratio for each feeding period; it is not automatically inferred from the pig's identification results. The current age is obtained based on the difference between the pig's registration date and the system date. The current feeding period and the start time of the next meal are obtained from the feeding schedule. Curve time nodes can be stored at 15-minute to 30-minute intervals, with linear interpolation used between nodes. This interval is derived from the meal scheduling granularity, which is beneficial for obtaining continuous cumulative target amounts without needing to increase the temporal resolution to image frame level.
[0068] Furthermore, the cumulative baseline for the next meal is the cumulative value of the target diet curve at the start of the next meal, in kilograms. The confirmed cumulative meal quantity only includes the correction trough weight reduction of pigs whose trajectory identity confidence in S2 has reached the confirmation threshold and has been assigned to the corresponding pig. For the confirmed meal closest to the start of the next meal, its correction trough weight reduction is multiplied by the corresponding trajectory identity confidence to obtain the confidence correction meal quantity. For each confirmed meal before this most recent meal, the complete correction trough weight reduction written into the meal record at the time of identity confirmation is still accumulated, and the confidence is not recalculated. The use of the complete correction trough weight reduction for earlier meals is only to avoid the identity confidence of the same meal being repeatedly attenuated in the calculation of the next meal candidate quantity, and does not indicate that the earlier meal has been re-verified by subsequent meals. This embodiment does not use subsequent meals to re-identify the identity of earlier meals, does not recalculate the trajectory identity confidence of earlier meals, and does not write back or modify historical meal records based on subsequent meals.
[0069] Furthermore, the increment of the target diet curve in the next feeding period is the difference between the cumulative target amount at the end of the next feeding period and the cumulative target amount at the beginning. The remaining curve increment is the sum of the curve increments for each period from the start of the next feeding to the end of the feeding period for the current day. Both quantities are non-negative weights. If the target diet curve shows a subsequent node being smaller than the previous node, the curve is marked as invalid and dynamic feeding is suspended, without masking the error by taking the absolute value. The allocation coefficient for the next feeding is between 0 and 1. When the remaining curve increment is 0, it is set to 0, indicating that the daily plan has ended. This boundary rule can prevent the candidate quantity from being abnormally amplified due to a zero denominator and erroneous curves.
[0070] Furthermore, the inputs required for calculating the candidate amount for the next meal include: the cumulative target amount of the target diet curve at the start of the next meal, the correction trough weight decrease for each meal confirmed to be assigned to the corresponding pig, the trajectory identity confidence level corresponding to the confirmed meal closest to the start of the next meal, the curve increment of the target diet curve during the next meal period, the remaining curve increment from the start of the next meal to the end of the feeding period of the day, the actual feed amount of the previous meal, and the correction trough weight decrease corresponding to the previous meal.
[0071] During calculation, the correction sink weight reduction amount corresponding to the confirmed meal closest to the start time of the next meal is first multiplied by the trajectory identity confidence level of that meal to obtain the confidence-corrected meal quantity. For each confirmed meal before this most recent meal, the correction sink weight reduction amount recorded at the time of identity confirmation is accumulated, without repeated confidence level calculation. The confidence-corrected meal quantity replaces the correction sink weight reduction amount corresponding to the most recent meal in the cumulative confirmed meal quantity to form the confidence-corrected cumulative meal quantity.
[0072] Subtract the confidence-corrected cumulative meal quantity from the cumulative baseline for the next meal. If the difference is negative, the amount of ration to be supplemented is set to zero; if the difference is not negative, the difference is set as the amount of ration to be supplemented. Determine the allocation coefficient for the next meal based on the proportion of the curve increment to the remaining curve increment. If the remaining curve increment is zero or below the preset minimum effective boundary, the allocation coefficient for the next meal is set to zero. Multiply the amount of ration to be supplemented by the allocation coefficient for the next meal to obtain the basic candidate quantity.
[0073] Subsequently, the actual amount of feed fed in the previous meal is subtracted from the corresponding correction trough weight drop. When the difference is positive, it is determined as the uneaten surplus; when the difference is not positive, the uneaten surplus is determined to be zero. The uneaten surplus is multiplied by the trajectory identity confidence level corresponding to the previous meal to obtain the confidence-corrected surplus, and then subtracted from the basic candidate quantity.
[0074] When the deduction result is less than zero, the candidate quantity for the next meal is set to zero. When the deduction result is not less than zero, the deduction result is set as the candidate quantity for the next meal. The candidate quantity for the next meal is the output of this step and is processed by the boundary conditions for changes in adjacent meals.
[0075] If the actual feed amount recorded for the previous meal is invalid, the corresponding correction trough weight reduction for the previous meal is invalid, or the identity of the pig for the previous meal is not confirmed, then no dynamic candidate amount for the next meal will be generated for that pig, and the corresponding meal will remain in a pending confirmation state.
[0076] The lower boundary is obtained by subtracting the boundary amplitude from the target quantity of the previous meal, and the upper boundary is obtained by adding the boundary amplitude to the target quantity of the previous meal. When the candidate quantity of the next meal is less than the lower boundary, the lower boundary is determined as the target quantity of the next meal. When the candidate quantity of the next meal is greater than the upper boundary, the upper boundary is determined as the target quantity of the next meal. When the candidate quantity of the next meal is between the lower and upper boundaries, the candidate quantity of the next meal is determined as the target quantity of the next meal. Based on the unit drive quantity calibration relationship of the feeding actuator, the target quantity of the next meal is converted into a drive sequence. The feeding actuator is controlled to feed according to the drive sequence, and the tank weight sequence is read synchronously. When the increase in tank weight during the feeding process reaches the target quantity of the next meal, the drive is stopped. The increase in tank weight at the time of stopping the drive is recorded as the actual feeding quantity of this meal, and the actual feeding quantity of this meal is used for the calculation of the candidate quantity of the next meal.
[0077] Furthermore, the curve increments for both the previous and next meal periods are directly read from the same target diet curve to avoid inconsistencies in dimensions or time boundaries between different configuration versions. The preset base step size represents the minimum target quantity adjustment allowed even if the curve increments are the same in adjacent meals, and can be set from 0.05 kg to 0.15 kg; this embodiment uses 0.1 kg. Its setting is derived from the minimum stable feed batch size of the feeding actuator, the weighing resolution, and the control granularity of the pig's single meal amount. This setting prevents the actuator from frequently starting and stopping due to excessively small boundaries, and also prevents unconstrained jumps in candidate quantities within a single meal.
[0078] Furthermore, considering that the changes in the target diet curve need to be preserved, and that it is not advisable to perform excessively large adjustments between adjacent meals when the identity confidence level is low, this embodiment obtains the boundary range, lower boundary, upper boundary, and target amount for the next meal according to the following formula:
[0079] in, This indicates the permissible range of variation between the next meal and the previous meal, expressed in kilograms. This indicates the preset base step size, which is set to 0.05 kg to 0.15 kg in this embodiment, and can be selected as 0.10 kg. This indicates the increment of the target diet curve at the next meal interval, expressed in kilograms. This represents the increment of the target diet curve during the previous meal period, expressed in kilograms. It represents the absolute value of the difference between the increments of the curves in two adjacent time periods, reflecting the allowable changes in meal frequency within the ration plan itself. This represents the basic retention factor in the boundary range, which is set to 0.5 in this embodiment. The boundary adjustment coefficient representing the confidence level of trajectory identity is set to 0.5 in this embodiment, and . This represents the confidence level of the trajectory identity from the previous meal, derived from S2, and ranges from 0 to 1. When performing individual dynamic feeding in this step, its value must not be lower than the confirmation threshold. This indicates the lower bound of the target amount for the next meal, expressed in kilograms. This indicates the upper limit of the target amount for the next meal, expressed in kilograms. This represents the target quantity for the previous meal, derived from the boundary processing results of the previous meal, and is expressed in kilograms. This represents the candidate quantity for the next meal obtained from the previous formula, in kilograms. This indicates the target quantity for the next meal after the boundary of changes from adjacent meals, expressed in kilograms. This indicates taking the minimum value, used to limit the target quantity of the next meal from not exceeding the upper boundary.
[0080] Boundary coefficients of 0.5 and 0.5 are used to ensure that most of the variation space of the diet curve is retained when the trajectory identity confidence reaches the confirmation threshold. The closer the confidence is to 1, the closer the allowable boundary amplitude is to the sum of the difference in the diet curve and the basic step size. If the lower boundary is less than 0, the final target amount will not be less than 0 because the candidate amount for the next meal has been restricted to non-negative.
[0081] Furthermore, the unit drive quantity calibration relationship of the feeding actuator is established after equipment installation or maintenance. At least five sets of no-load feeding operations are performed, starting with the fewest drive pulses and increasing to the most, with each set repeated three times. The median increase in tank weight is recorded, thus forming a monotonic calibration table between the number of drive pulses and the feeding weight. Linear interpolation is used between adjacent calibration points, and the number of drive pulses corresponding to the target quantity is determined by the maximum integer number of pulses not exceeding the target quantity. Any remaining amount less than one unit drive quantity is compensated by the last short pulse. The unit drive quantity can be set from 0.005 kg to 0.02 kg, a range derived from the single stable operation of the feeding motor and the weighing resolution, which is beneficial for balancing feeding speed and target quantity control particle size.
[0082] Furthermore, before feeding begins, the median value of the trough weight samples over a consecutive second is recorded as the initial trough weight. During the feeding process, the trough weight sequence is read synchronously, and the trough weight increase is obtained by subtracting the initial trough weight from the median value of the current three consecutive samples. The feeding process stops when the trough weight increase reaches or exceeds the target amount for the next meal. The three consecutive samples correspond to a period of 0.15 seconds to 0.3 seconds, which originates from the trough weight sampling frequency and the short-term fluctuation period of the impact of the feeding particles, preventing premature feeding stoppage due to a single upward abnormal value. If the feed has been output but the trough weight has not increased by at least one unit of drive force for two consecutive seconds, the feed is stopped and an abnormality flag for the feeding mechanism is generated, and pulse accumulation is discontinued.
[0083] Furthermore, after stopping the drive, wait for the trough weight to stabilize continuously for 1 to 2 seconds, and record the difference between the median trough weight in the stabilization window and the initial trough weight as the actual feed amount for this meal. This actual feed amount is associated with the pig's identity, the target amount for the next meal, the drive sequence, the start time, the stop time, and the valid trough weight marker, and is read as the actual feed amount for the previous meal when S3 is executed next time. S3 is applicable to consecutive meals where the target amount and actual feed amount for the previous meal already exist. The initial meal of a feeding day is executed incrementally according to the first meal curve of the target diet curve, and enters the dynamic adjustment process after obtaining the actual feed amount for the first meal.
[0084] It should be noted that this step does not involve adding the entire difference between the cumulative target amount and the cumulative feed intake to the next meal all at once. Instead, it first allocates the amount of feed to be added according to the remaining target ration curve, then uses the trajectory identity confidence level of the latest meal to calculate the uneaten surplus from the previous meal, and deducts the confidence-corrected surplus from the basic candidate amount. Finally, it uses the change boundary constraints related to the increment of adjacent curves and the target amount of the previous meal to constrain the feed intake. This creates a continuous data loop between identity results, actual feed intake, trough surplus, ration plan, and execution agency, preventing trough surplus from being repeatedly included in the feed intake for the next meal.
[0085] Example 2, an embodiment of the present invention, provides a dynamic adjustment system for individual pig feeding amount based on individual identification, including a snout trajectory calibration module, a cross-frame identity verification module, and a feeding amount limiting module.
[0086] The module is used to acquire continuous images of the feed trough inlet and the trough weight sequence, segment the meal trajectory according to the snout entry and exit time sequence, and correct the trough weight drop according to the stable residence interval.
[0087] The module is used to construct visible area fusion features of meal trajectories, determine the trajectory identity confidence through cross-frame mutual verification, and assign the correction slot weight drop amount when the confirmation conditions are met.
[0088] The module is used to calculate the candidate amount of the next meal based on the cumulative amount of meals for the corresponding pig, the target daily feed curve, and the trajectory identity confidence level. After limiting the target amount of the next meal by the boundary of the change between adjacent meals, the feed is controlled.
Claims
1. A method for dynamically adjusting the amount of feed per meal based on individual pig identification, characterized in that, include: Acquire continuous images of the feed trough inlet and the trough weight sequence, segment the meal trajectory according to the snout entry and exit time sequence, and correct the trough weight drop according to the stable residence interval; Construct visible area fusion features for meal trajectories, determine trajectory identity confidence through cross-frame mutual verification, and assign correction slot weight drop amount when confirmation conditions are met; The candidate amount for the next meal is calculated based on the cumulative amount of meals for the corresponding pigs, the target daily feed curve, and the trajectory identity confidence level. The feed intake is then controlled after the target amount for the next meal is limited by the boundary of the change between adjacent meals.
2. The method for dynamically adjusting the feeding amount per meal for individual pigs as described in claim 1, characterized in that: The sequence of entry and exit of the kissing part to segment the meal trajectory includes... Locate the feed trough opening area, key points on the pig's snout, and center point of the torso in each frame of a continuous image of the feed trough inlet; The first frame moment in which the key point of the snout enters the feeding trough opening area from the outside of the feeding trough opening area and the center point of the torso is continuously located in the feeding channel is recorded as the starting point of the meal. The first frame moment when the key point of the snout leaves the feeding trough opening area and the center point of the torso leaves the feeding channel consecutively is recorded as the end point of the meal; The pig contours between the start and end points of the meal are connected according to the inter-frame displacement continuity of the same trunk center point to form the meal trajectory, and the contours of other pigs that enter the feed trough opening area at the same time are marked as competing trajectories.
3. The method for dynamically adjusting the feeding amount per meal based on individual pig identification as described in claim 2, characterized in that: The correction of the tank weight descent amount according to the stable residence interval includes Align the timestamp of the trough weight sequence with the frame time of the meal trajectory, and select the interval after the meal start point where the meal trajectory continuously occupies the feeding channel and the trough weight continuously decreases as the stable residence interval. The median value of the fixed-length slot weight window located before the starting boundary and after the ending boundary of the stable residence interval is obtained to obtain the starting slot weight reference and the ending slot weight reference. Identify the weight change segment corresponding to the period when the competition trajectory enters the feed trough opening area, and subtract the weight difference corresponding to the weight change segment from the weight difference between the initial and final feed trough weight references to obtain the corrected weight reduction.
4. The method for dynamically adjusting the feeding amount per meal based on individual pig identification as described in claim 3, characterized in that: The visible area fusion features for constructing meal trajectories include, Within each frame of the pig's outline on the meal trajectory, locate the base of the ears, the line connecting the eyes, the tip of the nose, and the midline point of the back. Based on the base of the ears, the line connecting the eyes, the tip of the nose, and the midline point of the back, divide the head and face texture area, the ear edge shape area, and the back marking area. For the head and face texture area, ear edge shape area, and back pattern area, calculate the complete proportion of the area falling into the pig outline, the coverage proportion covered by the competing trajectory, and the sharpness consistency value with the corresponding area of the adjacent frame. Combine the difference between the complete proportion and the coverage proportion with the sharpness consistency value to generate the area visibility weight. Extract the grayscale direction arrangement with the line connecting the eyes as the directional reference in the head and face texture area, extract the boundary curvature sequence with the line connecting the roots of the two ears as the position reference in the ear edge shape area, and extract the texture distribution sequence with the back central axis as the position reference in the back pattern area. The gray-level orientation, boundary curvature sequence, and texture distribution sequence are transformed to the local coordinates established by the corresponding position reference, and intra-frame weighting is performed according to the corresponding region visibility weight to obtain frame-level region features; The median feature is obtained from the frame-level regional features of the same area in the meal trajectory according to the time sequence. Frame-level regional features whose deviation from the median feature exceeds the deviation threshold within the trajectory are marked as abnormal features and removed. Regions with a visible weight greater than the region activation threshold are recorded as visible combination codes; when the visible weight of a region is not greater than the region activation threshold, the visible weight of the region is only renormalized among the remaining activated regions, and the zero value of the non-activated region is not written into the fusion result. The gray-scale direction arrangement, boundary curvature sequence, and texture distribution sequence are spliced together according to the re-normalized region visibility weights and associated with the visibility combination encoding to form frame-level fusion features and trajectory-level fusion features respectively. The trajectory-level fusion features are used as the visible region fusion features.
5. The method for dynamically adjusting the feeding amount per meal for individual pig identification as described in claim 4, characterized in that: The method of determining trajectory identity confidence through cross-frame mutual verification includes: Based on the registered image of each pig, an identity template set corresponding to the visible combination code is established. Each identity template records the head and face texture features, ear edge shape features, back marking features, and the local coordinates of the corresponding features. For each retained frame, select an identity template with the same visible combination code or containing all enabled regions from the identity template set. Calculate the region correspondence distance between the frame-level fusion feature and the selected identity template. Obtain the first and second candidate identities in the region correspondence distance ranking and the distance difference between the first and second distances. When time-continuous frame-level fusion features have the same first candidate identity, meal trajectories satisfy inter-frame displacement constraints, and the first candidate identity does not correspond to a competing trajectory at the same frame time, a positive mutual verification record is generated. When the first candidate identity switches between adjacent frames, the same candidate identity corresponds to both the meal trajectory and the competing trajectory at the same frame time, or the distance between the corresponding regions exceeds the matching threshold, a conflict verification record is generated. Accumulate positive mutual verification records along the time sequence of the meal trajectory and deduct conflicting mutual verification records. Combine the accumulated results with the distance difference to generate frame-level identity scores for each candidate identity. The frame-level identity score is traced back from the end of the meal to the beginning of the meal. Frame segments that continuously maintain the same candidate identity and do not contain conflicting mutual verification records are merged. Trajectory-level candidate identity scores are generated based on the duration of the merged frame segments and the frame-level identity score. The scores of each trajectory-level candidate identity are normalized among all candidate identities, and the normalized results are used as the trajectory identity confidence scores. When the confidence level of the trajectory identity of the top scorer reaches the confirmation threshold, the top scorer identity is identified as the corresponding pig, and the correction trough weight reduction is assigned to the corresponding pig; when the confidence level of the trajectory identity does not reach the confirmation threshold, the correction trough weight reduction is marked as unconfirmed meal quantity, and the unconfirmed meal quantity is not included in the cumulative meal quantity of any pig.
6. The method for dynamically adjusting the feeding amount per meal for individual pig identification as described in claim 5, characterized in that: The calculation of the next meal candidate quantity based on the cumulative meal quantity of the corresponding pig, the target diet curve, and the trajectory identity confidence level includes, Read the target diet curve for the corresponding pig at the current age and current feeding time, and determine the cumulative target amount corresponding to the target diet curve at the start of the next meal as the cumulative baseline for the next meal; The correction trough weight reduction amount assigned to the corresponding pigs is summarized and confirmed in chronological order to form the confirmed cumulative meal count; For the confirmed meal closest to the start time of the next meal, the correction trough weight drop amount corresponding to the meal is multiplied by the corresponding trajectory identity confidence level to obtain the confidence correction meal amount; For each confirmed meal before the most recent meal, the cumulative amount of correction tank weight reduction recorded at the time of identity verification will not be recalculated; Replace the calibration tank weight drop corresponding to the most recent meal in the confirmed cumulative meal quantity with the confidence calibration meal quantity to form the confidence calibration cumulative meal quantity; Subtract the confidence-corrected cumulative meal quantity from the cumulative baseline for the next meal to obtain the amount of supplementary food up to the start of the next meal; Obtain the curve increment of the target diet curve during the next meal period and the remaining curve increment from the start of the next meal to the end of the feeding period of the day. Determine the ratio of the curve increment during the next meal period to the remaining curve increment as the allocation coefficient for the next meal. The amount of food to be supplemented is combined with the allocation coefficient for the next meal to generate a basic candidate amount; Read the actual feed amount of the previous meal and the corresponding correction trough weight drop amount of the previous meal, and subtract the corresponding correction trough weight drop amount of the previous meal from the actual feed amount of the previous meal; when the difference is positive, the difference is determined as the uneaten surplus amount, and when the difference is not positive, the uneaten surplus amount is determined as zero. Multiply the uneaten surplus by the confidence level of the trajectory identity corresponding to the previous meal to obtain the confidence-corrected surplus. Subtract the confidence correction balance from the base candidate quantity; When the deduction result is less than zero, the candidate quantity for the next meal is set to zero; when the deduction result is not less than zero, the deduction result is set as the candidate quantity for the next meal. Input the candidate quantity for the next meal into the boundary of the adjacent meal change process.
7. The method for dynamically adjusting the feeding amount per meal for individual pig identification as described in claim 6, characterized in that: The method of controlling the feeding after limiting the target amount of the next meal by the boundary of changes between adjacent meals includes... Read the target amount of the previous meal and the curve increment of the target daily ration curve in the previous meal period and the next meal period. Add the absolute value of the difference between the two curve increments to the preset base step size, and combine the sum with the trajectory identity confidence to obtain the boundary amplitude. The lower boundary is obtained by subtracting the boundary range from the target quantity of the previous meal, and the upper boundary is obtained by adding the boundary range to the target quantity of the previous meal. When the candidate quantity for the next meal is less than the lower boundary, the lower boundary is determined as the target quantity for the next meal. When the number of candidates for the next meal is greater than the upper boundary, the upper boundary is determined as the target number for the next meal. When the candidate quantity for the next meal is between the lower and upper boundaries, the candidate quantity for the next meal is determined as the target quantity for the next meal. Based on the unit drive quantity calibration relationship of the feeding actuator, the target quantity of the next meal is converted into a drive sequence, the feeding actuator is controlled to feed according to the drive sequence, and the tank weight sequence is read synchronously. When the increase in trough weight during the feeding process reaches the target amount for the next meal, the drive is stopped. The increase in trough weight at the time of stopping the drive is recorded as the actual feeding amount for this meal, and the actual feeding amount for this meal is used for the calculation of the candidate amount for the next meal.
8. A dynamic adjustment system for individual pig feeding amounts based on pig identification, employing the dynamic adjustment method for individual pig feeding amounts based on pig identification as described in any one of claims 1 to 7, characterized in that: This includes a snout trajectory calibration module, a cross-frame identity verification module, and a feeding amount limiting module; The module is used to acquire continuous images of the feed trough inlet and the trough weight sequence, segment the meal trajectory according to the snout entry and exit sequence, and correct the trough weight drop according to the stable residence interval. The module is used to construct visible area fusion features of meal trajectories, determine the trajectory identity confidence through cross-frame mutual verification, and assign the correction slot weight drop amount when the confirmation conditions are met. The module is used to calculate the candidate amount of the next meal based on the cumulative amount of meals for the corresponding pig, the target daily feed curve, and the trajectory identity confidence level, and then control the feeding after limiting the target amount of the next meal by the boundary of the change between adjacent meals.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method for dynamically adjusting the feeding amount of individual pigs based on individual identification, as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for dynamically adjusting the feeding amount of individual pigs based on individual identification as described in any one of claims 1 to 7.